akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <queue>
#include <utility>
using namespace std;

long long n, q, k, a[100005], b[100005], c[100005], t1, t2, w[100005], ba[100005], bw[100005];

vector<pair<long long, long long>> g[100005];

void dfs(int p, int pr)
{

    int cnt = 0;
    for (auto i : g[p])
        if (i.first != pr)
        {
            w[i.first] = w[p] + i.second;
            dfs(i.first, p);
        }
}

int main()
{
    cin >> n;
    for (int i = 0; i < n - 1; ++i)
    {
        cin >> a[i] >> b[i] >> c[i];
        g[a[i]].push_back({b[i], c[i]});
        g[b[i]].push_back({a[i], c[i]});
    }

    cin >> q >> k;

    dfs(k, -1);

    for (int i = 0; i < q; ++i)
    {

        cin >> t1 >> t2;
        cout << w[t1] + w[t2] << endl;
    }
}

Measured memory_bytes: 18176
//C++14 (Clang 3.8.0)

#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int maxn=500001;
P a[maxn],b[maxn];
vector<ll> divisor(ll x){
  vector<ll> res;
  for(ll i=1LL;i*i<=x;i++){
    if(x%i==0){
      res.push_back(i);
      if(i!=x/i)res.push_back(x/i);
    }
  }
  return res;
}

int main(){
  ll n;
  cin>>n;
  vector<ll> tmp=divisor(n);
  int res=100;
  for(int i=0;i<tmp.size();i++){
    ll a=tmp[i];
    ll b=n/tmp[i];
    ll x=1LL;
    int k1;
    for(int j=0;;j++){
      x*=10LL;
      if(a<x){
        k1=j+1;
        break;
      }
    }
    int k2;
    x=1LL;
    for(int j=0;;j++){
      x*=10LL;
      if(b<x){
        k2=j+1;
        break;
      }
    }
    res=min(res,max(k1,k2));

  }


cout<<res<<endl;
}


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

class node{
    int key;
    node *left;
    node *right;

    public:
    node();

    node(int);
    node* Insert(node *,int);
    void inorderprint(node *);
    void preorderprint(node *);
};

vector<int> print;

node::node() : key(0),left(NULL),right(NULL){}

node::node(int v){
    key = v;
    left = right = NULL;
}

node* node::Insert(node *root,int value){
    if(!root){
        return new node(value);
    }
    if(value>root->key){
        root->right = Insert(root->right,value);
    }else{
        root->left = Insert(root->left,value);
    }

    return root;
}

void node::inorderprint(node *root){
    if(!root) return;
    inorderprint(root->left);
    print.push_back(root->key);
    inorderprint(root->right);
}
void node::preorderprint(node *root){
    if(!root) return;
    print.push_back(root->key);
    preorderprint(root->left);
    preorderprint(root->right);
}
int main(){
    int n;cin >> n;
    node t,*root = NULL;
    for(int i=0;i<n;i++){
        string s;cin >> s;
        if(i==0){
            int value;cin >> value;
            root = t.Insert(root,value);
            continue;
        }
        if(s[0]=='p'){
            print.clear();
            t.inorderprint(root);
            for(int pr=0;pr<print.size();pr++){
                cout << " ";
                cout << print[pr];
                if(pr==print.size()-1) cout << endl;
            }
            print.clear();
            t.preorderprint(root);
            for(int pr=0;pr<print.size();pr++){
                cout << " ";
                cout << print[pr];
                if(pr==print.size()-1) cout << endl;
            }
        }else{
            int value;cin >> value;
            t.Insert(root,value);
        }
    }
    
    return 0;
}


Measured memory_bytes: 20592
#include <iostream>
#include <map>
#define ll long long
using namespace std;
map<int, int> mp;
int n;
ll rs = 0;
int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		int x; cin >> x;
		rs += mp[i - x];
		mp[i + x]++;
	}
	cout << rs << "\n";
	return 0;
}

Measured memory_bytes: 20632
#include <bits/stdc++.h>
 
using namespace std;
 
#define SPEED ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fileio freopen("in.in", "r", stdin),freopen("out.out", "w", stdout);
#define ll long long int
#define FF first
#define SS second
#define mp make_pair
#define pb push_back
#define pii pair<int,int>
#define pll pair<long long int,long long int>
#define sd(x) scanf("%d",&x)
#define slld(x) scanf("%lld",&x)
#define pd(x) printf("%d\n",x)
#define plld(x) printf("%lld\n",x)
#define pss printf
#define MOD 1000000007
#define INF 1e18
#define eps 0.00001
#define endl '\n'
#define debug(n1) cout<<n1<<endl
ll n;
ll a[100005];
int main() {
slld(n);
ll sum=0;
for(int i=1;i<=n;i++)
slld(a[i]),sum+=a[i];
sort(a+1,a+n+1);
ll ans=0;
for(int i=n;i>=1;i--)
{
	if(2*sum>=a[i+1])
		ans++;
	else break;
	sum-=a[i];
}
plld(ans);
	return 0;
           } 

Measured memory_bytes: 1024
import sys

A = []

flag_First = True
for Count in range(3):
    for x in input().split(' '):
        x.strip('\n')
        InputValue = int(x)
        if 1<=int(x)<=100:
            if flag_First==True:
                A.append (InputValue)
                flag_First = False
            else:
                for Index in A:
                    if Index == InputValue:
                        print('No')
                        sys.exit()

                A.append (InputValue)
        else:
            print('No')
            sys.exit()

N = int(input())
if N<=0 and N>10:
    print('No')
    sys.exit()

B = []
for Count in range(1,N+1):
    InputValue = int(input())
    if 1<=InputValue<=100:
        if Count == 1:
            B.append (InputValue)
        else:
            for Index in B:
                if Index == InputValue:
                    print('No')
                    sys.exit()

            B.append (InputValue)

Bingo =[0,0,0,0,0,0,0,0,0]

for Item_B in B:
    for Index,Item_A in enumerate(A):
        if Item_A == Item_B:
            Bingo[Index]= 1

def CheckHorizontalBingo(Start,End):

    Flag_Bingo = True
    for Index,Item in enumerate(Bingo):
        if Start<=Index<=End:
            if Item == 0 :
                Flag_Bingo = False

    if Flag_Bingo == True:
        print('Yes')
        sys.exit()

CheckHorizontalBingo(0,2)
CheckHorizontalBingo(3,5)
CheckHorizontalBingo(6,8)

def CheckVerticalBingo(One,Two,There):

    Flag_Bingo = True
    for Index,Item in enumerate(Bingo):
        if Index==One or Index==Two or Index==There:
            if Item == 0 :
                Flag_Bingo = False

    if Flag_Bingo == True:
        print('Yes')
        sys.exit()

CheckVerticalBingo(0,3,6)
CheckVerticalBingo(1,4,7)
CheckVerticalBingo(2,5,8)

def CheckDiagonalBingo(One,Two,There):

    Flag_Bingo = True
    for Index,Item in enumerate(Bingo):
        if Index==One or Index==Two or Index==There:
            if Item == 0 :
                Flag_Bingo = False

    if Flag_Bingo == True:
        print('Yes')
        sys.exit()

CheckDiagonalBingo(0,4,8)
CheckDiagonalBingo(2,4,6)

print('No')

Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
 
// #define int long long
 
/* short */
#define pb push_back
#define print(x) cout << x << '\n'
 
/* REPmacro */
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPS(i, a, n) for (int i = (a); i < (n); i++)
 
/* typedef */
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef pair<int, int> pii;

/* const */
const int INF = INT_MAX;
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

/* func */
inline bool is_uruu(int y) {return (y % 4 == 0 && (y % 100 != 0 || y % 400 == 0));}
  
signed main()
{
  ios::sync_with_stdio(false);
  int n;

  for (; cin >> n, n;){
    int cnt = 0;
    for (; n >= 5; n /= 5, cnt += n);
    print(cnt);
  }

  return (0);
}

Measured memory_bytes: 1192
def maxHeapify(A, i):
    global H
    l = i * 2 + 1
    r = i * 2 + 2
    if l < H and A[l] > A[i]:
        largest = l
    else:
        largest = i
    if r < H and A[r] > A[largest]:
        largest = r
    
    if largest != i:
        A[i], A[largest] = A[largest], A[i]
        maxHeapify(A, largest)    

def buildMaxHeap(A):
    global H
    for i in reversed(range(int((H + 1) / 2))):
        maxHeapify(A, i)

H = int(input())
A = list(map(int, input().split(" ")))
buildMaxHeap(A)
print(" ", end = '')
print(' '.join(map(str, A)))


Measured memory_bytes: 63696
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <iterator>
#include <string>
#include <limits>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
i64 mod = 1000000007;
int int_max = 2147483647;
i64 INF = 1e12;
int max_n = 1e5;


int main(int argc, char **argv) {
    double a,b,h,m;
    cin >> a >> b >> h >>m;

    i64 total = h*60+m;

    double ga = 0.5 * total;
    double gb = 6 * total;
    while (gb > 360) {
        gb -= 360;
    }
    double deg = abs(ga - gb);
    deg = deg / 180 * M_PI;
    double cos_d = cos(deg);

    double c = (a*a + b*b) - 2.*a*b*cos_d;

    cout << std::setprecision(20) << sqrt(c) << endl;

    return 0;
}


Measured memory_bytes: 4228
#include <iostream>
#include <unordered_set>
#include <string>

using namespace std;

int main() {
	string cmd; // while ????????´??§??????????????????????????°???????????¨??????
	int order;
	string str;
	unordered_set<string> dict;

	cin >> order;

	for (int i=0;i<order;i++) {
		cin >> cmd;
		if (cmd == "insert") {
			cin >> str;
			dict.insert(str);
		
		} else if (cmd == "find") {
			cin >> str;
			if(dict.count(str) > 0) {
				cout << "yes" << endl;
			} else {
				cout << "no" << endl;
			}
		}
	}
}

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

vector<int> Homu ; 
int find(int homu){
    if(Homu[homu] < 0)return homu;
    return Homu[homu] = find(Homu[homu]);
}
bool unite(int homu, int pura){
    homu = find(homu);
    pura = find(pura);
    if(homu == pura)return false;
    if(Homu[homu] > Homu[pura])swap(homu, pura);
    Homu[homu] += Homu[pura];
    Homu[pura] = homu;
    return true;
}
bool same(int homu, int pura){
    return find(homu) == find(pura);
}
long long size(int homu){
    return -Homu[find(homu)];
}


int main(){
    long long homuhomuhomu, homuhomu;
    cin >> homuhomuhomu >> homuhomu;
    vector<pair<int,int>> HomuPura(homuhomu);
    for(auto& homupura : HomuPura){
        cin>> homupura.first >> homupura.second ;
    }
    vector<long long > HOMU(homuhomu);
    HOMU[homuhomu - 1] = homuhomuhomu * (homuhomuhomu - 1) / 2;
    Homu.resize(homuhomuhomu + 1, -1) ;
    for(int homura = homuhomu - 2 ; homura >= 0 ; --homura){
        int homu = HomuPura[homura + 1].first, pura = HomuPura[homura + 1].second ;
        HOMU[homura] = HOMU[homura + 1];
        if(!same(homu, pura)){
            HOMU[homura] -= size(homu) * size(pura) ;
        }
        unite(homu, pura);
    }

    for(auto homu : HOMU){
        cout<<homu<<endl;
    }

    return 0;
}


Measured memory_bytes: 3328
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<vector<int> > G(N);
	for (int i = 0; i < N - 1; ++i) {
		int a, b;
		cin >> a >> b;
		--a, --b;
		G[a].push_back(b);
		G[b].push_back(a);
	}
	int M;
	cin >> M;
	vector<int> p(M), q(M);
	for (int i = 0; i < M; ++i) {
		cin >> p[i] >> q[i];
		--p[i], --q[i];
	}
	vector<int> par(N), depth(N);
	function<void(int, int)> make_order = [&](int pos, int pre) {
		par[pos] = pre;
		for (int i : G[pos]) {
			if (i == pre) continue;
			depth[i] = depth[pos] + 1;
			make_order(i, pos);
		}
	};
	make_order(0, -1);
	vector<long long> A(1 << M);
	for (int i = 0; i < M; ++i) {
		long long x = 0;
		while (p[i] != q[i]) {
			if (depth[p[i]] < depth[q[i]]) {
				swap(p[i], q[i]);
			}
			x |= 1LL << (p[i] - 1);
			p[i] = par[p[i]];
		}
		for (int j = 1 << i; j < 2 << i; ++j) {
			A[j] = A[j - (1 << i)] | x;
		}
	}
	long long ans = 0;
	for (int i = 0; i < 1 << M; ++i) {
		int parity = 0;
		for (int j = 0; j < M; ++j) {
			if ((i >> j) & 1) parity ^= 1;
		}
		long long mul = 1;
		for (int j = 0; j < N - 1; ++j) {
			if (!((A[i] >> j) & 1)) mul *= 2;
		}
		if (parity == 0) ans += mul;
		else ans -= mul;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 8448
//author: Harsh Nema
#include <bits/stdc++.h>
#define ll long long int
#define F first
#define S second
const ll mod = 1e9 + 7;
const ll INF = 922337203685477;
#define pb push_back
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;
int main()
{
    fastio;
    ll n=0;
    cin>>n;
    ll l=n%10;
    if(l==2 or l==4 or l==5 or l==7 or l==9) cout<<"hon";
    else if(l==0 or l==1 or l==6 or l==8) cout<<"pon";
    else cout<<"bon";
    return 0;
}


Measured memory_bytes: 3544
import sys
# sys.setrecursionlimit(100000)


def input():
    return sys.stdin.readline().strip()


def input_int():
    return int(input())


def input_int_list():
    return [int(i) for i in input().split()]


def main():
    n = input_int()
    L1 = [None] + list(input()) + [None]
    L2 = [None] + list(input()) + [None]
    seq = []
    if L1[1] == L2[1]:  # 縦ドミノ
        L1[1] = L2[1] = "#"
        seq.append("X")
    elif L1[1] == L1[2]:  # 横ドミノ
        L1[1] = L1[2] = L2[1] = L2[2] = "#"
        seq.append("Y")

    for i in range(1, n + 1):
        if L1[i] == "#":
            continue
        else:
            if L1[i] == L2[i]:
                seq.append("X")
                L1[i] = "#"
            elif L1[i] == L1[i + 1]:
                seq.append("Y")
                L1[i] = L1[i + 1] = "#"
    if seq[0] == "X":
        ans = 3
    elif seq[0] == "Y":
        ans = 6

    for i in range(1, len(seq)):
        if seq[i - 1] == "X":
            if seq[i] == "X":
                ans *= 2
            elif seq[i] == "Y":
                ans *= 2
        elif seq[i - 1] == "Y":
            if seq[i] == "X":
                ans *= 1
            elif seq[i] == "Y":
                ans *= 3
        ans %= 1000000007
    print(ans)
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 62208
#include <bits/stdc++.h>
 
using namespace std;
#define pb push_back
#define mp make_pair
typedef long long int ll;

int h,w,k;
bool f[803][803];


vector<string> gr(803);
vector<pair<int,int>> rqu; 
queue<pair<int,int>> qu;
int ri,rj;
void proc(int ro,int co, int ir,int jr){
    if(!f[ro+ir][co+jr]&&gr[ro+ir][co+jr]=='.'){
        //cout<<"pushlandi "<<ro+ir<<" "<<co+jr<<endl;
        qu.push(mp(ro+ir,co+jr));
        rqu.pb(mp(ro+ir,co+jr));
        
        f[ro+ir][co+jr] = 1;
    }
}

int calc(int x,int y){
    //cout<<"geldim  "<<x<<" "<<y<<" "<<ri<<" "<<rj<<endl;
    if(x==1||x==h||y==1||y==w)
        return 1;
    x = min(x-1,h-x);
    y = min(y-1,w-y);
    x = min(x,y);
    if(x%k!=0){
        x = x/k+1;
    }else{
        x = x/k;
    }
    x++;
    
    return x;
}

int main(){
    cin>>h>>w>>k;
    
    for(int i = 1;i<=h;i++){
        cin>>gr[i];
        gr[i] = " "+gr[i];
    }
    
    for(int i = 1;i<=h;i++){
        for(int j = 1;j<=w;j++){
            if(gr[i][j]=='S'){
                ri = i;
                rj = j;
            }
        }
    }
    //cout<<ri<<" "<<rj<<endl; 
    
    qu.push(mp(ri,rj));
    f[ri][rj] = 1;
    int s;
    for(int i = 0;i<k;i++){
        s = qu.size();
        for(int i = 0;i<s;i++){
            proc(qu.front().first,qu.front().second,1,0);
            proc(qu.front().first,qu.front().second,-1,0);
            proc(qu.front().first,qu.front().second,0,1);
            proc(qu.front().first,qu.front().second,0,-1);
            qu.pop();
        }
    }
    int res = 1000000000;
    int x,y;
    //cout<<rqu.size()<<" vector size"<<endl;
    if(rqu.empty()){
        x = min(ri-1,h-ri);
        y = min(rj-1,w-rj);
        x = min(x,y);
        if(x%k!=0){
            x = x/k+1;
        }else{
            x = x/k;
        }
        x++;
        cout<<x;
        return 0;
    }else{
        for(int i = 0;i<rqu.size();i++){
            res = min(res,calc(rqu[i].first,rqu[i].second));
        }
    }
    
    cout<<res;
    
    
    return 0;
}

Measured memory_bytes: 10992
package main

import "fmt"

func main() {
	var N, M int
	fmt.Scan(&N, &M)
	max := 1
	for di := 1; di*di <= M; di++ {
		if M%di != 0 {
			continue
		}
		if M/di >= N {
			max = Max(max, di)
		}
		dj := M / di
		if M/dj >= N {
			max = Max(max, dj)
		}
	}
	fmt.Println(max)
}

func Max(a, b int) int {
	if a < b {
		return b
	}
	return a
}


Measured memory_bytes: 1772
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MN = 100100;
const int A = 60;
ll w[MN];
ll fr[A];
int main() {
	ll n;
	cin >> n;
	for(int i=0;i<n;i++) {
		cin >> w[i];
		for(int j=0;j<A;j++) {
			if(w[i]&(1LL<<j)) {
				fr[j]++;
			}
		}
	}
	ll res = 0;
	ll tot = 0;
	ll ms = 0;
	int st = 0;
	for(int b=A-1;b>=0;b--) {
		if(fr[b]&1) {
			tot += 1LL<<b;
			continue;
		}
		ms |= 1LL<<b;
		ll ma = -1,mi = -1;
		for(int i=st;i<n;i++) {
			if((w[i]&(1LL<<b)) && w[i] > ma) {
				ma = w[i];
				mi = i;
			}
		}
		if(mi >= 0) {
			swap(w[mi],w[st]);
			mi = st;
			for(int i=0;i<n;i++) {
				if((w[i]&(1LL<<b)) && (i != mi)) {
					w[i] ^= ma;
				}
			}
			st++;
		}
	}
	for(int i=0;i<n;i++) {
		res ^= w[i];
	}
	tot += (res&ms)*2;
	cout << tot << '\n';
}


Measured memory_bytes: 1024
using System;
using System.IO;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder.Contest.D
{
	class Program
	{
		public static void Main(string[] args)
		{
			var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
			Console.SetOut(sw);

			Scanner cin = new Scanner();

			int n = cin.nextInt();
			int[] p = cin.ArrayInt(n);

			int ans = 0;

			for (int i = 0; i < n; i++)
			{
				if (p[i] == i + 1)
				{
					if (i != n - 1)
					{
						int x = p[i];
						p[i] = p[i + 1];
						p[i + 1] = x;
						i++;
						ans++;
					}
					else
					{
						int x = p[i];
						p[i] = p[i - 1];
						p[i - 1] = x;
						ans++;
					}
				}
			}

			for (int i = 0; i < n; i++)
			{
				if (p[i] == i + 1) Console.WriteLine("Error: "+i);
			}

			Console.WriteLine(ans);

			Console.Out.Flush();
		}
	}

	class Scanner
	{
		string[] s;
		int i;

		char[] cs = new char[] { ' ' };

		public Scanner()
		{
			s = new string[0];
			i = 0;
		}

		public string next()
		{
			if (i < s.Length) return s[i++];
			string st = Console.ReadLine();
			while (st == "") st = Console.ReadLine();
			s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
			if (s.Length == 0) return next();
			i = 0;
			return s[i++];
		}

		public int nextInt()
		{
			return int.Parse(next());
		}

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = nextInt() + add;
			}
			return Array;
		}

		public long nextLong()
		{
			return long.Parse(next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = nextLong() + add;
			}
			return Array;
		}

		public double nextDouble()
		{
			return double.Parse(next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++)
			{
				Array[i] = nextDouble() + add;
			}
			return Array;
		}
	}
}

Measured memory_bytes: 18784
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=998244353, INF=mod*mod*3LL;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
int inc(char c){
	if(c == 'R') return 0;
	else if(c == 'G') return 1;
	else return 2;
}
int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    string s;
    vector<ll> a(3),b(8);
    cin >> n >> s;
    ll ans = 1;
    for(int i=0;i<n*3;i++){
    	int c = inc(s[i]);
    	if(b[(1<<c)^7]) (ans *= b[(1<<c)^7]--) %= mod;
    	else{
    		ll num = 0;
    		for(int j=0;j<3;j++) if(j != c) num += a[j];
    		if(num){
    			(ans *= num) %= mod;
    			for(int j=0;j<3;j++){
    				if(j != c && a[j]){
    					b[(1<<j) | (1<<c)]++;
    					a[j]--;
    					break;
    				}
    			} 
    		}else a[c]++;
    	}
    }
    for(ll i=1;i<=n;i++) (ans *= i) %= mod;
    cout << ans << endl;
    return 0;
}


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

#define REP(i,n) for(int i=0; i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
using namespace std;

int main() {
	int a, b, c, x;
	cin >> a >> b >> c >> x;
	int res = 0;
	REP(i, a+1) {
		REP(j, b+1) {
			REP(k, c+1) {
				if (500 * i + 100 * j + 50 * k == x) {
					res++;
				}
			}
		}
	}
	cout << res << endl;
	return 0;
}

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

int main()
{
  int A,B,C ;
  cin>>A>>B>>C ;
  
  if(A>B&&A>C) cout<<A*10+B+C<<endl ;
  else if(B>C) cout<<B*10+A+C<<endl ;
  else cout<<C*10+A+B<<endl ;
  
  return 0 ;
}

Measured memory_bytes: 256
s = str(input())
n = len(s)
m = [0 for _ in range(n)]
for i in range(n):
  m[i] = int(s[i])
a = 0
for i in range(2**(n-1)):
  ai = 0
  tmp = 0
  for j in range(n-1):
    if ((i>>j)&1) == 1:
      ai += tmp*10+m[j]
      tmp = 0
    else:
      tmp = tmp*10+m[j]
  tmp = tmp*10 + m[n-1]
  ai += tmp
  a += ai
print(a)
  

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


typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long double ld;

typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

const int INF = 1e9 + 7;
const int MOD = 1e9 + 7;
const int MAXN = 1e6 + 3;

#define _  %  MOD
#define __ %= MOD

#define      each(it,s)        for(auto it = s.begin(); it != s.end(); ++it)
#define      sortA(v)          sort(v.begin(), v.end())
#define      sortD(v)          sort(v.begin(), v.end(), greater<auto>())
#define      fill(a)           memset(a, 0, sizeof (a))

#define      swap(a,b)        {a=a+b;b=a-b;a=a-b;}
#define      rep(i, n)         for(ll i = 0; i < (n); ++i)
#define      repA(i, a, n)     for(ll i = a; i <= (n); ++i)
#define      repD(i, a, n)     for(ll i = a; i >= (n); --i)
#define watch(x) cout << (#x) << " is " << (x) <<endl

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

#define fbo find_by_order
#define ook order_of_key

ll gcd(ll a,ll b){if(b==0) return a; else return gcd(b,a%b);}
ll power(ll x,ll y){ll res=1; while(y>0){if(y&1) res=res*x;y=y>>1;x=x*x;}return res;} // modular exponent

int main()
{
    ios_base::sync_with_stdio(false); // don't use printf and scanf
    cin.tie(NULL); // cout<<fixed<<setprecision
    ll n,m,x;
    cin>>n>>m>>x;
    vector<ll> c(n+1);
    vector<ll> a[n+1];
    rep(i,n)
    {
        cin>>c[i];
        rep(j,m)
        {
            ll val;
            cin>>val;
            a[i].pb(val);
        }
    }
    int check=0;
    ll counter=power(2,n);
    ll cost=INF;
    for(ll ctr=0;ctr<counter;ctr++)
    {
        vector<ll> temparr(m+1,0);
        ll tempcost=0;
        for(ll j=0;j<n;j++)
        {
            if(ctr & (1<<j))
            {
                tempcost+=c[j];
                rep(i,m) temparr[i]+=a[j][i];
            }
        }
        int flag=1;
        rep(i,m)
        {
            if(temparr[i] < x) flag=0;
        }
        if(flag==1)
        {
            // watch(tempcost);
            check=1;
            cost=min(cost,tempcost);
        }
    }
    if(check)
    {
        cout<<cost<<'\n';
    }
    else cout<<-1<<'\n';
    return 0;
}
// JUST ASK YOURSELF DID YOU GIVE YOUR BEST ? ISSE ZYADA
// KUCH KAR BHI NAHI SAKTE !! ENJOY AND GIVE YOUR BEST!!


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;
using vb = vector<bool>;
const ll oo = 0x3f3f3f3f3f3f3f3fLL;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define mp make_pair
#define pb push_back
#define has(c, i) ((c).find(i) != end(c))
#define FOR(i,a,b) for (ll i=(a); i<(b); i++)
#define FORD(i,a,b) for (ll i=ll(b)-1; i >= a; i--)

int main() {
  cout << fixed << setprecision(8);

  ll n, W;
  cin >> n >> W;

  vl weights(n);
  vl values(n);
  FOR(i,0,n) {
    cin >> weights[i] >> values[i];
  }

  unordered_map<ll, ll> m[n+1] = {};
  m[0][0] = 0;
  ll res = 0;

  FOR(i,0,n) {
    m[i+1] = m[i];
    for(auto a:m[i]) {
      ll val = a.first + values[i];
      ll w = a.second + weights[i];
      if(w <= W)
	res = max(res, val);
      if(has(m[i+1], val))
	m[i+1][val] = min(m[i+1][val], w);
      else
	m[i+1][val] = w;
    }
  }
  
  cout << res << endl;
}


Measured memory_bytes: 116876
#include<bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long int ll;
typedef long double ld;
const ll INF=(1LL<<62);
const ld pi=acosl((ld)-1);
const ll mod = 1000000007;
// const ll mod = 1234567;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"
#define TO_STRING(VariableName) # VariableName

template <typename T>ostream &operator<<(ostream &out,const vector<T> &v) {rep(i,(int)v.size()-1)cout<<v[i]<<" ";cout<<v[(int)v.size()-1];return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const map<T1, T2> &p) {out << "(" << p.first << ", " << p.second << ")";return out;}
template <typename T1, typename T2>ostream &operator<<(ostream &out, const pair<T1, T2> &p){out << "(" << p.first << ", " << p.second << ")";return out;}
template<class T>void debag(const T &obj){cout<<obj<<endl;}

bool solve(){
  ll n;cin>>n;
  vector<ll>a(n);
  rep(i,n)cin>>a[i];

  vector<vector<ll>>dpv(n+1,vector<ll>(n+1,INF));

  vector<ll>sum(n+1,0);
  rep(i,n)sum[i+1]=sum[i]+a[i];
  auto getCost=[&](int l,int r){
    return sum[r]-sum[l];
  };

  function<ll(ll,ll)> dp=[&](ll l,ll r){
    if(l+1==r)return dpv[l][r]=a[l];
    if(dpv[l][r]!=INF)return dpv[l][r];
    for(ll m=l+1;m<r;m++){
      chmin(dpv[l][r],dp(l,m)+dp(m,r)+getCost(l,m)+getCost(m,r));
    }
    return dpv[l][r];
  };

  cout<<dp(0,n)-sum[n]<<endl;
  return false;
}

signed main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout<<fixed<<setprecision(30);
  solve();
}


Measured memory_bytes: 1536
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while(true){
			int n = Integer.parseInt(br.readLine());

			if(n == 0) break;

			int[][] data = new int[1000][4];
			//?????????????????????
			for(int i = 0; i < data.length ; i++){
				for(int j = 0; j < data[i].length; j++){
					data[i][j] = 0;
				}
			}

			//?????????????????????
			for(int i = 0; i < n ; i++){
				String[] tmpArray = br.readLine().split(" ");

				//int ID = Integer.parseInt(tmpArray[0]);
				for(int j = 0; j < 3; j++){

					data[i][j] = Integer.parseInt(tmpArray[j]);
				}
			}

			//?????????????¨?
			//long[] result = new long[4001];
			ArrayList<SaleData> saleData = new ArrayList<SaleData>();

			/*
			for(int i = 0; i < result.length ; i++){
				result[i] = 0;
			}*/

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

				//int remain = 1000000 - result[data[i][0]];

				/*
				if(remain <= 0){
					continue;
				}
				*/

				if(data[i][1] == 0){
					continue;
				}
				//int require = remain / data[i][1] + 1;

				//if(data[i][2] >= require){
					//result[data[i][0]] = 1000000;
				//}
				//else{

				//??¢?????????ID??§????´??????????????????????????????§????????????
				boolean exist = false;
				for(int j = 0; j < saleData.size(); j++){
					if(saleData.get(j).getId() == data[i][0]){
						saleData.get(j).addResult((long)data[i][1]*data[i][2]);
						exist = true;
						break;
					}
				}
				if(!exist){
					saleData.add(new SaleData(data[i][0], (long)data[i][1]*data[i][2]));
				}
				//	result[data[i][0]] += (long)data[i][1]*data[i][2];
				//}
			}

			//????????????
			int count = 0;
			for(int i = 0; i < saleData.size(); i++){
				if(saleData.get(i).getResult() >= 1000000){
					//System.out.println(i + "result "+result[i]);
					System.out.println(saleData.get(i).getId());
					count++;
				}
			}

			if(count == 0){
				System.out.println("NA");
			}
		}
	}

}

class SaleData {
	private int id;
	private long result;

	public SaleData (int id, long result){
		this.id = id;
		this.result = result;
	}

	public void addResult (long price){
		result += price;
	}

	public int getId (){
		return id;
	}
	public long getResult(){
		return result;
	}
}

Measured memory_bytes: 27936
#include <bits/stdc++.h>
using namespace std;
int x;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    cin >> x;
    if(x >= 30)
        cout << "Yes\n";
    else
        cout << "No\n";
}


Measured memory_bytes: 3636
#include <stdio.h>
#include<string.h>

int main()
{
  int k,n;

  scanf("%d %d",&k,&n);
 
  int a[n+2];
  int i;
  int l[n+2];
  int max_l=0;
  int num=1;
  long long sum=0;
  
  for(i=0;i<=n+1;i++)
  {
    a[i]=0;
    l[i]=0;
  }
  
  for(i=1;i<=n;i++)
  {
    scanf("%d",&a[i]);
  }
  
  for(i=1;i<n;i++)
  {
   l[i]=a[i+1]-a[i];
  }
  l[n]=k-a[n]+a[1];
  
  max_l=l[1];
  for(i=2;i<=n;i++)
  {
    if(max_l<l[i])
    {
      max_l=l[i];
      num=i;
    }
  }
  
  sum=k-l[num];
/*  for(i=1;i<=n;i++)
  {
    if(i!=num)
    {
    sum+=l[i];
    }
    
  }*/
  
  printf("%lld\n",sum);
  return 0;
}


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

long gcd(long A, long B){
  if(B==0) return A;
  return gcd(B, A%B);
}

int main(){
  long A, B;
  cin >> A >> B;
  cout << A*B/gcd(A,B) << endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<stack>
#include<set>
#include<climits>
#include<cstdlib>
#include<cmath>
#include<string>
#include<iomanip>

using namespace std;

#define INF 1 << 29
#define LL long long int

LL const MOD = 1000000007;

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

    LL n,m,d;

    cin >> n >> m >> d;

    double divnum = (double)(m-1)/(double)(n*n);

    LL total = 0;

    if(n <= 2*d){
        total += n;
    }else if(d == 0){
        total += n;
    }else{
        total += 2*d;
        total += 2*(n-2*d);
    }

    cout << fixed;
    cout << setprecision(17) << (double)total*divnum << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

int d[110],w,q;

int check(int wide){
	int cnt=0;
	rep(i,0,w+1){
		if(d[i]){
			cnt=0;
		}else{
			cnt++;
		}
		if(cnt==wide) return i+1-cnt;
	}
	return -1;
}

signed main(){
	while(cin>>w>>q && !(w==0&&q==0)){
		char c;
		int id,wide;
		rep(i,0,w) d[i]=0;
		d[w]=1;

		map<int,pii> mp;
		rep(i,0,q){
			cin>>c;
			if(c=='s'){
				cin>>id>>wide;
				mp[id].first=wide;
				int ind=check(wide);
				if(ind==-1) o("impossible");
				else{
					o(ind);
					mp[id].second=ind;
					rep(j,0,wide){
						d[ind+j]=1;
					}
				}
			}else{
				cin>>id;
				rep(j,0,mp[id].first){
					d[mp[id].second+j]=0;
				}
			}
		}
		o("END");
	}
}

Measured memory_bytes: 1196
//Coded by tzc_wk
/*
数据不清空，爆零两行泪。
多测不读完，爆零两行泪。
边界不特判，爆零两行泪。
贪心不证明，爆零两行泪。
D P 顺序错，爆零两行泪。
大小少等号，爆零两行泪。
变量不统一，爆零两行泪。
越界不判断，爆零两行泪。
调试不注释，爆零两行泪。
溢出不 l l，爆零两行泪。
*/
#include <bits/stdc++.h>
using namespace std;
#define fi			first
#define se			second
#define fz(i,a,b)	for(int i=a;i<=b;i++)
#define fd(i,a,b)	for(int i=a;i>=b;i--)
#define foreach(it,v) for(__typeof(v.begin()) it=v.begin();it!=v.end();it++)
#define all(a)		a.begin(),a.end()
#define giveup(...) return printf(__VA_ARGS__),0;
#define fill0(a)	memset(a,0,sizeof(a))
#define fill1(a)	memset(a,-1,sizeof(a))
#define fillbig(a)	memset(a,0x3f,sizeof(a))
#define fillsmall(a) memset(a,0xcf,sizeof(a))
#define mask(a)		(1ll<<(a))
#define maskx(a,x)	((a)<<(x))
#define _bit(a,x)	(((a)>>(x))&1)
#define _sz(a)		((int)(a).size())
#define filei(a)	freopen(a,"r",stdin);
#define fileo(a)	freopen(a,"w",stdout);
#define fileio(a) 	freopen(a".in","r",stdin);freopen(a".out","w",stdout)
#define eprintf(...) fprintf(stderr,__VA_ARGS__)
#define put(x)		putchar(x)
#define eoln        put('\n')
#define space		put(' ')
#define y1			y_chenxiaoyan_1
#define y0			y_chenxiaoyan_0
typedef pair<int,int> pii;
inline int read(){
	int x=0,neg=1;char c=getchar();
	while(!isdigit(c)){
		if(c=='-')	neg=-1;
		c=getchar();
	}
	while(isdigit(c))	x=x*10+c-'0',c=getchar();
	return x*neg;
}
inline void print(int x){
	if(x<0){
		putchar('-');
		print(abs(x));
		return;
	}
	if(x<=9)	putchar(x+'0');
	else{
		print(x/10);
		putchar(x%10+'0');
	}
}
inline int qpow(int x,int e,int _MOD){
	int ans=1;
	while(e){
		if(e&1)	ans=ans*x%_MOD;
		x=x*x%_MOD;
		e>>=1;
	}
	return ans;
}
int n=read(),a[300005];
struct Fenwick_Tree{
	int bit[300005];
	Fenwick_Tree(){fill0(bit);}
	inline void add(int x){
		for(int i=x;i<=n;i+=(i&(-i)))	bit[i]++;
	}
	inline int sum(int x){
		int ans=0;
		for(int i=x;i;i-=(i&(-i)))	ans+=bit[i];
		return ans;
	}
};
inline vector<int> calc(vector<int> t){
	vector<int> v;Fenwick_Tree Bit;
	foreach(it,t){
		v.push_back(Bit.sum(n)-Bit.sum(*it));
		Bit.add(*it);
	}
	return v;
}
signed main(){
	fz(i,1,n)	a[i]=read();
	for(int i=1;i<=n;i+=2)	if(a[i]&1^1)	return puts("No"),0;
	for(int i=2;i<=n;i+=2)	if(a[i]&1)		return puts("No"),0;
	vector<int> b,b1,b2;
	for(int i=1;i<=n;i+=2)	b1.push_back(a[i]);	
	for(int i=2;i<=n;i+=2)	b2.push_back(a[i]);	
	for(int i=1;i<=n;i++)	b.push_back(a[i]);	
	vector<int> c=calc(b),c1=calc(b1),c2=calc(b2);
	int sum1=0,sum2=0,sum3=0;
	foreach(it,c)	sum1+=*it;
	foreach(it,c1)	sum2+=*it;
	foreach(it,c2)	sum3+=*it;
	if(sum1==(sum2+sum3)*3)	puts("Yes");
	else					puts("No");
	return 0;
}

Measured memory_bytes: 9200
#include<stdio.h>
#include<math.h>
int main(){
  int box[300000]={},i,j,n,cnt;
  for(i=2;i<=123456*2;i++)
    box[i]=1;
  for(i=2;i<=sqrt(123456*2);i++){
    if(box[i]==1){
      for(j=i*i;j<=123456*2;j+=i)
        box[j]=0;
    }
  }
  while(1){
    cnt=0;
    scanf("%d",&n);
    if(n==0)
      break;
    for(i=n+1;i<=2*n;i++)
      cnt+=box[i];
    printf("%d\n",cnt);
  }
}



Measured memory_bytes: 2896
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <cstring>
#include <ctime>
#include <unordered_map>
#include <iomanip>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(v) (v).begin(),(v).end()

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

const ll inf = (1LL<<58);


ll N,a[310][310],id[310];

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

    int i,j,k;
    for (i=1; i<=N; i++)
        for (j=1; j<=N; j++)
            cin >> a[i][j];

    bool ok=1; ll res=0;
    for (i=1; i<=N; i++){
        for (j=i+1; j<=N; j++){
            bool g=0;
            for (k=1; k<=N; k++)
                if (a[i][k]+a[k][j]<a[i][j]) ok=0;
                else if (a[i][k]+a[k][j]==a[i][j] && j!=k && i!=k) g=1;

            if (!g) res+=a[i][j];
        }
    }

    cout << (ok ? res : -1 ) << "\n";
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define MAX_V 1000
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const long long int MOD = 1000000007;
const int INF = 100000000;

struct edge{int to, cap, rev; };

vector<edge> G[MAX_V], H[MAX_V];
int level[MAX_V];
int iter[MAX_V];

void add_edge(int from, int to, int cap){
	G[from].push_back((edge){to, cap, G[to].size()});
	G[to].push_back((edge){from, cap, G[from].size()-1});
}

void bfs(int s){
	memset(level,-1,sizeof(level));
	queue<int> que;
	level[s] = 0;
	que.push(s);
	while(!que.empty()){
		int v = que.front(); que.pop();
		for(int i = 0; i < G[v].size(); i++){
			edge &e = G[v][i];
			if(e.cap > 0 && level[e.to] < 0){
				level[e.to] = level[v]+1;
				que.push(e.to);
			}
		}
	}
}

int dfs(int v, int t, int f){
	if(v == t) return f;
	for(int &i = iter[v]; i < G[v].size(); i++){
		edge &e = G[v][i];
		if(e.cap > 0 && level[v] < level[e.to]){
			int d = dfs(e.to, t, min(f,e.cap));
			if(d > 0){
				e.cap -= d;
				G[e.to][e.rev].cap += d;
				return d;
			}
		}
	}
	return 0;
}

int max_flow(int s, int t){
	int flow = 0;
	for(;;){
		bfs(s);
		if(level[t] < 0) return flow;
		memset(iter,0, sizeof(iter));
		int f;
		while((f = dfs(s, t, INF)) > 0){
			flow += f;
		}
	}
}

int n, e, q;
int x[1000], s[1000], t[1000];
set<P> saw;
int pre = 0;

int main(){
    cin >> n >> e >> q;
    rep(i,e){
        int s, t;
        cin >> s >> t;
        if(s > t) swap(s,t);
        s--; t--;
        saw.insert(P(s,t));
        add_edge(s,t,1);
    }
    rep(i,q){
        cin >> x[i] >> s[i] >> t[i];
        s[i]--; t[i]--;
        if(s[i] > t[i]) swap(s[i],t[i]);
        if(saw.count(P(s[i],t[i])) == 0){
            add_edge(s[i],t[i],0);
            saw.insert(P(s[i],t[i]));
        }
    }
    pre = max_flow(0,n-1);
    rep(i,q){
        if(x[i] == 1){
            rep(j,G[s[i]].size()){
                int rev = G[s[i]][j].rev;
                if(G[s[i]][j].to == t[i]){
                    G[s[i]][j].cap = 1;
                    G[t[i]][rev].cap = 1;
                }
            }
            pre = max_flow(0,n-1)+pre;
        } else{
            bool ok = true;
            rep(j,G[s[i]].size()){
                int rev = G[s[i]][j].rev;
                if(G[s[i]][j].cap != 1) ok = false;
                if(G[s[i]][j].to == t[i]){
                    G[s[i]][j].cap = 0;
                    G[t[i]][rev].cap = 0;
                }
            }
            if(!ok){
                rep(j,n) rep(k,G[j].size()){
                    int rev = G[j][k].rev;
                    int to = G[j][k].to;
                    if(G[j][k].cap == 2){
                        G[j][k].cap = 1;
                        G[to][rev].cap = 1;
                    }
                }
                pre = max_flow(0,n-1);
            }
        }
        cout << pre << endl;
    }
}

Measured memory_bytes: 4832
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define GET_ARRAY_SIZE(a)   (sizeof(a)/sizeof(a[0]))
#define LL long long
#define VI vector<int>
#define VL vector<LL>
#define VII vector< vector<int> >
#define VLL vector< vector<LL> >
#define VS vector<string>
#define PII pair<int,int>
#define PIS pair<int,string>
#define PSI pair<string,int>
#define PLL pair<ll,ll>
LL facctorialMethod(int k);
int main(){
    LL n,k,ans;
    cin >> n >> k;
    VL p(n);
    for(int i = 0; i < n; i++) {
        cin >> p[i];
    }
    sort(p.begin(),p.end());
    ans = 0;
    for(int i = 0; i < k; i++) {
        ans += p[i];
    }
    cout << ans << endl;


    return 0;
}

LL facctorialMethod(int k){
    int sum = 1;
    for (int i = 1; i <= k; ++i){
        sum *= i;
    }
    return sum;
}


Measured memory_bytes: 3632
import java.util.*;
public class Main{
  public static void main(String[]args){
    Scanner sc=new Scanner(System.in);
    int a=sc.nextInt();
    String s=sc.next();
    if(a>=3200){
      System.out.println(s);
    }
    if(a<=3199){
      System.out.println("red");
    }

  }
}

Measured memory_bytes: 21844
import sys
sys.setrecursionlimit(1000000000)
input = sys.stdin.readline

n=int(input())
a=list(map(int,input().split()))
q=int(input())

ans=sum(a)

x=[0]*(10**5+10)
for i in a:
    x[i]+=1


for _ in range(q):
    b,c=map(int,input().split())
    ans+=x[b]*c-x[b]*b
    print(ans)
    x[c]+=x[b]
    x[b]=0

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

#define     F       first
#define     S       second
typedef pair<int, int>  pi;
typedef long long       ll;

const ll OO=1e18+18;
int n, s, c[59], d[59];
vector< pair<int, pi> > adj[59]; // {node, {a[i], b[i]}}
ll dist[59][10009];
bool vis[59][10009];

void Dijkstra(int node) {
    for (int i=1; i<=n; ++i) {
        for (int silver=0; silver<=10000; ++silver) {
            dist[i][silver]=OO;
        }
    }

    dist[node][min(s, 10000)]=0;
    priority_queue< pair<ll, pi> > pq; // {dist, {node, silver}}
    pq.push({0, {node, min(s, 10000)}});
    while (!pq.empty()) {
        int node=pq.top().S.F,
            silver=pq.top().S.S;

        pq.pop();
        if (vis[node][silver]) {
            continue;
        }

        vis[node][silver]=1;
        for (int i=0; i<adj[node].size(); ++i) {
            int child=adj[node][i].F,
                a=adj[node][i].S.F,
                b=adj[node][i].S.S;

            if (silver>=a) {
                ll cost=dist[node][silver]+b;
                if (cost<dist[child][silver-a]) {
                    dist[child][silver-a]=cost;
                    pq.push({-cost, {child, silver-a}});
                }
            }

            if (silver+c[node]<=10000) {
                ll cost=dist[node][silver]+d[node];
                if (cost<dist[node][silver+c[node]]) {
                    dist[node][silver+c[node]]=cost;
                    pq.push({-cost, {node, silver+c[node]}});
                }
            }
        }
    }
}

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

    int m;
    cin >> n >> m >> s;
    while (m--) {
        int x, y, a, b;
        cin >> x >> y >> a >> b;
        adj[x].push_back({y, {a, b}});
        adj[y].push_back({x, {a, b}});
    }

    for (int i=1; i<=n; ++i) {
        cin >> c[i] >> d[i];
    }

    Dijkstra(1);
    for (int i=2; i<=n; ++i) {
        ll mn=OO;
        for (int silver=0; silver<=10000; ++silver) {
            mn=min(mn, dist[i][silver]);
        }

        cout << mn << " ";
    }

    return 0;
}


Measured memory_bytes: 15808
import java.util.*;
import java.lang.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        int a[] = new int[n];
        for(int i = 0; i < n; i++){
            a[i] = sc.nextInt();
        }
        int b[] = new int[n - k + 1];
        for(int i = 0; i < n - k + 1; i++){
            if (a[i] >= 0) {
                b[i] = a[i + k - 1];
            }else if (a[i + k - 1] < 0) {
                b[i] = -1 * a[i];
            }else if (-1 * a[i] > a[i + k - 1]) {
                b[i] = 2 * a[i + k - 1] - a[i];
            }else{
                b[i] = -2 * a[i] + a[i + k - 1];
            }
        }
        int min = 800000000;
        for(int i = 0; i < b.length; i++){
            min = Math.min(min, b[i]);
        }
        System.out.println(min);
    }
}

Measured memory_bytes: 50136
N = int(input())
hlist = list(map(int, input().split()))
cost = [-1 for _ in range(N)]

def dp(n):
  if n==0: return 0
  if n==1: return abs(hlist[1] - hlist[0])
  else: return min(cost[n-1]+abs(hlist[n]-hlist[n-1]), cost[n-2]+abs(hlist[n]-hlist[n-2]))

for i in range(N):
  cost[i]=dp(i)
print(cost[-1])

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

struct Node {
  int key;
  Node *prev;
  Node *next;
};

// the pointer that indicates the first element
Node *nil;

void init() {
  nil = (Node *)malloc(sizeof(Node));
  nil->prev = nil;
  nil->next = nil;
}

Node* listSearch(int key) {
  Node *cur = nil->next;
  while (cur != nil && cur->key != key) {
    cur = cur->next;
  }
  return cur;
}

void printList() {
  Node *cur = nil->next;
  int isf = 0;
  while (cur != nil) {
    if (isf++) cout << " ";
    cout << cur->key;
    cur = cur->next;
  }
  cout << endl;
}

void deleteNode(Node *t) {
  if (t == nil) return;
  t->prev->next = t->next;
  t->next->prev = t->prev;
  free(t);
}

void deleteFirst() {
  deleteNode(nil->next);
}

void deleteLast() {
  deleteNode(nil->prev);
}

void insert(int key) {
  Node *x = (Node *)malloc(sizeof(Node));
  x->key = key;
  x->next = nil->next;
  nil->next->prev = x;
  nil->next = x;
  x->prev = nil;
}

int main() {
  init();
  int n, v;
  string s;
  cin >> n;
  for (int i = 0; i < n; i++) {
    cin >> s;
    if (s == "insert") {
      cin >> v;
      insert(v);
    } else if (s == "deleteFirst") {
      deleteFirst();
    } else if (s == "deleteLast") {
      deleteLast();
    } else if (s == "delete") {
      cin >> v;
      deleteNode(listSearch(v));
    }
  }
  printList();
}



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

int divider(string str){
  int maxi=-1;
  for(int k=0;k < str.size();k++){
    string s1 = str.substr(0,k);
    string s2 = str.substr(k);
    maxi = max(maxi, atoi(s1.c_str())*atoi(s2.c_str()));
  }
  if(maxi/10) return maxi;
  else return 0;
}

string changer(int a){
  stringstream ss;
  ss << a;
  return ss.str();
}

int main()
{
  int n;
  cin >> n;
  for(int i=0;i < n;i++){
    string str;
    cin >> str;
    
    int cnt=0;
    int judge;
    string ss=str;
    
    while(judge = divider(ss)){
      ss = changer(judge);
      cnt++;
    }
    if(str.size() != 1){
      cout << cnt+1 << endl;
    }
    else cout << cnt << endl;
  }
  return 0;
}


Measured memory_bytes: 3244
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)
#define pcnt __builtin_popcountll
#define rng(a) a.begin(), a.end()
#define sz(x) (int)(x).size()
#define v(T) vector<T>
#define vv(T) v(v(T))

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
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; }

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

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

    rep(i, 3) rep(j, 3) {
        char c;
        cin>>c;
        if (i == j) cout<<c;
    }
    cout<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;

const int P=30000;

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

  if(N==3){
    cout<<"2 5 63"<<endl;
    return 0;
  }else if(N==4){
    cout<<"2 5 20 63"<<endl;
    return 0;
  }

  vector<int> ans;
  ans.push_back(2);
  ans.push_back(8);
  ans.push_back(14);
  ans.push_back(3);
  ans.push_back(9);

  vector<int> t;
  for(int i=2;i<=P;i+=2){
    if(i%3==1) t.push_back(i);
    if(t.size()==3){
      for(auto x:t) ans.push_back(x);
      t.clear();
    }

    if(ans.size()+3>N) break;
  }
  vector<int> f;
  for(int i=16;i<=P;i+=2){
    if(i%3==2) f.push_back(i);
    if(f.size()==3){
      for(auto x:f) ans.push_back(x);
      f.clear();
    }

    if(ans.size()+3>N) break;
  }

  for(int i=0;i<min(min(N-ans.size(),t.size()),f.size());i++){
    ans.push_back(t[i]);
    ans.push_back(f[i]);
  }

  t.clear();
  for(int i=12;i<=P;i+=3){
    if(i%2!=0) t.push_back(i);
    if(t.size()==2){
      for(auto x:t) ans.push_back(x);
      t.clear();
    }

    if(ans.size()+2>N) break;
  }

  for(int i=1;i<=P;i++){
    if(ans.size()==N) break;
    if(i%6==0){
      ans.push_back(i);
    }
  }
  for(auto v:ans) cout<<v<<" ";
  cout<<endl;

  return 0;
}


Measured memory_bytes: 512