akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <sstream>
#include <fstream>

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)

using namespace std;
typedef long long unsigned int ll;

int main() {
  int N, D, X;
  cin >> N >> D >> X;
  vector<int> A(N);
  for (int i = 0; i < N; ++i) cin >> A[i];

  int ans = 0;
  for (int i = 0; i < N; ++i) {
    ans++;
    int d = A[i] + 1;
    while (d <= D) {
      ans++;
      d += A[i];
    }
  }
  cout << ans + X << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdlib.h>
#include <fstream>
#include <iostream>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

ll mod(ll a, ll b){
  ll ret=a%b;
  if(ret<0) ret+=b;
  return ret;
}

ll modpow(ll a,ll b,ll c){
  ll res=1;
  while(b>0){
    if(b&1) res=mod(res*a,c);
    a=mod(a*a,c);
    b>>=1;
  }
  return res;
}

int main() {
  string s,t;
  cin>>s>>t;
  int ans=1e9;
  for(int i=0;i<=(int)s.size()-(int)t.size();i++){
    int temp=0;
    for(int j=0;j<(int)t.size();j++){
      if(s[i+j]!=t[j]) temp++;
    }
    ans=min(ans,temp);
  }
  cout<<ans<<endl;
  return 0;
}


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

struct Process
{
  string name;
  long time;
};

queue<Process> q;

int main()
{
  long long N, Q;
  cin >> N >> Q;
  for (int i = 0; i < N; i++)
  {
    string name;
    long time;
    cin >> name >> time;
    Process p = {name, time};
    q.push(p);
  }

  long long endTime = 0;
  while (!q.empty())
  {
    Process p = q.front();
    q.pop();
    if (p.time <= Q)
    {
      endTime += p.time;
      cout << p.name << " " << endTime << endl;
    }
    else
    {
      endTime += Q;
      Process np = {p.name, p.time - Q};
      q.push(np);
    }
  }
}



Measured memory_bytes: 6188
a, b, c, d = list(map(int, input().split(" ")))

i = 2
while a > 0 and c > 0:
    if i % 2 == 0:
        c -= b
    else:
        a -= d
    i+=1

if (a > 0):
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9032
n=gets.to_i
s=gets.split.map(&:to_i)
kai=s.repeated_combination(3).to_a
for i in 0..kai.size-1
  if ((kai[i].sum.to_i)-(kai[i].max.to_i)*2)<=0
    kai[i]=nil
  elsif kai[i][0]==kai[i][1] || kai[i][1]==kai[i][2] || kai[i][2]==kai[i][0]
    kai[i]=nil
  end
end
kai.compact!
puts kai.size


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

using ll = long long;

const int MAXN = 1010;
int N;
ll dist[MAXN][MAXN];
int ccNum[MAXN];
vector<int> ccs[MAXN];

const int MAXM = 2020;
int M;
pair<ll, pair<int, int>> edges[MAXM];
ll X;

const int MOD = int(1e9)+7;

int main() {
  cin >> N >> M >> X;
  for (int e = 0; e < M; e++) {
    int u, v, w; cin >> u >> v >> w; u--, v--;
    edges[e] = {w,{u,v}};
  }
  sort(edges,edges+M);
  for (int i = 0; i < N; i++) { ccs[ccNum[i] = i].push_back(i); }
  for (int e = 0; e < M; e++) {
    int u = ccNum[edges[e].second.first], v = ccNum[edges[e].second.second];
    if (u==v) continue;
    X -= edges[e].first;
    for (int a : ccs[u]) for (int b : ccs[v]) dist[a][b] = dist[b][a] = edges[e].first;
    for (int b : ccs[v]) { ccs[ccNum[b] = u].push_back(b); }
  }
  ll c0 = 0, c1 = 0;
  for (int e = 0; e < M; e++) {
    ll v = edges[e].first - dist[edges[e].second.first][edges[e].second.second];
    c0 += (v < X); c1 += (v <= X);
  }
  c0 = max(c0-1, 0ll), c1 = max(c1-1, 0ll);
  int v0 = 1, v1 = 1;
  for (int i = 0; i < M-c0;i++) { v0 <<= 1; if (v0 >= MOD) v0 -= MOD; }
  for (int i = 0; i < M-c1;i++) { v1 <<= 1; if (v1 >= MOD) v1 -= MOD; }
  int ans = v0 - v1; if (ans < 0) ans += MOD;
  cout << ans << '\n';
}

Measured memory_bytes: 9600
using System;
class Volumen0
{
    static void Main()
    {
        int count = int.Parse(Console.ReadLine());
        const int MAX_SIZE = 201;
        int[] alpha = new int[MAX_SIZE];
        string[] nums = new string[MAX_SIZE];
        for (int i = 0; i < count; ++i)
        {
            nums = Console.ReadLine().Split(' ');
            for (int j = 0; j < nums.Length; ++j)
            {
                alpha[j] = int.Parse(nums[j]);
                alpha[j] = alpha[j] * alpha[j];
            }
            if (alpha[0] == alpha[1] + alpha[2] || alpha[1] == alpha[0] + alpha[2] || alpha[2] == alpha[1] + alpha[0])
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}


Measured memory_bytes: 15944
int_count = int(input())
int_arr = list(map(int, input().split()))

result = 0
number = 1

stop = False

while True:
    for num in int_arr:
        if num % 2 == 1:
            stop = True
            break
    if stop:
        break
    else:
        result = result + 1
        for i, v in enumerate(int_arr):
            int_arr[i] = v/2


print(result)




Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (ll i=0;i<n;i++)
#define all(x) x.begin(),x.end()
signed main(){
    char s[4];cin>>s;
    int a,b;
    a=(s[0]-'0')*10+(s[1]-'0');
    b=(s[2]-'0')*10+(s[3]-'0');
    bool p=((a>=1)&&(a<=12));
    bool q=((b>=1)&&(b<=12));
    cout<<((p&&q)?"AMBIGUOUS":(p?"MMYY":(q?"YYMM":"NA")));
    return 0;
}

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

int main()
{
	int n;
	int cash = 100000;
	const double rate = 1.05;

	cin >> n;

	for( int i = 0; i < n; ++i ){
		cash = ( int )( cash * rate );
		if( cash % 1000 ){
			cash = ( cash / 1000 + 1 ) * 1000;
		}
	}

	cout << cash << endl;

	return 0;
}

Measured memory_bytes: 0
#include <ctype.h>
#include <limits.h>
#include <math.h>
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main(int argc, char **argv) {
  int a, b, c;
  scanf("%d %d %d", &a, &b, &c);
  printf((a == b && b != c) || (a != b && b == c) || (c == a && a != b) ? "Yes\n" : "No\n");
  return EXIT_SUCCESS;
}


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

int main() {
  int N ;
  cin >> N;
  
  int d = N % 10;
  int c = ( N / 10 ) % 10;
  int b = ( N / 100 ) % 10;
  int a = ( N / 1000 ) % 10;
    
  if( a==b && b==c ){
    cout << "Yes" << endl;
  }
  
  else if ( b==c && c==d ){
    cout << "Yes" << endl;
  }
  
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
#define ll long long
#define ld long double
#define pb push_back

using namespace std;

ll x;

bool isprime(ll a)
{
    for (ll i=2;i*i<=a;i++)
    {
        if (a%i==0)return 0;
    }
    return 1;
}

int main()
{
    cin >> x;
    for (;;x++)
    {
        if (isprime(x))
        {
            cout << x << endl;
            break;
        }
    }
}


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

#define int long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define all(c) (c).begin(),(c).end()
#define F first
#define S second
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;
const ld PI = acos(-1.0);

map<int,int> m;

int fun(int n)
{
	if(n == 1)  return 1;
	if(m[n] != 0)   return m[n];
	
	int ans = 1 + 2*fun(n/2);
	m[n] = ans;
	return ans;
}
int32_t main(){
	fast;
	int n;
	cin >> n;

	int ans = fun(n);
	cout << ans;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n,a=0,b=0,x,i=1;
	cin>>n;
	long long y=n;
	if(n%2==1)
	x=0;
	else
	{
		n=n/2;
		while(n!=0)
		{
			b+=n/5;
			n=n/5;
		}
		x=(b);
	}
	cout<<x;
	return 0;
	
	
}


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

using namespace std;
using ll =long long;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int,int> PII;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
using P = pair<int,int>;
//Write From this Line

int main()
{
	string s;
	cin >> s;
	int ans = 0;
	rep(i,s.size()){
		if(i % 2 == 0){
			if(s[i] == 'p') {
				ans --;
			}
		} else {
			if(s[i] == 'g'){
				ans ++;
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
#include <cstring>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for(long long i=0; i<n; i++)
#define reps(i, s, e) for(long long i=s; i<e; i++)
#define repr(i, n) for(long long i=n-1; i>=0; i--)
#define reprs(i, s, e) for(long long i=e-1; i>=s; i--)

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

    ll n; cin >> n;

    if(n % 1000 == 0){
        cout << 0 << endl;
    }
    else{
        cout << 1000 - n % 1000 << endl;
    }

    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <fstream>
#include <algorithm>       // for next_permutation
#include <vector>
#include <queue>
#include <bits/stl_numeric.h>

#define DEBUG 0
#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

typedef vector<vector <int>> Graph;




ll solve() {
    int N;
    cin >> N;
    deque <int> a[1010];
    //各選手の現在の日程がいつまで埋まっているか
    vector<int> step(1010, 0);
    int M;//試合回数
    REP(i,N)
    {
        REP(j,N-1)
        {
            int x;
            cin >> x;
            //選手の試合相手を順番につっこむ
            a[i].push_back(x-1);
        }
    }
    //
    M = N*(N-1)/2;

    queue<int> que;
    //全選手つっこむ
    REP(i,N)que.push(i);

    int num = 0;
    while(que.size())
    {
        int ok=0;
        queue <int> que2;
        while(que.size())
        {
            int i = que.front();
            que.pop();
            //以下の条件を定めてi == 0から貪欲で行う
            //日程が超えていないか 選手が全日程試合を終えていないか
            //相手選手の直近で予定している試合相手がiか
            //相手選手の日程が超えていないか
            if(step[i] <= num && a[i].size() && a[a[i].front()].front() == i && \
            step[a[i].front()]<=num)
            {
                //スケジュールを更新
                step[i] = step[a[i].front()] = num + 1;
                //que2->次の周期の試合日程を組む順 最後にqueとswapする
                que2.push(i);
                que2.push(a[i].front());
                //試合日程の更新が成立したので取り出す
                a[a[i].front()].pop_front();
                a[i].pop_front();
               --M;
            }
        }
        ++num;
        if(M == 0)break;
        swap(que,que2);
    }

    int res;

    if(M)
    {
        res = -1;
    }
    else
    {
        res = num;
    }
    return res;
}

int main()
{
    cout << solve() << endl;
}


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

int main(void){
    int A, B;
    cin >> A >> B;
    int ans = 0;
    ans = max(ans, A + A - 1);
    ans = max(ans, B + B - 1);
    ans = max(ans, A + B);
    
    cout << ans << endl;
}

Measured memory_bytes: 256
main=do
    n<-readLn::IO Int
    putStrLn $ if n==0 then "0" else f "" 1 n
f ac _ 0 = ac
f ac c n
    | even n = f ('0':ac) (negate c) (n`div`2)
    | True = f ('1':ac) (negate c) ((n-c)`div`2)


Measured memory_bytes: 508
A = int(input())
B = int(input())
C = int(input())
X = int(input())
sumX = []

for i in range(A+1) :
    for j in range(B+1):
        for k in range(C+1):
            sumX.append(500*i + 100*j + 50*k)
print(sumX.count(X))

Measured memory_bytes: 8276
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define DL double
#define MLL map<LL,LL>::iterator
#define MSL map<string,L>::iterator
#define MLS map<LL,string>::iterator
#define MSS map<string,string>::iterator
#define MCL map<char,LL>::iterator
#define SL set<LL>::iterator
#define SS set<string>::iterator sl
#define G getline
#define SZ size()
#define IN insert
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
V<LL>u,w;
set<LL>v;
int main()
{
    FAST;
    LL n,m,i,j,k,p,q,o,l,s,t,z;
    cin>>n>>m>>o;
    k=0;
    for(i=1;i<=1000000;i++)
    {
        if(o-(n*i)%m==0)
        {
            cout<<"YES"<<endl;
            k=1;
            break;
        }
    }
    if(k==0)
    {
        cout<<"NO"<<endl;
    }

    return 0;

}


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

#define MAX_N 200

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

  int gcd[MAX_N + 1][MAX_N + 1];

  for (int i = 1; i <= N; i++) {
    gcd[i][i] = gcd[0][i] = gcd[i][0] = i;
    for (int j = i + 1; j <= N; j++) {
      gcd[i][j] = gcd[j][i] = gcd[i][j % i];
    }
  }

  long ans = 0;
  for (int a = 1; a <= N; a++) {
    for (int b = 1; b <= N; b++) {
      for (int c = 1; c <= N; c++) {
        ans += gcd[gcd[a][b]][c];
      }
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 3756
#pragma comment(linker, "/stack:200000000")
#include<bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define look(x) cout<< #x <<'='<< x << '\n' << flush
#define all(v) (v).begin(),(v).end()
#define ll long long
#define ull unsigned long long
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

const long double pi = 2 * acos ( 0.0 );

int main()
{
    ios_base::sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;  cout.tie( 0 ) ;
    //freopen("milk2.in","r",stdin);
    //freopen("milk2.out","w",stdout);
    //cout.precision(4) ;
    int t ;
    cin >> t ;
    int a[t] ;
    int m[t] ;
    for(int i = 0 ; i < t; i++){
      cin >> a[i] ;
    }
    m[0] = 0 ;
    m[1] = abs(a[0] - a[1]) ;
    for(int i = 2 ; i < t ; i++){
      m[i] = min((m[i - 2] + abs(a[i - 2] - a[i])) , (m[i - 1] + abs(a[i - 1] - a[i]))) ;
      //look(m[i]) ;
    }
    cout << m[t - 1] << endl ;
    return 0 ;
}

Measured memory_bytes: 1024
#include <cstdio>

int main (){
    int N,K;
    scanf("%d %d",&N,&K);
    K--;
    char s[N];
    scanf("%s",s);
    if(s[K]=='A') s[K]='a';
    if(s[K]=='B') s[K]='b';
    if(s[K]=='C') s[K]='c';
    printf("%s",s);
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <queue>
#include <set>
using ll = long long;
using uint = unsigned int;
using graph = std::vector<std::vector<ll>>;
using wGraph = std::vector<std::vector<std::pair<ll,ll>>>;
#define rep(i,n) for (int i=0; i < int(n); i++)

using namespace std;
ll MOD7 = 1000000007;
ll MOD9 = 1000000009;
vector<ll> InputVec(ll N){
    vector<ll> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    return A;
}
void OutputVec(vector<ll> A){
    for (int i = 0; i < A.size(); ++i) {
        cout << A[i] << ",";
    }
    cout << endl;
}
vector<vector<ll>> InputVec2d(ll H,ll W){
    vector<vector<ll>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<ll>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        for (int xi = 0; xi < W; ++xi) {
            cin >> A[yi][xi];
        }
    }
    return A;
}
vector<vector<char>> InputVec2dStr(ll H,ll W){
    vector<vector<char>> A(H);
    for (int yi = 0; yi < H; ++yi) {
        A[yi] = vector<char>(W);
    }
    for (int yi = 0; yi < H; ++yi) {
        string S;
        cin >> S;
        for (int xi = 0; xi < W; ++xi) {
            A[yi][xi] = S[xi];
        }
    }
    return A;
}

void OutputVec2d(vector<vector<ll>> A){
    for (int yi = 0; yi < A.size(); ++yi) {
        for (int xi = 0; xi < A[yi].size(); ++xi) {
            cout << A[yi][xi] << ",";
        }
        cout << endl;
    }
}

graph InputGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    return G;
}
graph InputDGraph(ll N,ll M){
    graph G(N);
    for (int i = 0; i < M; ++i) {
        ll a,b;
        cin >> a >> b;
        a--;b--;
        G[a].push_back(b);
    }
    return G;
}

void OutputGraph(graph G){
    for (int i = 0; i < G.size(); ++i) {
        cout << i << ":";
        for (int j = 0; j < G[i].size(); ++j) {
            cout << G[i][j]<< ",";
        }
        cout << endl;
    }
}

void OutputAnswerBool(bool b,bool isUpperCase = false){
    if(b){
        if(isUpperCase){
            cout << "YES" << endl;
        }else{
            cout << "Yes" << endl;
        }
    }else{
        if(isUpperCase){
            cout << "NO" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}

int main() {
    ll N;
    string S;
    cin >> N;
    cin >> S;
    vector<ll> bC(N);
    vector<ll> wC(N);
    if(S[0] == '#'){
        bC[0] = 1;
        wC[0] = 0;
    }else{
        bC[0] = 0;
        wC[0] = 1;
    }
    for (int i = 1; i < N; ++i) {
        if(S[i] == '#'){
            bC[i] = bC[i-1] + 1;
            wC[i] = wC[i-1];
        }else{
            bC[i] = bC[i-1];
            wC[i] = wC[i-1] + 1;
        }
    }
    ll m = N;
    m = min(m,wC[N-1]);
    for (int i = 0; i < N; ++i) {
      m = min(m,bC[i] + (wC[N-1] - wC[i]));
    }

    cout << m << endl;
}


Measured memory_bytes: 3716
#include<bits/stdc++.h>
#define fo(i,a,b) for(i=a;i<=b;i++)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define N 200000
using namespace std;
int n,m,k,i,x,y,c,res,mn;
int a[N],b[N];
int main()
{
    cin>>n>>m>>k;
    fo(i,1,n) cin>>a[i];
    fo(i,1,m) cin>>b[i];
    mn = a[1]; fo(i,2,n) mn = min(mn,a[i]); res += mn;
    mn = b[1]; fo(i,2,m) mn = min(mn,b[i]); res += mn;
    fo(i,1,k)
    {
        cin>>x>>y>>c;
        res = min(res,a[x]+b[y]-c);
    }
    cout<<res<<endl;
}


Measured memory_bytes: 1024
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int[] array = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int a = sc.nextInt() - 1;
    System.out.println(array[a]);
	
  
  }
}

Measured memory_bytes: 21844
n, m, l = map(int,input().split())
a = list()
for i in range(n):
    a.append(list(map(int,input().split())))

b = list()
for i in range(m):
    b.append(list(map(int,input().split())))

for i in range(n):
    line = list()
    for j in range(l):
        c = 0
        for k in range(m):
            c += a[i][k] * b[k][j]
        line.append(str(c))
    print(' '.join(line))


Measured memory_bytes: 6248
// C++ includes used for precompiling -*- C++ -*-

// Copyright (C) 2003-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.

// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
// <http://www.gnu.org/licenses/>.

/** @file stdc++.h
 *  This is an implementation file for a precompiled header.
 */

// 17.4.1.2 Headers

// C
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
// #include <cstdalign>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

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

int main()
{

  string s;

  cin >> s;

  if (s[0] == s[1] || s[1] == s[2] || s[2] == s[3])
  {
    cout << "Bad" << endl;
  }
  else
  {
    cout << "Good" << endl;
  }

  return 0;
}


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

int main() {
	char str[1200];
	int i = 0;
	for (; i < 1200; i++) 
	{
		char in;
		scanf("%c", &in);
		if (in == '\n')
			break;
		
		if (in >= 'A'&&in <= 'Z')
			str[i] = in + 32;
		else if (in >= 'a'&&in <= 'z')
			str[i] = in - 32;
		else
			str[i] = in;
		printf("%c", str[i]);
	}
	putchar('\n');
	return 0;
}

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

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	
	for(int n;cin>>n && n;){
		map<string,int> ps;
		vector<int> ts(n);
		for(int i=0;i<n;i++){
			string s; int w,t; cin>>s>>w>>t;
			ps[s]=i;
			ts[i]=(w*1440+t/100*60+t%100)%10080;
		}
		int m; cin>>m;
		vector<int> fs(n);
		for(int i=0;i<m;i++){
			string s; cin>>s;
			fs[ps[s]]=1;
		}
		
		for(int i=0;i<n;i++)
			ts.push_back(ts[i]+10080);
		vector<int> is(n*2);
		iota(begin(is),end(is),0);
		sort(begin(is),end(is),[&](int i,int j){return ts[i]<ts[j];});
		
		int res=-1;
		for(int l=0,r=10080;l<30;l++,r++){
			vector<int> dp(r+1);
			int p=0;
			for(int i:is) if(l<=ts[i] && ts[i]+30<=r){
				int t=ts[i];
				for(;p<t;p++) dp[t]=max(dp[t],dp[p]);
				dp[t+30]=max(dp[t+30],dp[t]+(fs[i]?1000:1));
			}
			for(;p<r;p++) dp[r]=max(dp[r],dp[p]);
			if(dp[r]/1000==m)
				res=max(res,dp[r]/1000+dp[r]%1000);
		}
		
		cout<<res<<'\n';
	}
}

Measured memory_bytes: 1352
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.math.BigInteger;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int[] a = new int[n];
            int s = 0;
            for (int i = 0; i < n; ++i) {
                a[i] = in.nextInt();
                s += a[i];
            }
            int half = s / 2;
            BigInteger mask = BigInteger.ONE.shiftLeft(half + 1).subtract(BigInteger.ONE);
            BigInteger can = BigInteger.ONE;
            for (int x : a) {
                can = can.or(can.shiftLeft(x)).and(mask);
            }
            int x = can.bitLength() - 1;
            out.println(s - x);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

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

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

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

    }
}



Measured memory_bytes: 342352
#include <bits/stdc++.h>  
using namespace std;  
#define INF 0x3f3f3f3f  
typedef long long ll;  
const int N =  1010;  
#define FI first
#define SE second
typedef pair<int, int>pii;

int main()  
{  
  // freopen("in.txt","r",stdin);
   int x, a, b;
   while (~scanf("%d%d%d", &x, &a, &b))
   {
   		if (b <= a)
   			puts("delicious");
   		else if (b - a <= x)
   			puts("safe");
   		else
   			puts("dangerous");

   }
   return 0;  
}  

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

#define PI 3.14159265358979323846264338327950L
#define ll long long
#define lli long long int

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int a;
    cin >> a;
    int number = a + (int)pow(a, 2) + (int)pow(a, 3);
    cout << number << "\n";

    return 0;
}


Measured memory_bytes: 4108
// AOJ 2671 Digital Clock
// 2018.3.18 bal4u

#include <stdio.h>

int t[14][10];
char seg[10][7] = {{1,1,1,0,1,1,1},{0,0,1,0,0,1,0},{1,0,1,1,1,0,1},{1,0,1,1,0,1,1},{0,1,1,1,0,1,0},
                   {1,1,0,1,0,1,1},{1,1,0,1,1,1,1},{1,0,1,0,0,1,0},{1,1,1,1,1,1,1},{1,1,1,1,0,1,1}};
char k[10] = {6,2,5,5,4,5,6,3,7,6};
int fhh[15], fmm[15], fss[15];
int fmd[29], fyy[29];
int hms[43], ymd[57];

int days[13] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

#define getchar_unlocked()  getchar()
int in()
{
	int n = 0, c = getchar_unlocked();
	do n = 10*n + (c & 0xf), c = getchar_unlocked(); while (c >= '0');
	return n;
}

int main()
{
	int  N, K, p, q, i, j;
	int  yy, month, dd, hh, mm, ss;
	long long ans;

	N = in(), K = in();
	for (i = 0; i < 14; i++) for (j = 0; j < 10; j++) t[i][j] = k[j];
	while (K--) {
		p = in(), q = in();
		for (j = 0; j < 10; j++) if (seg[j][q]) t[p][j]--;
	}
	
	for (hh = 0; hh < 24; hh++) fhh[t[8 ][hh/10]+t[9 ][hh%10]]++;
	for (mm = 0; mm < 60; mm++) fmm[t[10][mm/10]+t[11][mm%10]]++;
	for (ss = 0; ss < 60; ss++) fss[t[12][ss/10]+t[13][ss%10]]++;
	for (hh = 0; hh <= 14; hh++) for (mm = 0; mm <= 14; mm++) for (ss = 0; ss <= 14; ss++) {
		hms[hh+mm+ss] += fhh[hh] * fmm[mm] * fss[ss];
	}

	for (month = 1; month <= 12; month++) for (dd = 1; dd <= days[month]; dd++) {
		fmd[t[4][month/10]+t[5][month%10]+t[6][dd/10]+t[7][dd%10]]++;
	}
	for (yy = 0; yy <= 9999; yy++) {
		fyy[t[0][yy/1000]+t[1][(yy/100)%10]+t[2][(yy/10)%10]+t[3][yy%10]]++;
	}
	for (yy = 0; yy <= 28; yy++) for (mm = 0; mm <= 28; mm++) {
		ymd[yy+mm] += fyy[yy] * fmd[mm];
	}
	for (yy = 0; yy <= 9999; yy+=4) if (yy%400 == 0 || yy%100 != 0) {
		ymd[t[0][yy/1000]+t[1][(yy/100)%10]+t[2][(yy/10)%10]+t[3][yy%10]+
			t[4][0]+t[5][2] + t[6][2]+t[7][9]]++;
	}

	ans = 0;
	for (i = 0; i <= N; i++) {
		if (i > 56 || N-i > 42) continue;
		ans += (long long)ymd[i] * hms[N-i];
	}
	printf("%lld\n", ans);
	return 0;
}


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

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

    vector<vector<char>>a(n,vector<char>(n));
    vector<vector<char>>b(m,vector<char>(m));

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

    for(int i=0;i<m;i++)
        for(int j=0;j<m;j++)
            cin>>b[i][j];
            
    bool ans=false;
    for(int i=0;i<=n-m;i++){
        for(int j=0;j<=n-m;j++){
            bool flag=true;
            for(int k=0;k<m;k++){
                for(int l=0;l<m;l++){
                    if(a[k+i][l+j]!=b[k][l])
                        flag=false;
                }
            }
            if(flag)
                ans=true;
        }
    }

    ans?cout<<"Yes":cout<<"No";
    cout<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <vector>
#include <bitset>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <deque>
#include <string>
#include <list>
#include <iterator>
#include <algorithm>
#include <unordered_map>
#define int                long long
#define pb                 push_back
#define pi                 pair<int,int>
#define vi                 vector<int>
#define all(v)             v.begin(),v.end()
#define MOD                1000000007
#define F                  first
#define S                  second
#define FOR(i,r)           for(int i=0;i<r;i++)
#define REP(i,l,r)         for(int i=l;i<r;i++)
#define RER(i,l,r)         for(int i=l;i>=r;i--)
#define print(v)           for(auto i : v)cout << i << ' ';
#define FASTIO             ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mem(arr,k)         memset(arr,k,sizeof(arr));
#define pii                acos(-1.0)
#define PI                 3.1415926535897932385
#define Sin(a)             sin((pi*a)/180)
#define test()             int x;cin >> x;while(x--){solve();}
#define test2()            int x;cin >> x;for(int i=1;i<=x;i++){cout << "Case #" << i << " : ";solve();}
#define watch(x)           cout << (#x) << " is " << (x) << endl
using namespace std;


/* Mathematical Functions */
int power(int x,int y);
bool isPrime(int n);
int modInv(int a,int b);
int gcdExtended(int a,int b,int *x,int* y);
int mpower(int a,int b,int p);

const int inf = (int)1e17;
const int N = (int)3e5+5;

int32_t main(){

	FASTIO;
	int val = 1e18;
	int cur = 1;
	vi A;
	A.pb(0);
	while(pow(cur,5) <= val){
		A.pb(cur);
		A.pb(-cur);
		cur++;
	}
	int x;
	cin >> x;
	REP(i,0,A.size()){
		REP(j,i+1,A.size()){
			if(pow(A[i],5)-pow(A[j],5) == x){
				cout << A[i] << ' ' << A[j];
				return 0;
			}
		}
	}
    return 0;

}
int modInv(int a, int m)
{
int x, y;
int g = gcdExtended(a, m, &x, &y);
int res = (x%m + m) % m;
return res;
}
 
int gcdExtended(int a, int b, int *x, int *y)
{
if (a == 0){
    *x = 0, *y = 1;
    return b;
  }
  int x1, y1;
  int gcd = gcdExtended(b%a, a, &x1, &y1);
  *x = y1 - (b/a) * x1;
  *y = x1;
  return gcd;
}
 
int mpower(int x, int y, int p)
{
int res = 1;
x = x % p;
while(y > 0){
    if(y & 1) res = (res*x) % p;
      y = y>>1;
      x = (x*x) % p;
    }
    return res;
}
int power(int x, int y)
{
int res = 1;
while (y > 0){
    if (y & 1) res = res*x;
      y = y>>1;
      x = x*x;
    }
    return res;
}
 
bool isPrime(int n)
{
if (n <= 1)  return false;
  if (n <= 3)  return true;
    if (n%2 == 0 || n%3 == 0) return false;
      int p=sqrt(n);
      for(int i=5;i<=p;i=i+6)
        if (n%i == 0 || n%(i+2) == 0)
          return false;
      return true;
}

Measured memory_bytes: 4260
// Multithreading.cpp : Ce fichier contient la fonction 'main'. L'exécution du programme commence et se termine à cet endroit.
//

#include <iostream>
#include <algorithm>
#include <cmath>
#include<vector>
#include<set>
using namespace std;
#define mp make_pair
#define pb push_back
#define eb emplace_back

#define vd vector<double>
#define rep(i,a,b) for(int i=a;i<b;++i)
typedef pair<int, int> ii;
typedef  vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef long long ll;
//const int N = 101;
using namespace std;
const int N = 200001;
long A[N]; int in[N];
long long calcul(long long n) {
     //long a=n*n*n;
    return n*n*n;
}
long long ans;
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int n,k; cin >> n>>k;
    rep(i, 1, n + 1) {
        ++A[i % k];
    }
    if (k % 2 == 0) {
        ans+=calcul(A[k/2]);
    }
    ans+=calcul(A[0]);
  cout<<ans;
    return 0;
}



Measured memory_bytes: 4272
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int a[10010];
int b[10010];

int main() {
	int n;
	while(n=in()){
		memset(a,0,sizeof(a));
		memset(b,0,sizeof(b));
		int i,j;
		for(i=1;i<n;i++){
			a[i*i%n]=1;
		}
		for(i=0;i<n;i++){
			if(a[i]==0)continue;
			for(j=i+1;j<n;j++){
				if(a[j]==0)continue;
				int k=i-j;
				if(k<0)k+=n;
				if(k>(n-1)/2)k=n-k;
				b[k]+=2;
			}
		}
		for(i=1;i<(n+1)/2;i++)cout<<b[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 960
n, m, l = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(n)]
B = [list(map(int, input().split())) for _ in range(m)]
for i in range(n):
    print(' '.join(str(sum(A[i][k] * B[k][j] for k in range(m))) for j in range(l)))



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

int main(){
	int l,a,b,c,d;
	scanf("%d%d%d%d%d",&l,&a,&b,&c,&d);
	printf("%d\n",l-max(((a-1)-(a-1)%c)/c+1,((b-1)-(b-1)%d)/d+1));
}
	

Measured memory_bytes: 1172
import java.util.HashMap;
import java.util.Scanner;

public class Main {

	void run() {
		Scanner in = new Scanner(System.in);
		
		HashMap<String, Integer> item = new HashMap<String, Integer>();
		
		while(true) {
			int N = Integer.parseInt(in.next());
			if (N == 0) break;
			for(int i = 0; i < N; i++) {
				item.put(in.next(), Integer.parseInt(in.next()));
			}
			
			int M = Integer.parseInt(in.next());
			for(int i = 0; i < M; i++) {
				String item_name = in.next();
				int item_cost = item.get(item_name);
				int X = Integer.parseInt(in.next());
				int recipe_cost = 0;
				for(int j = 0; j < X; j++) {
					recipe_cost += item.get(in.next());
				}
				if(item_cost > recipe_cost) {
					item.put(item_name, recipe_cost);
				}
			}
			System.out.println(item.get(in.next()));
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
using namespace std;

int main()
{
    //freopen("in.txt", "r", stdin);
    //freopen("out.txt", "w", stdout);
    int t;
    cin>>t;
    map<string, int> x;
    x["AC"] = 0;
    x["WA"] = 0;
    x["TLE"] = 0;
    x["RE"] = 0;
    while(t--){
        string t;
        cin>>t;
        x[t]++;
    }
    cout<<"AC x "<<x["AC"]<<"\nWA x "<<x["WA"]<<"\nTLE x "<<x["TLE"]<<"\nRE x "<<x["RE"]<<"\n";
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define loop(n, i) for(int i=0;i<n;i++)
#define loop1(n, i) for(int i=1;i<=n;i++)
#define rloop(n, i) for(int i=n;i;i++)
#define HERE cout << "HERE: " << __LINE__ << endl;
#define INSP(v) cout << v << " at " << __LINE__ << endl;
using namespace std;
using ll = long long;
template <class T>
using V = vector<T>;

int main() {
    int x, a; cin >> x >> a;
    cout << (x < a ? "0" : "10") << endl;
    return 0;
}



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

int32_t main(){
    int x, k, d;
    cin >> x >> k >> d;
    if(k >= abs(x) / d + (abs(x) % d != 0)){
        k -= abs(x) / d;
        if(k % 2 == 0){
            cout << abs(x) % d << '\n';
        } else {
            cout << d - abs(x) % d << '\n';
        }
    } else
        cout << min(abs(x - d * k), abs(x + d * k));
}


Measured memory_bytes: 3632
#include <iostream>
#include <bits/stdc++.h>
#include <string>
#include <ctype.h>
#include <algorithm>
#include <cmath>
#include <vector>

#define REP(i, n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define square(x) (x) * (x)

const int INF = 1e9;

using namespace std;

int main() {
    int n;
    cin >> n;
    bool card[4][13] = {false};
    string mark[4] = {"S", "H", "C", "D"};
    REP(i, n) {
        int suit;
        int num;
        string m;
        cin >> m >> num;
        if (m == "S")
            suit = 0;
        if (m == "H")
            suit = 1;
        if (m == "C")
            suit = 2;
        if (m == "D")
            suit = 3;
        card[suit][num-1] = true;
    }
    REP(i, 4)
        REP(j, 13)
            if (card[i][j] == false)
                cout << mark[i] << " " << j+1 << endl;
    return 0;
}

Measured memory_bytes: 1212
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
for p in range(a + 1):
    for q in range(b + 1):
        r = (x - p * 500 - q * 100) // 50
        if 0 <= r <= c:
            ans += 1
print(ans)

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

int main()
{
    int in[3]={0},n[2]={0, 0};
    cin >> in[0]
        >> in[1]
        >> in[2];
    for(int i = 0;i < 3;i++)
    {
        if(in[i] == 5)
            n[0]++;
        else if(in[i] ==7 )
            n[1]++;
    }
    if(n[0] == 2 && n[1] == 1)
        cout << "YES";
    else
        cout << "NO";
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <sstream>

#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <queue>
#include <stack>

#include <algorithm>
#include <utility>
#include <numeric>
#include <functional>

#include <chrono>
#include <random>

using namespace std;
using i64 = int_fast64_t;
using ui64 = uint_fast64_t;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<i64>;
using vvl = vector<vl>;
using vd = vector<double>;
using vvd = vector<vd>;
using vb = vector<bool>;
using vvb = vector<vb>;
using pii = pair<int, int>;
using pll = pair<i64, i64>;

//////////////////////////////////////////////////
template<typename T>
struct edge{
    int f, t;
    T data;
    edge(int f_, int t_, T data_):f(f_), t(t_), data(data_){};
    edge(){};
    bool operator<(const edge& r){
        return this->data < r.data;
    }
};

template<typename T>
struct graph{
    vector< vector<edge<T> > > data;
    graph(int n):data(n){};
    graph(){};
    int size(){
        return (int)data.size();
    }
    void add_edge(int f, int t, T c){
        data[f].emplace_back(f, t, c);
    }
};

int main(){
    int n;
    cin >> n;
    graph<i64> g(n);
    for(int i=0;i<n-1;i++){
        int u, v;i64 w;
        cin >> u >> v >> w;
        u--;v--;
        g.add_edge(u, v, w);
        g.add_edge(v, u, w);
    }
    vector<int> ret(n, -1);
    ret[0] = 0;
    queue<int> q;
    q.push(0);
    while(!q.empty()){
        int c = q.front();q.pop();
        for(auto && x:g.data[c]){
            if(ret[x.t] == -1){
                ret[x.t] = x.data & 1 ? ret[x.f] ^ 1 : ret[x.f];
                q.push(x.t);
            }
        }
    }
    for(auto&& x:ret)cout << x << endl;
    return 0;
}


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

#define MAX 25
#define NIL -1

using namespace std;

struct Node {
    int parent, left, right;
};

Node T[MAX];
int D[MAX], H[MAX];
int root = 0;

int getDepth(int node) {
    int d = 0;
    while(T[node].parent != NIL) {
        node = T[node].parent;
        d++;
    }
    return d;
}

int getHeight(int id) {
    int h1 = 0, h2 = 0;
    if(T[id].left != NIL)
        h1 = getHeight(T[id].left) + 1;

    if(T[id].right != NIL)
        h2 = getHeight(T[id].right) + 1;
    return H[id] = (h1 > h2 ? h1: h2);

}

int getSibling(int id) {
    if(T[id].parent == NIL) return NIL;
    if(T[T[id].parent].left != id && T[T[id].parent].left != NIL)
        return T[T[id].parent].left;
    if(T[T[id].parent].right != id && T[T[id].parent].right != NIL)
        return T[T[id].parent].right;
    return NIL;
}


void print(int id) {
    printf("node %d: ", id);
    printf("parent = %d, ", T[id].parent);
    printf("sibling = %d, " ,getSibling(id));
    int deg = 0;
    if(T[id].left != NIL) deg++;
    if(T[id].right != NIL) deg++;
    printf("degree = %d, ", deg);
    printf("depth = %d, ", getDepth(id));
    printf("height = %d, ", H[id]);
    if(T[id].parent == NIL) printf("root\n");
    else if(T[id].left == NIL && T[id].right == NIL) printf("leaf\n");
    else printf("internal node\n");


}

int main()
{
    int n, id, left, right;
    scanf("%d", &n);

    for(int i = 0; i < n; i++) T[i].parent = NIL;
    for(int i = 0; i < n; i++) {
        scanf("%d%d%d", &id, &left, &right);
        T[id].left =  left;
        T[id].right = right;

        if(left != NIL) T[left].parent = id;
        if(right != NIL) T[right].parent = id;
    }

    for(int i = 0; i < n; i++) {
        if(T[i].parent == NIL) {
            root = i;
            break;
        }
    }

    getHeight(root);

    for(int i = 0; i < n; i++) {
        print(i);
    }


    return 0;
}

Measured memory_bytes: 2740
import java.util.*;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);
		long[] a = new long[3];
		a[0] = sc.nextLong();
		a[1] = sc.nextLong();
		a[2] = sc.nextLong();
		Arrays.sort(a);
		long b = a[2]/2;
		long c = a[2]-b;
		System.out.println(Math.abs(a[0]*a[1]*b-a[0]*a[1]*c));
	}
	
	// print
	static void print(String s) {
		System.out.println(s);
	}
	
	// union find lib
	// usage:
	// 最初にinitを呼ぶ
	// root: 直接は呼ばないで
	// unite: まとめる
	// same: グループ判定
	static void init(int par[], int N) {
		for(int i=0; i<N; i++) {
			par[i] = i;
		}
	}
	
	static int root(int x, int [] par) {
		if(par[x] == x) {
			return x;
		} else {
			return (par[x] = root(par[x], par));
		}
	}
	
	static boolean same(int x, int y, int[] par) {
		return root(x, par) == root(y, par);
	}
	
	static void unite(int x, int y, int[] par) {
		x = root(x, par);
		y = root(y, par);
		if(x == y) return;
		par[x] = y;
	}
	
	// end union find lib
	
	// number lib
	
	static long lcm(long a, long b) {
		return a*(b/gcd(a, b));
	}
	
	static long gcd(long a, long b) {
		long ta = Math.max(a, b);
		long tb = Math.min(a, b);
		long tmp;
		while((tmp = ta%tb) != 0) {
			ta = tb;
			tb = tmp;
		}
		return tb;
	}
	
	static long modcomb(long n, long k, long mod) {
		if(k==1) {
			return n;
		}
		
		long ans = 1;
		for(long i=n; i>=n-k+1; i--) {
			ans = (ans * i)%mod;
		}
		for(long i=k; 0<i; i--) {
			ans = (ans * modpow(i, mod-2, mod)) % mod;
		}
		return ans;
	}
	
	static long modpow(long a, long b, long mod) {
		if(b==0) return 1;
		if(b%2==0) {
			long d = modpow(a, b/2, mod);
			return (d*d)%mod;
		} else {
			return (a*modpow(a, b-1, mod))%mod;
		}
	}
	
	static int disit(long a, long d) {
		int count = 0;
		while(a!=0) {
			a = a/d;
			count++;
		}
		return count;
	}
	
	// end number lib
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <queue>
using namespace std;
constexpr long long INF = 1LL << 62;
template<class T> inline bool chmin(T &a, T b){ if(a > b) { a = b; return true;} return false;}

struct Edge {
    int src, dst, cost;
    Edge(int s, int d, int c = 1) : src(s), dst(d), cost(c) {}
    bool operator<(const Edge &e){ return cost < e.cost;}
};
using Edges = vector<Edge>;
using Graph = vector<Edges>;

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

    Graph g(k);
    for(int i=0; i < k; ++i) {
        g[i].emplace_back(i, (i * 10) % k, 0);
        g[i].emplace_back(i, (i + 1) % k, 1);
    }

    vector<long long> dist(k, INF);
    deque<int> dq;
    dq.push_front(1);
    dist[1] = 1;

    while(!dq.empty()) {
        int v = dq.front(); dq.pop_front();

        for(Edge e : g[v]) {
            if(chmin(dist[e.dst], dist[e.src] + e.cost)) {
                if(e.cost == 0) dq.push_front(e.dst);
                else dq.push_back(e.dst);
            }
        }
    }
    
    cout << dist[0] << '\n';
    return 0;
}

Measured memory_bytes: 6656
#include<bits/stdc++.h>
#pragma warning(disable:4996)
#ifdef _MSC_VER
#  define __builtin_popcount __builtin_popcountll
#  define __builtin_popcountll __popcnt
#endif
#define int long long
using namespace std;
using ll = long long;
using ld = long double;
const long double PI = acos(-1.0);
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
inline void my_io() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	std::cout << fixed << setprecision(10);
}
//nCkを求める
const int MAX = 510000;
const int MOD = 1e9 + 7;
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
signed main() {
	COMinit();
	int n, k;
	cin >> n >> k;
	for (int i = 1; i <= k; i++) {
		//まず　青玉の分割方法を計算する　kコの青玉をi分割する　よってk-1Ci-1
		int blue_bunkatu = COM(k - 1, i - 1);
		//次に赤玉のどこにしきりを入れるかを計算する 赤玉はn-kコある　よってn-k+1Ci
		int red_bunkatu = COM(n - k + 1, i);
		cout << (blue_bunkatu%MOD) * (red_bunkatu%MOD)%MOD << endl;

	}
}


Measured memory_bytes: 12288
#include<bits/stdc++.h>
using namespace std;
long long n,a[100010];
int main(int argc, char const *argv[])
{
	scanf("%lld",&n);
	int cn=0;
	for(int i=0;i<n;i++)
	{
		scanf("%lld",a+i);
	}
	long long  flag=1,st,en;
	if(a[n-1]>2)
	{
		cout<<"-1\n";
	}
	else
	{
		if(a[n-1] == 2)
			st=2,en=3;
		else
			st=2,en=2;
		long long hold1,hold2,temp;
		for(int i=n-2;i>=0;i--)
		{
			hold1=(st+a[i]-1)/a[i];
			hold2=(en)/a[i];
			hold1*=a[i];
			hold2*=a[i];
			hold2+=(a[i]-1);
			st=hold1;
			en=hold2;
			//cout<<"i= "<<i<<" st= "<<st<<" en= "<<en<<endl;
			//ast=st-1;
			//aen=en;
			//cout<<"i= "<<i <<" st= "<<st<<" en= "<<en<<endl;
		}
		if(st<=en)
		{
			cout<<st<<" "<<en<<"\n";
		}
		else
			cout<<"-1\n";
	}
	return 0;
}

Measured memory_bytes: 1024
/* BISMILLAHIR RAHMANIR RAHIM */
#include<bits/stdc++.h>
using namespace std;
#define ll        long long
#define ull       unsigned long long
#define si(x)     scanf("%d", &x)
#define sll(x)    scanf("%lld", &x)
#define ssll(x,y)    scanf("%lld %lld", &x ,&y)
#define sd(x)     scanf("%lf", &x)
#define l0(i,n)   for(ll i=0; i<n; i++)
#define MAX       100005
#define maxn 	  200002
#define pb 		  push_back
#define mk 		  make_pair
#define endl	  "\n"
#define INF 	  1000000000
#define MOD		  1000000007
#define imie(...) "[" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

int main ()
{
		ios::sync_with_stdio(0);
		cin.tie(0);
		//CODE TONOY
		ll  a,b,c,d;
		cin >> a >> b >> c >> d;
		cout << max(a*b,c*d) << endl;
		return 0;  
}  


Measured memory_bytes: 3632