akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int main(){
  int n;
  cin >> n;
  int ans=n;
  bool ok=false;
  for(int i=0;i<100000;i++){
    ok=true;
    for(int j=2;j<sqrt(ans);j++){
      if(ans%j==0)
        ok=false;
    }
    if(ok)
      break;
    else
      ans++;
  }
  cout << ans << endl;
  return 0;
}

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

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  rep(i, n) { cin >> h[i]; }

  h[0] = min(1, h[0] - 1);
  for (int i = 1; i < n; i++) {
    if (h[i - 1] > h[i]) {
      cout << "No" << endl;
      return 0;
    }
    h[i] = max(h[i - 1], h[i] - 1);
  }

  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
/*    #include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;       */
using namespace std;

#define ll long long
#define ull unsigned long long
#define f(a, b) for (ll i = a; i < b; i++)
#define mod 1000000007
#define mp make_pair
#define pb push_back
#define pl pair<ll, ll>
#define vll vector<ll>
#define pll vector<pair<ll, ll>>
#define ld long double
#define fr(a, b) for (ll j = a; j >= b; j--)
#define fi(a, b) for (ll j = a; j < b; j++)
#define fii(a, b) for (ll k = a; k < b; k++)
#define print(x) cerr << #x << " is " << x << endl;
//      typedef tree<ll ,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;

ll n, m, s, d;
vll adj[100050];
ll a[100050][3];

ll bfs()
{
    f(0, n + 1) fi(0, 3) a[i][j] = 1e18;
    a[d][0] = 0;
    queue<pl> q;
    q.push({0, d});
    while (!q.empty())
    {
        ll cd = q.front().first, v = q.front().second;
        // cout << v << " " << cd << "\n";
        if (cd % 3 == 0 && v == s)
            return cd / 3;
        q.pop();
        f(0, adj[v].size()) if (a[adj[v][i]][(cd + 1) % 3] == 1e18)
            a[adj[v][i]][(cd + 1) % 3] = cd + 1,
                                    q.push({cd + 1, adj[v][i]});
    }
    return -1;
}

int main()
{
// #ifndef ONLINE_JUDGE
//     freopen("input.txt", "rt", stdin);
//     freopen("output.txt", "wt", stdout);
// #endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll x, y;
    cin >> n >> m;
    f(0, m) cin >> x >> y, adj[y].pb(x);
    cin >> s >> d;
    ll ans = bfs();
    cout << ans;

// #ifndef ONLINE_JUDGE
//     cout << "\nTime Elapsed : " << 1.0 * clock() / CLOCKS_PER_SEC << " s\n";
// #endif
    return 0;
}

Measured memory_bytes: 8064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		long a = scanner.nextLong();
		long b = scanner.nextLong();
		long maxA = 1;
		long maxB = 1;
		for (int i = 1; i <= a; i++) {
			maxA *= i;
			maxA %= (Math.pow(10, 9)+7);
		}
		for (int i = 1; i <= b; i++) {
			maxB *= i;
			maxB %= (Math.pow(10, 9)+7);
		}
		if (a == b) {
			long result = ((maxA*maxB*2) % (1000000007));
			System.out.println(result);
		} else if (a+1 == b || b+1 == a) {
			long result = ((maxA*maxB) % (1000000007));
			System.out.println(result);
		} else {
			System.out.println("0");
		}
		scanner.close();
	}
}


Measured memory_bytes: 25172
#include<cstdio>
#include<iostream>

using namespace std;

int main(void){

	int A[101];
	int i,n,tmp;

	cin>>n;
	for(int i=0;i<n;i++) cin>>A[i];

	for(int j=1;j<n;j++){
		for(int i=0;i<n;i++){
			cout<<A[i];
			if(i==n-1) cout<<endl;
			else cout<<" ";
		}
		tmp=A[j];
		i=j-1;
		while(i>=0&&A[i]>tmp){
			A[i+1]=A[i];
			i--;
		}
		A[i+1]=tmp;
	}

	for(int i=0;i<n;i++){
		cout<<A[i];
		if(i==n-1) cout<<endl;
		else cout<<" ";
	}

	return 0;
}

Measured memory_bytes: 1160
// Aizu Vol-1 0166: Area of Polygon
// 2017.8.8

#include <stdio.h>
#include <math.h>

#define M	0.00872664625997164788461845384244
#define EPS 1e-8

int main()
{
	int i, n, v;
	double s[2];
	int a[2];

	while (1) {
		i = 2;
		while (i-- > 0) {
			s[i] = a[i] = 0;
			scanf("%d", &n); if (n == 0) return 0;
			while (--n > 0) {
				scanf("%d", &v);
				a[i] += v;
				s[i] += sin(M*v)*cos(M*v);
			}
			v = 360 - a[i];
			s[i] += sin(M*v)*cos(M*v);
		}
		if (fabs(s[0]-s[1]) <= EPS) putchar('0');
		else if (s[0] >= s[1]) putchar('2');
		else putchar('1');
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 576
using System;
using System.Collections.Generic;
using System.Numerics;
using System.Linq;

namespace AtCoderTemplate
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = Scanner.scanint[0];
            var w = Scanner.rescan(n);
            var book = new List<Tuple<string, int, int>>();
            for(var i = 0; i < n; i++)
            {
                book.Add(new Tuple<string, int, int>(w[i][0], -int.Parse(w[i][1]), i+1));
            }
            book.Sort();
            for (var i = 0; i < n; i++) Console.WriteLine(book[i].Item3);
        }
    }

    public class Scanner
    {
        public static string[] scan => Console.ReadLine().Split(' ');
        public static string[][] rescan(int n) => Enumerable.Repeat(0, n).Select(_ => Console.ReadLine().Split(' ')).ToArray();
        public static int[] scanint => Array.ConvertAll(scan, int.Parse);
        public static long[] scanlong => Array.ConvertAll(scan, long.Parse);
    }

    public class Ex
    {
        public static int[] subarr(int[] arr, int begin, int n) { int[] a = new int[arr.Length]; Array.Copy(arr, begin, a, 0, n); return a; }
    }
}


Measured memory_bytes: 11744
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <ctype.h>

#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define all(v) (v).begin(), (v).end()
#define rev(s) (s).rbegin(), (s).rend()
#define MP make_pair
#define X first
#define Y second

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<double, double> dP;

const int INF = 1000000000;
const double EPS = 1e-10;

int main(){
	while(1){
		int n;
		cin >> n;
		if(!n) break;
		vector<int> v(n);
		int sum = 0;
		rep(i, n){
			cin >> v[i];
			sum += v[i];
		}
		vector<int> subset;
		subset.push_back(0);
		rep(i, n){
			int prevsize = subset.size();
			rep(j, prevsize){
				subset.push_back(v[i]+subset[j]);				
			}
		}

		sort(all(subset));

		int m = sum;
		rep(i, subset.size()){
			int d = sum - 2*subset[i];
			if(d < 0) break;
			m = min(m, d); 
		}
		cout << m << endl;
	}

	return 0;
}

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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;

const int INF = 1e9;

int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int H, W;
int a[20][20];
int ans;

bool inside(int x, int y) {
    return 0 <= x && x < H && 0 <= y && y < W;
}

void dfs(int x, int y, int c) {
    if (c > 10) return;

    rep(k, 4) {
        int nx = x + dx[k], ny = y + dy[k];
        if (!inside(nx, ny)) continue;
        if (a[nx][ny] == 1) continue;
        while (true) {
            if (!inside(nx, ny)) break;
            if (a[nx][ny] == 1) {
                a[nx][ny] = 0;
                dfs(nx - dx[k], ny - dy[k], c + 1);
                a[nx][ny] = 1;
                break;
            }
            else if (a[nx][ny] == 3) {
                ans = min(ans, c);
                break;
            }

            nx += dx[k], ny += dy[k];
        }
    }
}

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

    while (cin >> W >> H, H) {
        int sx, sy;
        rep(i, H) rep(j, W) {
            cin >> a[i][j];
            if (a[i][j] == 2) {
                sx = i, sy = j;
            }
        }

        ans = INF;
        dfs(sx, sy, 1);

        cout << (ans == INF ? -1 : ans) << endl;
    }
}

Measured memory_bytes: 3140
#include <iostream>

#include <fstream>

#include <cstdio>

#include <cmath>

#include <vector>

#include <cstring>

#include <string>

#include <set>

#include <map>

#include <stack>

#include <queue>

#include <algorithm>

using namespace std;

int main(){
  int N;
  cin >> N;
  int a,b,c,d;
  a = N/1000;
  b = (N-a*1000)/100;
  c = (N-a*1000-b*100)/10;
  d = N-a*1000-b*100-c*10;
  if(a==b && b==c){
    printf("Yes");
  }else if(b==c && c==d){
    printf("Yes");
  }
  else{
    printf("No");
  }
  return 0;
}



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

int main()
{
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if(abs(c-a) <= d || 
    abs(b-a) <= d && abs(c-b) <= d)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 3568
#include <bits/stdc++.h>
#define sz(x) (int((x).size()))
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
template<typename T> bool domax(T &a, T b) { return (b > a ? (a = b, true) : false); }
template<typename T> bool domin(T &a, T b) { return (b < a ? (a = b, true) : false); }
typedef long long ll;

int n;
char s[1005];
bool k[256];

int main() {
    scanf("%s", s);
    n = strlen(s);
    for (int i = 0; i < n; i++) {
        k[s[i]] = true;
    }
    printf("%s\n", ((k['N']==k['S']) && (k['E'] == k['W'])) ? "Yes" : "No");
}


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

int main(){
	double xa, ya, ra, xb, yb, rb;
	int n;
	cin >> n;
	while( n-- ){
		cin >> xa >> ya >> ra >> xb >> yb >> rb;
		double diff = sqrt((xa-xb)*(xa-xb)+(ya-yb)*(ya-yb));
		if( diff + rb < ra ){
			cout << "2" << endl;
		}else if( diff + ra < rb ){
			cout << "-2" << endl;
		}else if( diff <= ra + rb ){
			cout << "1" << endl;
		}else{
			cout << "0" << endl;
		}
	}
}

Measured memory_bytes: 1224
#include<bits/stdc++.h>
using namespace std;
using ll = long long;

int main()
{
    string s;
    cin >> s;
    if(s == "Sunny") cout << "Cloudy" << endl;
    else if(s == "Cloudy") cout << "Rainy" << endl;
    else cout << "Sunny" << endl;
    return 0;
}

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

using namespace std;


int canw[33], cans[3003];
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int a, b, c, d, e, f;
  cin >> a >> b >> c >> d >> e >> f;
  pair<int, int> ans = {0, a*100};
  for (int A = 0; A < 33; ++A) {
    for (int B = 0; B < 33; ++B) {
      if(A*a+B*b>31) continue;
      canw[A*a+B*b] = 1;
    }
  }
  for (int C = 0; C < 3000; ++C) {
    for (int D = 0; D < 3000; ++D) {
      if (C*c+D*d>3000) continue;
      cans[C*c+D*d] = 1;
    }
  }
  for (int s = 0; s < 3000; ++s) {
    for (int w = 0; w < 3000; w+=100) {
      if (s+w>f) continue;
      if (!canw[w/100]) continue;
      if (!cans[s]) continue;
      if (s*100>e*w) continue;
      if (s*ans.second>w*ans.first) {
        ans.first = s;
        ans.second = w;
      }
    }
  }
  cout << (ans.first+ans.second) << " " << ans.first << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {


    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        main2(sc);
    }

    public static void main2(Scanner sc) {

        int N = sc.nextInt();
        double sum = 0;

        for (int i = 0; i < N; i++) {
        	double x = sc.nextDouble();
        	sum += 1/x;
        }

        System.out.println(1/sum);
    }
}

Measured memory_bytes: 22484
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <cassert>
#include <cmath>


using namespace std;
using ll = long long int;

#define rep(i, n) for(ll i = 0; i < (n); i++)
#define MOD 1000000007

int main() {
  cin.tie(nullptr); ios::sync_with_stdio(false);
  ll N, K; cin >> N >> K;

  ll sum = 0;
  for (ll j = K; j <= N + 1; j++) {
    ll mx = N * (N + 1) / 2 - (N - j) * ((N - j + 1)) / 2;
    ll mn = (j - 1) * j / 2;
    ll a = mx - mn + 1;
    sum += a % MOD;
    sum %= MOD;
  }

  cout << sum << endl;

  return 0;
}

Measured memory_bytes: 3160
#include<bits/stdc++.h>
    #define ll long long
    #define rep(i,a,b) for(i=a;i<b;i++)
    #define pb push_back
    #define all(v) v.begin(),v.end()
    #define F first
    #define S second
    #define CLR(a) memset((a),0,sizeof(a))
    #define mp make_pair
    #define hell 1000000007

    using namespace std;
     //int g[105][105];
    //vector < int > wt(100004);
   // vector < int > a;
    //vector < int > v(30500);
    //int cst[102][100005];
    //int ansr[100005];
 //ll int sum,x=0,c=0,n,m,flag=0,a1,a2,flag1=0,flag2=0;
    //vector < vector < int > > adj(5000, vector < int > (5000));
 //int  dp[1000006];
   // int level[500];




    void solve()
    {
        int i,j=0,r=200,p,q,k=0,ans=0,d,h,flag=0,n,m=0,a,b,id,c,h1,h2,a1,b1;
         cin>>n;
         vector < vector < int > > dp(n,vector < int > (3));
         vector < int > va(n),vb(n),vc(n);
         rep(i,0,n)
           {
               cin>>va[i]>>vb[i]>>vc[i];
           }
           dp[0][0]=va[0];
           dp[0][1]=vb[0];
           dp[0][2]=vc[0];
           rep(i,1,n)
             {
                 dp[i][0]=max(dp[i-1][1],dp[i-1][2])+va[i];
                 dp[i][1]=max(dp[i-1][0],dp[i-1][2])+vb[i];
                 dp[i][2]=max(dp[i-1][0],dp[i-1][1])+vc[i];
             }
             cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<endl;



    }



    int main()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        int t=1;
        //cin>>t;
        while(t--)
        solve();
    }

       /*

  void bfs( int i , int j)
       {
           vis[i][j]= true;
         queue < int > que;
         que.push(k);
         while(!que.empty())
         {
            int x= que.front();
            que.pop();
             for ( int i=1;i<=n;i++)
             {
                 if((!g[1][n] and g[x][i] ) or (g[1][n] and ! g[x][i]))
                 {
                   if(!vis[i])
                   {
                       que.push(i);
                       level[i]=level[x]+1;
                       vis[i]= true;
                   }
                 }
             }
         }
       }

      ll int por(ll int a,ll int b)
         {
            ll int k=1;
            while(b>0)
            {
                if(b%2) k=k*a,k%=hell;
                b/=2;
                a*=a; a%=hell;
            }
            return k;
         } */


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

using namespace std;


double rast(double x1,double y1,double x2, double y2)
{
    return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
}



int main()
{
    //freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);

    string s;
    cin >> s;
    int n=s.size();

    int cur=0;
    vector <int> ans(n,0);
    for (int i=0;i<n;i++)
        {
            if (s[i]=='R')
                cur++;
            else
            {
                ans[i]+=cur/2;
                ans[i-1]+=cur/2+cur%2;
                cur=0;
            }
        }

    cur=0;
    for (int i=n-1;i>=0;i--)
    {
        if (s[i]=='L')
            cur++;
        else
        {
            ans[i]+=cur/2;
            ans[i+1]+=cur/2+cur%2;
            cur=0;
        }
    }

    for (int i:ans)
        cout << i << " ";
}


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

int main()
{
	int W, H, x, y, r;
	cin >> W >> H >> x >> y >> r;
	if (0 <= x - r && x + r <= W && 0 <= y - r &&y + r <= H)
	{
		cout << "Yes\n";
	}
	else
	{
		cout << "No\n";
	}

	return 0;
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9 + 10;
const ll MOD = 1e9 + 7;

const int MAXN = 1e4 + 5;

char c[MAXN], c1[MAXN], c2[MAXN];

char ans[MAXN];

char minc;

int n, k;

void str_double (char *c) {
	REP(i, 0, n) {
		c[2 * n - 1 - i] = c[i];
	}
}


int my_strcmp(char *c1, char *c2) {
	for(int i = 0; c1[i]; i++) {
		if (c1[i] != c2[i]) {
			return c1[i] < c2[i] ? -1 : 1;
		}
	}
	return 0;
}

void process() {
	int len = 0;
	for(int i = n - 1; i >= 0 && c2[i] == minc; i--, len++);
	//printf("%d %d\n", k, len);
	REP(j, 0, k - 1) {
		str_double(c2);
		REP(i, 0, n) {
			c2[i] = c2[i + len];
		}
		c2[n] = 0;
		//printf("%s\n", c2);
		len = min(len * 2, n);
	}
	str_double(c2);
	c2[2 * n - len] = 0;
	if (my_strcmp(ans, c2 + n - len) == 1) {
		strcpy(ans, c2 + n - len);
	}
}



void solve(){
	//printf("aabca\n");
	//return;
	
	scanf("%d%d%s", &n, &k, &c[0]);
	strcpy(ans, c);
	strcpy(c1, c);
	str_double(c1);
	//printf("%s\n", c1);
	if (k == 1) {
		REPN(i, 0, n) {
			REP(j, i, i + n) {
				c2[j - i] = c1[j];
			}
			//printf("%s\n", c2);
			if (my_strcmp(ans, c2) == 1) {
				strcpy(ans, c2);
			}
		}
		printf("%s\n", ans);
		return;
	}
	minc = 'z';
	REP(i, 0, n) {
		minc = min(minc, c[i]);
	}
	int lim = 1;
	for(int i = 1; i < n; i *= 2, lim++);
	
	//printf("%d\n", lim);
	
	if (k >= lim) {
		REP(i, 0, n) {
			putchar(minc);
		}
		putchar('\n');
		return;
	}
	
	REP(i, n - 1, 2 * n) {
		if (c1[i] == minc && (i == n - 1 || c1[i + 1] != minc)) {
			REPN(j, i - n + 1, i) {
				c2[j - (i - n + 1)] = c1[j];
			}
			c2[n] = 0;
			//printf("%d %s\n", i, c2);
			process();
		}
		if (i == n - 1) {
			k--;
		}
	}
	
	printf("%s\n", ans);
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


Measured memory_bytes: 256
import java.util.*;
import java.util.List;
import java.util.Arrays;
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int time = sc.nextInt();
        List<Integer> c = new ArrayList<>();
        List<Integer> t = new ArrayList<>();

        for (int i = 0; i < n; i++) {
            c.add(sc.nextInt());
            t.add(sc.nextInt());

        }
        for (int i = n - 1; i >= 0; i--) {
            if (t.get(i) > time) {
                c.remove(i);
                t.remove(i);
            }
        }
        if (c.size() > 0) {
            Collections.sort(c);
            System.out.println(c.get(0));
        } else {
            System.out.println("TLE");
        }
    }

}





Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,M; 
  cin>>N>>M;
  vector<int> cnt(M,0);
  for(int i=0;i<N;++i){
     int K; cin>>K;
     for(int j=0;j<K;++j){
      int S; cin>>S;
      ++cnt[S-1];
       }
 }
  int T=0;
  for(int f=0;f<M;++f){
     if(cnt[f]==N){
         ++T;
     }
   }
  cout<<T;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	char Sa[101]="";
	char Sb[101]="";
	char Sc[101]="";
	scanf("%s",Sa);
	scanf("%s",Sb);
	scanf("%s",Sc);
	int ai = 0;
	int bi = 0;
	int ci = 0;
	char turn = 'a';
	while(1){
		if(turn == 'a' && Sa[ai] == 'a'){
			ai++;
		}else if(turn == 'a' && Sa[ai] == 'b'){
			ai++;
			turn = 'b';
		}else if(turn == 'a' && Sa[ai] == 'c'){
			ai++;
			turn = 'c';
		}else if(turn == 'b' && Sb[bi] == 'a'){
			bi++;
			turn = 'a';
		}else if(turn == 'b' && Sb[bi] == 'b'){
			bi++;
		}else if(turn == 'b' && Sb[bi] == 'c'){
			bi++;
			turn = 'c';
		}else if(turn == 'c' && Sc[ci] == 'a'){
			ci++;
			turn = 'a';
		}else if(turn == 'c' && Sc[ci] == 'b'){
			ci++;
			turn = 'b';
		}else if(turn == 'c' && Sc[ci] == 'c'){
			ci++;
		}else if(turn == 'a' && Sa[ai] == '\0'){
			printf("A\n");
			break;
		}else if(turn == 'b' && Sb[bi] == '\0'){
			printf("B\n");
			break;
		}else if(turn == 'c' && Sc[ci] == '\0'){
			printf("C\n");
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
     #include<stdlib.h>
     int comp(const void*a,const void*b)
     {
         return *(int*)a-*(int*)b;
     }
     int main(int argc, char *argv[])
     {
        int number[100000];
        int n,i,x=0,j,t,c;
        scanf("%d",&n);
        for(i=0;i<n;i++)
            scanf("%ld",&number[i]);
        qsort(number,n,sizeof(int),comp);
        c=number[n/2]-number[n/2-1];
        printf("%d\n",c);
        return 0;
     }

Measured memory_bytes: 892
from collections import defaultdict
n = int(input())
a = [0] + [int(x) for x in input().split()]

d1 = defaultdict(int)
d2 = defaultdict(int)

for i in range(1,n+1):
    d1[i-a[i]] += 1
    d2[i+a[i]] += 1

ans = 0

for k in d1.keys():
    ans += d1[k]*d2[k]
print(ans)

Measured memory_bytes: 71216
#include<stdio.h>
int main(void){
    while(1){
        int n,m;
        scanf("%d %d",&n,&m);
        if(n==0&&m==0)break;
        int log=0,count1=1,count2=1,array[1000]={0};
        while(log!=count1){
            //printf("<log=%d count1=%d array[count1]=%d>\n",log,count1,array[count1]);
            if(array[count1]==0){
                log=0;log+=count1;
                if(count1<n&&count2<m){
                    count1+=1;count2+=1;//printf("<a>\n");
                }
                else if(count1<n&&count2==m){
                    array[count1]=1;count1+=1;count2=1;//printf("<b>\n");
                }
                else if(count1==n&&count2<m){
                    count1=1;count2+=1;//printf("<c>\n");
                }
                else if(count1==n&&count2==m){
                    array[n]=1;count1=1;count2=1;//printf("<d>\n");
                }
            }
            else if(array[count1]==1){
                if(count1<n){
                    count1+=1;//printf("<e>\n");
                }
                else if(count1==n){
                    count1=1;//printf("<f>\n");
                }
            }
            //printf("<log=%d count1=%d array[count1]=%d>\n",log,count1,array[count1]);
            //printf("\n");
        }
    printf("%d\n",count1);
    }
return 0;
}

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

int main(){
int N;
  cin >> N;
  vector<int> x(N),y(N),h(N);
  for(int i=0;i<N;i++){
    cin >> x[i] >> y[i] >> h[i];
  }
int max=100;
  for(int posy=0;posy<=max;posy++){
    for(int posx=0;posx<=max;posx++){
    int needh=-1;
      for(int i=0;i<N;i++){
        if(h[i]>0){
          int tmp=h[i]+abs(posy-y[i])+abs(posx-x[i]);
          if(needh==-1){
           needh=tmp;
          }
          else{
            if(needh!=tmp){
            needh=-2;
            break;
            }
          }
        }
      }
     if(needh==-2) continue;
     for(int i=0;i<N;i++){
       if(h[i]==0){
       int dist = abs(posy-y[i])+abs(posx-x[i]);
         if(needh>dist){
           needh=-2;
           break;
         }
       }
     } 
     if(needh==-2)continue;
     cout << posx << " " << posy << " " << needh << endl;
    }
  }


}


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

int main(){
  int a, b;
  cin >> a >> b;
  if((a + b)%2 == 0){
    cout << (a + b)/2 << endl;
  }
  else{
    cout << (a + b)/2 + 1 << endl;
  }
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val s = readLine()!!
    val stack = mutableListOf<Char>()
    for (c in s) {
        if (c == 'B') {
            if (stack.isNotEmpty()) {
                stack.removeAt(stack.size - 1)
            }
        } else {
            stack.add(c)
        }
    }
    println(stack.joinToString(""))
}

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

int main() {
  ll H, W;
  cin >> H >> W;

  ll ans = 1e15;
  for (int i = 0; i < 2; ++i) {
    ll x, y;
    if (i == 0) {
      x = H;
      y = W;
    } else {
      x = W;
      y = H;
    }

    for (int j = 1; j < x; ++j) {
      ll a = j * y;
      ll h = (x - j) / 2;
      
      ll b = h * y;
      ll c = ((x - j) - h) * y;
      ll ma = max(max(a, b), c);
      ll mi = min(min(a, b), c);
      ans = min(ans, ma - mi);
      
      h = y / 2;
      b = (x - j) * h;
      c = (x - j) * (y - h);

      ma = max(max(a, b), c);
      mi = min(min(a, b), c);
      ans = min(ans, ma - mi);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){

        Scanner sc = new Scanner(System.in);

        int[] x,n,N;
        x = new int[300];
        n = new int[100];
        N = new int[1000];


        for(int i=0;;i++){
            n[i] = sc.nextInt();
            x[i] = sc.nextInt();
            if(x[i]==0 && n[i]==0)  break;
            for(int j= (x[i]-n[i]<3 ? x[i]-3:n[i]);j>x[i]/3;j--){
                int y=0;
                y = x[i] - j;
                for(int k=(y<j ? y-1:j-1);k>y/2;k--){
                    if(k!=y-k && j!=k && j!=y-k )  N[i]++;
                }
            }
            System.out.println(N[i]);

        }

    }
}


Measured memory_bytes: 26408
#include <stdio.h>
#include <iostream>
#include <cstdio>
#include <algorithm> 
#include <stdio.h>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <list>
#include <utility>
#include <set>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <bitset>
#include <stdio.h>
#include <string.h>
#include <assert.h>
#include <random>

using namespace std;

static const double EPS = 1e-9;
template<class T> bool INRANGE(T x, T a, T b) { return a <= x&&x <= b; }
template<class T> void amin(T &a, T v) { if (a > v) a = v; }
template<class T> void amax(T &a, T v) { if (a < v) a = v; }
int ROUND(double x) { return (int)(x + 0.5); }
bool ISINT(double x) { return fabs(ROUND(x) - x) <= EPS; }
bool ISEQUAL(double x, double y) { return fabs(x - y) <= EPS*max(1.0, max(fabs(x), fabs(y))); }
double SQSUM(double x, double y) { return x*x + y*y; }
#define PI  (acos(-1))
#define ARRAY_NUM(a) (sizeof(a)/sizeof(a[0])) 
#define NG (-1)
#define BIG ((int)1e9+10)
#define BIGLL ((ll)4e18)
#define SZ(a) ((int)(a).size())
#define SQ(a) ((a)*(a))
typedef unsigned long long ull;
typedef long long ll;



int main()
{
	ll a,b,c;
	cin >> a >> b >> c;

	for (int i=0;i<1000000;i++)
	{
		if (a % 2 || b % 2 || c % 2)
		{
			printf("%d\n", i);
			return 0;
		}
		ll na = (b+c)/2;
		ll nb = (c+a)/2;
		ll nc = (a+b)/2;

		a = na;
		b = nb;
		c = nc;
	}

	printf("%d\n", -1);
	return 0;
}


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

int main() {
  string s;
  cin >> s;
  int length = 0;
  int max_length = 0;
  bool is_acgt = false;

  for (char x : s) {
    if (x == 'A' || x == 'C' || x == 'G' || x == 'T') {
      if (!is_acgt) {
        is_acgt = true;
        length = 1;
      } else {
        length++;
      }
    } else if (is_acgt) {
      is_acgt = false;
      max_length = max(max_length, length);
    }
  }
  max_length = max(max_length, length);

  cout << max_length << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define pf push_front
#define all(t) t.begin(), t.end()
#define inrange(i, a, b) (((i)>= min((a), (b))) && ((i) <= max((a), (b))))
typedef vector<ll> vi;
typedef pair<ll, ll> pii;
#define fi first
#define se second
#define upb upper_bound
#define lwb lower_bound
#define show(x) cout << #x << " is " << x << "\n";
const ll inf = 2e18;
const ll mod = 7;
const ld pi = 3.141592653589793238462643383279502884;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

void print(ll a[], ll n){for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<"\n";}
ll power(ll x, ll y){
    if(y<=0) return 1;
    ll ans = 1;
    x %= mod;
    while(y){
        if(y&1)
            ans = (x * ans) % mod;
        x = (x * x) % mod;
        y >>= 1;
    }
    return ans;
}
ll modInverse(ll n) {return power(n, mod-2);}
inline ll mul(ll a, ll b){ return (a * b) % mod; }
inline ll sub(ll a, ll b){ ll c = (a - b); if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = (a + b); if(c >= mod) c -= mod; return c; }
inline ll divi(ll a, ll b){ return mul(a, modInverse(b)); }

//------------------------------------------------------------------------------------------

//const ll N = 2e5 + 1;
//vector<ll> adj[N];
//bool visited[N];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cout<<fixed<<setprecision(10);


	ll k;
	cin>>k;
	if(k%2==0) cout<<-1;
	else {
		int c=1;
		int flag=0;
		ll val=0;
		for(int i=1;i<=1000000;i++){
			val = ((val*10)+7)%k;
			if(val==0){
				cout<<i;
				flag=1;
				break;
			}
		}
		if(flag==0) cout<<-1;
	}
    return 0;
}


Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define MAX 200010
#define inf 1<<29
#define linf 1e18
#define eps (1e-8)
#define mod 1000000007
#define pi M_PI
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define pd(a) printf("%.10f\n",(double)(a))
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(a)-1;(b)<=i;i--)
#define equals(a,b) (fabs((a)-(b))<eps)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<double,int> pdi;
typedef vector<int> vi;
typedef vector<pii> vpi;
const int dx[8]={1,0,-1,0,1,1,-1,-1};
const int dy[8]={0,1,0,-1,1,-1,1,-1};

int main()
{
  int n;
  int l[MAX],r[MAX];
  map<int,int> L,R;
  string s;

  cin>>n>>s;

  FOR(i,0,n)if(s[i]=='>')l[i]++;
  RFOR(i,n,0)if(s[i]=='<')r[i]++;
  FOR(i,1,n)l[i]+=l[i-1];
  RFOR(i,n,1)r[i-1]+=r[i];
  FOR(i,0,n){
    if(s[i]=='>')l[i]--;
    else r[i]--;
  }
  FOR(i,0,n)L[l[i]]=i;
  RFOR(i,n,0)R[r[i]]=i;
 
  int ans=0;
  FOR(i,0,n){
    if(s[i]=='>'){
      if(l[i]<r[i])ans=max(ans,R[r[i]-l[i]-1]+1);
      else ans=max(ans,n-L[l[i]-r[i]]);
    }
    else {
      if(l[i]<=r[i])ans=max(ans,R[r[i]-l[i]]+1);
      else ans=max(ans,n-L[l[i]-r[i]-1]);
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 8628
#include <bits/stdc++.h>
#define FOR(i,k,n) for(int i=(k);i<(int)(n);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;

int main() {
  string s;
  cin >> s;
  int len = s.size();
  int n;
  cin>>n;
  vector<vector<int>> ranges(len);
  REP(i,n) {
    int l, r;
    cin>>l>>r;
    --l;--r;
    int a, b;
    if (r >= len/2) {
      if (l >= len/2) {
        a = len-r-1;
        b = len-l-1;
      } else if (l-1 >= len-r-1) {
        a = len-r-1;
        b = l-1;
      } else {
        a = l;
        b = len-r-1-1;
      }
    } else {
      a = l;
      b = r;
    }
    if (a <= b) {
      ranges[a].push_back(b);
    }
  }
  REP(i,len) {
    if (ranges[i].size() > 1) {
      sort(ALL(ranges[i]));
      ranges[i].erase(unique(ALL(ranges[i])), end(ranges[i]));
      int m = ranges[i].size();
      REP(j,m-1) {
        ranges[ranges[i][j]+1].push_back(ranges[i][j+1]);
      }
      ranges[i].erase(begin(ranges[i])+1, end(ranges[i]));
    }
  }
  using T = pair<int,int>;
  priority_queue<T, vector<T>, greater<T>> q;
  int sum = 0;
  vector<int> t(len);
  REP(i,len) {
    t[i] = s[i] - 'a';
  }
  bool ok = true;
  REP(i,len/2) {
    if ((t[i]+sum)%26 != t[len-i-1]) {
      if (ranges[i].empty()) {
        ok = false;
        break;
      }
      int diff = (t[len-i-1] + 26 - (t[i]+sum)%26)%26;
      sum += diff;
      q.emplace(ranges[i][0], diff);
    }
    while (!q.empty() && q.top().first == i) {
      sum -= q.top().second;
      q.pop();
    }
  }
  if (ok) {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  return 0;
}


Measured memory_bytes: 7680
#define _USE_MATH_DEFINES
#include "bits/stdc++.h"
#define rep(i,a,b) for (int i = (a); i < (b); i++)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const int inf = 2e9;

vector<vector<P>> g;
vector<int> ans;
void dfs(int now,int col) {
	if (ans[now] >= 0) return;
	ans[now] = col;
	for (P p : g[now]) {
		if (ans[p.first] >= 0) continue;
		if (p.second % 2 == 0) dfs(p.first, col);
		else dfs(p.first, col ^ 1);
	}
	return;
}

int main() {
	int n; cin >> n;
	ans.resize(n, -1); g.resize(n);
	rep(i, 0, n - 1) {
		int u, v, w; cin >> u >> v >> w;
		u--; v--;
		g[u].push_back({ v,w });
		g[v].push_back({ u,w });
	}
	dfs(0, 0);
	rep(i, 0, n) printf("%d\n", ans[i]);
	return 0;
}


Measured memory_bytes: 9600
import sys
## io
IS = lambda: sys.stdin.readline().rstrip()
II = lambda: int(IS())
MII = lambda: list(map(int, IS().split()))
MIIZ = lambda: list(map(lambda x: x-1, MII()))
## dp
INIT_VAL = 0
MD2 = lambda d1,d2: [[INIT_VAL]*d2 for _ in range(d1)]
MD3 = lambda d1,d2,d3: [MD2(d2,d3) for _ in range(d1)]
## math
DIVC = lambda x,y: -(-x//y)
DIVF = lambda x,y: x//y

def main():
    n = II()
    dd = [II() for _ in range(n)]
    print(len(set(dd)))

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
//Attack Survival
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();//参加者
    int k=sc.nextInt();//初期ポイント
    int q=sc.nextInt();//正解数
    int count1[]=new int[n+1];
    int count2[]=new int[n+1];
    int a[]=new int[n+1];

    for (int i=1;i<=q;i++) {
      int m=sc.nextInt();
      count1[m]++;
    }

    for (int i=1;i<=n;i++) {
      count2[i]=q-count1[i];
    }

    for (int i=1;i<=n;i++) {
      a[i]=k-count2[i];
      if (a[i]>0) {
        System.out.println("Yes");
      }else{
        System.out.println("No");
      }
    }

  }
}


Measured memory_bytes: 66432
#include <stdio.h>

int main() {
  int n;
  int tmp;
  int max = -2000000000, min;

  scanf("%d", &n);
  scanf("%d", &tmp);
  min = tmp;

  int i;
  for (i = 0; i < n-1; i++) {
    scanf("%d", &tmp);
    if (max < tmp-min) {
      max = tmp-min;
    }
    if (min > tmp) {
      min = tmp;
    }
  }

  printf("%d\n", max);
  
  
  return 0;
}


Measured memory_bytes: 2108
#include <stdio.h>

main(){

  long d = 1;
  long a,b,c;

  scanf("%ld %ld",&a,&b);

if(b>a){
c = a;
a = b;
b = c;
}

  while(d != 0){
    d = a % b;
    a = b;
    b = d;
  }

  printf("%ld\n",a);

}

Measured memory_bytes: 0
#include<bits/stdc++.h>
    using namespace std;
    typedef long long ll;
    //--<for debugging>
    #define whatis(x) cout << #x << " is " << x<<" ";
    #define whatisl(x) cout << #x << " is " << x<<"\n";
    #define parr(array,end)for(ll loop=0;loop<end;loop++)cout<<array[loop]<<" ";cout<<"\n";
    #define lline cout<<"\n";
    #define errorl(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout<<"\n";}
    #define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args);cout<<"___";}
        
    void err(istream_iterator<string> it) {}
    template<typename T, typename... Args>
    void err(istream_iterator<string> it, T a, Args... args) {
        cout << *it << " = " << a <<" , ";
        err(++it, args...);
    }
    //--</for debugging> 
    #define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
    #define testcase ll tt; cin >> tt; while(tt--)
    #define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
    #define pb push_back 
    #define vars ll h,i,j,k,d,l,p,q,r,x,y,a,b,c,v,var,n,m,z,s,ans,ind1,ind2,flag,limit1,limit2,limit3,mod;string str;
    #define vll vector<ll>
    #define pll pair<ll,ll>
    #define sll set<ll>
    #define pint pair<int,int>
    const ll INF=1e9+7;
    const ll MOD=1e9+7;
    const string yes="Yes\n";
    const string no="No\n";
    int main()
    {
        boost vars
        //freopen("input.txt","r",stdin);
        //freopen("output.txt","w",stdout);
        cin>>str;
        n=str.length();
        s=0;
        for(i=0;i<n;i++)
        {
            s+=str[i]-'0';
        }
        if(s%9==0)cout<<yes;
        else cout<<no;
    }

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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
	int N; cin >> N;
	string S; cin >> S;
	int x = 0, M = 0;
	for(int i = 0; i < N; i++) {
		if(S[i] == 'I') x++;
		else x--;
		M = max(M, x);
	}
	cout << M << endl;
	return 0;
}

Measured memory_bytes: 3628
#include <iostream>
#include <math.h>

using namespace std;
#define value 0.006


int main(void) {
    int N, T, A;
    cin >> N >> T >> A;

    int aim = (T - A) / value;
    int diffe, ans;
    int min = 2147483647;
    int H[N], i;
    for (i = 0; i < N; i++) {
        cin >> H[i];
        diffe = abs(aim - H[i]);
        if (min > diffe) {
            min = diffe;
            ans = i+1;
        }

    }

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
//using namespace __gnu_pbds;

#define ll       long long
#define PR       pair<ll, ll>
#define READ(f)  freopen(f, "r", stdin)
#define WRITE(f) freopen(f, "w", stdout)

const int N = 3e5 + 5;
const int MOD = 1e9 + 7;
const double PI = 2 * acos(0.0);
//template<typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

string s;
vector<ll> ids[5];

ll GO(int i, int x, int y, char X, char Y) {
    ll ans = 0;
    for (int j = 0; j < ids[x].size(); j++) {
        if (ids[x][j] < i) continue;
        int d = ids[x][j] - i;
        int l = 0, r = ids[y].size() - 1, got = -1;
        while (l <= r) {
            int m = l + r >> 1;
            if (ids[y][m] > ids[x][j]) {
                got = m;
                r = m - 1;
            } else {
                l = m + 1;
            }
        }
        if (got == -1) continue;
        int have = (int)ids[y].size() - got;
        int bad = ids[x][j] + d;
        if (bad < s.size() && s[bad] == X) {
            have--;
        }
        ans += have;
    }
    for (int j = 0; j < ids[y].size(); j++) {
        if (ids[y][j] < i) continue;
        int d = ids[y][j] - i;
        int l = 0, r = ids[x].size() - 1, got = -1;
        while (l <= r) {
            int m = l + r >> 1;
            if (ids[x][m] > ids[y][j]) {
                got = m;
                r = m - 1;
            } else {
                l = m + 1;
            }
        }
        if (got == -1) continue;
        int have = (int)ids[x].size() - got;
        int bad = ids[y][j] + d;
        if (bad < s.size() && s[bad] == Y) {
            have--;
        }
        ans += have;
    }
    return ans;
}

int main() {
//    ios::sync_with_stdio(false);
//    cin.tie(0);
    int n;
    cin >> n >> s;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'R') {
            ids[0].push_back(i);
        } else if (s[i] == 'G') {
            ids[1].push_back(i);
        } else {
            ids[2].push_back(i);
        }
    }
    ll ans = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == 'R') {
            ans += GO(i, 1, 2, 'B', 'G');
        } else if (s[i] == 'G') {
            ans += GO(i, 0, 2, 'B', 'R');
        } else {
            ans += GO(i, 0, 1, 'G', 'R');
        }
    }
    cout << ans << '\n';
    return 0;
}


Measured memory_bytes: 3668
from logging import getLogger, basicConfig, DEBUG
basicConfig(level=DEBUG)
LOGGER = getLogger(__name__)

N = int(input())

def calc(n):
    list = [int(s) for s in str(n)]
    return sum(list)

def main():
    result = calc(N)
    # LOGGER.debug(result)
    if N % result == 0:
        ans = 'Yes'
    else:
        ans = 'No'
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 4212
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n, m; cin >> n >> m;
    vector<pair<long long, int>> v;
    for (int i = 0; i < n; i++) {
        long long a; int b;
        cin >> a >> b;
        v.emplace_back(a, b);
    }
    sort(v.begin(), v.end());
    long long ans = 0;
    for (auto x: v) {
        int t = min(m, x.second);
        m -= t;
        ans += x.first * t;
        if (m == 0) break;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2420
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,l,r) for(long long i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REPS(i,n) FOR(i,1,n+1)
#define RFOR(i,l,r) for(long long i=(l);i>=(r);--i)
#define RREP(i,n) RFOR(i,n-1,0)
#define RREPS(i,n) RFOR(i,n,1)
#define int long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
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;
}
const int INF=1e18;
const int MOD=998244353;
const int MAX=300001;
int fac[MAX],finv[MAX],inv[MAX];

void COMinit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<MAX;i++){
        fac[i]=fac[i-1]*i%MOD;
        inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;
        finv[i]=finv[i-1]*inv[i]%MOD;
    }
}

int COM(int n,int k){
    if(n<k)return 0;
    if(n<0||k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%MOD)%MOD;
}

int powMOD(int n,int r){
    if(r==0)return 1;
    if(r%2==0)return powMOD(n,r/2)*powMOD(n,r/2)%MOD;
    if(r%2==1)return powMOD(n,r-1)*n%MOD;
}

signed main(){
    int n;cin>>n;n-=2;
    if(n==1){
      	cout<<2<<" "<<5<<" "<<63<<endl;
      	return 0;
    }
    cout<<3<<" "<<9<<" ";
    if(n<=10000){
        REP(i,n/2)cout<<2+6*i<<" "<<4+6*i<<" ";
        if(n%2!=0)cout<<6<<endl;
        return 0;
    }
    if(n<=14998){
        REP(i,5000)cout<<2+6*i<<" "<<4+6*i<<" ";
        REP(i,(n-10000)/2)cout<<15+12*i<<" "<<21+12*i<<" ";
        if(n%2!=0)cout<<6<<endl;
        return 0;
    }
    REP(i,5000)cout<<2+6*i<<" "<<4+6*i<<" ";
    REP(i,2499)cout<<15+12*i<<" "<<21+12*i<<" ";
    REPS(i,n-14998)cout<<6*i<<" ";
    cout<<endl;
}

Measured memory_bytes: 384
n,x = gets.chomp.split(" ").map(&:to_i)
l_arr = gets.chomp.split(" ").map(&:to_i)

count = 1

d = 0
l_arr.each do |l|
  d = d + l
  if (d <= x) then
    count += 1
  end
end

puts count


Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

constexpr int inf = 0x3f3f3f3f;
constexpr ll linf = 0x3f3f3f3f3f3f3f3fLL;

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

    int n; cin >> n;
    cout << n * 800 - (n / 15) * 200 << endl;
    return 0;
}


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

bool p[200000];

void erato(){
	fill(p, p+200000, true);
	p[0] = p[1] = false;

	for(int i=0; i*i < 200000; i++){
		if(!p[i]) continue;

		for(int j= i+i; j < 200000; j += i){
			p[j] = false;
		}
	}
}

int main(){
	erato();
	int ans, num, input;
	while(cin >> input, input){
		ans = 0; num = 0;
		for(int i=0; i < 200000; i++){
			if(p[i]){
				ans += i;
				num++;
			}
			if(num == input) break;
		}
		cout << ans << endl;
	}

}

Measured memory_bytes: 1356
import Control.Monad
import Data.Maybe
import qualified Data.ByteString.Char8 as BS
import Data.List
import qualified Data.Vector.Unboxed as VU

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
    q <- getInt
    lrs <- replicateM q $ do
        [l, r] <- getIntList
        return (l, r)
    let ps = VU.fromList . scanl' (+) (0 :: Int) $ map (\p -> if isPrime p && isPrime ((p+1) `div` 2) then 1 else 0) [1..100000]
        ans = map (\(l,r) -> ps VU.! r - ps VU.! (l-1)) lrs
    mapM_ print ans

primes = primes'
  where
    primes' = [2, 3, 5] ++ f 5 7 (drop 2 primes')
    f m s (p:ps) = [n | n <- ns, gcd m n == 1] ++ f (m * p) (p * p) ps
      where
        ns = [x + y | x <- [s,s + 6 .. p * p - 2], y <- [0, 4]]

isPrime n = (n > 1) && isPrime' primes
  where
    isPrime' (x:xs)
      | x * x > n = True
      | rem n x == 0 = False
      | otherwise = isPrime' xs

Measured memory_bytes: 40316
/**
*    author:  yuya1234
*    created: 13.07.2020 16:42:02
**/

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define FORV(i,v) for(auto i=v.begin(); i!=v.end();i++)

#define SORT(s) sort((s).begin(),(s).end())
#define SORTD(s) sort((s).rbegin(),(s).rend())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define SZ(x) ((int)(x).size())
#define MEMSET(v, h) memset((v), h, sizeof(v))

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}

template< typename T >
struct Combination {
  vector< T > _fact, _rfact, _inv;

  Combination(int sz) : _fact(sz + 1), _rfact(sz + 1), _inv(sz + 1) {
    _fact[0] = _rfact[sz] = _inv[0] = 1;
    for(int i = 1; i <= sz; i++) _fact[i] = _fact[i - 1] * i;
    _rfact[sz] /= _fact[sz];
    for(int i = sz - 1; i >= 0; i--) _rfact[i] = _rfact[i + 1] * (i + 1);
    for(int i = 1; i <= sz; i++) _inv[i] = _rfact[i] * _fact[i - 1];
  }

  inline T fact(int k) const { return _fact[k]; }

  inline T rfact(int k) const { return _rfact[k]; }

  inline T inv(int k) const { return _inv[k]; }

  T P(int n, int r) const {
    if(r < 0 || n < r) return 0;
    return fact(n) * rfact(n - r);
  }

  T C(int p, int q) const {
    if(q < 0 || p < q) return 0;
    return fact(p) * rfact(q) * rfact(p - q);
  }

  T H(int n, int r) const {
    if(n < 0 || r < 0) return (0);
    return r == 0 ? 1 : C(n + r - 1, r);
  }
};

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  //std::cout << std::fixed << std::setprecision(15);

  int n;
  cin>>n;

  string s[n];
  ll cnt[5];
  MEMSET(cnt,0);
  REP(i,n){
    cin>>s[i];
    if(s[i][0]=='M')cnt[0]++;
    else if(s[i][0]=='A')cnt[1]++;
    else if(s[i][0]=='R')cnt[2]++;
    else if(s[i][0]=='C')cnt[3]++;
    else if(s[i][0]=='H')cnt[4]++;
  }

  ll ans=0;
  REP(i,5)FOR(j,i+1,4)FOR(k,j+1,4){
    ans+=cnt[i]*cnt[j]*cnt[k];
  }

  cout<<ans<<endl;



  return 0;
}

Measured memory_bytes: 6724
#include<stdio.h>
#include<string.h>
int main(void){
int N,M,i;
char O[55],E[55];
scanf("%s",O);
scanf("%s",E);
N=strlen(O);
for(i=0;i<N;i++){
printf("%c",O[i]);
if(E[i]!='\0'){
printf("%c",E[i]);
}
}
}

Measured memory_bytes: 128