akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i=(int)m ; i < (int) n ; ++i )
#define rep(i,n) REP(i,0,n)
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

template<typename F,typename C>
struct MinCostFlow{
    struct Edge{
        int to;
        F cap;
        C cost;
        int rev;
    };
    const C INF;
    vector<vector<Edge>> v;
    vector<C> pot,dist;
    vector<int> prevv,preve;

    MinCostFlow(int n):v(n),INF(numeric_limits<C>::max()){}

    void add_edge(int from,int to,F cap,C cost){
        v[from].emplace_back((Edge){to,cap,cost,(int)v[to].size()});
        v[to].emplace_back((Edge){from,0,-cost,(int)v[from].size()-1});
    }

    C min_cost_flow(int s,int t,F f){
        int n=v.size();
        C ret=0;
        using P = pair<C,int>;
        priority_queue<P,vector<P>,greater<P>> que;
        pot.assign(n, 0);
        prevv.assign(n, -1);
        preve.assign(n, -1);

        while(f>0){
            dist.assign(n, INF);
            que.emplace(0,s);
            dist[s]=0;
            while(!que.empty()){
                int cur=que.top().second;
                C d=que.top().first;
                que.pop();
                if(dist[cur]<d)continue;
                rep(i,v[cur].size()){
                    Edge &e = v[cur][i];
                    C next_cost = dist[cur]+e.cost+pot[cur]-pot[e.to];
                    if(e.cap>0 && dist[e.to]>next_cost){
                        dist[e.to]=next_cost;
                        prevv[e.to]=cur;
                        preve[e.to]=i;
                        que.emplace(dist[e.to],e.to);
                    }
                }
            }
            if(dist[t]==INF)return -1;
            rep(i,n)pot[i]+=dist[i];
            F add_flow = f;
            for(int u=t;u!=s;u=prevv[u]){
                add_flow=min(add_flow,v[prevv[u]][preve[u]].cap);
            }
            f-=add_flow;
            ret+=add_flow*pot[t];
            for(int u=t;u!=s;u=prevv[u]){
                Edge& e=v[prevv[u]][preve[u]];
                e.cap -=add_flow;
                v[e.to][e.rev].cap += add_flow;
            }
        }
        return ret;
    }
};

int main(){
    int n,m,f;
    cin>>n>>m>>f;
    MinCostFlow<int,int> mcf(n);
    rep(i,m){
        int a,b,c,d;
        cin>>a>>b>>c>>d;
        mcf.add_edge(a, b, c, d);
    } 
    cout<<mcf.min_cost_flow(0, n-1, f)<<endl;
    return 0;
}


Measured memory_bytes: 3204
#include <iostream>
#include <string>

using namespace std;

int main() {
  string s; cin >> s;
  bool flg = true;
  for(int i = 0; i < s.size(); i++) {
    if(i % 2) {
      if(s[i] == 'R') {
        flg = false; break;
      }
    } else {
      if(s[i] == 'L') {
        flg = false; break;
      }
    }
  }
  cout << (flg ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
	int a;
	int b;
	int s;
	int m;
	int h;
	cin >> a;
	b=a/60;
	s=a%60;
	h=b/60;
	m=b%60;
	cout <<(h)<<(":")<<(m)<<(":")<<(s)<< endl;
	return 0;
}



Measured memory_bytes: 3092
n=int(input())
t=[int(i) for i in input().split()]
v=[int(i) for i in input().split()]
S=[0 for i in range(n)]
S1=[0 for i in range(n)]
S2=[0 for i in range(n)]
vel=[0 for i in range(n)]

dt=[0 for i in range(n)]
v0=[0 for i in range(n)]
ve=[0 for i in range(n)]
ok=0



for i in range(n):
    if n ==1:
        dt[0]=t[0]
    elif i==n-1:
        v0[i]=ve[i-1]
        ve[i]=0
        dt[i]=t[i]
    else:
        v0[i]=ve[i-1]
        dt[i]=t[i]
        ve[i]=min(v[i+1],v[i],v0[i]+dt[i])

#print(dt)
#print(v0)
#print(ve)

while ok==0:
    for i in range(n-1):
#        if  abs((ve[i]-ve[i+1])/dt[i+1]) >1:
        if  abs((ve[i+1]-v0[i+1])/dt[i+1]) >1:
                ve[i]=ve[i]-1
                v0[i+1]=v0[i+1]-1
#                v0[i]=v0[i]-1
#                print("dt",dt)
#                print("v0",v0)
#                print("ve",ve)
                break
    else:
        ok=1


#print(dt)
#print(v0)
#print(ve)


for i in range(n):

    ttt=0.5*(ve[i]+dt[i]-v0[i])
    vvv=ttt+v0[i]
    if vvv-v[i]>=0:
        S[i]=0.5*(v0[i]+vvv)*ttt + 0.5*(ve[i]+vvv)*(dt[i]-ttt) - (ttt-v[i]+v0[i])*(vvv-v[i]) 
        S1[i]=0.5*(v0[i]+vvv)*ttt + 0.5*(ve[i]+vvv)*(dt[i]-ttt)
        S2[i]=(ttt-v[i]+v0[i])*(vvv-v[i]) 
    else:
        S[i]=0.5*(v0[i]+vvv)*ttt + 0.5*(ve[i]+vvv)*(dt[i]-ttt)
        S1[i]=0.5*(v0[i]+vvv)*ttt + 0.5*(ve[i]+vvv)*(dt[i]-ttt)
        S2[i]=0

print(sum(S))



Measured memory_bytes: 3192
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char c;
  cin >> c;
  if(c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
    cout << "vowel" << endl;
  } else {
    cout << "consonant" << endl;
  }
}

Measured memory_bytes: 256
import java.util.Scanner;

class Main {
  public static void main(String args[]){
    int A;
    int B;
    Scanner sc = new Scanner(System.in);

    A = sc.nextInt();
    B = sc.nextInt();

    if(A > 8 || B >8){
      System.out.println(":(");
    }else{
      System.out.println("Yay!");
    }
  }
}


Measured memory_bytes: 21332
#include <iostream>

int main()
{
	int M1, M2, D1, D2;
	std::cin >> M1 >> D1;
	std::cin >> M2 >> D2;

	if (M1 == 4 || M1 == 6 || M1 == 9 || M1 == 11)
	{
		if (D1 > 30)
		{
			std::cout << 0;
		}
		else if (D1 == 30)
		{
			if (M2 != M1 + 1 && D2 != 1)
			{
				std::cout << 0;
			}
			else
			{
				std::cout << 1;
			}
		}
		else
		{
			if (D2 != D1 + 1)
			{
				std::cout << 0;
			}
			else
			{
				std::cout << 0;
			}
		}
	}
	else if (M1 == 2)
	{
		if (D1 > 28)
		{
			std::cout << 0;
		}
		else if (D1 == 28)
		{
			if (M2 != M1 + 1 && D2 != 1)
			{
				std::cout << 0;
			}
			else
			{
				std::cout << 1;
			}
		}
		else
		{
			if (D2 != D1 + 1)
			{
				std::cout << 0;
			}
			else
			{
				std::cout << 0;
			}
		}
	}
	else
	{
		if (D1 > 31)
		{
			std::cout << 0;
		}
		else if (D1 == 31)
		{
			if (M2 != M1 + 1 && D2 != 1)
			{
				std::cout << 0;
			}
			else
			{
				std::cout << 1;
			}
		}
		else
		{
			if (D2 != D1 + 1)
			{
				std::cout << 0;
			}
			else
			{
				std::cout << 0;
			}
		}
	}


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define mod_ceil(a, b) (a % b) ? a / b + 1 : a / b
using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll a, b, c, k, ans = 0, tmp;
    cin >> a >> b >> c >> k;
    tmp = min(a, k);
    ans += tmp;
    k -= tmp;
    tmp = min(b, k);
    k -= tmp;
    tmp = min(c, k);
    ans -= tmp;
    k -= tmp;
    cout << ans << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
int main()
{
    int a,b,c,d,e,f;
    cin>>a>>b>>c>>d>>e>>f;
    if(e-a>f) cout<<":(";
    else cout<<"Yay!";
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int n;
    scanf("%d",&n);
    int a[100005];
    int b[100005];
    ll sum=0;
    for(int i=0;i<=n;i++)
        scanf("%d",&a[i]);
    for(int i=0;i<n;i++)
        scanf("%d",&b[i]);
    for(int i=0;i<n;i++)
    {
        if(b[i]>a[i])
        {
            sum+=a[i];
            b[i]-=a[i];
            a[i]=0;
            if(a[i+1]<b[i])
            {
                sum+=a[i+1];
                a[i+1]=0;
            }
            else
            {
                sum+=b[i];
                a[i+1]-=b[i];
            }
        }
        else sum+=b[i];
    }
    printf("%lld\n",sum);
    return 0;
}


Measured memory_bytes: 1024
from itertools import permutations

N = int(input())
XY = []
for _ in range(N):
    x, y = map(int, input().split())
    XY.append((x, y))

ans = 0
c = 0

for p in permutations(range(N)):
    dist = 0
    x1, y1 = XY[p[0]]
    for i in p[1:]:
        x, y = XY[i]
        dist += ((x1 - x) ** 2 + (y1 - y) ** 2) ** 0.5
    ans += dist
    c += 1

print(ans / c)


Measured memory_bytes: 69088
// Devarshi

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

#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define ll long long
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define rep(i,n) for(i=0;i<n;i++)
#define forn(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define for1(i, n) for (ll i = 1; i <= (ll)(n); ++i)
#define ford(i, n) for (ll i = (ll)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (ll i = (ll)(a); i <= (ll)(b); ++i)
#define fora(it,x) for(auto it:x)
#define PI 3.14159265
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef pair<ll, ll> pii;
typedef vector<ll> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }

const int maxn=1000001;

bool isprime(int n){
	int n1=n;
	for(int i=2;i<=sqrt(n);i++){
		if(n%i==0){
			return false;
		}
	}
	//if(n1==n) return true;
	return true;
}

int main(){

sync
/*
#ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("out.txt", "w", stdout);
#endif
*/
int n,m;
cin>>n>>m;
if(m%n==0) cout<<m/n;
else{
	//cout<<1<<endl;
	if(isprime(m)) cout<<1;
	else{
		int i=1;
		int ans=1;
		while(m-(n-1)*i>0){
			int k=m-(n-1)*i;
			if(k%i==0) ans=i;
			i++;
		}
		cout<<ans;
	}
}
return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>
#include <set>
#include <map>
#include <deque>
#include <iomanip>
#include <cstdio>

using namespace std;
typedef  long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define  MP make_pair
#define  PB push_back
#define inf  1000000007
#define rep(i,n) for(int i=0;i<(int)(n);++i)


int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    string t;
    for(int i=2*n-1;i>=n;i--){
        t.push_back(s[i]);
    }
    ll ans = 0;
    for(int bit = 0;bit<(1<<n);bit++){
        string s1,s2;
        int cnt = 0;
        for(int i=0;i<n;i++){
            if((bit>>i)&1){
                s1.push_back(s[i]);
                cnt++;
            }else{
                s2.push_back(s[i]);
            }
        }
        ll dp[20][20][20]={};
        dp[0][0][0] = 1;
        for(int i=0;i<n;i++){
                for(int j=1;j<=cnt;j++){
                    for(int k=0;k<=n-cnt;k++){
                        if(t[i]==s1[j-1])dp[i+1][j][k] +=dp[i][j-1][k];
                    }
                }
                for(int j=0;j<=cnt;j++){
                    for(int k=1;k<=n-cnt;k++){
                        if(t[i]==s2[k-1])dp[i+1][j][k] +=dp[i][j][k-1];
                    }
                }
        }
        //cout << s1 << " " << s2 << " " << cnt<< endl;
        ans += dp[n][cnt][n-cnt];
        //cout << ans << endl;
        //if(bit%1000==0)cout << bit << endl;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main(void) {
    int N;
    cin >> N;
    vector<int> H(N);
    for(int i=0; i<N; i++) {
        cin >> H[i];
    }

    int ans = 0;
    int tmp = 0;
    for(int i=N-1; i>=0; i--) {
        if(H[i-1] >= H[i]) {
            tmp++;
        } else {
            tmp = 0;
        }
        ans = max(ans, tmp);
    }

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


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define ll long long
typedef tuple<ll,ll,ll> T;
typedef pair<ll,T> P;
vector<ll> d,a,b,c;
ll x,y,z,k;
int main(){
  cin>>x>>y>>z>>k;
  for(int i=0;i<x;i++){
    ll t;
    cin>>t;
    a.push_back(t);
  }
  for(int i=0;i<y;i++){
    ll t;
    cin>>t;
    b.push_back(t);
  }
  for(int i=0;i<z;i++){
    ll t;
    cin>>t;
    c.push_back(t);
  }
  sort(a.begin(),a.end(),greater<ll>());
  sort(b.begin(),b.end(),greater<ll>());
  sort(c.begin(),c.end(),greater<ll>());
  priority_queue<P> pq;
  pq.push(P(a[0]+b[0]+c[0],T(0,0,0)));
  set<T> s;
  for(int i=0;i<k;i++){
    P e=pq.top();
    pq.pop();
    cout<<e.first<<endl;
    if(get<0>(e.second)!=x-1){
      if(s.find(T(get<0>(e.second)+1,get<1>(e.second),get<2>(e.second)))==s.end()){
       s.insert(T(get<0>(e.second)+1,get<1>(e.second),get<2>(e.second)));
      pq.push(P(a[get<0>(e.second)+1]+b[get<1>(e.second)]+c[get<2>(e.second)],T(get<0>(e.second)+1,get<1>(e.second),get<2>(e.second))));
    }
    }
    if(get<1>(e.second)!=y-1){
      if(s.find(T(get<0>(e.second),get<1>(e.second)+1,get<2>(e.second)))==s.end()){
       s.insert(T(get<0>(e.second),get<1>(e.second)+1,get<2>(e.second)));
      pq.push(P(a[get<0>(e.second)]+b[get<1>(e.second)+1]+c[get<2>(e.second)],T(get<0>(e.second),get<1>(e.second)+1,get<2>(e.second))));
    }
    }
    if(get<2>(e.second)!=z-1){
      if(s.find(T(get<0>(e.second),get<1>(e.second),get<2>(e.second)+1))==s.end()){
       s.insert(T(get<0>(e.second),get<1>(e.second),get<2>(e.second)+1));
      pq.push(P(a[get<0>(e.second)]+b[get<1>(e.second)]+c[get<2>(e.second)+1],T(get<0>(e.second),get<1>(e.second),get<2>(e.second)+1)));
    }
    }
  }
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())
#define endl "\n"

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    string s, t, u;
    ll a, b;
    cin >> s >> t >> a >> b >> u;
    if (s == u) a--;
    if (t == u) b--;
    printf("%lld %lld\n", a, b);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define forloop(n) for(int i = 0; i < n; i++)
#define ll long long
 
#define mod 1000000007
long long exp(long long taban, long long us) {
    long long carpan = taban;
    long long temp = us;
    long long res = 1;
    for(int i = 0;;i++){
        if(temp % 2) res = (res*carpan) % mod;
        temp /= 2;
        carpan = (carpan*carpan) % mod;
        if(temp == 0) break;
    }
    return res;
}
ll ebob(ll a, ll b){
	if(!a)return b;
	return ebob(b%a, a);
}
ll ekok(ll a, ll b){
	return (((a*b)%mod)*(exp(ebob(a,b), (ll)mod-2))) % mod;
}

int main(){
	ios_base::sync_with_stdio(false); cin.tie(NULL);
	bool primes[1000005] = {};
	int h = 2;
	while(h < 1000005/2){
		for(int k = 2*h; k < 1000005; k += h){
			primes[k] = 1;
		}
		h++;
	}
	vector<int> pr;
	for(int i = 2; i < 1000005; i++){
		if(!primes[i]) pr.push_back(i);
	}
	int n; cin>>n;
	vector<ll> vec(n);
	ll sum = 0;
	for(int i = 0; i < n; i++){
		cin>>vec[i];
	}
	map<int, int> mp;
	for(int u = 0; u < vec.size(); u++){
		ll x = vec[u];
		sum = (sum + exp(x, mod-2)) % mod;
		for(int i = 2; i*i <= x; i++){
			if(!primes[i]){
				int cnt = 0;
				while(x % i == 0){
					x /= i;
					cnt++;
				}
				mp[i] = max(mp[i], cnt);
			}
		}
		if(x != 1){
			mp[x] = max(mp[x], 1);
		}
	}
	ll temp = 1;
	for(auto x: mp){
		temp = (temp * exp(x.first, x.second)) % mod;
	}
	cout<<(sum*temp)%mod;
	return 0;
}


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

int main(){
    int   n;
    cin >> n;
    vector<long long> a(n);
    long long  ans = 1;
    int flag = 0;
    for ( long long  i = 0; i<n; i++ ) {
        cin >> a[i];
        if( a[i] == 0 ) {
            ans = 0;
            flag = 1;
        }
    }

    if( flag == 0) {
    for(long long i = 0; i < n; ++i) {
        if(a[i] > 1000000000000000000/ ans || a[i] * ans > 1000000000000000000) {
            ans = -1;
            break;
        }
        ans *= a[i];
    }

    }

    cout << ans << endl;
}

Measured memory_bytes: 3928
#include <bits/stdc++.h>
#define REP(i, n) for(int i=0; i<(int)(n); i++)
#define REP1(i,a,b) for(int i=a; i<=(int)(b); i++)
#define ALL(x) begin(x),end(x)
#define PB push_back
using namespace std;
typedef int64_t LL;
typedef vector<int> VI;
typedef pair<int,int> PII;

template<class T> inline bool chmax( T &a, const T &b ) { return b>a ? a=b,true : false; }
template<class T> inline bool chmin( T &a, const T &b ) { return b<a ? a=b,true : false; }
template<class T> using MaxHeap = priority_queue<T>;
template<class T> using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template<class T, class F=less<T>>void sort_uniq( vector<T> &v, F f=F() ) {
    sort(begin(v),end(v),f);
    v.resize(unique(begin(v),end(v))-begin(v));
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    map<int,int> mp;
    int n;
    cin >> n;
    int ans=0;
    REP(i,n) {
    	int a;
    	cin >> a;
    	mp[a]++;
    }
    for ( auto p:mp ) {
    	if ( p.second < p.first ) {
    		ans+=p.second;
    	}
    	else {
	    	ans+=p.second-p.first;
    	}
    }
    cout << ans << '\n';
    return 0;
}

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

using namespace std;
const int N=1e5+6, M=7 ;

int maxHappiness[N][M];
int happiness[N][M];
int n ;

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

    for(int i=0 ; i<n ; i++){
        for(int j=0 ; j<3 ; j++){
            scanf("%d" , &happiness[i][j]);
        }
    }

    maxHappiness[0][0]=happiness[0][0];
    maxHappiness[0][1]=happiness[0][1];
    maxHappiness[0][2]=happiness[0][2];

    for(int currentday=1 ; currentday<n ; currentday++){

        for(int newactivity=0 ; newactivity<3 ; newactivity++){

            for(int lastactivity=0 ; lastactivity<3 ; lastactivity++){

                if(lastactivity==newactivity)continue;
                        maxHappiness[currentday][newactivity]=max(maxHappiness[currentday][newactivity] , maxHappiness[currentday-1][lastactivity]+happiness[currentday][newactivity]);

            }

        }

    }
    int ans=max({maxHappiness[n-1][0] , maxHappiness[n-1][1] , maxHappiness[n-1][2]});
    printf("%d\n", ans);

}


Measured memory_bytes: 5760
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def k(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def X(): return list(input())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
def gcd(*numbers): reduce(math.gcd, numbers)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7
count = 0
ans = 0

N = k()
a = l()

for i in a:
    if i == ans+1:
        ans+=1

if ans == 0:
    print(-1)
else:
    print(N-ans)


Measured memory_bytes: 33180
n,m,x = map(int,input().split())
cost = []
a = []
for i in range(n):
    ca = list(map(int,input().split()))
    cost.append(ca[0])
    a.append(ca[1:])

ans = 10**7
for bit in range(2**n):
    alg = [0 for i in range(m)]
    ccount = 0
    for i in range(n):
        if bit >> i & 1:
            for j in range(m):
                alg[j] += a[i][j]
            ccount += cost[i]
    if min(alg) >= x:
        ans = min(ans,ccount)
if ans == 10**7:
    print(-1)
else:
    print(ans)

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

using namespace std;
typedef long long ll;
typedef pair<int, int> i_i;
typedef pair<ll, ll> l_l;
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define int ll
//const ll mod = 1000000007;

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

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

# a 回目、b 回目を考えたとき、a mod K と b mod K の値が異なれば、a, b それぞれの回で独立に手を選べる。
# mod K の値に応じて、N 回のジャンケンを K 個のグループに分けたとき、各グループに対して、最大何点取れるかを考えればよい。
# あるグループで最大何点取れるかは、前回の手を覚えておきながら DP or 貪欲法で求めればよい。

n, k = map(int, input().split())
r, s, p = map(int, input().split())
t = str(input())
# print(n, k, r, s, p, t)

t_list = list(t)
groups = [[] for i in range(k)]
for i in range(len(t_list)):
    mod = i % k
    groups[mod].append(t_list[i])
# print(groups)

def score(my_hand, hand):
    if my_hand == 'r' and hand == 's':
        return r
    elif my_hand == 's' and hand == 'p':
        return s
    elif my_hand == 'p' and hand == 'r':
        return p
    return 0

def get_win_hand(hand):
    if hand == 'r':
        return 'p'
    elif hand == 's':
        return 'r'
    else:
        return 's'

result = 0
# for each group
for i in range(k):
    hands = groups[i]
    # for each hand in a group
    for j in range(len(hands)):
        hand = hands[j]
        win_hand = get_win_hand(hand)
        if j == 0:
            my_hand = win_hand
            result += score(my_hand, hand)
            my_hand_prev = my_hand
        else:
            candidates = ['r', 's', 'p']
            candidates.remove(my_hand_prev)
            if win_hand == my_hand_prev:
                if j == len(hands) - 1:
                    candidates.pop()
                    my_hand = candidates[0]
                else:
                    hand_next = hands[j+1]
                    win_hand_next = get_win_hand(hand_next)
                    if win_hand_next == my_hand_prev:
                        candidates.pop()
                    else:
                        candidates.remove(win_hand_next)
                my_hand = candidates[0]
                result += score(my_hand, hand)
                my_hand_prev = my_hand
            else:
                my_hand = win_hand
                result += score(my_hand, hand)
                my_hand_prev = my_hand

print(result)


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

int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end(), greater<int>());
    int alice = 0;
    int bob = 0;
    for (int i = 0; i < n; i++) {
        if (i % 2 == 0) {
            alice += a[i];
        } else {
            bob += a[i];
        }
    }
    cout << alice - bob << endl;
    return 0;
}


Measured memory_bytes: 3628
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>
#include <stack>
#include <bitset>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

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

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

  int k, x;
  cin >> k >> x;

  if(x-k+1 > -1000000){
    FOR(i, x-k+1, x){
      cout << i << " ";
    }
  }
  else {
    FOR(i, -1000000, x){
      cout << i << " ";
    }
  }
  if(x+k-1 < 1000000){
    FOR(i, x, x+k-1+1){
      cout << i << " ";
    }
  }
  else {
    FOR(i, x, 1000001){
      cout << i << " ";
    }    
  }
  cout << endl;
  
  return 0;
}


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

#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp> // Include for built in treap
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
const int MOD = 1e9 + 7;
#define ll long long int
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
#define vi vector<int>
#define vl vector<ll>
#define vpii vector<pii>
#define vpll vector<pll>
#define si set<int>
#define mpii map<int, int>
#define prq priority_queue
#define sz(s) (int) s.size()
#define pf(a) printf("%d\n",a)
#define sc1(a) scanf("%d",&a)
#define sc2(a, b) scanf("%d%d",&a,&b)
#define pi 2 * acos (0.0)
#define inf 1e9
#define dbg cout<<"ok"<<endl;
#define FOR(i, j, k) for(int i=(j); i<(k); i++)
#define REV(i, j, k) for(int i=(n-1); i>=k; i--)
#define rnd(a, b) ((((rand()<<15)^rand())%((b)-(a) + 1))+(a))
#define FAST_IO ios_base::sync_with_stdio(false),cin.tie(NULL)
#define mem(x, y) memset(x, y, sizeof(x))
typedef tree <int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pb_ds;
const double EPS = 1e-9;
const int MXX = 1e5 + 5;

int main()
{
    int ar[100002];
    int ar1[100002];
    int n, k;
    scanf("%d %d",&n,&k);
    for(int i=0;i<=n-1;i++)
    {
        scanf("%d",&ar[i]);
    }
    for(int i=1;i<=n-1;i++)
    {
        if(i==1)
        {
          ar1[i]=abs(ar[i]-ar[i-1]);
        }
        else if(i==2&&k>=2)
        {
            ar1[i]=min(abs(ar[i]-ar[i-2]),ar1[i-1]+abs(ar[i]-ar[i-1]));
        }
        else if(i==2&&k==1)
        {
            ar1[i]=ar1[i-1]+abs(ar[i]-ar[i-1]);
        }

        else
        {
            int minn = INT_MAX;
            for(int j=1;j<=k;j++)
            {
                if(i-j>=0)
                    minn=min(minn,ar1[i-j]+abs(ar[i]-ar[i-j]));
            }

        ar1[i] =minn;
       }
    }

      printf("%d",ar1[n-1]);

       return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) a.begin(),a.end()
int main(){
	const long mod=1000000007;
	int N,M;cin>>N>>M;
	int A[M];
	rep(i,0,M){
		cin>>A[i];
	}long ans[N+1];
	ans[0]=1;int j;
	if(A[0]==1){
		ans[1]=0;
		j=1;
	}else{
		ans[1]=1;
		j=0;
	}
	rep(i,2,N+1){
		if(i==A[j]){
			ans[i]=0;
			if(j<M-1) j++;
		}else{
			ans[i]=(ans[i-1]+ans[i-2])%mod;
		}//cout<<ans[i]<<endl;
	}cout<<ans[N]<<endl;
}

Measured memory_bytes: 1408
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<int, int> P;
typedef pair<int, pair<P, P> > PP;

#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
//for gcc (未test)
// #define FOREACH_IT(it,c) for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
// for Debug.
#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}
// 入力をpush_back(d)やarray[d]に使う時に1行で書ける
// int INPUT_INT() {int d;cin>>d;return d;}
template<class T>T IN() { T d; cin >> d; return d; }
// 最大公約数（Greatest Common Divisor）
LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; }
// 最小公倍数（Least Common Multiple）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
// Y年はうるう年か否か
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); }

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

// vector注意
// vec[i][j]の形に入力を入れるとき、vecは初期化してある必要がある.

// ------------------- include, typedef, define END. -------------------

int main() {
	FAST_IO;
	// for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;
	bool dbgF = true;

	//コードはここから書く.

	int N;
	LL ans = 1;
	cin >> N;
	FOR(i, 1, N + 1) {
		ans = ans*i % 1000000007;
	}
	cout << ans << endl;

	return 0;
}

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

int main() {
  int a,b,A,B ;
  
  cin >> a >> b;
  
  A = a % 2;
  B = b % 2;
  
  if(A==1 && B==1){
    cout << "Odd" ;
  }
  else{
    cout << "Even";
  }
}


Measured memory_bytes: 256
#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
#include<queue>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
int main() {
	ll n;
	cin >> n;
	ll count = 0;
	ll a = n;
	
	while (a) {
		a /= 26;
		count++;
	}
	
	string s;
	char c;
	ll sum = 0;
	while (n) {
		ll y = n % 26;
		n--;
		n /= 26;
		if (y == 0) {
			s+='z';
		}
		else {
			c = 'a' - 1 + y;
			s += c;
		}
		sum++;
		
	}
	reverse(s.begin(), s.end());
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 3628
#include<stdio.h>
#include<stdlib.h>

typedef long long int int64;

#define MIN(a,b) ((a)<(b)?(a):(b))

void run(void){
  const int m=1000;
  int n,W;
  scanf("%d%d",&n,&W);
  int64 *dp=(int64 *)calloc(m*n+1,sizeof(int64));
  int i;
  for(i=1;i<=m*n;i++) dp[i]=W+1;
  for(i=0;i<n;i++){
    int w,v;
    scanf("%d%d",&w,&v);
    for(int j=m*n;j>=v;j--){
      dp[j]=MIN(dp[j],dp[j-v]+w);
    }
  }
  for(i=m*n;dp[i]>W;i--);
  printf("%d\n",i);
}

int main(void){
  run();
  return 0;
}


Measured memory_bytes: 896
#include <vector>
#include <math.h>
#include <iostream>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <deque>
#include <map>

typedef long long ll;
#define rep(i, a, n) for(int i = a; i<n; i++)
#define ALL(a) begin(a), end(a)
#define mii map<int, int>
#define msi map<string, int>
#define vi vector<int>
#define vl vector<ll>
#define MOD 1000000007
#define INF 1e9
#define showVector(v) rep(i,0,v.size()){p(v[i]);p(" ")} pl("")
# define p(s) std::cout << s ;
# define pl(s)  std::cout << s << endl;
using namespace std;

// 素数判定 O(√n)
bool is_prime(int n){
    for(int i = 2; i * i <= n; i++){
        if(n % i == 0) return false;
    }
    return true;
}
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;
}
int main() {
    ll N, M;
    cin >> N >> M;
    //vector<vector<int>> data(3, vector<int>(4));
    vector<pair<ll, ll> > a(N);
    rep(i, 0, N) {
        cin >> a[i].first;
        cin >> a[i].second;
    }
    ll answer = 0;
    sort(a.begin(), a.end());
    rep(i, 0, N) {
        while(a[i].second > 0) {
            M -= 1;
            --a[i].second;
            answer += a[i].first;
            if (M == 0) {
                cout << answer << endl;
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <cmath>
#include <vector>
#include <queue>
#include <climits>
#include <utility>
typedef long long ll;
using namespace std;

int main(void){
  int n, i;
  cin >> n;

  if(n==3){
    printf("2\n");
    printf("1 3\n");
    printf("2 3\n");
  }
  else if(n==4){
    printf("4\n");
    printf("1 2\n");
    printf("1 3\n");
    printf("4 2\n");
    printf("4 3\n");
  }
  else if(n%2){
    printf("%d\n",(n/2)*4);

    printf("%d %d\n",n,1);
    printf("%d %d\n",n,n-1);
    for(i=1;i<n/2;i++){
      printf("%d %d\n",i,i+1);
      printf("%d %d\n",i,n-i-1);
      printf("%d %d\n",n-i,i+1);
      printf("%d %d\n",n-i,n-i-1);
    }
    printf("%d %d\n",n/2,n);
    printf("%d %d\n",n/2+1,n);
  }
  else{
    printf("%d\n",(n/2)*4);

    for(i=1;i<n/2;i++){
      printf("%d %d\n",i,i+1);
      printf("%d %d\n",i,n-i);
      printf("%d %d\n",n-i+1,i+1);
      printf("%d %d\n",n-i+1,n-i);
    }
    printf("%d %d\n",n/2,1);
    printf("%d %d\n",n/2,n);
    printf("%d %d\n",n/2+1,1);
    printf("%d %d\n",n/2+1,n);
  }

  return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <stdlib.h>
#include <stdio.h>

using namespace std;

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

int abs_A(int num) {
    if (num > 0)
        return num;
    else
        return -num;
}

int abs_B(long long num, long long numb) {
    if (num - numb >= 0)
        return num - numb;
    else
        return -1 * (num - numb);
}

long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}

long long lcm(long long a, long long b) {
    return a * b / gcd(a, b);
}

bool permutation(vector<int>& vec,vector<int>& P) {
    bool ok = true;
    for (int i = 0; i < vec.size(); i++) {
        //cout << vec.at(i);
        if (vec.at(i) != P.at(i)) {
            ok = false;
        }
    }
    return ok;
}

/*bool nibu(vector<int>& retu,int key) {
    
}*/

const long long MOD = 1000000007;
const int INF = 1001001001;

int main() {
    long long N;
    cin >> N;
    cout << N * (N - 1) / 2 << endl;
}



Measured memory_bytes: 256
n, k, q = map(int, input().split())
A = list(int(input()) for _ in range(q))
M = list(k-q for _ in range(n))

for i in range(q):
  M[A[i]-1] += 1

for m in M:
  if m > 0:
    print('Yes')
  else:
    print('No')

Measured memory_bytes: 11800
N = int(input())
B = list(map(int, input().split()))

sum = 0

for i in range(N):
    if i == 0:
        sum += B[i]
    elif i == N - 1:
        sum += B[i - 1]
    else:
        if B[i] >= B[i - 1]:
            sum += B[i - 1]
        else:
            sum += B[i]

print(sum)

Measured memory_bytes: 3064
using System;

namespace ITP1_1_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var input = Console.ReadLine().Split(' ');
            var a = int.Parse(input[0]);
            var b = int.Parse(input[1]);
            Console.WriteLine("{0} {1}", a * b, (a + b) * 2);
        }
    }
}

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

int main()
{ 
    ll n;
 cin>>n;
 ll a[n];
 ll b[n+1]={0};
 for(ll i=0;i<n;i++)
 {
    cin>>a[i];
    b[a[i]]++;
 }
 ll ans=0;
 
 for(ll i=1;i<=n;i++)
 {
     //cout<<b[i]<<endl;
     ans=ans+(b[i]*(b[i]-1))/2;
 }
 
 for(ll i=0;i<n;i++)
 {
     ll z=b[a[i]];
     z--;
     cout<<ans-z<<endl;
 }  
 return 0;
}

Measured memory_bytes: 5760
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <stdio.h>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << 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; }
bool compare_by_b(pair<LL, LL> a, pair<LL, LL> b) {
    if(a.second != b.second) return a.second < b.second;
    else return a.first < b.first;
}
std::uint32_t euclidean_gcd(std::uint32_t a, std::uint32_t b){return b != 0 ? euclidean_gcd(b, a % b) : a;}
void solve(long long L){
}
int main(){
    double L;
    cin>>L;
    L/=3;
    cout<<setprecision(10)<<L*L*L<<endl;
    return 0;
}


Measured memory_bytes: 256
function Main(input)
{ 
	input = input.split("\n");

  if (input[0][0] == input[1][2] && input[0][2] == input[1][0] && input[0][1] == input[1][1])
    console.log("YES");
  else
    console.log("NO");
}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 7372
#include<iostream> 
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)n; i++) 

int main() {
    int A, B, C, K;
    cin >> A >> B >> C >> K;
    int total = 0;
    
    while (K > 0) {
        if (A > 0) {
            while (A > 0) {
                total += 1;
                A -= 1;
                K -= 1;
                if (K == 0) {
                    break;
                }
            }
        } else if (B > 0) {
            while (B > 0) {
                B -= 1;
                K -= 1;
                if (K == 0) {
                    break;
                }
            }
        } else if (C > 0) {
            while (C > 0) {
                total -= 1;
                C -= 1;
                K -= 1;
                if (K == 0) {
                    break;
                }
            }
        }
    }
    cout << total << endl;
}

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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef long double Double;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<long double> vD;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))

bool solve(int a, int b) {
    return (a <= 8 && b <= 8);
}

int main() {
    int a,b; cin >>a >> b;
    cout << (solve(a,b) ? "Yay!":":(") << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int m = in.nextInt();
        int x = in.nextInt();

        int c[] = new int[n];
        int a[][] = new int[n][m];
        for (int i = 0; i < n; i++) {
            c[i] = in.nextInt();
            for (int j = 0; j < m; j++) {
                a[i][j] = in.nextInt();
            }
        }

        int select = 0;
        int min = Integer.MAX_VALUE;
        int understands[] = new int[m];
        while (select < powLong(2, n)) {
            Arrays.fill(understands, 0);
            int cost = 0;
            int currentSelect = select;
            for (int i = 0; i < n; i++) {
                if ((currentSelect & 1) == 1) {
                    for (int j = 0; j < m; j++) {
                        understands[j] += a[i][j];
                    }
                    cost += c[i];
                }
                currentSelect >>= 1;
            }

            if (allOk(understands, x)) {
                min = Math.min(cost, min);
            }

            select++;
        }

        if (min == Integer.MAX_VALUE) {
            System.out.println(-1);
        } else {
            System.out.println(min);
        }
    }

    static final boolean allOk(int understands[], int x) {
        for (int i = 0; i < understands.length; i++) {
            if (understands[i] < x) {
                return false;
            }
        }
        return true;
    }

    static final long powLong(long a, long e) {
        long r = 1;
        while (e > 0) {
            if ((e & 1) == 1) {
                r *= a;
            }
            e = e >> 1;
            a *= a;
        }

        return r;
    }
}

Measured memory_bytes: 28344
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'

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

  int64 n; cin >> n;
  int64 a[5]; rep(i, 5) cin >> a[i];

  int64 mn = *min_element(a, a + 5);

  if (mn >= n) {
    print(5); return 0;
  }

  //int pos = min_element(a, a + 5) - a;

  int64 cnt = 0;

  if (n % mn == 0) cnt = n / mn;
  else cnt = n / mn + 1;

  print(cnt + 4);

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n);i++)
#define sz(x) int(x.size())
typedef long long ll;
typedef pair<int,int> P;

int main(){ 
  int n;
  cin >> n;
  vector<int> res(n, 0);
  for (int i = 0; i < n - 1; i++) {
    int a;
    cin >> a;
    a--;
    res[a]++;
  }
  for (int i = 0; i < n; i++) {
    cout << res[i] << endl;
  }
  return 0;
} 

Measured memory_bytes: 3988
def main():

    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    visited = dict()
    visited[1] = 0
    inv_d = dict()
    inv_d[0] = 1
    j = 0
    period = 0
    shift = 0
    for i in range(1, N+1):
        if A[j] in visited:
            period = i-visited[A[j]]
            shift = visited[A[j]]
            break
        else:
            visited[A[j]] = i
            inv_d[i] = A[j]
            j = A[j]-1

    if K <= shift:
        return inv_d[K]
    else:
        return inv_d[(K-shift) % period + shift]



if __name__ == '__main__':
    print(main())

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

typedef long long ll;

int main(){
    string s;
    cin>>s;

    int c0 = 0, c1 = 0;
    for(int i=0; i<s.size(); i++){
        if(s[i]=='0'){
            c0++;
        }else if(s[i]=='1'){
            c1++;
        }
    }

    cout<<min(c0,c1)*2<<endl;
    return 0;    
}

Measured memory_bytes: 3736
/* {{{ Shinobu kawaii */
/*
  ______   __        _                  __
.' ____ \ [  |      (_)                [  |
| (___ \_| | |--.   __   _ .--.   .--.  | |.--.   __   _
 _.____`.  | .-. | [  | [ `.-. |/ .'`\ \| '/'`\ \[  | | |
| \____) | | | | |  | |  | | | || \__. ||  \__/ | | \_/ |,
 \______.'[___]|__][___][___||__]'.__.'[__;.__.'  '.__.'_/

*/
/* }}} */

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

// #define int long long
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);}} fast;

/* cpp template {{{ */

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) (v).begin(), (v).end()
#define X real()
#define Y imag()

/* REPmacro */
#define REPS(i, a, n) for (int i = (a); i < (n); ++i)
#define REP(i, n) REPS(i, 0, n)
#define RREP(i, n) REPS(i, 1, n + 1)
#define DEPS(i, a, n) for (int i = (a); i >= n; --i)
#define DEP(i, n) DEPS(i, n, 0)

/* debug */
#define debug(x) cerr << x << " " << "(L:" << __LINE__ << ")" << '\n';

/* typedef */
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<vii> viii;
typedef pair<int, int> pii;
typedef double D;
typedef complex<D> P;

/* const */
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1e9 + 7;
const D EPS = 1e-9;
const int dx[] = {0, 1, 0, -1, 1, -1, 1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

/* func */
inline bool inside(int y, int x, int H, int W) {return y >= 0 && x >= 0 && y < H && x < W;}
inline int in() {int x; std::cin >> x; return x;}
template <typename T> void print(T x) {std::cout << x << '\n';}
template <typename T>
void print(std::vector<T>& v, std::string s = " ") {
  REP(i, v.size()) {
    if (i != 0) std::cout << s;
    std::cout << v[i];
  }
  std::cout << '\n';
}

/* }}} */

signed main()
{
  string s;
  cin >> s;

  int scnt = 0, ans = 0;
  REP(i, s.size()) {
    if (s[i] == 'T' && scnt > 0) {
      ++ans;
      --scnt;
    }
    if (s[i] == 'S') ++scnt;
  }
  print(s.size() - 2 * ans);

  return 0;
}

Measured memory_bytes: 720