akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <queue>
#include <tuple>
#include <bitset>
#include <map>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
typedef pair<int,int> P;
const int inf = 1012345678;
int dx[] = {1,-1,0,0};
int dy[] = {0,0,1,-1};
int N;

int main(){
  int A , B;
  cin >> A >> B;
  if((A+B)%2 == 0){
    cout << (A+B)/2 << endl;
  }
  else{
    cout << "IMPOSSIBLE" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
import math

# 入力
A,B = (int(x) for x in input().split())

LA = list(range(math.ceil(12.5*A),math.ceil(12.5*(A+1))))
LB = list(range(math.ceil(10*B),math.ceil(10*(B+1))))

intersect = set(LA) & set(LB)

if intersect == set():
    print(-1)
else:
    print(min(intersect))


Measured memory_bytes: 3060
H,W,K = list(map(int,input().split()))

goal = [0 for i in range(W)]
goal[0] = 1
oldGoal = [0 for i in range(W)]
oldGoal[0] = 1
fib = [1, 1, 2, 3, 5, 8, 13, 21, 34]

if W == 1:
    print(1)
    exit()

for i in range(H):
    for j in range(W):
        if j == 0:
            a1 = oldGoal[j] * fib[W-1]
            a2 = oldGoal[j+1] * fib[W-2]
            a1 = a1 % 1000000007
            a2 = a2 % 1000000007
            goal[j] = a1 + a2
        elif j == W - 1:
            a1 = oldGoal[j-1] * fib[W-2]
            a2 = oldGoal[j] * fib[W-1]
            a1 = a1 % 1000000007
            a2 = a2 % 1000000007
            goal[j] = a1 + a2
        else:
            a1 = oldGoal[j-1] * fib[j-1] * fib[W-j-1]
            a2 = oldGoal[j] * fib[j] * fib[W-j-1]
            a3 = oldGoal[j+1] * fib[j] * fib[W-j-2]
            a1 = a1 % 1000000007
            a2 = a2 % 1000000007
            a3 = a3 % 1000000007
            goal[j] = a1 + a2 + a3
    for k in range(W):
        oldGoal[k] = goal[k]
print(goal[K-1] % 1000000007)

Measured memory_bytes: 9292
import copy

class Dice:
    def __init__(self, numbers):
        self.dd = dict(zip(['U', 'S', 'E', 'W', 'N', 'B'], numbers))

    def next(self, o):
        old = copy.deepcopy(self.dd)
        if o == 'E':
            self.dd['B'] = old['E']
            self.dd['U'] = old['W']
            self.dd['E'] = old['U']
            self.dd['W'] = old['B']
        elif o == 'S':
            self.dd['B'] = old['S']
            self.dd['U'] = old['N']
            self.dd['S'] = old['U']
            self.dd['N'] = old['B']
        elif o == 'W':
            self.dd['B'] = old['W']
            self.dd['U'] = old['E']
            self.dd['E'] = old['B']
            self.dd['W'] = old['U']
        elif o == 'N':
            self.dd['B'] = old['N']
            self.dd['U'] = old['S']
            self.dd['S'] = old['B']
            self.dd['N'] = old['U']

dn = [int(n) for n in input().split()]
op = input()
ad = Dice(dn)

for o in op:
    ad.next(o)

print(ad.dd['U'])

Measured memory_bytes: 8216
a, b, k = map(int, input().split())

if 2*k >= b-a+1:
    for i in range(a, b+1):
        print(i)
else:
    for i in range(a, a+k):
        print(i)
    for j in range(b-k+1, b+1):
        print(j)


Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
string S;long long power[11];
int main(){
    power[0]=1;for(int i=1;i<11;i++)power[i]=power[i-1]*10;
    cin>>S;int a[10]={0,1,2,3,4,5,6,7,8,9};
    long long X=0;string Y="";
    do{
        long long P1=stoll(S);
        long long P2=0;
        for(int i=0;i<S.size();i++){
            P2+=power[i]*a[i];
        }
        long long SA=min(abs(P1-P2),power[S.size()]-abs(P1-P2));
        string G="";for(int i=0;i<S.size();i++){G+=(char)('0'+a[S.size()-1-i]);}
        if(SA>X || (SA==X && Y>G)){X=SA;Y=G;}
    }while(next_permutation(a,a+10));
    cout<<Y<<endl;
    return 0;
}

Measured memory_bytes: 3164
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define Ans(f, y, n) if(f) cout << y << endl; else cout << n << endl;
#define int long long
#define INF 1000000000000000000
using namespace std;

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
template<typename T>
void debug(vector<vector<T>> m){ REP(i, m.size()){ REP(j, m[i].size()){ cout << m[i][j] << ","; } cout << endl;} }



signed main(){

    int N, M, Q; cin >> N >> M >> Q;
    vector<string> S(N); readv(S);

    mat c1(N + 1, vec(M + 1, 0)), c2(N + 1, vec(M + 1, 0)), c3(N + 1, vec(M + 1, 0));

    REP(i, N) REP(j, M) if(S[i][j] == '1') c1[i + 1][j + 1]++;
    REP(i, N + 1) REP(j, M) c1[i][j + 1] += c1[i][j];
    REP(j, M + 1) REP(i, N) c1[i + 1][j] += c1[i][j];

    REP(i, N) REP(j, M - 1) if(S[i][j] == '1' && S[i][j + 1] == '1') c2[i + 1][j + 1]++;
    REP(i, N + 1) REP(j, M) c2[i][j + 1] += c2[i][j];
    REP(j, M + 1) REP(i, N) c2[i + 1][j] += c2[i][j];

    REP(i, N - 1) REP(j, M) if(S[i][j] == '1' && S[i + 1][j] == '1') c3[i + 1][j + 1]++;
    REP(i, N + 1) REP(j, M) c3[i][j + 1] += c3[i][j];
    REP(j, M + 1) REP(i, N) c3[i + 1][j] += c3[i][j];

    int x1, x2, y1, y2;
    REP(q, Q){
        cin >> x1 >> y1 >> x2 >> y2;
        int v1 = c1[x2][y2] - c1[x2][y1 - 1] - c1[x1 - 1][y2] + c1[x1 - 1][y1 - 1];
        int v2 = c2[x2][y2 - 1] - c2[x2][y1 - 1] - c2[x1 - 1][y2 - 1] + c2[x1 - 1][y1 - 1];
        int v3 = c3[x2 - 1][y2] - c3[x2 - 1][y1 - 1] - c3[x1 - 1][y2] + c3[x1 - 1][y1 - 1];
        cout << v1 - v2 - v3 << endl;
    }
    
    return 0;
}

Measured memory_bytes: 101120
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;


class Program
{
    static void Main(string[] args)
    {
        // 入力
        //var s = Console.ReadLine();
        //var n = int.Parse(Console.ReadLine());
        int[] hwk = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var h = hwk[0];
        var w = hwk[1];
        var k = hwk[2];

        char[][] s = new char[h][];
        for (int i = 0; i < h; i++)
        {
            s[i] = Console.ReadLine().ToCharArray();
        }

        int[][] ans = new int[h][];
        for (int i = 0; i < h; i++)
        {
            ans[i] = new int[w];
        }

        var count = 1;
        for (int i = 0; i < h; i++)
        {
            var skip = true;
            var start = 0;
            for (int j = 0; j < w; j++)
            {
                if (s[i][j] == '#')
                {
                    if (skip)
                    {
                        skip = false;
                    }
                    else
                    {
                        for (int y = start; y < j; y++)
                        {
                            ans[i][y] = count;
                        }
                        start = j;
                        count++;
                    }
                }
            }

            if (!skip)
            {
                for (int y = start; y < w; y++)
                {
                    ans[i][y] = count;
                }
                count++;
            }
        }

        for (int i = 1; i < h; i++)
        {
            if (ans[i][0] == 0)
            {
                for (int j = 0; j < w; j++)
                {
                    ans[i][j] = ans[i - 1][j];
                }
            }
        }

        for (int i = h - 1; i >= 0; i--)
        {
            if (ans[i][0] == 0)
            {
                for (int j = 0; j < w; j++)
                {
                    ans[i][j] = ans[i + 1][j];
                }
            }
        }


        // 出力
        for (int i = 0; i < h; i++)
        {
            for (int j = 0; j < w; j++)
            {
                Console.Write(ans[i][j] + " ");
            }
            Console.WriteLine("");
        }

    }
}

Measured memory_bytes: 34988
//keep trying :)
#include <bits/stdc++.h>
#define float long double
#define int long long
#define ll long long
#define PB push_back
#define MP make_pair
#define ss second
#define ff first
#define PI 3.14159265
#define inf 9*(1e18)
#define fastrack ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
void PT(int a);
void PT1(int a);
const int M = 5*(1e5) + 7, mod = 1e9 + 7;
int z[M];

signed main(){
    fastrack;
    //int tt; cin >> tt; while(tt--)
    {
        int n;
        cin >> n;
        cout << n + n * n + n * n * n << "\n";
    }
    return 0;
}

void PT(int a){
    cout << a << "\n";
}

void PT1(int a){
    cout << a << " ";
}


Measured memory_bytes: 3652
#include <iomanip>
#include <iostream>
#include <cmath>

using namespace std;

int main(int argc, char* argv[]) {
  while (true) {
    int n; cin >> n;
    if (n == 0) break;
    
    int point[n];
    double total = 0;
    for (int i = 0; i < n; i++) {
      cin >> point[i];
      total += point[i];
    }
    double avg = total / n;
    double total_p = 0;
    for (int i = 0; i < n; i++) {
      total_p += pow(point[i]-avg, 2);
    }
    cout << fixed << setprecision(6) << sqrt(total_p / n) << endl;
  }
  return 0;
}

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

typedef long long int ll;
typedef pair<ll, ll> pll;

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

char C[4] = {'Y', 'A', 'K', 'I'};
string solve(string s)
{
    if (s.length() < 4)
        return "No";
    REP(i, 4)
    {
        if (C[i] != s[i])
            return "No";
    }
    return "Yes";
}
int main()
{
    string S;
    cin >> S;
    cout << solve(S) << endl;
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n, m int
	fmt.Scan(&n, &m)

	if abs(n-m) >= 2 {
		fmt.Println(0)
		return
	}

	ans := 1
	for i := n; i > 0; i-- {
		ans = ans * i % 1000000007
	}
	for i := m; i > 0; i-- {
		ans = ans * i % 1000000007
	}
	if n == m {
		ans = ans * 2 % 1000000007
	}

	fmt.Println(ans)
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}


Measured memory_bytes: 512
#pragma region _head

#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<set>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>
#include<regex>

#pragma region _define

#define int LL
#define f(i,a,b) for(LL i=a;i<b;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n) f(i,0,n)cout<<v[i]<<endl
#define ei else if
#define all(a) a.begin(),a.end()
#define size(s) ((LL)s.size())
#define F first
#define S second
#define check() cout<<"! ! !"
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl
#define int_INF 1<<29
#define ll_INF 1LL<<60
#define MOD 1000000007

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vc = vector<char>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using qi = queue<LL>;
using qc = queue<char>;
using qs = queue<st>;
using si = stack<LL>;
using sc = stack<char>;
using ss = stack<st>;
using pi = pair<LL, LL>;
using mll = map<LL, LL>;
using vpi = vector<pi>;

#pragma endregion

#pragma region _graph

#define node 50  //グラフの最大位数　適宜変更
//bool graph[node][node]; bool visited[node] = { false };
#define link(a,b,m) f(i,0,m){cin>>a[i]>>b[i]; a[i]--; b[i]--; graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;}

#pragma endregion


LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

//素数判定
bool is_prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n % i == 0) {
			return false;
		}
	}
	return true;
}

//階乗計算
LL factorial(LL n) {
	LL a = 1, ret = 1;
	while (a < n) {
		a++;
		ret *= a;
		ret %= MOD;
	}
	return ret;
}

#pragma endregion 



/*****************************************************************************/

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

	int n;
	cin >> n;
	vi a(3*n);
	f_vI(a, 3*n);
	sort(all(a));
	int ans = 0;
	for (int i = n; i < 3 * n; i += 2) {
		ans += a[i];
	}
	cout << ans;
	return 0;
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a;
    a.push_back(0);
    auto getnext = [&](vector<int> &a) {
        int n = a.size();
        int j = 0;
        while (true) {
            ++a[j];
            while (j < n && a[j] == 10) {
                a[j] = 0;
                if (j == n - 1) {
                    a.push_back(1);
                    ++n;
                }
                else ++a[j + 1];
                ++j;
            }
            if (j + 1 < n && a[j + 1] + 1 < a[j]) ++j;
            else break;
        }
        for (int i = j - 1; i >= 0; --i) {
            a[i] = max(a[i + 1] - 1, 0);
        }
    };
    auto print = [&](vector<int> a) {
        int n = a.size();
        for (int i = n - 1; i >= 0; --i) cout << a[i];
        cout << endl;
    };
    while (n--) {
        getnext(a);
    }
    print(a);
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n,m,ans=0;
	scanf("%lld%lld",&n,&m);
	if(n>m)
	{
		cout<<"0"<<endl;
		return 0;
	}
	if(m%n==0)
	{
		cout<<m/n<<endl;
		return 0;
	}
	for(long long i=1;i<=m;i++)
	{
		if(m%i==0&&m/i>=n)
		ans=i;
		if(m/i<n) break;
	}
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Comparator;
import java.util.PriorityQueue;
import java.util.Scanner;

//Traveling Alone: One-way Ticket of Youth
public class Main {

	public static int n;
	public static int m;

	public static int[][] cost;
	public static int[][] time;

	public static int[] dist;

	public static int dijkstra(int start, int goal, int x){
		Arrays.fill(dist, Integer.MAX_VALUE);
		dist[start] = 0;
		PriorityQueue<Integer> q = new PriorityQueue<Integer>(m, new Comparator<Integer>(){
			public int compare(Integer o1, Integer o2) {
				return dist[o1]-dist[o2];
			}
		});
		q.add(start);
		while(!q.isEmpty()){
			int u = q.poll();
			if(u==goal)return dist[goal];
			if(x==0){
				for(int i=0;i<m;i++){
					if(cost[u][i]!=Integer.MAX_VALUE && dist[u]+cost[u][i] < dist[i]){
						dist[i] = dist[u] + cost[u][i];
						q.remove(i);
						q.add(i);
					}
				}
			}
			else{
				for(int i=0;i<m;i++){
					if(time[u][i]!=Integer.MAX_VALUE && dist[u]+time[u][i] < dist[i]){
						dist[i] = dist[u] + time[u][i];
						q.remove(i);
						q.add(i);
					}
				}
			}
		}
		return -1;
	}

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			n = sc.nextInt();
			m = sc.nextInt();
			if(n==0&&m==0)break;
			cost = new int[m][m];
			time = new int[m][m];
			dist = new int[m];
			for(int[] a:cost)Arrays.fill(a, Integer.MAX_VALUE);
			for(int[] a:time)Arrays.fill(a, Integer.MAX_VALUE);
			while(n--!=0){
				int a = sc.nextInt()-1;
				int b = sc.nextInt()-1;
				int c = sc.nextInt();
				int t = sc.nextInt();
				if(cost[a][b] > c)
					cost[a][b] = cost[b][a] = c;
				if(time[a][b] > t)
					time[a][b] = time[b][a] = t;
			}
			int k = sc.nextInt();
			while(k--!=0){
				int s = sc.nextInt()-1;
				int t = sc.nextInt()-1;
				int x = sc.nextInt();
				System.out.println(dijkstra(s, t, x));
			}
		}
	}
}

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

int main() {
  long long int N;
  cin >> N;
  //cout << N << endl;
  vector<int> a_v(N);
  for (int i = 0 ; i < N; i++) {
    cin >> a_v.at(i);
  }
  //long long int v_sum = accumulate(a_v.begin(), a_v.end(), 0LL);

  long long int max = accumulate(a_v.begin(), a_v.end(), 0LL);
  long long int f_max = 0;
  cout << max-N << endl;
  return 0;
}


Measured memory_bytes: 256
N, M = map(int, input().split())

AB = [list(map(int, input().split())) for _ in range(N)]
CD = [list(map(int, input().split())) for _ in range(M)]

for a, b in AB:
    res = [0, float("inf")]
    for i, (c, d) in enumerate(CD):
        if res[1] > abs(a - c) + abs(b - d):
            res[0] = i
            res[1] = abs(a - c) + abs(b - d)
    print(res[0] + 1)


Measured memory_bytes: 3064
N = int(input())
A = [int(input()) for _ in range(N)]
mx1 = max(A)

mx2 = -1
cnt = 0
for i in range(N):
    if A[i] == mx1:
        cnt += 1
    else:
        mx2 = max(mx2, A[i])
    if cnt == 2:
        break
if mx2 == -1:
    mx2 = mx1
for i in range(N):
    if cnt >= 2:
        print(mx1)
    else:
        if A[i] == mx1:
            print(mx2)
        else:
            print(mx1)

Measured memory_bytes: 12640
/// sultanov
  
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
      
#define x first
#define y second
#define pb push_back
#define sz(x) (int) x.size()
  
using namespace std;
using namespace __gnu_pbds;
 
template<typename T> 
using ordered_set = tree<T, null_type,                                                                                  
less<T>, rb_tree_tag, 
tree_order_statistics_node_update>;
 
using ll = long long;
using pii = pair<int, int>;                                    
 
const int INF32 = 1e9;                                                                               

int main() {                                                  
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);  
    string s, t;
    cin >> s >> t;
    int ans = 0;
    for (int i = 0; i < sz(s); i++)
        ans += s[i] == t[i];
    cout << ans;
    return false;               
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using P = pair<int, int>;

int main() {
  string s;
  cin >> s;
  int n = s.length();
  bool flag = true;
  for (int i = 0; i < n; i++)
  {
    if (i%2==0) {
      if (s[i]!='R'&&s[i]!='U'&&s[i]!='D'){
        flag = false;
      }
    } else {
      if (s[i]!='L'&&s[i]!='U'&&s[i]!='D'){
        flag = false;
    }
  }
  }
  if (flag) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <map>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <set>
#include <stack>
#include <stack>
#include <list>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>

#define rep(i,n) for (int i = 0; i < (n); ++i)

using namespace std;
// using ll = long long;
// using P = pair<int, int>;

const int SN = 4;
const int RN = 13;
const char Suits[] = {'S', 'H', 'C', 'D'};

bool cs[SN][RN];

int main(){
    int n;
    cin >> n;
    
    rep(i,n){
        char sc;
        int c, r;
        cin >> sc >> r;
        c = 0;
        
        switch(sc){
            case 'S': c = 0; break;
            case 'H': c = 1; break;
            case 'C': c = 2; break;
            case 'D': c = 3; break;
        }
        
        cs[c][r-1] = true;
    }
    
    for(int s = 0; s < SN; s++){
        for(int r = 0; r < RN; r++){
            if(! cs[s][r]) cout << Suits[s] << ' ' << r+1 <<endl;
        }
    }

    return 0;
}



Measured memory_bytes: 3096
#include <algorithm>
#include <iostream>
#include <cmath>

using namespace std;

int main() {
	int a, b; cin >> a >> b;
	int ans = max(ceil(a / 0.08), ceil(b / 0.1));
	cout << (floor(ans * 0.08) == a && floor(ans * 0.1) == b ? ans : -1) << '\n';
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, start, n) for (int i = (int)(start); i < (int)(n); ++i)

int main(){
    int N, num;
    cin >> N;
    int MAX_VAL = 1000000;
    vector<int> dp(MAX_VAL+1, 0);
    rep(i, 0, N){
        cin >> num;
        dp[num]++;
    }
    int ans = 0;
    rep(i, 0, MAX_VAL+1){
        if (dp[i] == 1){
            ans++;
        }
        if (dp[i]){
            for (int j = 2; i*j <= MAX_VAL; j++){
                dp[i*j] = 0;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 7196
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

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

//INT_MAX	2,147,483,647 = 2*1.0e9
const int INF = 2e9;

int main(){
  int N, K;
  cin >> N >> K;

  vector<int> x(N);
  bool flag = true;
  for(int i = 0; i < N; i++){
    cin >> x[i];
    if(x[i] == 0){
      flag = false;
      K--;
    }
  }
  if(K == 0){
    cout << 0 << endl;
    return 0;
  }

  if(flag) x.push_back(0);
  sort(x.begin(), x.end());
  
  int num_to_0 = lower_bound(x.begin(), x.end(), 0) - x.begin();
  int num_from_0 = (int)x.size() - (upper_bound(x.begin(), x.end(), 0) - x.begin());

  int ans = INF;
  //左にだけ行く時
  if(num_to_0 >= K){
    ans = min(ans, -x[num_to_0 - K]);
  }

  // 左に行ってから右に行く時
  for(int i = min(K-1, num_to_0); i >= 1; i--){
    if(num_to_0 + K-i < (int)x.size()){
      int temp = -2 * x[num_to_0 - i] + x[num_to_0 + K-i];
      ans = min(ans, temp);
    }
  }

  // 右に行ってから左に行く時
  for(int i = min(K-1, num_from_0); i >= 1; i--){
    if(num_to_0 - (K-i) >= 0){
      int temp = 2 * x[num_to_0 + i] - x[num_to_0 - (K-i)];
      ans = min(ans, temp);
    }
  }

  // 右にだけ行く時
  if(num_from_0 >= K){
    ans = min(ans, x[num_to_0 + K]);
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
 
int main()
{
  int N;
  cin >> N;

  vector<tuple<string,int,int>> A;
  REP(i,N){
    string s;
    int a;
    int b;
    cin >> s >> a;
    a = -1*a;
    b = i;
    A.push_back(make_tuple(s,a,b));
  }

  sort(ALL(A));
  REP(i,N){
    cout << get<2>(A.at(i))+1 << endl;
  }
}

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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll;
const int inf = 0x3fffffff; const ll INF = 0x1fffffffffffffff; const double eps=1e-12;
void tostr(ll x,string& res){while(x)res+=('0'+(x%10)),x/=10; reverse(ALL(res)); return;}
template<class T> inline bool chmax(T& a,T b){ if(a<b){a=b;return 1;}return 0; }
template<class T> inline bool chmin(T& a,T b){ if(a>b){a=b;return 1;}return 0; }
//template end



int main(){
   int n; scanf("%d",&n);
   map<string,int> mp;
   rep(i,0,n){
      string s; cin>>s;
      mp[s]++;
   }
   int maxx=0;
   for(auto p:mp)chmax(maxx,p.second);
   for(auto p:mp)if(maxx==p.second)cout<<p.first<<endl;
   return 0;
}

Measured memory_bytes: 25216
#include <bits/stdc++.h>
using namespace std;
#define ll long long int

int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a,b,c;
    cin>>a>>b>>c;
    int ans=0;
    ans+= min((a+b+1),c);
    ans+=b;
    cout<<ans;

}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

const int INF = 1e9+5;

int main(){
  ll n,m;
  ll res=0;
 cin >> n >> m; 
  if(n==1 && m==1) res = 1;
  else if(n==1 && m!=1) res=m-2;
  else if(n!=1 && m==1) res=n-2;
  else res=(ll)((n-2)*(m-2));
  cout << res <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef double db;
typedef vector <ll> vll;
typedef pair <ll, ll> pll;
#define pb push_back
#define mp make_pair
#define MAX 1000000
#define mod 1000000007
#define all(_) _.begin(), _.end()
#define F first
#define S second
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

int main()
{
    ios_base :: sync_with_stdio(false);
    cin.tie(NULL), cout.tie(NULL);
    ll n, sum = 0, m;
    cin >> n;
    m = n;
    while(n)
    {
        sum += n % 10;
        n /= 10;
    }
    cout << ((m % sum == 0) ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.string;
import std.conv;
import std.algorithm;
import std.math;
import std.regex;

void main() {
	auto s = readln.chomp.to!(dchar[]), t = readln.chomp.to!(dchar[]);
	s.sort();
	t.sort!"a > b";
	
	writeln(s < t ? "Yes": "No");
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
int main(){
	string S;
	vector<char> ans;
	char C;
	int Q,T,F;
	bool rev=false;
	cin>>S>>Q;
	for(int i=0;i<S.length();i++)ans.push_back(S[i]);
	for(int i=0;i<Q;i++){
		cin>>T;
		if(T==1)rev=!rev;
		else{
			cin>>F>>C;
			if(rev)F=3-F;
			if(F==1)ans.insert(ans.begin(),C);
			else ans.push_back(C);
		}
	}
	if(rev)for(int i=ans.size()-1;i>=0;i--)cout<<ans[i];
	else for(int i=0;i<ans.size();i++)cout<<ans[i];
	return 0;
}

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

using namespace std;
 
#define debug(s) cerr << #s << " = " << s << '\n'
#define all(v) (v).begin(), (v).end()
#define mem(a,val) memset(a, val, sizeof a)
 
#define ff first
#define ss second
typedef long long ll;

const int N = 200010;
int n, a[N], b[N];

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n;
  for (int i = 1; i <= n; ++i) cin >> a[i] >> b[i];
  double ml, mr;
  sort(a + 1, a + 1 + n);
  sort(b + 1, b + 1 + n);
  int ans;
  if (n & 1) {
    ml = a[n/2 + 1], mr = b[n/2 + 1];
    ans = max(0, (int)(mr - ml + 1));
  }
  else {
    ml = (a[n/2] + a[n/2 + 1]);
    mr = (b[n/2] + b[n/2 + 1]);
    ans = max(0, (int)(mr - ml + 1));
  }
  cout << ans << '\n';
}

Measured memory_bytes: 5124
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		int A[]=new int[N];
		int z=0;
		long sum=0;
		while(z<N){
			A[z]=stdIn.nextInt();
			if(z==0)
				sum=A[z];
			else
				sum=A[z]-sum;
			z++;
		}z=0;
		System.out.println(sum);
		while(z<N-1){
			sum/=2;
			sum=(A[z]-sum)*2;
			System.out.println(sum);
			z++;
		}
	}
}

Measured memory_bytes: 66756
#最初の分割を全探索
H,W = map(int,input().split())
ans = H*W
for i in range(1,H):
    S0 = i*W
    h = (H-i)//2
    S1 = [S0,h*W,(H-i-h)*W]
    ans = min(ans,max(S1)-min(S1))
    h = H-i
    w = W//2
    S1 = [S0,h*w,h*(W-w)]
    ans = min(ans,max(S1)-min(S1))
for j in range(1,W):
    S0 = j*H
    w = (W-j)//2
    S1 = [S0,H*w,H*(W-j-w)]
    ans = min(ans,max(S1)-min(S1))
    w = W-j
    h = H//2
    S1 = [S0,h*w,(H-h)*w]
    ans = min(ans,max(S1)-min(S1))
print(ans)

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

using namespace std;


int main()
{


        string s;
        string s1;
        cin>>s;
        cin>>s1;

        for(int i=0;i<s.length();i++)
        {
           if(s[i]!=s1[i])
           {
               cout<<"No"<<endl;
               return 0;
           }
        }

cout<<"Yes"<<endl;




        return 0;


}


Measured memory_bytes: 3620
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		int i;
		for (i = 1;; i++) {

			int x = sc.nextInt();

			if (x != 0) {
				System.out.printf("Case %d: %d\n", i, x);
			} else {

				break;

			}

		}
	}

}

Measured memory_bytes: 61736
import collections

N = int(input())
S = [input() for _ in range(N)]

AC_count = S.count("AC")
WA_count = S.count("WA")
TLE_count = S.count("TLE")
RE_count = S.count("RE")

print(f"AC x {AC_count}")
print(f"WA x {WA_count}")
print(f"TLE x {TLE_count}")
print(f"RE x {RE_count}")


Measured memory_bytes: 16476
import java.util.Scanner;

/**
 * author: Acrafter
 * date: 2017/1/15
 * time: 16:04
 */
public class Main{
    private static int left = -1, right = -1;
    private static int[] balls = new int[10];
    private static String result = "NO";
    public static void main(String[] args){
        Scanner input = new Scanner(System.in);
        int m = input.nextInt();
        balls = new int[10];
        for (int i = 0; i < m; i++) {
            for (int i2 = 0; i2 < 10; i2++) {
                balls[i2] = input.nextInt();
            }
            left = -1; right = -1;
            result = "NO";
            dfs(0);
            System.out.println(result);
        }
    }

    public static void dfs(int i){
        if(i==10){
            result = "YES";
            return;
        }
        if (left<balls[i]){
            left = balls[i];
            dfs(i+1);
        }else if(right<balls[i]) {
            right = balls[i];
            dfs(i+1);
        }
    }
}

Measured memory_bytes: 26116
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define SORT(x) sort(x.begin(), x.end())
#define RS(x) rsort(x.begin(),x.end()))
#define REVE(x) reverse(x.begin(), x.end())
#define ALL(x) (x).begin(), (x).end()
int INF = 1e9 + 1;
int MOD = 1e9+7;
signed main()
{
    int n,b=0,min=INF;
    cin >> n;
    vector<int> x(n);
   REP(i,n){
      x[i]=0;
      cin >> x[i];
     }
     SORT(x);
  REP(j,100){
REP(i,n)
  {
b+=(x[i]-j)*(x[i]-j);
   }
    if(min>=b){
    min=b;
    }
    b=0;
  }
  cout << min ;
}


Measured memory_bytes: 256
import Data.List

pattern1 :: [Int] -> [String]
pattern1 x = map show [(x !! 0),(x !! 1),(x !! 5),(x !! 4),(x !! 0)]

pattern2 :: [Int] -> [String]
pattern2 x = map show [(x !! 1),(x !! 2),(x !! 4),(x !! 3),(x !! 1)]

pattern3 :: [Int] -> [String]
pattern3 x = map show [(x !! 2),(x !! 0),(x !! 3),(x !! 5),(x !! 2)]

solve :: [Int] -> [String] -> [Int]
solve list [] = []
solve list (x : xs)
  | isInfixOf x (unwords $ pattern1 list) = list !! 2 : solve list xs
  | isInfixOf x (unwords $ pattern2 list) = list !! 0 : solve list xs
  | isInfixOf x (unwords $ pattern3 list) = list !! 1 : solve list xs
  | isInfixOf x (unwords $ reverse $ pattern1 list) = list !! 3 : solve list xs
  | isInfixOf x (unwords $ reverse $ pattern2 list) = list !! 5 : solve list xs
  | isInfixOf x (unwords $ reverse $ pattern3 list) = list !! 4 : solve list xs

main = getContents >>= mapM_ print . (\(a:_:b) -> solve (map read $ words a) b) . lines

Measured memory_bytes: 3824
// JOI - Prelim  0533
// コンテスト
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),*  )) => {
        ( $(read_value!($iter, $t)),*  )
    };
    ($iter:expr, [ $t:tt ; $len:expr  ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        ns: [u64; 20],
    }
    let mut a_s = ns;
    let mut b_s = a_s.split_off(10);
    a_s.sort_by(|a, b| b.cmp(a));
    b_s.sort_by(|a, b| b.cmp(a));
    let a_sum = a_s.iter().take(3).fold(0, |sum, v| sum + v);
    let b_sum = b_s.iter().take(3).fold(0, |sum, v| sum + v);
    println!("{} {}", a_sum, b_sum);
}


Measured memory_bytes: 5036
n = int(input())
a = list(map(int, input().split()))

odd_cnt = 0
for i in range(n):
    if a[i]%2 == 1:
        odd_cnt += 1
if odd_cnt % 2 == 0 or (odd_cnt == 1 and a.index(1)>0):
    print("YES")
else:
    print("NO")

Measured memory_bytes: 14112
# include "cstdio"

const int maxm=200000+10; 

int 
	a[maxm], 
	b[maxm],
	n;
     
long long 
	ans; 

inline int read(){ 
	int s=0,w=1;
	char ch=getchar();
	while(ch<'0' || ch>'9'){
		if(ch=='-') w=-w;
		ch=getchar();
	}
	while(ch>='0' && ch<='9'){
		s=s*10+ch-'0';
		ch=getchar();
	}
	return s*w;
}

int main(){
	n=read(); 
	register int i,j;
	for(i=1;i<=n;i++){
		j=read();
		a[i]=j+a[i-1]; 
		b[i]=j^b[i-1];
	}
	for (i=j=1;i<=n;i++){
         for(;a[i]-a[j-1]!=(b[i]^b[j-1]);j++);
         ans+=i-j+1;
    }
	printf("%lld",ans);
	return 0; 
} 

Measured memory_bytes: 1664
a = int(input())

B = []

for i in range(a):
    B.append(input())

AC = 0
TLE = 0
WA = 0
RE = 0

for i in range(a):
    if B[i] == "AC":
        AC += 1
    elif B[i] == "TLE":
        TLE += 1
    elif B[i] == "WA":
        WA += 1
    elif B[i] == "RE":
        RE += 1

print(f"AC x {AC}")
print(f"WA x {WA}")
print(f"TLE x {TLE}")
print(f"RE x {RE}")


Measured memory_bytes: 16068
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for(int i = 0; i < (n); ++i)

int main()
{
    int k;
    cin >> k;
    rep(i, k) {
        cout << "ACL";
    }
    cout << endl;
    return 0;
}

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

int main() {

  long long int n;

  cin >> n;

  double xa, ya, ra, xb, yb, rb;

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

    cin >> xa >> ya >> ra >> xb >> yb >> rb;

    double x = xa - xb;
    x *= x;
    double y = ya - yb;
    y *= y;
    double r = ra - rb;
    r *= r;
    if ( r > x + y ) {
      if ( ra > rb ) {
	cout << 2 << endl;
      }else {
	cout << -2 << endl;
      }
    }else {
      if ( x + y > ( ra + rb ) * ( ra + rb ) ) {
	cout << 0 << endl;
      }else {
	cout << 1 << endl;
      }
    }

  }

  return 0;

}

Measured memory_bytes: 1232
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
 
using namespace __gnu_pbds;
using namespace std;
 
typedef long long int ll;
typedef unsigned long long int sll;
typedef long double ld;
#define A 1000000007
#define D 100000000000000ll
#define B 998244353ll
#define C 1000000000000000000ll
#define M 4000
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define oset tree<pair<ll,ll>, null_type,greater<pair<ll,ll>>, rb_tree_tag,tree_order_statistics_node_update> 
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define rev(v) reverse(v.begin(),v.end())
#define sor(v) sort(v.begin(),v.end())
#define bs binary_search
#define lb(v,x) lower_bound(v.begin(),v.end(),x)
#define ub(v,x) upper_bound(v.begin(),v.end(),x)
#define ve vector
#define br break
#define PI acos(-1)
#define subt cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n" 

ll ch(string x,string y,ll m)
{
    ll ans=0;
    for(int i=0;i<m;i++)
        if(x[i]!=y[i])  
            ans++;
    return ans;
}

int main() 
{
    FAST;
    string s,t;
    cin>>s>>t;
    ll n=s.length(),m=t.length(),ans=m;
    for(int i=m-1,st=0;i<n;i++,st++)
    {
        string p;
        for(int j=st;j<=i;j++)
            p.pb(s[j]);
        ans=min(ans,ch(p,t,m));
    }
    cout<<ans;
    subt;
    return 0;
}

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

int main() {
	int N, A;
	cin >> N >> A;
	if (N % 500 <= A) cout << "Yes";
	else cout << "No";
	return 0;
}
/*
31536000のコメント解説欄
ここテンプレで用意してるから、A問題とかだとこの先空欄の危険あり

無限の500円玉を持っているので500で割った余りが1円玉で足りるかのみを考慮でおｋ
*/

Measured memory_bytes: 256
import java.util.*;

class Main{

    void solve(){
        Scanner sc = new Scanner(System.in);

        while(true){
            int sum = sc.nextInt();
            if(sum==0) break;
            for(int i=0; i<9; i++) sum -= sc.nextInt();
            System.out.println(sum);
        }
    }

    public static void main(String[] args){
        new Main().solve();
    }
}

Measured memory_bytes: 17176
#pragma GCC optimize("Ofast,inline,unroll-loops,fast-math")
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;

int main(void)
{
    int a, b, c, d;
    bool f;

    cin >> a >> b >> c >> d;
    for(f = false; true; f ^= 1)
    {
        if(!f)
        {
            c -= b;
            if(c <= 0)
            {
                cout << "Yes" << endl;
                break;
            }
        }
        else
        {
            a -= d;
            if(a <= 0)
            {
                cout << "No" << endl;
                break;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 3636
#include<stdio.h>
int main(void){
	double fivetime,tentime;
	while(scanf("%lf %lf",&fivetime,&tentime) != EOF){
		if(fivetime < 35.50){
			if(tentime < 71.00){
				printf("AAA\n");
			}
			else if(tentime < 77.0 && tentime >= 71.00){
				printf("AA\n");
			}
			else if(tentime < 83.00 && tentime >= 77.00){
				printf("A\n");
			}
			else if(tentime < 89.00 && tentime >= 83.00){
				printf("B\n");
			}
			else if(tentime < 105.00 && tentime >= 89.00){
				printf("C\n");
			}
			else if(tentime < 116.00 && tentime >= 105.00){
				printf("D\n");
			}
			else if(tentime < 148.00 && tentime >= 116.00){
				printf("E\n");
			}
			else{
				printf("NA\n");
			}
		}
		else if(fivetime < 37.50 && fivetime >= 35.50){
			if(tentime < 77.00){
				printf("AA\n");
			}
			else if(tentime < 83.00 && tentime >= 77.0){
				printf("A\n");
			}
			else if(tentime < 89.00 && tentime >= 83.00){
				printf("B\n");
			}
			else if(tentime < 105.00 && tentime >= 89.00){
				printf("C\n");
			}
			else if(tentime < 116.00 && tentime >= 105.00){
				printf("D\n");
			}
			else if(tentime < 148.00 && tentime >= 116.00){
				printf("E\n");
			}
			else{
				printf("NA\n");
			}
		}
		else if(fivetime < 40.00 && fivetime >= 37.50){
			if(tentime < 83.00){
				printf("A\n");
			}
			else if(tentime < 89.00 && tentime >= 83.00){
				printf("B\n");
			}
			else if(tentime < 105.00 && tentime >= 89.00){
				printf("C\n");
			}
			else if(tentime < 116.00 && tentime >= 105.00){
				printf("D\n");
			}
			else if(tentime < 148.00 && tentime >= 116.00){
				printf("E\n");
			}
			else{
				printf("NA\n");
			}
		}
		else if(fivetime < 43.00 && fivetime >= 40.00){
			if(tentime < 89.00){
				printf("B\n");
			}
			else if(tentime < 105.00 && tentime >= 89.00){
				printf("C\n");
			}
			else if(tentime < 116.00 && tentime >= 105.00){
				printf("D\n");
			}
			else if(tentime < 148.00 && tentime >= 116.00){
				printf("E\n");
			}
			else{
				printf("NA\n");
			}
		}
		else if(fivetime < 50.00 && fivetime >= 43.00){
			if(tentime < 105.00){
				printf("C\n");
			}
			else if(tentime < 116.00 && tentime >= 105.00){
				printf("D\n");
			}
			else if(tentime < 148.00 && tentime >= 116.00){
				printf("E\n");
			}
			else{
				printf("NA\n");
			}
		}
		else if(fivetime < 55.00 && fivetime >= 50.00){
			if(tentime < 116.00){
				printf("D\n");
			}
			else if(tentime < 148.00 && tentime >= 116.00){
				printf("E\n");
			}
			else{
				printf("NA\n");
			}
		}
		else if(fivetime < 70.00 && fivetime >= 55.00){
			if(tentime < 148.00){
				printf("E\n");
			}
			else{
				printf("NA\n");
			}
		}
		else{
			printf("NA\n");
		}
	}
	return 0;
}

Measured memory_bytes: 608
#include <iostream>
#include <string>
#include <cstdlib>

using namespace std;

int main() {
	string x;
	char tmp;
	int sum;

	cin >> x;

	while(x != "0") {
		sum = 0;

		for(int i = 0;i < x.size();i++) {
			tmp = x[i];

			sum += atoi(&tmp);
		}

		cout << sum << endl;
		cin >> x;
	}

	return 0;
}

Measured memory_bytes: 3144
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<cmath>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
#include<numeric>
#include<functional>
#include<algorithm>
#include<bitset>
#include<tuple>
#include<unordered_set>
#include<unordered_map>
#include<random>
#include<array>
#include<cassert>
using namespace std;
#define INF (1<<29)
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(v) v.begin(),v.end()
#define uniq(v) v.erase(unique(all(v)),v.end())



bool YYMM(string s) {
	int a = (s[0] - '0') * 10 + (s[1] - '0');
	int b = (s[2] - '0') * 10 + (s[3] - '0');
	return 1 <= b && b <= 12;
}

bool MMYY(string s) {
	int a = (s[0] - '0') * 10 + (s[1] - '0');
	int b = (s[2] - '0') * 10 + (s[3] - '0');
	return 1 <= a && a <= 12;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);

	string s;
	cin >> s;

	if (YYMM(s)) {
		if (MMYY(s)) {
			cout << "AMBIGUOUS";
		}
		else {
			cout << "YYMM";
		}
	}
	else {
		if (MMYY(s)) {
			cout << "MMYY";
		}
		else {
			cout << "NA";
		}
	}
	cout << endl;


	return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var a, b, c, k int
	fmt.Scan(&a, &b, &c, &k)
	ans := 0
	if a > 0 {
		if a >= k {
			ans += k
		} else {
			ans += a
		}
		k -= a
	}
	if b > 0 && k > 0 {
		k -= b
	}
	if k > 0 {
		ans -= k
	}

	fmt.Println(ans)
}


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

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

    int N;
    cin >> N;

    if(N > 2){
        cout << (N / 3) << endl; 
    }else{
        cout << 0 << endl;
    }
    
    return 0;
}


Measured memory_bytes: 888
import collections
N=int(input())
A=list(map(int,input().split()))
i=0
A.insert(0,float("inf"))
#print(A)
buy=[0]*N
sell=[0]*N
for i in range(N-1):
    if (A[i]>=A[i+1])and(A[i+2]>=A[i+1]):
        buy[i]=1
    if (A[i]<=A[i+1])and(A[i+2]<=A[i+1]):
        sell[i]=1
kabu=0
money=1000
#print(buy,sell)
#print(money,kabu)
A=A[1:]
#print(A)
for i in range(N):
    if sell[i]==1:
        money=money+kabu*A[i]
        kabu=0
    if buy[i]==1:
        kabu=kabu+money//A[i]
        money=money-(money//A[i])*A[i]
    #print(money,kabu,A[i])
    #input()
#print(money,kabu)
money=money+kabu*A[N-1]
print(money)




Measured memory_bytes: 64896
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

int main() {
    int n, A[3];
    cin >> n >> A[0] >> A[1] >> A[2];

    int l[n];
    for (int i = 0; i < n; i++) {
        cin >> l[i];
    }

    int ans = 1 << 30;
    for (int i = 0; i < (1 << (2 * n)); i++) {
        vector <int> use[4];
        int t = i;
        for (int j = 0; j < n; j++) {
            use[t % 4].push_back(l[j]);
            t /= 4;
        }

        int ret = 0;
        for (int j = 0; j < 3; j++) {
            if (use[j].size() == 0) {
                ret = 1 << 30;
                break;
            }

            int mp = 10 * (use[j].size() - 1);
            int sm = 0;
            for (int k : use[j]) {
                sm += k;
            }

            mp += abs(sm - A[j]);
            ret += mp;
        }

        ans = min(ans, ret);
    }

    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <algorithm>
#include <string> 
#include <vector>
#include <iomanip>
using namespace std;

int main()
{
	vector<int> MOJI(3);
	cin >> MOJI.at(0) >> MOJI.at(1) >> MOJI.at(2);
	sort(MOJI.begin(), MOJI.end());
	if (MOJI.at(0) == 5 && MOJI.at(1) == 5 && MOJI.at(2) == 7) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
long long n;
cin >> n;
long long a[n+1];
for (int i = 0;i < n;i++) cin >> a[i];
sort (a,a+n);
bool can = true;
for (int i = 0;i < n;i++){
    if(a[i]==a[i+1]) can = false;
}
if(can) cout << "YES" << endl;
else cout << "NO" << endl;
}

Measured memory_bytes: 1792
#include <iostream> 
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <queue>
#include <set>
#include <stack>
#include <cstring>

#define mp make_pair
#define s second
#define f first
#define ll long long
using namespace std;
const ll MAX = 1e10;
ll h[100003], dp[100003];

int main () {
ios::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
		
	int n;
	cin >> n;
	
	for (int i=0; i<n; i++) {
		cin >> h[i];
	}
	
	dp[0] = 0;
	for (int i=1; i<n; i++) {
		dp[i] = MAX;
		for (int j=1; j<=2; j++) {
			if (i - j < 0) continue;
			dp[i] = min(dp[i], dp[i-j] + abs(h[i] - h[i-j]));
		}
	}
	
	cout << dp[n-1];
return 0;	
}




Measured memory_bytes: 1792
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstring>
#include <fstream>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

const int MAX = 150007;
const int MOD = 1000000007;

long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

void solve() {
    long long n;
    cin >> n;
    long long curr = 0;
    for (long long i = 0; i < 1000000; i++) {
        curr = ((curr * 10) % n + 7) % n;
        if (curr % n == 0) {cout << i + 1; return;}
    }
    cout << -1;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    //freopen("rental.in", "r", stdin); freopen("rental.out", "w", stdout);
    //int tt; cin >> tt; for (int i = 1; i <= tt; i++) {solve(); cout << endl;}
    solve();
}


Measured memory_bytes: 3620
#include <algorithm>
#include <climits>
#include <iostream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
template <class T> ostream &operator<<(ostream &os, vector<T> &v) {
  for (auto i = v.begin(); i != v.end(); i++) {
    os << *i << " ";
  }
  return os;
}

using ll = long long int;

bool cmp(pair<ll, ll> a, pair<ll, ll> b) {
  if(a.second != b.second)
    return a.second < b.second;
  else
    return a.first < b.first;
}

int main(void) {
  ll n;
  cin>>n;
  vector<pair<ll, ll>> a(n);
  for(int i=0; i<n; i++) {
    ll x, y;
    cin>>x>>y;
    a[i] = make_pair(x, y);
  }
  sort(a.begin(), a.end(), cmp);
  ll t=0;
  for(auto i=a.begin(); i!=a.end(); i++) {
    t+=i->first;
    if(t>i->second) {
      std::cout << "No" << std::endl;
      return 0;
    }
  }
  std::cout << "Yes" << std::endl;
  
  return 0;
}



Measured memory_bytes: 3456