akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define REP(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
const ll MOD = 1000000007;
using namespace std;

int main(){
    int group[] = {0, 1, 3, 1, 2, 1, 2, 1, 1, 2, 1, 2, 1};
    int x, y; cin >> x >> y;
    cout << (group[x]==group[y] ? "Yes\n" : "No\n");
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  int c = 0;
  vector<int> A(N);
  for (int& a : A) {
    cin >> a;
    c += a % 2 == 0;
  }
  cout << (c == N ? "second" : "first") << endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const long long MOD=1000000007;

int main() {
  int n;
  cin>>n;
  vector<int> color(9);
  rep(i,9) color[i]=0;
  rep(i,n){
    int a;
    cin>>a;
    if(a>=3200) a=3200;
    color[a/400]++;
  }
  
  int ans=0;
  rep(i,8) if(color[i]>0) ans++;
  cout<<max(ans,1)<<" "<<ans+color[8]<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
const int INF = 1000010;
int main(){
    long long l; cin >> l;
    cout << fixed << setprecision(12) << (double)l*l*l/27 << endl;
    return 0;
}

Measured memory_bytes: 256
//#define LOCAL

#include <cstdio>
#include <algorithm>
using namespace std;

int main()
{
	#ifdef LOCAL
		freopen("E:\\Temp\\input.txt", "r", stdin);
		freopen("E:\\Temp\\output.txt", "w", stdout);
	#endif

	int a, b, n, minv, maxv = -2e9;
	scanf("%d%d", &n, &b); 
	--n; minv = b;
	while(n--) {
		scanf("%d", &a);
		maxv = max(maxv, a-minv);
		minv = min(minv, a);
		//printf("minv=%d, maxv=%d\n", minv, maxv);
	}

	printf("%d\n", maxv);

	return 0;
}

	

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


int main (void) {
    int N;
    cin >> N;
    vector<vector<ll>> sizes(3, vector<ll>(N));
    
    rep(i, 3) rep(j, N) cin >> sizes.at(i).at(j);
    rep(i, 3) sort(sizes.at(i).begin(), sizes.at(i).end());
    
    ll ans = 0;
    rep(i, N) {
        ll x = lower_bound(sizes.at(0).begin(), sizes.at(0).end(), sizes.at(1).at(i)) - sizes.at(0).begin();
        ll y = sizes.at(2).end() - upper_bound(sizes.at(2).begin(), sizes.at(2).end(), sizes.at(1).at(i));
        if (x > N | y > N) continue;
        ans += x * y;
    }
    cout << ans << endl;
}


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

int main() {
	int a, b;
	cin >> a >> b;
	if (a < b) {
		cout << "a < b" << endl;
	} else if (a > b) {
		cout << "a > b" << endl;
	} else {
		cout << "a == b" << endl;
	}
	return 0;
}

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

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		int diam = A.Max();
		int[] cnt = new int[diam + 1];
		for(int i=0;i<N;i++) cnt[A[i]]++;
		
		switch(diam % 2){
			
			case 0: {
				bool chk = true;
				for(int i=diam; i >= diam - diam / 2; i--){
					if(i > diam - diam / 2){
						chk &= cnt[i] >= 2;
					}
					if(i == diam - diam / 2){
						chk &= cnt[i] == 1;
					}
				}
				for(int i=diam - diam / 2 - 1; i >= 0; i--){
					chk &= cnt[i] == 0;
				}
				Console.WriteLine(chk ? "Possible" : "Impossible");
			
			} break;
			
			case 1: {
				bool chk = true;
				for(int i=diam; i >= diam - diam / 2; i--){
					if(i > diam - diam / 2){
						chk &= cnt[i] >= 2;
					}
					if(i == diam - diam / 2){
						chk &= cnt[i] == 2;
					}
				}
				for(int i=diam - diam / 2 - 1; i >= 0; i--){
					chk &= cnt[i] == 0;
				}
				Console.WriteLine(chk ? "Possible" : "Impossible");
			
			
			} break;
			
		}
		
	}
	int N;
	int[] A;
	public Sol(){
		N = ri();
		A = ria();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 13268
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <ios>
#include <iostream>
#include <numeric>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

int main()
{
    int A, B;
    cin >> A >> B;
    if (B % A == 0) {
        cout << A + B << endl;
    } else {
        cout << B - A << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n-1; i >= 0; i--)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
const int mod = 1e9+7;
const int INF = 1e9;
const int MAX = 1e6;

int main() {
    int n, k;
    cin >> n >> k;
    vi a(n);
    rep(i, n) cin >> a[i];
    if ((n-1) % (k-1) == 0) cout << (n-1) / (k-1) << endl;
    else cout << (n-1) / (k-1) + 1 << endl;
}

Measured memory_bytes: 3792
#include<iostream>
#include<algorithm>

using namespace std;


int main() {
    int a, b, c;

    cin >> a >> b >> c;

    int x1 = a + b;
    int x2 = b + c;
    int x3 = c + a;

    int ans = min(min(x1, x2), x3);

    cout << ans << endl;

}

Measured memory_bytes: 764
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
using namespace std;
int ans;
int N;
int A[100];
int B[100];
bool X[100];
int main()
{
	scanf("%d",&N);
	for(int i=0;i<N;i++)scanf("%d%d",&A[i],&B[i]);
	for(int i=0;i<N;i++)X[i]=1;
	for(int i=1;i<=31;i++){
		int mid=32;
		int midi=-1;
		for(int j=0;j<N;j++){
			if(A[j]<=i&&i<=B[j]&&X[j]){
				mid=min(mid,B[j]);
				if(mid==B[j])midi=j;
			}
		}
		if(midi==-1){
			ans+=50;
		}
		else{
			ans+=100;
			X[midi]=0;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1188
//
// Created by kuroneko on 2019-07-06.
//

#include <iostream>
#include <vector>

typedef long long ll;
using namespace std;

int main() {
    int N, M; cin >> N >> M;
    vector<int> L(M), R(M);

    for (int i = 0; i < M ; i++) {
        cin >> L[i] >> R[i];
    }

    sort(R.begin(), R.end());
    sort(L.rbegin(), L.rend());

    int ans = R[0] - L[0] + 1;
    cout << ((ans >= 0) ? ans : 0) << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define ii pair <int, int>
#define app push_back
#define all(a) a.begin(), a.end()
#define bp __builtin_popcount
#define ll long long
#define mp make_pair
#define f first
#define s second
#define Time (double)clock()/CLOCKS_PER_SEC

const int MOD = 998244353;

int mod(int n) {
    n %= MOD;
    if (n < 0) return n + MOD;
    else return n;
}   
int fp(int a, int p) {
    int ans = 1, c = a;
    for (int i = 0; (1ll << i) <= p; ++i) {
        if ((p >> i) & 1) ans = mod(ans * c);
        c = mod(c * c);
    }   
    return ans;
}   
int dv(int a, int b) { return mod(a * fp(b, MOD - 2)); }

const int C = 1000, N = 1e5 + 7;
int sum[3][C];
int dp[N];
int n;

int b = fp(10, 18);
vector <int> g[N];
void solve(int t) {
    for (int i = 1; i <= n; ++i)
        g[i].clear();
    
    int m;
    cin >> m;
    for (int i = 0; i < m; ++i) {
        int u, v;
        cin >> u >> v;
        if (v < u)  
            swap(u, v);
        g[u].app(v);
    }   

    for (int i = n; i; --i) {
        vector <int> a;
        for (int v : g[i])
            a.app(dp[v]);
        sort(all(a));
        a.app(N);
        if (a[0])
            dp[i] = 0;
        else {
            for (int j = 0; ; ++j)
                if (a[j] + 1 < a[j + 1]) {
                    dp[i] = a[j] + 1;
                    break;
                }   
        }             
        sum[t][dp[i]] = mod(sum[t][dp[i]] + fp(b, i));
    }   

}   

signed main() {
    #ifdef HOME
    freopen("input.txt", "r", stdin);
    #else
    #define endl '\n'
    ios_base::sync_with_stdio(0); cin.tie(0);
    #endif
    cin >> n;
    for (int i = 0; i < 3; ++i)
        solve(i);
    int ans = 0;
    for (int a = 0; a < C; ++a)
        for (int b = 0; b < C; ++b) 
            ans = mod(ans + mod(mod(sum[0][a] * sum[1][b]) * sum[2][a ^ b]));
    cout << ans << endl;
}   

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

int main(){
    ll n, ans, rt;
    cin >> n;
    rt = sqrt(n);
    ans = rt + n;

    for(int i = 1; i <= rt; ++i){
        if(n % i == 0)
            ans = min(i + n/i -2, ans);
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
// c++ -std=c++14 atcoder.cpp
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cmath>

using namespace std;

int main() {
    int64_t h, w;
    cin >> h >> w;

    int64_t ans;
    if (h%2 == 0 || w%2 == 0) {
        ans = h*w/2;
    } else {
        ans = h*w/2+1;
    }
    if (h == 1 || w == 1) {
        ans = 1;
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
n, k = map(int, input().split())
mod = 10**9+7
result = 0
memo = [0 for _ in range(k+1)]
for i in range(k, 0, -1):
    y = k//i
    z = pow(y, n, mod)
    j = 2
    while j*i<=k:
        z -= memo[j*i]
        z %= mod
        j += 1
    memo[i] = z
    result = (result+z*i)%mod
print(result)

Measured memory_bytes: 73248
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

typedef long long ll;
//const int INF = 2e9;
//const ll INF = 9e18;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll a, b, x;
    cin >> a >> b >> x;
    auto num = [&](ll n, ll x){
        if (n>=0) return n/x+1;
        else return 0LL;
    };
    ll ans = num(b,x)  - num(a-1,x);
    
    cout << ans << "\n";
}

Measured memory_bytes: 256
a={0:0,1:0,2:0,3:0,4:0,5:0}
for _ in range(int(input())):
    b=int(float(input()))
    if b<165:b=160
    elif b>185:b=185
    a[b//5-32]+=1
for i in a:print('%d:'%(i+1)+'*'*a[i])

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

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

int main() {
  int n, a, b;
  string s;
  cin >> n >> a >> b >> s;
  for (char c : s) {
    switch (c) {
    case 'a':
      if (a + b > 0) {
        cout << "Yes" << endl;
        --a;
      } else {
        cout << "No" << endl;
      }
      break;
    case 'b':
      if (a + b > 0 && b > 0) {
        cout << "Yes" << endl;
        --b;
      } else {
        cout << "No" << endl;
      }
      break;
    case 'c':
      cout << "No" << endl;
      break;
    }
  }
}


Measured memory_bytes: 848
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskA solver = new TaskA();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskA {
        public void solve(int testNumber, FastScanner in, PrintWriter out) {
            StringBuilder sb = new StringBuilder();
            sb.append("Christmas");
            for (int i = in.nextInt(); i < 25; i++)
                sb.append(" Eve");
            out.println(sb);
        }

    }

    static class FastScanner {
        private InputStream in;
        private byte[] buffer = new byte[1024];
        private int bufPointer;
        private int bufLength;

        public FastScanner(InputStream in) {
            this.in = in;
        }

        private int readByte() {
            if (bufPointer >= bufLength) {
                if (bufLength == -1)
                    throw new InputMismatchException();

                bufPointer = 0;
                try {
                    bufLength = in.read(buffer);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (bufLength <= 0)
                    return -1;
            }
            return buffer[bufPointer++];
        }

        private static boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public long nextLong() {
            long n = 0;

            int b = readByte();
            while (isSpaceChar(b))
                b = readByte();

            boolean minus = (b == '-');
            if (minus)
                b = readByte();

            while (b >= '0' && b <= '9') {
                n *= 10;
                n += b - '0';
                b = readByte();
            }

            if (!isSpaceChar(b))
                throw new NumberFormatException();

            return minus ? -n : n;
        }

        public int nextInt() {
            long n = nextLong();

            if (n < Integer.MIN_VALUE || n > Integer.MAX_VALUE)
                throw new NumberFormatException();

            return (int) n;
        }

    }
}



Measured memory_bytes: 20820
n=int(input())
b=[int(i) for i in input().split()]
ind=1
ans=0
tmp=b[0]
for i in range(n):
    ans+=ind-i
    while ind<n:
        if tmp+b[ind]!=tmp^b[ind]:
            tmp-=b[i]
            break
        else:
            tmp+=b[ind]
            ind+=1
            ans+=1
print(ans)

    










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

using namespace std;

typedef long long ll;
inline ll max(ll a, ll b)
{
    return a > b ? a : b;
}
inline ll min(ll a, ll b)
{
    return a > b ? b : a;
}
ll my_gcd(ll a, ll b)
{
    ll x = max(a, b), y = min(a, b);
    if (y == 0) {
        return x;
    } else {
        return my_gcd(y, x % y);
    }
}

int main()
{
    ll K;
    cin >> K;
    ll sum = 0;
    for (int i = 1; i <= K; i++) {
        sum += i;
    }
    for (int i = 1; i <= K; i++) {
        for (int j = 1; j <= K; j++) {
            if (i == j)
                continue;
            sum += 3 * my_gcd(i, j);
        }
    }
    for (int i = 1; i <= K; i++) {
        for (int j = i + 1; j <= K; j++) {
            for (int k = j + 1; k <= K; k++) {
                sum += 6 * my_gcd(k, my_gcd(i, j));
            }
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 3636
N, W = map(int, input().split())

Ws = []
Vs = []

for _ in range(N):
  w, v = map(int, input().split())
  Ws.append(w)
  Vs.append(v)


S = [ [0 for _ in range(W+1)] for _ in range(N)]

if Ws[0] <= W:
  for i in range(Ws[0], W+1):
    S[0][i] = Vs[0]

for weight in range(W+1):
  for item_num in range(N-1):
    if weight - Ws[item_num+1] < 0:
      S[item_num+1][weight] = max(S[item_num+1][weight], S[item_num][weight])
    else:
      S[item_num+1][weight] = max(S[item_num+1][weight], S[item_num][weight-Ws[item_num+1]] + Vs[item_num+1], S[item_num][weight])

print(max(S[N-1]))


Measured memory_bytes: 171656
#include<bits/stdc++.h>
#include<iterator>
using namespace std;
typedef long long int lli;
int main()
{
    lli n,W;
    cin >> n>>W;
    vector<lli>weight;
    vector<lli>val;
    lli sum=0;
    for(lli i=0;i<n;i++)
    {
        lli a,b;cin >> a >>b;sum+=b;
        weight.push_back(a);val.push_back(b);
    }
    lli dp[n+1][sum+2];
   for(int j=0;j<=sum;j++)
   {
       for(int i=0;i<=n;i++)
       {
           if(i==0 || j==0)
           {
               dp[i][j]=0;
           }
           else if(val[i-1] > j)
           {
               dp[i][j]= dp[i-1][j];
           }
           else
           {
               if(j == val[i-1])
               {
                   lli p = weight[i-1];
                   if(dp[i-1][j] != 0 )
                   {
                       p = min(p , dp[i-1][j]);
                   }
                   dp[i][j]=p;
               }
               else if(dp[i-1][j-val[i-1]] !=0)
               {
                   lli p = weight[i-1] + dp[i-1][j-val[i-1]];
                    if(dp[i-1][j] !=0)
                    {
                        dp[i][j] = min(p,dp[i-1][j]);
                    }
                    else
                    {
                        dp[i][j]=p;
                    }
               }
               else
               {
                   dp[i][j] = dp[i-1][j];
               }
               
               
           }
       }
   }

       for(int i=sum;i>=0;i--)
       {
           if(dp[n][i] <= W && dp[n][i] >0)
           {
            //    cout << dp[n][i] ;
               cout << i<<endl;
               return 0;
           }
       }
   }


Measured memory_bytes: 79104
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cstdlib>

#define MAX_NUM 200000

using namespace std;

int main(int argc, char const *argv[])
{
	int n,m;
	map<string, int> mp_d;

	cin >> n;
	
	for (int i = 0; i < n; ++i)
	{
		string tmp;
		cin >> tmp;
		mp_d[tmp] += 1;
	}

	cin >> m;

	for (int i = 0; i < m; ++i)
	{
		string tmp;
		cin >> tmp;

		mp_d[tmp] -= 1;
		if(mp_d[tmp] == -1){
			cout << "NO" << "\n";
			return 0;
		}
	}

	cout << "YES" << "\n";

	return 0;
}

Measured memory_bytes: 24960
N = int(input())
A  = list(map(int, input().split()))

num_dic = {}

for x in A:
    if x in num_dic:
        num_dic[x] += 1
    else:
        num_dic[x] = 1

tot = 0
for key, val in num_dic.items():
    tot += val * (val - 1) // 2

for x in A:
    print(tot - num_dic[x] + 1)


Measured memory_bytes: 26140
def gcd(i,j):
  if i > j:
    tmp = i
    i = j
    j = tmp
  while i != 0:
    tmp = i
    i = j%i
    j = tmp
  return j
def lcm(i,j):
  return i*j//gcd(i,j)  
def main():
  a,b,c,d = map(int,input().split())
  ans = b-a+1
  ans -= (b//c - (a-1)//c) + (b//d - (a-1)//d) - (b//lcm(c,d) -(a-1)//lcm(c,d))
  print(ans)


main()


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define ld long double
#define ll long long
#define pb push_back
#define F first
#define S second
const int mod = 1e9+7, A = 1e5+15;

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    int n, k, r, s, p;
    string a, ans;
    cin >> n >> k >> r >> s >> p >> a;
    ans.resize(n);
    for (int i = 0; i < n; i++)
    {
        if (i < k)
        {
            if (a[i] == 'r') ans[i] = 'p';
            if (a[i] == 's') ans[i] = 'r';
            if (a[i] == 'p') ans[i] = 's';
        }
        else
        {
            if (a[i] == 'r') ans[i] = (ans[i - k] == 'p' ? 'z' : 'p');
            if (a[i] == 's') ans[i] = (ans[i - k] == 'r' ? 'z' : 'r');
            if (a[i] == 'p') ans[i] = (ans[i - k] == 's' ? 'z' : 's');
        }
    }
    ll out = 0;
    for (int i = 0; i < n; i++)
    {
        if (ans[i] == 'r') out += r;
        if (ans[i] == 's') out += s;
        if (ans[i] == 'p') out += p;
    }
    cout << out;
    return 0;
}

Measured memory_bytes: 512
import java.io.IOException;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {

		Scanner sc = new Scanner(System.in);

		int a = sc.nextInt();
		int b = sc.nextInt();

		if (a % 3 == 0){
			System.out.println("Possible");
		} else if (b % 3 == 0){
			System.out.println("Possible");
		} else if ((a + b) % 3 == 0){
			System.out.println("Possible");
		} else {
			System.out.println("Impossible");
		}
	}

}


Measured memory_bytes: 23764
a[9999],i,j,z,t,c;main(p){for(;a[2]=read(i=0,&c,1);)for(t*=c<60||!--z;++j&7||++i&7;)i&j&&i>>~-c%4&c>60?a[i-z*9]+=p=a[j%8+~z*9]%10007,t+=p:0;t=!printf("%d\n",t%10007);}

Measured memory_bytes: 532
function Main(input) {
  input = input.split("\n").map(Number);
  n = input[0];
  x = input.slice(1,n+1);
  x = x.filter((d,i,n)=>n.indexOf(d)==i);
  console.log(x.length);
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
#define     int                long long
#define     ll                 long long
#define     start              int t;cin>>t;while(t--)
#define     f(n)               for(ll i=0;i<n;i++)
#define     fk(i,k,n)          for(ll i=k;i<=n;i++)
#define     al(s)              s.begin(),s.end()
#define     mp                 make_pair
#define     isvowel(a)         (a=='a' or a=='e' or a=='o' or a=='i' or a=='u')
#define     pb                 push_back
#define     ln                 cout<<"\n"
#define     sum(v)             accumulate(v.begin(), v.end(), 0ll)
#define     db1(x)           cout<<(#x)<<" is "<<x<<endl
#define     db2(x,y)           cout<<(#x)<<" is "<<x<<endl<<(#y)<<" is "<<y<<endl
#define     MOD                1000000007
#define     mii                map<int,int>
#define     vi                 vector<int>
#define     vii                vector<pair<int, int> >

const int N=2e5+20;
void print(vector<int> v, int n){f(n){cout<<v[i]<<" ";}}

void run()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(0);
    /*#ifndef ONLINE_JUDGE 
    freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
    #endif  */  
}

int32_t main()
{
    run();
 int n,a,b;
 cin>>n>>a>>b;
 int x=n/(a+b);

 int ans=x*a+(min(a,(n%(a+b))));
 cout<<ans;

}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <math.h>
#include <vector>
#include <map>
#include <queue>
#include <utility>
#include <algorithm>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector <int> V(N);
  vector <int> C(N);
  for (int i = 0; i < N; i++) {
	  cin >> V[i];
	}
  for (int i = 0; i < N; i++) {
	  cin >> C[i];
	}
  int ans = 0;
  for (int i = 0; i < N; i++) {
	  ans += max(0, V[i] - C[i]);
	}
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main() {
	int D, G;
	cin >> D >> G;
	vector<int> p(D), c(D);
	for (int i = 0; i < D; i++) cin >> p[i] >> c[i];

	int score, count;
	int ans = 1500;

	for (int bit = 0; bit < (1 << D); bit++) {
		score = 0;
		count = 0;
		int j = -1;
		for (int i = 0; i < D; i++) {
			if (bit & (1 << i)) {
				score += 100 * (i + 1) * p[i] + c[i];
				count += p[i];
			}
			else j = max(j, i);
		}
		if (score >= G) ans = min(ans, count);
		else {
			for (int k = 0; k < p[j]; k++) {
				score += 100 * (j + 1);
				count++;
				if (score >= G) {
					ans = min(ans, count);
					break;
				}
			}
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3588
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    int ans=0;
    FOR(i,1,n+1){
        if(i < 10)ans++;
        else if(i >= 100 && i <= 999)ans++;
        else if(i >= 10000 && i <= 99999)ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
public class Main {
        public static void main(String[] args) throws java.io.IOException{
            Scanner scan = new Scanner(System.in);
            StringBuilder sb =new StringBuilder();
            String [] words = scan.nextLine().split("[ ,.]");
            for(int i=0;i<words.length;i++){
                if(words[i].length()>=3&&words[i].length()<=6){
                    sb.append(words[i]);
                    sb.append(" ");
                }
            }
            System.out.println(sb.toString().trim());
        }
}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    int sum;
    cin >> n;
    vector<int>v(n);
    for(int i=0; i<n; ++i){
        cin >> v[i]; 
    }
    sort(v.begin(), v.end());
    sum = accumulate(v.begin(), v.end()-1, 0);
    if(v[n-1]<sum){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

ll dp[1001][1001];
ll fact[1001], D[1001];
ll ppow(ll a) {
	ll b = MOD - 2;
	ll res = 1;
	while (b) {
		if (b & 1)res = (res*a) % MOD;
		a = (a*a) % MOD;
		b >>= 1;
	}
	return res;
}
ll comb(ll a, ll b) {
	return (((fact[a] * D[a - b]) % MOD)*D[b]) % MOD;
}
int main() {
	fact[0] = 1; D[0] = 1;
	int n, a, b, c, d; scanf("%d%d%d%d%d", &n, &a, &b, &c, &d);
	for (int i = 1; i <= n; i++) {
		fact[i] = (fact[i - 1] * i) % MOD;
		D[i] = ppow(fact[i]);
	}
	rep(i, n)dp[i][0] = 1;
	for (int i = a - 1; i < b; i++) {
		for (int j = 0; j <= n; j++) {
			if (j)(dp[i + 1][j] += dp[i][j]) %= MOD;
			if (j - c*(i + 1) < 0)continue;
			ll y = 1, t = n - j;
			for (int k = 1; j - k*(i + 1) >= 0 && k <= d; k++) {
				(y *= comb(t + i + 1, t)) %= MOD;
				t += i + 1;
				if (k < c)continue;
				ll o = y;
				(o *= ppow(fact[k])) %= MOD;
				(dp[i + 1][j] += dp[i][j - k*(i + 1)] * o) %= MOD;
			}
		}
	}
	cout << dp[b][n] << endl;
}

Measured memory_bytes: 8064
#pragma GCC optimize ("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse4")
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
inline int in(){int x;scanf("%lld",&x);return x;}
int32_t main()
{
	int a=in();
	cout<<a+a*a+a*a*a;
	
}

Measured memory_bytes: 3644
from math import *
from bisect import bisect_left

def cin(): # To take limited number of inputs
    return map(int,input().split())

def cins(): # To take space sepreated strings
    return input.split()

def cino(test=False): # To take individual int input (test = False)
    if not test:
        return int(input())
    else: # To take string input (test = True)
        return input()

def cina(): # array input
  return list(map(int,input().split()))

def ssplit(): # multiple string input
    return list(input().split())

def printlist(l): # To print space seperated array
    for i in l:
        print(i,end=" ")

def bs(arr, l, r, x): 
    while l <= r: 
        mid = l + (r - l) // 2; 
        if arr[mid] == x: 
            return mid 
        elif arr[mid] < x: 
            l = mid + 1
        else: 
            r = mid - 1
    return -1


def main():
    a = cino(True)
    if a.isupper():
        print('A')
    else:
        print('a')





if __name__ == '__main__':
    main()


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

int main(){
  int n,m;
  cin>>n>>m;
  vector<int> a(m),b(m),c(m);
  rep(i,m){
    cin>>a[i]>>b[i];
    rep(j,b[i]){
      int x;
      cin>>x;
      x--;
      c[i]+=1<<x;
    }
  }
  vector<vector<int>> dp(m+1,vector<int>(1<<n,1000000000));
  dp[0][0]=0;
  rep(i,m){
    rep(j,1<<n){
      if(dp[i][j]!=1000000000){
        dp[i+1][j]=min(dp[i+1][j],dp[i][j]);
        dp[i+1][j|c[i]]=min(dp[i+1][j|c[i]],dp[i][j]+a[i]);    
      }
    }
  }
  
  if(dp[m][(1<<n)-1]<1000000000) cout<<dp[m][(1<<n)-1]<<endl;
  else cout<<"-1"<<endl;
}

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

int main(){
    string s;
    cin >> s;
    int ans = s.size();
    int left = 0;
    for (int i = 0; i < s.size(); i++){
        if (s[i] == 'S') left++;
        if (s[i] == 'T'){
            if (left) left--, ans -= 2;
            else left = 0;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
module Sort_Module
    implicit none
    public
    contains
    recursive subroutine mergesort(a, p, r, b)
        integer(8) a(:), b(:)
        integer(8) p, r
        integer(8) q
        if (p < r) then
            q = (p+r)/2
            call mergesort(a, p, q, b)
            call mergesort(a, q+1, r, b)
            call merge(a, p, q, r, b)
        end if
    end subroutine mergesort
    subroutine merge(a, p, q, r, b)
        integer(8) a(:), b(:)
        integer(8) p, r, q, i, j, k
        integer(8) t
        k = p;   i = p;   j = q+1
        do
            if (.not. (k <= r)) exit
            if (j > r) then
                t = a(i);   i = i+1
            else if (i > q) then
                t = a(j);   j = j+1
            else if (a(i) <= a(j)) then
                t = a(i);   i = i+1
            else
                t = a(j);   j = j+1
            end if
            b(k) = t;   k = k+1
        end do
        do i = p, r
            a(i) = b(i)  
        end do
    end subroutine merge
    subroutine sort(a)
      integer(8) a(:),b(ubound(a,1)-size(a)+1:ubound(a,1)),n,k
      n = ubound(a,1)
      k = ubound(a,1)-size(a)+1
      call mergesort(a,k,n,b)
    end subroutine sort
    function POSL(a,v) result(r)!find first i:a(i)>=v
        implicit none
        integer(8) :: a(:),l,r,idx,v
        r = ubound(a,1) + 1
        l = ubound(a,1)-size(a)
        do while(r-l>1)
            idx = l + (r-l)/2
            if(a(idx) >= v)then
                r = idx
            else
                l = idx
            endif
        enddo
    end function
    function POSU(a,v) result(r)!find first i:a(i)>v
        implicit none
        integer(8) :: a(:),l,r,idx,v
        r = ubound(a,1) + 1
        l = ubound(a,1)-size(a)
        do while(r-l>1)
            idx = l + (r-l)/2
            if(a(idx) > v)then
                r = idx
            else
                l = idx
            endif
        enddo
    end function
    function NUM(a,v) result(n)
        implicit none
        integer(8) :: a(:),v,n
        n = POSU(a,v) - POSL(a,v)
    end function
end module Sort_Module
  

program atcoder
    use Sort_Module
    implicit none
    integer(8) :: ans,a,b,c(1:4),i,d(1:4)
    c=0
    do i=1,3
        read*,a,b
        c(a)=c(a)+1
        c(b)=c(b)+1
    enddo
    call sort(c)
    d(1)=1
    d(2)=1
    d(3)=2
    d(4)=2
    if( all(d==c) )then
        write(*,'(a)')"YES"
    else 
        write(*,'(a)')"NO"
    endif
    stop 
contains
end program atcoder

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<string.h>
#define max(x,y)(x>y?x:y)
#define min(x,y)(x>y?y:x)
#define MOD (int)1e9+7
int dx4[]={1,0,-1,0};
int dy4[]={0,-1,0,1};
typedef long long int ll;
typedef unsigned long long int ull;
ll gcd(ll x,ll y){if(!y)return x;return gcd(y,x%y);}
ll lcm(ll x,ll y){return x/gcd(x,y)*y;}
void swap(ll *x,ll *y){ll tmp=*x;*x=*y;*y=tmp;}
int asc_cmp(const void* X,const void* Y){ll x=*(int*)X,y=*(int*)Y;if(x<y)return -1;else if(x==y)return 0;else return 1;}
int desc_cmp(const void* X,const void* Y){ll x=*(int*)X,y=*(int*)Y;if(x<y)return 1;else if(x==y)return 0;else return -1;}
typedef struct pair_{
    int x;
    int y;
}pair_t;

int main(){
    int n;scanf("%d",&n);
    int a[300000];for(int i=0;i<n;i++)scanf("%d",&a[i]);

    ll cnt[300000]={};
    for(int i=0;i<n;i++){
        cnt[a[i]-1]++;
    }
    //printf("%lld\n",cnt[199999]);
    ll nPr[300000]={};
    for(int i=0;i<n;i++){
        ll x=cnt[i]*(cnt[i]-1);
        nPr[i]=x/2;
        //printf("%lld\n",nPr[i]);
    }
    ll sum=0;
    for(int i=0;i<n;i++){
        sum+=nPr[i];
    }
    //printf("sum:%lld\n",sum);
    for(int i=0;i<n;i++){
        ll x=(cnt[a[i]-1]-1);
        x*=(cnt[a[i]-1]-2);
        ll y=x/2;
        ll z=sum;
        z-=nPr[a[i]-1];
        z+=y;
        printf("%lld\n",z);
    }
}

Measured memory_bytes: 8320
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


void solve(void)
{

  int N;
  cin>>N;
  vector<int> data(N);
  int SUM = 0;
  for (int i = 0; i < N; i++)
  {
    cin>>data[i];
    SUM += data[i];
  }

  sort(data.begin(),data.end());

  for (int i = 0; i < N; i++)
  {
    if(SUM%10 != 0)break;

    if(data[i]%10 != 0)
    SUM -= data[i];

    if(i == N -1) SUM = 0;
  }
  
  cout<<SUM<<endl;

  
  
  
  return; 
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <string>
#include <vector>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repR(i, n) for(int i = (n) - 1; i > -1; i--)
#define rep1(i, n) for(int i = 1; i < (int)(n + 1); i++)
#define rep1R(i, n) for(int i = (n); i > 0; i--)
typedef long long ll;
typedef unsigned long long ull;
using namespace std;

int main() {
  ll N; cin >> N;
  if (N % 2 == 0) {
    cout << N << endl;
  } else {
    cout << N * 2 << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
#define pb push_back
#define ll long long
#define maxn 200005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define ms1(i) memset(i,-1,sizeof(i));
#define F first
#define S second
const int mod = 1e9+7;

int main(){
	int a,b;
	cin >> a >> b;
	if(b==1){
		cout<<0<<endl;
		exit(0);
	}
	if(a>=b){
		cout<<1<<endl;
		exit(0);
	}
	int ans = 1;
	int cur = a;
	while(cur<b){
		cur += a-1;
		ans++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=1010, md=1e9+7;
int n,m,ans,fac[N*N],inv[N*N],a[N],b[N];
inline int power(int x,int y) {
	int z=1;
	for (;y;y>>=1, x=1ll*x*x%md)
	if (y&1) z=1ll*z*x%md;
	return z;
}
inline int A(int n,int m) {
	//printf("* A(%d,%d)\n",n,m);
	return n<m?0:1ll*fac[n]*inv[n-m]%md;
}
inline int read() {
	int tmp=0, fh=1; char c=getchar();
	while (c<'0'||c>'9') {if (c=='-') fh=-1; c=getchar();}
	while (c>='0'&&c<='9') tmp=tmp*10+c-48, c=getchar();
	return tmp*fh;
}
int main() {
	n=read(); m=read();
	ans=fac[0]=1;
	for (int i=1;i<=n*m;i++) fac[i]=1ll*fac[i-1]*i%md;
	inv[n*m]=power(fac[n*m],md-2);
	for (int i=n*m;i;i--) inv[i-1]=1ll*inv[i]*i%md;
	for (int i=1;i<=n;i++) a[i]=read();
	for (int i=1;i<=m;i++) b[i]=read();
	sort(a+1,a+n+1); sort(b+1,b+m+1);
	for (int i=1;i<n;i++) if (a[i]==a[i+1]) {puts("0"); return 0;}
	for (int i=1;i<m;i++) if (b[i]==b[i+1]) {puts("0"); return 0;}
	//for (int i=1;i<=n;i++) printf("  %d",a[i]); printf("\n");
	//for (int i=1;i<=m;i++) printf("%d\n",b[i]);
	for (int i=1,j=1,done=0,todo=0;i<=n||j<=m;) {
		//printf("%d %d %d\n",i,j,ans);
		if (i>n||j>m||ans==0) {puts("0"); return 0;}
		if (a[i]==b[j]) {
			todo=n+m-i-j+1;
			ans=1ll*ans*A(a[i]-done-1,todo-1)%md;
			done+=todo;
			i++; j++;
			continue;
		}
		if (a[i]<b[j]) {
			todo=m-j+1;
			ans=1ll*ans*A(a[i]-done-1,todo-1)%md*todo%md;
			done+=todo;
			i++;
			continue;
		}
		if (a[i]>b[j]) {
			todo=n-i+1;
			ans=1ll*ans*A(b[j]-done-1,todo-1)%md*todo%md;
			done+=todo;
			j++;
			continue;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#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(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#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 bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

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>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
#define Add(x, y) x = (x + (y)) % mod
#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N; cin >> N;
    vec a(N); cin >> a;

    bools f(60, false);
    REP(i, N){
        int d = __builtin_ffsll(a[i]);
        f[d - 1] = true;
    }

    int X = 0;
    REP(i, N) X ^= a[i];

    int ans = 0;
    IREP(i, 60) if(bit_exist(X, i)){
        if(!f[i]){
            Out(-1);
            return 0;
        }else{
            ans++;
            X ^= bit(i + 1) - 1;
        }
    }
    Out(ans);


    return 0;
}


Measured memory_bytes: 1152
using System;

class MainClass
{
  public static void Main()
  {
    var N = int.Parse(Console.ReadLine());
    var a = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
    var b = Array.ConvertAll(Console.ReadLine().Split(), int.Parse);

    long ans = 0;
    for (var i = 0; i <= 28; i++)
    {
      var mask = (1 << i + 1) - 1;
      var maskedA = new int[N];
      var maskedB = new int[N];
      for (var j = 0; j < N; j++)
      {
        maskedA[j] = a[j] & mask;
        maskedB[j] = b[j] & mask;
      }
      Array.Sort(maskedB);

      var T = 1 << i;
      long parity = 0;
      for (var j = 0; j < N; j++)
      {
        var num1 = LowerBound(maskedB, T - maskedA[j]);
        var num2 = LowerBound(maskedB, 2 * T - maskedA[j]);
        var num3 = LowerBound(maskedB, 3 * T - maskedA[j]);
        parity += (num2 - num1) + (N - num3);
      }
      ans |= (parity & 1) << i;
    }
    Console.WriteLine($"{ans}");
  }

  private static int LowerBound(int[] arr, int val)
  {
    int first = 0, last = arr.Length - 1, mid;
    while (first <= last)
    {
      mid = (first + last) >> 1;
      if (val > arr[mid]) first = mid + 1;
      else last = mid - 1;
    }
    return first;
  }
}


Measured memory_bytes: 56168
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<math.h>
#include<bitset>
#include<iomanip>
#include<numeric>
using namespace std;

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

const double pi = 3.141592653589793;


//最大公約数
template<class T> T gcd(T a, T b)
{
	while (true)
	{
		T r;
		if (a%b == 0) return b;
		else
		{
			r = a % b;
			a = b;
			b = r;
		}
	}
}
//最小公倍数
template<class T> T lcm(T a, T b)
{
	return a / gcd(a, b)*b;
}
//文字0~9をint型0~9に変換
int char_to_int(char c)
{
	if (c == '0') return 0;
	if (c == '1') return 1;
	if (c == '2') return 2;
	if (c == '3') return 3;
	if (c == '4') return 4;
	if (c == '5') return 5;
	if (c == '6') return 6;
	if (c == '7') return 7;
	if (c == '8') return 8;
	if (c == '9') return 9;
	else return -1;
}
//a^b mod MODを計算
long long int ModPower(long long int a, long long int b, long long int MOD)
{
	if (b == 0) return 1;
	else if (b % 2 == 0)
	{
		long long int d = ModPower(a, b / 2, MOD);
		return (d*d) % MOD;
	}
	else
	{
		return (a*ModPower(a, b - 1, MOD)) % MOD;
	}
}
//nCr mod MODを計算
long long int ModCombi(long long int n, long long int r, long long int MOD)
{
	if (n == 0 || r == 0) return 1;

	long long int Kn = 1, Kr = 1, Knr = 1;

	long long int temp = 1;
	for (long long int i = 1; i <= n; i++)
	{
		temp *= i;
		temp %= MOD;
		if (i == n) Kn = temp;
		if (i == r) Kr = temp;
		if (i == n - r) Knr = temp;
	}

	long long int x = ModPower(Kr, MOD - 2, MOD);
	long long int y = ModPower(Knr, MOD - 2, MOD);

	long long int ans;
	ans = Kn * x;
	ans %= MOD;
	ans *= y;
	ans %= MOD;

	return ans;
}
//int型10進数をord桁のstring型2進数に変換する
string binary(int x, int ord)
{
	int y;
	string ans = "";
	for (int i = 0; i < ord; i++)
	{
		y = x / (int)pow(2, ord - 1 - i);
		y %= 2;
		if (y == 0) ans += "0";
		else ans += "1";
	}

	return ans;
}
//ord桁のstring型2進数をint型10進数に変換する
int rep_binary(string x, int ord)
{
	int res = 0;
	for (int i = 0; i < ord; i++)
	{
		if (x[i] == '1') res += (int)pow(2, ord - 1 - i);
	}
	return res;
}


/*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*/



int main()
{
	int N, A[105];
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		cin >> A[i];
	}

	int flag = 1, c = 0;
	int temp;

	while (flag)
	{
		flag = 0;

		for (int i = N - 1; i >= 1; i--)
		{
			if (A[i] < A[i - 1])
			{
				temp = A[i - 1];
				A[i - 1] = A[i];
				A[i] = temp;
				flag = 1;
				c++;
			}
		}
	}

	cout << A[0];
	for (int i = 1; i < N; i++)
	{
		cout << " " << A[i];
	}
	cout << endl;
	cout << c << endl;

	return 0;
}



Measured memory_bytes: 3108
def max_heapify(a, i)
  l = i * 2
  r = i * 2 + 1
  h = a.size

  if l < h && a[l] > a[i]
    largest = l
  else
    largest = i
  end

  if r < h && a[r] > a[largest]
    largest = r
  end

  if largest != i
    a[i], a[largest] = a[largest], a[i]
    max_heapify(a, largest)
  end
end

def build_max_heap(a)
  (a.size / 2).downto(1) do |i|
    max_heapify(a, i)
  end
end

gets.chomp.to_i
a = gets.chomp.split.map(&:to_i)
a.unshift(-1)

build_max_heap(a)

puts a.drop(1).map{|ai| " #{ai.to_s}"}.join



Measured memory_bytes: 53112
import java.io.*;
import java.util.*;

public class Main {


    private void solve(InputReader in, PrintWriter out) {
        String s = in.next();
        String t = in.next();
        char[] arrS = s.toCharArray();
        char[] arrT = t.toCharArray();
        Arrays.sort(arrS);
        Arrays.sort(arrT);
        if (!Arrays.equals(arrS, arrT)) {
            out.println("No");
            return;
        }
        arrS = s.toCharArray();
        char[] res = new char[arrS.length];
        arrT = t.toCharArray();
        for (int i = 0; i < arrS.length; i++) {
            for (int j = 0; j < arrS.length; j++) {
                res[(j + 1) % arrS.length] = arrS[j];
                if (Arrays.equals(arrS, arrT)) {
                    out.println("Yes");
                    return;
                }
            }
            arrS = res.clone();

        }
        out.println("No");
    }


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

    private void run() {
        try (
                InputReader in = new InputReader(System.in);
                PrintWriter out = new PrintWriter(System.out)) {
            solve(in, out);
        }
    }


    static class InputReader implements AutoCloseable {
        private BufferedReader reader;
        private StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public long nextLong() {
            return Long.parseLong(next());
        }

        public double nextDouble() {
            return Double.parseDouble(next());
        }

        @Override
        public void close() {

        }
    }

}


Measured memory_bytes: 22228
package main

import "fmt"

func main() {
	var n, k int
	var s string
	fmt.Scan(&n, &s, &k)
	c := s[k-1 : k]
	ans := ""
	for _, v := range s {
		if string(v) == c {
			ans += string(v)
		} else {
			ans += "*"
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define INF (1<<21)
int main(){
	int m;
	while(cin >> m , m){
		int wf[10][10] = {0};
		rep(i,10)rep(j,10)wf[i][j] = INF;
		rep(i,10)wf[i][i] = 0;
		int n = 0;
		rep(i,m){
			int a,b,c;
			cin >> a >> b >> c;
			wf[a][b] = wf[b][a] = c;
			n = max(n,max(a,b)+1);
		}
		rep(k,n)rep(i,n)rep(j,n)
			wf[i][j] = min(wf[i][j] , wf[i][k]+wf[k][j]);
		
		pair<int,int> d = make_pair(INF,-1);

		rep(i,n){
			int sum = 0;
			rep(j,n)sum += wf[i][j];
			d = min(d,make_pair(sum,i));
		}
		cout << d.second << " " << d.first << endl;
	}
}

Measured memory_bytes: 0
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Question question = new Question();
        question.solve(sc);
    }

    static class Question {

        public void solve(Scanner sc) {
            int n = sc.nextInt();
            Queue<Long> q = new ArrayDeque<>();
            for(long i = 1; i < 10; ++i) {
                q.offer(i);
            }
            long res = 0;
            while(n-- > 0) {
                res = q.poll();
                long t = res % 10;
                if(t != 0) q.offer(res * 10 + t - 1);
                q.offer(res * 10 + t);
                if(t != 9) q.offer(res * 10 + t + 1);
            }
            System.out.println(res);
        }
    }
}


Measured memory_bytes: 31828