akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cctype>
#include <string>
using namespace std;

int exp(string &s, int &i);
int term(string &s, int &i);
int factor(string &s, int &i);
int number(string &s, int &i);

int exp(string &s, int &i)
{
  int val = term(s, i);
  while(s[i] == '+' || s[i] == '-'){
    char op = s[i];
    i++;
    int val2 = term(s, i);
    if(op == '+') val += val2;
    else val -= val2;
  }
  return val;
}

int term(string &s, int &i)
{
  int val = factor(s, i);
  while(s[i] == '*' || s[i] == '/'){
    char op = s[i];
    i++;
    int val2 = factor(s, i);
    if(op == '*') val *= val2;
    else val /= val2;
  }
  return val;
}

int factor(string &s, int &i)
{
  if(isdigit(s[i]))
    return number(s, i);
  i++;
  int val = exp(s, i);
  i++;
  return val;
}

int number(string &s, int &i)
{
  int n = s[i] - '0';
  i++;
  while(isdigit(s[i])){
    n = n * 10 + (s[i] - '0');
    i++;
  }
  return n;
}

int main()
{
  int n;
  cin >> n;
  for(int j = 0; j < n; j++){
    string s;
    cin >> s;
    int i = 0;
    cout << exp(s, i) << endl;
  }
}

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

inline int D(){
    int t ;
    scanf( "%d" , &t ) ;
    return t ;
}
inline ll LLD(){
    ll t ;
    scanf( "%lld" , &t ) ;
    return t ;
}
//const int INF = 0x3f3f3f3f;
//const int mod=1e9+7;
//const double pi=3.14159265359;
//###################################################################

int main() {
  int n=D();
  cout<<n+n*n+n*n*n;
}

Measured memory_bytes: 3636
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]
dy8, dx8 = [0, -1, 0, 1, 1, -1, -1, 1], [1, 0, -1, 0, 1, 1, -1, -1]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def ceil(a, b):
    return (a + b - 1) // b


def main():
    X, A, B = map(int, input().split())

    if B <= A:
        print("delicious")
    elif B - A <= X:
        print("safe")
    else:
        print("dangerous")


if __name__ == '__main__':
    main()


Measured memory_bytes: 3952
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;
typedef pair<ll,ll> pll;
const ll mod=1e9+7;
//const ll mod=998244353;
const ll inf=5e18;
 
int main() {
  ll n;
  string s;
  cin >> n >> s;
  string a,b;
  a=s.substr(0,n);
  b=s.substr(n,n);
  reverse(b.begin(),b.end());
  map<pair<string,string>,ll> cnta,cntb; 
  for(ll i=0;i<(1<<n);i++) {
    bitset<20> bit(i);
    string e="",o="";
    for(ll j=0;j<n;j++) {
      if(bit.test(j)) {
        e=e+a[j];
      }
      else {
        o=o+a[j];
      }
    }
    cnta[{e,o}]++;
  }
  for(ll i=0;i<(1<<n);i++) {
    bitset<20> bit(i);
    string e="",o="";
    for(ll j=0;j<n;j++) {
      if(bit.test(j)) {
        e=e+b[j];
      }
      else {
        o=o+b[j];
      }
    }
    cntb[{e,o}]++;
  }
  ll ans=0;
  for(auto p:cnta) {
    ans+=p.second*cntb[p.first];
  }
  cout << ans << endl;
}

Measured memory_bytes: 104192
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

int a, b;
int co;

int gcd(int a, int b){
	if (b == 0)return a;
	co++;
	return gcd(b, a%b);
}

int main(){
	while (cin >> a >> b&&a+b){
		if (a < b)swap(a, b);
		co = 0;
		int ans = gcd(a, b);
		cout << ans << " " << co << endl;
	}
}

Measured memory_bytes: 1156
#include<bits/stdc++.h>
#define ll long long
#define xll __int128
#define fo(i,n) for(int i=0;i<n;i++)
#define rfo(i,n) for(int i=n-1;i>=0;i--)
#define Fo(i,q,n) for(int i=q;i<n;i++)
#define rFo(i,q,n) for(int i=n-1;i>=q;i--)
#define fO(i,n,k) for(int i=0;i<n;i+=k)
#define FO(i,q,n,k) for(int i=q;i<n;i+=k)
#define zero(a,n) memset(a,0,sizeof(a[0])*n)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define endl "\n"
#define Endl "\n"
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl;
using namespace std;
const int MOD=1000000007;
void print(){cout <<endl;}
template <typename T, typename... Types> 
void print(T var1, Types... var2){cout << var1 << " " ;print(var2...) ;}
//ceil of a/b
template <typename T>
T fceil(T a,T b){return (T)(a+b-1)/b;}
template <typename T>
void printvec(vector<T> v){ for(int i=0;i<(int)v.size();i++){ cout<<v[i]<<" ";} cout<<endl;}
template <typename T>
void printarr(T a[],int n){ for(int i=0;i<n;i++){ cout<<a[i]<<" ";} cout<<endl;}
//const int N=2e5;
//int arr[N+1];

 
int main(){
	int a;
cin>>a;
cout<<1-a<<endl;
	return 0;
}






/*NOTE: Take MOD after sorting and not before sorting!*/


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

long long eps = 1000000000000000000;
long long a[100050];

int main()
{
	int n;
	cin>>n;
	int flag = 0;
	long long ans = 1;
	
	for(int i = 0;i<n;++i){
		cin>>a[i];
	}
	
	sort(a,a+n);
	
	if(a[0] == 0) cout<<0<<endl;
	else{
		for(int i = 0;i<n;++i){
			if(a[i] > eps/ans){
				cout<<-1<<endl;
				return 0;
			}
			else ans *= a[i];
		}
		cout<<ans<<endl;
	}
	
	return 0;
} 

Measured memory_bytes: 4432
#include <bits/stdc++.h>
  using namespace std;
#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) int ab;cin>>ab;(p).push_back(ab);
#define vecpl2(p) long long ab;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main() {
	
	
	int N;
	map<int,int> S;
	cin>>N;
	fyg(N+1,1){
		int i=2;
int x=y;
		while(x!=1){
			if(x%i==0){S[i]++;x/=i;}else{
i++;}
		}

	}
ll ans=0;
vector<int> A(5,0);
	fx(100){
if(S[x]>=2){A.at(0)++;}
if(S[x]>=4){A.at(1)++;}
if(S[x]>=14){A.at(2)++;}
if(S[x]>=24){A.at(3)++;}
if(S[x]>=74){A.at(4)++;}
}
ans+=A.at(4);
ans+=A.at(3)*(A.at(0)-1);
ans+=A.at(2)*(A.at(1)-1);
ans+=(A.at(1)*(A.at(1)-1)*(A.at(0)-2))/2;
	ce(ans)
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using str = string;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
const double PI = 3.141592653589793238;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define REP(i, m, n) for (int i = m; i < (int)n; i++)
#define all(a) (a).begin(), (a).end()
#define allg(a) (a).begin(), (a).end(), greator<>()
#define d20 std::setprecision(20)
#define veci vector<int>
#define vecll vector<long long int>

template <typename T>
T lcm(T a, T b)
{
	return a / __gcd(a, b) * b;
}
void comb(vector<vector<ll>> &v) //v{n][k] == nCk
{
	for (int i = 0; i < v.size(); i++)
	{
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int k = 1; k < v.size(); k++)
	{
		for (int j = 1; j < k; j++)
		{
			v[k][j] = v[k - 1][j - 1] + v[k - 1][j];
		}
	}
}
string RunLengthEncoding(string str)
{
	int itr = 0;
	std::string res;
	while (itr < int(str.size()))
	{
		char tmp = str[itr++];
		int length = 1;
		while (itr < int(str.size()) && str[itr] == tmp)
		{
			++itr;
			++length;
		}
		res.push_back(tmp);
		res += to_string(length);
	}
	return res;
}

int a[101][101]={0};

int main()
{
	int n, k;
	cin >> n >> k;
	vector<int> v(n,0);
	rep(i,k){
		int d;
		cin >> d;
		rep(i,d){
			int tmp;
			cin >> tmp;
			tmp--;
			v[tmp]++;
		}
	}
	int ans = 0;
	rep(i,n){
		if(v[i]==0){
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3644
#include <complex>
#include <cstdio>
#include <cmath>
using namespace std;

// ?????§?¨?????????¨??????
typedef complex<double> P;

//XY??§?¨?
#define X real()
#define Y imag()

// ??´???p1,p2??¨??????p3,p4???????????????
// (n < 0)<=>?????? , (n == 0)<=>??´??????, (n > 0)<=>?????????????????????  
double isIntersect(P p1, P p2, P p3, P p4){  
    return ( (p1.X-p2.X)*(p3.Y-p1.Y) + (p1.Y-p2.Y)*(p1.X-p3.X)) * ((p1.X-p2.X)*(p4.Y-p1.Y) + (p1.Y-p2.Y)*(p1.X-p4.X));  
}

int main(){
	double xa, xb, xc, xd, ya, yb, yc, yd;

	while( scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", &xa, &ya, &xb, &yb, &xc, &yc, &xd, &yd) != EOF ){
		P a( xa , ya );
		P b( xb , yb );
		P c( xc , yc );
		P d( xd , yd );
		
		if( isIntersect(a,c,b,d) > 0.0 || isIntersect(b,d,a,c) > 0.0 ){
			printf("NO\n");
		}else{
			printf("YES\n");
		}
	}
}

Measured memory_bytes: 1036
#include<bits/stdc++.h>
using namespace std;
typedef complex<double> xy_t;
int n, temp, ans;
xy_t p[300];
xy_t c[2];
// 内積: a.x*b.x +a.y*b.y
double dot_product(xy_t a, xy_t b) { return (conj(a)*b).real(); }

bool center(xy_t a, xy_t b){
    xy_t dir = b - a;
    if(dot_product(dir, dir) > 4){
        return false;
    }
    xy_t ver = xy_t(-dir.imag(), dir.real());
    ver /= sqrt(dot_product(ver, ver));
    double len = sqrt(1 - dot_product(dir, dir) / 4);
    c[0] = a + dir / 2.0 - ver * len;
    c[1] =  a + dir / 2.0 + ver * len;
    return true;
}
int main(){
    while(cin >> n && n){
        ans = 1; // 最低でも一つは囲める
        for(int i = 0; i < n; i++){
            double x, y;
            cin >> x >> y;
            p[i] = xy_t(x, y);
        }
        for(int i = 0; i < n; i++){
            for(int j = i + 1; j < n; j++){
                if(center(p[i], p[j])){
                    for(int l = 0; l < 2; l++){
                        temp = 2;
                        for(int k = 0; k < n; k++){
                            if(k == i || k == j){
                                continue;
                            }
                            xy_t vec = c[l] - p[k];
                            if(dot_product(vec, vec) <= 1){
                                temp++;
                            }
                        }
                        ans = max(ans, temp);
                    }
                }
            }
        }
        cout << ans << endl;
    }
}


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

using namespace std;

int main(){
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    #endif
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout<<fixed;*/

    const int inf=1e9+5;
    int x[]={0,0,-1,1};
    int y[]={1,-1,0,0};

    int n,m;cin>>n>>m;
    vector<vector<char>> g(n+2,vector<char>(m+2));
    vector<vector<bool>> was(n+2,vector<bool>(m+2));
    vector<vector<int>> d(n+2,vector<int>(m+2,inf));
    vector<pair<int,int>> start;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++){
            cin>>g[i][j];
            if(g[i][j]=='#'){
                start.push_back({i,j});
            }
        }
    }
    queue<pair<int,int>> q;
    for(auto& x:start){
        q.push(x);
        d[x.first][x.second]=0;
        was[x.first][x.second]=1;
    }
    int ans=0;
    while(!q.empty()){
        auto c=q.front();
        q.pop();
        vector<pair<int,int>> v;
        for(int i=0;i<4;i++){
            v.push_back({c.first+x[i],c.second+y[i]});
        }
        for(auto& x:v){
            if(x.first>n||x.first<1||x.second>m||x.second<1||was[x.first][x.second]){
                continue;
            }
            q.push(x);
            d[x.first][x.second]=d[c.first][c.second]+1;
            ans=max(ans,d[x.first][x.second]);
            was[x.first][x.second]=1;
        }
    }
    cout<<ans;

    /*#ifndef ONLINE_JUDGE
        cout << "\nTime Elapsed : " << 1.0 * clock() << " ms\n";
    #endif*/
    return 0;
}


Measured memory_bytes: 21352
N = int(input())
A = list(map(int, input().split()))

colors = [0 for _ in range(8)]
over = 0

for a in A:
    if 1 <= a < 400:
        colors[0] = 1
    if 400 <= a < 800:
        colors[1] = 1
    if 800 <= a < 1200:
        colors[2] = 1
    if 1200 <= a < 1600:
        colors[3] = 1
    if 1600 <= a < 2000:
        colors[4] = 1
    if 2000 <= a < 2400:
        colors[5] = 1
    if 2400 <= a < 2800:
        colors[6] = 1
    if 2800 <= a < 3200:
        colors[7] = 1
    if 3200 <= a:
        over += 1

c = colors.count(1)

maxi = c + over

if c == 0:
    mini = 1
else:
    mini = c

print(mini, maxi)


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		String s = sc.next();
		
		if (s.equals("ABC")){
			System.out.println("ARC");
		} else {
			System.out.println("ABC");
		}

	}


}

Measured memory_bytes: 35640
count = 0


N = int(input())
P = "".join(list(map(str, input().split())))
Q = "".join(list(map(str, input().split())))


ans = []

def dfs(curr, p, q, n):
    if len(curr) == n:
        global count
        count+=1
        if curr == p:
            ans.append(count)
        if curr == q:
            ans.append(count)

        return 

    for i in range(1, n+1):
        if str(i) not in curr:
            dfs(curr + str(i), p, q, n)

for i in range(1, N + 1):
    dfs(str(i), P, Q, N)

print(abs(ans[0]-ans[1]))




Measured memory_bytes: 74280
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <unordered_map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e15;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> tri;
typedef pair<double,double> point;
const ll MAX = 30000;
constexpr ll nx[8] = {1,0,-1,0,1,-1,1,-1};
constexpr ll ny[8] = {0,1,0,-1,1,1,-1,-1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll w;
    cin >> w;
    PRINT(w*32);
}



Measured memory_bytes: 3180
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <iomanip>

using namespace std;

const int N = 1e5 + 7;

vector <int> g[N];
int dp[N];

void dfs(int v, int pr)
{
    for (int to : g[v])
    {
        if (to != pr)
        {
            dfs(to, v);
            dp[v] ^= dp[to] + 1;
        }
    }
}

int main()
{
#ifdef ONPC
    freopen("a.in", "r", stdin);
#endif
    int n;
    scanf("%d", &n);
    for (int i = 1; i < n; i++)
    {
        int x, y;
        scanf("%d%d", &x, &y);
        g[x].push_back(y);
        g[y].push_back(x);
    }
    dfs(1, -1);
    if (dp[1] == 0)
    {
        cout << "Bob" << '\n';
    }
    else
    {
        cout << "Alice" << '\n';
    }
}



Measured memory_bytes: 12416
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <string.h>
#include <iomanip>
#include <stdlib.h>
#include <algorithm>
using namespace std;

int INF = 1<<29;
double Pi = 3.141592653589;
const int mod = 1000000007;
// memset(a,0,sizeof(a)); →全部０にする

long long int i,j;

long long int solve(long long int a,long long int b,long long int c){
	return max(a,max(b,c))-min(a,min(b,c));
}




int main(){
	long long int h,w;
	long long int ans=INF;
	int hh,ww;
	cin>>h>>w;
	for(i=1;i<h;i++){
		hh=h-i;
		if((hh*w)%2==0){
			ans=min(ans,solve((w*hh)/2,(w*hh)/2,i*w));
		}else if(hh>w){
			ans=min(ans,solve((hh/2)*w,(hh/2+1)*w,w*i));
		}else{
			ans=min(ans,solve((w/2)*hh,(w/2+1)*hh,w*i));
		}
	}
	ww=h;
	h=w;
	w=ww;
	for(i=1;i<h;i++){
		hh=h-i;
		if((hh*w)%2==0){
			ans=min(ans,solve((w*hh)/2,(w*hh)/2,i*w));
		}else if(hh>w){
			ans=min(ans,solve((hh/2)*w,(hh/2+1)*w,w*i));
		}else{
			ans=min(ans,solve((w/2)*hh,(w/2+1)*hh,w*i));
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

int main() {
  int r,g,b;
  cin >> r >> g >> b;
  int ans = r*100+g*10+b;
  if(ans%4 == 0){
    cout << "YES" << endl;
    return 0;
  }
  cout << "NO" << endl;
}


Measured memory_bytes: 3600
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <map>
#include <vector>

using namespace std;

void b_strings_with_the_same_length(void) {
	int n;
	string s, t;
	cin >> n >> s >> t;
	
	for (int i = 0; i < n; i++) {
		cout << s[i] << t[i];
	}

	cout << endl;
}

int main()
{
    b_strings_with_the_same_length();

    return 0;
}

Measured memory_bytes: 3608
n,a,b = map(int, input().split())
s = input()
kaigai = 0
sankasha = 0
for i in range(n):
    if s[i] == "c":
        print("No")
    else:
        if s[i] == "b":
            if kaigai < b and sankasha < a+b:
                sankasha += 1
                kaigai += 1
                print("Yes")
            else:
                print("No")
        else:
            if sankasha < a+b:
                sankasha += 1
                print("Yes")
            else:
                print("No")

Measured memory_bytes: 4016
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#define ll long long
using namespace std;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll x,y;
    cin>>x>>y;
    cout<<x+(y>>1);
    return 0;
}


Measured memory_bytes: 256
import fractions
from functools import reduce

def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)

n, x = list(map(int, input().split(" ")))
y = list(map(int, input().split(" ")))

z = []
for i in y:
    z.append(abs(i-x))

print(gcd_list(z))

Measured memory_bytes: 16284
#include <algorithm>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
//#include <bits/stdc++.h>
#define FOR(i,k,n) for (int (i)=(k); (i)<(n); ++(i))
#define RFOR(i,k,n) for (int (i)=(n)-1; (i)>=(k); --(i))
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define debug(x) cerr<< #x <<": "<<x<<endl
#define debug2(x,y) cerr<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl
using namespace std;
//static const int INF = 1e9;
//static const double PI = acos(-1.0);
//static const double EPS = 1e-10;
//static const int dx[8] = { 1, 1, 0,-1,-1,-1, 0, 1};
//static const int dy[8] = { 0, 1, 1, 1, 0,-1,-1,-1};
typedef long long int LL;
typedef unsigned long long int ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef vector<char> VC;
typedef vector<VC> VVC;
typedef vector<bool> VB;
typedef vector<VB> VVB;
typedef pair<int, int> PII;

// initialization
template<typename A, size_t N, typename T> void FILL(A (&array)[N], const T &val){
  fill( (T*)array, (T*)(array+N), val );
}

// pair
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {
  return s << "(" << p.first << ", " << p.second << ")";
}
// vector
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
  int len = v.size();
  for (int i = 0; i < len; ++i) {
    s << v[i]; if (i < len - 1) s << "\t";
  }
  return s;
}
// 2 dimentional vector
template<typename T> ostream& operator<<(ostream& s, const vector< vector<T> >& vv) {
  int len = vv.size();
  for (int i = 0; i < len; ++i) {
    s << vv[i] << endl;
  }
  return s;
}

int main() {
  int N, a;
  cin >> N;
  vector<set<int> > Graph(N);
  int ans = 0;
  REP(i, N) {
    cin >> a;
    Graph[i].insert(a - 1);
    if(Graph[a - 1].find(i) != Graph[a - 1].end()) { ans++; }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 9600
#pragma GCC optimize ("-O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include<cmath>
#include<cstdio>
#include<algorithm>
#include<bitset>
#include<complex>
#include<deque>
#include<fstream>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<limits>
#include<list>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<utility>
#include<valarray>
#include<vector>
#include<array>
#include<forward_list>
#include<random>
#include<ratio>
#include<tuple>
#include<unordered_map>
#include<unordered_set>
#include<cstring>

using namespace std;
using Int = long long; using uint = unsigned int; using uInt = unsigned long long;
typedef pair<int,int> Pi; typedef pair<Int,Int> Pl;
constexpr int mod = 1e9+7;
constexpr int INF32 = numeric_limits<int>::max();
constexpr Int INF64 = numeric_limits<Int>::max();
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define mp make_pair
#define Pr(t) priority_queue<t>
#define gPr(t) priority_queue<t,vector<t>,greater<t>>
#define V(t) vector<t>
#define rep(i,n) for(int i=0; i<(n); ++i)
#define rer(i,l,r) for(int i=(l); i<=(r); ++i)
#define gnr(i,l,r) for(int i=(r); i>=(l); --i)
#define eb emplace_back
#define pri1(a) cout<<(a)<<'\n'
#define pri2(a,n) {rep(i,n-1)cout<<a[i]<<' '; if(n)cout<<a[n-1]<<'\n';}
#define prip(p) cout<<p.fi<<' '<<p.se<<'\n'
#define priend(a) {cout<<(a)<<'\n'; return 0;}
#define fil(a,v) memset((a),v,sizeof(a))
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n,m,_,x,y,q;
string s,sb;
bool ok;
char cf,cb;

int dp[3001][3001];
int main(){
  cin.tie(nullptr); ios::sync_with_stdio(0);
  //cout<<fixed<<setprecision(20);

  cin>>n>>m; Pi a[n]; rep(i,n)cin>>a[i].fi>>a[i].se; sort(a,a+n);
  int ans=0;
  rep(i,n){
    rer(j,1,m-1){
      if(j>=a[i].fi)cmax(dp[i+1][j],dp[i][j-a[i].fi]+a[i].se);
      cmax(dp[i+1][j],dp[i][j]);
    }
    cmax(ans,dp[i][m-1]+a[i].se);
  }
  END
}

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

long long floor_(long long a, long long b){
  if(b < 0) a *= -1, b *= -1;
  if(a > 0 and b > 0)
    return a/b;
  long long r = (a%b+b)%b;
  return (a-r)/b;
}

int main(){
  long long N, K;
  cin >> N >> K;
  vector<long long> A(N);
  for(int i = 0; i < N; ++i) cin >> A[i];
  sort(A.begin(), A.end());

  auto cnt = [&](long long m){
               long long ret = 0;
               for(int i = 0; i < N; ++i){
                 if(!A[i]){
                   if(m >= 0) ret += N-1;
                   continue;
                 }

                 if(A[i] < 0){
                   int ok = N, ng = -1;
                   while(ok-ng > 1){
                     int mid = (ok+ng)/2;
                     if(A[i]*A[mid] <= m) ok = mid;
                     else ng = mid;
                   }
                   ret += N-ok;
                 }else{
                   int ok = N, ng = -1;
                   while(ok-ng > 1){
                     int mid = (ok+ng)/2;
                     if(A[i]*A[mid] > m) ok = mid;
                     else ng = mid;
                   }
                   ret += ok;
                 }
                 if(A[i]*A[i] <= m) --ret;
               }
               ret /= 2;
               return ret;
             };
  const long long INF = 1e18;
  long long ok = INF+1, ng = -(INF+1);
  while(ok-ng > 1){
    long long m = (ok+ng)/2;
    long long c = cnt(m);
    // cerr << m << " " << c << endl;
    if(c < K) ng = m;
    else ok = m;
  }
  cout << ok << endl;
}


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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;

void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    int n;
    cin >> n;
    priority_queue <float, vector<float>, greater<float> > pq;
    FOR(i, 1, n)
    {
        float x;
        cin >> x;
        pq.push(x);
    }
    float res = 0;
    while(pq.size() > 1)
    {
        float x = pq.top();
        pq.pop();
        float y = pq.top();
        pq.pop();
        res = (x + y) / 2;
        pq.push(res);
    }
    cout << fixed << setprecision(5) << pq.top();
    return 0;
}


Measured memory_bytes: 256
process.stdin.resume();
process.stdin.setEncoding('utf8');

var lines = [];
var reader = require('readline').createInterface({
  input: process.stdin,
  output: process.stdout
});
reader.on('line', (line) => {
  lines.push(line);
});
reader.on('close', () => {
    let [N, K] = lines[0].split(" ").map(v=>BigInt(v));
    const map = {};
    let ans = N;
    while(!map[N]){
        const a = N%K;
        map[a] = true;
        ans = ans>a?a:ans;
        N = K>a?K-a:a-K;
        if(ans==0)break;
    }
    console.log(ans.toString());
    
});


Measured memory_bytes: 31080
X, Y, A, B, C = [int(i) for i in input().split()]
P = [int(i) for i in input().split()]
Q = [int(i) for i in input().split()]
R = [int(i) for i in input().split()]
P.sort()
Q.sort()
R.sort(reverse=True)

cand = P[-X:] + Q[-Y:]
cand.sort()
i = 0
while(i<X+Y and i<C):
    if(cand[i]>=R[i]):
        break
    i += 1
print(sum(cand[i:])+sum(R[:i]))


Measured memory_bytes: 23644
#include <iostream>
#include <string>
#include <math.h>

using namespace std;

int main(int argc, char const *argv[]){
    int a, b, c, d;
    scanf("%d %d %d %d",&a, &b, &c, &d);

    if(a*b >= c*d){
        printf("%d\n", a*b);
    }
    else{
        printf("%d\n", c*d);
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
int n;
cin >>n;
int a[n],b=0,c=0;
for (int i=0;i<n;i++){
cin >>a[i];
if (a[i]%2==0)b++;
else c++;
}
if (c>=1)cout <<"first" <<endl;
else cout<<"second"<<endl;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
long long int gcd(long long int a , long long int b)
{
    if(b==0)
    {

        return a;
    }
    return gcd(b,a%b);


}



int main()
{

long long int a,b,c,k;
cin>>a>>b>>c>>k;
long long int ans=0;
if(k>0)
{
    if(k>=a)
    {

        ans=ans+a;
        k=k-a;
    }
    else{
        ans=ans+k;
        k=0;
    }

}
if(k>0)
{

    k=k-b;

}

if(k>0)
{

    ans=ans-k;



}

cout<<ans<<endl;



return 0;

}


Measured memory_bytes: 3620
#include <iostream>
#include <numeric>
#include <algorithm>
#include <functional>
#include <vector>
#include <cmath>
#include <chrono>
#include <queue>
#include <set>
#include <cassert>
#include <random>
#include <chrono>
#include <complex>
#include <cstring>
int main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::string s;
    std::cin >> s;
    std::replace(s.begin(), s.end(), '?', 'D');
    std::cout << s << std::endl;
    return 0;
}

Measured memory_bytes: 3740
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please


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


	int N;
	cin >> N;
	string S[100];
	int T[100];

	rep(i, N) {
		cin >> S[i] >> T[i];
	}
	string X;
	cin >> X;

	int kotae = 0;
	int neta = 0;
	rep(i, N) {
		if (neta) kotae += T[i];
		else {
			if (S[i] == X) neta = 1;
		}
	}

	co(kotae);



	Would you please return 0;
}

Measured memory_bytes: 256
/* package whatever; // don't place package name! */

/* package whatever; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		if( a < 1000 ){
			System.out.println("ABC");
		}
		else{
			System.out.println("ABD");
		}
	}
}

Measured memory_bytes: 21972
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>

using namespace std;

int main()
{
    int a[5][105],n;
    while(scanf("%d",&n)!=EOF)
    {
        for (int i=1;i<=2;i++)
            for (int j=1;j<=n;j++) scanf("%d",&a[i][j]);
        for (int i=n;i>1;i--)
        {
            a[2][i-1]+=a[2][i];
        }
        a[1][n]+=a[2][n];
        for (int i=n-1;i>=1;i--)
            a[1][i]+=max(a[1][i+1],a[2][i]);
        printf("%d\n",a[1][1]);
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<string>
#include<stack>
#include<cstdio>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define rep1(i,x) for(int i=1;i<=x;i++)
#define sor(v) sort(v.begin(),v.end())
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))

const int INF=1000000000;
const int dre_4[4][2]={{1,0},{0,1},{-1,0},{0,-1}};
const int dre_8[8][2]={{1,0},{1,1},{0,1},{-1,1},{-1,0},{-1,-1},{0,-1},{1,-1}};

char a[110][110];

void dfs(int x,int y,char c){
	if(a[x][y]!=c)return;
	a[x][y]='.';
	
	rep(i,4){
		dfs(x+dre_4[i][0],y+dre_4[i][1],c);
	}
}

int main(){
	while(1){
		int h,w;
		cin>>h>>w; if(h==0&&w==0)break;
		
		rep(i,110)rep(j,110)a[i][j]='.';
		rep1(i,h){
			scanf("\n");
			rep1(j,w){
				cin>>a[i][j];
			}
		}
		
		int ret=0;
		rep1(i,h){
			rep1(j,w){
				if(a[i][j]!='.'){
					dfs(i,j,a[i][j]);
					ret++;
				}
			}
		}
		
		cout<<ret<<endl;
	}
}

Measured memory_bytes: 1644
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
 
int main()
{
    int b, f, r, v;;
    int house[5][4][11];
    int i, n;
 
    for (b = 1; b <= 4; b++) {
        for (f = 1; f <= 3; f++) {
            for (r = 1; r <= 10; r++) house[b][f][r] = 0;
        }
    }
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%d%d%d%d", &b, &f, &r, &v);
        house[b][f][r] += v;
    }
 
    for (b = 1; b <= 4; b++) {
        for (f = 1; f <= 3; f++) {
            for (r = 1; r <= 10; r++) printf(" %d", house[b][f][r]);
            putchar('\n');
        }
        if (b < 4) puts("####################");
    }
    return 0;
}


Measured memory_bytes: 2132
#include <bits/stdc++.h>
#define INF 2e9
#define MOD 1000000007
#define MOD9 998244353
#define intMAX 51000;
#define PI 3.14159265359
using namespace std;
typedef long long llong;
typedef long double ldouble;

using Graph = vector<vector<int>>;

int main(){
	int N;
	cin >> N;
	vector<int> ans(10001, 0);
	for(int x=1; x<=100; ++x){
		for(int y=1; y<=100; ++y){
			for(int z=1; z<=100; ++z){
				int prod = x*x + y*y + z*z + x*y + y*z + z*x;
				if(prod<=10000) ++ans[prod];
			}
		}
	}
	for(int i=1; i<=N; ++i){
		cout << ans[i] << endl;
	}
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
template<typename key>
using ordered_set = tree<key, null_type, less<key>, rb_tree_tag, tree_order_statistics_node_update>;
#define F first
#define S second
#define T second.first
#define D second.second
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);
#define all(v) v.begin(),v.end()
#define OO 0x3f3f3f3fLL
#define INF 0x3f3f3f3f3f3f3f3fLL
#define sz(s) (int)(s.size())
#define RT(s) return cout<<s,0
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pii;
typedef pair<ll,pair<ll,ll>> piii;
const int N = 2e5+5, M= 20, mod = 1000000000;
const double EPS = 1e-10;


int main(){
    FIO
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    int n;
    cin>>n;
    ll A[n];
    for(int i=0; i<n; i++){
        cin>>A[i];
    }
    int ans = 0;
    for(int i=0; i<n; i++){
        for(int j=i+1; j<n; j++){
            for(int k = j+1; k<n; k++){
                if(A[i]+A[j]>A[k] && A[i]+A[k]>A[j] && A[k]+A[j]>A[i] && A[i]!=A[j] && A[i]!=A[k] && A[k] != A[j])
                    ans++;
            }
        }
    }
    cout<<ans;
}


Measured memory_bytes: 3648
import java.util.Scanner

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val s = sc.next()

    if (s != s.reversed()) {
        println("No")
        return
    }

    val n = s.length
    val startSub = s.substring(0, (n - 1) / 2)
    if (startSub != startSub.reversed()) {
        println("No")
        return
    }

    val endSub = s.substring((n + 1) / 2, n)
    if (endSub != endSub.reversed()) {
        println("No")
        return
    }

    println("Yes")

}

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

using namespace std;

void solve()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	int H;
	while (cin >> H, H)
	{
		vector< vector<int> > stone(H, vector<int>(5));
		for (int i = 0; i < H; ++i)
		{
			for (int j = 0; j < 5; ++j)
			{
				cin >> stone[i][j];
			}
		}
		int preSum = -1;
		int sum = 0;
		while (preSum != sum)
		{
			preSum = sum;
			for (int i = 0; i < H; ++i)
			{
				if (stone[i][0] == stone[i][1] && stone[i][1] == stone[i][2] && stone[i][2] == stone[i][3] && stone[i][3] == stone[i][4])
				{
					sum += stone[i][0] * 5;
					stone[i][0] = stone[i][1] = stone[i][2] = stone[i][3] = stone[i][4] = 0;
				}
				else if (stone[i][0] == stone[i][1] && stone[i][1] == stone[i][2] && stone[i][2] == stone[i][3])
				{
					sum += stone[i][0] * 4;
					stone[i][0] = stone[i][1] = stone[i][2] = stone[i][3] = 0;
				}
				else if (stone[i][1] == stone[i][2] && stone[i][2] == stone[i][3] && stone[i][3] == stone[i][4])
				{
					sum += stone[i][1] * 4;
					stone[i][1] = stone[i][2] = stone[i][3] = stone[i][4] = 0;
				}
				else if (stone[i][0] == stone[i][1] && stone[i][1] == stone[i][2])
				{
					sum += stone[i][0] * 3;
					stone[i][0] = stone[i][1] = stone[i][2] = 0;
				}
				else if (stone[i][1] == stone[i][2] && stone[i][2] == stone[i][3])
				{
					sum += stone[i][1] * 3;
					stone[i][1] = stone[i][2] = stone[i][3] = 0;
				}
				else if (stone[i][2] == stone[i][3] && stone[i][3] == stone[i][4])
				{
					sum += stone[i][2] * 3;
					stone[i][2] = stone[i][3] = stone[i][4] = 0;
				}
			}
			for (int i = H - 1; i >= 0; --i)
			{
				for (int j = 0; j < 5; ++j)
				{
					if (stone[i][j] == 0)
					{
						int pos = i - 1;
						while (pos >= 0 && stone[pos][j] == 0)
						{
							--pos;
						}
						if (pos >= 0)
						{
							swap(stone[i][j], stone[pos][j]);
						}
					}
				}
			}
		}
		cout << sum << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1228
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<n; i++)
typedef long long ll;
typedef long long unsigned int llu;
ll mod = 1000000007;
ll INF = 1000000009;

/*
各ペアについて、和がxを超えていれば、右を減らす
右が0なら左をxまで減らす
*/

void solve(){
    int n,x;
    cin >> n >> x;
    int a[n+10];
    rep(i,n){
        cin >> a[i];
    }
    ll count = 0;
    for(int i=1; i<n; i++){
        if(a[i-1]+a[i]>x&&a[i-1]<=x) {
            count += (a[i]+a[i-1]-x);
            a[i]=x-a[i-1];
        }
        else if(a[i-1]+a[i]>x&&a[i-1]>x){
            count += a[i];
            count += a[i-1]-x;
            a[i]=0;
            a[i-1] = x;
        }
    }
    cout << count << endl;
}

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


Measured memory_bytes: 640
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define RALL(n) rbegin(n),rend(n)
#define MOD (1000000007)
#define INF (2e9)
#define INFL (2e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
using vint=vector<int>;
using vll=vector<ll>;
using vbool=vector<bool>;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main()
{
    string s; cin >> s;
    stack<int> stk;
    int pair = 0;
    rep(i, s.size()){
        if(s[i]=='S'){
            if(stk.empty()) stk.push(0);
            else stk.push(stk.top()+1);
        }else{
            if(stk.empty()) continue;
            stk.pop();
            pair++;
        }
    }
    pr((int)s.size() - 2*pair);
    return 0;}

Measured memory_bytes: 4008
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds; 
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define T pair<int, int>
#define ordered_set tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>
#define int long long
#define MOD 1000000007
#define pb push_back 
#define ins insert
#define fast(); ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ld long double
#define endl '\n'
int m(int a) {
    return ((a%MOD)+MOD)%MOD;
}
int p(int a, int b) {
    if (b==0) return (int)1;
    int x = p(a, b>>1);
    if (b & 1) return m(x*m(a*x));
    return m(x*x);
}
signed main(){
    fast();
    int n;
    cin >> n;
    int ans = 0;
    for(int i=1; i<=n; i++){
        for(int j=1; j<=n; j++){
            for(int k=1; k<=n; k++){
                ans += __gcd(i, __gcd(j, k));
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3652
#include<iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <bitset>
#include <stack>
#include <queue>
#include <fstream>

using namespace std;
using ll=long long;

#define PRI(n) cout << n <<endl;
#define PRI2(n, m) cout << n << " " << m << endl;
#define PRI3(n, m, o) cout << n << " " << m<< " " << o << endl;

#define REP(i, n)  for(int i = 0; i < (int)n; ++i)
#define REPInv(i, n)  for(int i = n-1; i >= 0; --i)

#define FOR(i, t, n)  for(int i = t; i <= (int)n; ++i)
#define FORInv(i, t, n)  for(int i = t; i >= (int)n; --i)

const char alphabet[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r',
                           's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};
const ll MOD = 1e9 + 7;

bool isPrime(ll x) {
    if (x == 0)return 0;
    if (x == 1)return 0;
    if (x == 2)return 1;
    if (x % 2 == 0)return 0;
    FOR(i, 3, x - 1) {
        if (x % i == 0)return 0;
    }
    return 1;
}

ll GCD(ll a, ll b) {
    if (b == 0)return a;
    return GCD(b, a % b);
}

ll LCM(ll a, ll b) {
    ll gcd = GCD(a, b);
    return a / gcd * b;
}

ll nCr(int n, int r) {
    vector<ll> C(r + 1);
    C[0] = 1;
    FOR(i, 1, n) FORInv (j, min(i, r), 1)C[j] = (C[j] + C[j - 1]) % MOD;
    return C[r];
}

struct edge {
    int to, cost;
    bool flag = false;
};
ll N, M;
string S;
vector<edge> X[100010];
bool B[100010];
int D[100010];


int main() {
    cin >> N >> M;
    int c=0,ans=0;
    int a, b;
    cin >> a;
    REP(i, N-1) {
        cin >> b;
        if(b-a>c){
            c = b-a;
            ans = 1;
        }else if(b-a==c){
            ans++;
        }
        if(a>b)a=b;
    }
    PRI(ans)
    return 0;

}


Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		//String line = br.readLine();
		Scanner scan = new Scanner(System.in);

	    int a = scan.nextInt();
	    int b = scan.nextInt();
	    
	    if(a*b%2==0)
	        System.out.println("Even");
	    else
	    	System.out.println("Odd");


	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;
mt19937 mrand(random_device{}()); 
const ll mod=1000000007;
int rnd(int x) { return mrand() % x;}
ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
// head

#define bit(x) (1ll<<(x))

const int N=101000;
const ll M=100000000000000000ll;
int n;
ll x[N],y[N];
int c[N];
void query(ll l,ll r) {
	if (l==r) {
		printf("%lld\n",l-M);
	} else {
		ll md=(l+r)>>1;
		ll cnt=0;
		rep(i,0,n) {
			// x[i]+ subset of  y[i]
			ll fl=max(0ll,l-x[i]);
			ll fr=min(y[i],md-x[i]);
			if (fr<fl) continue;
			ll cr=0; int num=c[i]-1; ll posr=1;
			ll cl=y[i]; ll posl=bit(num+1)-1;
			per(j,0,60) if (y[i]&bit(j)) {
				if (cr+bit(j)<=fr) cr+=bit(j), posr+=bit(num);
				if (cl-bit(j)>=fl) cl-=bit(j), posl-=bit(num);
				--num;
			}
//			printf("%lld %lld %d %lld %lld %lld\n",l-M,r-M,i,posl,posr,posr-posl);
			cnt^=posr-posl;
		}
		if (cnt&1) query(l,md); else query(md+1,r);
	}
}
int main() {
	scanf("%d",&n);
	rep(i,0,n) {
		scanf("%lld%lld",x+i,y+i);
		if (y[i]<0) {
			y[i]=(bit(60)+y[i]);
		}
		x[i]+=M;
		c[i]=__builtin_popcountl(y[i]);
	}
	query(0,bit(58)-1);
}


Measured memory_bytes: 2176
#define _USE_MATH_DEFINES	//M_PI
#include <iostream>			//std::cout, std::cin
#include <string>			//std::string
#include <vector>			//std::vector
#include <algorithm>		//std::sort
#include <time.h>			//localtime_s
#include <cstdlib>			//abs
#include <cmath>			//abs, pow, sqrt, sin, cos,
#include <fstream>			//std::ifstream
#include <iomanip>			//std::setprecision

int main(void) {



	int a, b, C;
	std::cin >> a >> b >> C;

	double S = a * b * sin(C*M_PI/180.0) / 2.0;
	double L = a + b + sqrt(pow(a, 2) + pow(b, 2) - (2 * a*b*cos(C*M_PI / 180.0)));
	double H = b*sin(C*M_PI / 180.0);

	std::cout << std::fixed << std::setprecision(6) << S << std::endl;
	std::cout << std::fixed << std::setprecision(6) << L << std::endl;
	std::cout << std::fixed << std::setprecision(6) << H << std::endl;

}

Measured memory_bytes: 1288
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>

using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
int main(){
    int N,T;
    cin >> N >> T;
    int ans =INT_MAX;
    for(int i = 0 ; i < N; i++){
        int c,t;
        cin >> c >> t;
        if( t <= T){
            ans = min(ans,c);
        }
    }
    if(ans==INT_MAX) cout <<"TLE"<<endl;
    else cout << ans << endl;


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <set>
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, m, n) for(int i = m; i < n; i++)
#define ALL(v) v.begin(),v.end()
#define INF 1e9
typedef long long ll;
using namespace std;

int main() {
    string s; cin >> s;
    string ans = "";
    REP(i,1,s.size()+1){
        if(i%2!=0){
            ans += s[i-1];
        }
    }
    cout << ans << endl;

    return 0;
}

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

int main(){

  int n,q;
  while(1){
    cin >> n >> q;
    if(!n and !q) break;

    int x[10000]={};
    for(int j=0; j<n; j++){
      int m;
      cin >> m;
      int p=0;
      for(int i=0; i<m; i++){
	int d; cin >> d;
	x[d]++;
      }
    }
    q--;
    int ans = -1;
    for(int i=0; i<10000; i++){
      if(x[i] > q){
	ans = i;
	q = x[i]; 
      }
    }
    if(ans == -1) 
      cout << 0 << endl;
    else
      cout << ans << endl;
  }

}

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

int main()
{
	char a[10],b[10],c[10];
	cin>>a>>b>>c;
	if(a[strlen(a)-1]==b[0] and b[strlen(b)-1]==c[0]) cout<<"YES"<<endl;
	else cout<<"NO";
}


Measured memory_bytes: 256