akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <limits.h>
using namespace std;

int main() {
	int x, a, b, ad, bd;
	cin >> x >> a >> b;
	if (a > x) ad = a - x;
	else ad = x - a;
	if (b > x) bd = b - x;
	else bd = x - b;
	if (ad < bd) cout << "A";
	else cout << "B";
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int inputA = scanner.nextInt();
		int inputB = scanner.nextInt();
		int inputC = scanner.nextInt();
		int inputD = scanner.nextInt();
		scanner.close();

		int result = 0;
		if (inputA < inputB) {
			result += inputA;
		} else {
			result += inputB;
		}
		if (inputC < inputD) {
			result += inputC;
		} else {
			result += inputD;
		}

		System.out.println(result);

	}
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
using namespace std;

#define rep(i,n) for(int i=0 ; i<(n) ; i++)
#define repr(i,n) for(int i=(n) ; i>=0 ; i--)
#define ALL(x) (x).begin(),(x).end()

typedef long long ll;
typedef unsigned long long ull;
 
const ll INF = 1LL<<60;
const int MINF = 1e9;
const int MOD = 1e9+7;

using vi = vector<int>;
using vii = vector<vi>;

template<typename T> bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T> bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

template<typename T>
T GCD(T a,T b){ return b ? GCD(b,a%b) : a ;}
template<typename T>
T LCM(T a,T b){ return a*b / GCD(a,b) ;}

int main(){
    long double l;cin >> l;
    long double ans = l/3 * l/3 * l/3;
    cout << fixed << setprecision(10);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
    
    int n;
    double res, aux;
    cin >> n;

    if( n%2 == 0){
        res = n/2;         
        printf("%.10f\n", res / n);       
    }else if( n == 1){
        printf("1.0000000000");
    }else{
        res = (n-1)/2;
        aux = n - res;         
        printf("%.10f\n", aux / n); 
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define all(h) (h).begin(), (h).end()
using namespace std;
typedef double D;
typedef pair<D,int> pdi;
typedef pair<int,int> pii;
typedef pair<D,pii> pdii;

D dist(pdi a, pdi b){
  return sqrt((a.first-b.first)*(a.first-b.first)+(a.second-b.second)*(a.second-b.second));
}

int main(){
  int n;
  while(cin >> n, n){
    vector<int> x(n),y(n);
    vector<int> h;
    rep(i,n){
      cin >> x[i] >> y[i];
      h.push_back(y[i]);
    }
    sort(all(h));
    h.erase(unique(all(h)),h.end());
    
    vector<pdi> p;
    rep(i,n-1){
      p.push_back(pdi(x[i],y[i]));
      if(y[i] < y[i+1]){
	rep(j,h.size()){
	  if(h[j]<=y[i] || y[i+1]<=h[j])continue;
	  D X = x[i] + (D)(x[i+1]-x[i])*(h[j]-y[i])/(y[i+1]-y[i]);
	  p.push_back(pdi(X,h[j]));
	}
      }else if(y[i] > y[i+1]){
	rrep(j,h.size()){
	  if(h[j]<=y[i+1] || y[i]<=h[j])continue;
	  D X = x[i+1] - (D)(x[i+1]-x[i])*(h[j]-y[i+1])/(y[i]-y[i+1]);
	  p.push_back(pdi(X,h[j]));
	}
      }
    }
    p.push_back(pdi(x[n-1],y[n-1]));

    map<pii,D> d;
    d[pii(0,(int)p.size()-1)] = 0;
    priority_queue< pdii, vector<pdii>, greater<pdii> > q;
    q.push(pdii(0,pii(0,p.size()-1)));
    
    while(q.size()){
      pdii s = q.top(); q.pop();
      D dis = s.first;
      int a = s.second.first, b = s.second.second;
      if(a==b){
	cout << fixed << setprecision(3) << dis << endl;
      	break;
      }
      if(d[pii(a,b)] < dis)continue;
      
      for(int aa=a-1;aa<=a+1;aa++){
	if(aa<0 || aa>=(int)p.size())continue;
	for(int bb=b-1;bb<=b+1;bb++){
	  if(bb<0 || bb>=(int)p.size())continue;
	  if(p[aa].second != p[bb].second)continue;
	  pii np = pii(aa,bb);
	  D ndis = dist(p[a],p[aa]) + dist(p[b],p[bb]) + dis;

	  if(d.count(np)==0 || d[np] > ndis){
	    d[np] = ndis;
	    q.push(pdii(ndis,np));
	  }
	}
      }
    }
  }
}

Measured memory_bytes: 3260
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int e = sc.nextInt();
        int f = sc.nextInt();
        int g = sc.nextInt();
        int h = sc.nextInt();
        int i = sc.nextInt();
        boolean ok = false;
        for (int x = -100; x <= 100; x++) {
            if (a + x == d && b + x == e && c + x == f) {
                ok = true;
                break;
            }
        }
        if (!ok) {
            System.out.println("No");
            return;
        }
        ok = false;
        for (int x = -100; x <= 100; x++) {
            if (g + x == d && h + x == e && i + x == f) {
                ok = true;
                break;
            }
        }
        if (!ok) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }
    }
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
using ll = int_fast64_t;
const int mod = 1e9 + 7;
const int inf = (1 << 30) - 1;
const ll infll = (1LL << 61) - 1;
#define fast() ios::sync_with_stdio(false), cin.tie(nullptr)
#define digit(N) cout << fixed << setprecision((N))
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

// 1 - indexed
template <typename T>
struct BIT
{
   vector<T> bit;

   BIT(int sz) : bit(sz + 1, 0) {}

   // sum of [1, k]
   T sum(int k)
   {
      T res = 0;
      for (int x = k; x > 0; x -= x & -x)
         res += bit[x];
      return res;
   }

   void add(int k, T w)
   {
      for (int x = k; x < bit.size(); x += x & -x)
         bit[x] += w;
   }

   // sum of [x, y)
   T getSum(int x, int y)
   {
      return sum(y - 1) - sum(x - 1);
   }

   // find an index i s.t. a[1] + a[2] + ⋯ + a[x] ≧ w
   T lower_bound(T w)
   {
      if (w <= 0)
         return 0;

      T x = 0;
      int p = 1, N = bit.size();

      while (2 * p <= N)
         p *= 2;

      for (T k = p; k > 0; k /= 2)
      {
         if (x + k <= N && bit[x + k] < w)
         {
            w -= bit[x + k];
            x += k;
         }
      }

      return x + 1;
   }
};

int main()
{
   fast();

   int N, Q;
   cin >> N >> Q;
   vector<int> c(N + 1);
   for (int i = 0; i < N; i++)
      cin >> c[i + 1];

   vector<vector<pair<int, int>>> queries(N + 1, vector<pair<int, int>>());

   for (int i = 0, l, r; i < Q; i++)
   {
      cin >> l >> r;
      queries[l].emplace_back(r, i);
   }

   vector<priority_queue<int, vector<int>, greater<int>>> pos(N + 1);

   for (int i = 1; i <= N; i++)
      pos[c[i]].push(i);

   BIT<int> bit(N);

   for (int i = 1; i <= N; i++)
   {
      if (pos[i].empty())
         continue;
      bit.add(pos[i].top(), 1);
      pos[i].pop();
   }

   vector<int> ans(Q);

   for (int l = 1; l <= N; l++)
   {
      for (auto q : queries[l])
      { // 左端がlのクエリ
         int R = q.first + 1, ind = q.second;
         ans[ind] = bit.getSum(l, R);
      }

      if (pos[c[l]].empty())
         continue;

      int nxt = pos[c[l]].top();
      pos[c[l]].pop();
      bit.add(nxt, 1);
   }

   for (int i = 0; i < Q; i++)
      cout << ans[i] << "\n";
}

Measured memory_bytes: 62588
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

class MainClass : Scanner
{
    static void Main()
    {
        var (N, K) = ReadTuple<int,int>();
        var S = RString();
        var list = new List<int>();
        int now = 0;
        while (now < N)
        {
            int cnt = 0;
            while (now < N && S[now] == '1') { cnt++; now++; }
            list.Add(cnt);
            cnt = 0;
            while (now < N && S[now] == '0') { cnt++; now++; }
            list.Add(cnt);
        }
        list.Add(0);
        var d = new List<int>();
        d.Add(0);
        for (int i = 0; i < list.Count; i++)
        {
            d.Add(d.Last() + list[i]);
        }
        int ans = 0;
        int W = 1 + K * 2;
        if (d.Count < W) ans = d.Last();
        else
        {
            for (int i = 0; i < d.Count-W+1; i+=2)
            {
                ans = Math.Max(ans,d[i+W]-d[i]);
            }
        }
        WriteLine(ans);
    }
}



class Scanner
{
    public static string RString() => Console.ReadLine();
    public static int RInt() => ReadTuple<int>();
    public static long RLong() => ReadTuple<long>();
    public static double RDouble() => ReadTuple<double>();

    public static string[] RStrings() => Console.ReadLine().Split();
    public static int[] RInts() => Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
    public static long[] RLongs() => Array.ConvertAll(Console.ReadLine().Split(), long.Parse);
    public static double[] RDoubles() => Array.ConvertAll(Console.ReadLine().Split(), double.Parse);
    public static int[] RInts(Func<string, int> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static long[] RLongs(Func<string, long> func) => Console.ReadLine().Split().Select(func).ToArray();
    public static double[] RDoubles(Func<string, double> func) => Console.ReadLine().Split().Select(func).ToArray();
    //public static string[] RStrings(Func<string, string> func) => Console.ReadLine().Split().Select(func).ToArray();

    public static T1 ReadTuple<T1>()
    {
        var r = RString();
        var r1 = (T1)Convert.ChangeType(r, typeof(T1));
        return r1;
    }
    public static (T1, T2) ReadTuple<T1, T2>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        return (r1, r2);
    }
    public static (T1, T2, T3) ReadTuple<T1, T2, T3>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
        return (r1, r2, r3);
    }
    public static (T1, T2, T3, T4) ReadTuple<T1, T2, T3, T4>()
    {
        var r = RStrings();
        var r1 = (T1)Convert.ChangeType(r[0], typeof(T1));
        var r2 = (T2)Convert.ChangeType(r[1], typeof(T2));
        var r3 = (T3)Convert.ChangeType(r[2], typeof(T3));
        var r4 = (T4)Convert.ChangeType(r[3], typeof(T4));
        return (r1, r2, r3, r4);
    }
}


Measured memory_bytes: 30232
#include <iostream>
#include<algorithm>
#include<string>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <iomanip>
#include <numeric>
#pragma region Macros
#define int long long
#define double long double
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<=n;i++)
#define LAST(x) x[x.size()-1]
#define ALL(x) (x).begin(),(x).end()
#define swap(a,b) (a += b,b = a - b,a -= b)
#define CEIL(a,b) ((a+b-1)/b)
int FACT(int a) {
	if (a == 0)
		return 1;
	else
		return a * FACT(a - 1);
}
int nPr(int n, int r) {
	int s = n - r + 1;
	int sum = 1;
	for (int i = s; i <= n; i++)
		sum *= i;
	return sum;
}
//int nCr(int n, int r)
int nCr2(int n, int r) {
	return FACT(n) / (FACT(r) * FACT(n - r));
}
int GCD(int a, int b)
{
	if (a < b)
		swap(a, b);
	if (b == 0)
		return a;
	if (a % b == 0)
		return b;
	return GCD(b, a % b);
}
int LCM(int a, int b)
{
	return  a * b / GCD(a, b);
}
//int NUMOFDIV(int n) 素因数分解して+1してかける奴
int NUMOFDIV2(int n) {
	int ans = 0;
	REP(i, n) {
		if (n % i == 0)
			ans++;
	}
	return ans;
}
double LOG(int a, int b) {
	return log(b) / log(a);
}
inline bool BETWEEN(int x, int min, int max) {
	if (min <= x && x <= max)
		return true;
	else
		return false;
}
inline bool PRIMEOR(int x) {
	if (x == 1)
		return false;
	if (x == 2)
		return true;
	if (x % 2 == 0)
		return false;
	double sqrtx = sqrt(x);
	for (int i = 3; i <= sqrtx; i += 2) {
		if (x % i == 0)
			return false;
	}
	return true;
}
bool SQRTOR(int n) {
	if (sqrt(n) == (int)sqrt(n))
		return true;
	else
		return false;
}
using namespace std;
#pragma endregion
signed main() {
	int N, ans = 0,min=1000000,x;
	cin >> N;
	rep(i, N) {
		cin >> x;
		if (x <= min) {
			ans++;
			min = x;
		}
	}
	cout << ans;
}

Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
INF = float("inf")
MOD = 10 ** 9 + 7


def input():
    return sys.stdin.readline().strip()


def main():
    N = int(input())
    A = input()
    B = input()
    C = input()

    ans = 0
    for i in range(N):
        if A[i] == B[i] == C[i]:
            continue
        elif A[i] == B[i] or B[i] == C[i] or C[i] == A[i]:
            ans += 1
        else:
            ans += 2

    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;

int n,a,b,c;
int l[9];
int a0=0,b0=0,c0=0,total_dis = 3000,used_map=0;

void cal_dis(){
	if(a0 && b0 && c0)//不能凭空增加 
		total_dis = min(abs(a0-a)+abs(b0-b)+abs(c0-c)+used_map,total_dis);
}

void dfs(int i){
	
	if(i>n){
		return ;
	}
	//尝试放在a 
	if(a0){
		used_map += 10;
	} 
	a0 += l[i];
	cal_dis();
	dfs(i+1);
	a0 -= l[i];
	if(a0){
		used_map -= 10;	
	}

	
	//尝试放在b 
	if(b0){
		used_map += 10;
	} 
	b0 += l[i];
	cal_dis();
	dfs(i+1);
	b0 -= l[i];
	if(b0){
		used_map -= 10;	
	}
	
	
	//尝试放在c 
	if(c0){
		used_map += 10;
	} 
	c0 += l[i];
	cal_dis();
	dfs(i+1);
	c0 -= l[i];
	if(c0){
		used_map -= 10;	
	}
	
	//尝试都不放
	cal_dis();
	dfs(i+1);
}

int main(){
	cin>>n>>a>>b>>c;
	for( int i=1;i<=n;i++ ){
		cin>>l[i];
	}
	dfs(1);
	cout<<total_dis;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

const int dy[] = {0, 1, -1, 0};
const int dx[] = {-1, 0, 0, 1};
const int INF = INT_MAX / 2;

int main()
{
    int h, w;
    cin >> h >> w;
    vector<string> a(h+2, string(w+2, '#'));

    int sy, sx, gy, gx;
    for(int y=1; y<=h; ++y){
        for(int x=1; x<=w; ++x){
            cin >> a[y][x];
            if(a[y][x] == 'S'){
                sy = y;
                sx = x;
                a[y][x] = '.';
            }
            else if(a[y][x] == 'G'){
                gy = y;
                gx = x;
                a[y][x] = '.';
            }
        }
    }

    priority_queue<tuple<int, int, int> > pq;
    vector<vector<int> > dp(h+2, vector<int>(w+2, INF));
    pq.push(make_tuple(0, sy, sx));
    dp[sy][sx] = 0;

    while(!pq.empty()){
        int cost, y, x;
        tie(cost, y, x) = pq.top();
        pq.pop();
        if(dp[y][x] < cost)
            continue;

        for(int i=0; i<4; ++i){
            int cost2 = cost;
            int y2 = y + dy[i];
            int x2 = x + dx[i];

            if(a[y2][x2] == '.')
                cost2 += 2;
            else if(a[y2][x2] == 'o')
                ++ cost2;
            else
                cost2 = INF;

            if(cost2 < dp[y2][x2]){
                pq.push(make_tuple(cost2, y2, x2));
                dp[y2][x2] = cost2;
            }
        }

        for(int i=0; i<4; ++i){
            for(int j=1; j<=3; ++j){
                int cost2 = cost + 2 + j;
                int y2 = y + dy[i] * j;
                int x2 = x + dx[i] * j;
                if(a[y2][x2] == '#')
                    break;

                if(cost2 < dp[y2][x2]){
                    pq.push(make_tuple(cost2, y2, x2));
                    dp[y2][x2] = cost2;
                }
            }
        }
    }

    cout << dp[gy][gx] << endl;

    return 0;
}

Measured memory_bytes: 1248
#include <bits/stdc++.h>

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t n;
  std::cin >> n;

  std::vector<std::vector<int64_t>> data(10, std::vector<int64_t>(10, 0));

  for (int64_t i = 1; i <= n; i++) {
    const auto tail = i % 10;
    auto j = i;
    while (10 <= j) {
      j /= 10;
    }
    const auto head = j;

    data[head][tail]++;
  }

  int64_t ans = 0;
  for (int64_t i = 1; i <= n; i++) {
    const auto tail = i % 10;
    auto j = i;
    while (10 <= j) {
      j /= 10;
    }
    const auto head = j;
    ans += data[tail][head];
  }

  std::cout << ans << std::endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define pii pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< pii >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define in(x, a, b) ((a) <= (x) && (x) < (b))
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second
#define Decimal fixed << setprecision(10)

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

using Weight = int;
using Flow = int;
struct Edge {
    int s, d; Weight w; Flow c;
    Edge() {};
    Edge(int s, int d, Weight w = 1) : s(s), d(d), w(w), c(w) {};
};
bool operator<(const Edge &e1, const Edge &e2) { return e1.w < e2.w; }
bool operator>(const Edge &e1, const Edge &e2) { return e2 < e1; }
inline ostream &operator<<(ostream &os, const Edge &e) { return (os << '(' << e.s << ", " << e.d << ", " << e.w << ')'); }

using Edges = vector<Edge>;
using Graph = vector<Edges>;
using Array = vector<Weight>;
using Matrix = vector<Array>;

void addArc(Graph &g, int s, int d, Weight w = 1) {
    g[s].emplace_back(s, d, w);
}
void addEdge(Graph &g, int a, int b, Weight w = 1) {
    addArc(g, a, b, w);
    addArc(g, b, a, w);
}

int solve(Graph &g, vi &used, int pos, int hop)
{
    if (used[pos]) return hop;
    used[pos] = 1;
    return solve(g, used, g[pos][0].d, hop+1);
}

signed main()
{
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int2(n, r);
    vector<int> data(n);
    for (int i = 0; i < n; i++) {
        cin >> data[i];
        data[i]--;
    }

    Graph g(n);
    rep(i, data.size()) {
        addArc(g, i, data[i]);
    }

    vi used(n, 0);
    map<int, int> poka;
    rep(i, n) {
        if (!used[i]) {
            poka[solve(g, used, i, 0)]++;
        }
    }

    vi dp(n+1, 0);
    dp[0] = 1;
    for (auto i = poka.begin(); i != poka.end(); i++) {
        int tmp = i->sec;
        for (int k = 1; tmp > 0; k*=2) {
            int key = min(tmp, k);
            tmp -= key;
            for (int j = dp.size()-1; j >= 0; j--) {
                if (j + key * i->fir < dp.size() && dp[j]) 
                    dp[j + key * i->fir] = 1;
            }
        }
    }

    if (dp[r] || dp[n-r]) {
        std::cout << "Yes" << std::endl;
    } else {
        std::cout << "No" << std::endl;
    }


    return 0;
}



Measured memory_bytes: 22896
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <numeric>
#include <algorithm>
#include <utility>


using std::cout;
using std::cin;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;


ll gcd(ll a, ll b) {
    while (b != 0) {
        auto tmp = a;
        a = b;
        b = tmp % a;
    }
    return a;
}

ll lcm(ll a, ll b) {
    return (a * b) / gcd(a, b);
}

int isPrime(int a) {
    for (int i = 2; i * i <= a; ++i) {
        if (a % i == 0) {
            return 0;
        }
    }
    return 1;
}





void oneCase () {
    int r, g, b;
    cin >> r >> g >> b;
    if ((g * 10 + b) % 4  == 0) {
        cout << "YES" << "\n";
    } else {
        cout << "NO" << "\n";
    }
}




int main() {
    int t = 1;
//    cin >> t;
    while (t > 0) {
        oneCase();
        --t;
    }

    return 0;
}

Measured memory_bytes: 256
x,y = map(int,input().split())
flag = 0
for i in range(x+1):
  if (y - 2*i)%4 == 0 and (y -  2 * i)//4 == x - i:
    flag += 1
    print("Yes")
    break
if flag == 0:
  print("No")

Measured memory_bytes: 9024
s = list(input())
t = list(input())
s.sort()
t.sort(reverse=True)
for ss, tt in zip(s, t):
    if ss<tt:
        print('Yes')
        break
    elif ss>tt:
        print('No')
        break
else:
    if len(s)<len(t):
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm> 
#include <queue>
#include <functional>
#include <map>
#include <string>
using namespace std;
typedef long long ll;


int main(void){
    string s;
    cin >> s;

    bool flag = false;
    for (int i = 0; i < 4; i++){
        if (s[i] == 'A'&&s[i + 1] == 'C'){
            flag = true;
        }
    }

    if (flag){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
using namespace __gnu_pbds;
using namespace std;
/*
int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
*/
#define ull unsigned long long int
#define ll long long int
#define ld long double
#define MAX 1000000007
//1e9+7
#define pll pair<ll,ll>
#define pii pair<int,int>
#define piii pair<int,pii>
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FO ifstream fin("a.in");ofstream fout("a.out");
#define TEST int testcase;cin>>testcase;while(testcase--)
#define FTEST int testcase;fin>>testcase;while(testcase--)
#define all(x) (x).begin(),(x).end()
#define mset0(x) memset((x), 0, sizeof((x)));
#define mset1(x) memset((x), -1, sizeof((x)));
#define endl "\n"
#define plll pair<ll,pll>
#define plii pair<ll,pii>
#define no {cout<<"no"<<endl;return;}
#define yes {cout<<"yes"<<endl;}
#define rep(i,N) for(int i=0;i<N;i++)
const int maxn=1e6;
const int mod=998244353;
typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag, tree_order_statistics_node_update> ordered_set;
int n,q,k,c=0;
pii arr[maxn+1];
ll A,B,g;
void solve(){
    cin>>A>>B;
    g=__gcd(A,B);
    if(g==1){cout<<1;return;}

    int ans=1;
    //cout<<g<<endl;
    if(g%2==0){
        ans++;
        //cout<<2<<endl;
        while(g%2==0) g/=2;
    }
    //cout<<g<<endl;
    for(ll x=3;x*x<=g;x+=2){
        if(g%x==0){
            ans++;
            //cout<<x<<endl;
            while(g%x==0) g/=x;
        }
    }
    if(g>1) ans++;
    cout<<ans;
    return;
}
int main(){
    IO
    //TEST
    solve();

    return(0);
}
/*
1
aabce
ace
*/


Measured memory_bytes: 3600
#include<iostream>
#include<stdlib.h>
#include<algorithm>
using namespace std;

int main()
{
	int n,w[100];
	cin>>n;
	int sum=0;
	for(int i=0;i<n;i++){
		cin>>w[i];
		sum+=w[i];
	}
	
	int ans=sum,v=0;
	for(int i=0;i<n;i++){
		v+=w[i];
		int t=abs(sum-2*v);
		ans=min(ans,t);
	}
	
	cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 384
n,m = map(int,input().split())
if n<2:
    if m<2:
        print(0)
    else:
        print((m*(m-1))//2)
else:
    if m<2:
        print((n*(n-1))//2)
    else:
        print(((m*(m-1))//2) + ((n*(n-1))//2))

Measured memory_bytes: 38256
#include<iostream>
using namespace std;

inline bool kaibun(int number)
{
    bool ans = false;
    if(number/10000==number%10){
        if(number/1000-(number/10000)*10==(number%100-number%10)/10){
            ans = true;
        }
    }
    return ans;
}

int main()
{
    int A,B;
    int ans=0;
    cin>>A>>B;
    for(int i=A; i<=B; i++){
        if(kaibun(i))ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<cmath>
#include<map>

using namespace std;

int main(){
    long long  x,p=0;
    cin >> x;

    for(long long int k=100;k<x;){
        k=1.01*k; 
        p++;
    }

    cout << p << endl;




    return 0;
}

Measured memory_bytes: 3676
// Created by Kshitij Anand NSIT
#include <bits/stdc++.h>
//#include <ext/numeric>
//using namespace __gnu_cxx;


using namespace std;


#define int long long
#define pb push_back
#define P pair<int,int>
#define F first
#define S second
#define vi vector<int>
#define vc vector<char>
#define vb vector<bool>
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define mp(a, b) make_pair(a, b)
#define min3(a, b, c) min(min(a, b), c)
#define min4(a, b, c, d) min(min(a, b), min(c, d))
#define max3(a, b, c) max(max(a, b), c)
#define max4(a, b, c, d) max(max(a, b), max(c, d))
#define fill(arr,val) memset(arr,val,sizeof(arr))
#define inf 1e18
#define ps(x,y) fixed<<setprecision(y)<<x
#define db(x)  cout<<#x<<" : "<<x<<endl


const int N = 1000000007;

void solve(){

    int n,a,b,c, ans=0, count=0, sum=0;
    cin>>n;
    
    int rem = 0;

    while(count<= n){
        count++;
        rem = (rem*10 + 7)%n;

        if(rem == 0){

            cout<<count<<endl;

            return ;
        }

    }  

    cout<<-1<<endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    
  //  int t; cin>>t; while(t--)
    {     
      solve();
    }

  return 0;
}


Measured memory_bytes: 3652
import sys

N=int(input())
a=[[0,0,0]]+[list(map(int,input().split())) for i in range(N)]

for i in range(N):
    dt,dx,dy=[a[i+1][j]-a[i][j] for j in range(3)]
    if abs(dx)+abs(dy)>dt or (abs(dx)+abs(dy)-dt)%2!=0:
        print("No")
        sys.exit()
print("Yes")

Measured memory_bytes: 28148
#include<stdio.h>
int main(void){
    int n,x,y;
    int a,b,c;
    int ans;
    while(1){
        scanf("%d %d",&n,&x);
        if(n==0 && x==0){
            break;
        }
        ans=0;
        y=x;
        if(y>n){
            y=n;
        }
        for (a=1;a<=y;a++){
			for (b=a+1;b<=y;b++){
				c=x-a-b;
				if (c>b && c<=n){
				    ans++;
				}
			}
		}
		printf("%d\n",ans);
    }
    return 0;
}


Measured memory_bytes: 2052
#include <iostream>
#include <cstring>

using namespace std;

const int MaxN = 100005;

long long n, cost0, cost1;
long long v[MaxN], pSum[MaxN], auxV[MaxN];

long long CalcCost(long long currV[]) {
  long long ans = 0;
  memset(pSum, 0, sizeof pSum);
  pSum[1] = currV[1];
  for (int i = 2; i <= n; ++i) {
    pSum[i] = pSum[i - 1] + currV[i];

    if (pSum[i - 1] > 0 and pSum[i] >= 0) {
      pSum[i] = -1;
      ans += currV[i] - (- 1 - pSum[i - 1]);
      currV[i] = - 1LL - pSum[i - 1];
//      --currV[i];
//      pSum[i] = pSum[i - 1] + currV[i];
//      ++ans;
    }

    if (pSum[i - 1] < 0 and pSum[i] <= 0) {
      pSum[i] = 1;
      ans += -(currV[i] - (1 - pSum[i - 1]));
      currV[i] = 1LL - pSum[i - 1];
//      ++currV[i];
//      pSum[i] = pSum[i - 1] + currV[i];
//      ++ans;
    }
  }

  return ans;
}

inline void ResetV() {
  for (int i = 1; i <= n; ++i) {
    v[i] = auxV[i];
  }
}

int main() {
  cin >> n;
  for (int i = 1; i <= n; ++i) {
    cin >> v[i];
    auxV[i] = v[i];
  }

  if (v[1] < 0) {
    cost1 = CalcCost(v);
    ResetV();
    if (v[1] <= 0) {
      cost0 = 1 - v[1];
      v[1] = 1;
    }

    cost0 += CalcCost(v);
  }
  else if (v[1] > 0) {
    cost0 = CalcCost(v);
    ResetV();
    if (v[1] >= 0) {
      cost1 = v[1] + 1;
      v[1] = -1;
    }
    cost1 += CalcCost(v);
  }
  else {
    v[1] = 1;
    cost0 = 1 + CalcCost(v);
    ResetV();
    v[1] = -1;
    cost1 = 1 + CalcCost(v);
  }

  cout << min(cost0, cost1) << '\n';
  return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    string s;
    cin >> s;
    ll n = len(s);
    vector<ll> idx;
    rep(i, n - 1) {
        if ((s[i] == 'R') && (s[i + 1] == 'L')) idx.push_back(i);
    }
    vector<ll> ans(n, 0);
    rep(i, n) {
        auto it = lower_bound(all(idx), i);
        if (s[i] == 'L') it--;
        ll dist = *it - i;
        if (dist % 2 == 0) ans[*it]++;
        else ans[*it + 1]++;
    }
    rep(i, n) printf("%lld%s", ans[i], (i == (n - 1)) ? "\n" : " ");
    return 0;
}


Measured memory_bytes: 1864
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

const ll MOD = 998244353;
const int N = 3000006;

ll fat[N];

ll pot(ll b, ll e){
	ll ans = 1; b %= MOD;
	while(e){
		if(e & 1) ans = (ans * b) % MOD;
		b = (b * b) % MOD;
		e /= 2;
	}
	return ans;
}

ll C(int n, int k){
	return (fat[n] * pot(fat[k] * fat[n-k], MOD-2)) % MOD;
}

int n;
ll a, b, k;

int main(){

	fat[0] = 1;
	for(int i = 1; i < N; i++) fat[i] = (i * fat[i-1]) % MOD;

	scanf("%d %lld %lld %lld", &n, &a, &b, &k);

	ll ans = 0;
	for(int c = 0; c <= n; c++){
		ll lef = k - c * a;
		if(lef < 0 || lef % b) continue;
		ll d = lef / b;
		if(d > n) continue;
		ans = (ans + C(n, c) * C(n, d)) % MOD;
	}

	printf("%lld\n", ans);

}

Measured memory_bytes: 23808
#include<stdio.h>
int main(void){
   char x[1000];
   int sum;
   int i;
   int b;

   b=10;
   scanf("%s",&x);
   while(x[0]!='0'){
      sum=0;
      for(i=0;x[i]!='\0';i++){
         sum += x[i]-'0';
      }
      printf("%d\n",sum);
      scanf("%s",&x);
   }
   return 0;
}

Measured memory_bytes: 536
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    String march="MARCH";
    long[] a=new long[6];
    for(int i=0;i<n;i++){
      a[march.indexOf(sc.next().charAt(0))+1]++;
    }
    long ans=0; 
    for(int i=1;i<=3;i++){
      for(int j=i+1;j<=4;j++){
        for(int k=j+1;k<=5;k++){
          ans+=a[i]*a[j]*a[k];
        }
      }
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 45724
n, m = gets.split.map(&:to_i)
broken = Array.new(n, false)
m.times {
    a = gets.to_i
    broken[a - 1] = true
}

step = []
if !broken[0] then
    step[0] = 1
else
    step[0] = 0
end

if n == 1 then
    puts step[0]
    exit
end

if !broken[1] then
    step[1] = step[0] + 1
else
    step[1] = 0
end

2.upto(n - 1).each {|i|
    if !broken[i] then
        step[i] = step[i - 1] + step[i - 2]
        step[i] %= 1000000007
    else
        step[i] = 0
    end
}

puts step.last


Measured memory_bytes: 3784
# -*- coding: utf-8 -*-
import numpy as np

def solve():
    N, K = map(int, input().split())
    C = np.array(list(map(int,input().split())))
    z = (C<0).sum()
    D = set()
    for i in range(N-K+1):
        l = -min(C[i],0)
        r = max(C[i+K-1],0)
        d = 2*l+r if l < r else 2*r+l
        D.add(d)
    return str(min(D))

if __name__ == '__main__':
    print(solve())




Measured memory_bytes: 23092
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(x)(x).begin(), (x).end() // 昇順ソート
#define rall(v)(v).rbegin(), (v).rend() // 降順ソート
#define INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair < ll, ll >
#define F first
#define S second
const int MOD = 1000000007;
template < class T > bool chmax(T & a,const T & b) { if (a < b) { a = b; return true; } return false; }
template < class T > bool chmin(T & a,const T & b) { if (a > b) { a = b; return true; } return false; }
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

auto GCD(auto a, auto b) { //ユークリッドの互助法で最大公約数
    if(a % b == 0)return b;
    else return GCD(b, a % b);
}
auto LCM(auto a, auto b) { //GCDを使って最小公倍数を求める
    auto g = GCD(a, b);
    return (a / g) * b;
}


int main() {
    LL N,K;cin >> N >> K;
    vector<LL> A(N);rep(i,N)cin >> A[i];
    sort(all(A));

    LL G = A[0];
    rep(i,N)G = GCD(G,A[i]);

    if(K > A[N-1])cout << "IMPOSSIBLE" << endl;
    else{
        if(K % G == 0)cout << "POSSIBLE" << endl;
        else cout << "IMPOSSIBLE" << endl;
    }


}

Measured memory_bytes: 1024
A,V=list(map(int,input().split(' ')))
B,W=list(map(int,input().split(' ')))
T=int(input())
if A<B:
    if A+T*V>= B+T*W:
        print('YES')
    else:
        print('NO')
if A>B:
    if A-T*V<= B-T*W:
        print('YES')
    else:
        print('NO')

Measured memory_bytes: 9192
//g++  5.4.0

#include <bits/stdc++.h>

using namespace std;

const long long INF = 1e18+5;

int main()
{
   int n; cin >> n;
   
    vector<int> arr(n);
    for(int i = 0; i < n; i++) cin >> arr[i];
    
    vector<long long> pre_sum(n+1,0);
    long long s = 0;
    for(int i = 0; i < n; i++){
        s += arr[i];
        pre_sum[i] = s;
    }
    
    auto f = [&](int L, int R){
        if(L == 0) return pre_sum[R];
        else return pre_sum[R] - pre_sum[L-1];
    };
    
    long long dp[405][405];
    
    for(int L = n-1; L >= 0; L--){
        for(int R = L; R <= n-1; R++){
            if(L == R){
                dp[L][R] = 0;
            }
            else{
                dp[L][R] = INF;
                long long sum = f(L,R);
                for(int i = L; i < R; i++){
                    dp[L][R] = min(dp[L][R], dp[L][i] + dp[i+1][R] + sum);
                }
            }
        }
    }
    
    cout << dp[0][n-1] << endl;
}

Measured memory_bytes: 1536
import collections
n = int(input())
si = []
for i in range(n):
    si.append(input())
ss = collections.Counter(si)

n_ma = max(ss.values())
ans = []
for i in ss.keys():
    if ss[i] == n_ma:
        ans.append(i)

ans.sort()
for i in range(len(ans)):
    print(ans[i])

Measured memory_bytes: 100460
#define ll long long int
#include <bits/stdc++.h>
//#include <fstream>
using namespace std;
 
#define         ff               first
#define         ss               second
#define         mp               make_pair
#define         pb               push_back
#define         pf               push_front
#define         vi               vector<ll>
#define         pii              pair<ll,ll>
#define         qi               queue<ll>
#define         mem(a,b)         memset(a,b,sizeof(a))
#define         print(a)         cout<<a<<'\n'
#define         sorted(arr)      sort(arr.begin(),arr.end())
#define         gcd(a,b)         gcd((a),(b))
#define         lcm(a,b)         ((a)*(b))/gcd((a),(b))
#define         all(v)           v.begin(),v.end()
#define         read(a)          scanf("%d", &a)
#define         f(a,n)           for(ll i=a;i<n;i++)
#define         in2(n,m,arr)     for(ll i=0;i<n;i++){for(ll j=0;j<m;j++)cin>>arr[i][j];}
#define         debug(a)         cerr<<a<<" ";
#define         debug1(a)        cerr<<a<<'\n'
 
/*typedef tree<int, null_type, less<int>, rb_tree_tag , tree_order_statistics_node_update> Set;*/
 
 
const unsigned ll mod = 1e9 + 7 ;
const ll inf = (ll)1e18 + 2;
const ll N = (ll)1e6 + 2;
//
//template<typename... T>
//void write(T&... args)
//{
//    ((cout << args << ' '), ...);
//}
//ll power ( ll x , ll y)
//{
//    ll res = 1;
//    while (y > 0)
//    {
//        if (y & 1)
//            res = (res * x) ;
//        y = y >> 1;
//        x = (x * x) ;
//    }
//    return res  ;
//}
//
//struct node{
//    ll x , y , z;
//};
//map<pair<ll, ll>,ll> c;
//vector<set<ll>> tree;
//vector<ll> ar ;
//set<ll> s;
//ll get(ll x)
//{
//    if(x == ar[x])
//        return x;
//    return ar[x] = get(ar[x]);
//}
//void merge(ll a ,ll b)
//{
//    a = get(a);
//    b = get(b);
//    if(a == b)
//    {
//        return ;
//    }
//    ar[b] = ar[a];
// }
//
//ll sev[100006];
//vector<ll> pri;
//void seive()
//{
//    for(ll i = 2 ; i < 100006 ; i ++)
//    {
//        if(!sev[i])
//        {
//            for(ll j = i ; j < 100006 ; j += i)
//            {
//                if(!sev[j])
//                    sev[j] = i;
//            }
//        }
//        if(sev[i] == i)
//            pri.pb(i);
//    }
//}
void solve()
{
    string s1 , s2;
    cin >> s1 >> s2;
    ll n , m ;
    cin >> n >> m;
    string s3;
    cin >> s3;
    if(s3 == s1)
        n --;
    else if(s3 == s2)
        m --;
    cout << n << " " << m << '\n';
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll t ;
    t = 1;
    //cin >> t;
    //seive();
    while(t --)
    {
        solve();
    }
    cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    return 0;
}
 


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <complex>

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define EQ(a,b) (abs((a)-(b))<eps)

using namespace std;

typedef long double ld;
typedef complex<ld> P;
typedef vector<P> VP;
const ld eps = 1e-8, pi = acos(-1.0);


ld dot (P a, P b) { return real(conj(a) * b); }
ld cross (P a, P b) { return imag(conj(a) * b); }

class L{
public:
  P a, b;
  L (P aa, P bb) { a = aa; b = bb; }
  L (ld ax, ld ay, ld bx, ld by) { a = P(ax, ay); b = P(bx, by); }
};

bool isis_sp(L s, P p) {
  return abs(s.a - p) + abs(s.b - p) - abs(s.b - s.a) < eps;
}

VP is_ll(L s, L t){
  VP v;
  P sv = s.b - s.a, tv = t.b - t.a;
  if (abs(cross(sv,tv)) > 0)
    v.push_back(s.a + sv * cross(tv, t.a - s.a) / cross(tv, sv));
  return v;
}

int main() {
  int m;
  cin >> m;
  REP(i,m) {
    ld xa,ya,xb,yb;
    cin >> xa >> ya >> xb >> yb;
    P s(xa,ya), t(xb,yb);
    L nl(s,t);
    int n;
    cin >> n;
    vector<L> vl;
    VP crt;
    VP crb;
    REP(j,n){
      double xs, ys, xt, yt;
      int o,l;
      cin >> xs >> ys >> xt >> yt >> o >> l;
      P sj(xs,ys), tj(xt,yt);
      L lj(sj,tj);
      VP vp = is_ll(nl,lj);
      if(!vp.empty()){
        if(isis_sp(nl,vp[0]) && isis_sp(lj,vp[0])){
          if(o == l)
            crt.push_back(vp[0]);
          else
            crb.push_back(vp[0]);
        }
      }
    }
    sort(begin(crt),end(crt), [&](P l, P r){ return norm(l-s) < norm(r-s); });
    sort(begin(crb),end(crb), [&](P l, P r){ return norm(l-s) < norm(r-s); });
    int k=0;
    int cnt = 0;
    REP(j,crt.size()){
      bool b = false;;
      while(k<crb.size() && norm(crb[k]-s) < norm(crt[j]-s)) {
        ++k;
        b = true;
      }
      if(b) {
        if (j)
          cnt += 2;
        else
          cnt += 1;
      }
    }
    if (k < crb.size() && !crt.empty())
      cnt += 1;
    cout << cnt << endl;
  }
  return 0;
}

Measured memory_bytes: 1284
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
#include<cmath>
#include<stack>
#include <algorithm>
#include <functional>
//#include<stdlib.h>
using namespace std;
int main() {
	double  w, h, x, y,a;
	cin >>w>>h>>x>>y;
	a = (w * h) / 2.0;
	cout << a<<' '<<(((w/2.0!=x)|| (h / 2.0 != y))?0:1);
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
using namespace std;
int main(){
  int n, m, k;
  while(cin >> n >> m >> k, n){
    long long int prob[n*m+1];
    fill(prob,prob+n*m+1,0LL);
    fill(prob+1,prob+m+1,1LL);
    //prob[0] = 1;
    long long int t = m;
    for(int i = 1; i < n; ++i){
      t *= m;
      int acum[m*(i+1)+1];
      fill(acum,acum+m*(i+1)+1,0);
      //cout << "acum = ";
      for(int j = 0; j <= m*(i+1); ++j){
	acum[j+1] = acum[j]+prob[j];
	//cout << acum[j] << " ";
      }//cout << acum[m*(i+1)] << endl;
      //cout << "prob = ";
      for(int j = 0; j < i; ++j) prob[j] = 0;
      for(int j = i; j <= m*(i+1); ++j){
	prob[j] = acum[j] - acum[max(0,j-m)];
	//cout << prob[j] << " ";
      }//cout << endl;;
    }
    double ans = 0.0;
    for(int i = n; i <= n*m; ++i){
      ans += (double)max(1,i-k)*prob[i]/t;
    }
    printf("%.12f\n",ans);
  }
  return 0;
}

Measured memory_bytes: 3272
import itertools
s = list(input())
for op in itertools.product(range(2), repeat=3):
    ans = int(s[0])
    for i in range(3):
        if op[i] == 1:
            ans += int(s[i+1])
        else:
            ans -= int(s[i+1])
    if ans == 7:
        break

for i,j in zip(s,op):
    if j == 1:
        j = '+'
    else:
        j = '-'
    print(str(i)+j,end='')
print(s[-1]+'=7')


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;

int main() {
  int N, A, B, x1, x2;
  cin >> N >> A >> B;
  x1 = A * N;
  x2 = B;
  if (x1 <= x2) {
    cout << x1 << endl;
  }
  else {
    cout << x2 << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
	int n;
	cin >> n;
	int mx = 0;
	map<string, int> mp;
	rep (i, n) {
	  string s;
	  cin >> s;
	  mp[s]++;
	  mx = max(mx, mp[s]);
	}
	for (auto m: mp) {
	  if (m.second == mx) cout << m.first << endl;
	}
    
    return 0;
}



Measured memory_bytes: 19252
////=====BIsmillahir Rahmanir Rahim =====////

/*                        ______
 _______   /\     |``\   |        |  /
    |     /  \    |__/   |____    |/
    |    / _ _\   |  \   |        |\
    |   /      \  |   \  |______  |  \

            Dept. of CSE
         Comilla University

*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define fi 2*acos(0.0)
#define ee 2.71828
#define ll  long long
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define Node struct node
#define spc " "
#define  E  2.71828182845904523536
#define pb push_back
#define pp pop_back
#define ff first
#define ss second
#define valid(nx,ny) nx>=0 && nx<n && ny>=0 && ny<m
#define edl printf("\n")
#define infinity 1e16
#define mod 1000000007
#define cn continue
#define csprint1 printf("Case %lld: ", cs++)
#define csprint2 printf("Case %lld:\n", cs++)
#define sf(a) scanf("%lld", &a)
#define sff(a,b) scanf("%lld %lld",&a,&b)
#define sfff(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define sffff(a,b,c,d) scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define all(v) v.begin(),v.end()
#define pfn(a) printf("%lld\n",a)
#define pfs(a) printf("%lld ",a)

using namespace __gnu_pbds;
using namespace std;
typedef pair<ll, ll> pl;
typedef vector<int> vi;
typedef vector<pl> vpi;
typedef vector<pl> vpl;
typedef tree<pair<ll, int> , null_type, less<pair<ll, int> >, rb_tree_tag, tree_order_statistics_node_update> ost;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
    cerr << *it << " = " << a <<","<< spc;
    err(++it, args...);
    cout<<edl;
}
///Bit manipulation

bool checkbit(int mask,int bit){return mask & (1<<bit);}
int setbit(int mask,int bit){ return mask | (1<<bit) ; }
int clearbit(int mask,int bit){return mask & ~(1<<bit);}
int togglebit(int mask,int bit){return mask ^ (1<<bit);}
int bitno(int mask) {return (int)__builtin_popcount(mask);}

/*----------------------Graph Moves----------------*/
const int fx[]={+1,-1,+0,+0};
const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*------------------------------------------------*/

///=====================================///

const int  maX=1e5+10;
ll M = 10000007;
int main() {
    ll n;sf(n);
    ll ara[n];
    for(ll i=0;i<n;i++)sf(ara[i]);
    ll sum=0;
    ll dp[maX];
    dp[n-1]=0;
    for(ll i=n-2;i>=0;i--){
        ll x,y;
        x=dp[i+1]+abs(ara[i]-ara[i+1]);
        y=infinity;
        if(i+2<n){
            y=dp[i+2]+abs(ara[i]-ara[i+2]);
        }
        //cout<<x<<spc<<y<<endl;
        dp[i]=min(x,y);
    }
    pfn(dp[0]);
return 0;
}


Measured memory_bytes: 5320
#include <bits/stdc++.h>

using namespace std;

int main()
{
    int n,m;
    set <int> a,b;
    cin>>n;
    while(n--)
    {
        int x;
        cin>>x;
        a.insert(x);
    }
    cin>>m;
    while(m--)
    {
        int x;
        cin>>x;
        b.insert(x);
    }
    vector <int> c;
    set_difference(a.begin(),a.end(),b.begin(),b.end(),back_inserter(c));
    for(int i=0;i<c.size();i++)
    {
        cout<<c[i]<<endl;
    }
    return 0;
}



Measured memory_bytes: 22636
#include <iostream>
#include <string>
#include <vector>
using namespace std;

string kansu( string s, string t ) {

  if ( s.size() > t.size() ) return s;
  if ( s.size() < t.size() ) return t;

  for ( long long int i = 0; i < s.size(); i++ ) {
    if ( s[i] > t[i] ) return s;
    if ( s[i] < t[i] ) return t;
  }

  return s;

}

int main() {

  while( true ) {

    long long int w, h;
    cin >> w >> h;
    if ( w == 0 ) break;

    vector< string > c;

    for ( long long int i = 0; i < h; i++ ) {

      string in;
      cin >> in;
      c.push_back( in );

    }

    vector< vector< string > > m;
    for ( long long int i = 0; i < h+1; i++ ) {
      vector< string > m2;
      for ( long long int j = 0; j < w+1; j++ ) {
	m2.push_back( "" );
      }
      m.push_back( m2 );
    }

    string ans = "";

    for ( long long int y = 0; y < h; y++ ) {
      for ( long long int x = 0; x < w; x++ ) {

	if ( '0' <= c[y][x] && c[y][x] <= '9' ) {

	  if ( c[y][x] == '0' && m[y][x] == "" ) {
	  }else {
	    string k = m[y][x] + c[y][x];
	    m[y+1][x] = kansu( m[y+1][x], k );
	    m[y][x+1] = kansu( m[y][x+1], k );
	    ans = kansu( ans, k );
	  }

	}

      }
    }

    cout << ans << endl;

  }

  return 0;

}

Measured memory_bytes: 1352
<?php
fscanf(STDIN, "%d", $format);

$former = floor($format / 100);
$latter = $format % 100;
$YYMM = FALSE;
$MMYY = FALSE;

if ($former <= 12 && $former > 0) $MMYY = TRUE;
if ($latter <= 12 && $latter > 0) $YYMM = TRUE;

if ($YYMM && $MMYY) echo "AMBIGUOUS\n";
else if ($YYMM) echo "YYMM\n";
else if ($MMYY) echo "MMYY\n";
else echo "NA\n";


Measured memory_bytes: 4604
N = int(input())
S = [input() for i in range(N)]

table = {}
for Si in S:
    table[Si] = 1 if table.get(Si) is None else table.get(Si) + 1

maximum = max(table.values())

answer = []
for key, value in table.items():
    if value != maximum: continue
    
    answer.append(key)
answer.sort()
answer = "\n".join(answer)


print(answer)


Measured memory_bytes: 35592