akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

class Main{
    static int w,h;
    static String[][] fieldS;
    static int[][] fieldI;
    static List<String> numList;

    public static void main(String[] args){
	Scanner sc = new Scanner(System.in);

	numList = new ArrayList<String>();
	for(int i=0; i<10; i++){
	    String num = Integer.toString(i);
	    numList.add(num);
	}

	w = sc.nextInt();
	h = sc.nextInt();

	while(w!=0 && h!=0){
	    fieldS = new String[h][w];
	    for(int i=0; i<h; i++){
		for(int j=0; j<w; j++){
		    fieldS[i][j] = "";
		}
	    }
	    fieldI = new int[h][w];

	    for(int i=0; i<h; i++){
		String line = sc.next();
		for(int j=0; j<w; j++){
		    if(numList.contains(line.substring(j,j+1))){
			fieldI[i][j] = Integer.parseInt(line.substring(j,j+1));
		    }else{
			fieldI[i][j] = -1;
		    }
		}
	    }

	    String ans = solve();
	    if(!ans.equals("-1") && !ans.equals(""))System.out.println(ans);
	    else if(ans.equals("-1"))System.out.println(1);
	    else System.out.println(0);

	    w = sc.nextInt();
	    h = sc.nextInt();
	}
    }

    public static String solve(){
	String up = "";
	String left = "";
	boolean hantei = false;
	for(int i=0; i<h; i++){
	    for(int j=0; j<w; j++){
		if(fieldI[i][j]!=-1){
		    hantei = false;
		    if(i-1>=0){up = fieldS[i-1][j]; hantei=true;}
		    if(j-1>=0){left = fieldS[i][j-1]; hantei=true;}
		    if(hantei ||(i==0 && j==0)){
			String select = getLargerOne(up,left);
			fieldS[i][j] = select + Integer.toString(fieldI[i][j]);
			if(fieldS[i][j].equals("0")){fieldS[i][j]="";}
			up = "";
			left = "";
		    }else {fieldS[i][j]=Integer.toString(fieldI[i][j]);}
		}
	    }
	}
	String max = getMax();
	return max;
    }

    public static String getLargerOne(String up, String left){

	if(up.length()>left.length()){return up;}
	else if(left.length()>up.length()){return left;}

	for(int i=0; i<up.length(); i++){
	    int upI = Integer.parseInt(up.substring(i,i+1));
	    int leftI = Integer.parseInt(left.substring(i,i+1));
	    if(upI>leftI){return up;}
	    else if(leftI>upI){return left;}
	}
	return up;
    }

    public static String getMax(){
	int maxLen = 0;
	List<String> sameLen = new ArrayList<String>();
	for(int i=0; i<h; i++){
	    for(int j=0; j<w; j++){
		if(fieldS[i][j].length()>maxLen){
		    maxLen = fieldS[i][j].length();
		}
	    }
	}

	for(int i=0; i<h; i++){
	    for(int j=0; j<w; j++){
		if(fieldS[i][j].length()==maxLen){
		    sameLen.add(fieldS[i][j]);
		}
	    }
	}
	if(sameLen.size()==1){return sameLen.get(0);}
	int maxInt = 0;
	for(int i=0; i<maxLen; i++){
	    maxInt = 0;
	    for(int j=0; j<sameLen.size(); j++){
		String a = sameLen.get(j);
		//System.out.println(a);
		int num = Integer.parseInt(a.substring(i,i+1));
		if(num>maxInt){
		    maxInt = num;j=-1;
		}
		else if(num<maxInt){sameLen.remove(j); j--;}
		else if(num==maxInt && i==maxLen-1 && j==sameLen.size()-1){return sameLen.get(0);}
		if(sameLen.size()==1){return sameLen.get(0);}
	    }
	}
	return "-1";
    }
}

Measured memory_bytes: 16000
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"
#include "numeric"
#include "cassert"
#include "functional"

using namespace std;

//constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-8;

//int N, M, K, H, W, L, R;
long long int N, M, K, H, W, L, R;



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

	cin >> N >> M;
	int bef = -MOD;
	for (int i = 1 + M; i <= N; i += M * 2 + 1) {
		bef = i;
		K++;
	}
	if (bef + M < N)K++;
	cout << K << endl;
}


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

int main()
{
  int n, n1, n2, i, j;
  cin >> n;
  n1 = n / 4;
  n2 = n / 7;

  for(i=0; i<=n1; i++) {
    for(j=0; j<=n2; j++) {
      if(i*4+j*7==n) {
	cout << "Yes";
	return 0;
      }
    }
  }
  cout << "No";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//#define LOCAL
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
#define forn(i,a,b) for(int i=a;i<b;i++)
#define ft first
#define sd second
#define sz size()
#define pb push_back
#define pob pop_back()
#define pf push_front
#define pof pop_front()
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;
typedef pair<double,double> pdd;
typedef pair<long long,long long> pll;
//cout << fixed << setprecision(12) <<x<<endl;

int main(){
fastIO;
#ifdef LOCAL
     freopen("in.txt", "r", stdin);
#endif
int n,m;
cin>>n>>m;
vector<pii> v;
forn(i,0,m){
    int x,y;
    cin>>x>>y;
    v.pb({x,y});
}
int L=-1,M=n;
for(auto &x:v){
    L=max(L,x.ft);
    M=min(M,x.sd);
}
    int ans=(M-L)+1;
    //cout<<max((M-L)+1,1)<<endl;
    if(ans<0) ans=0;
    cout<<ans<<endl;
    

}


Measured memory_bytes: 4228
#include <bits/stdc++.h>
#pragma GCC optimize ("O3")
#pragma GCC target ("avx2") 
#pragma GCC optimization ("unroll-loops")


using namespace std;
using ll = long long;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define ff first
#define ss second
#define Ceil(x, y) ((x+y-1)/y)
#define pb(x) push_back(x)
#define eb(x) emplace_back(x);
const int mod = (int) 1e9 + 7;


void solve()
{
	int n;
	cin>>n;
	int cnt = 0;
	bool flag = false;
	for(int i=0; i<n; i++)
	{
		int e1, e2;
		cin>>e1>>e2;
		if(e1 == e2)
			cnt++;
		else
			cnt = 0;
		if(cnt == 3)
			flag = true;
	}
	cout<<(flag? "Yes" : "No");
}

int main(int argc, char *argv[])
{
	clock_t clk_start = clock();
	fast;
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
 
	int cases = 1;
	// cin>>cases;
	for(int i=1; i<=cases; i++)
	{
		// cout<<"Case #"<<i<<": ";
		solve();
	}
	cerr<<"Execution Time: "<<fixed<<double(clock() - clk_start)/double(CLOCKS_PER_SEC)<<setprecision(6)<<" sec\n"; 
}

Measured memory_bytes: 3788
#include<stdio.h>

int main(void)
{
	char c;
	scanf("%c", &c);
	if (c == 'a')
		printf("vowel\n");
	else if (c == 'i')
		printf("vowel\n");
	else if (c == 'u')
		printf("vowel\n");
	else if (c == 'e')
		printf("vowel\n");
	else if (c == 'o')
		printf("vowel\n");
	else
		printf("consonant\n");
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<string>
using namespace std;
#define MOD 1000000007
int main(){
  int n; cin >> n;
  string s; cin >> s;
  vector<long long int> l,r;
  int parity = 0;
  for(int i=0;i< 2*n;i++){
    if(parity < 0){cout << 0 << endl; return 0;}
    if(parity==0 && s[i]=='W'){cout << 0 << endl; return 0;}
    if((parity%2==1) == (s[i]=='W')) {parity++; l.push_back(i);}
    else {parity--; r.push_back(i);}
  }
  if(parity != 0 || (r.size() != n) || (l.size()!=n) ){cout << 0 << endl; return 0;}
  long long int ans = 1;
  for(int i=n-1; i>=0; i--){
  	int num = n - (n-1-i) - (lower_bound(r.begin(), r.end(), l[i]) - r.begin());
    ans = (ans * num) % MOD;
  }
  for(int i=1;i<=n;i++){
    ans = (ans * i) % MOD;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3320
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b;
  cin>>a>>b;
  int ans;
  if((a+b)%2==0) {
    ans=(a+b)/2;
    cout<<ans<<endl;
    
  }
  else{
    cout<<"IMPOSSIBLE"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
import sys

N, Y = (int(x) for x in input().split())
t = Y // 1000
z = t % 5 - 5

while z <= N:
    z += 5
    x = (t-z-5*(N-z))//5
    if x < 0:
        continue
    y = N-z-x
    if y < 0:
        continue
    if 10*x + 5*y + z == t:
        print('{} {} {}'.format(x, y, z))
        sys.exit()

print('-1 -1 -1')


Measured memory_bytes: 3064
import java.util.*;
import java.io.*;

 public class Main{
// taking inputs
static BufferedReader s1;
static BufferedWriter out;
static String read() throws IOException{String line="";while(line.length()==0){line=s1.readLine();continue;}return line;}
static int int_v (String s1){return Integer.parseInt(s1);}
static long long_v(String s1){return Long.parseLong(s1);}
static int[] int_arr() throws IOException{String[] a=read().split(" ");int[] b=new int[a.length];for(int i=0;i<a.length;i++){b[i]=int_v(a[i]);}return b;}
static long[] long_arr() throws IOException{String[] a=read().split(" ");long[] b=new long[a.length];for(int i=0;i<a.length;i++){b[i]=long_v(a[i]);}return b;}
static void assign(){s1=new BufferedReader(new InputStreamReader(System.in));out=new BufferedWriter(new OutputStreamWriter(System.out));}
static long Modpow(long a,long p,long m){long res=1;while(p>0){if((p&1)!=0){res=(res*a)%m;}p >>=1;a=(a*a)%m;}return res;}
static long Modmul(long a,long b,long m){return ((a%m)*(b%m))%m;}
static long ModInv(long a,long m){return Modpow(a,m-2,m);}
static long nck(int n,int r,long m){if(r>n){return 0l;}return Modmul(f[n],ModInv(Modmul(f[n-r],f[r],m),m),m);}
static long[] f;
static long mod=(long)1e9+7;
//......................................@uthor_Alx..............................................
  static boolean ok(int[] a, int k,int m){
  		long c=0;
  		for(int i=0;i<a.length;i++){
  			if(a[i]>m) c+=a[i]/m;
  		}
  		return c<=k;
  }
   public static void main(String[] args) throws  IOException{
				assign();
				int t=1;//int_v(read()),cn=1;
				while(t--!=0){
					int[] x=int_arr();
					int n=x[0],k=x[1];
					int l=1,r=0;
					int[] a=int_arr();
					for(int z:a){r=Math.max(r,z);}
					while(l<r){
						int m=(l+r)>>1;
						if(ok(a,k,m)){
							r=m;
						}
						else{
							l=m+1;
						}
					}
					out.write(r+"");
				}
			    
			    out.flush();

	}
}
	       

	       


Measured memory_bytes: 63580
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

long long get(long long N, long long x)
{
  const auto m = (N / x) - 1;
  return (m && N % m == x) ? m : 0LL;
}

int main(int argc, char* argv[])
{
  using std::cin;
  using std::cout;
  std::ios::sync_with_stdio(false);
  cin.tie(nullptr);

  long long N;
  cin >> N;

  long long res = 0;
  for (int i = 1; i <= N/i; ++i)
  {
    if (N % i) continue;
    res += get(N, i);
    if (N/i != i) res += get(N, N/i);
  }
  cout << res << "\n";

  return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vi vector<int>
typedef long long ll;

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

  vi rm(N);rm[N - 1] = 0;
  vi lm(N);lm[0] = 0;
  for(int i = 1;i < N;++i){
    lm[i] = ((S[i - 1] == 'W') ? lm[i - 1] + 1 : lm[i - 1]);
  }
  for(int i = N - 2;i >= 0;--i){
    rm[i] = ((S[i + 1] == 'E') ? rm[i + 1] + 1 : rm[i + 1]);
  }
  int minv = 300000;
  for(int i = 0;i < N;++i)
    minv = min(minv, lm[i] + rm[i]);
  cout << minv;
}


Measured memory_bytes: 2948
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<queue>
#include<cmath>
#include <numeric>
#include<iomanip>
#include <cstdint>

using namespace std;

vector<vector<int>>to;
vector<vector<int>>id;
vector<int>ans;

void dfs(int v, int c = -1, int p = -1) {
	int k = 1;
	for (int i = 0; i < to[v].size();i++) {
		int u = to[v][i];
		int ei = id[v][i];
		if (u == p) {
			continue;
		}
		if (k == c) {
			++k;
		}
		ans[ei] = k;
		++k;
		dfs(u, ans[ei], v);
	}
}

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

	to.resize(n);
	id.resize(n);
	ans.resize(n - 1);
	for (int i = 0; i < n-1; i++) {
		int a, b;
		cin >> a >> b;
		--a;
		--b;
		to[a].push_back(b);
		to[b].push_back(a);
		id[a].push_back(i);
		id[b].push_back(i);
	}
	dfs(0);
	int m = 0;
	for (int i = 0; i < n; i++) {
		m = max(m, int(to[i].size()));
	}
	cout << m << endl;
	for (int i = 0; i < ans.size(); i++) {
		cout << ans[i] << endl;
	}
}

Measured memory_bytes: 12032
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define NMAX 10000

int main(){
  unsigned short *A, *B;

  int C[NMAX+1];
  int n, i, j;
  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  for ( i = 0; i <= NMAX; i++ ) C[i] = 0;

  for ( i = 0; i < n; i++ ){
    scanf("%hu", &A[i + 1]);
    C[A[i + 1]]++;
  }

  for ( i = 1; i <= NMAX; i++ ) C[i] = C[i] + C[i - 1];

  for ( j = 1; j <= n; j++ ){
    B[C[A[j]]] = A[j];
    C[A[j]]--;
  }

  for ( i = 1; i <= n; i++ ){
    if ( i > 1 ) printf(" ");
    printf("%d", B[i]);
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 8464
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>

// Remove GCC optimizer for codechef
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;
using namespace __gnu_pbds;

  #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  #define int long long
  #define endl "\n"
  #define all(v) v.begin(),v.end()
  #define double long double
  #define trace1(x)                cerr<<#x<<": "<<x<<endl
  #define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
  #define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
  #define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
  #define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<< ": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
  #define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
  #define cases int testcases;cin>>testcases; while(testcases--)
  const int N = 500005;


int par[N];

void make_set(int n)
{
  for(int i = 0; i <= n; i++)par[i] = i;
}
int getParent(int s)
{
  if(s == par[s])return par[s];
  else return par[s] = getParent(par[s]);
}
void join(int a,int b)
{
  a = getParent(a);
  b = getParent(b);
  if(a != b)par[b] = a;
}

int32_t main()
{



    int n,m;
    cin >> n >> m;

    make_set(n);
    map<int,int> mp;

    for(int i = 1; i<= m; i++)
    {
      int x,y,z;

      cin >> x >> y >> z;
      join(x,y);
    }


    set<int> s;

    for(int i = 1; i <= n; i++)
    {
      s.insert(getParent(i));
    }

    cout << s.size();





    return 0;
}

Measured memory_bytes: 5760
#include <iostream>
#include<iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e9+7
#define rep(i,m,n) for(int i=m;i<n;i++)
#define mrep(i,m,n) for(int i=m;i>n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;


//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない

int main() {

	ll n, k, m = 0;

	cin >> n >> k;

	ll num[100000] = { 0 };

	rep(i, 0, n) {
		ll a, b;
		cin >> a >> b;
		num[a - 1] += b;
		m = max(m, a);
	}

	rep(i, 0, m) {
		k = k - num[i];
		if (k <= 0) {
			cout << i + 1 << endl;
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 1024
import sys


def xxx(val, op):
    target = []
    for i, o in enumerate(op):
        if sum([val[k] for k in o]) == 0:
            return []
        k0 = o[0]
        k1 = o[1]
        if val[k0] == 0:
            p, m = k0, k1
        elif val[k1] == 0:
            p, m = k1, k0
        elif i < len(op) - 1 and k1 in op[i+1]:
            p, m = k1, k0
        else:
            p, m = k0, k1
        val[p] += 1
        val[m] -= 1
        target.append(p)
    return target


n, a, b, c = [int(x) for x in input().split()]
op = [sys.stdin.readline().strip() for _ in range(n)]
val = {"A": a, "B": b, "C": c}

target = xxx(val, op)
if len(target) == 0:
    print("No")
else:
    print("Yes")
    for t in target:
        print(t)


Measured memory_bytes: 17016
#define _USE_MATH_DEFINES
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<string>
#include<set>
#include<map>
#include<stdbool.h>
#include<math.h>
#include<sstream>
#include<math.h>
#include<vector>
#include<functional>
#include<queue>
#include<utility>
#include<bitset>
typedef long long ll;
#define N (1000000000+7)
#define INF 1e16
using namespace std;
typedef pair<ll, ll> P;

int main(void) {
	int n, k;
	cin >> n >> k;
	cout << n - k + 1 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
const long long MOD = 1000000007LL;
const string alpha = "abcdefghijklmnopqrstuvwxyz";
int main(){
    int n;
    cin >> n;
    vector<string> s;
    vector<int> a;
    string ss;
    int aa;
    map<string,vector<int>> mp1;
    map<int,int> mp2;
    rep(i,n){
        cin >> ss >> aa;
        s.push_back(ss);
        a.push_back(aa);
        mp1[ss].push_back(aa);
        mp2[aa] = i+1;
    }
    sort(s.begin(),s.end());
    bool fl = true;
    string sss;
    rep(i,n){
        if(mp1[s[i]].size() == 1){
            cout << mp2[mp1[s[i]][0]] << endl;
            fl = true;
        }
        else{
            if(s[i] != sss){
            sort(mp1[s[i]].begin(),mp1[s[i]].end(),greater<int>());
            rep(j,mp1[s[i]].size()){
                cout << mp2[mp1[s[i]][j]] << endl;
            }
            sss = s[i];
            }
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
using namespace std;
typedef long long int ll;
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n,r; cin >> n >> r;
    if(n>=10){
        cout << r << endl;
    }else{
        cout << r+100*(10-n) << endl;
    }
}

Measured memory_bytes: 892
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int N = sc.nextInt();
		String s = sc.next();
		
		char[] c = s.toCharArray();
		StringBuilder sb = new StringBuilder();
		
		for(int i=0;i<c.length-1;i++) {		
			if(c[i] == c[i+1]) {
				continue;
			}
			sb.append(c[i]);
		}
		sb.append(c[c.length-1]);
		
		System.out.println(sb.toString().length());
		
		sc.close();
	}
}

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

int main(){
    int n, a[1000];
    cin >> n;

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

    for (int i = 0; i < n - 1; ++i) cout << a[i] << " ";

    cout << a[n-1] << endl;

    for (int i = 1; i < n; i++){
        int v = a[i];
        int j = i - 1;
        while (j >= 0 && a[j] > v){
            a[j+1] = a [j];
            j--;
        }
        a[j+1] = v;

        for (int k = 0; k < n - 1; ++k) cout << a[k] << " ";
        cout << a[n-1] << endl;
    }

}



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

int main() {
  int N;
  cin >> N;
  int M=100;
  for(int i=0; i<N; i++){
    int A;
    cin >>A;
    int j=0;
    while (A%2==0){
      A/=2;
      j++;
    }
    if(j<M){
      M=j;
    }
  }
  cout<<M<<endl;
  
}


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

int n, k, x, y;

int main()
{
    while (~scanf("%d%d%d%d", &n, &k, &x, &y)) {
        int fst = min(n, k);
        int snd = n - fst;
        unsigned long long ans = fst*x + snd*y;
        printf("%lld\n", ans);
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int a,b;
	char op=0;
	
	while(1){
			scanf("%d %c %d",&a,&op,&b);
			if(op=='+'){
				printf("%d\n",a+b);
			}else if(op=='-'){
				printf("%d\n",a-b);
			}else if(op=='*'){
				printf("%d\n",a*b);
			}else if(op=='/'){
				printf("%d\n",a/b);
			}else if(op=='?'){
				break;
			}
	}
	return 0;
}


Measured memory_bytes: 2076
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,ans,b,c,i,j,x;
	ans=0;
	cin>>a>>b>>c>>x;
	for(i=0;i<=a;i++)
	{
		for(j=0;j<=b;j++)
		{
			if(x-i*500-j*100>=0&&x-i*500-j*100<=c*50)
			{
				ans++;
			}
		}
	}
	cout<<ans;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring> 
#include<cassert>
#include<cmath>
#include<sstream>
#include<fstream>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<bitset>
using namespace std;
int n,k;
int num[100005];
vector<int> nei[100005];
vector<pair<int,int> > nenei[100005];
int mival[100005],maval[100005];
bool vis[100005];
int val[100005];
bool node[100005];
bool puq[100005];
const int INF=1e9;
int ans[100005];
void bfs1(){
	for(int i=0;i<n;i++) mival[i]=-INF;
	priority_queue<pair<int,int> >q;
	for(int i=0;i<n;i++){
		if(val[i]!=-1) {
			mival[i]=val[i];
			vis[i]=1;
			node[i]=1;
			puq[i]=1;
			q.push(make_pair(mival[i],i));
		}
	}
	while(!q.empty()){
		int v=q.top().second,nu=q.top().first;q.pop();
		if(vis[v]&&!node[v])continue;
		vis[v]=1;
		for(int i=0;i<nei[v].size();i++){
			int u=nei[v][i];
			if(vis[u])continue;
			if(mival[u]!=-INF&&abs(mival[u])%2!=abs((nu-1)%2)){
				cout<<"No";
				exit(0);
			}
			if(mival[u]<nu-1){
				q.push(make_pair(nu-1,u));
				mival[u]=nu-1;
			}
		}
	}
}
void bfs2(){
	for(int i=0;i<n;i++) maval[i]=INF;
	memset(vis,0,sizeof vis);
	memset(node,0,sizeof node);
	priority_queue<pair<int,int> >q;
	for(int i=0;i<n;i++){
		if(val[i]!=-1) {
			maval[i]=val[i];
			vis[i]=1;
			node[i]=1;
			puq[i]=1;
			q.push(make_pair(-maval[i],i));
		}
	}
	while(!q.empty()){
		int v=q.top().second,nu=q.top().first;q.pop();
		if(vis[v]&&!node[v])continue;
		vis[v]=1;
		for(int i=0;i<nei[v].size();i++){
			int u=nei[v][i];
			if(vis[u])continue;
			if(maval[u]!=INF&&abs(mival[u])%2!=abs((-nu+1)%2)){
				cout<<"No";
				exit(0);
			}
			if(maval[u]>-nu+1){
				q.push(make_pair(nu-1,u));
				maval[u]=-nu+1;
			}
		}
	}
}
void dfs(int v,int pa){
//	cout<<v<<" "<<ans[v]<<endl;
	for(int i=0;i<nei[v].size();i++){
		int u=nei[v][i];
		if(u==pa) continue;
		if(ans[v]+1>=mival[u]&&ans[v]+1<=maval[u]){
			ans[u]=ans[v]+1;
			dfs(u,v);
		}
		else if(ans[v]-1>=mival[u]&&ans[v]-1<=maval[u]){
			ans[u]=ans[v]-1;
			dfs(u,v);
		}
		else{
			cout<<"No";
			exit(0);
		}
	}
} 
int main(){
	scanf("%d",&n);
	for(int i=0;i<n-1;i++){
		int x,y;
		scanf("%d %d",&x,&y);
		x--,y--;
		nei[x].push_back(y);
		nei[y].push_back(x);
	}
	scanf("%d",&k);
	memset(val,-1,sizeof val);
	int root;
	for(int i=0;i<k;i++){
		int x,y;
		scanf("%d %d",&x,&y);
		x--;
		root=x;
		val[x]=y;
	}
	bfs1();
	bfs2();
	ans[root]=val[root];
//	cout<<"hahh";
//	for(int i=0;i<n;i++)cout<<i<<" "<<mival[i]<<","<<maval[i]<<endl;
	dfs(root,-1);
	cout<<"Yes"<<endl;
	for(int i=0;i<n;i++){
		cout<<ans[i]<<endl;
	}
	return 0;
}

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

using namespace std;
#define ll long long
const int mxN=1e5;

int main(){
//#ifndef ONLINE_JUGDE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
//#endif
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	ll x=max(a*c,a*d);
	ll y=max(b*c,b*d);
	cout<<max(x,y);
	return 0;
}

/*
*/




Measured memory_bytes: 3616
#include <stdio.h>

int main(){
	int n, b, f, r, v;
	int i, j, k;
	int A[4][3][10];

	for(i=0; i<4; i++) {
		for(j=0; j<3; j++) {
			for(k=0; k<10; k++) {
				A[i][j][k] = 0;
			}
		}
	}
	
	scanf("%d", &n);

	for(i=0; i<n; i++) {
		scanf("%d %d %d %d", &b, &f, &r, &v);
		A[b-1][f-1][r-1] += v;
	}

	for(i=0; i<4; i++) {						// building
		if(i != 0){
			printf("####################\n");
		}
		for(j=0; j<3; j++) {					// floor
			for(k=0; k<10; k++) {				// room
				printf(" %d", A[i][j][k]);
			}
			printf("\n");
		}
	}
	return 0;
}

Measured memory_bytes: 612
import numpy as np
N = int(input())
a = np.zeros(N+1)
for i in range(N):
    a[i+1] = int(input())
i = 1
n = 0
for j in range(N):
    n = n+1
    i = a[i]
    if i == 2:
        print(n)
        break
if i!=2:
    print(-1)

Measured memory_bytes: 22168
import java.util.*;

public class Main{
	public static void main(String args[]){
		Scanner in = new Scanner(System.in);
		int a =in.nextInt(), b = in.nextInt(), c = in.nextInt();
		int count = 0;
		if(a!=b) {
			count++;
		}
		if(b!=c) {
			count++;
		}
		if(a!=c) {
			count++;
		}
		if(count == 3) {
			System.out.println("3");
			//System.out.print("Three different colors: \n"+a+", "+b+" and "+c+".");
		}
		if(count == 2) {
			if(a==c) c = b;
			System.out.println("2");
			//System.out.print("Two different colors: "+a+" and "+c+".");
		}
		if(count == 0) {
			System.out.println("1");
			//System.out.print("One different color: \r\n"+a+".");
		}
		in.close();
	}
}

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

int main(){
	int n;
	cin >> n;
	string s;
	cin >> s;
  
  	if((s.length() % 2) != 0 ){
      cout << "No";
      return 0;
    }

	if( s.substr(0,n/2).compare(s.substr(n/2,n/2)) == 0 )
		cout << "Yes";
	else
		cout << "No";

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int arr[1000005];
int dp[1000005];
int N,K;
int dpa(int curN){
//  int mal = abs(arr[lInd]-arr[curN]);
if(curN<=0) return 1e18 ;
  if (curN == 1) return 0;
if (curN == 2) return abs(arr[2]-arr[1]);
  if(dp[curN]!=-1) return dp[curN];
  int locmin=1e18;
  for(int i=1;i<=K&& curN-i>0 ;i++)
    locmin = min(locmin,dpa(curN-i)+abs(arr[curN]-arr[curN-i]));
  return dp[curN]= locmin;
}

//   if(dp[curN]!=-1) dp[curN]=min(dp[curN],dp[lInd]+mal);
// else { dpa(curN-1,curN);
//       dpa(curN-2,curN);}
//



int main() {


int aN =N-1;
memset(dp,-1,sizeof(dp));
//scanf("%d %d", &N,&K);
cin>>N>>K;
//cout<<K<<"asd\n";
for (size_t i = 0; i < N; i++) {
//cout<<N<<"as43d\n";
cin>> arr[i+1];
//cout<<endl<<arr[i];
}
int mal=0;int curN=1;

cout<<dpa(N)<<endl;

  return 0;
}


Measured memory_bytes: 11008
k,n=gets.chomp.split(" ").map(&:to_i);
as=gets.chomp.split(" ").map(&:to_i);

betweenDistances = []
betweenDistances.push(as[0] + (k - as[-1]))

as.each_with_index do |a,i|
    #print i
    if i == as.length - 1
        break
    end
    #puts as[i + 1] - a
    betweenDistances.push(as[i + 1] - a)
end

print k - betweenDistances.max

Measured memory_bytes: 30532
#include <iostream>
#include <vector>
#include <algorithm>

constexpr int INF = 1145141919;


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

    int N, A, B;
    std::cin >> N >> A >> B;

    std::string S;
    std::cin >> S;

    int sanka_all    = 0;
    int sanka_kaigai = 0;
    for(int i=0; i<N; i++){
        if( S[i] == 'a' ){
            if( sanka_all<A+B ){
                sanka_all++;
                std::cout << "Yes" << '\n';
            }else{
                std::cout << "No" << '\n';
            }
        }else if( S[i] == 'b' ){
            if( sanka_all<A+B && sanka_kaigai<B ){
                sanka_kaigai++;
                sanka_all++;
                std::cout << "Yes" << '\n';
            }else{
                std::cout << "No" << '\n';
            }
        }else{
            std::cout << "No" << '\n';
        }
    }

    return 0;
}


Measured memory_bytes: 848
N = int(input())
S = [int(input()) for i in range(N)]
S.sort()
A = [0]*2
for s in S:
    if s%10==0:
        A[0]+=1
    else:
        A[1]+=1
if A[1]==0:
    print(0)
elif sum(S)%10==0:
    for s in S:
        if s%10!=0:
            print(sum(S)-s)
            break
else:
    print(sum(S))

Measured memory_bytes: 3064
S = input()
l = len(S)
A,B,C,q = [0]*l,[0]*l,[0]*l,[0]*l
inf = 1000000007
for i in range(l):
    if S[i] == 'A':
        A[i] = 1
    elif S[i] == 'B':
        B[i] = 1
    elif S[i] == 'C':
        C[i] = 1
    else:
        q[i] = 1

for i in range(l-1):
    A[i+1] += A[i]
    B[i+1] += B[i]
    C[i+1] += C[i]
    q[i+1] += q[i]

ans = 0
for i in range(1,l-1):
    if S[i] == 'B':
        ans += (A[i-1]) * (C[-1]-C[i]) * pow(3,q[-1],inf)
        ans %= inf
        if q[-1] >= 1:
            ans += (q[i-1]) * (C[-1] - C[i]) * pow(3,q[-1]-1,inf)
            ans %= inf
            ans += (A[i-1]) * (q[-1] - q[i]) * pow(3,q[-1]-1,inf)
            ans %= inf
        if q[-1] >= 2:
            ans += (q[i-1]) * (q[-1] - q[i]) * pow(3,q[-1]-2,inf)
            ans %= inf

    elif S[i] == '?':
        ans += (A[i-1]) * (C[-1]-C[i]) * pow(3,q[-1]-1,inf)
        ans %= inf
        if q[-1] >= 2:
            ans += (q[i-1]) * (C[-1] - C[i]) * pow(3,q[-1]-2,inf)
            ans %= inf
            ans += (A[i-1]) * (q[-1] - q[i]) * pow(3,q[-1]-2,inf)
            ans %= inf
        if q[-1] >= 3:
            ans += (q[i-1]) * (q[-1] - q[i]) * pow(3,q[-1]-3,inf)
            ans %= inf

print(ans%inf)


 

Measured memory_bytes: 45676
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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;
}
template <typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts)
{
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v)
{
    for (auto &e : t)
        fill_v(e, v);
}
int main()
{
    ll A, B, C;
    cin >> A >> B >> C;
    ll ans = 0;
    ans = min(C,A+B+1)+B;

    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

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

using namespace std;

typedef double Weight;

const Weight INF = 1e+10;
struct Edge{
  int src, dest; Weight weight;
  bool operator < (const Edge &rhs) const {return weight > rhs.weight;}
};

typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

int main() {
  while(1){
    int n,m,p,a,b;
    cin>>n>>m>>p>>a>>b;
    --a;--b;
    if(!n)break;
    vector<int> t(n);
    REP(i,n)cin>>t[i];
    Graph g(m);
    REP(i,p){
      int x,y;
      double z;
      cin>>x>>y>>z;
      --x;--y;
      g[x].push_back({x,y,z});
      g[y].push_back({y,x,z});
    }
    vector<vector<double>> dp(1<<n,vector<double>(m,INF));
    dp[0][a]=0;
    REP(i,1<<n)REP(j,m)
      REP(k,n)REP(l,g[j].size())
        if(!(i>>k&1))
          dp[i|(1<<k)][g[j][l].dest]=min(dp[i|(1<<k)][g[j][l].dest],dp[i][j]+g[j][l].weight/t[k]);
    double mind=INF;
    REP(i,1<<n)mind=min(mind,dp[i][b]);
    if(mind < INF)
      cout<<setprecision(10)<<fixed<<mind<<endl;
    else
      cout<<"Impossible"<<endl;
  }
  return 0;
}

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

int main()
{
	int n;
	cin >> n;
	int array[n];
	int multiplesOf4 = 0, evenButNo4 = 0, odds = 0;
	for (int i = 0; i < n; ++i)
	{
		cin >> array[i];
		if (array[i] % 4 == 0) multiplesOf4++;
		else if (array[i] % 2 == 0) evenButNo4++;
		else odds++;
	}

	bool flag = true;

	if (odds)
	{
		if (odds == 1 && multiplesOf4 == 0) flag = false;
		else if (multiplesOf4 < odds - 1) flag = false;
		else if (evenButNo4 && odds != multiplesOf4) flag = false;
	} 
	if (multiplesOf4 == 0 && evenButNo4%2 == 1) flag = false;

	if (flag) cout << "Yes";
	else cout << "No";


	return 0;
}

Measured memory_bytes: 640
/**
 *   Praveen Fulera    
**/

// #pragma GCC optimize("O3", "unroll-loops")
// #pragma GCC target("avx2")

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

typedef long long int ll;
#define endl '\n'
#define int long long
#define pb push_back
#define pii pair <int, int>
#define ff first
#define ss second
#define point pair <double, double>

const int mod = 1e9 + 7;
//const int mod = 998244353;

int power(int n, int k){
  int res = 1;
  for(int i = 1; i <= k; i++){
    res*=n;
  }
  return res;
}

int C(int n, int k){
  if(k < 0)return 0;
  if(k > n) return 0;
  if(k == 0) return 1;
  if(k == 1)return n;
  if(k == 2) return((n*(n-1))/2);
  return (n*(n-1)*(n-2))/6;
}

signed main(){
  ios_base::sync_with_stdio(false); cin.tie(NULL);
  
  // #ifndef ONLINE_JUDGE
  //   freopen("input.txt", "r", stdin);
  //   freopen("output.txt", "w", stdout);
  // #endif

  string s; cin >> s;
  int k, ans = 0; cin >> k;
  int n = s.size();
  for(char c = '1'; c <= '9'; c++){
         if(s[0] < c) break;
         if(s[0] > c) {ans += (C(n-1,k-1)*power(9,k-1)); continue;}
         ans += (C(n-1,k)*power(9,k));
         if(k == 1) {ans++; break;}
         for(int i = 1; i < n; i++){
           if(s[i] == '0') continue;
           else{
             ans += ((s[i]-'0'-1)*(C(n-i-1,k-2))*power(9,k-2));
             ans += (C(n-i-1,k-1)*power(9,k-1));
             if(k == 2){ans++; break;}
             for(int j = i+1; j < n; j++){
               if(s[j] == '0') continue;
               else{
                  ans += (s[j]-'0'-1)*(C(n-j-1,k-3))*power(9,k-3);
                  ans += (C(n-j-1,k-2)*power(9,k-2));
                  ans++;
                  break;
               }
             }
             break;
           }
         }
  }
  cout << ans << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <functional>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <numeric>
#include <cmath>

#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;
using P = pair<ll, ll>;

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;}

const ll MOD = 1000000007;
const int INF = 1<<29;

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


Measured memory_bytes: 19264
n = gets.to_i
s = gets.to_s
 
if n%2==1
 puts "No" 
else 
  before_half = s[0, n/2]
  after_half = s[n/2, n/2]

  if before_half == after_half
      puts "Yes"
  else
      puts "No"
  end
end

Measured memory_bytes: 1788
#include <iostream>
#include <string>
#include <algorithm>
#include <set>
#include <numeric>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, k, n) for(int i = (k); i < (int)(n); i++)
using namespace std;
using ll = long long;

int main(){
    int N, cnt = 0, ans = 0, tmp = 0;
    int R;
    cin >> R;
    if(R < 1200)
        cout << "ABC" << endl;
    else if(R <2800)
        cout << "ARC" << endl;
    else
        cout << "AGC" << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

struct edge {
  int f;
  int t;
  int c;
};
int main() {
  while (1) {
    int N, M; cin >> N >> M;
    if (!N)break;
    vector<edge>es(N);
    for(int i = 0; i < M; ++i) {
      int f, t, c; cin >> f >> t >> c;
      f--; t--;
      es.push_back(edge{ f,t,c });
    }
    UnionFind uf(N);
    sort(es.begin(), es.end(), [](const edge&l, const edge&r) {return l.c < r.c; });
    vector<int>nums;
    for (int e = 0; e < es.size(); ++e) {
      int f = es[e].f;
      int t = es[e].t;
      if (uf.root(f) == uf.root(t))continue;
      else {
        uf.unionSet(f, t);
        nums.push_back(es[e].c);
      }
    }
    int ans = nums[N / 2-1];
    
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3212
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007

int main() {

  string S;
  cin >> S;

  int h = 0,t = S.size()-1;
  int sum = 0;
  while(t-h >= 0) {
    if(S.at(h) != S.at(t)) sum++;
    h++;
    t--;
  }

  cout << sum << endl;
}



Measured memory_bytes: 256
from collections import deque

def main():
    N,C,K = map(int,input().split())
    T = deque(sorted([int(input()) for _ in range(N)]))
    ans = 0
    while len(T) != 0:
        tmp = T.popleft()
        limit = tmp + K
        count = 1
        while count < C and len(T) != 0:
            tmp = T.popleft()
            if tmp > limit:
                T.appendleft(tmp)
                break
            else:
                count += 1
        ans += 1
    print(ans)

if __name__ == '__main__':
    main()

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

int main() 
{
    int n,m,x;
    cin >> n >> m >> x;
    int sum=0;
    for (int i=0; i<m; i++)
    {
        int a;
        cin >> a;
        if (a<x)
            sum++;
    }
    cout << min(sum,m-sum);    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

int main(){
  int n;

  while(n = getInt()){
    int cnt[10] = {0};
    REP(i,n){
      int t = getInt();
      cnt[t]++;
    }

    REP(i,10){
      if(cnt[i] == 0) putchar('-');
      else REP(j,cnt[i]) putchar('*');
      puts("");
    }
  }
  return 0;
}

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

#define _USE_MATH_DEFINES
#define reb(i,b,n)         for(int i=(int)(b); i<(int)(n); i++)
#define rep(i,n)           reb(i,0,n)
#define each(it,v)         for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define reach(it,v)        for(__typeof((v).rbegin()) it=(v).rbegin();it!=(v).rend();it++)
#define vsort(v)           sort((x).begin(), (x).end()
#define rvsort(v)          sort((x).rbegin(), (x).rend()
#define mp(a, b)           make_pair(a, b)
#define fi                 first
#define se                 second
#define pb                 push_back
#define dbg(x)             cerr<<__LINE__<<": "<<#x<<" = ["<<(x)<<"]"<<endl;
#define dbgArr(table, n)   rep(i,n){cout<<table[i]<<' ';}cout<<'\n';
#define dbg2Arr(table,W,H) rep(y,H){rep(x,W)cout<<table[y][x]<<' ';cout<<'\n';}

using namespace std; using std::stringstream;

typedef long long       ll; typedef unsigned long long ull; typedef long double     ld;
typedef pair <int, int> P;  typedef pair <int, P>      PP;
typedef vector<int>     vi; typedef vector<vi>         vvi; typedef vector<ll>      vl;
typedef vector<P >      vP; typedef vector<char>       vc;  typedef vector<string>  vs;

static const int    INF  = 0x3f3f3f3f;
static const ll     INFL = 0x3f3f3f3f3f3f3f3fLL;
static const double EPS  = 1e-9;
static const ll     MOD  = 1000000007LL;

static const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};

int main(int argc, char *argv[])
{
    int X, Y;
    cin >> X >> Y;

    bool ret = false;
    rep(i, X+1) {
        int j = X-i;
        if (i*2 + j*4 == Y) {
            ret = true;
            break;
        }
    }

    if (ret) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  int max_1 = max(max(a,b), c);
  int max_2 = max_1;
  for(int i = 0; i < k; i++){
   max_2 *= 2;
  }
  cout << a + b + c + max_2 - max_1 << endl;
  return 0;
}

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

const int N=2000;
int A[N];
int n;

bool fanction(int i,int m){
  if(i>n){
    return false;
  }
  if(m==0){
    return true;
  }
  
  
  return fanction(i+1,m)||fanction(i+1,m-A[i]);
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int q;
  int B[N];

  cin>>n;
  for(int i=0;i<n;i++){
    cin>>A[i];
  }
  cin>>q;
  for(int i=0;i<q;i++){
    cin>>B[i];
  }

  for(int i=0;i<q;i++){
    if(fanction(0,B[i])){
      cout<<"yes"<<endl;
    }
    else cout<<"no"<<endl;
  }

  return 0;
}
  
  



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

int main() {

  int a[4];
  int b[4];

  while(cin>>a[0]>>a[1]>>a[2]>>a[3]) {
    cin>>b[0]>>b[1]>>b[2]>>b[3];

    int h=0,k=0;
    for(int i=0; i<4; i++) {
      for(int j=0; j<4; j++) {
	if(a[i] == b[j]) {
	  if(i==j) h++;
	  else k++;
	}
      }
    }

    cout<<h<<" "<<k<<endl;
  }
}

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

double exp(double a, int b) {
  double res=1;
  for(; b; a=a*a, b>>=1)
    if(b&1) res=res*a;
  return res;
}


int main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  
  int n;
  cin >> n;
  cout << fixed << setprecision(6) << exp(n/3.0,3);
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int input;
	long long int count = 0;
	
	scanf("%d", &input);
	for (int i = 1; i<=input; i++){
		if (i%3 == 0 && i%5 == 0){
		}else if (i%3 == 0){	
		}else if (i%5 == 0){
		}else {
			count += i;
		}
	}
	printf("%lld\n", count);
	return 0;
}

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

int main()
{
    int n, m;
    int A[100][100] = {}, b[100] = {};

    cin >> n >> m;

    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < m; j++)
        {
            cin >> A[i][j];
        }
    }
    for (int i = 0; i < m; i++)
    {
        cin >> b[i];
    }

    for (int i = 0; i < n; i++)
    {
        int sum_ = 0;
        for (int j = 0; j < m; j++)
        {
            sum_ += A[i][j] * b[j];
        }
        cout << sum_ << endl;
    }

    return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> a(n), b(n);
    ll cnt = 0;
    rep (i, n) cin >> a[i];
    rep (i, n) cin >> b[i];
    rep (i, n) {
        if (a[i] > b[i]) {
            ll diff = a[i] - b[i];
            b[i] += diff;
            cnt += diff;
        }
    }
    rep (i, n) {
        if (a[i] < b[i]) {
            ll d = (b[i] - a[i]) / 2;
            a[i] += 2 * d;
            cnt -= d;
        }
    }
    if (cnt <= 0) cout << "Yes" << endl;
    else cout << "No" << endl;

    
    return 0;
}



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

int main(){
  char str[1200];
  int i;

  fgets(str,sizeof str,stdin);

  for(i=0; i<strlen(str); ++i){
    if('A'<=str[i] && str[i]<='Z'){
      str[i]+=32;
    }
    else if('a'<=str[i] && str[i]<='z'){
      str[i]-=32;
    }
    printf("%c",str[i]);
  }

  return 0;
}



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

int main(){
  int W,H,x,y,r;
  cin>>W>>H>>x>>y>>r;
  if(x<r || W-x<r || y<r || H-y<r){
    cout<<"No"<<endl;
  }else cout<<"Yes"<<endl;
  return 0;
}

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

void fnInput(vector<int>& rvnSeq)
{
  int nSeqSiz;
  cin >> nSeqSiz;
  rvnSeq.resize(nSeqSiz);

  for (int& rnSeq : rvnSeq)
    cin >> rnSeq;
}
  
int fnLowerCnt(const vector<int>& cnrvnSeq)
{
  int nMaxSeqCnt = 0;
  int nBgn = 0;

  while (nBgn < cnrvnSeq.size() )
  {
    int nSeqCnt = 0;
    int nFoward = nBgn;

    while ( nFoward < cnrvnSeq.size() - 1  &&
            cnrvnSeq[nFoward] >= cnrvnSeq[nFoward + 1] )
    {
      nSeqCnt++;
      nFoward++;
    }
    nMaxSeqCnt = max(nMaxSeqCnt, nSeqCnt);
    nBgn = nFoward + 1;
  }
  return nMaxSeqCnt;
}
  
int main()
{
  vector<int> vnSeq;

  fnInput(vnSeq);
  cout << fnLowerCnt(vnSeq) << endl;

  return 0;
}

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

int x[4] = { 0,1,0,-1 }, y[4] = { -1,0,1,0 };
int main()
{
	int a;
	while (cin >> a, a) {
		int xmin, xmax, ymin, ymax; xmin = xmax = ymin = ymax = 0;
		int c[200]{}, d[200]{};
		for (int b = 0; b < a-1; b++) {
			int e, f; scanf("%d%d", &e, &f);
			int g = c[e] + x[f], h = d[e] + y[f];
			c[b + 1] = g; d[b + 1] = h;
			xmin = min(xmin, g);
			xmax = max(xmax, g);
			ymin = min(ymin, h);
			ymax = max(ymax, h);
		}
		cout << (ymax - ymin + 1) << " " << (xmax - xmin + 1) << endl;
	}
}

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

int main(){
    long long N, X;
    cin >> N >> X;
    long long ret = N;
    N -= X;
    while(N % X != 0){
        ret += (N / X) * X * 2;
        long long t = X;
        X = N % X;
        N = t;
    }
    ret += X * (N / X * 2 - 1);
    cout << ret << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define p pair<int, int>
#define endl '\n'

using namespace std;

struct DO{
    vector<int> do_arr;
    int len;

    DO(int n){
        int q1 = 1;
        while (q1 < n){
            q1 *= 2;
        }
        len = q1;
        do_arr.assign(2*q1, 0);
    }

    void change(int q, int x){
        do_arr[len+q] = x;
        q = (len+q)/2;
        while (q > 0){
            do_arr[q] = max(do_arr[2*q], do_arr[2*q+1]);
            q /= 2;
        }
    }

    int ans(int l, int r, int l1, int r1, int q){
        if (l >= r1 || l1 >= r || l == r){
            return 0;
        }
        if (l1 <= l && r <= r1){
            return do_arr[q];
        }
        int m = (l+r)/2;
        return max(ans(l, m, l1, r1, 2*q), ans(m, r, l1, r1, 2*q+1));
    }
};

vector<int> a, ans;
vector<vector<int>> s, d;
DO do_arr = *(new DO(1));

void DFS(int vertex, int parent){
    s[a[vertex]].push_back(do_arr.ans(0, do_arr.len, 0, a[vertex], 1)+1);
    do_arr.change(a[vertex], s[a[vertex]].back());
    ans[vertex] = do_arr.do_arr[1];
    for (int q: d[vertex]){
        if (q != parent){
            DFS(q, vertex);
        }
    }
    s[a[vertex]].pop_back();
    do_arr.change(a[vertex], s[a[vertex]].back());
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    int n;
    cin >> n;
    a.assign(n, 0), d.assign(n, {}), ans.assign(n, 0), s.assign(n, {0});
    do_arr = *(new DO(n));
    vector<p> a1(n);
    for (int q = 0; q < n; q++){
        cin >> a1[q].first;
        a1[q].second = q;
    }
    sort(a1.begin(), a1.end());
    int q1 = 0;
    a[a1[0].second] = 0;
    for (int q = 1; q < n; q++){
        q1 += (a1[q].first != a1[q-1].first);
        a[a1[q].second] = q1;
    }
    for (int q = 0; q < n-1; q++){
        int x, y;
        cin >> x >> y;
        d[x-1].push_back(y-1);
        d[y-1].push_back(x-1);
    }
    DFS(0, -1);
    for (int q: ans){
        cout << q << endl;
    }
    return 0;
}


Measured memory_bytes: 61796