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

typedef long long ll;
typedef double dd;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;

const int mx=1e6+11;
const double PI = acos(-1);
#define MOD 1000000007


#define nl '\n'
#define pb push_back
#define F first
#define S second
#define I insert
#define mp make_pair

#define sz(x) x.size()
#define sa(v) sort(v.begin(),v.end())
#define sd(v) sort(v.begin(),v.end(),greater<>())
#define rev(s) reverse(s.begin(),s.end())
#define tt int t; cin>>t; while(t--)
#define lo(i,a,b) for(ll i=a;i<b;i++)
#define be(a) (a).begin(),(a).end()
#define rbe(a) (a).rbegin(),(a).rend()

#define sqr(a) ((a) * (a))
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define mem(a,b) memset(a,b,sizeof(a))

#define yes cout<<"YES"<<nl;
#define no cout<<"NO"<<nl;

#define su ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#define frac cout.unsetf(ios::floatfield); cout.precision(10); cout.setf(ios::fixed,ios::floatfield);

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)
void faltu () {            cerr << endl;}
template < typename T, typename ... hello>void faltu( T arg, const hello &... rest) {cerr << arg << ' ';faltu(rest...);}
ll f(ll x)
{
   return x*(x-1)/2;
}
ll div(ll n)
{
   ll sum=0;
   for(int i=1;i<=n;i++)
   {
      sum+=i*f(n/i+1);
   }
   return sum;
}

int main()
{
   su;
   ll n;
   cin>>n;
   cout<<div(n)<<nl;
   return 0;
}


Measured memory_bytes: 3644
//#include <bits/stdc++.h>
#include <iostream>
#include <climits>

using namespace std;

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

typedef long long int ll;


int main()
{
	ios_base :: sync_with_stdio(false);
	cin.tie(NULL);

	int n;
	int arr[100];

	cin >> n;
	rep(i , n)
		cin >> arr[i];

	int sum = 0;
	rep(i , n)
		sum += arr[i];

    int ans = abs(sum-arr[0]);
	int prefix = arr[0];
	for(int i=1 ; i<n-1 ; i++)
	{
	    prefix += arr[i];
	    //cout << ans << "\n";
		if(abs(prefix - (sum-prefix)) < ans)
			ans = abs(prefix - (sum-prefix));
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <climits>
#include <unistd.h>
#include <cmath>
using namespace std;
int main(){
    int n, m;
    cin >> n >> m;
    int ans = 1;
    if (n== 1)
        ans = m;
    for (int i = 2; ((long long)i * i) <= (long long)m; ++i){
        if ((m % i) == 0){
            if (m/i >= n)
                ans = max(i, ans);
            if (i >= n)
                ans = max(m/i, ans);
        }
    }
    cout << ans;
    return 0;
}



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

int main(void){
    int n;
    cin >> n;
    vector<int> h(n);
    int cnt = 0, res = 0, pre = 0;
    rep(i,n) {
        int cur;
        cin >> cur;
        if (pre >= cur) cnt++;
        else cnt = 0;
        res = max(res, cnt);
        pre = cur;
    }
    cout << res << endl;
    return 0;
}


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



int main() {

  int64_t n;
  cin>>n;

  int64_t cnt=0;
  for(int i=1;i<=n;i++){
    for(int j=1;j<=n/i;j++){
      int k=n-i*j;
      if(i*j+k==n && k>0)
        cnt++;
    }
  }

  cout<<cnt<<endl;

  return 0;
}

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

int w, a, b;

int main() {
    cin >> w >> a >> b;

    if (a < b) {
        cout << max(0, b - (a + w)) << endl;    
    }
    else {
        cout << max(0, a - (b + w)) << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <stack>
#include <utility>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define INF 1000000001
#define mod 1000000007
using namespace std;

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

	char s[6];
	cin>>s;
	rep(i,4){
		if(s[i]=='A' && s[i+1]=='C'){
			cout<<"Yes"<<endl;
			return 0;
		}
	}
	cout<<"No"<<endl;
}

Measured memory_bytes: 256
def actual(a, b, c, d):
    hp_takahashi, atk_tahashi = a, b
    hp_aoki, atk_aoki = c, d

    while True:
        hp_aoki -= atk_tahashi

        if hp_aoki <= 0:
            return 'Yes'

        hp_takahashi -= atk_aoki

        if hp_takahashi <= 0:
            return 'No'

a, b, c, d = map(int, input().split())
print(actual(a, b, c, d))

Measured memory_bytes: 9128
#!python3

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())
from functools import lru_cache

mod = 10 **9 + 7


@lru_cache(100)
def calc(n):
    m = (n-5) // 2

    #return (1+m)*(2+m)*(3+m)*(4+m)*(5+m)*(1025024*m**10+3003*(-4+n)*(-3+n)*(-2+n)*(-1+n)*n*(1+n)*(2+n)*(3+n)*(4+n)*(5+n)-549120*m**9*(-1+10*n)+42240*m**8*(-398+45*n*(-1+7*n))-369600*m**7*(3+2*(-2+n)*n*(49+26*n))+2688*m**6*(33529+75*n*(-33-679*n+91*n**3))-336*m**5*(88065+2*n*(426107+7*n*(-6675+13*n*(-2420+9*n*(5+22*n)))))+560*m**4*(-291598+n*(216249+7*n*(95465+26*n*(-495+n*(-980+11*n*(3+5*n))))))-30*m**3*(-3080960+n*(-10447602+7*n*(854525+13*n*(93170+n*(-15295+22*n*(-714+5*n*(7+6*n)))))))+2*m**2*(28412712+25*n*(-3433650+n*(-4123841+13*n*(189882+n*(142177+22*n*(-1344+n*(-791+27*n*(2+n))))))))-m*(30149280+n*(31294296+n*(-93275400+13*n*(-3808420+n*(2988195+11*n*(111678+25*n*(-1302+n*(-456+n*(45+14*n))))))))))/1307674368000
    return (
        (1+m)*(2+m)*(3+m)%mod*(4+m)*(5+m)%mod*(
            1025024*pow(m,10,mod)+3003*(-4+n)%mod*(-3+n)*(-2+n)%mod*(-1+n)*n*(1+n)%mod*(2+n)*(3+n)%mod*(4+n)*(5+n)%mod
            -549120*pow(m,9,mod)*(-1+10*n)%mod
            +42240*pow(m,8,mod)*(-398+45*n*(-1+7*n))%mod
            -369600*pow(m,7,mod)*(3+2*(-2+n)*n*(49+26*n)%mod)%mod
            +2688*pow(m,6,mod)*(33529+75*n*(-33-679*n+91*n**3)%mod)%mod
            -336*pow(m,5,mod)*(88065+2*n*(426107+7*n*(-6675+13*n*(-2420+9*n*(5+22*n)%mod))%mod))%mod
            +560*pow(m,4,mod)*(-291598+n*(216249+7*n*(95465+26*n*(-495+n*(-980+11*n*(3+5*n))%mod))%mod))%mod
            -30*pow(m,3,mod)*(-3080960+n*(-10447602+7*n*(854525+13*n*(93170+n*(-15295+22*n*(-714+5*n*(7+6*n)%mod))%mod))%mod))%mod
            +2*pow(m,2,mod)*(28412712+25*n*(-3433650+n*(-4123841+13*n*(189882+n*(142177+22*n*(-1344+n*(-791+27*n*(2+n))%mod))%mod))%mod))%mod
            -m*(30149280+n*(31294296+n*(-93275400+13*n*(-3808420+n*(2988195+11*n*(111678+25*n*(-1302+n*(-456+n*(45+14*n)%mod))%mod))%mod))%mod))%mod
        )%mod*pow(1307674368000%mod, mod-2, mod)%mod
    )

def resolve():
    it = map(int, sys.stdin.read().split())
    N = next(it)

    ans = [0] * N
    for i in range(N):
        n = next(it)
        ans[i] = calc(n)

    print(*ans, sep="\n")

if __name__ == "__main__":
    resolve()


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

using namespace std;

double n, k, res;

double proc(double n, int k, int c) {
//	cout << c << endl;
	int p = 0;
	if (c >= k) {
		return (1 / n);
	}
	for (int i = 1; ; i++) {
		c *= 2;
		if (c >= k) {
			p = i;
			break;
		}
	}

	return (1 / n)*pow((0.5), p);
}

int main() {
	cin >> n >> k;

	double pp = 0;

	for (int i = 1; i <= n; i++) {
		pp += proc(n, k, i);
	}

	printf("%.15lf\n", pp);

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string>
using namespace std;
const double PI = acos(-1.0);
const string alp = "abcdefghijklmnopqrstuvwxyz";
const string ALP = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define UNIQ(c) (c).erase(unique((c).begin(), (c).end()), (c).end());
#define Yn(b) puts(b?"Yes":"No")
#define YN(b) puts(b?"YES":"NO")
 
bool isprime(int p) {
  if (p==1) return false;
    FOR(i,2,p) {
      if (p%i==0) return false;
    }
  return true;
}
 
int main(){
  string s;
  cin >> s;
  Yn(s[0]!=s[1]&&s[1]!=s[2]&&s[2]!=s[0]);
}

Measured memory_bytes: 256
import sys


def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]


s = S()
ans = ''
if 'C' in s:
    ans += 'C'
    if 'F' in s[s.index('C'):]:
        ans += 'F'
if ans == 'CF':
    print('Yes')
else:
    print('No')


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
/*--------------------------------------------*/

int main(){
    //cout << fixed << setprecision(10)
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N,M;
    cin >> N >> M;

    ll ac = 0,wa = 0;

    vector<ll> ct(N),WA(N);

    rep(i,M){
        int a;
        string s;
        cin >> a >> s;
        --a;
        if(!ct[a]){  //まだ正解してないなら
            if(s == "AC"){
                ct[a] = 1;
                ac++;
                wa += WA[a];
            }else{
                WA[a]++;
            }
        }
    }

    cout << ac << ' ' << wa << endl;

    

}

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

int main() {
  int64_t n;
  cin >> n;
  vector<int64_t> vec(n);
  int64_t a=0;
  rep(i,n){
    int64_t x;
    cin >> x;
    vec[i]=x;
    a=a^x;
  }
  rep(i,n){
    int64_t c=vec[i]^a;
    cout << c << " ";
  }
}

Measured memory_bytes: 4720
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main
{
	PrintWriter out = new PrintWriter(System.out);
	BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    StringTokenizer tok = new StringTokenizer("");
    String next() throws IOException {
        if (!tok.hasMoreTokens()) { tok = new StringTokenizer(in.readLine()); }
        return tok.nextToken();
    }
    int ni() throws IOException { return Integer.parseInt(next()); }
    long nl() throws IOException { return Long.parseLong(next()); }
  
    static long m=998244353;
  
    void solve() throws IOException {
        int n=ni(),k=ni();
        int[]A=new int[n];
        long[]B=new long[n];
        A[0]=ni();
        for (int x=1;x<n;x++) {
            A[x]=ni();
            int lb=Math.max(0,x-k);
            B[x]=Integer.MAX_VALUE;
            for (int y=lb;y<x;y++) B[x]=Math.min(B[x], B[y]+Math.abs(A[x]-A[y]));
        }
        System.out.println(B[n-1]);
    }
    
    public static void main(String[] args) throws IOException {
        new Main().solve();
    }
}

Measured memory_bytes: 32512
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from collections import deque
sys.setrecursionlimit(10**7)
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def ifn(): return float(input()) #浮動小数点読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def fmn(): return map(float, input().split()) #浮動小数点map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def fln(): return list(map(float, input().split())) # 浮動小数点リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def two_distance(a, b, c, d): return ((c-a)**2 + (d-b)**2)**.5 # 2点間の距離
MOD = 10**9+7

N,K = imn()
h = iln()

dp = [10**10 for _ in range(N)]
dp[0] = 0
for i in range(N):
    for j in range(1, K+1):
        if i+j < N: dp[i+j] = min(dp[i+j], dp[i]+abs(h[i+j]-h[i]))
print(dp[N-1])


Measured memory_bytes: 82012
#include<stdio.h>
#include<math.h>
int main()
{
    int n, i, j, a;
    scanf("%d", &n);
    if(n>0 && n<105)
        printf("0\n");
    else
    {
        int count2 = 0;
        for(i=105;i<=n;i+=2)
        {
            int count1 = 0;
            for(j=1;j<=i/2;j+=2)
            {
                if(i%j==0)
                    count1++;
            }
            if(count1 == 7)
                count2++;
        }
        printf("%d\n", count2);
    }
}


Measured memory_bytes: 128
#include<cstdio>
#include<cmath>
#include<string>
#include<iostream>
#include<algorithm>
#include<utility>
#include<vector>
#include<map>
#include<set>
#include<limits>
#include<bitset>
#include<array>
#include<numeric>

using namespace std;
typedef long long int ll;


int n,a,b;

int main(){
    scanf("%d %d %d",&n,&a,&b);
    
    if((b-a)%2)printf("Borys\n");
    else printf("Alice\n");
}

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

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

int main() {
    int n;
    cin >> n;

    vector<int> l(n, 0);

    rep(i, n){
        cin >> l[i];
    }

    int count = 0;

    for(int i = 0; i < n-2; i++) {
        for(int j = i+1; j < n-1; j++) {
            if(l[i] == l[j])
                continue;
            for(int k = j+1; k < n; k++) {
                if(l[i] == l[k] || l[j] == l[k])
                    continue;

                if((l[i] + l[j] > l[k]) && (l[j] + l[k] > l[i]) && (l[k] + l[i] > l[j])) {
                    count++;
                }
            }
        }
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3196
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
int Max = 10000000;
int main()
{
	int n, t; double a; cin >> n >> t >> a;
	vector<double> h(n);
	int ans = 0;
	double Min = Max;
	rep(i, n) {
		cin >> h[i];
		h[i] *= 0.006;
		h[i] = t - h[i];
		double q = abs(h[i] - a);
		Min = min(Min, q);
	}
	rep(i, n) {
		if (Min == abs(h[i] - a))
			ans = i+1;
	}
	cout << ans;
}


Measured memory_bytes: 3716
#include<stdio.h>

int main(void)
{
    int W,H,x,y,r;
    
    scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
    
    if(x-r < 0 || x+r > W || y-r < 0 || y+r > H){
        printf("No");
    }else{
        printf("Yes");
    }
    
    putchar('\n');
    
    return 0;
}


Measured memory_bytes: 2112
#include <stdio.h>
 
 
 
int main()
{
	char str[4];
	int i;
	
		scanf("%s", str,5);
	
	if (str[0] == str[1] || str[1] == str[2] || str[2] == str[3] || str[3] == str[4]) {
		printf("Bad\n");
	}else if(str[0] == str[1] && str[1] == str[2] || str[2] == str[3] && str[3] == str[4]) {
	printf("Bad\n");
    }else if(str[0] == str[1] && str[1] == str[2] && str[2] == str[3] && str[3] == str[4]) {
      printf("Bad\n");
        }
      else  printf("Good\n");
 
 
    return 0;
}

Measured memory_bytes: 128
using System;

namespace ABC110A
{
    class Program
    {
        static void Main(string[] args)
        {
            int a, b, c;
            string[] ss = Console.ReadLine().Split(' ');
            a = int.Parse(ss[0]);
            b = int.Parse(ss[1]);
            c = int.Parse(ss[2]);
            if (a >= b && b >= c || a >= c && c >= b)
                Console.WriteLine(a * 10 + b + c);
            else if (b >= c && c >= a || b >= a && a >= c)
                Console.WriteLine(b * 10 + c + a);
            else
                Console.WriteLine(c * 10 + b + a);
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const long long LINF=8101145141919364364,LMOD=998244353;
// const int dx[]={1,1,0,-1,-1,-1,0,1},dy[]={0,-1,-1,-1,0,1,1,1};

int main(){
    int n,x; cin>>n>>x;
    long long a[n]; rep(i,n) cin>>a[i];
    long long dp[n][n]; rep(i,n) dp[0][i]=a[i];
    for(int magic=1;magic<n;magic++){
        for(int num=0;num<n;num++){
            dp[magic][num]=min(a[(num+n-magic)%n],dp[magic-1][num]);
        }
    }
    // rep(i,n){
    //     rep(j,n){
    //         cout<<dp[i][j]<<" ";
    //     }
    //     cout<<endl;
    // }
    long long ans=LINF;
    for(long long magic=0;magic<n;magic++){
        long long sum=0;
        rep(num,n){
            sum+=dp[magic][num];
        }
        ans=min(ans,sum+magic*x);
    }
    cout<<ans<<endl;
    return 0;
}


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

int main()
{
  vector<vector<int>> map(3);
  vector<vector<bool>> match(3, vector<bool>(3));
  
  for (int i = 0; i < 3; i++)
  {
    vector<int> m(3);
    cin >> m[0] >> m[1] >> m[2]; 
    map[i] = m;
  }
  
  int n ;
  cin >> n;
  
  for (int i = 0; i < n; i++)
  {
    int target;
    cin >> target;
    bool hit = false;
    
    for (int w = 0; w < 3; w++)
  	{
      for (int h = 0; h < 3; h++)
  	  {
        if (map[w][h] == target)
        {
          hit = true;
          match[w][h] = true;
          break;
        }
      }
      if (hit == true) break;
    }
  }
  
  // 縦
  bool bingo = false;
  for (int w = 0; w < 3; w++)
  {
    if (match[w][0] == true && match[w][1] == true && match[w][2] == true)
    {
      cout << "Yes" << endl; 
      return 0;
    }
  }
  
  for (int h = 0; h < 3; h++)
  {
    if (match[0][h] == true && match[1][h] == true && match[2][h] == true)
    {
      cout << "Yes" << endl; 
      return 0;
    }
  }
  
  if (match[0][0] == true && match[1][1] == true && match[2][2] == true)
  {
    cout << "Yes" << endl; 
    return 0;
  }
  
  if (match[0][2] == true && match[1][1] == true && match[2][0] == true)
  {
    cout << "Yes" << endl; 
    return 0;
  }
  
  cout << "No" << endl; 
  return 0;
}

Measured memory_bytes: 256
n = int(input())
s = []
h = []
c = []
d = []
for i in range(n):
    M = input().split()
    if M[0] == "S":
        s.append(M[1])
    elif M[0] == "H":
        h.append(M[1])
    elif M[0] == "C":
        c.append(M[1])
    elif M[0] == "D":
        d.append(M[1])

for i in range(1,14):
    if str(i) not in s:
        print("S {}".format(i))
for i in range(1,14):
    if str(i) not in h:
        print("H {}".format(i))
for i in range(1,14):
    if str(i) not in c:
        print("C {}".format(i))
for i in range(1,14):
    if str(i) not in d:
        print("D {}".format(i))



Measured memory_bytes: 5604
use std::cmp;

fn main() {
  let nw_lim = read::<usize>();
  let n_lim = nw_lim[0];
  let w_lim = nw_lim[1];
  let mut items: Vec<(usize, usize)> = Vec::new();
  for _ in 0..n_lim {
    let wv = read::<usize>();
    items.push((wv[0], wv[1]));
  }
  
  let mut v_max = 0usize;
  let mut dp: Vec<Vec<usize>> = Vec::new();
  dp.push(vec![0; n_lim]);
  for v_cur in 1..=100000usize {
    let mut row = vec![w_lim+1];
    let mut w_min = w_lim+1;
    for i in 0..n_lim {
      let (w, v) = items[i];
      let mut min = row[i];
      if v <= v_cur {
        min = cmp::min(min, dp[v_cur-v][i] + w);
      }
      row.push(min);
      w_min = cmp::min(w_min, min);
    };
    if w_min <= w_lim {
      v_max = v_cur;
    };
    dp.push(row);
  }
  
  println!("{}", v_max);
}

fn read<T: std::str::FromStr>() -> Vec<T> {
  gets().split_whitespace().filter_map(|s|s.parse().ok()).collect()
}

fn gets() -> String {
  let mut line = String::new();
  std::io::stdin().read_line(&mut line).ok();
  line.trim().to_string()
}


Measured memory_bytes: 105880
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}

//d
int main(){FIN
    
    ll n;cin>>n;
    string s;cin>>s;
    ll id1=0, id2=s.size()-1;
    ll ans=0;
    while(id2>id1){
        if (s[id1]=='W' && s[id2]=='R') {
            ans++;
            id2--; id1++;
        }
        if (s[id1]=='R') id1++;
        if (s[id2]=='W') id2--;
    }
    cout<<ans<<endl;
    return 0;
}


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

int main(void){
   int X,Y,Z;
   cin>>X>>Y>>Z;
   for(int i=1;;i++){
      int result=Y*i+Z*(i+1);
      if(result>X) {
         cout<<i-1<<endl;
         return 0;
      }
   }
   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);
        String S = sc.nextLine();
        int date = Integer.parseInt(String.join("", S.split("/")));
        System.out.println(date <= 20190430 ? "Heisei" : "TBD");
    }
}


Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define ll          long long
#define pb          push_back
#define vi          vector<ll int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define hell        1000000007
#define lbnd        lower_bound
#define ubnd        upper_bound
#define sll            set<ll int>
#define msll        multiset<ll int>
#define io    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;

ll n,q,val[200005];
vi a[200005];
bool vis[200005];

void dfs(ll node, ll ans)
{
    vis[node]=1;
    for(auto i:a[node])
    {
        if(!vis[i])
        {
            dfs(i,ans+val[node]);
        }
    }
    val[node]+=ans;
}

int main()
{
    io
    ll i,j;
    cin>>n>>q;
    memset(vis,0,sizeof vis);
    for(i=0;i<n-1;i++){
        ll x,y;
        cin>>x>>y;
        a[x].pb(y);
        a[y].pb(x);
    }
    while(q--){
        ll p,x;
        cin>>p>>x;
        val[p]+=x;
    }
    dfs(1,0);
    for(i=1;i<=n;i++){
        cout<<val[i]<<" ";
    }

    return 0;
}

Measured memory_bytes: 24448
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef long long ll;

int main(){
    ll N, M;

    cin >> N >> M;

    ll A[N];
    ll s[M], c[M];

    for(ll i = 0; i < N; i++){
        A[i] = 0;
    }
    for(ll i = 0; i < M; i++){
        cin >> s[i] >> c[i];
        for(ll j = 0; j < i; j++){
            if(s[j] == s[i] && c[j] != c[i]){
                cout << -1 << endl;
                return 0;
            }
        }
        if(N != 1 && s[i] == 1 && c[i] == 0){
            cout << -1 << endl;
            return 0;
        }
        A[s[i] - 1] = c[i];
    }

    if(N != 1 && A[0] == 0){
        A[0] = 1;
    }

    ll ans = 0;

    if(N == 1){
        ans += A[0];
    }else if(N == 2){
        ans += A[0] * 10 + A[1];
    }else if(N == 3){
        ans += A[0] * 100 + A[1] * 10 + A[2];
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;

typedef long long ll;
typedef pair<int, int> PII;
typedef double db;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define pct __builtin_popcount

#define N 15

struct P {
  int x, y;
  P(){}
  P(int _x, int _y):x(_x), y(_y) {}
  P operator + (const P&a) const {return P(x+a.x, y+a.y);}
  P operator - (const P&a) const {return P(x-a.x, y-a.y);}
  ll dot (const P&a) const {return (ll)x*a.x + (ll)y*a.y;}
  ll crs (const P&a) const {return (ll)x*a.y - (ll)y*a.x;}
  db dis (const P&a) const {return sqrt((ll)(x-a.x)*(x-a.x) + (ll)(y-a.y)*(y-a.y));}
} a[N];

int n, c[N];
db f[1<<N];
db g[1<<N];

int fn[N];
int fa(int x) {
	if (x == fn[x]) return x;
	return fn[x] = fa(fn[x]);
}

bool cmp(PII x, PII y) {
	return a[x.fi].dis(a[x.se]) < a[y.fi].dis(a[y.se]);
}

int main() {
	cin >> n;
	for (int i = 0; i < n; i ++)
		cin >> a[i].x >> a[i].y >> c[i];
	for (int p = 1; p < (1<<n); p ++) {
		vector<PII> b;
		for (int i = 0; i < n; i ++)
			for (int j = i+1; j < n; j ++)
				if (((p>>i)&1) && ((p>>j)&1))
					b.pb(mp(i, j));
		sort(b.begin(), b.end(), cmp);
		for (int i = 0; i < n; i ++) fn[i] = i;
		db dd = 0;
		for (int i = 0; i < (int) b.size(); i ++)
			if (fa(b[i].fi) != fa(b[i].se)) {
				dd += a[b[i].fi].dis(a[b[i].se]);
				fn[fa(b[i].fi)] = fa(b[i].se);
			}
		for (int i = 0; i < n; i ++)
			if ((p>>i)&1) g[p] += c[i];
		(g[p] -= dd) /= pct(p);
	}
	memset(f, 0, sizeof f);
	f[0] = 1e10;
	for (int p = 0; p < (1<<n); p ++) {
		int q = ((1<<n)-1)^p;
		for (int c = q; c; c = (c-1)&q)
			f[p|c] = max(f[p|c], min(f[p], g[c]));
	}
	printf ("%.9lf\n", f[(1<<n)-1]);
	return 0;
}

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

using ll = long long;

const int MAXN = 55;
const int MAXV = 55 * MAXN;
int N;
int A;
ll dp[MAXN][MAXN][MAXV + 100];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

	cin >> N >> A;
	dp[0][0][0] = 1;
	for (int i = 0; i < N; i++) {
		int X; cin >> X;
		for (int n = 0; n <= i; n++) {
			for (int v = 0; v < MAXV; v++) {
				dp[i+1][n+1][v+X] += dp[i][n][v];
				dp[i+1][n][v] += dp[i][n][v];
			}
		}
	}

	ll ans = 0;
	for (int n = 1; n <= N; n++) {
		ans += dp[N][n][n * A];
	}
	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 67968
#include<bits/stdc++.h>
#define L long long
#define vi vector<int>
#define pb push_back
#define pi pair<int,int>
#define pii pair<pi,int>
#define aa first
#define bb second
#define xx aa.aa
#define yy aa.bb
#define zz bb
#define mp make_pair
#define mpp(a,b,c) mp(mp(a,b),c)
using namespace std;
const int q=998244353;
int n,m,a[1000010],b[1000010],p;
inline int C(int n,int m)
{
	return (L)a[n]*b[m]%q*b[n-m]%q;
}
inline int C2(int n,int m)
{
	return (L)b[n]*a[m]%q*a[n-m]%q;
}
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int i;
	scanf("%d%d",&n,&m);
	if(n<m)
	  swap(n,m);
	a[0]=1;
	for(i=1;i<=n+m;i++)
	  a[i]=(L)a[i-1]*i%q;
	b[0]=b[1]=1;
	for(i=2;i<=n+m;i++)
	  b[i]=q-(L)q/i*b[q%i]%q;
	for(i=2;i<=n+m;i++)
	  b[i]=(L)b[i]*b[i-1]%q;
	p=n;
	for(i=1;i<=m;i++)
	  p=(p+(L)b[2]*C(2*i,i)%q*C(n-i+m-i,n-i)%q*C2(n+m,n))%q;
	printf("%d\n",p);
	return 0;
}


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

int main() {
  int a,b,c;
  cin>>a>>b>>c;
  if(a<c&&b>c){
    cout<<"Yes"<<endl;
  }
  else if(a>c&&b<c){
    cout<<"Yes"<<endl;
  }
  else {
    cout<<"No"<<endl;
  }
  
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define typeof(x) __typeof__(x)
#define int long long int
#define double long double
#define mod(x) ((x % MOD) + MOD) % MOD
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);--i)

#define ALL(c) (c).begin(),(c).end()
#define RALL(c) (c).rbegin(),(c).rend()
#define SZ(c) (int)((c).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define SORT(c) sort(ALL(c))
#define RSORT(c) sort(RALL(c))
#define LB(c,x) (int)(lower_bound(ALL(c),x)-(c).begin())
#define UB(c,x) (int)(upper_bound(ALL(c),x)-(c).begin())
#define COUNT(c,x) UB(c,x)-LB(c,x)
#define UNIQUE(c) SORT(c); (c).erase(unique(ALL(c)),(c).end());
#define COPY(c1,c2) copy(ALL(c1),(c2).begin())
#define EXIST(s,e) (s).find(e)!=(s).end()
#define PB push_back
#define MP make_pair
#define vec vector

#define dump(x)  cerr << #x << " = " << (x) << endl;

using namespace std;

typedef pair<int,int> P;
struct edge { int to, cost; };

const int INF = 1e18;
const int MOD = 1e9+7;

template<typename T> ostream& operator << (ostream& s, const vector<T>& v) {
   s << "[";
   for (int i = 0; i < v.size(); i++) { s << v[i]; if (i < v.size() - 1) s << " "; }
   s << "]";
   return s;
}
template<typename T1, typename T2> ostream& operator << (ostream& s, const pair<T1,T2>& p) {
   s << "(" << p.first << "," << p.second << ")";
   return s;
}

signed main()
{
   int N, M; cin >> N >> M;
   int ans = 1;
   for (int i = 1; i*i <= M; i++) {
      if (M % i == 0) {
         if (i >= N) {
            ans = max(ans, M/i);
         } else if (M/i >= N) {
            ans = max(ans, i);
         }
      }
   }

   cout << ans << endl;

   return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <numeric>

const int maxN = (int)2e3 + 10;

//标号为x的白、黑色球在wp[x]、bp[x]的位置上
int wp[maxN], bp[maxN];
char C[maxN * 2];
int V[maxN * 2];
int N;

void input()
{
    scanf("%d", &N);
    for (int i = 1; i <= N + N; i++)
    {
        scanf(" %c%d", C + i, V + i);
        if (C[i] == 'W')
            wp[V[i]] = i;
        else
            bp[V[i]] = i;
    }
}

struct Seg
{
    struct Node
    {
        int cnt;
        int ch[2];
    };
    Node node[maxN * 18];
    int root[maxN * 2];
    int cnt = 0;

    inline int newNode() { return cnt++; }
    int _init0(int l, int r) {
        if (l + 1 == r)
            return newNode();
        int res = newNode();
        int m = (l + r) >> 1;
        node[res].ch[0] = _init0(l, m);
        node[res].ch[1] = _init0(m, r);
        return res;
    }
    int insert(int key, int prev, int delta = 1)
    {
        int l = 1, r = N + N + 1; //2N!!!!!!!!
        int res = newNode();
        int cur = res;
        while (1)
        {
            node[cur] = node[prev];
            node[cur].cnt += delta;
            if (l + 1 == r)
                break;
            int m = (l + r) >> 1;
            int dir = (key < m ? 0 : 1);
            key < m ? r = m : l = m;
            cur = node[cur].ch[dir] = newNode();
            prev = node[prev].ch[dir];
        }
        return res;
    }
    int _l, _r;
    int _query(int nl, int nr, int cur)
    {
        if (_l <= nl && _r >= nr)
            return node[cur].cnt;
        if (_r <= nl || _l >= nr)
            return 0;
        int mid = (nl + nr) >> 1;
        return _query(nl, mid, node[cur].ch[0]) + _query(mid, nr, node[cur].ch[1]);
    }
    int query(int l, int r, int v) {
        _l = l;
        _r = r + 1;
        return _query(1, N + N + 1, root[v]); //2N!!!!!!!!!!
    }
};

Seg segW, segB;

void initSeg()
{
    segW.root[0] = segW._init0(1, N + N + 1);
    segB.root[0] = segB._init0(1, N + N + 1);
    for (int i = 1; i <= N; i++)
        segW.root[i] = segW.insert(wp[i], segW.root[i - 1]);
    for (int i = 1; i <= N; i++)
        segB.root[i] = segB.insert(bp[i], segB.root[i - 1]);
}

using LL = long long;

LL dp[maxN][maxN];

int solve()
{
    initSeg();
    memset(dp, 0x3f, sizeof(dp));
    dp[0][0] = 0;
    for (int x = 0; x <= N; x++)
        for (int y = 0; y <= N; y++)
        {
            if (x == 0 && y == 0)
                continue;
            if (x > 0)
            {
                int d = wp[x] +
                        segW.query(wp[x] + 1, N + N, x - 1) +
                        segB.query(wp[x] + 1, N + N, y) -
                        (x + y);
                dp[x][y] = std::min(dp[x][y], d + dp[x - 1][y]);
            }
            if (y > 0)
            {
                int d = bp[y] +
                        segW.query(bp[y] + 1, N + N, x) +
                        segB.query(bp[y] + 1, N + N, y - 1) -
                        (x + y);
                dp[x][y] = std::min(dp[x][y], d + dp[x][y - 1]);
            }
        }
    return dp[N][N];
}

int main()
{
    input();
    printf("%d\n", solve());
    return 0;
}

Measured memory_bytes: 32640
#include<stdio.h>
int main(void){
	int a,b,c,i,num=0;
	scanf("%d %d %d",&a,&b,&c);
	for(i=1;i<=10000;i++){
		if(c<i)
			break;
		if(c%i==0&&i>=a&&i<=b){
			num++;
		}
	}
	printf("%d\n",num);
	return 0;
}


Measured memory_bytes: 1836
import java.util.*;
import static java.lang.Math.*;
import java.math.BigInteger;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		// 入力
		int r = sc.nextInt();
		
		// 計算
		int result = r*r;
		
		// 出力
		System.out.println(result);
	}
}


Measured memory_bytes: 23892
# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque
# from decorator import stop_watch
#
#
# @stop_watch
def solve(N, As):
    ans = 0
    i = 1
    for A in As:
        if A == i:
            i += 1
        else:
            ans += 1
    ans = -1 if ans == N else ans
    print(ans)


if __name__ == '__main__':
    # S = input()
    N = int(input())
    # N, M = map(int, input().split())
    As = [int(i) for i in input().split()]
    # Bs = [int(i) for i in input().split()]
    solve(N, As)


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

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

    ll count;

    if(a == 0) count = b/x+1;
    else count = b/x-(a-1)/x;

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3572
//Compiler optimization
#pragma GCC optimize("Ofast")

//include
#include <bits/stdc++.h>
using namespace std;

//typedef
typedef long long ll;
typedef double db;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<char> vc;
typedef string S;
typedef queue<int> qi;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<vl> mat;

//macro
#define sort(a) sort(a.begin(),a.end())
#define reverse(a) reverse(a.begin(),a.end())
#define unique(a) a.erase(unique(a.begin(),a.end()),a.end())
#define fr(i,n)for(ll i=0;i<(n);i++)
#define ifr(i,n)for(ll i=(n)-1;i>=0;i--)
#define all(x) x.begin(),x.end()

//abbreviation
#define pb push_back
#define elif else if
#define mp make_pair
#define endl '\n'

//debug
#define debug(x) cerr << #x << ": " << x << endl

//const
const  ll INF = 1e18;

ll n,k;
vl a;

bool judge(ll x){
    ll t = 0;
    fr(i,n){
        t+=(a[i]-1)/x;
    }
    if(t<=k)return true;
    return false;
}
int main(){
    cin >> n >> k;
    fr(i,n){
        ll x;cin >> x;
        a.push_back(x);
    }
    ll ok = 1e9;
    ll ng = 0;
    ll mid;
    while(ok - ng > 1){
        mid = (ok+ng)/2;
        if(judge(mid)){
            ok = mid;
        }else{
            ng = mid;
        }
        debug(ok);
    }
    cout << ok << endl;
}

Measured memory_bytes: 5332
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;++i)
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
  
const ll MOD=1e9+7;
const ll INF=1e18;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
 
const int MAX=510000;
bool is_prime(long long N) {
    if (N == 1) return false;
    for (long long i = 2; i * i <= N; ++i) {
        if (N % i == 0) return false;
    }
    return true;
}
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
   
  int q;
  cin >> q;
  vector<int>s(100010);
  for(int i=1;i<=100000;i++){
    if(i&1 && is_prime(i) && is_prime((i+1)/2)) s[i]++;
  }
  rep(i,100005){
    s[i+1]+=s[i];
  }
  while(q--){
    int l,r;
    cin >> l >> r;
    l--;
    cout << s[r]-s[l] << endl;
  }
  return 0;
}


Measured memory_bytes: 3696
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
using namespace std;
int main(void){
    int x;cin>>x;
    if(x>=1800){
        cout<<1<<endl;
    }else if(x>=1600){
        cout<<2<<endl;
    }else if(x>=1400){
        cout<<3<<endl;
    }else if(x>=1200){
        cout<<4<<endl;
    }else if(x>=1000){
        cout<<5<<endl;
    }else if(x>=800){
        cout<<6<<endl;
    }else if(x>=600){
        cout<<7<<endl;
    }else{
        cout<<8<<endl;
    }
}


Measured memory_bytes: 3524
<?php
  	fscanf(STDIN, "%d %d %d", $a, $b, $c);	
	$poor = FALSE;

	if ($a == $b && $a != $c) $poor = TRUE;
	if ($a == $c && $a != $b) $poor = TRUE;
	if ($b == $c && $b != $a) $poor = TRUE;

	if ($poor) {
      	echo "Yes\n";
    } else {
      	echo "No\n";
    }
    
	
  

Measured memory_bytes: 5368
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include<climits>
#include<fstream>
using namespace std;
///////////////////library zone!!!!!!!!!!!!!!!!!!!!!!!!!!!!
typedef long long ll;
typedef long double ld;
#define all(a) (a).begin(),(a).end()
#define EPS (1e-5)
const ll Mod = 1000000007;
const ll mod = 998244353;
struct H {
	ll x, y;
	bool operator<(const H &b) const {
		if (x != b.x) return x < b.x;
		return y < b.y;
	}
	bool operator>(const H &b) const {
		if (x != b.x) return x > b.x;
		return y > b.y;
	}
	bool operator==(const H &b) const { return x == b.x&&y == b.y; }
	bool operator!=(const H &b) const { return (*this) != b; }
};
struct P {
	ll pos, cost;
	bool operator<(const P &b) const { return cost < b.cost; }
	bool operator>(const P &b) const { return cost > b.cost; }
};
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
	bool operator<(const E &b) const { return cost < b.cost; }
	bool operator>(const E &b) const { return cost > b.cost; }
};
template<typename T, typename U>
void chmin(T &a, U b) {
	if (a > b) a = b;
}
template<typename T, typename U>
void chmax(T &a, U b) {
	if (a < b) a = b;
}
template<typename T>
T max_0(T a) {
	if (a < 0) return 0;
	return a;
}
template<typename T>
T min_0(T a) {
	if (a > 0) return 0;
	return a;
}
ll read() {
	ll u;
	ll k = scanf("%lld", &u);
	return u;
}
ll gcd(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcd(j%i, i);
}
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x % p;
		x = x * x % p;
		n >>= 1;
	}
	return res;
}//x^n%p
vector<string>split(string s, char c = ' ') {
	vector<string>vec;
	string h = "";
	for (int i = 0; i < s.size();) {
		int j = i;
		while (j < s.size() && s[j] != ' ') {
			h += s[j++];
		}
		if (h.size() > 0) vec.push_back(h);
h = "";
i = j + 1;
	}
	return vec;
}
template<typename T>
void print_vec(vector<T>a) {
	for (int i = 0; i < a.size(); i++) {
		cout << (i == 0 ? "" : " ") << a[i];
	}
	cout << endl;
}
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
int n;
int a[300000];
H b[300000];
H c[300000];
//この値の時に答えとして使った2組
signed main() {
	cin >> n;
	n = 1 << n;
	for (int i = 0; i < n; i++) cin >> a[i];
	int ans = 0;
	for (int i = 1; i < n; i++) {
		vector<H>v = { H{a[0],0},H{a[i],i} };
		for (int j = 0; j < 19; j++) {
			if (i&(1 << j)) {
				v.push_back(b[i ^ (1 << j)]);
				v.push_back(c[i ^ (1 << j)]);
			}
		}
		sort(all(v));
		H r = v[v.size() - 1], t;
		int k = 2;
		while (v[v.size() - k].y == r.y) k++;
		t = v[v.size() - k];
		chmax(ans, r.x + t.x);
		cout << ans << endl;
		b[i] = r, c[i] = t;
	}
}

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

int n;
string c;

long long solve(string s)
{
    if(s.size() == n){
        string t = s;
        reverse(t.begin(), t.end());
        istringstream iss(s + c + t);

        long long a;
        iss >> a;

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

    for(char i='9'; i>='0'; --i){
        if(s.empty() && i == '0')
            continue;
        long long ret = solve(s + i);
        if(ret != -1)
            return ret;
    }

    return -1;
}

int main()
{
    cin >> n >> c;

    if(c[0] == '-'){
        if(n == 1)
            cout << 11 << endl;
        else
            cout << string(2*n, '9') << endl;
        return 0;
    }

    long long ret = solve("");
    if(ret == -1){
        string s = string(n, '9') + c + string(n, '9');
        cout << s << endl;
    }else{
        cout << ret << endl;
    }

    return 0;
}

Measured memory_bytes: 1232
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define len(v) ll(v.size())
#define fi first
#define se second

template <class T>
void cout_vec(const vector<T> &vec){
  for(auto itr:vec) cout<<itr<<' ';
  cout<<endl;
}

template <class T>
void cout_vec2(const vector<vector<T>> &vec){
  rep(i,vec.size()){
    rep(j,vec[i].size()){
      cout<<vec[i][j]<<' ';
    }
    cout<<endl;
  }
}

typedef pair<ll,ll> P;
const ll mod=1e9+7;
const ll inf=1e15;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  string a,b,c;
  cin>>a>>b>>c;
  string ans;
  ans.push_back(a[0]);
  ans.push_back(b[0]);
  ans.push_back(c[0]);
  cout<<ans<<endl;
}

Measured memory_bytes: 256
main::IO()
main = do
  nc<-getLine
  let n = read nc ::Int
  dat<-(get_n n)
  print (solver 1 dat)
 
 
 
solver :: Int -> [Int] -> Int
solver x [] = 0
solver x (b:rest)= if b<x then solver x rest
                          else if b==x then solver (x+1) rest
                                       else if (mod b x==0) then ((div b x)-1)+(solver (max 2 x) rest)
                                                            else (div b x)+(solver (max 2 x) rest)
 
get_n::Int -> IO [Int]
get_n 0 = return []
get_n n = do
          c<-getLine
          let m = read c ::Int
          rest<- (get_n (n-1))
          return (m:rest)

Measured memory_bytes: 64892
using System;
using System.Collections.Generic;
using System.Linq;
using static AtCoder.Io;
namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var nx = ReadLongArray();
            var n = nx[0];
            var x = nx[1];
            var a = ReadLongArray();

            long count = 0;
            for (var i = 0; i < a.Length; i++)
            {
                if (a[i] > x)
                {
                    count += a[i] - x;
                    a[i] -= a[i] - x;
                }

                if (i > 0 && a[i] + a[i - 1] > x)
                {
                    count += a[i] + a[i - 1] - x;
                    a[i] -= a[i] + a[i - 1] - x;
                }
            }
            Console.WriteLine(count);
        }
    }

    public static class Io
    {
        public static string ReadString() => Console.ReadLine();
        public static string[] ReadStringArray() => ReadString().Split(' ');
        public static int ReadInt() => int.Parse(ReadString());
        public static long ReadLong() => long.Parse(ReadString());
        public static int[] ReadIntArray() => ReadStringArray().ParseInt().ToArray();
        public static long[] ReadLongArray() => ReadStringArray().ParseLong().ToArray();
        public static IEnumerable<int> ParseInt(this IEnumerable<string> source) => source.Select(int.Parse);
        public static IEnumerable<long> ParseLong(this IEnumerable<string> source) => source.Select(long.Parse);
    }

    public static class Utility
    {
        public static IEnumerable<int> EnumerateDigits(int value)
        {
            while (value > 0)
            {
                yield return value % 10;
                value /= 10;
            }
        }
    }
}


Measured memory_bytes: 33500
#include <iostream>
#include <iomanip>
#include <queue>
#include <deque>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <bitset>

#define REP(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define FILL(x, y) memset(x, y, sizeof(x))
#define pb push_back
#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define eprintf(...) 42
#endif

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 (a > b) {
      a = b;
      return 1;
   }
   return 0;
}

using namespace std;
using ll = long long;

const int kInf = 2e9;
const ll kLInf = 2e18;

int gcd (int a, int b) {
   return b ? gcd(b, a % b) : a;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

int M1, D1, M2, D2;

int main()
{
   cout << fixed << setprecision(10);
   cin >> M1 >> D1 >> M2 >> D2;
   int ans = M2 > M1 ? 1 : 0;
   cout << ans << endl;
   return 0;
}



Measured memory_bytes: 764
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
	while(1){
		int n; cin >> n;
		if (n == 0) break;
		int mind = 1000001;
		vector<int> v(n);
		for (int i = 0; i < n; i++){
			cin >> v[i];
		}
		sort(v.begin(),v.end());
		for (int i = 0; i < n -1; i++){
			mind = min(mind , v[i+1] - v[i]);
		}
		cout << mind << endl;
	}
return 0;
}

Measured memory_bytes: 3120
MN = 1000000
prime = []
mem = [False] * 2 + [True] * MN
for i in range(2, MN):
  if not mem[i]:
    continue
  prime.append(i)
  for j in range(i + i, MN, i):
    mem[j] = False

while True:
  N, ans = input(), 0
  if not N:
    break

  for p in prime:
    if p > N / 2:
      break
    if mem[N - p]:
      ans += 1
  print(ans)

Measured memory_bytes: 59524
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, k, x, y;
  cin >> n >> k >> x >> y;
  
  int total = 0;
  for (int i = 1; i <= n; i++) {
    if (i <= k) {
      total += x;
    } else if (i > k) {
      total += y;
    }
  }
  cout << total << endl;
}

Measured memory_bytes: 256