akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(t) t.begin(), t.end()
#define inrange(i, a, b) (((i)>= min((a), (b))) && ((i) <= max((a), (b))))
typedef vector<ll> vi;
#define fi first
#define se second
const ll inf = 9e18;
const ll mod = 1e9 + 7;

void print(ll a[], ll n){for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<"\n";}
ll power(ll x, ll y, ll M = inf){
    ll ans = 1;
    x %= M;
    while(y){
        if(y&1)
            ans = (x * ans) % M;

        x = (x * x) % M;
        y >>= 1;
    }
    return ans;
}
ll modInverse(ll n) {return power(n, mod-2, mod);}
inline ll mul(ll a, ll b){ return (a * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > mod) c -= mod; return c; }
inline ll divi(ll a, ll b){ return mul(a, modInverse(b)); }

	ll dp[3001][3001];

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

	string s, t;
	cin>>s>>t;
	for(int i=0;i<=s.size();i++){
		for(int j=0;j<=t.size();j++){
			if(i==0 || j==0)
				dp[i][j] = 0;
			else if(s[i-1] == t[j-1]){
				dp[i][j] = dp[i-1][j-1] + 1;
			}
			else{
				dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
			}
		}
	}
	ll i = s.size();
	ll j = t.size();
	string er = "";
	while(i>0 && j>0){
		if(s[i-1] == t[j-1]){
			er = s[i-1] + er;
			i--;
			j--;
		}
		else if(dp[i][j-1] > dp[i-1][j]){
			j--;
		}
		else{
			i--;
		}
	}
	cout<<er;
	return 0;
}

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

using namespace std;

#define intt long long
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int N = 105;
const intt INF = 1e18L + 5;

int n, W;

int main() {
	
	FAST;
	
	cin >> n >> W;
	vector <int> v(n + 1), w(n + 1);
	for (int i = 1; i <= n; i ++) {
		cin >> w[i] >> v[i];
	}
	int V = 0;
	for (int i = 1; i <= n; i ++) {
		V += v[i];
	}
	vector <intt> dp(V + 1, INF);
	dp[0] = 0;
	for (int k = 1; k <= n; k ++) {
		for (int x = V; x >= 0; x --) {
			if (x - v[k] >= 0) {
				dp[x] = min(dp[x], w[k] + dp[x - v[k]]);
			} 
		}
	}
	for (int x = V; x >= 0; x --) {
		if (dp[x] <= W) {
			cout << x << '\n';
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define INF 100000000
#define INFF 9223372036854775807
#define ll long long
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,m,n) for(int i=m;i<n;i++)
#define ALL(N) (N.begin(),N.end())
#define de cout << "debug" << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main() {
    int N;
    cin >> N;
    int x[110],y[110],h[110];
    REP(i,N) cin >> x[i] >> y[i] >> h[i];
    int a, b;

    int MAX = 101;
    REP(i,MAX){
        REP(j,MAX){
            int needH = -1;
            REP(k,N){
                if(h[k] > 0){
                    int tmp = h[k] + abs(i-y[k]) + abs(j-x[k]);
                    if(needH == -1) {
                        needH = tmp;
                    }
                    else {
                        if(needH != tmp){
                            needH = -2;
                            break;
                        }
                    }
                }
            }

            if(needH == -2) continue;

            REP(k,N){
                if(h[k] == 0){
                    int dist = abs(i-y[k])+abs(j-x[k]);
                    if(needH > dist){
                        needH = -2;
                        break;
                    }
                }
            }

            if(needH == -2) continue;

            cout << j << " " << i << " " << needH << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
/*
    Author : Nishant Gupta 2.0
*/
#include<bits/stdc++.h>
using namespace std;

#define LL long long int
#define getcx getchar_unlocked
#define X first
#define Y second
#define PB push_back
#define MP make_pair
#define MAX 100005
#define LOG_MAX 20
#define MOD 1000000007
#define INF 0x3f3f3f3f
#define INFL (LL(1e18))
#define chk(a) cerr << endl << #a << " : " << a << endl
#define chk2(a,b) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << endl
#define chk3(a,b,c) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << endl
#define chk4(a,b,c,d) cerr << endl << #a << " : " << a << "\t" << #b << " : " << b << "\t" << #c << " : " << c << "\t" << #d << " : " << d << endl
#define rep(i, a, n) for(i=a;i<n;i++)
#define rev(i, a, n) for(i=a;i>=n;i--)
#define in(x) scanf("%d", &x)
#define inl(x) scanf("%lld", &x)
#define in2(x, y) scanf("%d %d", &x, &y)
#define inl2(x, y) scanf("%lld %lld", &x, &y)
#define MSV(A,a) memset(A, a, sizeof(A))
#define rep_itr(itr, c) for(itr = (c).begin(); itr != (c).end(); itr++)
#define finish(x) {cout<<x<<'\n'; return;}
typedef pair<int, int> pi;
typedef pair<LL, LL> pl;
const char en = '\n';

vector<LL> v;
void solve() {
	LL n, x, m;
	inl2(n, x);inl(m);
	
	v.PB(0);
	v.PB(x);
	vector<LL> pos(m, -1);
	pos[x] = 1;
	
	LL idx = 2;
	LL loop = -1;
	for(idx=2;;idx++) {
		LL mod = (v[idx-1]*v[idx-1]) % m;
		if(pos[mod] != -1) {
			loop = pos[mod];
			break;
		}
		v.PB(mod);
		pos[mod] = idx; 
	}
	
	if(loop <= 0) raise(SIGABRT);
	
	idx--;
	for(LL i=1;i<=idx;i++) {
		v[i] += v[i-1];
	}
	
	if(n <= idx) {
		finish(v[n]);
	}
	
	LL ans = v[idx];
	n -= idx;
	LL sz = idx - loop + 1;
	LL sum_loop = v[idx] - v[loop-1];
	ans = ans + (sum_loop) * (n/sz);
	
	
	LL rem = n % sz;
	if(rem != 0) ans = ans + v[loop+rem-1] - v[loop-1];
	
	cout<<ans<<en;
}

int main() {
	int t = 1;
	
	//~cin>>t;
	while(t--) {
		solve();
	}
    return 0;
}


Measured memory_bytes: 4700
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
main(){
    vector<int> xs(5); for(auto& x:xs) cin>>x;
    int k; cin>>k;
    vector<pair<int,int>> xss;
    for(int i=0; i<5; ++i){
        for(int j=0; j<5; ++j){
            xss.push_back({xs[i], xs[j]});
        }
    }
    vector<bool> bools;
    for(auto xs:xss){
        int p=xs.first, q=xs.second;
        bools.push_back(abs(p-q) <= k);
    }
    bool exists=find(bools.begin(), bools.end(), false) != bools.end();
    printf(exists ? ":(\n" : "Yay!\n");
}

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

using namespace std;

#define LL long long
#define pb push_back
#define pLL pair<LL,LL>
#define ff first
#define ss second
#define rep(i,a,b) for(LL i=a;i<=b;++i)
#define repb(i,a,b) for(LL i=a;i>=b;--i)
#define ld double
#define mp make_pair
#define vLL vector<LL>
#define vpLL vector<pLL>
#define vld vector<ld>
#define pld pair<ld,ld>
#define vpld vector<pld>
#define SLL set<LL>
#define SpLL set<pLL>
#define FIO ios::sync_with_stdio(false)

LL n,k,a[100005];

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cin>>n>>k;
	rep(i,1,n) cin>>a[i];
	LL ans=0,sum=0;
	rep(i,2,k) sum+=abs(a[i]-a[i-1]);
	if(a[1]<0 and a[k]>0) ans=sum+abs(min(-a[1],a[k]));
	else if(a[1]>=0) ans=sum+a[1];
	else if(a[k]<=0) ans=sum+abs(a[k]);
	rep(i,2,n-k+1){
		sum-=abs(a[i]-a[i-1]);
		sum+=abs(a[i+k-1]-a[i+k-2]);
		if(a[i]<0 and a[i+k-1]>0) ans=min(ans,sum+abs(min(-a[i],a[i+k-1])));
		else if(a[i]>=0) ans=min(ans,sum+a[i]);
		else if(a[i+k-1]<=0) ans=min(ans,sum+abs(a[i+k-1]));
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define COUT(x) cout<<(x)<<endl
typedef long long ll;
template<class T> inline void chmax(T& a, T b) {
  if (a < b) a = b;
}

template<class T> inline void chmin(T& a, T b) {
  if (a > b) a = b;
}
const int MOD = 1000000007;
const long long INF = 1LL << 60;


int main() {
  int a,b;
  cin >> a >> b;
  
  cout << a * b << endl;
}

Measured memory_bytes: 3636
#!/usr/bin/env python3

import sys
sys.setrecursionlimit(300000)

MOD = 1000000007  # type: int

def solve(N: int, K: int):
    sums = [0] * (N + 2)
    for i in range(1, N + 2):
        sums[i] = sums[i - 1] + i
        sums[i] %= MOD

    cum = [0] * (N + 3)
    for i in range(N + 2):
        if i == 0:
            tmp = N + 1
        else:
            #tmp = (i + 1) * N - sums[i]
            #tmp = (i + 1) * N - sums[i]
            tmp = sums[N] - sums[max(0, N - i)]
            tmp -= sums[i - 1] - 1
        tmp %= MOD
        cum[i + 1] = cum[i] + tmp
        cum[i + 1] %= MOD
    #print(cum)
    ret = cum[N + 2] - cum[K]
    ret %= MOD
    print(ret)
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    K = int(next(tokens))  # type: int
    solve(N, K)

if __name__ == '__main__':
    main()


Measured memory_bytes: 68084
#include <stdio.h>

int main(int argc, char const *argv[]) {
  int x, y;
  scanf("%d %d", &x, &y);
  int x_group, y_group;
  if (x == 4 || x == 6 || x == 9 || x == 11) {
    x_group = 2;
  }
  else if (x == 2) {
    x_group = 3;
  }
  else {
    x_group = 1;
  }
  if (y == 4 || y == 6 || y == 9 || y == 11) {
    y_group = 2;
  }
  else if (y == 2) {
    y_group = 3;
  }
  else {
    y_group = 1;
  }

  if (x_group == y_group) {
    printf("Yes\n");
  }
  else {
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int x,y,z;
    cin>>x>>y>>z;
    int a=x,b=y,c=z;
    swap(a,b);
    swap(a,c);
    cout<<a<<" "<<b<<" "<<c;
    return 0;
}

Measured memory_bytes: 256
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  bool[string] c;
  auto a = readln.chomp.split;
  foreach (e; a) {
    c[e] = true;
  }
  c.keys.length.writeln;
}


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

#define fi first
#define se second
typedef long long LL;
typedef long double LD;

struct cell{
    int x,y;
    cell(int x=0, int y=0) : x(x), y(y) {}
};

int H,W,K,d[810][810],sz,res; char a[810][810];
bool v[810][810]; cell q[2000000];
int dx[4]={1,-1,0,0},dy[4]={0,0,-1,1};

int get_dist(int x, int y){
    return (1+min({(x-1+K-1)/K,(H-x+K-1)/K,(y-1+K-1)/K,(W-y+K-1)/K}));
}

int main(){
    cin >> H >> W >> K;

    int i,j,sx,sy;
    for (i=1; i<=H; i++)
        for (j=1; j<=W; j++){
            cin >> a[i][j];
            if (a[i][j]=='S')
                sx=i,sy=j,d[i][j]=0;
        }

    sz=1; res=(1<<30);
    q[sz]=cell(sx,sy);
    v[sx][sy]=1;

    int k;
    for (i=1; i<=sz; i++){
        res=min(res,get_dist(q[i].x,q[i].y));
        int x=q[i].x,y=q[i].y;

        if (d[x][y]==K) continue;
        for (k=0; k<4; k++){
            int nx=x+dx[k],ny=y+dy[k];
            if (nx<1 || nx>H || ny<1 || ny>W ||
                a[nx][ny]=='#' || v[nx][ny]) continue;

            q[++sz]=cell(nx,ny);
            v[nx][ny]=1;
            d[nx][ny]=d[x][y]+1;
        }
    }

    cout << res << "\n";
    return 0;
}


Measured memory_bytes: 19712
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

int N, K;
vector<int> A(51, 0);

int main(void){
	
	scanf("%d %d", &N, &K);
    for(int i = 0; i < N; ++i) scanf("%d", &A[i]);
    sort(A.begin(), A.begin() + N, greater<int>());
    
    int ans = 0;
    for(int i = 0; i < K; ++i) ans += A[i];
    printf("%d\n", ans);
    
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<set>
using namespace std;
typedef long long ll;
int main(){
    int n;cin >> n;
    ll p[n];
    for(int i=0;i<n;i++){
        cin >> p[i];
    }    
    ll pos[n+1];
    for(int i=0;i<n;i++){
        pos[p[i]] = i;
    }
    multiset<ll> s;
    s.emplace(-1);s.emplace(-1);
    s.emplace(n);s.emplace(n);
    ll res = 0;
    for(int a = n;a >= 1;a--){
        int i = pos[a];
        auto r = s.upper_bound(i),l = r;l--;
        ll l2 = *l;l--;ll l1  =*l;
        ll r1  =*r;r++;ll r2  =*r;
        ll x = (l2-l1)*(r1-i) + (i-l2)*(r2-r1);
        res += x*a;
        s.emplace(i);
    }   
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 6528
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
	int a;cin>>a;
	cout << a + a * a + a * a* a << endl;
	return 0;
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;


int main(){
    string s[7] = {"SUN","MON","TUE","WED","THU","FRI","SAT"};
    int k = 0;
    string t;
    cin>>t;
    for(int i=0;i<7;i++)if(t == s[i] ) k = i;
    cout<<7-k<<endl;
    return 0;
}


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

int N, M;
char a[60][60], b[60][60];

bool judge(int sy, int sx) {
	bool f = true;
	for (int i = sy; i < sy + M; i++) {
		for (int j = sx; j < sx + M; j++) {
			if (a[i][j] != b[i - sy][j - sx])f = false;
		}
	}
	return f;
}


int main() {
	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			cin >> a[i][j];
		}
	}
	for (int i = 0; i < M; i++) {
		for (int j = 0; j < M; j++) {
			cin >> b[i][j];
		}
	}
	for (int sy = 0; sy <= N - M; sy++) {
		for (int sx = 0; sx <= N - M; sx++) {
			if (judge(sy, sx)) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <string.h>
#include <stdio.h>
#include <algorithm>
#include <math.h>

using namespace std;
// 00100110111111101
int main()
{
    int n , arr[100] , alice = 0 , bob = 0 ;
    cin >> n ;
    for(int i = 0 ; i < n ; ++ i)
        cin >> arr[i] ;
    sort(arr,arr+n);
    for(int i =n-1;i>=0;i -= 2 )
    {
       // cout << arr[i] << " " << arr[i-1 ] <<" ";
        if(i!=0){
           //      cout << arr[i] << " " << arr[i-1 ] <<" ";
        alice += arr[i] ;
        bob += arr[i-1] ;
        }else{
        //cout <<endl<< arr[i] << " ";
        alice += arr[i] ;
        }
    }
    cout << alice - bob << endl;



      return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0; (i)<(n); ++(i))
#define rep1(i,n) for(int i=1; (i)<(n); ++(i))
#define maxi(v) distance(v.begin(), max_element(v.begin(), v.end()))
#define mini(v) distance(v.begin(), min_element(v.begin(), v.end()))
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
ll gcd(ll x, ll y){
  if(y==0) return x;
  else return gcd(y, x%y);
  }
  int main(){
  int n; cin >> n;
  vector<int> l(n); rep(i,n) cin >> l[i];
  sort(l.begin(), l.end());
  int ans=0;
  rep(i,n){
    for(int j=i+1; j<n; ++j){
      for(int k=j+1; k<n; ++k){
        if(l[k] >= l[i]+l[j])break;
        if(l[i] < l[j]+l[k] && l[j] < l[i]+l[k])ans++;
      }
    }
  }
  cout << ans;
  
  return 0;
  }

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

int main() {
  int n, q;
  string s;
  cin >> n >> q >> s;
  vector<int> c(n), ac(n), l(q), r(q);

  for (int i = 0; i < n - 1; i++) {
    if (s[i] == 'A' && s[i + 1] == 'C') c[i + 1]++;
  }

  ac[0] = 0;
  for (int i = 0; i < n - 1; i++) {
    ac[i + 1] = ac[i] + c[i + 1];
  }

  for (int k = 0; k < q; k++) cin >> l[k] >> r[k];

  for (int k = 0; k < q; k++) cout << ac[r[k] - 1] - ac[l[k] - 1] << endl;
}

Measured memory_bytes: 2688
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
    int x[3];
	cin >> x[0]>>x[1]>>x[2];
    sort(x,x+3);
    string ans;
    if(x[0]==5&&x[1]==5&&x[2]==7)ans="YES";
    else ans = "NO";
      cout << ans << endl;
}

Measured memory_bytes: 256
import itertools
N, M, Q = map(int, input().split())
l = []
for _ in range(Q):
    l.append(tuple(map(int, input().split())))
    
c = list(itertools.combinations_with_replacement(list(range(1, M+1)), N))

m = 0
for i in c:
    flag = True
    sum = 0
    for j in l:
        if i[j[1]-1] - i[j[0]-1] == j[2]:
            sum += j[3]
    m = max(m, sum)
        
print(m)


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

int main(){
  int a,b,c;
  cin >> a >> b	>> c;
  if((a+b)/2==a){
    cout << c << endl;
  }else	if((b+c)/2==b){
    cout << a << endl;
  }else{
    cout << b << endl;
  }
}



Measured memory_bytes: 256
from itertools import product
N,M=map(int,input().split())
l=list(product((0,1),repeat=N))
L=len(l)
for i in range(2**N):
    l[i]=[l[i],1300000]
r=(2048,1024,512,256,128,64,32,16,8,4,2,1)
l[0][1]=0
for i in range(M):
    a,b=map(int,input().split())
    c=tuple(map(int,input().split()))
    t=[0]*N
    for j in c:
        t[-j]=1
    for j in range(L):
        s=0
        for k in range(N):
            if l[j][0][-k-1] or t[-k-1]:
                s+=r[-k-1]
        l[s][1]=min(l[j][1]+a,l[s][1])
if l[-1][1]==1300000:
    print(-1)
else:
    print(l[-1][1])

Measured memory_bytes: 55560
#include <bits/stdc++.h>
using namespace std;
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(false), cout << fixed << setprecision(20);
#define int long long
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define _overload(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(...) _overload(__VA_ARGS__, repi, _rep)(__VA_ARGS__)
#define _rev(i, n) revi(i, n, 0)
#define revi(i, a, b) for(int i = (int)(a - 1); i >= (int)(b); i--)
#define rev(...) _overload(__VA_ARGS__, revi, _rev)(__VA_ARGS__)
#define each(i, n) for(auto&& i: n)
void in(){}
template<typename F, typename... R>
bool in(F& f, R&... r){
    if(cin >> f){in(r...);return true;}
    else return false;
}
#define out(x) cout << (x)
#define space() cout << " "
#define indent() cout << '\n'
void print(){}
template<typename F, typename... R>
void print(F f, R... r){out(f), indent(), print(r...);}
#define debughead(x) cerr << "Line " << __LINE__ << ": " << #x << ": "
#define debugout(x) cerr << (x) << " "
#define debugindent() cerr << '\n'
#define debug(x) debughead(x), debugout(x), debugindent()
const int INF = 1e18, MOD = 1e9 + 7;
template<typename T>
bool chmax(T& a, T b){return (a = max(a, b)) == b;}
template<typename T>
bool chmin(T& a, T b){return (a = min(a, b)) == b;}

main(){
    INCANT;
    int n, a, l, c, r, res = INF, w, x, y, z;
    string s;
    in(n);
    int sum[n + 1] = {};
    rep(i, 1, n + 1){
        in(a);
        sum[i] = sum[i - 1] + a;
    }
    l = 1, r = 3;
    rep(c, 2, n - 1){
        while(abs(sum[c] - 2 * sum[l]) > abs(sum[c] - 2 * sum[l + 1])){
            l++;
        }
        while(abs(sum[n] - sum[c] - 2 * (sum[r] - sum[c])) > abs(sum[n] - sum[c] - 2 * (sum[r + 1] - sum[c]))){
            r++;
        }
        w = sum[l], x = sum[c] - sum[l], y = sum[r] - sum[c], z = sum[n] - sum[r];
        chmin(res, max({w, x, y, z}) - min({w, x, y, z}));
    }
    print(res);
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <stack>
#define LL long long
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=1;i<=n;i++)
#define repp(i,x,y) for(int i=x;i<=y;i++)
#define INF INT_MAX
using namespace std;
struct st{int p,b,c;};
bool operator <(st a,st b){return a.c>b.c;}
unordered_map<int,vector<int> >E[100010];
vector<int>G[100010];
unordered_map<int,int>d[100010];
int main(){
	int n,m;
	cin>>n>>m;
	for(int i=0;i<m;i++){
		int p,q,c;
		cin>>p>>q>>c;
		p--,q--;
		E[p][c].pb(q);
		E[q][c].pb(p);
		G[p].pb(c);
		G[q].pb(c);
	}
	priority_queue<st>qq;
	d[0][0]=0;
	qq.push({0,0,0});
	while(!qq.empty()){
		st p=qq.top();
		qq.pop();
		if(d[p.p][p.b]!=p.c)continue;
		if(d[p.p].find(0)==d[p.p].end()||d[p.p][0]>p.c){
			d[p.p][0]=p.c;
			qq.push({p.p,0,p.c});
		}
		if(p.b==0){
			for(auto v:G[p.p]){
				if(d[p.p].find(v)==d[p.p].end()||d[p.p][v]>p.c+1){
					d[p.p][v]=p.c+1;
					qq.push({p.p,v,p.c+1});
				}
			}
			continue;
		}
		for(auto v:E[p.p][p.b]){
			if(d[v].find(p.b)==d[v].end()||d[v][p.b]>p.c){
				d[v][p.b]=p.c;
				qq.push({v,p.b,p.c});
			}
		}
	}
	int mi=INF;
	for(auto p:d[n-1])mi=min(mi,p.second);
	if(mi==INF)puts("-1");
	else cout<<mi<<endl;
	return 0;
}


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

int main() {
  int N, L;
  cin >> N >> L;
  vector<string> S(N);
  for (int i = 0; i < N; i++) {
    cin >> S.at(i);
  }
  sort(S.begin(), S.end());
  string ans = S.at(0);
  for (int i = 1; i < N; i++) {
    ans += S.at(i);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
A,B=list(map(int,input().split()))
C,D,s=0,0,B-A+1
C=0 if A%2==0 else A
D=0 if B%2==1 else B
if ((s-(0 if C==0 else 1)-(0 if D==0 else 1))//2)%2==0:
   E=0
else:
   E=1
print(C^D^E)


Measured memory_bytes: 9172
n = gets.to_i
s = n.times.map { gets.chomp.chars.map(&:to_i) }

has_ans = false
ans = -1

n.times do |start|
  v = [start]
  remain = [*0..n - 1] - [start]
  count = 1
  n.times do
    if remain.empty?
      ans = count if ans < count
      has_ans = true
      break
    end

    tmp = []
    v.each do |t|
      remain.each do |i|
        tmp << i if s[t][i] == 1
      end
      tmp.uniq!
    end

    if !tmp.empty? && tmp.combination(2).none? { |i, j| s[i][j] == 1 }
      v = tmp
      remain -= v
      count += 1
    else
      break
    end
  end
end
if has_ans
  puts ans
else
  puts '-1'
end

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define FILLl(n,first_dimension_size,value) fill((ll*)n,(ll*)(n+first_dimension_size),value)
#define FILL(n,first_dimension_size,value) fill((int*)n,(int*)(n+first_dimension_size),value)
#define INF (1 << 30)
#define MOD 1000000007
//int dy[4] = {-1,0,0,1};
//int dx[4] = {0,1,-1,0};



int main(){
  
  string s;
  cin >> s;
  if(s == "ABC")cout << "ARC" << endl;
  else cout << "ABC" << endl;

  
  


  

  return 0;
}

Measured memory_bytes: 3620
n, k = gets.split.map(&:to_i)
x = gets.split.map(&:to_i)

ans = 10 ** 9
(k - 1).upto(n - 1) do |i|
    if x[i] <= 0
        d = -x[i - k + 1]
    elsif x[i - k + 1] >= 0
        d = x[i]
    else
        d = x[i] - x[i - k + 1] + (x[i] < -x[i - k + 1] ? x[i] : -x[i - k + 1])
    end
    
    ans = d if ans > d
end

puts ans

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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define pvd(v) cout << setprecision(16) << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, l, r)  (a).begin()+(l),(a).begin()+(r)


int main() {
	int n,k;
	cin >> n >> k;
	vector<double> E(n);
	FOR(i, 0, n - 1) {
		double p;
		cin >> p;
		E[i] = (1.0f + p) / 2.0f;
	}
	vector<double> sume(n);
	sume[0] = E[0];
	FOR(i, 1, n - 1) {
		sume[i] = sume[i-1] + E[i];
	}
	vector<double> kko(n-k+1);
	kko[0] = sume[k - 1];
	FOR(i, 1, n - k) {
		kko[i] = sume[i + k - 1] - sume[i-1];
	}
	sort(ALL(kko));
	pvd(kko[kko.size()-1])
	return(0);
}

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

typedef long long ll;
typedef long double ld;
typedef pair<int, int> P;
typedef pair<int, P> P1;

#define fr first
#define sc second
#define mp make_pair
#define pb push_back
#define rep(i, x) for (int i = 0; i < x; i++)
#define rep1(i, x) for (int i = 1; i <= x; i++)
#define rrep(i, x) for (int i = x - 1; i >= 0; i--)
#define rrep1(i, x) for (int i = x; i > 0; i--)
#define sor(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define lb(vec, a) lower_bound(vec.begin(), vec.end(), a)
#define ub(vec, a) upper_bound(vec.begin(), vec.end(), a)
#define uniq(vec) vec.erase(unique(vec.begin(), vec.end()), vec.end())
#define mp1(a, b, c) P1(a, P(b, c))

const int INF = 1000000000;
const ll M = 1000000000;
const int dir_4[4][2] = {{1, 0}, {0, 1}, {-1, 0}, {0, -1}};
const int dir_8[8][2] = {{1, 0},  {1, 1},   {0, 1},  {-1, 1},
                         {-1, 0}, {-1, -1}, {0, -1}, {1, -1}};

/*----------------------------------------------/
/- char         : %c  | char *       : %s  | short        : %hd
/- int          : %d  | long         : %ld | long long    : %lld
/- unsigned short:%hu | unsigned int : %u  | unsigned long: %lu
/- u_long long  : %llu| (octal)      : %o  | (hexadecimal): %x
/- float        : %f  | double       : %lf |
/----------------------------------------------*/

/*----------------------------------------------/
/- INT_MAX, LONG_MAX   : 1<<15 = 2.1*pow(10, 9)       (= 2147483647)
/- UINT_MAX, ULONG_MAX : 1<<16 = 4.2*pow(10, 9)       (= 4294967295)
/- LLONG_MAX           : 1<<63 = 9.2*pow(10, 18)      (= 9223372036854775807)
/- ULLONG_MAX          : 1<<64 = 1.8*pow(10, 19)      (= 18446744073709551615)
/----------------------------------------------*/

int main() {
    int cnt = 0;
    string s;
    cin >> s;
    rep(i, s.size()) {
        if (cnt == 0 && s[i] == 'C')
            cnt++;
        if (cnt == 1 && s[i] == 'F')
            cnt++;
    }
    if (cnt == 2)
        puts("Yes");
    else
        puts("No");

    /* ====================================== */
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
use std::str::FromStr;

fn get_one<T : FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().parse().ok().unwrap();
}

fn get_vec<T : FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    return s.trim().split_whitespace().map(|e| e.parse().ok().unwrap()).collect();
}

fn get_vec_by_lines<T : FromStr>(n : usize) -> Vec<T> {
    let mut v : Vec<T> = Vec::new();
    for _i in 0..n {
        let x : T = get_one();
        v.push(x);
    }
    return v;
}

fn main() {
    let h : i32 = get_one();
    let w : i32 = get_one();
    let n : i32 = get_one();
    let m = std::cmp::max(h,w);
    println!("{}", (n+m-1) / m);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

struct edge{
	int to,cap,rev;
	edge(){}
	edge(int tt,int cc,int rr){
		to=tt;
		cap=cc;
		rev=rr;
	}
};


class dinic{
public:
	const int INF=1000000;
	vector<edge> G[2001];
	int level[2001];
	int iter[2001];
	void add_edge(int from,int to,int cap){
		G[from].push_back(edge(to,cap,G[to].size()));
		G[to].push_back(edge(from,0,G[from].size()-1));
	}

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

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

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

dinic di;

int n;
int f[10005],t[10005];
int fie[30][30];

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		string s;
		cin >> s;
		f[i]=s[0]-'a';
		t[i]=s[s.size()-1]-'a';
		fie[f[i]][t[i]]++;
	}	
	for(int i=0;i<26;i++){
		bool flag=false;
		for(int j=0;j<26;j++){
			if(fie[j][i]>0)flag=true;
		}
		if(!flag)continue;
		int cnt=0;
		int cnt2=0;
		for(int j=0;j<26;j++){
			if(i==j)continue;
			cnt+=fie[j][i];
			cnt2+=fie[i][j];
		}
		//printf("%d\n",i);
		for(int j=0;j<1000;j++){
			di.G[j].clear();
		}
		int S=26*2;
		int T=S+1;
		di.add_edge(S,i,cnt2);
		di.add_edge(26+i,T,cnt);
		for(int j=0;j<26;j++){
			di.add_edge(26+j,j,10000);
			for(int k=0;k<26;k++){
				if(j==k)continue;
				di.add_edge(j,26+k,fie[j][k]);
			}
		}
		int v=di.max_flow(S,T);
		//printf("%d %d\n",i,v);
		if(v==cnt2){
			printf("%c\n",('a'+i));
		}
	}
	return 0;
} 


Measured memory_bytes: 3512
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vl;
typedef vector<int> vi;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> vvl;
typedef vector<vector<int>> vvi;
typedef vector<vector<char>> vvec;
typedef vector<vector<bool>> vveb;
typedef vector<vector<string>> vves;
#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 rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define rev(v) reverse(v.begin(), v.end())
#define fs first
#define sc second
#define pb push_back
#define pp pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
//const int64 INF = 1LL << 58;
#define dame { puts("-1"); return 0;}
#define YES { cout << "YES" << endl; return 0; }
#define NO { cout << "NO" << endl; return 0; }
#define Yes { cout << "Yes" << endl; return 0; }
#define No { cout << "No" << endl; return 0; }
#define OK { cout << "OK" << endl; return 0; }
#define NG { cout << "NG" << endl; return 0; }
#define sz(v) ((int)(v).size())
#define uniq(a) sort(all(a));(a).resize(unique(all(a)) - a.begin());
#define dab(v) for(auto i:v)cout<<i<<' '; cout << endl;
#define vin(v) for (ll i = 0; i < v.size(); ++i) cin >> v[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 (a>b) { a=b; return 1; } return 0; }
template<class T>void out(T a){cout << a << endl;}
template<class T>void die(T a){cout << a << endl; exit(0);}
int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

#define SIZE 200005
#define MOD 1000000007
 
typedef pair <int,int> P;
 
ll inv[SIZE], fac[SIZE], finv[SIZE];
void make(){
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for(int i=2; i<SIZE; i++)
	{
		inv[i] = MOD - inv[MOD%i]*(MOD/i)%MOD;
		fac[i] = fac[i-1] * (ll) i % MOD;
		finv[i] = finv[i-1] * inv[i] % MOD;
	}
    return ;
}
ll comb(int a,int b){
	if(a < b) return 0;
	return fac[a] * (finv[b] * finv[a-b] % MOD) % MOD;
}



ll beki(int a, int n){
    if(n == 0) return 1;
    ll ans = beki(a, n / 2);
    ans = ans * ans;
    if(n % 2 == 1) ans = ans * a;
    return ans;
}

string S,T,U;
int a,b,c;
vi A,B,C;


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
    //cout << fixed << setprecision(15);
    
    cin >> S;
    cout << S.substr(0,3) << endl;
}

Measured memory_bytes: 3652
#include <cstdio>

int main()
{
  int n, x, m;
  scanf("%d %d", &n, &x);
  int sum = 0;
  int min = 100000;
  for (int i = 0; i < n; ++i)
  {
    scanf("%d", &m);
    sum += m;
    if (m < min)
    {
      min = m;
    }
  }
  printf("%d\n", n + (x - sum) / min);
  return 0;
}

Measured memory_bytes: 256
///-----Bismillahir Rahmanir Rahim-----///

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

///---FAST I/O---///
#define Boost() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

///---DATA TYPE---///
typedef long long ll;
typedef long long int lli;
///vector
typedef vector<int> vi;
typedef vector<ll> vl;
///pair
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;

///---LOOP---///
#define rep0(i,n) for(i=0;i<n;i++)
#define rep1(i,n) for(i=1;i<=n;i++)

///---I/O---///
#define sf scanf
#define pf printf

///---OTHERS---///
#define pb push_back
#define all(c)		c.begin(),c.end()
#define MK make_pair
#define F first
#define S second
#define endl '\n'


///---INITIALIZATION---//
#define mem(a,b) memset(a, b, sizeof(a) )

///---CALCULATE---///
#define gcd(a,b) __gcd(a,b)
#define lcm(a,b) (a*(b/gcd(a,b)))
#define sqr(a) ((a) * (a))

///---BIT OPERATION---///
inline bool checkBit(ll n, int i)
{
    return n&(1LL<<i);
}
inline ll setBit(ll n, int i)
{
    return n|(1LL<<i);;
}
inline ll resetBit(ll n, int i)
{
    return n&(~(1LL<<i));
}

///------String/Char Related Functions-----///
string makeintString(int x)
{
    stringstream ss;
    ss << x;
    string str = ss.str();
    ///cout<<str<<endl;
    return str;
}
string makellString(ll x)
{
    stringstream ss;
    ss << x;
    string str = ss.str();
    ///cout<<str<<endl;
    return str;
}
char cpp(char c)
{
    return static_cast<char>(c + 1);
}

///---CONSTANT---///
const double PI = acos(-1);
const double eps = 1e-9;
const int inf = 2000000000;
const ll infLL = 9000000000000000000;
#define MOD 1000000007

int main()
{
    Boost();

    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        n--;
        string s="";
        while(n>=0)
        {
            ll d=n%26;
            char c=d+97;
            s+=c;
            n/=26;
            n--;
        }
        reverse(s.begin(),s.end());
        cout<<s<<endl;
    }
    return 0;
}


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

int main() {
  int N, A, ans;
  cin >> N >> A;
  ans = N * N - A;
  cout << ans << endl;
}


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

using namespace std;
using   ll=long long;

#define fast        	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

#define endl        	"\n"
#define pb          	push_back
#define mp          	make_pair
#define F           	first
#define S           	second
#define int             long long int
#define pll				pair<int , int>

#define ALL(v)      	v.begin(),v.end()
#define ALLR(v)     	v.rbegin(),v.rend()
#define pii         	3.14159265358979323
#define inf     		LLONG_MAX
#define ones(x)     	__builtin_popcount(x)
#define fill(a,b)   	memset(a,b,sizeof(a))
#define mod 			1000000007
#define hell            998244353 

ll mod_pow(ll a,ll b,ll m) 
{
    ll res = 1;
    while(b)	
    {
        if(b&1) 	
        {
        	res=(res*a) % m;
        }
        a=(a*a) % m;
        b>>=1;
    }
    return res;
}

ll mod_inverse(ll a) 
{
	return mod_pow(a , mod-2 , mod);
}

void solve() 
{
	int x , a;
	
	cin >> x >> a;
	
	if(x < a) {
		cout << 0;
	}
	else {
		cout << 10;
	}
}

signed main() {
    fast;
    
    int t = 1;
    
	//cin >> t;
    
    while(t--) {
        solve();
    }
 
    return 0;
}


Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int n;
    cin>>n;
    int csf[n-1][3];
    for(int i=0;i<n-1;i++){
        for(int j=0;j<3;j++){
            cin>>csf[i][j];
        }
    }
    for(int i=0;i<n;i++){
        int ans=0;
        for(int j=i;j<n-1;j++){
            if(ans<=csf[j][1])ans=csf[j][1];
            else {
                if(ans%csf[j][2]!=0)ans=ans+csf[j][2]-(ans%csf[j][2]);
            }
            ans+=csf[j][0];
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
N = int(input())
S = input()
# Sheep:0, Wolf:1
for s in range(2):
    for t in range(2):
        T = [None] * N
        T[0] = s
        T[1] = t
        for j in range(1, N-1):
            if (T[j] == 0) == (S[j] == 'o'):
                T[j + 1] = T[j-1]
            else:
                T[j + 1] = 1 - T[j-1]

        if ((T[N - 1] == 0) == (S[N - 1] == 'o')) == (T[N - 2] == T[0]):
            if ((s == 0) == (S[0] == 'o')) == (T[N - 1] == t):
                ans = [None] * N
                for i in range(N):
                    ans[i] = ['S', 'W'][T[i]]
                print(''.join(ans))
                exit()
print(-1)


Measured memory_bytes: 73200
N, K, Q = map(int, input().split())

num_list = [0] * (N+5)

for _ in range(Q):
    A = int(input())
    num_list[A] += 1

for i in range(1, N+1):
    if K - (Q - num_list[i]) > 0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 9848
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll ZERO = 0;
const int Inf = 1e9;
const ll INF = 9223372036854775807;
const ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;

int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    int ret = Inf;
    int w = 0;
    int b = 0;
    for(int i = 0;i < N;i++) {
        if(S.at(i) == '.') {
            w++;
        }
    }
    for(int i = 0;i < N;i++) {
        ret = min(ret,w + b);
        if(S.at(i) == '#') {
            b++;
        }
        else {
            w--;
        }
    }
    ret = min(ret,w + b);
    cout << ret << endl;
}

Measured memory_bytes: 640
#pragma region header
#include <bits/stdc++.h>
#define int long long
using namespace std;
#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 rev(i, n) for(int i = (int)(n - 1); i >= 0; i--)
#define rev1(i, n) for(int i = (int)(n); i > 0; i--)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define resort(v) sort((v).rbegin(), (v).rend())
#define vi vector<int>
#define vvi vector<vector<int>>
#define vc vector<char>
#define vvc vector<vector<char>>
#define vb vector<bool>
#define vvb vector<vector<bool>>
using ll = long long;
using P = pair<int, int>;
/* ----------------よく使う数字や配列----------------- */
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};
constexpr ll mod = 1e9+7;
constexpr int inf = INT32_MAX/2;
constexpr ll INF = LLONG_MAX/2;
constexpr long double eps = DBL_EPSILON;
constexpr long double pi = 3.141592653589793238462643383279;
/* ----------------------end----------------------- */

/* --------------------テンプレート------------------ */
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
/* ----------------------end----------------------- */

/* --------------------ライブラリ-------------------- */
ll fact(int i) {       //階乗
    if (i == 0) return 1;
    return (fact(i - 1)) * i % mod;
}
ll gcd(ll a, ll b) {        //最大公約数
    if(b == 0) return a;
    return gcd(b, a % b); 
}
ll lcm(ll a, ll b) {      //最小公倍数
    return a * b / gcd(a, b);
}
int keta(ll n) {        //桁数を求める
    if(n == 0) return 1;
    int count = 0;
    while(n != 0) {
        n /= 10;
        count++;
    }
    return count;
}
ll ketasum(ll n) {    //各桁の和
    ll sum = 0;
    while(n != 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}
/* ----------------------end----------------------- */
#pragma endregion
signed main() {
    int x;cin >> x;
    if(x>=30) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

const int mod = 1000000007;
int add(int a, int b) { return (a += b) < mod? a : a - mod; }
int sub(int a, int b) { return (a -= b) >=  0? a : a + mod; }
int mul(int a, int b) { return 1LL * a * b % mod; }
void adds(int& a, int b) { a = add(a, b); }
void subs(int& a, int b) { a = sub(a, b); }
void muls(int& a, int b) { a = mul(a, b); }
void maxs(int& a, int b) { a = max(a, b); }
void mins(int& a, int b) { a = min(a, b); }
int pwr(int a, ll p) {
    if (p == 0) return 1;
    if (p & 1) return mul(a, pwr(a, p - 1));
    return pwr(mul(a, a), p / 2);
}
int inv(int a) { return pwr(a, mod - 2); }

int n;
string s[2];
int dp[52][4][4];

int f(int k, int a, int b)
{
    if (k == n) return 1;
    if (dp[k][a][b] != -1) return dp[k][a][b];
    int sol = 0;
    if (s[0][k] == s[1][k])
    {
        for (int i = 0; i < 3; ++i)
            if (i != a && i != b)
                adds(sol, f(k + 1, i, i));
    }
    else
    {
        for (int i = 0; i < 3; ++i)
            for (int j = 0; j < 3; ++j)
                if (i != j && i != a && j != b)
                    adds(sol, f(k + 2, i, j));
    }
    return dp[k][a][b] = sol;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> s[0] >> s[1];
    memset(dp, -1, sizeof dp);
    cout << f(0, 3, 3);
}


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

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using u64 = unsigned long long;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template <class M>
struct SegmentTree{
    using T = typename M::T;
    int sz, n, height{};
    vector<T> seg;
    explicit SegmentTree(int n) {
        sz = 1; while(sz < n) sz <<= 1, height++;
        seg.assign(2*sz, M::e());
    }

    void set(int k, const T &x){ seg[k + sz] = x; }

    void build(){
        for (int i = sz-1; i > 0; --i) seg[i] = M::f(seg[2*i], seg[2*i+1]);
    }

    void update(int k, const T &x){
        k += sz;
        seg[k] = x;
        while (k >>= 1) seg[k] = M::f(seg[2*k], seg[2*k+1]);
    }

    T query(int a, int b){
        T l = M::e(), r = M::e();
        for(a += sz, b += sz; a < b; a >>=1, b>>=1){
            if(a & 1) l = M::f(l, seg[a++]);
            if(b & 1) r = M::f(seg[--b], r);
        }
        return M::f(l, r);
    }

    template<class F>
    int search_right(int l, F cond){
        if(l == n) return n;
        T val = M::e();
        do {
            while(!(l&1)) l >>= 1;
            if(!cond(M::f(val, seg[l]))){
                while(l < sz) {
                    l <<= 1;
                    if (cond(M::f(val, seg[l]))){
                        val = M::f(val, seg[l]);
                        l++;
                    }
                }
                return l - sz;
            }
            val = M::f(val, seg[l]);
            l++;
        } while((l & -l) != l);
        return n;
    }

    template<class F>
    int search_left(int r, F cond){
        if(r == 0) return 0;
        T val = M::e();
        do {
            while(r&1) r >>= 1;
            if(!cond(M::f(val, seg[r]))){
                while(r < sz) {
                    r = ((r << 1)|1);
                    if (cond(M::f(seg[r], val))){
                        val = M::f(seg[r], val);
                        r--;
                    }
                }
                return r + 1 - sz;
            }
            val = M::f(seg[r], val);
        } while((r & -r) != r);
        return 0;
    }
    T operator[](const int &k) const { return seg[k + sz]; }
};

struct Monoid{
    using T = int;
    static T f(T a, T b) { return max(a, b); }
    static T e() { return 0; }
};
int main() {
    int n, k;
    cin >> n >> k;
    vector<int> v(n);
    for (auto &&i : v) scanf("%d", &i);
    int M = 300010;
    SegmentTree<Monoid> seg(M+1);
    for (int i = 0; i < n; ++i) {
        int val = seg.query(max(0, v[i]-k), min(M+1, v[i]+k+1))+1;
        seg.update(v[i], val);
    }
    cout << seg.query(0, M+1) << "\n";
    return 0;
}

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

#define ll long long
#define pii pair<int, int>

using namespace std;

int main() {
    int ans = 1e9 + 7;
    int n, k;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = 1; i <= 100; i++) {
        int sum = 0;
        for (auto el:a)sum += (el - i) * (el - i);
        ans = min(ans, sum);
    }
    cout << ans;
}

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

int main(){
	int a, b, c, n;

	cin >> n;
	while (n--){
		cin >> a >> b >> c;
		if (a*a == b*b + c*c || b*b == a*a + c*c || c*c == a*a + b*b){
			cout << "YES" << endl;
		}
		else
			cout << "NO" << endl;
	}
	return 0;
}


Measured memory_bytes: 1152
#include<stdio.h>
int main(){
  int x,y,h;
 
  while(scanf("%d%d",&x,&y)!=EOF)
    {
      while(y!=0)
    {
      x=x%y;
      h=x;
      x=y;
      y=h;
    }
 
      printf("%d\n",x);
    }    
  return 0;
}

Measured memory_bytes: 1796
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
ll INF = 1e10;
int main()
{
    int x, y;
    string s;
    cin >> s >> x >> y;
    int n = s.size();

    vector<vector<bool>> dp(16010, vector<bool>(8010));
    for(int i = 0; i <= n; i++)
    {
        for(int j = 0; j <= n; j++)
        {
            dp[i][j] = false;
        }
    }
    dp[0][1] = true;

    vector<int> vx;
    vector<int> vy;
    int pos = 0;
    int dr = 1;
    while(pos < n)
    {
        int count = 0;
        while(pos < n && s[pos] == 'F')
        {
            pos++;
            count++;
        }
        if(dr == 1) vx.push_back(count);
        else vy.push_back(count);

        if(pos >= n) break;

        int tc = 0;
        while(pos < n && s[pos] == 'T')
        {
            pos++;
            tc++;
        }
        if(tc % 2 == 1) dr *= -1;
    }

    for(int i = 1; i < vx.size(); i++)
    {
        for(int j = 0; j <= n; j++)
        {
            if(j+vx[i] <= n) dp[j+vx[i]][i+1] = dp[j+vx[i]][i+1] || dp[j][i];
            if(vx[i] <= j) dp[j-vx[i]][i+1] = dp[j-vx[i]][i+1] || dp[j][i];
        }
    }

    if(!dp[abs(vx[0]-x)][vx.size()])
    {
        cout << "No" << endl;
        return 0;
    }

    for(int i = 0; i <= n; i++)
    {
        for(int j = 0; j <= n; j++)
        {
            dp[i][j] = false;
        }
    }
    dp[0][0] = true;
    for(int i = 0; i < vy.size(); i++)
    {
        for(int j = 0; j <= n; j++)
        {
            if(j+vy[i] <= n) dp[j+vy[i]][i+1] = dp[j+vy[i]][i+1] || dp[j][i];
            if(vy[i] <= j) dp[j-vy[i]][i+1] = dp[j-vy[i]][i+1] || dp[j][i];
        }
    }
    if(!dp[abs(y)][vy.size()])
    {
        cout << "No" << endl;
        return 0;
    }
    cout << "Yes" << endl;
}

Measured memory_bytes: 18944