akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll     = int64_t;
using ull    = uint64_t;
using prefix = __attribute__((constructor))void;
const ll MOD = 1000000007;
const ll INF = LONG_MAX;

#define elif           else if
#define def            inline auto
#define func           inline constexpr ll
#define up(i,a,n)      for(ll i=(a),i##_1=(n);i<=i##_1;++i)
#define down(i,a,n)    for(ll i=(a),i##_1=(n);i>=i##_1;--i)
#define rep(i,n)       up(i,0,n-1)
#define append(a)      push_back(a)
#define fout           cout<<fixed<<setprecision(10)
#define fasten         cin.tie(0),ios::sync_with_stdio(0)

func    gcd(ll a,ll b) {return b?gcd(b,a%b):a;}
func    lcm(ll a,ll b) {return a*b/gcd(a,b);}
def     dig(ll a)      {return to_string(a).length();}
prefix  init()         {fasten,fout;}

    ll rail[501][501];
signed main(){
    ll N,M,Q,L,R,S;
    cin>>N>>M>>Q;
    rep(i,M){
        cin>>L>>R;
        rail[L][R-L]++;
    }
    up(i,1,N){
        up(j,1,N){
            rail[i][j]+=rail[i][j-1];
        }
    }
    rep(i,Q){
        cin>>L>>R;
        S=0;
        up(j,L,R){
            S+=rail[j][R-j];
        }
        cout<<S<<"\n";
    }
}
//for compilation: g++ -o _ _.cpp -std=c++14 (or 17)
//
//for fastening: g++ -O2 -o _ _.cpp -std=c++14 (or 17)
//for fastening: g++ -O3 -mtune=native -march=native -o _ _.cpp -std=c++14 (or 17)


Measured memory_bytes: 2944
import java.util.*;

public class Main{
    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);
	int R = sc.nextInt();
	if(R < 1200) System.out.print("ABC");
	else if(R < 2800) System.out.print("ARC");
	else System.out.print("AGC");
    }
}


Measured memory_bytes: 21588
using System;
using System.Collections.Generic;

namespace test
{
    class MainClass
    {
        public static void Main(string[] args)
        {

            //問題165

            int K = int.Parse(Console.ReadLine());

            string[] line = Console.ReadLine().Split(' ');

            int A = int.Parse(line[0]);
            int B = int.Parse(line[1]);

            //for (int i = A; i <= B; i++)
            //{
            //    if (i % K == 0) 
            //    {
            //        Console.WriteLine("OK");
            //        return;
            //    }
            //}

            if (A <= B - B % K)
            {
                Console.WriteLine("OK");
                return;
            }
            else
            {
                Console.WriteLine("NG");

            }

        }


    }
}


Measured memory_bytes: 27384
import java.io.IOException;
import java.io.InputStream;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {
	public static void main(String[] args) {
		FastScanner sc = new FastScanner();
		int N = sc.nextInt();
		int[] A = new int[N+1];
		long ans = 0;
		for (int i = 0; i <= N; i++) {
			A[i] = sc.nextInt();
		}
		for (int i = 0; i < N; i++) {
			int B = sc.nextInt();
			int surplus = 0;
			if (A[i] < B) {
				ans += A[i];
				surplus = B - A[i];
				if (A[i+1] < surplus) {
					ans += A[i+1];
				} else {
					ans += surplus;
				}
				A[i+1] = Math.max(A[i+1] - surplus,0);
			} else {
				ans += B;
			}
			
		}
		System.out.println(ans);
	}
}

class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }

    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }

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


Measured memory_bytes: 23508
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2147483647
#define int long long
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
//typedef long long int ll;
signed main(){
    
    int h,w,min=9223372036854775807;
    cin>>h>>w;
    for(int i=1;i<h;i++){
        int a,b,c,k=(h-i)/2;
        a=i*w;
        if(h-i>1){
            b=k*w;
            c=(h-i-k)*w;
            min=std::min(std::max({a,b,c})-std::min({a,b,c}),min);
        }
        k=w/2;
        b=k*(h-i);
        c=(w-k)*(h-i);
        min=std::min(std::max({a,b,c})-std::min({a,b,c}),min);
    }
    for(int i=1;i<w;i++){
        int a,b,c,k=(w-i)/2;
        a=i*h;
        if(w-i>1){
            b=k*h;
            c=(w-i-k)*h;
            min=std::min(std::max({a,b,c})-std::min({a,b,c}),min);
        }
        
        k=h/2;
        b=k*(w-i);
        c=(h-k)*(w-i);
        min=std::min(std::max({a,b,c})-std::min({a,b,c}),min);
    }
    
    cout<<min<<endl;
    
}


Measured memory_bytes: 256
a, b, c, x, y = map(int, input().split())

_1 = a*x + b*y
if x >= y:
    _2 = 2*y*c + (x - y)*a
    _3 = 2*x*c
else:
    _2 = 2*x*c + (y - x)*b
    _3 = 2*y*c
print(min(min(_1, _2), _3))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1e9+7;
#define rep1(i, n) for (ll i=0; i<(n); i++) 
#define rep2(i, k, n) for (ll i=k; i<(n); i++)
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; }


int main() {
    ll n;
    cin >> n;
    vector<ll> a(n, 0);
    rep1(i, n) cin >> a[i];
    sort(a.begin(), a.end());
    ll ai = a[a.size()-1];
    ll aj;
    P p = make_pair(INF, 0);
    rep1(i, n-1){
        if (p.first>abs(ai-a[i]*2)){
            p = make_pair(abs(ai-a[i]*2), a[i]);
        }
    }
    aj = p.second;
    cout << ai << " " << aj << endl;
    //printf("%.12f", ans);
}

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

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define mp make_pair
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }

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

  int N;
  cin >> N;
  set<string> s;
  rep (i, N) {
    string S;
    cin >> S;
    s.insert(S);
  }
  cout << s.size() << endl;
}


Measured memory_bytes: 19284
#include<iostream>
using namespace std;
int main(){
        int a,b,c,t;
        cin >> a >> b >> c;
        if (a>b) {t=a;a=b;b=t;}
        if (b>c) {t=b;b=c;c=t;}
        if (a>b) {t=a;a=b;b=t;}
        cout << a <<" "<< b <<" "<< c <<endl;
        return 0;
}

Measured memory_bytes: 1164
#include <iostream>

using namespace std;

int hist[1100000];

int main()
{
  int N;
  cin >> N;
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    hist[a]++;
    hist[a - 1]++;
    hist[a + 1]++;
  }
  
  int ans = -1;
  for (int i = 0; i < 1100000; i++) {
  	ans = max(ans, hist[i]);
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define pi acos(-1)
#define IOS ios_base::sync_with_stdio(0); cin.tie(); cout.tie();
#define ff first
#define ss second
#define pb push_back
#define debug(val) cerr << "The value of " << #val << " is = " << val << '\n';
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 0x3f3f3f3f;
const ll mininf = -922337203685477;
const ll nax = 1e5 + 5;
int n, arr[nax], curr=0, maks=0;

int main(){
	IOS
	cin >> n;
	for(int i=1;i<=n;i++){
		cin >> arr[i];
	}
	for(int i=2;i<=n;i++){
		if(arr[i]<=arr[i-1]){
			curr++;
		}
		else{
			maks=max(maks, curr);
			curr=0;
		}
	}
	maks=max(maks, curr);
	cout << maks << '\n';
}


Measured memory_bytes: 3992
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
typedef long long ll;
const int mod = 1e9 + 7;
int main() {

    int n;
    cin >> n;
    string s[3];
    rep(i, 3){
        cin >> s[i];
    }

    int ans = 0;
    rep(i, n){
        set<char> c;
        c.insert(s[0][i]);
        c.insert(s[1][i]);
        c.insert(s[2][i]);
        ans += c.size() - 1;
    }
    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define EPS 1e-10
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s,n) qsort(s,n,sizeof(char),cmp)
#define chsort_r(s,n) qsort(s,n,sizeof(char),char_cmp_r);
#define TYPE char
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
	return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
	return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
	int t=*a;
	*a=*b;
	*b=t;
}
long long gcd(long long x,long long y){
	return x%y?gcd(y,x%y):y;
}
long long lcm(long long x,long long y){
	return x/gcd(x,y)*y;
}

// konoshita kara kaku

int main(void){
	char s[5];
	chin(s);
	sort(s,3);
	puts(strcmp(s,"abc")==0?"Yes":"No");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <utility>
#include <cstring>
#include <cmath>
const int MOD = 1e9 + 7;
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};
using namespace std;
typedef long long ll;
char d[] = {'E', 'S', 'W', 'N'};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll h, w, l;
    while(cin >> h >> w >> l)
    {
        if(h == 0 && w == 0 && l == 0)
            break;
        int y, x, dir;
        char table[h + 1][w + 1];
        for(int i = 0; i < h; i++)
            for(int j = 0; j < w; j++)
            {
                cin >> table[i][j];
                if(table[i][j] == 'E')
                {
                    y = i; x = j; dir = 0;
                }
                if(table[i][j] == 'S')
                {
                    y = i; x = j; dir = 1;
                }
                if(table[i][j] == 'W')
                {
                    y = i, x = j; dir = 2;
                }
                if(table[i][j] == 'N')
                {
                    y = i; x = j; dir = 3;
                }
            }
        ll flag[h + 1][w + 1][4];
        memset(flag, -1, sizeof(flag));
        while(l > 0)
        {
            if(flag[y][x][dir] != -1)
            {
                ll tmp = (flag[y][x][dir] - l);
                l %= tmp;
                if(l == 0) l += tmp;
 
            }
            else
                flag[y][x][dir] = l;
            int ny = y + dy[dir];
            int nx = x + dx[dir];
            if(ny < 0 || nx < 0 || ny >= h || nx >= w || table[ny][nx] == '#')
            {
                dir = (dir + 1) % 4;
            }
            else
            {
                y += dy[dir];
                x += dx[dir];
                l--;
            }
        }
        cout << y + 1 << " " << x + 1 << " " << d[dir] << endl; 
    }
    return 0;
}


Measured memory_bytes: 3464
#include<iostream>
#include<cstdlib>
#include <cmath>
#include<algorithm>
#include<vector>
#include<string>
#include<unordered_map>
#include <bits/stdc++.h>
using namespace std;

#define INF 10000000
int main()
{ 
    int N;
    cin >> N;
    
    int a[N];
    for(int i=0; i<N; i++){
        cin >> a[i];
    }
    
    long long money[N];
    for(int n=0; n<N; n++){
        money[n] = - INF;
    }
    money[0] = 1000;
    for(int n=1; n<N; n++){
        money[n] = money[n-1];
        for(int i=0; i<n; i++){
            long long stock = money[i] / a[i];
            long long im = money[i] + (a[n]-a[i]) * stock;
            money[n] = max(money[n], im);
        }
    }
    
    cout << money[N-1] << endl;        
        
}


Measured memory_bytes: 3560
import java.util.Scanner;

public class Main
{
	public static void main(String args[])
	{
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext())
		{
			int n = sc.nextInt();
			int count = 0;
			for(int i=0;i<10;i++)
			{
				for(int j=0;j<10;j++)
				{
					for(int p=0;p<10;p++)
					{
						for(int q=0;q<10;q++)
						{
							if(i+j+p+q == n) count++;
						}
					}
				}
			}
			System.out.println(count);
		}
	}
}

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

bool judge(int a, int b, int c) {
    if (a < b + c && b < c + a && c < a + b) return true;
    else return false;
}

int main() {
    int n;
    cin >> n;
    int a[n];
    rep(i,n) cin >> a[i];
    sort(a, a+n);
    int64_t ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            for (int k = j + 1; k < n; k++) {
                if (judge(a[i], a[j], a[k])) ans++;
                else break;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<cstdio>
int n;
int a[100010];
int main(){
	scanf("%d", &n);
	for(int i = 1; i <= n; i++) scanf("%d", &a[i]);
	for(int i = n; i >= 2; i--){
		if(a[i - 1] - 1 > a[i]){
			printf("No");
			return 0;
		}
		else if(a[i - 1] - 1 == a[i]) a[i - 1] = a[i - 1] - 1;
	}
	printf("Yes");
	return 0;
}

Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  double ret = 0;
  while (n--) {
    double x;
    string s;
    cin >> x >> s;
    if (s == "JPY") {
      ret += x;
    } else {
      ret += x * 380000;
    }
  }
  printf("%.10f\n", ret);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <string>
#include <algorithm>
#include <cstring>
#include <map>
#include <set>
using namespace std;

int main(void){
  int N;
  cin >> N;
  
  set<int> don;  
  
  for(int i=0;i<N;i++){
    int tmp;
    cin >> tmp;
    don.insert(tmp);
  }
  
  if(don.size() == N){
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
  

  return 0;
}



Measured memory_bytes: 9600
#include<cstdio>
#include<iostream>
using namespace std;
int main()
{
	int a,b;
	char op;
	cin>>a>>op>>b;
	if(op=='+')
	 cout<<a+b<<endl;
	else if(op=='-')
	 cout<<a-b<<endl;
	 return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STI(s) atoi(s.c_str())
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int
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;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const ll MOD = 1000000007;
const double EPS = 1e-9;
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;

vector<vector<pair<int,int>>> g(101010);
vi ans(101010,-1);
vb used(101010,false);

void dfs(int n, int s){
    // cout<<"n;"<<n<<endl;
    rep(i,g[n].size()){
        if(used[g[n][i].first])continue;
        used[g[n][i].first]=1;
        if(g[n][i].second%2==0){
            ans[g[n][i].first]=s;
            dfs(g[n][i].first,s);
        }
        else{
            ans[g[n][i].first]=1-s;
            dfs(g[n][i].first,1-s);
        }
    }
}

int main(void) {
    
    int n;
    cin>>n;
    rep(i,n-1){
        int u,v,w;
        cin>>u>>v>>w;
        u--;v--;
        g[u].pb(mp(v,w));
        g[v].pb(mp(u,w));
    }
    used[0]=1;
    ans[0]=0;
    dfs(0,0);
    rep(i,n)fin(ans[i]);
}


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

int main(){
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++){
		cout<<'x';
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  int N;
  cin >> N;
  int a=0;
  for(int i=0; i<N; i++){
    int k;
    cin >> k;
    a ^= k;
  }  
  cout << (a==0?"Yes":"No") << endl;
  return 0;
}

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

namespace A_ABC157
{
    class MainClass
    {

        static int[] s1, s2, s3, n;

        public static void Main(string[] args)
        {
            s1 = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
            var d1 = new Dictionary<int, bool>();
            d1.Add(s1[0], false);
            d1.Add(s1[1], false);
            d1.Add(s1[2], false);
            s2 = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
            var d2 = new Dictionary<int, bool>();
            d1.Add(s2[0], false);
            d1.Add(s2[1], false);
            d1.Add(s2[2], false);
            s3 = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
            var d3 = new Dictionary<int, bool>();
            d1.Add(s3[0], false);
            d1.Add(s3[1], false);
            d1.Add(s3[2], false);
            n = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);

            for (int i = 0; i < n[0]; i++)
            {
                int[] b = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
                if (d1.ContainsKey(b[0]))
                {
                    d1[b[0]] = true;
                }
            }

            for (int i = 0; i < 3; i++)
            {
                if (d1[s1[i]] == true && d1[s2[i]] == true && d1[s3[i]] == true)
                {
                    WriteLine("Yes");
                    return;
                }
            }
            if (d1[s1[1]] == true && d1[s1[2]] == true && d1[s1[0]] == true)
            {
                WriteLine("Yes");
                return;
            }
            if (d1[s2[1]] == true && d1[s2[2]] == true && d1[s2[0]] == true)
            {
                WriteLine("Yes");
                return;
            }
            if (d1[s3[1]] == true && d1[s3[2]] == true && d1[s3[0]] == true)
            {
                WriteLine("Yes");
                return;
            }

            if (d1[s1[0]] == true && d1[s2[1]] == true && d1[s3[2]] == true)
            {
                WriteLine("Yes");
                return;
            }
            if (d1[s1[2]] == true && d1[s2[1]] == true && d1[s3[0]] == true)
            {
                WriteLine("Yes");
                return;
            }



            WriteLine("No");
        }
    }
}


Measured memory_bytes: 13280
main = do
  li <- getLine
  let [a,b,x] = map read $ words li
  let ans = compute a b x
  print ans

{-
xで割り切れるような数は nx である
a = mx + i, b = nx + j (0<=i,j<x) と表せたとする。
i = 0のとき、aは確実にそれで、あと n-m個ある。jは必要ない。
i > 0のとき、n-m個だけある。
-}

compute :: Int -> Int -> Int -> Int
compute a b x = n - m + if i == 0 then 1 else 0
  where
    (m,i) = divMod a x
    n = div b x

Measured memory_bytes: 508
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

A = input()
B = input()

if len(A) != len(B):
    print("GREATER" if len(A) > len(B) else "LESS")
else:
    def lt(A, B):
        l = len(A)
        for i in range(l):
            if A[i] > B[i]:
                return "GREATER"
            elif A[i] < B[i]:
                return "LESS"
        return "EQUAL"

    print(lt(A, B))

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
#define FASTIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define forn(i, a, b) for(int i = (a); i <= (b); ++i)
#define forev(i, b, a) for(int i = (b); i >= (a); --i)
#define endl "\n"
int dp[100005];
int getAns(int a[],int i,int n){
    if(i == n-1)return 0;
    if(dp[i] != -1)return dp[i];
    //jump to i+1
    int x = 0;
    if(i < n-1)x = abs(a[i+1] - a[i]) + getAns(a,i+1,n);

    //jump to i+2
    int y = 0;
    if(i < n-2)y = abs(a[i+2] - a[i]) + getAns(a,i+2,n);
   // cout<<x<<" "<<y<<endl;
    if(i == n-2)return dp[i] = x;
    return dp[i] = min(x,y);
}
int main(){
    FASTIO
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++)cin>>a[i];
    memset(dp,-1,sizeof(dp));
    cout<<getAns(a,0,n)<<endl;
}


Measured memory_bytes: 7296
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<climits>
#include<iostream>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<list>
#include<map>
#include<set>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
 
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)

int a[7368792];

bool sosuu(int n){
    bool isPrime = true;
    for(int i = 2;i < n;i++){
        if(n / i == 0){
            isPrime = false;
            break;
        }
    }
    return isPrime;
}

int main(){
    while(1){
        int m,n;

        scanf("%d%d",&m,&n);
        if(m == 0 && n == 0)
            break;

        REP(i,7368792)
            a[i] = 1;
 
        int start = m;
        while(!sosuu(start++));
        start--;

        int cou = 0;
        for(int i = start;cou < n;i++){
            if(a[i] == 1){
                cou++;
                for(int j = i;j <= 7368791;j+=i){
                    a[j] = 0;
                }
            }
        }
        int b;
        for(b = start;true;b++){
            if(a[b] == 1)
                break;
        }
        printf("%d\n",b);
    }
}

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

#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define rev(v) reverse(v.begin(), v.end());
#define io() ios_base::sync_with_stdio(0);cout.tie(0);cin.tie(0);srand(time(NULL));
using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

signed main(){
	io();
	int n, k; cin >> n >> k;
	vector<ll> v(n);
	for(auto &x : v) cin >> x;
	sort(allr(v));
	ll ans = 0;
	for(int i = k;  i < n; ++i){
		ans += v[i];
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 4752
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<int,int>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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; }
int main(){
int n,m;
cin>>n>>m;
V<int> a(n,0);
for(int i=0;i<m;i++){
    int u,v;
    cin>>u>>v;
    a[u-1]++;a[v-1]++;
}
for(int i=0;i<n;i++)cout<<a[i]<<endl;
}

Measured memory_bytes: 256
import java.util.*;
class Main
{
	public static void main(String[] args)                                        
	{
		Scanner sc=new Scanner(System.in);
		int t,k,l;
		String p;
		p=sc.next();
		
		if((p.charAt(2)==p.charAt(3))&&(p.charAt(4)==p.charAt(5)))
		System.out.println("Yes");
		else
				System.out.println("No");

		
		
		
	
		
	}
	
	
			
	
		
}



Measured memory_bytes: 22740
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

func main() {
	s := IOInitialize()
	N := Int(s)
	strs := scanstrings(s, N)
	m := map[string]int{}
	for _, str := range strs {
		if !(str == "M" || str == "A" || str == "R" || str == "C" || str == "H") {
			continue
		}
		if _, ok := m[str]; ok {
			m[str]++
		} else {
			m[str] = 1
		}
	}
	cnt := int64(0)
	selectedKeyMap := map[string]bool{}
	for key, value := range m {
		selectedKeyMap[key] = true
		sum := int64(0)
		_selectedKeyMap := map[string]bool{}
		for _key, _value := range m {
			_selectedKeyMap[_key] = true
			if _, ok := selectedKeyMap[_key]; ok {
				continue
			}
			_sum := int64(0)
			for __key, __value := range m {
				if _, ok := _selectedKeyMap[__key]; ok {
					continue
				}
				if _, ok := selectedKeyMap[__key]; ok {
					continue
				}
				_sum += int64(__value)
			}
			sum += _sum * int64(_value)
		}
		cnt += sum * int64(value)
	}
	fmt.Println(cnt)
}

func IOInitialize() *bufio.Scanner {
	s := bufio.NewScanner(os.Stdin)
	s.Split(bufio.ScanWords)
	return s
}

func Int(s *bufio.Scanner) int {
	if !s.Scan() {
		panic("scan error")
	}

	value, err := strconv.Atoi(s.Text())
	if err != nil {
		panic("text to int error")
	}
	return value
}

func String(s *bufio.Scanner) string {
	if !s.Scan() {
		panic("scan error")
	}

	return s.Text()
}

func scanstrings(s *bufio.Scanner, len int) (strs []string) {
	for i := 0; i < len; i++ {
		str := String(s)
		_strs := strings.Split(str, "")
		strs = append(strs, _strs[0])
	}
	return
}


Measured memory_bytes: 10752
#include<stack>
#include<cstdio>
#include<cstring>

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

using namespace std;

typedef long long ll;

const ll INF=1LL<<61;

const int Q_MAX=300000;

int q;
ll a,b;

char from[Q_MAX+1],to[Q_MAX+1][16];

// dp[c][dep] := ( 文字 c からはじめて, クエリ dep, dep+1, ..., q-1 を順に処理したときにできる文字列の長さ )
ll dp[26][Q_MAX];
ll dfs_count(char c,int dep){
	if(dep==q) return 1;

	ll &res=dp[c-'a'][dep];
	if(res!=-1) return res;

	if(from[dep]==c){
		res=0;
		for(int i=0;to[dep][i];i++){
			res+=dfs_count(to[dep][i],dep+1);
			res=min(res,INF);
		}
	}
	else{
		res=dfs_count(c,dep+1);
	}
	return res;
}

struct state{
	int pos;
	char c;
	int dep;
};

int main(){
	char s[16];
	scanf("%s%d%lld%lld",s,&q,&a,&b);
	a--;
	rep(i,q){
		scanf(" %c%s",from+i,to[i]);
		if(to[i][0]=='.') to[i][0]='\0';
	}

	memset(dp,-1,sizeof dp);
	// 再帰が深くならないように適当に間引いて計算しておく
	for(char c='a';c<='z';c++) for(int dep=q-1;dep>=0;dep-=100) dfs_count(c,dep);

	// 経路圧縮用
	static char next_c[26][Q_MAX+1];
	static int next_dep[26][Q_MAX+1];
	// next_c, next_dep を初期化
	for(char c='a';c<='z';c++) rep(dep,q+1) {
		char &c2=next_c[c-'a'][dep];
		int &dep2=next_dep[c-'a'][dep];
		if(dep==q){
			c2=c;
			dep2=dep;
		}
		else{
			if(from[dep]==c){
				int len=strlen(to[dep]);
				int cnt=0,i0=-1;
				rep(i,len) if(dfs_count(to[dep][i],dep+1)>0) cnt++, i0=i;

				if(cnt!=1){
					c2=c;
					dep2=dep;
				}
				else{
					c2=to[dep][i0];
					dep2=dep+1;
				}
			}
			else{
				c2=c;
				dep2=dep+1;
			}
		}
	}

	int sz=0;
	static char ans[100010];

	ll cnt=0;
	stack<state> S;
	for(int i=strlen(s)-1;i>=0;i--){
		S.push((state){0,s[i],0});
	}
	while(!S.empty()){
		int pos=S.top().pos;
		char c=S.top().c;
		int dep=S.top().dep; S.pop();

		if(pos==0){
			if(sz==b-a) continue;

			if(a<=cnt && dep==q) ans[sz++]=c;

			ll num=dfs_count(c,dep);
			if(cnt+num<=a){
				cnt+=num;
			}
			else{
				char c2=next_c[c-'a'][dep];
				int dep2=next_dep[c-'a'][dep];
				// 経路圧縮しない
				if(dep2==dep){
					int len=strlen(to[dep]);
					for(int i=len-1;i>=0;i--) if(dfs_count(to[dep][i],dep+1)>0) S.push((state){0,to[dep][i],dep+1});
				}
				// 経路圧縮する
				else{
					S.push((state){1,c,dep});
					S.push((state){0,c2,dep2});
				}
			}
		}
		else{ // pos==1
			char c2=next_c[c-'a'][dep];
			int dep2=next_dep[c-'a'][dep];
			next_c[c-'a'][dep]=next_c[c2-'a'][dep2];
			next_dep[c-'a'][dep]=next_dep[c2-'a'][dep2];
		}
	}

	if(sz<b-a) puts(".");
	else       puts(ans);

	return 0;
}

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

constexpr int mod=1e9+7;

template< int mod >
struct ModInt {
  int x;

  ModInt() : x(0) {}

  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}

  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }

  ModInt &operator*=(const ModInt &p) {
    x = (int) (1LL * x * p.x % mod);
    return *this;
  }

  ModInt &operator/=(const ModInt &p) {
    *this *= p.inverse();
    return *this;
  }

  ModInt operator-() const { return ModInt(-x); }

  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }

  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }

  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }

  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }

  bool operator==(const ModInt &p) const { return x == p.x; }

  bool operator!=(const ModInt &p) const { return x != p.x; }

  ModInt inverse() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }

  ModInt pow(int64_t n) const {
    ModInt ret(1), mul(x);
    while(n > 0) {
      if(n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }

  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }

  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt< mod >(t);
    return (is);
  }

  static int get_mod() { return mod; }
};

using modint = ModInt< mod >;

template< typename T >
T mod_pow(T x, T n, const T &p) {
  T ret = 1;
  while(n > 0) {
    if(n & 1) (ret *= x) %= p;
    (x *= x) %= p;
    n >>= 1;
  }
  return ret;
}

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

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

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

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

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

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

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

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

int main()
{
    int k;cin>>k;
    string s;
    cin>>s;
    int n=s.length();
    Combination<modint>comb(2000000);
    modint ans=0;
    for(int i=k;i>=0;--i){
        modint res=modint(26).pow(i);
        res*=modint(25).pow(k-i);
        res*=comb.C(n+k-i-1, n-1);
        ans+=res;
    }
    cout<<ans;
}

Measured memory_bytes: 27712
#pragma region
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, m, n) for (int i = m; i < n; i++)
#define all(v) v.begin(), v.end()
#define INF 1e9
#define EPS 1e-10
using namespace std;
typedef long long ll;
#pragma endregion

int main()
{
    int N,M,count = 0;
    cin >> N >> M;

    count = N * (N - 1) / 2 + M * (M - 1) / 2;
    cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
    int n,p[20];
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> p[i]; 
    }
    int a=0;
    for(int j=1;j<n-1;j++){
        if(p[j]<p[j+1]){
            if(p[j]>p[j-1]){
                a++;
            }
        }
        else if(p[j]>p[j+1]){
            if(p[j]<p[j-1]){
                a++;
            }
        }
    }
    cout << a;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define vi vector<int>
#define vl vector<ll>
#define rep(a,n) for(int i=a;i<n;i++)
#define rep1(a,n) for(int i=a;i<=n;i++)
int main()
{
   int n;
   cin>>n;
   int k,p;
   vi v;
   for(int i=0;i<n;i++)
   {
       cin>>k;
       v.pb(k);
   }
   sort(v.begin(),v.end());
   p=n/2;
   cout<<v[p]-v[p-1]<<"\n";
    return 0;
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template <class T> using vec = vector<T>;
template <class T> using vvec = vector<vec<T>>;

bool chmax(ll& a,ll b){
    if(a<b){
        a = b;
        return true;
    }
    return false;
}

void check(ll res,vec<ll> A,vec<int> op){
    for(auto& x:op){
        assert(0<=x && x<A.size());
        if(x==0) A.erase(A.begin());
        else if(x==(int) A.size()-1) A.pop_back();
        else{
            A[x] = A[x-1]+A[x+1];
            A.erase(A.begin()+x+1);
            A.erase(A.begin()+x-1);
        }
    }
    assert(A.size()==1);
    assert(res==A[0]);
}

void print(ll ans,vec<int> op){
    cout << ans << "\n";
    cout << op.size() << "\n";
    for(auto& x:op) cout << x+1 << "\n"; 
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vec<ll> A(N);
    vec<ll> sum(2);
    vvec<int> pos(2);
    for(int i=0;i<N;i++){
        cin >> A[i];
        if(A[i]>0){
            sum[i%2] += A[i];
            pos[i%2].push_back(i);
        }
    }
    vec<ll> B = A;
    vec<int> op;
    if(pos[0].empty() && pos[1].empty()){
        int p = max_element(A.begin(),A.end())-A.begin();
        for(int i=N-1;i>p;i--) op.push_back(i);
        for(int i=0;i<p;i++) op.push_back(0);
        print(A[p],op);
        return 0;
    }

    vec<int> left;
    ll ans = 0;
    int sign = 0;
    if(sum[0]<sum[1]){
        ans = sum[1];
        left = pos[1];
        sign = 1;
    }else{
        ans = sum[0];
        left = pos[0];
    }
    int n = left.size();
    int l = left[0],r = left[n-1]+1;
    for(int i=N-1;i>=r;i--){
        op.push_back(i);
        A.pop_back();
    }
    for(int i=0;i<l;i++){
        op.push_back(0);
        A.erase(A.begin());
        sign ^= 1;
    }
    for(auto& x:left) x -= l;
    bool update = true;
    while(update){
        update = false;
        for(int i=(int) A.size()-2;i>0;i--) if(i%2==sign && A[i]<0){
            op.push_back(i);
            for(auto& x:left){
                if(x>i+1) x--;
                if(x>i-1) x--;
            }
            A[i] = A[i+1]-A[i-1];
            A.erase(A.begin()+i+1);
            A.erase(A.begin()+i-1);
            update = true;
            break;
        }
    }
    update = true;
    set<int> s;
    for(auto& x:left) s.insert(x);
    int now = 0;
    for(int i=1;i<A.size();i+=2){
        op.push_back(i-now);
        now += 2;
    }
    check(ans,B,op);
    print(ans,op);

}


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


void solve(std::vector<long long> A){
    if(A[0] + A[1] + A[2] <= 21){
        cout << "win" << endl;
        return;
    }
    cout << "bust" << endl;

}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    std::vector<long long> A(3);
    for(int i = 0 ; i < 3 ; i++){
        scanf("%lld",&A[i]);
    }
    solve(std::move(A));
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
	int a,b,c;
	int s,bs;
	c=0;
	s=0;
	bs=0;
	while(scanf("%d,%d",&a,&b)!=EOF){
		s=s+a*b;
		bs=bs+b;
		c++;
	}
	printf("%d\n",s);
	printf("%.0f\n",(float)bs/(float)c+0.5);
	return 0;
}

Measured memory_bytes: 628
#include<cstdio>
#include<string>
#include<cstring>
#include<utility>
#include<cmath>
#include<map>
#include<queue>
#include<set>
#include<algorithm>
#include<vector>
#include<iostream>
#define ll long long
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define inf 0x7fffffff
using namespace std;
int main()
{
	int i,j,k,n,m,x,y;
	string s;
	cin>>s;
	sort(s.begin(),s.end());
	if(s[0]==s[1]&&s[1]!=s[2]&&s[2]==s[3])
	{
		printf("Yes");
	}
	else
	{
		printf("No");
	}
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"math"
	"math/rand"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func Scanner() string {
	sc.Scan()
	return sc.Text()
}

func intScanner() int {
	n, _ := strconv.Atoi(Scanner())
	return n
}

func floatScanner() float64 {
	n, _ := strconv.ParseFloat(Scanner(), 64)
	return n
}
func stringToInt(s string) int {
	n, _ := strconv.Atoi(s)
	return n
}
func stringSliceScanner(n int) []string {
	a := make([]string, n)
	for i := 0; i < n; i++ {
		a[i] = Scanner()
	}
	return a
}
func intSliceScanner(n int) []int {
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = intScanner()
	}
	return a
}
func larger(a, b int) int {
	if a < b {
		return b
	} else {
		return a
	}
}
func smaller(a, b int) int {
	if a > b {
		return b
	} else {
		return a
	}
}
func max(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x < a[i] {
			x = a[i]
		}
	}
	return x
}
func min(a []int) int {
	x := a[0]
	for i := 0; i < len(a); i++ {
		if x > a[i] {
			x = a[i]
		}
	}
	return x
}
func abs(x int) int {
	if x < 0 {
		x = -x
	}
	return x
}

var mod int
var t float64

func main() {
	mod = 1000000007
	buf := make([]byte, 0)
	sc.Buffer(buf, mod)
	sc.Split(bufio.ScanWords)
	d := intScanner()
	c := intSliceScanner(26)
	s := make([][]int, d)
	for i := 0; i < d; i++ {
		s[i] = intSliceScanner(26)
	}
	best := -mod
	bestSchedule := make([]int, d)
	changeNum := 100
	for x := 0; x < 1; x++ {
		schedule := make([]int, d)
		for i := 0; i < d; i++ {
			schedule[i] = rand.Intn(26)
		}
		score := calcScore(schedule, c, s, d)
		t = float64(score) * 1.
		for y := 0; y < 150000; y++ {
			changes := make([]int, changeNum)
			pres := make([]int, changeNum)
			for i := 0; i < changeNum; i++ {
				changes[i] = rand.Intn(d)
				pres[i] = schedule[changes[i]]
				schedule[changes[i]] = rand.Intn(26)
			}
			nextScore := calcScore(schedule, c, s, d)
			if prob(score, nextScore) >= math.Abs(rand.Float64()) {
				score = nextScore
			} else {
				for i := 0; i < changeNum; i++ {
					schedule[changes[i]] = pres[i]
				}
			}
			if nextScore >= best {
				best = nextScore
				copy(bestSchedule, schedule)
			}
			t *= 0.999
			if (y+1)%200 == 0 && changeNum > 1 {
				changeNum--
			}
		}
	}
	for i := 0; i < d; i++ {
		fmt.Println(bestSchedule[i] + 1)
	}
}
func calcScore(schedule []int, c []int, s [][]int, d int) int {
	score := 0
	last := make([]int, 26)
	for i, v := range schedule {
		score += s[i][v]
		for j, _ := range last {
			last[j]++
		}
		last[v] = 0
		for j, v := range last {
			score -= c[j] * v
		}
	}
	return score
}
func prob(before int, after int) float64 {
	if before <= after {
		return 1.0
	}
	return math.Exp((float64(after) - float64(before)) / float64(t))
}


Measured memory_bytes: 6864
import java.util.Scanner;

public class Main{

    public static void main(String []args){
        Scanner sc = new Scanner(System.in);
        int a=0;
        int b=0;
        int c=0;
        int d=0;
        int score=0;
        a=sc.nextInt();
        b=sc.nextInt();
        c=sc.nextInt();
        d=sc.nextInt();

        if(d-a-b<=0){
            if(a>=d){
                score=d;
            }else {
                score = a*1+b*0;
            }
        }else{
            int temp=d;
            int tscore=a*1+b*0;
             temp=d-a-b;
            score=tscore+temp*-1;








        }




        System.out.print(score);



    }

}


Measured memory_bytes: 35716
#include <iostream>
#include <vector>
#include <string>
#include <list>
#include <queue>
#include <cmath>
#include <algorithm>
#define rep(i, n) for(i = 0; i < (n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define MOD 1000000007
#define PI 3.14159265358979323846
#define INF 1 << 30

using namespace std;
typedef long long ll;
typedef pair<int, int> pp;

int Search(vector<double> & d, const int k, double l, double r) {
	if (ceil(l) == ceil(r))
		return ceil(l);
	int i, a = 0;
	double p = (l + r) / 2.0;
	rep(i, d.size()) {
		a += ceil(d[i] / p) - 1;
	}
	if (a <= k)
		return Search(d, k, l, p);
	else
		return Search(d, k, p, r);
}

int main(void) {
	int num, i, k;
	cin >> num >> k;
	vector<double> d(num);
	rep(i, num)
		cin >> d[i];
	cout << Search(d, k, 0.0, 1e10) << "\n";
	return 0;
}

Measured memory_bytes: 4748
N = int(input())
u = [[0 for i in range(3)] for j in range(N)]
for i in range(N):
    u[i] = [int(j) for j in input().split()]

dp = [[0 for i in range(3)] for j in range(N)]
dp[0] = [u[0][0], u[0][1], u[0][2]]

for i in range(1, N):
    dp[i][0] = u[i][0] + max(dp[i - 1][1], dp[i - 1][2])
    dp[i][1] = u[i][1] + max(dp[i - 1][0], dp[i - 1][2])
    dp[i][2] = u[i][2] + max(dp[i - 1][0], dp[i - 1][1])

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


Measured memory_bytes: 45684
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
/* constant */
const int INF = 1 << 30;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
struct mint {
    ll x;
    mint(ll x = 0):x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const {
        return pow(mod - 2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res /= a;
    }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
struct combination {
    // vector size : n + 1
    vector<mint> fact, ifact;
    // precaliculation O(n)
    combination(int n):fact(n+1), ifact(n+1) {
        assert(n < mod);
        // 0! = 1;
        fact[0] = 1;
        // 1! = 0! * 1 ... n! = (n-1)! * n
        for (int i = 1; i <= n; i++) fact[i] = fact[i-1] * i;
        // 1/n! = n!^(-1)
        ifact[n] = fact[n].inv();
        // (n-1)!^(-1) = n!^(-1) * n ... 0!^(-1) = 1!^(-1) * 1
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i] * i;
    }
    // combination O(1)
    // nCk = n! / (k! * (n-k)!)
    //     = n! * k!^(-1) * (n-k)!^(-1)
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n] * ifact[k] * ifact[n-k];
    }
};
/* global variables */
/* function */
/* main */
int main() {
    int n, k;
    cin >> n >> k;
    if (n < k) {
        cout << 0 << '\n';
        return 0;
    }
    mint ans = 1;
    combination c = combination(1000);
    ans = c(n - 1, k - 1);
    cout << ans << '\n';
}


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

int main() {
	string s;
	cin >> s;
	int a,b,c;
	a = stoi(s.substr(0,4));
	b = stoi(s.substr(5,2));
	c = stoi(s.substr(8,2));
	if(a>=2019&&b>=5) {
		cout << "TBD" << endl;
	}else {
		cout << "Heisei" << endl;
	}
	return 0;
}


Measured memory_bytes: 256