akhauriyash/Code-Regression huggingface dataset:
#include<cstdio>
#include<iostream>
using namespace std;
struct Date{
    int mx;
    int num;
};
int main(){
    while(1){
        int a[10]={0},b[10]={0};
        Date date;
        date.mx = 0;
        for(int i = 0; i < 5; i++){
            scanf("%d %d",&a[i],&b[i]);
            if(a[i] == 0 && b[i] == 0)goto end;
            if(date.mx < a[i]+b[i]){
                date.mx=a[i]+b[i];
                date.num = i;
            }
        }
        char d;
        switch(date.num){
            case 0:
                d = 'A';
                break;
            case 1:
                d = 'B';
                break;
            case 2:
                d = 'C';
                break;
            case 3:
                d = 'D';
                break;
            case 4:
                d = 'E';
                break;
        }
        printf("%c %d\n",d,date.mx);
    }
    end:
    return 0;
}

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

int main(){

  	string s;
	int n;  
  	cin >> n;
  
  	if(n <1200){
    	cout << "ABC" << endl;	
    }else if( n < 2800){
    	cout << "ARC" << endl;
    }else{
    	cout <<"AGC"  << endl;
    }
  	
	return 0;
}

Measured memory_bytes: 256
from itertools import permutations
import math


x = [int(input()) for i in range(5)]

lis = list(permutations(x,5))


minimum = 0
for i in x:
    minimum += math.ceil(i/10)*10

total = 0
for l in lis:
    total = l[0]
    for i in range(1,5):
        total += math.ceil(l[i]/10)*10
    minimum = min(minimum,total)

print(minimum)

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

int main(){
  int n,arr[100000];
  cin>>n;
  for(int i=0;i<n;i++) cin>>arr[i];

  int cnt[3]={1,0,0},idx=0,ans=0;
  for(int i=1;i<n;i++){
    if(arr[i-1]!=arr[i])cnt[idx%3]++;
    else ans=max(ans,cnt[0]+cnt[1]+cnt[2]),cnt[(idx+1)%3]=1,idx++;
  }
  ans=max(ans,cnt[0]+cnt[1]+cnt[2]);
  cout <<ans<<endl;
  return 0;
}

Measured memory_bytes: 1552
#include <iostream>
#include <stdio.h>
#include <vector>
#include <math.h>
#include <string>
using namespace std;
vector<bool> Dict((int)pow(5,12),false);
int main(void){
  int n;
  scanf("%d",&n);
  string s1,s2;
  int cnt,key;
  for(int i=0;i<n;i++){
    cin>>s1>>s2;
    cnt=0;
    key=0;
    for(string::iterator it = s2.begin();it!=s2.end();it++){
       if (*it=='A'){
	 key+=(int)pow(5,cnt);
       }else if (*it=='C'){
	 key+=(int)pow(5,cnt)*2;
       }else if (*it=='G') key+=(int)pow(5,cnt)*3;
       else key+=(int)pow(5,cnt)*4;
       cnt++;
    }
    if (!s1.compare("insert")) Dict[key]=true;
    else {
      if (Dict[key]){
	cout<<"yes"<<endl;
      }else {
	cout<<"no"<<endl;
      }
    }
  }
  return 0;
}



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

using namespace std;

#define ll long long int

#define mod int(1e9)+7

int main()
{
	ll a,b,c,d;
	cin >>  a >> b;
	vector<ll> v;
	for(ll i=0;i<a;i++)
	{
		cin >> c;
		v.push_back(c);
	}
	
	ll dp[b+1][a];
	
	for(ll i=0;i<=b;i++)
	{
		if(i<=v[a-1])
		dp[i][a-1]=1;
		else
		dp[i][a-1]=0;
	}
	for(ll i=0;i<a;i++)
	{
		dp[0][i]=1;
	}
	for(ll i=a-2;i>=0;i--)
	{
		vector<ll> ve(b+1);
		ve[0]=1;
		for(ll j=1;j<=b;j++)
		{
			ve[j]=ve[j-1]+dp[j][i+1];
		}
		for(ll j=1;j<=b;j++)
		{
			if(j>v[i])
			{
				dp[j][i]=ve[j]-ve[j-v[i]-1];
				dp[j][i]%=mod;
			}
			else
			{
				dp[j][i]=ve[j];
				dp[j][i]%=mod;
			}
		
		}
	}
//	cout << mod;
	cout << dp[b][0];
}

Measured memory_bytes: 79216
#include<iostream>
#include<ctype.h>
using namespace std;
int main() {
  for(int i=0;i<3;i++){
    string s;
    cin >> s;
    char c = toupper(s[0]); //　小文字を大文字に変換する関数. 
    cout << c;
  }
  return 0;
}

Measured memory_bytes: 256
import itertools
import numpy as np
N, K, *XYC = open(0).read().split()
N = int(N)
K = int(K)
board = np.zeros((4 * K + 1, 4 * K + 1), dtype=np.uint16)
for x, y, c in zip(XYC[::3], XYC[1::3], XYC[2::3]):
    x = int(x)
    y = int(y)
    if c == 'W':
        x += K
    x = x % (2 * K)
    y = y % (2 * K)
    board[x, y] += 1
    board[(x + K) % (2 * K), (y + K) % (2 * K)] += 1
board[1 + 2 * K:, 1 + 2 * K:] = board[:2 * K, :2 * K]
board[1:1 + 2 * K, 1 + 2 * K:] = board[1 + 2 * K:, 1 + 2 * K:]
board[1 + 2 * K:, 1:1 + 2 * K] = board[1 + 2 * K:, 1 + 2 * K:]
board[1:1 + 2 * K, 1:1 + 2 * K] = board[1 + 2 * K:, 1 + 2 * K:]
board[0, :] = 0
board[:, 0] = 0
for j in range(1, 3 * K):
    board[:, j] += board[:, j - 1]
for j in range(1, 3 * K):
    board[j, :] += board[j - 1, :]
ans = np.max(board[K:3 * K, K:3 * K] + board[:2 * K, :2 * K] -
             board[:2 * K, K:3 * K] - board[K:3 * K, :2 * K])
print(ans)


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

#define X first
#define Y second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define rep(i, a, b) for (int i = (a); i <= (b); ++i)
#define per(i, a, b) for (int i = (a); i >= (b); --i)

using namespace std;

using I = int;
using L = long;
using F = float;
using D = double;
using S = string;
using SS = stringstream;
using C = char;
using LL = long long;
using VI = vector<int>;
using VL = vector<long>;
using VF = vector<float>;
using VS = vector<string>;
using VVL = vector<vector<long>>;
using PLL = pair<long, long>;
using PLF = pair<long, float>;
using PLS = pair<long, string>;
using PSL = pair<string, long>;
using PSF = pair<string, float>;
using PSS = pair<string, string>;
using MLL = map<long, long>;
using MLF = map<long, float>;
using MLS = map<long, string>;
using MSL = map<string, long>;
using MSF = map<string, float>;
using MSS = map<string, string>;

const long kMax2 = 109;
const long kMax3 = 1009;
const long kMax4 = 10009;
const long kMax5 = 100009;
const long kMax6 = 1000009;
const long kInfI = 0x3F3F3F3F;
const float kInfF = 1e15;

template <class T>
void PrintVector(vector<T> & v, unsigned n) {
  rep(i, 0, n - 1) {
    cout << v[i] << " ";
  }
  cout << endl;
}

const L kMod = 10000;

int main(int argc, char const *argv[]) {
  L n, k;
  VVL f(kMax3, VL(9, 0));
  VL menu(kMax3, 0);
  cin >> n >> k;
  rep(i, 0, k - 1) {
    L a, b;
    cin >> a >> b;
    menu[a] = b;;
  }
  menu.resize(n + 1);
  f.resize(n + 1);
  if (menu[1] == 0 || menu[1] == 1) {
    f[1][1] = 1;
  }
  if (menu[1] == 0 || menu[1] == 2) {
    f[1][5] = 1;
  }
  if (menu[1] == 0 || menu[1] == 3) {
    f[1][6] = 1;
  }
  rep(i, 2, n) {
    rep(j, 0, 8) {
      if (menu[i] == 0 || menu[i] == 1) {
        switch (j) {
          case 0:
            f[i][j] = (f[i - 1][1] + f[i - 1][2]) % kMod;
            break;
          case 1:
            f[i][j] = (f[i - 1][3] + f[i - 1][4] + f[i - 1][5]) % kMod;
            break;
          case 2:
            f[i][j] = (f[i - 1][6] + f[i - 1][7] + f[i - 1][8]) % kMod;
            break;
          default:
            break;
        }
      }
      if (menu[i] == 0 || menu[i] == 2) {
        switch (j) {
          case 3:
            f[i][j] = (f[i - 1][0] + f[i - 1][1] + f[i - 1][2]) % kMod;
            break;
          case 4:
            f[i][j] = (f[i - 1][3] + f[i - 1][5]) % kMod;
            break;
          case 5:
            f[i][j] = (f[i - 1][6] + f[i - 1][7] + f[i - 1][8]) % kMod;
            break;
          default:
            break;
        }
      }
      if (menu[i] == 0 || menu[i] == 3) {
        switch (j) {
          case 6:
            f[i][j] = (f[i - 1][0] + f[i - 1][1] + f[i - 1][2]) % kMod;
            break;
          case 7:
            f[i][j] = (f[i - 1][3] + f[i - 1][4] + f[i - 1][5]) % kMod;
            break;
          case 8:
            f[i][j] = (f[i - 1][6] + f[i - 1][7]) % kMod;
            break;
          default:
            break;
        }
      }
    }
  }

  cout << accumulate(f[n].begin(), f[n].end(), 0) % kMod << endl;
  return 0;
}

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

int main()
{
    int n;
    cin >> n;
    int A[n];
    int B[n];
    for(int i = 1; i <= n; i++){
        B[i] = 0;
    }
    for(int i = 1; i < n; i++){
        cin >> A[i];
        B[A[i]]++;
    }
    for(int i = 1; i <= n; i++){
        cout << B[i] << endl;
    }
}


Measured memory_bytes: 5156
#include<iostream>
#include<string>
using namespace std;
int a;
int main(){
	string s,t;
	cin>>s>>t;
	if(s[0]==t[0]){
		a++;
	}
	if(s[1]==t[1]){
		a++;
	}
	if(s[2]==t[2]){
		a++;
	}
	cout<<a<<endl;
}


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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

template<typename T> class RPQ : public PQ<T, vector<T>, greater<T>> { };
template<typename Cost> void dijkstra(int start, vector<pair<int, Cost>> g[], Cost dist[]) {
	RPQ<pair<Cost, int>> q;
	dist[start] = 0;
	q.emplace(dist[start], start);
	while(! q.empty()) {
		auto cp = q.top(); q.pop();
		int  p = cp.SE;
		Cost c = cp.FI;
		if(dist[p] != c) { continue; }
		for(auto && e : g[p]) {
			int  ep = e.FI;
			Cost ec = e.SE;
			if(setmin(dist[ep], dist[p] + ec)) { q.emplace(dist[ep], ep); }
		}
	}
	return;
}

// ----

const int M = 100000;
int n, m, s, t;
LL d1[M], d2[M], INF = 1e16, ans[M];
vector<pair<int, LL>> g1[M], g2[M];

int main() {
	cin >> n >> m >> s >> t;
	s--; t--;
	inc(i, m) {
		int u, v, a, b;
		cin >> u >> v >> a >> b;
		u--; v--;
		g1[u].EB(v, a);
		g1[v].EB(u, a);
		g2[u].EB(v, b);
		g2[v].EB(u, b);
	}
	
	inc(i, n) { d1[i] = d2[i] = INF; }
	dijkstra(s, g1, d1);
	dijkstra(t, g2, d2);
	
	inc(i, n) { ans[i] = d1[i] + d2[i]; }
	dec(i, n - 1) { setmin(ans[i], ans[i + 1]); }
	
	inc(i, n) {
		cout << 1'000'000'000'000'000LL - ans[i] << "\n";
		// cout << ans[i] << endl;
	}
	
	return 0;
}


Measured memory_bytes: 19140
#include <iostream>
#include <vector>

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

const long long INF = 1LL << 60;

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 main() {
  int N, W;
  cin >> N >> W;

  vector<int> weight(N);
  vector<long long> value(N);

  long long sum_value = 0;
  for (int i = 0; i < N; i++) {
    cin >> weight[i] >> value[i];
    sum_value += value[i];
  }

  vector<vector<long long> > dp(
      N + 1, vector<long long>(sum_value + 1,
                               INF));  // i-1ばんめまででの品物の重さの最小値

  dp[0][0] = 0;

  for (int i = 0; i < N; i++) {
    for (int value_i = 0; value_i < sum_value + 1; value_i++) {
      if (value_i - value[i] >= 0) {
        chmin(dp[i + 1][value_i], dp[i][value_i - value[i]] + weight[i]);
      }
      chmin(dp[i + 1][value_i], dp[i][value_i]);
    }
  }

  long long res = 0;
  for (int sum_v = 0; sum_v < sum_value + 1; ++sum_v) {
    if (dp[N][sum_v] <= W) res = sum_v;
  }

  cout << res << endl;
}

Measured memory_bytes: 80256
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <stack>
#include <set>
#include <bitset>
#include <functional>
using namespace std;
#define fast_io ios_base::sync_with_stdio (false) ; cin.tie(0) ; cout.tie(0) ;
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define MOD (long long int)(998244353)
#define INF (int)(1123456789)
#define LINF (long long int)(112345678901234567)
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
#define all(v) v.begin(), v.end()
typedef pair<int, int> Pii;
typedef pair<ll, ll> Pll;

ll mpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = mpow(a,b/2); return memo*memo%MOD;}
  else return mpow(a,b-1) * a % MOD;
}
ll lpow(ll a, ll b){
  if(b==0) return 1;
  else if(b%2==0){ll memo = lpow(a,b/2); return memo*memo;}
  else return lpow(a,b-1) * a;
}
ll gcd(ll a, ll b){
  if(b==0) return a;
  else return gcd(b, a%b);
}
vector<ll> kaijo_memo;
ll kaijo(ll n){
  if(kaijo_memo.size() > n) return kaijo_memo[n];
  if(kaijo_memo.size() == 0) kaijo_memo.push_back(1);
  while(kaijo_memo.size() <= n) kaijo_memo.push_back(kaijo_memo[kaijo_memo.size()-1] * kaijo_memo.size() % MOD);
  return kaijo_memo[n];
}
vector<ll> gyaku_kaijo_memo;
ll gyaku_kaijo(ll n){
  if(gyaku_kaijo_memo.size() > n) return gyaku_kaijo_memo[n];
  if(gyaku_kaijo_memo.size() == 0) gyaku_kaijo_memo.push_back(1);
  while(gyaku_kaijo_memo.size() <= n) gyaku_kaijo_memo.push_back(gyaku_kaijo_memo[gyaku_kaijo_memo.size()-1] * mpow(gyaku_kaijo_memo.size(), MOD-2) % MOD);
  return gyaku_kaijo_memo[n];
}

ll nCr(ll n, ll r){
  if(n == r) return 1;//0個の丸と-1個の棒みたいな時に時に効く？不安.
  if(n < r || r < 0) return 0;
  ll ret = 1;
  if(n <= 1e7){
    ret *= kaijo(n); ret %= MOD;
    ret *= gyaku_kaijo(r); ret %= MOD;
    ret *= gyaku_kaijo(n-r); ret %= MOD;
  }else{
    rep(i,r){
      ret *= n-i; ret %= MOD;
      ret *= mpow(r-i, MOD-2); ret %= MOD;
    }
  }
  return ret;
}

int main(void){
  fast_io
  cout<<fixed<<setprecision(15);

  ll n,a,b,k; cin>>n>>a>>b>>k;
  ll ans = 0;
  rep(p, n+1){
    ll q = k - a * p;
    if(q % b != 0) continue;
    if(q < 0) continue;
    q /= b;
    if(q > n) continue;
    ans += nCr(n, p) * nCr(n, q) % MOD;
    ans %= MOD;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 11500
#include<cstdio>
#include<vector>
#include<cstdlib>
#include<cstring>
#include<utility>
#ifdef XS
	#include<De>
#endif
using namespace std;
#define MS(m) memset(m,0,sizeof(m))

typedef unsigned U;
typedef pair<int,int > P;
typedef long long ll;
void inp();
int main(){
#ifdef XS
	freopen("aoj0574.in","r",stdin);
#endif
	try{
		//while(1)
		//int n;scanf("%d",&n);for(int i=1;i<=n;i++)
		inp();
	}
	catch(... ){
#ifdef XS
		printf("%s","exception");
#endif
	}//for compatibility with cygwin c++ runtime
	return 0;
}
typedef vector<int > VI;
typedef vector<VI> VII;
void pA(VII &vii){
	for(U i = 0;i<vii.size();i++){
		for(U j = 0;j<vii[i].size();j++){
			printf("(%2d,%2d)", i,j);
		}
		printf("\n");
		for(U j = 0;j<vii[i].size();j++){
			printf("%7d",vii[i][j]);
		}
		printf("\n");
	}
}
VII vii;
void inp(){
	int n,m;scanf("%d%d",&n,&m);
	const int A = n+3;
	vii.resize(A);
	for(U i = 0;i< vii.size();i++){
		vii[i].resize(i+4, 0 );
	}
	for(int i = 1;i<=m;i++){
		int a,b,x;scanf("%d%d%d",&a,&b,&x);
	//	printf("%d%d%d\n",a,b,x);
		vii[a-1][b	] 	+= -1;
		vii[a-1][b+1] 	+= 1;
		vii[a+x][b	] 	+= 1;
		vii[a+x][b+x+2] += -1;
		vii[a+x+1][b+1]	+=-1;
		vii[a+x+1][b+x+2]+=1;
	}
	//flow
	//pA(vii);
	for(int i = 0;i<A;i++){
		for(U j = 1;j<vii[i].size();j++){
			vii[i][j] += vii[i][j-1];
		}
	}
	//pA(vii);
	for(int j = 0;j< vii[vii.size()-1].size() ;j++){
		for(int  i = vii.size() - 2 ;i >= j-1&&i>=0 ;i--){
			vii[i][j] += vii[i+1][j];
		}
	}
	//pA(vii);
	for(U i = 1; i < vii.size();i++){
		for(U j = 1;i + j < vii.size()&&j<vii[j].size();j++){
			vii[i + j -1][j] += vii[i  +j-2][j-1];
		}
	}
	int ans = 0;
	for(int i = 1;i<= n;i++){
		for(int  j = 1;j<=i;j++){
			if(vii[i][j]) ans++;
		}
	}
#ifdef XS
	pA(vii);
#endif
	printf("%d\n", ans);
}
//aoj0574.cc by xsthunder at Wed Jul 26 03:28:21 2017

Measured memory_bytes: 51448
#include <bits/stdc++.h>
#define reps(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) for(int i=0;i<a;i++)
using namespace std;


struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

int main(){
int N;
cin>>N;
int T[N];
int A[N];
rep(i,N){
    cin>>T[i]>>A[i];
}

long long int ima_left=1;
long long int ima_right=1;


rep(i,N){
    long long int wari_left = ima_left/T[i];
    long long int wari_right = ima_right/A[i];
    if(ima_left % T[i]==0){
        wari_left -=1;

    }
    if(ima_right % A[i]==0){
        wari_right -=1;

    }
    long long int maxi=max(wari_left,wari_right)+1;
    
    ima_left = T[i]*maxi;
    ima_right = A[i]*maxi;


}

cout<<ima_left+ima_right;


    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  int ans = 0;
  for(int i = 0; i < n; i++){
    int a;
    cin >> a;
    ans += a;
  }
  cout << ans - n << endl;
  return 0;
}

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

bool x[100001];
int q,l[100001],r[100001],ans[100001];

void sh()
{
	int i,j;
	x[0]=1;x[1]=1;
	for(i=2;i<=50000;i++)
	{
		if(x[i]==0)
		{
		    for(j=i+i;j<=100000;j+=i)
	        {
	        	x[j]=1;
            }
		}
	}  
}

void sh2()
{
	int i;
	for(i=99999;i>=3;i-=2)
	{
		if(x[i]==0)
		{
			if(x[(i+1)/2]!=0)x[i]=1;
		}
	}
	
}

void sh3()
{
	int i;
	ans[3]=1;
	for(i=4;i<=99999;i++)
	{
		if(x[i]==0)ans[i]=ans[i-1]+1;
		  else ans[i]=ans[i-1];
	}	
}

int main()
{
	cin>>q;
	sh();sh2();sh3();
	int i,j;
	for(i=1;i<=q;i++)cin>>l[i]>>r[i];
	for(i=1;i<=q;i++)
	{
		cout<<ans[r[i]]-ans[l[i]-1]<<endl;
	}
}

Measured memory_bytes: 1920
a, b, c = map(int, input().split())
abc = sorted([a, b, c])
even = 0
for i in abc:
    if i % 2 == 0:
        even += 1
ans = 0
if even == 0 or even == 3:
    ans = (abc[2] - abc[0]) // 2 + (abc[2] - abc[1]) // 2
elif even == 1:
    abc = [i + 1 if i % 2 == 1 else i for i in abc]
    ans = (abc[2] - abc[0]) // 2 + (abc[2] - abc[1]) // 2 + 1
else:
    abc = [i + 1 if i % 2 == 0 else i for i in abc]
    ans = (abc[2] - abc[0]) // 2 + (abc[2] - abc[1]) // 2 + 1

print(ans)

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

#define NREP() for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(),(x).end()
#define MSG(x) cout << x << endl;
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
using ll = long long;
const static ll MOD = 1e9 + 7;

int main(int argc, char *argv[]) {
    ll n;
    cin >> n;

    ll a[n+10];
    NREP() cin >> a[i];

    double sum = 0;
    NREP() {
        sum += 1 / (double)a[i];
    }

    cout << fixed << setprecision(30) << 1/sum << endl;
}


Measured memory_bytes: 768
#include <iostream>
using namespace std;
int main() {
	int N, M, K;
	cin >> N >> M >> K;
	for (int i = 0; i <= N; i++) {
		for (int j = 0; j <= M; j++) {
			if (i * M + j * N - 2 * i * j == K) {
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#define endl "\n"
#define ll long long int
using namespace std;

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

    vector <ll> a(n + 1);
    vector <ll> b(n);

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

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

    ll ans = 0;
    for(i = 0; i < n; i ++)
    {
    	ans = ans + min(b[i], a[i] + a[i + 1]);
    	ll left = max(0LL, b[i] - a[i]);
    	a[i + 1] = max(0LL, a[i + 1] - left);
    }

    cout << ans << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long                                    // long long省略
#define pb push_back                                    // push_back省略
#define mp make_pair                                    // make_pair省略
#define fi first                                        // first省略
#define se second                                       // second省略
#define itn int                                         // int誤字保険
#define count cout                                      // cout誤字保険
#define vecotr vector                                   // vector誤字保険
#define ednl endl                                       // endl誤字保険
#define opt() cin.tie(0); ios::sync_with_stdio(false)   // 入出力速度改善

#define rep(i,l,r) for(ll i=(l);i<(r);i++)               // 範囲[l, r)で刻み1のfor文(順方向)
#define repp(i,l,r,k) for(ll i=(l);i<(r);i+=(k))         // 範囲[l, r)で刻みkのfor文(順方向)
#define rrep(i,l,r) for(ll i=(r-1);i>=(l);i--)           // 範囲[l, r)で刻み1のfor文(逆方向)
#define rrepp(i,l,r,k) for(ll i=(r-1);i>=(l);i-=(k))     // 範囲[l, r)で刻みkのfor文(逆方向)
#define all(x) (x).begin(), (x).end()                   // vectorのポインタ位置指定用
#define max(p,q)((p)>(q)?(p):(q))                       // max拡張
#define min(p,q)((p)<(q)?(p):(q))                       // min拡張
#define bit(n,m)(((n)>>(m))&1)                          // 変数nのm番目のbitを取り出す

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int dy[]={0, 1, 0, -1};                                 // 4方向近傍
int dx[]={1, 0, -1, 0};                                 // 4方向近傍

int main(){
    ll a,b,c; cin>>a>>b>>c;
    cout << (a-1)*(b-1) << ednl;
}


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

int main() {
    ll a, b, c;
    cin >> a >> b >> c;
    ll ans = c-(a-b);
    if (ans < 0) cout << 0 << endl;
    else cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3624
d = {};
d["A"] = 0;
d["B"] = 0;
d["AB"] = 0;
d["O"] = 0;

while True:
 try:
  b = raw_input().strip().split(",")[1]
  d[b] += 1;
 except:
  break;

print d["A"]
print d["B"]
print d["AB"]
print d["O"]

Measured memory_bytes: 4208
#include <stdio.h>

main()
{
	char s1[100000];
	char s2[10];
	
	int i;
	
	int n;
	
	int a,w, t,r;
	a=0;
	w=0;
	t=0;
	r=0;
	
	scanf("%d",&n);
	
	for(i=0;i<n;i++)
	{
		scanf("%s",&s2[0]);
		s1[i]=s2[0];
	}
	
/*	for(i=0;i<n;i++)
	{
		printf("%c\n",s1[i]);
	}*/

	for(i=0;i<n;i++)
	{
		if(s1[i]=='A')
		{
			a++;
		}
		else if(s1[i]=='W')
		{
			w++;
		}
		else if(s1[i]=='T')
		{
			t++;
		}
		else if(s1[i]=='R')
		{
			r++;
		}
	}
	
	printf("AC x %d\n",a);
	printf("WA x %d\n",w);
	printf("TLE x %d\n",t);
	printf("RE x %d\n",r);

}

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

class UnionFindTree {
private:
  vector<int> par;
  vector<int> depth;

public:
  UnionFindTree(int n) {
    for (int i = 0; i < n; i++) {
      par.push_back(i);
      depth.push_back(0);
    }
  }

  int find(int x) {
    if (par[x] == x) {
      return x;
    } else {
      return par[x] = find(par[x]);
    }
  }

  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if (x == y)
      return;

    if (depth[x] < depth[y]) {
      par[x] = y;
    } else {
      par[y] = x;
      if (depth[x] == depth[y])
        depth[x]++;
    }
  }

  bool same(int x, int y) { return find(x) == find(y); }
};

int main() {
    int n, k, l;
    cin >> n >> k >> l;
    UnionFindTree road = UnionFindTree(n+1), rail = UnionFindTree(n+1);
    for(int i=0;i<k;++i){
        int p, q;
        cin >> p >> q;
        road.unite(p, q);
    }
    for(int i=0;i<l;++i){
        int r, s;
        cin >> r >> s;
        rail.unite(r, s);
    }
    map<pair<int, int>, int> mp;
    for(int i=1;i<=n;++i){
        mp[make_pair(road.find(i), rail.find(i))]++;
    }
    for(int i=1;i<=n;++i){
        cout << mp[make_pair(road.find(i), rail.find(i))];
        if(i == n)cout << endl;
        else cout << " ";
    }

  return 0;
}


Measured memory_bytes: 15124
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<double, long long> pdl;

const long double pi = 3.141592653589793;

#define debug(x) cerr << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define pb push_back
#define mp make_pair
#define mod 1000000007

ll A[1<<20], N;

int main() {
	//freopen("input.in","r",stdin);
  //freopen("output.out","w",stdout);
	cin>>N;
	rep(i, 3*N) {
		cin>>A[i];
	}
	sort(A, A+3*N);
	int counter = 0;
	int j = 3*N-2;
	ll ans = 0;
	while (counter < N) {
		ans += A[j];
		j -= 2;
		counter++;
	}

	cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 4480
#include <bits/stdc++.h>
#define ll long long
#define INF 999999999
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<n;++i)

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 505;

int X1[MAX_N],X2[MAX_N],Y1[MAX_N],Y2[MAX_N];
int w,h,n;
bool fld[MAX_N*6][MAX_N*6];

int compress(int *x1,int *x2,int W)
{
	vector<int> xs;
	rep(i,n){
		for(int d=-1;d<=1;d++){
			int tx1 = x1[i] + d;
			int tx2 = x2[i] + d;
			if(1 <= tx1 && tx1 <= W){
				xs.push_back(tx1);
			}
			if(1 <= tx2 && tx2 <= W){
				xs.push_back(tx2);
			}
		}
	}
	sort(xs.begin(),xs.end());
	xs.erase(unique(xs.begin(),xs.end()),xs.end());
	rep(i,n){
		x1[i] = find(xs.begin(),xs.end(),x1[i]) - xs.begin();
		x2[i] = find(xs.begin(),xs.end(),x2[i]) - xs.begin();
	}
	return xs.size();
}

int main()
{
	int dx[4] = {-1,0,0,1};
	int dy[4] = {0,-1,1,0};
	while(1){
	cin >> w >> h;
	if(w==0&&h==0){
		return 0;
	}else{
	cin >> n;
	rep(i,n){
		int p,q,r,s;
		scanf("%d%d%d%d",&p,&q,&r,&s);
		X1[i] = p+1;
		X2[i] = r;
		Y1[i] = q+1;
		Y2[i] = s;
	}
	w = compress(X1,X2,w);
	h = compress(Y1,Y2,h);
	memset(fld,0,sizeof(fld));
	rep(i,n){
		for(int y=Y1[i];y<=Y2[i];y++){
			for(int x=X1[i];x<=X2[i];x++){
				fld[y][x] = true;
			}
		}
	}
	int ans = 0;
	rep(y,h){
		rep(x,w){
			if(fld[y][x]){
				continue;
			}
			ans++;
			queue<P> que;
			que.push(P(x,y));
			while(!que.empty()){
				int sx = que.front().first;
				int sy = que.front().second;
				que.pop();
				rep(i,4){
					int tx = sx + dx[i];
					int ty = sy + dy[i];
					if(tx<0||w<=tx||ty<0||h<=ty){
						continue;
					}
					if(fld[ty][tx]){
						continue;
					}
					que.push(P(tx,ty));
					fld[ty][tx] = true;
				}
			}
		}
	}
	printf("%d\n",ans);
	}
	}
}

Measured memory_bytes: 12120
#include"bits/stdc++.h"

using namespace std;

#define Fast_D cout<<fixed<<setprecision(13);
#define FastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define nl "\n"
#define int long long
#define double long double
#define all(v) v.begin(),v.end()
#define scanstr(s) cin>>ws; getline(cin,s);

const double PI = 3.141592653589793;

void solve()
{
	string s;
	cin >> s;
	string cur ;
	reverse(all(s));
	for(char c : s)
	{
		cur+=c;
		if(cur=="maerd" || cur == "remaerd" || cur=="esare" || cur == "resare") cur.clear();
	}
	if(cur.size()==0) cout << "YES";
	else cout << "NO";
}

int32_t main()
{
	FastIO;
	Fast_D;
	solve();
	return 0;
}


Measured memory_bytes: 3744
import numpy as np
h, n = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
np_ab = np.array(ab)
max_a = max(np_ab[:,0]) #最大攻撃力
dp = [0]*(h + max_a)

for i in range(1, h + max_a):
    dp[i] = min(dp[i - a] + b for a, b in ab)
print(min(dp[h:]))


Measured memory_bytes: 14564
n = int(input())
char = "".join(chr(97+i) for i in range(n))
ans = []


def dfs(s, idx):
    if len(s) == n:
        ans.append(s)
    else:
        for i in range(idx):
            if i+1 != idx:
                dfs(s+char[i], idx)
            else:
                dfs(s+char[i], idx+1)


dfs("a", 2)
print(*ans, sep='\n')

Measured memory_bytes: 14496
A, B, C, D = map(int, input().split())


def gcd(a, b):
    while b:
        a, b = b, a % b
    return a


def lcm(a, b):
    return a * b // gcd(a, b)


divAC = A // C
divAD = A // D
divACD = A // lcm(C, D)
divBC = B // C
divBD = B // D
divBCD = B // lcm(C, D)

result = 0
if A % C == 0 or A % D == 0:
    result = (B - divBC - divBD + divBCD) - (A - divAC - divAD + divACD)
else:
    result = (B - divBC - divBD + divBCD) - (A - divAC - divAD + divACD) + 1
print(result)


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

using namespace std;
int main()
{
	int n;
	cin >> n;
	long long answer = 1, prom = 2,prom2;
	for (int i = 1; i < n; i++) {
		prom2 = answer;
		answer += prom;
		prom = prom2;
	}
	cout << answer;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(n) for (int I = 0; (I) < (n); ++(I) )
#define repeat(i, n) for( int i = 0; (i) < (n); ++(i) )
#define repeat_to(i, n) for( int i = 0; (i) <= (n); ++(i) )
#define repeat_from(i, m, n) for( int i = (m); (i) < (n); ++(i) )
#define repeat_from_to(i, m, n) for( int i = (m); (i) <= (n); ++(i) )
#define dump(x) cout << " " << #x << "=" << x
#define vdump(v) for(size_t T=0; T<v.size(); ++T){cout << " " << #v << "[" << T << "]=" << v[T];} cout << endl
using namespace std;
using lint = long long;
using ld = long double;

int main(void) {
    string a, b, c;
    cin >> a >> b >> c;
    if (a.back() == b.front() && b.back() == c.front())
        cout << "YES" << endl;
    else
        cout << "NO" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ld = long double;
const int NMAX = 303;
ld dp[NMAX][NMAX][NMAX];
int main() {
    std::cout << std::fixed << std::setprecision(9);
    for (int n; std::cin >> n; ) {
        std::fill(&dp[0][0][0], &dp[0][0][0] + NMAX * NMAX * NMAX, 0);
        int n1 = 0, n2 = 0, n3 = 0;
        for (int i = 0, a; i < n; i++) {
            std::cin >> a;
            n1 += (a == 1);
            n2 += (a == 2);
            n3 += (a == 3);
        }
        for (int i3 = 0; i3 <= n3; i3++) {
            for (int i2 = 0; i2 <= n2 + n3; i2++) {
                for (int i1 = 0; i1 <= n; i1++) {
                    int i0 = n - i1 - i2 - i3;
                    ld tmp = 0;
                    if (i3 > 0) tmp += i3 * (dp[i3-1][i2+1][i1] + 1);
                    if (i2 > 0) tmp += i2 * (dp[i3][i2-1][i1+1] + 1);
                    if (i1 > 0) tmp += i1 * (dp[i3][i2][i1-1] + 1);
                    if (i0 == n) continue;
                    tmp += i0;
                    tmp /= n;
                    ld coeff = (1 - ld(i0) / n);
                    dp[i3][i2][i1] = tmp / coeff;
                }
            }
        }
        std::cout << dp[n3][n2][n1] << std::endl;
    }
    return 0;
}

Measured memory_bytes: 434944
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<ll>;
using vvi= vector<vi>;
using vs = vector<string>;
#define ci(n,a)   ll a[n]; rep(i,(n)) cin>>a[i];
#define rep(i,n)  for(ll i = 0; i < (n); ++i)
#define red(i,n)  for(ll i = (n)-1; i >= 0; --i)
#define all(a)    begin(a),end(a)
#define pb(a)     push_back(a)
#define mp(a,b)   make_pair(a,b)
#define yn(a)     cout << ( (a)?"Yes\n":"No\n" )
inline ll gcd(ll a,ll b) { return b?gcd(b,a%b):a; }
ll INF = 1e9+9, LINF = 1e18;


int main(int argc,char* argv[]) 
{
    ll n,ans=1,a=1,b=1,c,d,q;
    cin>>n;
    rep(i,n){
        cin>>c>>d;
        q=max((a-1)/c+1,(b-1)/d+1);
        c*=q,d*=q;
        a=c,b=d;
    }
    cout<<c+d<<endl;
    
    return 0;
}


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

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch)
{
    if (ch == 'A') return 1;
    else if (ch == 'C') return 2;
    else if (ch == 'G') return 3;
    else if (ch == 'T') return 4;
    return 0;
}

long long getKey(char str[])
{
    long long sum = 0, p = 1, i;
    for (i = 0; i < strlen(str); i++)
    {
        sum += p*(getChar(str[i]));
        p *= 5;
    }
    return sum;
}

int h1(int key){ return key % M;}
int h2(int key){ return 1 + (key % (M - 1));}

int find(char str[])
{
    long long key, i, h;
    key = getKey(str);
    for (i = 0;; i++)
    {
        h = (h1(key) + i * h2(key)) % M;
        if (strcmp(H[h], str) == 0) return 1;
        else if (strlen(H[h]) == 0) return 0;
    }
    return 0;
}

int insert(char str[])
{
    long long key, i, h;
    key = getKey(str);
    for (i = 0;;i++)
    {
        h = (h1(key) + i* h2(key)) % M;
        if (strcmp(H[h], str) == 0) return 1;
        else if (strlen(H[h]) == 0)
        {
            strcpy(H[h], str);
            return 0;
        }
    }
    return 0;
}

int main()
{
    int i, n, h;
    char str[L], com[9];
    for (i = 0; i < M; i++) H[i][0] = '\0';
    scanf("%d", &n);
    for (i = 0; i < n; i++)
    {
        scanf("%s %s", com, str);

        if (com[0] == 'i')
        {
            insert(str);
        }
        else
        {
            if (find(str))
            {
                printf("yes\n");
            }
            else
            {
                printf("no\n");
            }
        }
    }
    return 0;
}



Measured memory_bytes: 16096
#include <iostream>
#include <string>
using namespace std;
int main()
{
    int a,b;
    cin >> a >> b;
    if(a<b){
        cout <<"a < b"<<endl;
    }  
    if(a>b){
        cout << "a > b"<<endl;
    }
    if(a==b){
        cout <<"a == b"<<endl;
    }
    return 0;
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll=long long;
using P=pair<int,int>;
int main(){
    int n,a,b;cin>>n>>a>>b;
    if((b-a)%2==1) cout<<"Borys"<<endl;
    else cout<<"Alice"<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <stdio.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>

//using namespace std;

#define Rep(i,a,b) for(int i = a; i < b; i++)
#define rep(i,b) Rep(i,0,b)
#define allof(a) (a).begin(), (a).end()

typedef long long ll;
const int inf = 1e9 + 7;
const ll infll = 1ll << 60ll;
const ll mod = 1e9 + 7;
// 0~3までは右左下上 4~7までは斜め
constexpr int dx[] = { 1, 0, -1, 0, 1, 1, -1, -1 };
constexpr int dy[] = { 0, -1, 0, 1, 1, -1, -1, 1 };

template<typename T> void chmax(T& a, T b) { a = std::max(a, b); }
template<typename T> void chmin(T& a, T b) { a = std::min(a, b); }
template<typename T> void chadd(T& a, T b) { a = a + b; }

namespace {  // 名前なし名前空間
	// gcd, lcm は C++17 でstdに標準入りしたので言語のバージョンに注意
	// 最大公約数
	ll gcd(ll a, ll b) {
		if (b == 0) return a;
		return gcd(b, a % b);
	}

	// 最小公倍数
	ll lcm(ll a, ll b) {
		return a / gcd(a, b) * b;
	}
}

int main() {
	
	int n, m;
	std::cin >> n >> m;
	std::vector<int> a(m), b(m);
	std::vector<std::vector<int>> c(m, std::vector<int>());
	rep(i, m) {
		std::cin >> a[i] >> b[i];
		rep(j, b[i]) {
			int tmp;
			std::cin >> tmp;
			c[i].push_back(--tmp);
		}
	}

	// bitDP
	std::vector<std::vector<int>> dp(m + 1, std::vector<int>(1 << n, inf));
	// dp[i][j] := i番目までの鍵を任意に購入して状態jになるのに必要な最小費用

	rep(i, m) {
		dp[i][0] = 0;
	}

	rep(i, m) {
		rep(bit, 1 << n) {
			// この状態から 鍵iを購入するかしないか
			int new_bit = bit;
			rep(j, b[i]) {
				new_bit |= (1 << c[i][j]);
			}
			// 買う
			dp[i + 1][new_bit] = std::min({ dp[i][new_bit], dp[i][bit] + a[i] , dp[i + 1][new_bit]});
			// 買わない
			dp[i + 1][bit] = std::min(dp[i][bit], dp[i + 1][bit]);
		}
	}

	// すべて揃った状態のを出力
	int ans = dp[m][(1 << n) - 1];
	if (ans == inf) ans = -1;
	std::cout << ans << std::endl;

	return 0;
}


Measured memory_bytes: 16384
import sys
import numpy as np
import collections

n = int(input())

s = []
for i in range(n):
    s.append(input())

c = collections.Counter(s)

c_sort = sorted(c.items(), key=lambda x:x[1], reverse=True)

max = c_sort[0][1]
max_list = []

for it in c_sort:
    if (it[1] == max):
        max_list.append(it[0])   
max_list.sort()
for list in max_list:
    print(list)

Measured memory_bytes: 56352
#include <bits/stdc++.h>
#define ll long long
#define SIZE 10000100
#define mp make_pair
using namespace std;
const ll mod = 1e9 + 7;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(nullptr); cout.tie(nullptr);
	ll n, k; cin >> n >> k;
	if (k >= n + 1) {
		cout << 1;
		return 0;
	}
	vector<ll> pre(n + 2, 0), suf(n + 2, 0);
	for (int i = 1; i <= n + 1; ++i) {
		pre[i] = pre[i - 1] + (i - 1);
		suf[i] = suf[i - 1] + (n - i + 1);
	}
	ll ans = 0;
	for (int i = k; i <= n + 1; ++i) {
		ans = (ans + suf[i] - pre[i] + 1 + mod) % mod;
	}
	cout << ans;
}

Measured memory_bytes: 6332
S = input()

kisu = "RUD"
gusu = "LUD"

for i, s in enumerate(S):
    if s == "R":
        if i % 2 != 0:
            print("No")
            exit()
    elif s == "L":
        if i % 2 == 0:
            print("No")
            exit()
print("Yes")

Measured memory_bytes: 3060
#include "bits/stdc++.h"
using namespace std;
int n,y;
int main(){
	cin>>n>>y;
	y/=1000;
	for(int i=0;i<=2000;i++){
		int flag1=0,flag2=0;
		for(int j=0;j<=2000;j++){
			for(int k=0;k<=2000;k++){
				int num=i*10+j*5+k;
				if(num>y||i+j+k>n) {
					flag1=1;break;
				}
				if(num==y&&i+j+k==n){
					cout<<i<<" "<<j<<" "<<k<<endl;
					return 0;
				}
			}
		} 
	}
	cout<<"-1 -1 -1"<<endl;
	return 0; 
}

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

const int N_MX = 200000;
int n;
int a[N_MX];
long long int ans = 0;

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

Measured memory_bytes: 4340
#include <bits/stdc++.h>
using namespace std;
#define Sz(a) ((int)(a).size())
const int maxn = 1000009;
const int MOD = 1e9 + 7;
string MP[maxn];
vector<vector<int>> U,D,L,R,V;
int main(){
#ifdef LOCAL
  freopen("a.in", "r", stdin);
#endif
  ios_base::sync_with_stdio(false),cout.tie(0),cin.tie(0);
  int n,m,k,x1,x2,y1,y2;
  cin>>n>>m>>k;
  cin>>x1>>y1>>x2>>y2;
  x1--;y1--;x2--;y2--;
  for(int i=0;i<n;++i)cin>>MP[i];
  U.assign(n,vector<int>(m));
  D.assign(n,vector<int>(m));
  R.assign(n,vector<int>(m));
  L.assign(n,vector<int>(m));
  V.assign(n,vector<int>(m,-1));
  auto in=[&](int x,int y){
    return x>=0&&x<n&&y>=0&&y<m;
  };
  auto work=[&](int x,int y,int dx,int dy,vector<vector<int>> &X,vector<pair<int,int>> &quee){
    int inx=x,iny=y;
    for(int j=1;j<=k;++j){
      x+=dx;y+=dy;
      if(!in(x,y))break;
      if(MP[x][y]=='@')break;
      if(V[x][y]==-1){
        X[x][y]=k-j;
        V[x][y]=V[inx][iny]+1;
        quee.emplace_back(x,y);
      }else if(V[x][y]==V[inx][iny]){
        if(X[x][y]>=k-j){
          break;
        }else{
          if(!in(x+dx*X[x][y],y+dy*X[x][y]))break;
          if(X[x+dx*X[x][y]][y+dy*X[x][y]]==0&&V[inx][iny]==V[x+dx*X[x][y]][y+dy*X[x][y]]){
            j+=X[x][y];
            X[x+dx*X[x][y]][y+dy*X[x][y]]=k-j;
          }
        }
      }else if(V[x][y]<V[inx][iny]){
        break;
      }
    }
  };
  vector<pair<int,int>> que;
  que.emplace_back(x1,y1);
  V[x1][y1]=0;
  for(int i=0;i<Sz(que);++i){
    int x=que[i].first,y=que[i].second;
    work(x,y,+1,0,D,que);
    work(x,y,-1,0,U,que);
    work(x,y,0,+1,R,que);
    work(x,y,0,-1,L,que);
  }
  cout<<V[x2][y2]<<'\n';
  return 0;
}
//2020.06.14 21:11:35


Measured memory_bytes: 68960
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

const int N = 200005;

int n, m;
int ans[N];
vector < pair < int, pair <int, int> > > vec;
set < pair <int, int> > s;

int main() {
  cin >> n >> m;
  for (int i = 0; i < n; i++) {
    int a, b, c;
    cin >> a >> b >> c;
    vec.push_back({c, {a, b}});
  }
  sort(vec.begin(), vec.end());
  for (int i = 0; i < m; i++) {
    int x;
    cin >> x;
    s.insert({-x, i});
  }
  memset(ans, -1, sizeof ans);
  for (int i = 0; i < n; i++) {
    int x = vec[i].first - vec[i].second.second + 1, y = vec[i].first - vec[i].second.first;
    auto beg = s.lower_bound({x, -2e9});
    auto ende = s.upper_bound({y, 2e9});
    while (beg != ende) {
      beg++;
      auto here = prev(beg);
      ans[here->second] = vec[i].first;
      s.erase(here);
    }
  }
  for (int i = 0; i < m; i++) {
    cout << ans[i] << '\n';
  }
  return 0;
}


Measured memory_bytes: 14448
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#include <climits>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RFOR(i,a,b) for (int i=(a)-1;i>=(b);i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 1e9;
const int MOD = 1e9 + 7;
 
using namespace std;
int dp[1002][1002];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
    int n;
    cin>>n;
    string s1,s2;
    while(n--){
        cin>>s1>>s2;
        FOR(i,1,s1.size()+1){
            FOR(j,1,s2.size()+1){
                if(s1[i-1] == s2[j-1])dp[i][j] = dp[i-1][j-1]+1;
                else dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
            }
        }
        cout << dp[s1.size()][s2.size()] << endl;
    }
  return 0;
}

Measured memory_bytes: 7044
#include"bits/stdc++.h"
using namespace std;
#define REP(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define rep(i,n) REP((i),0,(n))
using ll = long long;
using tp3=tuple<ll, ll, ll>;

int main()
{
	int W, H;
	cin >> W >> H;
	vector<ll> p(W), q(H);
	rep(i, W)cin >> p[i];
	rep(j, H)cin >> q[j];

	priority_queue<tp3, vector<tp3>, greater<tp3>> pq;
	rep(i, W)pq.push(make_tuple(p[i], i, 0));
	rep(j, H)pq.push(make_tuple(q[j], j, 1));

	ll res = 0;
	H++; W++;
	while (!pq.empty()) {
		ll num, pos, kind;
		tie(num, pos, kind) = pq.top(); pq.pop();
		if (kind == 0) {
			res += num * H;
			W--;
		}
		else {
			res += num * W;
			H--;
		}
	}
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 10096
#pragma GCC target ("avx2")
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")
#include <bits/stdc++.h>
#define int long long
#define ld long double
#define x first
#define y second
#define mp make_pair
#define pb push_back
#define rt return
#define yy cout<"Yes\n"
#define nn cout<<"No\n"
#define er erase
#define cl clear
#define bg begin
#define bk break
#define ct continue
using namespace std;
struct st{
    
};
bool cmp(){
    
    return 1;
}
int go(){
    
    return 0;
}
void recur(){
    
}
void solve(){
    string s;
    cin>>s;
    if (s=="RRR") cout<<3;
    else if (s=="RRS"||s=="SRR") cout<<2;
    else if (s=="RSS"||s=="SRS"||s=="SSR"||s=="RSR") cout<<1;
    else cout<<0;
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    int t=1;
    //cin>>t;
    while (t--) solve();
}

Measured memory_bytes: 3608
def main():
    H, W = map(int, input().split())
    a = [input() for _ in range(H)]

    ans = f(H, W, a)
    for x in ans:
        print(*x, sep="")


def f(H, W, a):
    b = []
    for line in a:
        if len(line) != line.count("."):
            b.append(line)

    if not b:
        return [[]]

    idxes = []
    for x in range(len(a[0])):
        y = sum(1 for i in range(len(b)) if b[i][x] == ".")
        if y != len(b):
            idxes.append(x)

    if not idxes:
        return [[]]

    ans = []
    for i in range(len(b)):
        line = []
        for j in range(len(a[0])):
            if j in idxes:
                line.append(b[i][j])
        ans.append(line)

    return ans


if __name__ == '__main__':
    main()


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

int main(){
 int A,B,C;
 cin >> A >> B >> C;
 int ispoor = 0;
 if(A==B && B!=C) ispoor = 1;
 if(B==C && C!=A) ispoor = 1;
 if(C==A && A!=B) ispoor = 1;
 if(ispoor){
   cout << "Yes" << endl;
 }else{
   cout << "No" << endl;
 }
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <map>
#include <string>
#include <math.h>
using namespace std;

#define ll long long

int main() {
	ll n, k, m, hoge;
	cin >> n >> k;
	vector<int> h;
	for (int i = 0; i < n; i++) {
		cin >> hoge;
		h.push_back(hoge);
	}
	m = 2000000000;
	sort(h.begin(), h.end());
	for (int i = 0; i <= n - k; i++) {
		hoge = h[i + k - 1] - h[i];
		m = min(m, hoge);
	}

	cout << m << endl;
	return 0;
}

Measured memory_bytes: 892
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
		int x;
		int y;
		int z;
		Scanner scan = new Scanner(System.in);
		String num = scan.nextLine();
		String[] numbers = num.split(" ");
		x = Integer.parseInt(numbers[0]);
		y = Integer.parseInt(numbers[1]);
//		z = Integer.parseInt(numbers[2]);

		String A = scan.nextLine();
		String[] a = A.split(" ");

		for(int i=0; i<y; i++) {
			x = x-Integer.parseInt(a[i]);
		}

		if(x<0) {
			System.out.println(-1);
		}else {
			System.out.println(x);
		}

	}
}

Measured memory_bytes: 30540