akhauriyash/Code-Regression huggingface dataset:
import java.lang.reflect.Array;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;
import java.util.TreeSet;


public class Main {
	static int N, M;
	static Integer[] TX, TY;
	static Integer[][] ZX, ZY;
			
	static private void solve()
	{
		TreeSet<Integer> tsx = new TreeSet<Integer>();
		TreeSet<Integer> tsy = new TreeSet<Integer>();
		for (int i = 0; i < N; i++) {
			tsx.add(TX[i]);
			tsy.add(TY[i]);
		}
		ArrayList<Integer> alx = new ArrayList<Integer>(tsx);
		ArrayList<Integer> aly = new ArrayList<Integer>(tsy);
		int tsw = tsx.size();
		int tsh = tsy.size();
		Object[] alxobj = alx.toArray();
		Object[] alyobj = aly.toArray();
		
		int[][] treasure = new int[tsy.size() + 1][tsx.size() + 1];
		for (int y = 0; y < tsh+1; y++) {
			for (int x = 0; x < tsw+1; x++) {
				treasure[y][x] = 0;
			}
		}
		for (int i = 0; i < N; i++) {
			int x = alx.indexOf(TX[i]);
			int y = aly.indexOf(TY[i]);
			treasure[y + 1][x + 1]++;
		}
		
		for (int y = 1; y <= tsh; y++) {
			for (int x = 1; x <= tsw; x++) {
				treasure[y][x] += treasure[y-1][x] + treasure[y][x-1] - treasure[y-1][x-1];
			}
		}
		
		
		
		for (int i = 0; i < M; i++) {
			Integer xx1 = tsx.ceiling(ZX[i][0]);
			Integer xx2 = tsx.floor(ZX[i][1]);
			Integer yy1 = tsy.ceiling(ZY[i][0]);
			Integer yy2 = tsy.floor(ZY[i][1]);
			
			if( xx1 == null || xx2 == null || yy1 == null || yy2 == null )
			{
				System.out.println("0");
				continue;
			}
			
			int x1 = Arrays.binarySearch(alxobj, xx1);
			int x2 = Arrays.binarySearch(alxobj, xx2) + 1;
			int y1 = Arrays.binarySearch(alyobj, yy1);
			int y2 = Arrays.binarySearch(alyobj, yy2) + 1;
			
			/*int x1 = alx.indexOf(xx1);
			int x2 = alx.indexOf(xx2) + 1;
			int y1 = aly.indexOf(yy1);
			int y2 = aly.indexOf(yy2) + 1;*/
			
			int ret = treasure[y2][x2] - treasure[y2][x1] - treasure[y1][x2] + treasure[y1][x1];
			System.out.println(ret);
		}
	}
	
	static public void main(String[] args)
	{
		Scanner sca = new Scanner(System.in);
		
		while(true)
		{
			N = sca.nextInt();
			M = sca.nextInt();
			
			TX = new Integer[N];
			TY = new Integer[N];
			for (int i = 0; i < N; i++) {
				TX[i] = new Integer(sca.nextInt());
				TY[i] = new Integer(sca.nextInt());
			}
			
			ZX = new Integer[M][2];
			ZY = new Integer[M][2];
			for (int i = 0; i < M; i++) {
				ZX[i][0] = new Integer(sca.nextInt());
				ZY[i][0] = new Integer(sca.nextInt());
				ZX[i][1] = new Integer(sca.nextInt());
				ZY[i][1] = new Integer(sca.nextInt());
			}
			
			solve();
			
			break;
		}
	}
}

Measured memory_bytes: 627748
// 2020-09-08 22:44:12
// clang-format off
#include<bits/stdc++.h>
#ifdef LOCAL
#include "lib/debug.hpp"
#else
#define debug(...) 1
#endif
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define rep(i, n) REP(i, 0, (n))
#define repc(i, n) REPC(i, 0, (n))
#define REP(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define REPC(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define REPCM(i, n, m) for (int i = (int)(n); i >= (int)(m); i--)
using namespace std;
using ll = long long;
using ld = long double;
using pr = pair<ll, ll>;
using vll = vector<ll>;
using vpr = vector<pr>;
using P = pair<int, int>;
template<class T> inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } else return false; }
template<class T> inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } else return false; }

// clang-format on
void answer() {
  int n;
  ll w;
  cin >> n >> w;
  vector<deque<ll> > a(4);
  ll w1;
  {
    ll v1;
    cin >> w1 >> v1;
    a[0].push_back(v1);
    rep(i, n - 1) {
      ll w2, v2;
      cin >> w2 >> v2;
      a[w2 - w1].push_back(v2);
    }
  }
  rep(i, 4) {
    sort(RALL(a[i]));
    rep(j, a[i].size() - 1) a[i][j + 1] += a[i][j];
    a[i].push_front(0);
  }
  auto calc_w = [&](int i, int j, int k, int l) {
    ll res = 0;
    res += i * (w1 + 0);
    res += j * (w1 + 1);
    res += k * (w1 + 2);
    res += l * (w1 + 3);
    return res;
  };
  ll ans = 0;
  repc(i, a[0].size()) {
    repc(j, a[1].size()) {
      repc(k, a[2].size()) {
        repc(l, a[3].size()) {
          if (calc_w(i, j, k, l) <= w) {
            chmax(ans, a[0][i] + a[1][j] + a[2][k] + a[3][l]);
          }
        }
      }
    }
  }
  cout << ans << '\n';
}
int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  answer();
  return 0;
}

Measured memory_bytes: 3668
#include<bits/stdc++.h>
#define F(i,a,b) for(int i=(a);i<=(b);++i)
#define F2(i,a,b) for(int i=(a);i<(b);++i)
#define dF(i,a,b) for(int i=(a);i>=(b);--i)
#define dF2(i,a,b) for(int i=(a);i>(b);--i)
#define dF3(i,a,b) for(int i=(a)-1;i>=(b);--i)
using namespace std;typedef long long ll;typedef double ld;int INF=0x3f3f3f3f;int INF2=0x7fffffff;ll LNF=0x3f3f3f3f3f3f3f3f;ll LNF2=0x7fffffffffffffff;

int n,k,q,Ans=INF;
int a[2001],p[2001],v[2001];
bool cmp(int i,int j){return a[i]<a[j];}
int siz[2001],bel[2001];
int check(){
	int S=0;
	F(i,1,n) bel[i]=0;
	F(i,1,n){
		if(!v[i]){
			if(v[i-1]) ++S, siz[S]=1;
			else ++siz[S];
			bel[i]=S;
		}
	}
	int cnt=0;
	int Amn=INF, Amx=-INF;
	F(i,1,n) if(!v[p[i]]){
		int pos=p[i];
		if(siz[bel[pos]]>=k) Amn=min(Amn,a[pos]), Amx=max(Amx,a[pos]), --siz[bel[pos]], ++cnt;
		if(cnt==q) break;
	}
	if(cnt!=q) return INF;
	else return Amx-Amn;
}
int main(){
	scanf("%d%d%d",&n,&k,&q);
	F(i,1,n) scanf("%d",a+i), p[i]=i;
	sort(p+1,p+n+1,cmp);
	v[0]=1;
	Ans=check();
	F(i,1,n){
		v[p[i]]=1;
		Ans=min(Ans,check());
	} printf("%d",Ans);
	return 0;
}

Measured memory_bytes: 256
def divisor(a, b, k):
    num = min(a, b)
    stack = []
    for i in range(num, 0, -1):
        if a%i==b%i==0:
            stack.append(i)
        if len(stack) == k:
            return stack[-1]
a, b, k = map(int, input().split())
print(divisor(a, b, k))

Measured memory_bytes: 3060
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<set>
#include<vector>
using namespace std;

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

  vector<int> s;
  s.push_back(a);
  s.push_back(b);
  s.push_back(c);
  sort(s.begin(),s.end());
  if(s.at(0)+s.at(1)==s.at(2)||s.at(0)==s.at(1)+s.at(2)){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}

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

using namespace std;

#define endl '\n';

int main () {
 ios::sync_with_stdio(0);
  
  int r, d;
  long int val;
  vector <long int> ans;
  cin >> r >> d >> val;
  for (int i = 0; i < 10; ++i) {
    val  = r*val - d;
    ans.push_back(val);
  }
  sort(ans.begin(), ans.end());
  for (auto i : ans) {
    cout << i << endl;
  }
}   

Measured memory_bytes: 256
// Aizu Vol0 0040: Affine Cipher
// 2017.7.31

#include <stdio.h>
#include <ctype.h>
#include <string.h>
#include <stdlib.h>

char *gets(char *);

#define M 26
#define MAX 700

#define EN(alpha, beta, a) ((alpha*a+beta) % M)

int key[MAX];
short half[2][26][26];

char buf[500 + 5], *p, *w;

int AT[] = { 1, 3, 5, 7, 9, 11, 15, 17, 19, 21, 23, 25, 0 };
char TR[M + 5];

int main()
{
	int i, n;
	int a, b, t, h;
	int di, dd;    // for dataset

	t = 't'-'a', h = 'h'-'a';		// th
	for (i = 0; AT[i]; i++) {
		a = AT[i];
		for (b = 0; b < M; b++) {
			n = EN(a, b, t) * M + EN(a, b, h);
			if (key[n] > 0) while (1);
			key[n] = a * M + b;
		}
	}

	t = 'i'-'a', h ='s'-'a';		// th-is
	for (i = 0; AT[i]; i++) {
		a = AT[i];
		for (b = 0; b < M; b++) {
			n = EN(a, b, t) * M + EN(a, b, h);
			half[0][a][b] = n;
		}
	}
	t = 'a'-'a', h = 't'-'a';		// th-at
	for (i = 0; AT[i]; i++) {
		a = AT[i];
		for (b = 0; b < M; b++) {
			n = EN(a, b, t) * M + EN(a, b, h);
			half[1][a][b] = n;
		}
	}

	gets(buf);
	dd = atoi(buf);
	for (di = 0; di < dd; di++) {
		gets(p = buf);
		while (*p) {
			while (*p && !isalpha(*p)) p++;
			if (!*p) while (1);
			w = p;
			while (isalpha(*p)) p++;
			if (p - w == 4) {
				i = *w++ - 'a'; i = i * M + (*w++ - 'a');
				if (key[i] > 0) {
					a = key[i] / M, b = key[i] % M;
					n = *w++ - 'a'; n = n * M + (*w - 'a');
					if (half[0][a][b] == n || half[1][a][b] == n) break;
				}
			}
		}

		for (i = 0; i < M; i++) TR[EN(a, b, i)] = i+'a';

		p = buf;
		while (*p) {
			while (*p && !isalpha(*p)) putchar(*p++);
			if (!*p) break;
			while (isalpha(*p)) putchar(TR[*p++ - 'a']);
		}
		putchar('\n');
	}
	return 0;
}

Measured memory_bytes: 524
#include<iostream>
using namespace std;
int main(){
    int H,W; //H=縦  W =横
    
    while(1){
        cin >> H >> W;
        if(H == 0 && W == 0) break;
        
        for(int i = 0; i < H; i++){  //縦
            
            for (int j = 0; j < W; j ++){  // j = 0 ~ 5
                
                if((i == 0) || (i == H-1) || (j == 0) || (j == W-1)) cout << "#";
                else cout << ".";
                
            }   
            
            cout << endl;
            
        }
        cout << endl;
    }
    
    return 0;
}


Measured memory_bytes: 3080
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
var n=Arr.shift()-0;
for(var I=0;I<n;I++){
   var arr=Arr.shift().split("").reverse();
   var str=Arr.shift();
   var x=str.length;
   arr.forEach(function(v){
      if(v=="J")str=str.slice(-1)+str.slice(0,-1);
      else if(v=="C")str=str.slice(1)+str.slice(0,1);
      else if(v=="E" && x%2==0)str=str.slice(x/2,x)+str.slice(0,x/2);
      else if(v=="E" && x%2==1)str=str.slice(~~(x/2)+1,x)+str[~~(x/2)]+str.slice(0,~~(x/2));
      else if(v=="A")str=str.split("").reverse().join("");
      else if(v=="P")str=str.replace(/\d/g,function(s){return (s=="0")?"9":(s-0)-1;});
      else if(v=="M")str=str.replace(/\d/g,function(s){return (s=="9")?"0":(s-0)+1;});
   });
   console.log(str);
}

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

#define fst first
#define snd second
#define fore(i,a,b) for(int i=a, ThxDem=b; i<ThxDem; ++i)
#define pb push_back
#define ALL(s) s.begin(),s.end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define SZ(s) int(s.size())
#define DBG(x) cerr <<#x << " = " << (x) << "\n"

#define SQR(x) ((x) * (x))

#define PI 3.1415926535897932385
#define INF 1000111222
#define eps 1e-7
#define maxN 11

using namespace std;

typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef vector<string> vstr;
typedef vector<vll> vvll;
typedef vector<bool> vbool;
typedef vector<pll> vpll;
typedef vector<vpll> vvpll;
typedef vector<vbool> vvbool;

ll gcd (ll a, ll b) {
	while (b) {
        	a %= b;
        	swap(a, b);
    	}
    	return a;
}

int main(){FIN
	ll A,B,v;
	set<ll> d;
	vll ans;
	bool ver;

	cin >> A >> B;
	
	v = gcd(A,B);
	
	fore(i,1,sqrt(v)+1){
		if((v%i) == 0){
			d.insert(i);
			d.insert(v/i);
		}
	}

	for(ll x:d){

		ver=1;
		fore(j,1,SZ(ans)){
			if(x%ans[j]==0){
				ver=0;
				break;
			}
		}
		if(ver) ans.pb(x);
	}

	cout << SZ(ans) << "\n";
	return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
using namespace std;
 
int P, Q, R;
const char *p;
 
int formula() {
   
  p++;
 
  switch( *p ) {
  case '-': return 2 - formula();
  case 'P': return P;
  case 'Q': return Q;
  case 'R': return R;
  case '0': return 0;
  case '1': return 1;
  case '2': return 2;
     
  case '(':
    int form1 = formula();
    int form2;
    p++;
    switch( *p ) {
    case '*':
      form2 = formula();
      p ++;
      return min( form1, form2 );
    case '+':
      form2 = formula();
      p++;
      return max( form1, form2 );
    }
  }
   
  return 0;
}
 
int main() {
  string str;
   
  while(getline(cin, str)) {
    int cnt = 0;
    if( str == "." ) break;
    for(int i=0; i<3; i++) {
      for(int j=0; j<3; j++) {
    for(int k=0; k<3; k++) {
      P = i, Q = j, R = k;
      p = &str[0]-1;
      if( formula() == 2 ) cnt ++;
    }
      }
    }
     
    cout << cnt << endl;
  }
   
  return 0;
}

Measured memory_bytes: 1184
#include <bits/stdc++.h>
using namespace std;
#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 all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
#define Yes "Yes"
#define No "No"
#define YES "YES"
#define NO "NO"
typedef long long ll;

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 int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/
struct mint {
    long long x;
    mint(long long _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 modpow(long long t) const {
        if (!t) return 1;
        mint a = modpow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return modpow(MOD-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};
struct combination {
    vector<mint> fact, ifact;
    //constructor(initiation)
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < MOD);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint Comb(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
    mint H(int n, int m){
        return Comb(n + m, m);
    }
};

combination Comb(1e7);

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

    int N,M,K;
    cin>>N>>M>>K;
    mint ans = 0;
     //x座標の差がkになる場合の数
     rep1(d,N){
         ans += mint(d) * mint(N-d) * mint(M) * mint(M) * Comb.Comb(N*M-2, K-2);
     }
     //y座標の差がkになる場合の数
     rep1(d,M){
         ans += mint(d) * mint(M-d) * mint(N) * mint(N) * Comb.Comb(N*M-2, K-2);
     }
     cout<<ans.x<<endl;
}

Measured memory_bytes: 156544
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << x << endl

using ld = double;
using P = complex<ld>;
using G = vector<P>;
const ld pi = acos(-1);
const ld eps = 1e-10;
const ld inf = 1e12;

ld cross(const P &a, const P &b) {
  return a.real() * b.imag() - a.imag() * b.real();
}
ld dot(const P &a, const P &b) {
  return a.real() * b.real() + a.imag() * b.imag();
}

using C = pair<ld, P>;
#define rad first
#define pnt second

C smallest_enclosing_disc(vector<P> ps) {
  auto c3 = [](const P &a, const P &b, const P &c) {
    ld A = norm(b - c);
    ld B = norm(c - a);
    ld C = norm(a - b);
    ld S = abs(cross(b - a, c - a));
    P p = (A * (B + C - A) * a + B * (C + A - B) * b + C * (A + B - C) * c) /
          (4 * S * S);
    ld r = abs(p - a);
    return make_pair(r, p);
  };

  auto c2 = [](const P &a, const P &b) {
    P c = (a + b) / (ld)2;
    ld r = abs(a - c);
    return make_pair(r, c);
  };

  auto in_circle = [](const P &a, const C &c) {
    return norm(a - c.pnt) <= c.rad * c.rad + eps;
  };

  int n = ps.size();
  random_shuffle(ps.begin(), ps.end());
  C c = c2(ps[0], ps[1]);
  for (int i = 2; i < n; ++i) {
    if (!in_circle(ps[i], c)) {
      c = c2(ps[0], ps[i]);
      for (int j = 1; j < i; ++j) {
        if (!in_circle(ps[j], c)) {
          c = c2(ps[j], ps[i]);
          for (int k = 0; k < j; ++k) {
            if (!in_circle(ps[k], c)) {
              c = c3(ps[i], ps[j], ps[k]);
            }
          }
        }
      }
    }
  }
  return c;
}

// http://www.spoj.com/problems/QCJ4/
// http://www.spoj.com/status/ns=18116289

int main() {
  srand(time(0));
  int n;
  cin >> n;
  vector<P> ps(n);
  for (int i = 0; i < n; ++i) {
    ld x, y;
    cin >> x >> y;
    ps[i] = P(x, y);
  }

  printf("%.15lf\n", (double)smallest_enclosing_disc(ps).rad);
}


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

using namespace std;

int n,k;
int sc[3];
string s;
string arr[100005];
int mem[100005][4];

int getop(char x)
{
	// r s p
	if(x=='r')
		return 2;
	if(x=='s')
		return 0;
	return 1;
}

int ii;

int go(int ind,int prv)
{
	if(ind>=arr[ii].size()) return 0;
	int &ret=mem[ind][prv];
	if(ret!=-1) return ret;
	ret=0;
	for(int i=0;i<3;i++)
	{
		if(i==prv) continue;
		ret=max(ret,(i==getop(arr[ii][ind]))*sc[i]+go(ind+1,i));
	}
	return ret;
}

int main()
{
	cin >> n >> k;
	for(int i=0;i<3;i++) cin >> sc[i];
	cin >> s;
	int ans=0;
	for(int i=0;i<k;i++)
	{
		for(int j=i;j<n;j+=k)
			arr[i]+=s[j];
	}
	for(int i=0;i<k;i++)
	{
		ii=i;
		for(int j=0;j<=arr[i].size();j++)
			for(int k=0;k<4;k++)
				mem[j][k]=-1;
		ans+=go(0,3);
	}
	cout << ans << endl;
}

Measured memory_bytes: 10624
#include <iostream>
#include <stdio.h>
using namespace std;

int main() {
    int a,b,d,r;
    cin>>a;
    cin>>b;
    d=a/b;
    r=a%b;
    double f=(double)a/double(b);
    printf("%d %d %lf\n",d,r,f);

    return 0;
}


Measured memory_bytes: 3228
<?php
$n=trim(fgets(STDIN));
$i=0;
$ans=0;
while($i<$n){
  list($a,$b)=explode(" ",trim(fgets(STDIN)));
  if($a==$b){
    ++$ans;
    if($ans==3){
      echo "Yes";
      exit;
    }
  }else{
    $ans=0;
  }
  ++$i;
}
echo "No";

Measured memory_bytes: 16172
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
typedef long long ll;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int L;
    cin >> L;
    int r = 0;
    while((1 << r + 1) <= L)
        r++;
    int N = r + 1, M = 0;
    using pll = pair<ll, ll>;
    vector<vector<pll>> G(N);

    rep(i, r) {
        G[i].push_back(MP(i + 1, 0));
        G[i].push_back(MP(i + 1, 1 << i));
        M += 2;
    }
    L -= (1 << r);
    ll cost = 1 << r;
    for(int i = r - 1; i >= 0; i--) {
        if(L >= (1 << i)) {
            L -= (1 << i);
            G[i].push_back(MP(N - 1, cost));
            cost += (1 << i);
            M++;
        }
    }
    cout << N << " " << M << endl;
    rep(i, N - 1) {
        for(pll p : G[i]) {
            cout << i + 1 << " " << p.first + 1 << " " << p.second << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int n;
    cin>>n;
    int sum=0;
    for(int i=1;i<=n;++i){
        for(int j=1;j<=n;++j){
            for(int k=1;k<=n;++k){
                int x=__gcd(i,j);
                int y=__gcd(x,k);
                int z=__gcd(x,y);
                sum+=z;
            }
        }
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 3668
def main():
    W, H, N = map(int, input().split())
    white = [[1]*H for _ in range(W)]
    for _ in range(N):
        x, y, a = map(int, input().split())
        xr = range(W)
        yr = range(H)
        if a == 1:
            xr = range(x)
        elif a == 2:
            xr = range(x, W)
        elif a == 3:
            yr = range(y)
        else:
            yr = range(y, H)
        for i in xr:
            for j in yr:
                white[i][j] = 0
    print(sum([sum(x) for x in white]))


if __name__ == "__main__":
    main()


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

/*

 * */

int main() {
    string S; cin >> S;

    string ans;
    if(S <= "2019/04/30"){
        ans = "Heisei";
    }else{
        ans = "TBD";
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
N=int(input())
T,A=map(int, input().split())
H=list(map(int, input().split()))
ls=[]
for i in range(N):
    ls.append((i+1,abs(A-(T-H[i]*0.006))))
ls0=list(sorted(ls, key=lambda x :x[1]))
print(ls0[0][0])


Measured memory_bytes: 3188
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<iterator>
#include<cmath>
#include<string>
#include<algorithm>
#include<sstream>
#include<queue>
#include<list>
#include<deque>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<chrono>
#include<iomanip>

/*  auto start = high_resolution_clock::now();
auto stop = high_resolution_clock::now();
auto duration = duration_cast<milliseconds>(stop - start);
pr(duration.count());    */

#define FastIO      ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define pb          push_back
#define siz         100009
#define mp          make_pair
#define ll          long long int
#define fileout     freopen("output.txt","w",stdout)
#define filein      freopen("input.txt","r",stdin)
#define pi          acos(-1.0)
#define all(x)      x.begin(),x.end()
#define ull		    unsigned long long int
#define m(a)	    memset(a,0,sizeof(a))
#define f(i,n)	    for(ll i=0;i<n;i++)
#define sc(a)	    scanf("%lld",&a)
#define pr(a)	    printf("%lld\n",a)
#define vll         vector<ll>
#define sll         set<ll>
const ll inf = 1000000007;
ll in = 1000000000000000000;
using namespace std;
//#pragma GCC optimize("Ofast")
//#pragma GCC target("avx,avx2,fma")
//#pragma GCC optimization ("unroll-loops")
int main()
{
    FastIO;
    ll a,b,c,d,i,j,k,l,m,n,t;
    string s;
    cin>>s;
    ll dp[100008][14];
    m(dp);
    if(s[0]=='?')
    {
        f(i,10)
        {
            dp[1][i]=1;
        }
    }
    else
    {
        a=(ll)(s[0]-'0');
        dp[1][a]=1;
    }
    n=s.size();
    for(i=2;i<=n;i++)
    {
        f(j,13)
        {
            if(s[i-1]=='?')
            {
                f(k,10)
                {
                    dp[i][(j*10+k)%13]+=dp[i-1][j];
                    dp[i][(j*10+k)%13]%=inf;
                }
            }
            else
            {
                a=(ll)(s[i-1]-'0');
                dp[i][(j*10+a)%13]+=dp[i-1][j];
                dp[i][(j*10+k)%13]%=inf;
            }
        }

    }
    cout<<dp[n][5]<<endl;
    return 0;
}


Measured memory_bytes: 14688
#include <stdio.h>
#include <string>
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;

int main(void){
    int a,b;
    cin >> a >> b;
    string ans;
    if(a*b%2==0)ans="No";
    else ans="Yes";
    cout << ans << endl;
    return 0;
}

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

int main() {
	string S;
	cin >> S;
	long long ans = 0;
	for (int i = 0;i<(1<<S.size()-1);++i) {
		long long tmp = S[0] - '0';
		for (int j = 0;j<(S.size()-1);++j) {
			if (1&(i>>j)) {
				ans += tmp;
				tmp = 0;
			}
			tmp *= 10;
			tmp += S[j+1] - '0';

		}
		ans += tmp;
	}
	cout << ans << endl;
	return 0;
}


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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#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 FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int mod = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  ll n;
  cin >> n;
  
  vector<ll> t(n), a(n);
  cin >> t[0] >> a[0];
  REP1(i, n){
    cin >> t[i] >> a[i];
    if(t[i] < t[i-1] || a[i] < a[i-1]){
      ll k = max(t[i-1]/t[i], a[i-1]/a[i]);
      if(k*t[i] < t[i-1] || k*a[i] < a[i-1])
        k++;
      t[i] *= k;
      a[i] *= k;
    }
  }
  
  cout << t[n-1]+a[n-1] << endl;
    
    
}

Measured memory_bytes: 256
import sys

s = list(map(str,input()))

if len(s)%2 == 1:
    print("No")
    sys.exit()

for i in range(len(s)):
    if i%2 == 0:
        if s[i] != "h":
            print("No")
            sys.exit()
    else:
        if s[i] != "i":
            print("No")
            sys.exit()

print("Yes")

Measured memory_bytes: 3060
while true
    

    n,x = gets.split.map{|i| i.to_i}
    if n==0 and x==0
        break
    end
    sum =0
    for i in 1..n-2
        for j in i+1..n-1
            for k in j+1..n

                if i+k+j==x
                    sum +=1
                end

            end
        end

    end

    puts sum

end


Measured memory_bytes: 6876
n,m=map(int,input().split())
a=[0]*(n+1)
b=[0]*(n+1)
flg=0
for i in range(m):
  p,q=map(int,input().split())
  if (p==1 and q==n) or (p==n and q==1):
    flg=1
  elif p==1:
    a[q]=1
  elif q==1:
    a[p]=1
  elif p==n:
    b[q]=1
  elif q==n:
    b[p]=1
for i in range(1,n+1):
  if a[i]==1 and b[i]==1:
    flg=1
if flg==1:
  print('POSSIBLE')
else:
  print('IMPOSSIBLE')

Measured memory_bytes: 6132
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <numeric>
#include <cstdint>
#include <iomanip>
#include <set>
#include <map>
#include <unordered_map>
#include <cassert>
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
#define fast_io(); std::ios_base::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0);

int main(){
    ll a, b, x;
    std::cin >> a >> b >> x;
    std::cout << ((a==0)?(b/x+1):(b/x-(a-1)/x)) << "\n";
    return 0;
}

Measured memory_bytes: 3620
_,*A = $<.read.split.map(&:to_i)
(p 0; exit) if A.include?(0)
x = A.inject(1){|z,a|
	z *= a
	1000000000000000000<z ? (break z) : (next z)
}
if 1000000000000000000<x
	p(-1)
else
	p x
end


Measured memory_bytes: 22420
#include <stdio.h>
#include <stdlib.h>

#include <iostream>
#include <iomanip>
#include <sstream>
#include <stdint.h>
#include <string.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>

#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1000000007ll;
const i64 smod = 998244353ll;
const i64 inf = 10000000000000007ll;

const double eps = 1e-10;

// del

const i64 MAXN = 300005;

double a, b, x;

double f(double alpha) {
    double beta = M_PI / 2 - alpha;

    double maxh = sin(beta) * b;
    double th = sin(alpha) * a;

    double S = 0;

    if (alpha < eps) {
        S = a * b;
    }
    else if (beta < eps) {
        S = 0;
    }
    else {
        if (th - maxh > eps) {
            S = (maxh / sin(beta)) * (maxh / sin(alpha)) / 2;
        }
        else {
            S = (th / sin(beta)) * (th / sin(alpha)) / 2;
            S += (th / tan(beta)) * (maxh - th);
            S += (th / tan(alpha)) * (maxh - th);
        }
    }


    return S;
}

bool g(double alpha) {
    return f(alpha) > x / a + eps;
}

double bin(double l, double r) {
    if (r - l < eps) {
        return (l + r) / 2;
    }
    double t = (r + l) / 2;
    if (g(t)) {
        return bin(t, r);
    }
    else {
        return bin(l, t);
    }
}

int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed);

    cin >> a >> b >> x;

    double R = bin(0, M_PI / 2);
    R = R / M_PI * 180;
    cout << R << endl;

    //for (double alpha = 0; alpha < M_PI / 2 + eps; alpha += M_PI / 2 / 10) {
    //    cerr << alpha / M_PI * 180 << ": "<< f(alpha) << endl;
    //}

    return 0;
}

Measured memory_bytes: 384
import java.util.*;
public class Main {
    static public Scanner read;
    static int a,b,n;
    public static void main(String[] args){
        read = new Scanner(System.in);
        a = read.nextInt();
        b = read.nextInt();
        n = a + b;
        if (b >= a)
            System.out.print("Impossible");
        else{
            String ans = "";
            int honest = getHonest();
            for (int i = 0; i < n; i++){
                ans += q(honest, i) ? '1' : '0';
            }
            System.out.print("! " + ans);
        }
    }

    static int getHonest() {
        int dis = b + 1 ;
        LinkedList<Integer> list = new LinkedList<>();
        for(int i = 0; i < n; i++) {
            if(list.isEmpty()) {
                list.push(i);
            }
            else {
                if(q(list.peek(), i)) {
                    list.push(i);
                }
                else {
                    list.pop();
                    dis--;
                }
            }
            if(list.size() >= dis)
                return list.pop();
        }
        return -1;
    }

    static boolean q(int a, int b){
        System.out.println("? " + a + " " + b);
        return read.next().equals("Y");
    }
}

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

int main()
{
    int N, M, Q;
    cin >> N >> M >> Q;
    vector<int> A(Q), B(Q), C(Q), D(Q);
    for (int i = 0; i < Q; i++)
    {
        cin >> A[i] >> B[i] >> C[i] >> D[i];
        A[i]--;
        B[i]--;
    }

    vector<vector<int> > V[11];
    for (int i = 1; i <= M; i++)
    {
        V[1].push_back({i});
    }

    for (int i = 1; i < N; i++)
    {
        for (auto &v : V[i])
        {
            int b = v.back();
            for (int a = b; a <= M; a++)
            {
                auto v2 = v;
                v2.push_back(a);
                V[i + 1].push_back(v2);
            }
        }
    }

    // for (int i = 0; i < 11; i++)
    // {
    //     for (int j = 0; j < V[i].size(); j++)
    //     {
    //         for (int k = 0; k < V[i][j].size(); k++)
    //         {
    //             cout << V[i][j][k] << " ";
    //         }
    //         cout << endl;
    //     }
    // }

    int ans = 0;
    for (auto &v : V[N])
    {
        int res = 0;
        for (int i = 0; i < Q; i++)
            if (v[B[i]] - v[A[i]] == C[i])
                res += D[i];
        ans = max(ans, res);
    }

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

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

using namespace std;
using ll = long long;

const int N = 100005;

char str[N];

int main() {
	scanf("%s", str);
	deque<char> d;
	for(int i = 0; str[i]; i++) {
		d.push_back(str[i]);
	}

	bool inv = false;
	int q;
	scanf("%d", &q);
	while(q--) {
		int t;
		scanf("%d", &t);
		if(t == 1) inv ^= 1;
		else {
			char c;
			scanf(" %d %c", &t, &c);
			t--;
			t ^= inv;
			if(t == 0) d.push_front(c);
			else d.push_back(c);
		}
	}

	if(!inv) {
		while(!d.empty()) {
			printf("%c", d.front());
			d.pop_front();
		}
	}
	else {
		while(!d.empty()) {
			printf("%c", d.back());
			d.pop_back();
		}
	}
	printf("\n");
}


Measured memory_bytes: 4092
N,M=map(int,input().split())
DP=[100]*(N+1)
DP[0]=1
DP[1]=1
for i in range(M):
	x=int(input())
	DP[x]=0
for i in range(2,N+1):
	if DP[i]!=0:
		if DP[i-1]==0:
			DP[i]=DP[i-2]
		if DP[i-2]==0:
			DP[i]=DP[i-1]
		else:
			DP[i]=DP[i-1]+DP[i-2]
	else:
		continue
print(DP[N]%(10**9+7))

Measured memory_bytes: 460020
#include<cstdio>
#include<iostream>
#include<algorithm>

using namespace std;

int main(void) {

	int n, a, b, p[100], x = 0, y = 0, z = 0;

	cin >> n >> a >> b;

	for (int k = 0; k < n; k++) {
		cin >> p[k];
		if (p[k] <= a)x++;
		else if (p[k] <= b)y++;
		else z++;
	}

	cout << min({ x, y, z }) << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
    ll p=998244353;
ll bin(ll x,ll po)
{
    ll ans=1;
    if(po==0)
    {
        return ans;
    }
    if(po%2==1)
    {
        po--;
        ans=x%p;
    }
    ll p1=bin(x,po/2);
    ans=ans*p1%p;
    ans=ans*p1%p;
    return ans;
}
int main() {
    ll n,m,k;
    cin>>n>>m>>k;
    ll ans=0;
    ll fact[200100];
    fact[0]=1;
    ll factinv[200100];
    factinv[0]=1;
    for(ll i=1;i<=200000;i++)
    {
        fact[i]=fact[i-1]*i%p;
        factinv[i]=factinv[i-1]*bin(i,p-2)%p;
    }
    //cout<<fact[n-1]<<endl;
    for(ll i=0;i<=k;i++)
    {
        //cout<<factinv[i]<<" "<<factinv[n-i-1]<<endl;
        ll val=(fact[n-1]*factinv[i]%p)*factinv[n-i-1]%p;
        //cout<<"val "<<val<<endl;
        val=val*bin(m-1,n-i-1)%p;
        val=val*m%p;
        //cout<<val<<endl;
        ans=(ans+val)%p;
    }
    cout<<ans;
}

Measured memory_bytes: 6760
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
// typedef long  l;
typedef pair<int,int> P;
const ll INF=100000000000000001;
const double PI=3.141592653589;

int gcd(int a,int b){
  if(a<b)swap(a,b);
  int c=a%b;
  while(c!=0){
    a=b;
    b=c;
    c=a%b;
  }
  return b;
}

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

  int aa=a[0];
  for(int i=1;i<n;i++){
    aa=gcd(aa,a[i]);
  }
  cout<<aa<<endl;

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
int main()
{
    int a, b;
    cin >> a >> b;
  
  	int ans;
  	if(a+b % 2){
		ans = (a + b + 1) / 2;
    }
 	else{
		ans = (a + b) / 2;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
from collections import deque


class UnionFindWeighted:
    """ポテンシャル付きUnionFind"""
    def __init__(self, n):
        self.parent = [-1] * n
        self.weight = [0] * n
        self.cnt = n
        self.INF = 10 ** 18

    def root(self, x):
        """頂点xの根を求める"""
        if self.parent[x] < 0:
            return x
        rt = self.root(self.parent[x])
        self.weight[x] += self.weight[self.parent[x]]
        self.parent[x] = rt
        return rt

    def merge(self, x, y, weight):
        """頂点xを含む集合と頂点y含む集合を結合する
        weight: 頂点yに対する頂点xのポテンシャル(頂点xの方がweight高い)
        """
        root_x = self.root(x)
        root_y = self.root(y)
        if root_x == root_y:
            return
        if self.parent[root_x] < self.parent[root_y]:
            self.parent[root_x] += self.parent[root_y]
            self.parent[root_y] = root_x
            self.weight[root_y] = -weight + self.weight[x] - self.weight[y]
        else:
            self.parent[root_y] += self.parent[root_x]
            self.parent[root_x] = root_y
            self.weight[root_x] = weight - self.weight[x] + self.weight[y]
        self.cnt -= 1

    def is_same(self, x, y):
        """頂点x, yが同じ集合に属するかどうかを返す"""
        return self.root(x) == self.root(y)

    def diff(self, x, y):
        """頂点yに対する頂点xのポテンシャルを求める
        ただし、頂点x,y間にポテンシャルが定義されていない場合は INF を返す
        """
        if not self.is_same(x, y):
            return self.INF
        return self.weight[x] - self.weight[y]

    def get_size(self, x):
        """頂点xを含む集合の要素数を返す"""
        return -self.parent[self.root(x)]

    def get_cnt(self):
        """集合の個数を返す"""
        return self.cnt


n = int(input())
info = [list(map(int, input().split())) for i in range(n - 1)]
qq, k = map(int, input().split())
query = [list(map(int, input().split())) for i in range(qq)]
k -= 1

tree = [[] for i in range(n)]
for a, b, cost in info:
    a -= 1
    b -= 1
    tree[a].append((b, cost))
    tree[b].append((a, cost))

uf = UnionFindWeighted(n)
root = k
par = {root: -1}
q = deque([root])
while q:
    v = q.pop()
    for nxt_v, cost in tree[v]:
        if nxt_v in par:
            continue
        else:
            par[nxt_v] = v
            uf.merge(nxt_v, par[nxt_v], cost)
            q.append(nxt_v)

for a, b in query:
    a -= 1
    b -= 1
    print(uf.diff(a, k) + uf.diff(b, k))

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

using namespace std;

int main(void)
{
    int N;
    cin >> N;
    long long K;
    cin >> K;

    multiset<long long> A;
    multiset<long long> B;
  
  long long asum = 0;
    for (int i = 0; i < N; i++)
    {
        long long a;
        cin >> a;
        A.insert(a);
      asum += a;
    }
  
  if(asum<=K){
    cout << 0 << endl;
    return 0;
  }
    for (int i = 0; i < N; i++)
    {
        long long b;
        cin >> b;
        B.insert(b);
    }

    vector<long long> mult(N,0);
    vector<long long> mult_d(N,0);
    auto aitr = A.begin();
    auto bitr = B.end();
    bitr--;
    long long max =0;
    long long min = -1;
    for (int i = 0; i < N; i++)
    {
        mult[i] = *aitr * *bitr;
        mult_d[i] = *bitr;
        bitr--;
        aitr++;

        if(mult[i]>max){
            max = mult[i];
        }
        if(mult[i]<min || min == -1){
            min = mult[i];
        }
    }

    long long top = max;
    long long bot = 0;
    long long def;

    long long sum;
    long long before = -1;
    while(true){
        sum = 0;
        def = (top+bot) /2;
        for(int i=0;i<N;i++){
          if(mult[i]>def){
          if((mult[i] - def)%mult_d[i]==0){
            sum += (mult[i] - def)/mult_d[i];
          }
          else{
            sum += (mult[i] - def)/mult_d[i] +1;
          }
          //cout<<sum<<"!"<<mult_d[i]<<" ";
        }
      }
      //cout<<def<<" "<<sum<<endl;

        if(sum>K){
            bot = def;
        }
        if(sum<=K){
            top = def;
        }
      if(before == def){
        if(sum>K){
          def++;
        }
        break;
      }
      before = def;
    }
    cout<<def<<endl;
}

Measured memory_bytes: 22144
#include<iostream>
using namespace std;
int main() {
    int binary[8];
    binary[0] = 1;
    for (int i = 1; i < 7; i++) {
        binary[i] = binary[i - 1] * 2;
    }
    int n;
    cin >> n;
    for (int i = 0; i < 7; i++) {
        if (n < binary[i]) {
            cout << binary[i - 1] << endl;
            return 0;
        }
    }
    cout << 64 << endl;
}


Measured memory_bytes: 764
import sys
input = sys.stdin.readline


def func(i: int) -> int:
    if i % 2 == 0:
        j = i // 2
        if j % 2 == 0:
            return 0 ^ i
        else:
            return 1 ^ i
    else:
        j = i // 2
        if j % 2 == 0:
            return 0 ^ (i-1) ^ i
        else:
            return 1 ^ (i-1) ^ i


def main():
    A, B = map(int, input().split())
    ans = func(A-1) ^ func(B)
    print(ans)


if __name__ == '__main__': main()

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

int main() {
	int n, money;
	std::cin >> n >> money;

	// 普通に全探索だとO(n^3)なので、
	// 計算量をO(n^2)まで落とす
	// z = n - x - y
	for (int x = 0; x <= n; x++) {
		for (int y = 0; x + y <= n; y++) {
			// 負の数にはならない
			int z = n - (x + y);
			if (10000 * x + 5000 * y + 1000 * z == money) {
				std::cout << x << " " << y << " " << z << std::endl;
				return 0;
			}
		}
	}

	std::cout << -1 << " " << -1 << " " << -1 << std::endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 2000000009
#define mod 1000000007
using namespace std;

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

    ll b[n-1];
    for(ll i=0;i<n-1;i++)
    	cin>>b[i];

    vector<ll> ans(n);
    ans[0]=b[0];
    ans[n-1]=b[n-2];
   
    for(ll i=1;i<n-1;i++)
    ans[i]=min(b[i],b[i-1]);

	ll sum=0;
	for(ll i=0;i<n;i++)
	sum+=ans[i];

	cout<<sum<<endl;
}


Measured memory_bytes: 256
import java.util.Arrays;

public class Main {


  private static void solve() {
    int n = ni();
    char[] s = ns();

    long[][] dp = new long[n][n];
    Arrays.fill(dp[0], 1);
    int mod = 1000000000 + 7;
    for (int i = 1; i < n; i++) {
      long[] sum = new long[n + 1];
      for (int j = 0; j < n; j ++) {
        sum[j + 1] = sum[j] + dp[i - 1][j];
        sum[j + 1] %= mod;
      }

      for (int j = 0; j < n - i; j++) {
        if (s[i-1] == '>') {
          dp[i][j] = (sum[n] - sum[j + 1] + mod) % mod;
        } else {
          dp[i][j] = sum[j + 1];
        }
      }
    }
    System.out.println(dp[n-1][0]);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

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

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


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

#define  all(x)          (x).begin(), (x).end()
#define  rall(v)          v.rbegin() , v.rend()
#define  ones(x)          __builtin_popcount(x)
#define  sz(v)           ((int)((v).size())
#define  debug(x)        cout << '>' << #x << ':' << x << endl;
#define  clr(v, d)       memset(v, d, sizeof(v));
#define  rep(i,a,b)      for(ll i=a; i<=b;i++)
#define  fo(i,n)         for(ll i=0;i<n;i++)
#define  rfo(i,n)        for(ll i=n-1;i>=0;i--)
#define  unq(vec)        sort(all(vec)); vec.resize(unique(all(vec)) - vec.begin());
#define  era(v)          sort(v.begin(), v.end());v.erase(unique(v.begin(), v.end()), v.end());
#define  pb              push_back
#define  mp              make_pair
#define  endl            '\n'
#define  fi               first
#define  se               second

using namespace std;
typedef long long         ll;
typedef long double       ld;
typedef vector<int>       vi;
typedef vector<long long> vll;
typedef vector<double>    vd;
typedef vector<vi >       vvi;
typedef vector< vd >      vvd;
typedef vector<string>    vs;
typedef pair<int,int>     pii;
typedef vector<pii>       vii;
typedef map<int,int>      mii;

ll gcd(ll a, ll b){return !b ? a : gcd(b, a % b);}
ll lcm(ll a, ll b){return (a / gcd(a, b)) * b;}
//ll modpow(ll a, ll b, ll m = MOD){a %= m; ll res = 1; while (b) {if (b & 1)res = (res * a) % m; a = (a * a) % m; b >>= 1;} return res;}
//ll bpow(ll a, ll b){ll res = 1; while (b) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
//ll modinv(ll a, ll m = MOD) {return modpow(a, m - 2, m);}

const ll MOD = 1e9 + 7;
const int dx4[4] = {0, 1, 0, -1};
const int dy4[4] = {-1, 0, 1, 0};
const int dx8[8] = {-1, -1, -1, 0, 1, 1, 1, 0};
const int dy8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
bool cmp(int X,int Y){return X>Y;}

int main()
{ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
long double a,b,h,m;
cin>>a>>b>>h>>m;
long double x = (h*30 + m/2)-6*m;
long double angle = min(x,360-x);
angle*=(3.141592653589793238)/180;


long double ans = sqrt(a*a + b*b - 2*a*b*cos(angle));

cout<<fixed<<setprecision(15)<<ans;
}















Measured memory_bytes: 4172
#include <bits/stdc++.h>
using namespace std;
 
//#define READ_NUMBER(i) scanf("%d",i)
 
int main(){
	int N, M, K, nA, Anm;
	int count = 0;
	cin >> N >> M;
	int array[M];
    //配列のリセット
	for(int j = 0;j < M;j++){
		array[j] = 0;	
		}
    //N = 1 の時はK1個が答えになる 
	if(N == 1){
		cin >> K;
		cout << K << endl;
	}else{
		for(int i = 0;i < N;i++){
			cin >> K; // 何個か調べる
			for(int j = 0;j < K;j++){
				cin >> nA; //n - 1番目の配列に１を足す
				array[nA - 1] += 1; 
            }
		}
		for(int i = 0;i < M;i++){
			if(array[i] == N){
                //配列のi番目がNだったら（全ての人が好き）
				count++;
			}
		}
		cout << count << endl;
	}
}

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

#define cc(x) cout << (x) << endl
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); ++i)
typedef long long ll;

template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

const ll inf = 1LL<<58;
const int iinf = 1<<30;
vector<int> ac;

int main(){
    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    int l[q], r[q];
    rep(i,q){
        cin >> l[i] >> r[i];
    }

    int tmp=0, j=0;
    rep(i,n){
        if(s[i]=='A'){
            tmp=1;
        }else if(s[i]=='C' && tmp==1){
            ac.push_back(++j);
            tmp=0;
            continue;
        }else{
            tmp=0;
        }
        ac.push_back(j);
    }
    
    rep(i,q){
        cc(ac[r[i]-1] - ac[l[i]-1]);
    }
}

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

bool ary[8];
int main(){
	int N,sum=0;
	cin>>N;
	int tmp;
	for(int i=1;i<=N;i++){
		cin>>tmp;
		if(tmp<3200)ary[(tmp)/400]|=true;
		else sum++;
	}
	int num=0;
	for(int i=0;i<8;i++) if(ary[i]) num++;

	if(!num) cout<<1<<" "<<sum<<endl;
	else cout<<num<<" "<<num+sum<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#define FOR(i,k,n) for(int(i)=(k);(i)<(n);(i)++)
using namespace std;

// assume c is lower
char to_upper(char c)
{
  return c - 'a' + 'A';
}

int main()
{
  string s1,s2,s3;
  cin >> s1 >> s2 >> s3;

  char c1,c2,c3;
  c1 = to_upper(s1[0]);
  c2 = to_upper(s2[0]);
  c3 = to_upper(s3[0]);

  cout << c1 << c2 << c3 << endl;

  return 0;
}


Measured memory_bytes: 256