akhauriyash/Code-Regression huggingface dataset:
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sys,collections,itertools,re,math,fractions,decimal,random,array,bisect,heapq

# decimal.getcontext().prec = 50
# sys.setrecursionlimit(10000)
# MOD = 10**9 + 7

def solve(f):
    a, b = f.read_int_list()
    if a > 8 or b > 8:
        return ":("
    else:
        return "Yay!"


class Reader(object):
    def __init__(self, filename=None):
        self.file = open(filename) if filename is not None else None
        self.case = 1

    def __readline(self):
        return self.file.next().strip() if self.file else raw_input()

    def next_case(self):
        self.file.next()
        self.case += 1

    def read_int(self): return int(self.__readline())
    def read_float(self): return float(self.__readline())
    def read_long(self): return long(self.__readline())
    def read_decimal(self): return decimal.Decimal(self.__readline())
    def read_str(self): return self.__readline()

    def read_int_list(self): return map(int, self.__readline().split())
    def read_float_list(self): return map(float, self.__readline().split())
    def read_long_list(self): return map(long, self.__readline().split())
    def read_decimal_list(self): return map(decimal.Decimal, self.__readline().split())
    def read_str_list(self): return self.__readline().split()

if __name__ == '__main__':
    filename = sys.argv[1] if len(sys.argv) > 1 else None
    f = Reader(filename)
    if f.file:
        while True:
            print "Case #%d\n"%f.case, solve(f)
            try:
                f.next_case()
            except StopIteration:
                break
    else:
        print solve(f)


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

using namespace std;

int main() {
	const int mod = 10000;
	int n,k;
	cin >> n >> k;
	priority_queue<pair<int,int>,vector<pair<int,int>>,greater<pair<int,int>>> a;
	int in1, in2;
	for (int i = 1; i <= k; i++) {
		cin >> in1 >> in2;
		a.push(make_pair( in1,in2 ));
	}

	vector<vector<long long>> dp(n + 1,vector<long long>(4));

	if (a.top().first != 1) {
		dp[1][1] = 1;
		dp[1][2] = 1;
		dp[1][3] = 1;
	}
	else{
		dp[1][a.top().second] = 1;
		a.pop();
	}

	if (a.top().first != 2) {
		dp[2][1] = dp[1][1]+dp[1][2]+dp[1][3];
		dp[2][2] = dp[1][1] + dp[1][2] + dp[1][3];
		dp[2][3] = dp[1][1] + dp[1][2] + dp[1][3];
	}
	else {
		for (int j = 1; j <= 3; j++) {
			if (a.top().second == j) {
				dp[2][j] = dp[1][1]	+ dp[ 1][2] + dp[1][3] ;
			}
			else {
				dp[2][j] = 0;
			}
		}
		a.pop();
	}

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

		if (a.empty()==true || i != a.top().first) {
			dp[i][1] = (dp[i-1][1]!=0)*(dp[i - 2][2] + dp[i - 2][3])
				+ dp[i - 1][2] + dp[i - 1][3];
			dp[i][2] = (dp[i - 1][2] != 0)*(dp[i - 2][1] + dp[i - 2][3])
				+ dp[i - 1][1] + dp[i - 1][3];
			dp[i][3] = (dp[i - 1][3] != 0)*(dp[i - 2][1] + dp[i - 2][2])
				+ dp[i - 1][1] + dp[i - 1][2];
		}
		else {
			for (int j = 1; j <= 3; j++) {
				if (a.top().second == j) {
					if (dp[i - 1][j] != 0) {
						dp[i][j] = dp[i - 1][1]//+dp[i-2][1]
							+ dp[i - 1][2]//+dp[i-2][2]
							+ dp[i - 1][3]//+dp[i-2][3]
							-dp[i - 1][j]
							+dp[i-2][1]
							+dp[i-2][2]
							+dp[i-2][3]
							- dp[i - 2][j];
					}
					else {
						dp[i][j] = dp[i - 1][1]//+dp[i-2][1]
							+ dp[i - 1][2]//+dp[i-2][2]
							+ dp[i - 1][3];//+dp[i-2][3]
					}
				}
				else {
					dp[i][j] = 0;
				}
			}
			a.pop();
		}
		for (int j = 1; j <= 3; j++) {
			dp[i][j] = dp[i][j] % mod;
		}
	}

	cout << (dp[n][1]+dp[n][2]+dp[n][3])%10000 << endl;
	return 0;

}


Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define in insert
#define PI 3.1415926535897932384626433832795
#define F first
#define S second
#define aLL(str) (str).begin(), (str).end()
#define IOS                  \
    ios::sync_with_stdio(0); \
    cin.tie(0);              \
    cout.tie(0)
#define ll long long
#define ld long double
#define lcm(a, b) (a * b) / __gcd(a, b)
#define flu(i, a, b) for (ll i = a; i < b; i++)
#define blu(i, a, b) for (ll i = a; i >= b; i--)
#define upper(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define Unique(X) (X).erase(unique(all(X)), (X).end())
#define all(v) v.begin(), v.end()
typedef vector<ll> vl;
typedef map<ll, ll> ml;
typedef vector<string> vs;
typedef vector<vector<int>> vvi;
char e = '\n';

const ll MOD = 1e9 + 7;

ll i, j, le;

int sv(int x)
{
    int n = 200000;
    bool prime[n + 1];
    memset(prime, true, sizeof(prime));

    for (int p = 2; p * p <= n; p++)
    {

        if (prime[p] == true)
        {
            for (int i = p * p; i <= n; i += p)
                prime[i] = false;
        }
    }
    if (prime[x])
        return 1;
    else
        return 0;
}

int main()
{
    IOS;
    int t;
   // cin >> t;
    t=1;
    while (t--)
    { 
      ll d,s;
      ld t;
      cin>>d>>t>>s;
      if ((ld)d/t <= s)cout<<"Yes"<<e;
      else cout<<"No"<<e;
    }
    return 0;
}

Measured memory_bytes: 3740
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.PriorityQueue;
import java.util.StringTokenizer;





 class Main{
	
	

	public static void main(String[] args) throws IOException {
		
		
		FastScanner sc=new FastScanner();
		int n = sc.nextInt();
		int capacity = sc.nextInt();
		dp = new long[n+1][capacity+1];
		for(int i=0; i<=n; i++) {
			for(int j=0; j<=capacity; j++)
				dp[i][j] = -1;
		}
		long wights[] = new long[n];
		long value[] = new long[n];
		for(int i=0; i<n; i++) {
			wights[i] = sc.nextLong();
			value[i] = sc.nextLong();
		}
		long v = solve(wights,value,n,capacity);
		System.out.println(v);
	}
	
	
	
	static long dp[][];
	
 
	private static long solve(long[] wights, long[] value, int n, int W) {
		if(n == 0 || W==0)
			return 0;
		if(dp[n][W] != -1)
			return dp[n][W];
		if(wights[n-1] <= W) {
			return dp[n][W] = Math.max(solve(wights, value, n-1, (int) (W-wights[n-1])) 
					+ value[n-1],
					solve(wights, value, n-1, W));
		}
		else {
			return dp[n][W] =  solve(wights, value, n-1, W);
		}
		
	}





	static void sort(int[] a) {
		ArrayList<Integer> l=new ArrayList<>();
		for (int i:a) l.add(i);
		Collections.sort(l);
		for (int i=0; i<a.length; i++) a[i]=l.get(i);
	}
	
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long[] readArrayLong(int n) {
        	long[] a=new long[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
        }
		long nextLong() {
			return Long.parseLong(next());
		}
		String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
	}
}


Measured memory_bytes: 139184
def q*a;a.delete a[0];a.empty?end;$<.map{|x|a,b,c,d,e=s=x.chop.split(",").map(&:to_i).sort;f,g,n=q(c,d,e),q(a,b,c),s.uniq.size;puts %w{four\ card full\ house straight three\ card two\ pair one\ pair null}[case;when q(a,b,c,d)||q(b,c,d,e);0;when a==b&&f||g&&d==e;1;when s==(a..e).to_a||s==[1,10,11,12,13];2;when g||q(b,c,d)||f;3;when n==3;4;when n==4;5;else 6;end]}

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#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>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define all(c) c.begin(),c.end()
const int inf = 1000000001;
const ll INF = 2e18 * 2;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };



int main() {
	vii c(3, vi(3));
	int i, j;
	rep(i, 3) {
		rep(j, 3) {
			cin >> c[i][j];
		}
	}
	int b2 = c[0][1] - c[0][0], b3 = c[0][2] - c[0][0];
	int a2 = c[1][0] - c[0][0], a3 = c[2][0] - c[0][0];
	for (int a1 = -300; a1 <= 300; a1++) {
		for (int b1 = -300; b1 <= 300; b1++) {
			vi a(3), b(3);
			a[0] = a1;
			a[1] = a1 + a2;
			a[2] = a1 + a3;
			b[0] = b1;
			b[1] = b1 + b2;
			b[2] = b1 + b3;
			bool flag = true;
			for (i = 0; i < 3; i++) {
				for (j = 0; j < 3; j++) {
					if (c[i][j] != a[i] + b[j]) {
						flag = false;
						break;
					}
				}
			}
			if (flag) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#include<vector>
using namespace std;
int main(void){

	ios::sync_with_stdio(false);
	int N, K;		cin >> N >> K;
	vector<int>	x(N);
	for(int i = 0 ; i < N ; i++)	cin >> x[i];

	int ans = 0;
	for(int i = 0 ; i < N ; i++)
		ans += 2 * min(K - x[i] , x[i]);

	cout << ans << endl;

 return 0;
}


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

int main() {
  int N;
  cin >> N;
  
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A.at(i);
  }
  
  int c = 0,j = 0;
  while (c <= N) {
    c++;
    if (A.at(j) == 2) {
      break;
    } else {
      j = A.at(j) - 1;
    }
  }
  
  if (c > N) {
    cout << -1 << endl;
  } else {
    cout << c << endl;
  }
}


Measured memory_bytes: 640
#include <stdio.h>

int main(void) {
    int s;
    scanf("%d", &s);

    int count = 0;
    if (s % 10 != 0) { count++; };
    if ((s / 10) % 10 != 0) { count++; };
    if ((s / 100) != 0) { count++; };

    printf("%d\n", count);

    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
/*
int main()
{
    int n;
    cin>>n;
    vector<int>vec(n);
    for(int i=0;i<n;i++){
        cin>>vec[i];
    }
    sort(vec.begin(),vec.end());
    for(int i=0;i<n-1;i++){
        if(vec[i]==vec[i+1]){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    cout<<"YES"<<endl;
    return 0;
}
*/
 int main()
 {
     set<int>s;
     int n;
     cin>>n;
     for(int i=0;i<n;i++){
        int a;
        cin>>a;
        s.insert(a);
     }
     if(s.size()==n){
        cout<<"YES"<<endl;
     }
     else
        cout<<"NO"<<endl;
     return 0;
 }

Measured memory_bytes: 9600
/*
problem's name:
statue:
writer:Patrick_y
*/
#include <iostream>
#include <map>
#include <vector>
#include <cstring>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <queue>
#include <string>
#include <stack>
#include <set>
#include <deque>
#include <cctype>
#include <sstream>
#include <math.h>
#include <stdio.h>
#include <time.h>
#define mp make_pair
typedef long long ll;
using namespace std;
const int INF=20050208;
/*------------main part------------*/



int num[200005];
int ans;
int tar[200005];
int main()
{
	int n;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>num[i];
	}
	for(int i=0;i<n;i++)
	{
		tar[num[i]]=tar[num[i]-1]+1;
	}
	for(int i=1;i<=n;i++)
	{
		ans=max(ans,tar[i]);
	}
	cout<<n-ans;
	return 0;
}

Measured memory_bytes: 1920
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		String x = input.nextLine();
		if (x.charAt(2)==x.charAt(3)&&x.charAt(4)==x.charAt(5)) System.out.println("Yes");
		else System.out.println("No");
	}
}

Measured memory_bytes: 22996
N=int(input())
cost=list(map(int,input().split()))
#cost=[int(input()) for i in range(N)]

answers=[0,abs(cost[1]-cost[0])]
for i in range(2,N):
	c_1=answers[i-2] + abs(cost[i]-cost[i-2])
	c_2=answers[i-1] + abs(cost[i]-cost[i-1])
	answers.append(min(c_1,c_2))
print(answers[-1])

Measured memory_bytes: 13980
#include <iostream>
#include <algorithm>
 
 
#define FAST_IO ios_base::sync_with_stdio(false), cin.tie(nullptr)
using namespace std;
 
signed main() {
    FAST_IO;
 
    int n;
    cin >> n;
    int a[n], b[n], c[n];
    for (int i = 0; i < n; i++) cin >> a[i] >> b[i] >> c[i];
    int dp[n + 1][3];
  	// Set the base values
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];
    for (int i = 1; i < n; i++) {
        dp[i][0] = a[i] + max(dp[i - 1][1], dp[i - 1][2]);
        dp[i][1] = b[i] + max(dp[i - 1][0], dp[i - 1][2]);
        dp[i][2] = c[i] + max(dp[i - 1][1], dp[i - 1][0]);
    }
  	// We want to print the maximum of all the states
    cout << max({dp[n - 1][0], dp[n - 1][1], dp[n - 1][2]}); 
    return 0;
}

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

typedef long long LL;
const LL mod=1000000007;
#define MAX 10000
const double PI  = acos(-1.0);

//-------------------------------------------


int main(){

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

    int N,Y,x,y;
    cin >> N >> Y;
    bool flag = false;
    int sum = 0;

    for ( int i = 0; i <= N; i++){
        for ( int  j = 0; j <= N; j++){

            sum = 10000* i + 5000 * j + 1000* (N - i -j);
            if( Y == sum && N - i -j >= 0){
                x = i;
                y = j;
                flag = true;
            }
        }
    }


    if (flag) cout << x << " "<< y <<" "<< N - x - y << endl;
    else cout << -1 << " "<< -1 << " "<< -1 << endl;


    return 0;

}


Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
using namespace std;
typedef long long ll;
const int N = 2e5+10;
ll pre[N][2] = {0}, aft[N][2] = {0};
ll a[N];
int main()
{
	int n;
	scanf("%d", &n);
	for(int i = 1; i <= n; i++)
	scanf("%lld", a+i);
	if(n % 2)
	{
		ll res = -1e18;
		for(int i = 2; i <= n; i+=2)
		{
			pre[i][0] = pre[i-2][0] + a[i - 1];
			pre[i][1] = max(pre[i - 2][0], pre[i - 2][1]) + a[i];
		}
		for(int i = n; i >= 1; i-=2)
		{
			aft[i][0] = max(aft[i+2][0], aft[i + 2][1]) + a[i - 1];
			aft[i][1] = aft[i + 2][1] + a[i];
		}
		for(int i = 1; i <= n; i+=2)
		{
			res = max(res, max(pre[i-1][0], pre[i-1][1]) + max(aft[i + 2][0], aft[i + 2][1]));
		}
		printf("%lld\n", res);
	}else
	{
		for(int i = 2; i <= n; i+=2)
		{
			pre[i][0] = pre[i-2][0] + a[i - 1];
			pre[i][1] = max(pre[i - 2][0], pre[i - 2][1]) + a[i];
			
		}
		printf("%lld\n", max(pre[n][0], pre[n][1]));
	}
} 

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

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}
template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

template<typename T>
void chmax(T &a, T b) {
    a = max(a, b);
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int ar[3] = {0};
    REP(i, 0, n) {
        int a;
        cin >> a;
        a %= 3;
        ar[a]++;
    }
    if (ar[1] == 0 && ar[2] == 0) {
        cout << 1 << endl;
    } else {
        int ans = 0;
        REP(i, 1, 3) {
            if (ar[i] == 0) continue;
            int res = ar[0] + 1;
            int sum = i;
            int br[3] = {ar[0], ar[1], ar[2]};
            br[i]--;
            bool update = true;
            while (update) {
                update = false;
                REP(j, 1, 3) {
                    if (sum == j && br[j]) {
                        sum = (sum + j) % 3;
                        br[j]--;
                        res++;
                        update = true;
                    }
                }
            }
            if (br[1] || br[2]) {
                res++;
            }
            chmax(ans, res);
        }
        cout << ans << endl;
    }
    return 0;
}



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

#define ff first
#define ss second
#define PI acos(-1)
#define pb push_back
#define int long long
#define ld long double
#define sp fixed<<setprecision
#define bp __builtin_popcountll
#define all(x) x.begin(),x.end()
#define pii pair<long long,long long>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

const int M = (1e9)+7;
const int N = 1e6+5;

signed main()
{
    FAST
    int tc=1;
    //cin>>tc;
    for(int ti=1;ti<=tc;ti++)
    {
        int n,d;
        cin>>n>>d;
        d *= d;
        int ans = 0;
        for(int i=0;i<n;i++)
        {
            int x,y;
            cin>>x>>y;
            int chk = (x*x) + (y*y);
            ans += (chk<=d);
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int H, W;
    cin >> H >> W;
    
    vector<vector<char>> mass(H, vector<char>(W));
    
    for (int i = 0; i < H; i++){
        for (int j = 0; j < W; j++){
            cin >> mass.at(i).at(j);
        }
    }


    for (int j = 0; j < W; j++){
        for (int i = 0; i < H; i++){
            if (mass.at(i).at(j) == '#'){
                break;
            }
            if ((i == H - 1) && (mass.at(i).at(j) == '.')){
                for (int k = 0; k < H; k++){
                        mass.at(k).at(j) = '0';
                }
                
            }
        }
    }
    
        
    for (int i = 0; i < H; i++){
        for (int j = 0; j < W; j++){
            if (mass.at(i).at(j) == '#'){
                break;
            }
            if ((j == W - 1) && (mass.at(i).at(j) == '.' || mass.at(i).at(j) == '0')){
                for (int k = 0; k < W; k++){
                    mass.at(i).at(k) = '0';
                }
                mass.at(i).at(W - 1) = '1';
            }
        }
    }
    
    for (int i = 0; i < H; i++){
        for (int j = 0; j < W; j++){
            if (!((mass.at(i).at(j) == '0') || (mass.at(i).at(j) == '1'))){
                cout << mass.at(i).at(j);
            }
            if ((j == W - 1) && (!(mass.at(i).at(j) == '1')))
                cout << endl;
        }
    }
}

Measured memory_bytes: 256
#include <iostream>
 
using namespace std;
 
int main(void){
  int a,b;
  cin>>a>>b;
  if(a==1&&b==1) cout<<"Draw"<<endl;
  else if(a==1) cout<<"Alice"<<endl;
  else if(b==1) cout<<"Bob"<<endl;
  else if(a==b) cout<<"Draw"<<endl;
  else if(a>b) cout<<"Alice"<<endl;
  else cout<<"Bob"<<endl;
 
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using p = pair<int,int>;
 
const int INF = 1001001001;
vector<int> to[100005];
 
int main() {
    int n, m;
    cin >> n >> m;
    rep(i,m) {
        int a,b;
        cin >> a >> b;
        --a; --b;
        to[a].push_back(b);
        to[b].push_back(a);
    }
  
    queue<int> q;
    vector<int> dist(n, INF);
    vector<int> pre(n, -1);
    dist[0] = 0;
    q.push(0);
    while(!q.empty()) {
        int v = q.front(); q.pop();
        for(int u : to[v]) {
            if(dist[u] != INF) continue;
            dist[u] = dist[v]+1;
            //通常のBFSとの違い
            pre[u] = v;
            //ここまで
            q.push(u);
        }
    }
  
    cout << "Yes" << "\n";
    rep(i,n) {
        if(i == 0) continue;
        int ans = pre[i];
        ++ans;
        cout << ans << "\n";
    }
    return 0;
}

Measured memory_bytes: 10500
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int main(){
    int k;
    cin >> k;
    int odd,even;
    if (k % 2 == 1){
        odd = k/2 + 1;
        even = k/2;
    } else {
        odd = k/2;
        even = k/2;
    }
    cout << odd * even << endl;


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(long long i=0; i<n; i++)
#define REPR(i, n) for(long long i=n-1; i>=0; i--)
#define FOR(i, m, n) for(long long i=m; i<=n; i++)
#define FORR(i, m, n) for(long long i=m; i>=n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

using namespace std;
using ll = long long;
using ull = unsigned long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;
const ll mod = 1e9+7;
const ll inf = 1e15;
ll power(ll a,ll b){return b?power(a*a%mod,b/2)*(b%2?a:1)%mod:1;}


int main(){FIN
    ll n,k;cin>>n>>k;
    ll ans = 100 * (n-k) * power(2,k);
    ans += (1900 * k) * power(2,k);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3600
#include <iostream>

using namespace std;

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

    char ans;
    if (X < Y) {
        ans = '<';
    } else if (X == Y) {
        ans = '=';
    } else {
        ans = '>';
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int maxn=110;
int n;
char x[maxn];
int main(){
    scanf("%s",x);n=strlen(x);
    if(x[0]!='A'){
        printf("WA");return 0;
    }
    int cnt=0;
    for(register int i=2;i<=(n-2);i++) if(x[i]=='C') cnt++;
    if(cnt!=1){
        printf("WA");return 0;
    }
    for(register int i=1;i<n;i++) if((x[i]!='C')&&(x[i]<'a')){
        printf("WA");return 0;
    }
    printf("AC");
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        new Main().run();
    }

    private void run() {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int[] A = new int[N];
        for(int i = 1; i < N; i++) {
            int boss = scanner.nextInt();
            A[boss - 1]++;
        }
        for(int i = 0; i < N; i++) {
            System.out.println(A[i]);
        }

        return;
    }
}


Measured memory_bytes: 61768
#include <iostream>
#include <math.h>
using namespace std;

int main()
{
	int a,b,recArea,round;

	cin >> a >> b ;

	recArea = a * b;
	round = 2 * a + 2 * b;

	cout << recArea << " " << round << endl;
    return 0;
}




Measured memory_bytes: 3088
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

struct trie{
	bool leaf;
	trie* node[2];
	trie(){
		leaf = false;
		for(int i = 0; i < 2; i++){
			node[i] = (trie*)0;
		}
	}

	void insert(const string &s){
		trie* r = this;
		for(int i = 0; i < s.length(); i++){
			int c = s[i]-'0';
			if(!r->node[c]) r->node[c] = new trie;
			r = r->node[c];
		}
		r->leaf = true;
	}
};


ll grundy(ll x){
	if(x== 0) return 0;
	ll res = 1;
	while(x%(res*2)==0) res*=2;
	return res;
}
ll n,l;
ll ans = 0;

void solve(trie *t,ll d){
	if(t->leaf || d>=l) return;
	if((!t->node[0]&&t->node[1]) || (!t->node[1]&&t->node[0])){
		ans ^= grundy(l-d);
	}
	for(int i = 0; i < 2; i++){
		if(t->node[i]) solve(t->node[i],d+1);
	}
	return;
}

int main()
{
	cin >> n >> l;
	trie t;
	for(int i = 0; i < n; i++){
		string s;
		cin >> s;
		t.insert(s);
	}
	solve(&t,(ll)0);
	cout << (ans!=(ll)0?"Alice":"Bob") <<endl;

	return 0;
}

Measured memory_bytes: 4992
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String revStr, str = in.readLine();
		int a, b, num = Integer.parseInt(in.readLine());
		StringBuffer sb = new StringBuffer(str);
		for (int i = 0; i < num; i++) {
			String[] order = in.readLine().split(" ");
			a = Integer.parseInt(order[1]);
			b = Integer.parseInt(order[2]);
			if (order[0].equals("print")) {
				System.out.println(str.substring(a, b + 1));
			} else if (order[0].equals("reverse")) {
				StringBuffer revSb = new StringBuffer(str.substring(a, b + 1));
				revStr = revSb.reverse().toString();
				str = sb.replace(a, b + 1, revStr).toString();
			} else if (order[0].equals("replace")) {
				str = sb.replace(a, b + 1, order[3]).toString();
			}
		}
	}
}

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

namespace ConsoleApplication6
{
    class Program
    {
        static void Main(string[] args)
        {
            var rl = RL();
            //var sprlst = spr(rl);
            //var intlist = sprlst.Select(x => c2i(x)).ToList();
            var k = c2i(rl);
            //var ls1 = Enumerable.Range(0, 10).Select(x => (long)x);
            var fbsum = (k * (k + 1)) / 2;
            var num3 = (k / 3) * 3; 
            var num5 = (k / 5) * 5;
            var num15 = (k / 15) * 15;
            var ans = fbsum - getsum(num3,3)-getsum(num5,5) +getsum(num15,15);

            bool ret = false;



            Console.WriteLine(ans);
            //Console.ReadLine();
            




        
        }
        static Int64 getsum(Int64 last, int ct) { return (ct + last) * (last / ct) / 2; }
        static string RL() { return Console.ReadLine().Trim(); }
        static IEnumerable<string> spr(string s) { return s.Split(' '); }
        static Int64 c2i(string c) { return Int64.Parse(c); }
        //static double c2d(string c) { return double.Parse(c); }
        static string bool2ret(bool b) { return b ? "Yes" : "No"; }
    }
}


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

int gcd(int x, int y);
int fac(ll n, vector<int> num);

const int INF = 1001001001;

//mint�p�̕ϐ� (10��9��)
const int mod = 1000000007;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x = 0) :x((x% mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream & is, const mint & a) { return is >> a.x; }
ostream& operator<<(ostream & os, const mint & a) { return os << a.x; }

string s(ll n) {
    if (n == 0)
        return "";
    n--;
    return s(n / 26) + string(1, 'a' + n % 26);
}

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

    string ans = s(n);

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

/*���C�u�����ő����*/
//���[�O���b�h�̌ݏ��@
int gcd(int x, int y) {
    int num[3];
    num[0] = (x > y) ? x : y;
    num[1] = (x <= y) ? x : y;
    num[2] = num[0] % num[1];

    while (num[2]) {
        num[0] = num[1];
        num[1] = num[2];
        num[2] = num[0] % num[1];
    }

    return num[1];
}

/*�f��������*/
//���색�C�u����
int fac(ll n, vector<int> num) {
    ll kazu = n;
    for (int i = 2; i <= sqrt(n); i++) {
        while (1) {
            if (kazu % i != 0) break;

            kazu /= i;
            num[i]++;
        }
    }
    if (kazu == n && n != 1) return 1;
    int ans = 0;
    if (kazu != 1) ans++;
    for (int i = 2; i <= sqrt(n); i++) {
        for (int j = 1; j <= num[i]; j++) {
            num[i] -= j;
            ans++;
        }
    }
    return ans;
}

Measured memory_bytes: 3724
#include <bits/stdc++.h>
using namespace std;
/* {{{ */
/*-------------------------------*/
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (b) - 1; i >= (a); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define rep(i, n) for(int i = 0; i < (n); i++)
#define RREP(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)
 
#define all(i) (i).begin(),(i).end()
#define rall(i) (i).begin(),(i).end(),greater<int>()
#define CLEAR(ary, i) memset((ary), (i), sizeof(ary))
#define PB push_back
#define pb push_back
#define mp make_pair
#define FST first
#define SEC second
#define fst first
#define sec second

#define int long long

const int INF = 999999999;
const int MOD = 1e9 + 7;
const double PI = acos(-1);
const int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};

inline int in(){int x;std::cin>>x;return x;}

typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef vector<long long> llv;
typedef vector<pint> vpint;
typedef queue<int> qint;
typedef stack<int> si;
typedef deque<int> dint;

template <typename T> void print(T x) { std::cout << x << '\n'; }
/*-------------------------------*/
/* }}} */

int fact(int n)
{
  if (n == 0) return 1;

  return n * fact(n - 1);
}

signed main()
{
  int a = in();

  cout << fact(a) << '\n';

  return (0);
}

Measured memory_bytes: 3196
#include<iostream>
#include<list>
#include<algorithm>


using namespace std;


class Rect
{
public:
	int H, W;
	Rect(int h,int w)
		: H(h)
		, W(w)
	{
	}

	void print() const
	{
		cout << H << " " << W << endl;
	}

	bool operator<(const Rect & rect) const
	{
		if (H*H + W*W < rect.H*rect.H + rect.W*rect.W)
		{
			return true;
		}
		if (H*H + W*W > rect.H*rect.H + rect.W*rect.W)
		{
			return false;
		}
		return H < rect.H;
	}
};


int main()
{
	list<Rect> vec;

	for (int h = 1; h <= 300; ++h)
	{
		for (int w = h + 1; w <= 300; ++w)
		{
			vec.emplace_back(Rect(h, w));
		}
	}	
	
	vec.sort();
	
	while(true)
	{
		int h, w;
		cin >> h >> w;
		if (h == 0 && w == 0)return 0;

		for (const auto & rect : vec)
		{
			if (Rect(h, w) < rect)
			{
				rect.print(); break;
			}
		}
	}
}


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

typedef long long int lld;

int main()
{
    lld n, answer = 0;

    scanf("%lld", &n);

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

        current_answer = n/i;

        if ((n%i) == 0)
        {
            current_answer --;
        }

        answer += current_answer;
    }


    printf("%lld", answer);

    return 0;
}

Measured memory_bytes: 1728
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
 
 long long gcd(long long a, long long b){
     if(b==0) return a;
     return gcd(b,a%b);
 }

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

    ll n;
    cin>>n;
    ll a[n], b[n];

    pair<ll, ll> p[n];
    for (int i = 0; i < n;i++){
        cin >> a[i] >> b[i];
        p[i] = make_pair(b[i], a[i]);
    }
    sort(p, p + n);
    ll now = 0;
    bool pos = true;
    for (int i = 0; i < n;i++){
        now += p[i].second;
        if(now>p[i].first){
            pos = false;
        }
    }
    if(pos){
        cout << "Yes" << endl;
    }
    else
        cout << "No" << endl;
}

Measured memory_bytes: 6528
def solve():
    n, m = map(int, input().split())
    if n == m == 1:
        print(1)
    elif n == 1:
        print(m-2)
    elif m == 1:
        print(n-2)
    elif n == 2 or m == 2:
        print(0)
    else:
        print((n-2)*(m-2))
    return 0

if __name__ == "__main__":
    solve()

Measured memory_bytes: 3060
<?php
$n = trim(fgets(STDIN));
$vArray = explode(" ", trim(fgets(STDIN)));
$minusCount = 0;
foreach($vArray as $v){
    $pArray[] = abs($v);
    if($v < 0)$minusCount++;
}
if($minusCount % 2 == 0){
    echo array_sum($pArray);
}else{
    echo array_sum($pArray) - min($pArray) * 2;
}



Measured memory_bytes: 18932
def main():
	N = int(input())
	a = list(map(int, input().split()))
	a.sort(reverse=True)
	alice = 0
	bob = 0
	for i in range(N):
		if i % 2 == 0:
			alice += a[i]
		else:
			bob += a[i]
	print(alice-bob)


if __name__ == '__main__':
	main()

Measured memory_bytes: 2940
//atcoder arc090 b
#include <bits/stdc++.h>
typedef long long ll;
const int N = 1e5 + 54;

inline void up(int &x, int y) { x < y ? x = y : 0; }
inline void down(int &x, int y) { x > y ? x = y : 0; }
inline int max(const int x, const int y) { return x > y ? x : y; }
inline int min(const int x, const int y) { return x < y ? x : y; }

int n, m, x, y, flag, head[N], cnt, dis[N], d, deg[N];
struct node { int u, v ,w; } edge[N << 2];

inline void add(int x, int y, int z) { 
	edge[cnt] = (node) {head[x], y, z}; head[x] = cnt++; 
	edge[cnt] = (node) {head[y], x, -z}; head[y] = cnt++;
	++deg[x], deg[y]++;
}

inline void dfs(int x, int fa) {
	for (int i = head[x]; ~i; i = edge[i].u) {
		int y = edge[i].v;
		if (dis[y] == 0) dis[y] = dis[x] + edge[i].w, dfs(y, x);
		else if (dis[y] != dis[x] + edge[i].w) { flag = 1; return; }
	}
}
int main() {
    std::ios::sync_with_stdio(false), std::cin.tie(0);
    memset(head, -1, sizeof head);
    std::cin >> n >> m;
    for (int i = 1; i <= m; ++i) std::cin >> x >> y >> d, add(x, y, d);
    for (int i = 1; i <= n; ++i)
    	if (! dis[i] && deg[i] > 0) {
    		dis[i] = 1000000010, dfs(i, 0);
    		if (flag) return std::cout << "No" << '\n', 0;
		}
    std::cout << "Yes" << '\n';
    return 0;
}

Measured memory_bytes: 12152
n=int(input())
a=list(int(input())for _ in range(n))
p=a[0]
count=1
for i in range(n):
    if p==2:
        print(1)
        exit()
    else:
        ans=a[p-1]
        p=ans
        count+=1
        if ans==2:
            print(count)
            exit()
print('-1')

Measured memory_bytes: 7072
#include<bits/stdc++.h>
using namespace std;
#define sync ios_base::sync_with_stdio(false), cin.tie(NULL)
#define F first
#define S second
#define eb emplace_back
#define pb emplace_back
#define mt make_tuple
#define gcd __gcd
#define PI 3.141592653589
// Input
#define in(a) scanf("%d",&a)
#define in2(a,b) scanf("%d%d",&a,&b)
#define in3(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define llin(a) cin >> a
#define inl(a) scanf("%lld",&a)
#define read(v,i,n) for(i=0;i<n;i++)in(v[i])
#define twod(mat,i,j,n,m) rep(i,n){rep(j,m)in(mat[i][j]);}
#define sc(ch) scanf("%c",&ch)
#define sstr(str) scanf("%s",str)
// Output
#define pr(a) printf("%d ",a)
#define pr2(a,b) printf("%d %d\n",a,b)
#define pr3(a,b,c) printf("%d %d %d\n",a,b,c)
#define out(a) printf("%d\n",a)
#define outl(a) printf("%lld\n",a)
#define llpr(a) cout << a << " "
#define llout(a) cout << a << "\n"
#define yes printf("YES\n")
#define no printf("NO\n")
#define lin printf("\n")
// Iterator
#define lp(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) for(i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define lower(v,k) lower_bound(v.begin(),v.end(),k)-v.begin()
#define upper(v,k) upper_bound(v.begin(),v.end(),k)-v.begin()
#define tf(mytuple) get<0>(mytuple)
#define ts(mytuple) get<1>(mytuple)
#define tt(mytuple) get<2>(mytuple)
// Debug
#define dbg(v,i,n) for(i=0;i<n;i++)pr(v[i]); lin
#define what(x) cerr << #x << " : " << x << "\n"
#define ck printf("continue\n")
#define debug(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
	cerr << *it << " = " << a << "\n";
	err(++it, args...);
}
// Data Type
#define ll long long int
#define ii pair<int,int>
#define pli pair<ll,int>
#define state tuple<int,int,int>
#define vi vector<int>
#define vii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define viii vector<pair<pair<int,int>,int> >
#define vvii vector<vector<pair<int,int> > >
#define M 1000000007
#define B 300  //check the limits, man
#define N 100003
const ll INF = 1e18;
int main()
{
    int i,n;
    string str;
    llin(str);
    n=1+str.size();
    vi v(n,0);
    rep(i,n-1)
    {
        if(str[i]=='<')
            v[i+1]=max(v[i+1],v[i]+1);
    }
    for(i=n-2;i>=0;i--)
    {
        if(str[i]=='>')
            v[i]=max(v[i],v[i+1]+1);
    }
    ll ans=0;
    rep(i,n)
        ans+=v[i];
    llout(ans);
}




Measured memory_bytes: 2820
#include<stdio.h>

int main(){
	int x,y,z;
	int s,k;
	int cnt=0;
	scanf("%d%d",&k,&s);
	for(int i=0;i<=k;i++){
		for(int j=0;j<=k;j++){
			if(s-i-j>=0&&s-i-j<=k){
				cnt++;
			}
		}
	}
	printf("%d",cnt);
}

Measured memory_bytes: 128
// Legends Never Die.

#include <bits/stdc++.h>

using namespace std;

typedef long long LL;
typedef pair<int, int> pii;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
	ifstream t("/proc/self/status");
	cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

template<typename T> inline int chkmin(T &a, const T &b) { return b < a ? a = b, 1 : 0; }
template<typename T> inline int chkmax(T &a, const T &b) { return b > a ? a = b, 1 : 0; }

template<typename T> inline T read()
{
	register T sum(0), fg(1);
	register char ch(getchar());
	for(; !isdigit(ch); ch = getchar()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getchar()) sum = sum * 10 - '0' + ch;
	return sum * fg;
}

const int n = 500;

int K;

inline void input()
{
	K = read<int>();
}

inline void solve()
{
	if(K <= n)
	{
		printf("%d\n", K);
		for(int i = 1; i <= K; ++i)
		{
			for(int j = 1; j <= K; ++j) printf("%d ", i);
			puts("");
		}
	}
	else
	{
		static int A[n + 5][n + 5];

		for(int i = 1; i <= n; ++i)
			for(int j = 1; j <= n; ++j)
				A[i][j] = (i + j) % n + 1;

		for(int i = 2; i <= n; i += 2)
			for(int j = 1; j <= n; ++j)
				if(A[i][j] + n <= K) A[i][j] += n;

		printf("%d\n", n);
		for(int i = 1; i <= n; ++i)
		{
			for(int j = 1; j <= n; ++j) printf("%d ", A[i][j]);
			puts("");
		}
	}
}

int main()
{
#ifdef K_ON // K-ON!
	freopen("C.in", "r", stdin);
	freopen("C.out", "w", stdout);
#endif

	input();
	solve();

	return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define  fo(i,n) for(ll i=0;i<n;i++)
#define rfo(i,n) for(ll i=n;i>=0;i--)
#define fori(it, x) for (__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define pb push_back
#define deb(x) cout<< #x << " = "<<x<<endl;
#define F first
#define S second
#define MP make_pair
#define all(x) (x).begin(), (x).end()
void solve()
{
	ll l,r,d;
	cin>>l>>r>>d;
	ll ans = 0;
	for(ll i=l;i<=r;i++)
	{
		if(i%d == 0)
		{
			ans++;
		}
	}
	cout<<ans;	
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
	solve();
    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 1000000007;

Int mod_pow(Int x, Int n){
    Int res = 1;
    for(int i = 0;i < 60; i++){
        if(n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

Int gcd(Int a, Int b) {
    return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
    return a * b / gcd(a, b);
}
// a x + b y = gcd(a, b)
Int extgcd(Int a, Int b, Int &x, Int &y) {
    Int g = a; x = 1; y = 0;
    if (b != 0) g = extgcd(b, a % b, y, x), y -= (a / b) * x;
    return g;
}

int A, B;

int main(){
    cin.tie(0);

    cin >> A >> B;
    cout << max({A+B, A-B, A*B}) << endl;
    return 0;
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int i,n,count;
    count=0;
    string s;
    cin >> s;
    n=s.size();
    vector<int> next(n);
    for(i=0;i<n;i++){
        if(s[i]=='R'){
            next[i]=i+1;
        }
            else {next[i]=i-1;
        }
    }
    for(int t=0;t<100;t++){
        vector<int> nn(n);
        for(i=0;i<n;i++){
            nn[i]=next[next[i]];
        }
    nn.swap(next);
    }
    vector<int> ans(n);
    for(int i = 0;i<n;i++){
        ans[next[i]]++;
    }
    for(int i=0;i<n;i++){
        cout<<ans[i]<<" ";
    }
    return 0;


}

Measured memory_bytes: 1392
//InTheNameOfGod
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,j,k) for(int i=j;i<k;++i)
#define rrep(i,j,k) for(int i=j;i>=k;i--)
#define pb push_back
#define lb(i) i&(-i);
const int maxn = 11;
ll x,y,re;
int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);
    re=0;
    cin>>x>>y;
    while(x<=y)
    {
        re++;
        x*=2;
    }
    cout<<re;
    return 0;
}


Measured memory_bytes: 256
// By Mohit Gupta
#include <bits/stdc++.h>
using namespace std;
//DEBUG 
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define printint(v) copy(begin(v), end(v), ostream_iterator<int>(cout," "))
#define printintv(s,e) copy(s,e, ostream_iterator<int>(cout," "))
#define forstl(i,v) for(auto &i: v)
#define all(v) (v).begin(), (v).end()
#define forn(i,e) for(int i = 0; i < e; i++)
#define forsn(i,s,e) for(int i = s; i < e; i++)
#define rforn(i,s) for(int i = s; i >= 0; i--)
#define rforsn(i,s,e) for(int i = s; i >= e; i--)
#define clz(a) __builtin_clz(a) // count leading zeroes
#define ctz(a) __builtin_ctz(a) // count trailing zeroes
#define popc(a) __builtin_popcount(a) // count set bits (for ints only diff for ll)
//https://gcc.gnu.org/onlinedocs/gcc/Other-Builtins.html for other in built
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define pb push_back
#define fi first
#define se second
#define int long long
#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
typedef pair<int,int> p32; 
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
typedef map<int,int> m32;
#pragma GCC optimize ("-O2")
const int LIM = 2e5+5, MOD = 998244353;
int t,n,m,x,y,k;

v32 a[LIM],b[LIM];

void solve(){
    cin>>n;
    forsn(i,0,n+1)  a[i].clear(),b[i].clear();
    int ans=0;
    int left=0,right=0;
    forsn(i,1,n+1){
        int l,r;
        cin>>k>>l>>r;
        if(l>r){
            left=max(left,k);
            ans+=r;
            a[k].pb(l-r);
        }
        else if(r>l){
            right=max(right,n-k);
            ans+=l;
            b[n-k].pb(r-l);
        }
        else ans+=l;
    }
    //stack up all a's and b's greedily
    priority_queue<int> q; //max queue
    for(int i=left;i>=1;i--){
        for(auto j: a[i]) q.push(j);
        if(q.empty()) continue;
        ans+=q.top();
        q.pop();
    }
    
    //erase all unalloted places
    while(!q.empty()) q.pop();

    for(int i=right;i>=1;i--){
        for(auto j: b[i]) q.push(j);
        if(q.empty()) continue;
        ans+=q.top();
        q.pop();
    }
    cout<<ans<<ln;
}

int32_t main()
{
    IOS;
    cin>>t;
    while(t--) solve();
}


Measured memory_bytes: 17732
#include <stdio.h>
#include <string.h>
 
int main(){
 int line[3];
 int count5 = 0;
 int count7 = 0;
  int i;
  if(!((scanf("%d",&line[0])==1) 
		&& (scanf("%d",&line[1])==1)
	&& (scanf("%d",&line[2])==1))){
		return -1;
	}
 for(i=0;i<3;i++){
 	if(line[i]==5){
      count5++;
    }
    if(line[i]==7){
      count7++;
    }
 }
 if(count5==2&&count7==1){
  printf("YES");
 } else {
  printf("NO");
 }
  return 0;
}

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

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}


int main() {
    ll N,K,R,S,P;
    cin >> N >> K;
    cin >> R >> S >> P;
    string enemy_hands;
    cin >> enemy_hands;
    ll score = 0;
    string your_hands;
    vector<bool> force_use(N,false);
    REP(i,N) {
        auto hand = enemy_hands[i];
        if (i>=K){
            if (hand==enemy_hands[i-K]) {
                if (!force_use[i-K]) {
                    force_use[i]= true;
                    continue;
                }
            }
        }

        if (hand=='r') score+=P;
        else if (hand=='s') score+=R;
        else if (hand=='p') score+=S;
    }
    cout << score << endl;


    return 0;
}


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

static const int MAX = 1000;
static const int VMAX=10000;

int n,A[MAX],s;
int B[MAX],T[VMAX+1];

int solve(){
  int ans=0;
  bool V[MAX];
  for(int i=0;i<n;i++){
    B[i]=A[i];
    V[i]=false;
  }
  sort(B,B+n);
  for(int i=0;i<n;i++)T[B[i]]=i;
  for(int i=0;i<n;i++){
    if(V[i])continue;
    int cur=i;
    int S=0;
    int m=VMAX;
    int an=0;
    while(1){
      V[cur]=true;
      an++;
      int v=A[cur];
      m=min(m,v);
      S+=v;
      cur=T[v];
      if(V[cur])break;
    }
    ans+=min(S+(an-2)*m,m+S+(an+1)*s);
  }
  return ans;
}

int main(){
  cin>>n;
  s=VMAX;
  for(int i=0;i<n;i++){
    cin>> A[i];
    s=min(s,A[i]);
  }
  int ans=solve();
  cout <<ans<<endl;
  return 0;
}



Measured memory_bytes: 3184
#include <bits/stdc++.h>
typedef long long LL;
using namespace std;

int main() {
  int n;
  cin >> n;
  bool flag = false;
  for (int i = 0; i < n; i ++) {
    int t; cin >> t;
    if (t % 2 == 1) flag = true;
  }
  if (flag) cout << "first" << endl;
  else cout << "second" << endl;
}

Measured memory_bytes: 256