akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

long long A, B;

//num以下の数字の bit_idx 番目のbitの合計
long long get_one_bit(long long num, long long bit_idx){
	long long interval = (1LL<<bit_idx); //連続する0,1
	long long setnum = interval * 2; //周期
	long long rep = (num+1)/setnum; //周期の数
	long long additional = (num+1)%setnum; //周期からはみ出る分
	long long one_in_add = max(0LL, additional - interval);

	//cout << "num " << num << " bit idx " << bit_idx << " int " << interval << " rep " << rep << " add " << additional << endl;
	//cout << " one_in_add " << one_in_add << endl;
	return one_in_add + rep * interval;
}

int main(){
	//cout << get_one_bit(4,0) << endl;
	//cout << get_one_bit(4,1) << endl;
	//cout << get_one_bit(4,2) << endl;
	//cout << get_one_bit(4,3) << endl;
	cin >> A >> B;
	A = max(0LL, A-1);

	long long ans = 0;
	for(long long i = 0; (B>>i) != 0; i++){
		long long b_bit = get_one_bit(B, i);
		long long a_bit = get_one_bit(A, i);
		if((b_bit - a_bit)%2 == 1){
			//cout << " add " << i << " bit " << endl;
			ans += (1LL<<i);
		}
	}
	cout << ans << endl;

}

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

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int k = -1, pos, j, i;
	ll sz = 0;
	string s, t;
	cin >> s;
	cin >> t;
	vvi lt('z' - 'a' + 1);
	for (i = 0; i < s.size(); i++)
		lt[s[i] - 'a'].push_back(i);

	for (i = 0; i < t.size(); i++) {
		j = t[i] - 'a';
		if (lt[j].size() == 0) {
			sz = -1; break;
		}
		pos = lower_bound(lt[j].begin(), lt[j].end(), k + 1) - lt[j].begin();
		if (pos == lt[j].size()) {
			sz += (s.size() - k) + lt[j][0];
			k = lt[j][0];
		}
		else {
			sz += (lt[j][pos] - k);
			k = lt[j][pos];
		}
	}
	cout << sz << endl;
	return 0;
}

Measured memory_bytes: 1228
//#include <bits/stdc++.h>
//#include <stdio.h>
#include<iostream>
#include<cstdio>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
#include<cctype>
#include<fstream>


#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000

using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;

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



int main(void) {
	long long int a, b, c;

	cin >> a >> b >> c;

	if (a + b + 1 >= c) {
		cout << b + c << endl;
	}
	else {
		cout << (a + b + 1) + b << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define M 1046527
#define NIL -1

int HashTable[M];

void init(){
    for ( int i = 0; i < M; i++) HashTable[i] = NIL;
}

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;
    else return 0;
}

long long getKey(char str[]){
    long long sum = 0, p = 1;
    for ( int 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 h(int key, int i) {return (h1(key) + i * h2(key)) % M;}

void insert(char str[]){
    int key = getKey(str);
    int i = 0, hash;
    while( 1 ){
        hash = h(key, i);
        if ( HashTable[hash] == NIL ){
             HashTable[hash] = key;
             break;
        }
        else if ( HashTable[hash] == key ) break;
        else i++;
    }
}

bool find(char str[]){
    int key = getKey(str);
    int i = 0, hash;
    while( 1 ){
        hash = h(key, i);
        if ( HashTable[hash] == key ) return 1;
        else if (HashTable[hash] == NIL or i >= M) return 0;
        else i++;
    }
}

int main(){
    init();
    int n;
    char com[10], str[15];
    scanf("%d",&n);
    for ( int 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: 6672
#include<cstdio>
#include<iostream>
#include<algorithm>
#define M 200005
using namespace std;
int A[M],B[M],C[M];
int main(){
	int n;
	scanf("%d",&n);
	int t=n%2;
	for(int i=1;i<=n;i++)scanf("%d",&A[i]);
	int k=(n+2)/2;
	B[1]=k;
	for(int i=2;i<=n;i++){
		int p=i/2;
		if(i%2==0){
			if(t)B[i]=k+p;
			else B[i]=k-p;
		}else{
			if(t)B[i]=k-p;
			else B[i]=k+p;
		}
	}
	for(int i=1;i<=n;i++)C[B[i]]=A[i];
	for(int i=1;i<=n;i++)printf("%d ",C[i]);
	puts("");
	return 0;
}

Measured memory_bytes: 4480
#include <bits/stdc++.h>
#include <stdio.h>
#define fin freopen("input", "r", stdin)
#define whatis(x) cerr << #x << ": " << x << endl;

using namespace std;
using ll = long long;

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

    cout << fixed;
    cout << setprecision(7);

    int n;
    cin >> n;

    if (n%2) {
        cout << (((n/2)+1)/(n*1.00)) << endl;
    } else {
        cout << (((n/2))/(n*1.00)) << endl;
    }
    


    return 0;
}


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

const int maxn = 1e5+5;
typedef long long ll;
int d[maxn];

struct node
{
    int b,c;
} a[maxn];

int cmp(node x,node y)
{
    return x.c>y.c;
}

int main()
{
    int n,m;
    scanf("%d %d",&n,&m);
    for(int i=0; i<n; i++)
    {
        scanf("%d",&d[i]);
    }
    sort(d,d+n);

    for(int i=0; i<m; i++)
    {
        scanf("%d %d",&a[i].b,&a[i].c);
    }
    sort(a,a+m,cmp);

    int j=0;
    ll ans=0;
    for(int i=0; i<n; i++)
    {
        if(d[i]<a[j].c&&a[j].b)
        {
            ans+=a[j].c;
            a[j].b--;
        }
        else
            ans+=d[i];
        if(a[j].b==0)
        {
            if(j+1<m)
                j++;
        }
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 1408
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << "\n"; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
// debug() << imie(x) imie(y)
//debugging ends

typedef long long ll;

int solve(){
    int n;
    cin>>n;
    vector<int> v(n);
    for (size_t i = 0; i < n; i++)
    {
      cin>>v[i];
    }
    sort(v.begin(),v.end());
    //debug()<< v;
    ll res=0;
    for (int i = 0; i < n-2; i++)
    {
      for (int j = i+1; j < n-1; j++)
      {
         if(v[i]==v[j]) continue;
        for (int k = j+1; k < n; k++)
        {
          if(v[j]==v[k]) continue;
          if(v[k]<v[i]+v[j]) res++;
        } 
      }
    }
    
    cout<<res;
    
    return 0;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cerr<<fixed<<setprecision(10);
  auto start = chrono::high_resolution_clock::now();
  int t=1;
  //cin>>t;
  while(t--)
    solve(),cout<<"\n";

  auto stop = chrono::high_resolution_clock::now(); 
  auto duration = chrono::duration_cast<chrono::nanoseconds>(stop - start); 
  cerr << "Time taken : " << ((long double)duration.count())/((long double) 1e9) <<"s \n";      
  
  return 0;
}


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

int n, m, l, r, ansL, ansR = 1e9;

int main() {
    cin >> n >> m;
    rep(i, m) {
        cin >> l >> r;
        ansL = max(ansL, l);
        ansR = min(ansR, r);
    }
    cout << max(ansR - ansL + 1, 0) << endl;
}

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

typedef long long int ll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;

using namespace std;

ll M[100005];
ll T[100005];
ll A[100005];

int main()
{
	int N;
	cin >> N;
	REP(i, N)
	{
		cin >> T[i];
	}
	REP(i, N)
	{
		cin >> A[i];
	}
	if (A[0] != T[N - 1])
	{
		cout << 0 << endl;
		return 0;
	}
	REP(i, N)
	{
		M[i] = 1;
		if (i > 0 && T[i] == T[i - 1])
		{
			M[i] = T[i];
		}
	}
	M[N - 1] = 1;
	IREP(i, N - 2)
	{
		if (M[i] == 1 && T[i] > A[i])
		{
			M[i] = 0;
			continue;
		}
		if (A[i] == A[i + 1])
		{
			M[i] = std::min(M[i], A[i]);
		}
		else if (T[i] < A[i])
		{
			M[i] = 0;
		}
		else
		{
			M[i] = 1;
		}
	}

	ll ans = 1;
	REP(i, N)
	{
		ans *= M[i];
		ans %= MOD;
	}

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

Measured memory_bytes: 2560
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>
#define M 5005
#define N 2005
#define mod 1000000007ll
using namespace std;
int n,A[M<<6],B[M<<6];
long long F[M][M],inv[M<<1],fac[M<<1],inv_fac[M<<1],ans;
int read(){
	char c=getchar();int ans=0;
	while (c<'0'||c>'9') c=getchar();
	while (c>='0'&&c<='9') ans=(ans<<1)+(ans<<3)+(c^48),c=getchar();
	return ans;
}
long long add(long long u,long long v){return u+v>=mod?u+v-mod:u+v;}
long long C(int n,int m){
	return fac[n]*inv_fac[m]%mod*inv_fac[n-m]%mod;
}
int main(){
	n=read();fac[0]=inv_fac[0]=inv[1]=1;
	for (int i=1;i<=n;i++) A[i]=read(),B[i]=read(),F[-A[i]+N][-B[i]+N]++;
	for (int i=2;i<=8000;i++) inv[i]=(mod-mod/i)*inv[mod%i]%mod;
	for (int i=1;i<=8000;i++) fac[i]=fac[i-1]*i%mod,inv_fac[i]=inv_fac[i-1]*inv[i]%mod;
	for (int i=1;i<=(N<<1);i++)
	    for (int j=1;j<=(N<<1);j++) F[i][j]=add(F[i][j],add(F[i-1][j],F[i][j-1]));
	for (int i=1;i<=n;i++) ans=add(ans,F[A[i]+N][B[i]+N]);
	for (int i=1;i<=n;i++) ans=add(ans,mod-C((A[i]+B[i])<<1,B[i]<<1));
	printf("%lld",ans*inv[2]%mod);
	return 0;
}
 

Measured memory_bytes: 160640
A, B, C, X, Y = map(int, input().split())
yen = 0
if (A+B)/2 > C:
    if X < Y:
        yen += 2*C*X
        yen += min(C*2, B)*(Y - X)
    else:
        yen += 2*C*Y
        yen += min(C*2, A)*(X - Y)

else:
    yen += A*X + B*Y

print(yen)

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

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

    int N,k; cin >> N >> k;
    int a[N];
    for(int i=0;i<N;i++){
        cin >> a[i];
    }
    ll ans[N];
    memset(ans,1e9+2,sizeof(ans));
    ans[0] = 0;
    for(int i=0;i<N;i++){
        for(int j=1;j<=k;j++){
            if(i+j<N){
                ans[i+j] = min(ans[i+j],ans[i]+abs(a[i+j]-a[i]));
            }
        }
    }
    cout << ans[N-1];

    return 0;
}


Measured memory_bytes: 1408
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

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

const ll MAX=500000;
const ll INFTY=1000000010;

ll L[MAX/2+2],R[MAX/2+2];
int cnt;

void merge(int A[], int left, int mid ,int right){
  int n1=mid - left;
  int n2=right-mid;

  rep(i,n1) L[i]=A[left+i];
  rep(i,n2) R[i]=A[mid+i];
  L[n1]=INFTY;
  R[n2]=INFTY;
  int i=0,j=0;
  for(int k=left;k<right;k++){
    cnt++;
    if(L[i]<=R[j]) A[k]=L[i++];
    else A[k]=R[j++];
  }
}

void mergeSort(int A[],int left,int right){
  if(left+1<right){
    int mid=(left + right)/2;
    mergeSort(A,left,mid);
    mergeSort(A,mid,right);
    merge(A,left,mid,right);
  }
}

int main() {
  cnt=0;
  int n;
  cin>>n;
  int S[MAX];
  rep(i,n) cin>>S[i];
  
  mergeSort(S,0,n);
  rep(i,n){
    if(i)cout<<" ";
    cout<<S[i];
  }
  cout<<endl;
  cout<<cnt<<endl; 
 
  return 0;
}


Measured memory_bytes: 8916
d = {'R':1, 'G':2, 'B':4}
MOD = 998244353
n = int(input())
s = input()

R = B = G = 0
ans = 1

for i in s:
    m = sorted([R, G, B])
    if i == 'R':
        c = R
        R += 1
    elif i == 'G':
        c = G
        G += 1
    else:
        c = B
        B += 1

    if c == m[-1]:
        ans *= n - m[-1]
    elif c == m[1]:
        ans *= m[2] - m[1]
    else:
        ans *= m[1] - m[0]

    ans %= MOD
        

print(ans)


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

#define ll long long

template<typename T> void drop(const T &x){cout<<x<<'\n';exit(0);}

void solve() {
  int h, w; cin >> h >> w;
  vector<string> c(h);
  for(int i=0; i<h; ++i) {
    cin >> c.at(i);
  }

  h*=2;
  for(int i=0; i<h; ++i) {
    cout << c.at(i/2) << '\n';
  }
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int T=1;
  //cin >> T;
  while(T--) solve();

  return 0;
}


Measured memory_bytes: 3552
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)

	runes := []rune(s)

	for i := 1; i < 4; i++ {
		if runes[i-1] == runes[i] {
			fmt.Println("Bad")
			return
		}
	}
	fmt.Println("Good")
}


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

ll gcd(ll a, ll b) {
    if (a < b) {
        ll tmp = a;
        a = b;
        b = tmp;
    }
    
    ll r = a % b;
    while(r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

int main(void){
    int n;
    cin >> n;
    vector<ll> a(n, 0);
    rep(i, n) cin >> a[i];
    
    vector<ll> ruiseki(n-1);
    vector<ll> ruiseki_rv(n-1);
    ruiseki[0] = a[0];
    rep(i, n-2) ruiseki[i+1] = gcd(ruiseki[i], a[i+1]);
    ruiseki_rv[n-2] = a[n-1];
    for (int i = n-2; i > 0; i--) ruiseki_rv[i-1] = gcd(ruiseki_rv[i], a[i]);
    
    //rep(i, n-1) cout << ruiseki[i] << endl;
    //rep(i, n-1) cout << ruiseki_rv[i] << endl;
    
    ll m = ruiseki_rv[0];
    for (int i = 0; i < n-2; i++) {
        m = max(m, gcd(ruiseki[i], ruiseki_rv[i+1]));
        //cout << i << " " << n-2-i << endl;
    }
    m = max(m, ruiseki[n-2]);
    cout << m << endl;
}

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

int main() {
  int r, c;
  cin >> r >> c;
  int a[r+1][c+1];
  
  for (int i = 0; i < r; i++) {
    for (int j = 0; j < c; j++) {
      cin >> a[i][j];
    }
  }
  
  for (int i = 0; i < r; i++) {
    int sum = 0;
    for (int j = 0; j < c; j++) {
      sum += a[i][j];
    }
    a[i][c] = sum;
  }
  
  for (int j = 0; j <= c; j++) {
    int sum = 0;
    for (int i = 0; i < r; i++) {
      sum += a[i][j];
    }
    a[r][j] = sum;
  }
  
  /*for (int i = r; i <= r; i++) {
    int sum = 0;
    for (int j = 0; j <= c; j++) {
      sum += a[i][j];
    }
    a[i][c] = sum;
  }*/
  
  for (int i = 0; i <= r; i++) {
    for (int j = 0; j <= c; j++) {
      cout << a[i][j];
      if (j == c) cout << endl;
      else cout << " ";
    }
  }
  
}



Measured memory_bytes: 3112
#pragma GCC optimize("O3")
#include<stdint.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/rope>
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define VIS(it,con) for(auto it=con.begin();it!=con.end();++it)
#define pob pop_back
#define pf push_front
#define pof pop_front
#define MIN(x,y) (x=min(x,(y)))
#define MAX(x,y) (x=max(x,(y)))
#define mid (l+r>>1)
#define lch (idx*2+1)
#define rch (idx*2+2)
/*****************************************************************************/
#include<bits/stdc++.h>
#define ll int_fast64_t
using namespace std;
typedef pair<ll,int> pii;
typedef vector<int> VI;
#define REP(i,j,k) for(int i=(j);i<(k);++i)
#define RREP(i,j,k) for(int i=(j)-1;i>=(k);--i)
#define ALL(a) a.begin(),a.end()
#define MST(a,v) memset(a,(v),sizeof a)
#define pb push_back
#define F first
#define S second
#define endl '\n'
//																#define __debug
#ifdef __debug
	#define IOS (void)0
	#define de(...) cerr<<__VA_ARGS__
	#define ar(a,s,t) {REP(__i,s,t)de(a[__i]<<' ');de(endl);}
#else
	#define IOS cin.tie(0),cout.tie(0),ios_base::sync_with_stdio(false)
	#define de(...) (void)0
	#define ar(...) (void)0
#endif
/***********************************default***********************************/
struct ED{
	int to,fl,cp,cs,rv;
};

const int maxn=1009;
const ll inf=1ll<<60;
int n,k,pe[2*maxn],pv[2*maxn];
ll h[2*maxn],dis[2*maxn];
bitset<2*maxn>cert;
vector<ED>G[2*maxn];

void init(int _n){
	k=_n;
//	REP(i,0,k)G[i].clear();
}

void adde(int fr,int to,int cp,int cs){
	G[fr].pb(ED{to,0,cp,cs,G[to].size()});
	G[to].pb(ED{fr,0,0,-cs,G[fr].size()-1});
}

void mnt(int u){
	REP(i,0,G[u].size()){
		ED&ee=G[u][i];
		if(ee.fl<ee.cp&&h[ee.to]>h[u]+ee.cs){
			h[ee.to]=h[u]+ee.cs;
		}
	}
}

ll sol(int s,int t){
	fill(h,h+k,inf);
	h[s]=0;
	mnt(s);
	REP(i,0,n)mnt(i);
	mnt(2*n+0);
	mnt(2*n+1);
	mnt(2*n+2);
	mnt(2*n+3);
	REP(i,0,n)mnt(i+n);
	mnt(t);
	ll cs=0;
	while(1){
		cert.reset();
		fill(dis,dis+k,inf);
		priority_queue<pii,vector<pii>,greater<pii> >pq;
		dis[s]=0;
		pq.push(pii(dis[s],s));
		while(!pq.empty()){
			int u=pq.top().S;pq.pop();
			if(cert[u])continue;
			cert[u]=1;
			REP(i,0,G[u].size()){
				ED&ee=G[u][i];
				if(ee.fl<ee.cp&&dis[ee.to]>dis[u]+ee.cs+h[u]-h[ee.to]){
					dis[ee.to]=dis[u]+ee.cs+h[u]-h[ee.to];
					pv[ee.to]=u;
					pe[ee.to]=i;
					pq.push(pii(dis[ee.to],ee.to));
				}
			}
		}
		if(dis[t]>=inf)break;
		REP(i,0,k)h[i]+=dis[i];
		int fl=100,u=t;
		while(u!=s){
			ED&ee=G[pv[u]][pe[u]];
			MIN(fl,ee.cp-ee.fl);
			u=pv[u];
		}
		u=t;
		while(u!=s){
			ED&ee=G[pv[u]][pe[u]],&re=G[u][ee.rv];
			ee.fl+=fl;
			re.fl-=fl;
			u=pv[u];
		}
		cs+=h[t]*fl;
	}
	return cs;
}

main(){
	IOS;
	cin>>n;
	init(2*n+6);
	REP(i,0,n){
		int x,y,c;cin>>x>>y>>c;
		adde(i,2*n+0,c,-x-y);
		adde(i,2*n+1,c,+x-y);
		adde(i,2*n+2,c,-x+y);
		adde(i,2*n+3,c,+x+y);
		adde(2*n+4,i,c,0);
	}
	REP(i,0,n){
		int x,y,c;cin>>x>>y>>c;
		adde(2*n+0,n+i,c,+x+y);
		adde(2*n+1,n+i,c,-x+y);
		adde(2*n+2,n+i,c,+x-y);
		adde(2*n+3,n+i,c,-x-y);
		adde(n+i,2*n+5,c,0);
	}
	cout<<-sol(2*n+4,2*n+5)<<endl;
}

Measured memory_bytes: 1168
a,b,c,d = gets.chomp.chars
 
['+','-'].repeated_permutation(3) do |op1,op2,op3|
    e = a+op1+b+op2+c+op3+d
    x = eval(e)
    if x == 7
        puts "#{e}=7"
        exit
    end
end
puts "hoge"

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

int main() {
    int N;
    cin >> N;
    vector<int> A(N), cnt(N, 0);
    for (int i; i < N; i++) {
        cin >> A.at(i);
    }
    for (int i; i < N; i++) {
        while (A.at(i) % 2 == 0) {
            A.at(i) /= 2;
            cnt.at(i) += 1;
        }
    }
    sort(cnt.begin(), cnt.end());
    cout << cnt.at(0) << endl;
}

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

public class Main{
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String str=sc.next();
		
		char[] arr=str.toCharArray();
		int[] nums=new int[4];
		for(int i=0;i<nums.length;i++) {
			nums[i]=(int)arr[i];
		}
		Arrays.sort(nums);
		if(nums[0]!=nums[3] && nums[0]==nums[1] && nums[2]==nums[3]) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
		
	}
}


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

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String s = in.readLine();
    int s_len = s.length();
    if(s.substring(0,(s_len-1)/2).equals(s.substring((s_len+1)/2,s_len))) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 24660
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n,q;
	cin>>n>>q;
	while(q--){
		int a,b;
		cin>>a>>b;
		if(n==1)cout<<min(a,b)<<endl;
		else{
			while(a!=b){
				if(a>b)a=(a+n-2)/n;
				else b=(b+n-2)/n;
			}
			cout<<a<<endl;
		}
	}
}






Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define ll long long
#define lld long double
#define MOD 1000000007
#define CAP 10000000
#define inf 1000000000000000000LL
#define pii pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define endl '\n'
#define sz(v) v.size()
#define all(v)    v.begin(),v.end()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
using namespace std;
ll power(ll x,ll y, ll md=MOD){ll res = 1;x%=md;while(y>0){if(y&1)res = (res*x)%md;x = (x*x)%md;y = y>>1;}return res%md;}
#define dbg(x) cout <<#x<<":"<<x<<endl;
 
#define int ll
 
ll min1() {return inf;}
ll max1() {return -inf;}
 
template<typename... Args>
int min1(int a, Args... args) {return min(a,min1(args...));}
template<typename... Args>
int max1(int a, Args... args) {return max(a,max1(args...));}

map<ll,ll> cnt;
unordered_map<ll,ll> res;

ll fen[101][64000];

void update(ll index, ll k, ll val){
	index++;
	while(index<=64000){
		fen[k][index] += val;
		index+=(index)&(-index);
	}
}

ll query(ll index, ll k){
	index++;
	ll ans = 0;
	while(index>0){
		ans+=fen[k][index];
		ans%=MOD;
		index-=(index)&(-index);
	}
	return ans%MOD;
}

signed main() {
	fast;
	
	ll n,k;
	cin>>n>>k;

	ll root = sqrt(n)+1;

	cnt[1] = n-(n/2);
	for(int i=2;i<=root;++i){
		ll temp = (n/i) - (n/(i+1));
		if(temp) cnt[i] = temp;
	}

	ll lim = n/(root+1);
	ll count = n;
	for(int i=1;i<=lim;++i){
		while(i*count>n){
			count--;
		}
		cnt[count]++;
	}

	int i = 0;
	for(map<ll,ll>::iterator it = cnt.begin(); it!=cnt.end(); ++it, ++i){
		res[i] = it->s;
	}

	ll tot = i;

	update(0,1,1);

	for(int i=2;i<=k;++i){
		for(int j=0;j<tot;j++){
			ll value = query(j,i-1);
			update(tot-j-1,i,(value*res[j])%MOD);
		}
	}

	ll ans = 0;
	for(int i=0;i<tot;++i){
		ans += (res[i]*query(i,k))%MOD;
		ans %= MOD;
	}
	ans%=MOD;
	cout<<ans;
	
}

Measured memory_bytes: 56740
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <numeric>
#include <queue>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct TEMP_OMAZINAI_ { TEMP_OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } TEMP__omazinai_instance__;
#define INF ((1LL<<61) + (1<<29))
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
ll my_gcd(ll a, ll b) { return b ? my_gcd(b, a%b) : a; };
void TEMP_INPUT_IMPL_() {};
template <class T, class... Args> void TEMP_INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; TEMP_INPUT_IMPL_(args...); }
void TEMP_OUTPUT_IMPL_() {};
template <class T, class... Args> void TEMP_OUTPUT_IMPL_(T dest, Args... args) { cout << dest << (sizeof...(Args) ? " " : ""); TEMP_OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; TEMP_INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define unique_v(v) v.erase(std::unique(v.begin(), v.end()), v.end()) //必ずソート後に実行
#define out(...) (TEMP_OUTPUT_IMPL_(__VA_ARGS__), std::cout<<std::endl)
#define set_fix(x) ((std::cerr<<std::fixed<<std::setprecision(x)),(std::cout<<std::fixed<<std::setprecision(x)))
//小さい方に寄る
#define space_op(x, y, a, b, c) ([](auto x_, auto y_, auto a_, auto b_, auto c_){if(x_<y_)return a_;if(x_>y_)return c_;return b_;}(x,y,a,b,c))
#define space_out(x, y, a, b, c) out(space_op(x, y, a, b, c))

// ^^^ Template ^^^ //


int main() {
	in(ll, A, B, K);
	loop(i, K) {
		if (i & 1) {
			B /= 2;
			A += B;
		} else {
			//begin
			A /= 2;
			B += A;
		}
	}
	out(A, B);
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include <sstream>
#include <iostream>
#include <cstdlib>
 
using namespace std;
 
#define BUF_SIZE 1024
#define ARRAY_SIZE 100
 
int main(){
 
    char buf[BUF_SIZE] = {0};
    int n = atoi(fgets(buf,BUF_SIZE,stdin));
 
    int array[ARRAY_SIZE] = {0};
 
    for(int i = 0; i < n; i++){
        cin >> array[i];
    }
 
    for(int k = 0;k < n; k++){
        if(k != n-1){
            printf("%d ",array[k]);
        }else{
            printf("%d\n",array[k]);
        }
    }
 
    int v = 0;
    int j = 0;
    for(int i = 1; i < n; i++){
        v = array[i];
        j = i-1;
        while(j >= 0 && array[j] > v){
            array[j+1] = array[j];
            j--;
        }
        array[j+1] = v;
        for(int k = 0;k < n; k++){
            if(k != n-1){
                printf("%d ",array[k]);
            }else{
                printf("%d\n",array[k]);
            }
        }
    }
 
}


Measured memory_bytes: 3140
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const double PI=3.141592653589;
const ll INF=1000000007;
const ll LMAX=1000000000000001;
ll gcd(ll a,ll b){if(a<b)swap(a,b);ll c=a%b;while(c!=0){a=b;b=c;c=a%b;}return b;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};


int main(){
  int n; cin>>n;
  map<string,int> mp;
  rep(i,n){
    string s; cin>>s;
    mp[s]++;
  }
  int k=-1;
  for(auto it=mp.begin();it!=mp.end();it++){
    k=max(k,it->sc);
  }
  for(auto it=mp.begin();it!=mp.end();it++){
  if(it->sc==k)
  cout<<it->fs<<endl;
}


  return 0;
}


Measured memory_bytes: 25216
#include <iostream>
#include <vector>
#include <stdio.h>

using namespace std;

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

  int b1 = 0, b0 = 0;
  for (char ch : in) {
    if (ch == '0') b0 ++;
    if (ch == '1') b1 ++;
  }
  printf("%d\n", 2 * min(b0, b1));

}


Measured memory_bytes: 512
A,B,C,D = input()

#print(A,B,C,D)

for i in range(2**3):
    ls=["+","+","+"]
    for j in range(3):
        if (i>>j)&1:
            ls[j]="-"
    #print(ls)
        
    if eval(A+ls[0]+B+ls[1]+C+ls[2]+D)==7:
        print(A+ls[0]+B+ls[1]+C+ls[2]+D+"=7")
        break

Measured memory_bytes: 3064
n = int(input())
lst = list(map(int,input().split()))
ans = [0] * n
if n == 1:
    print(lst[0] * 2)
else:
    ans[0] = ans[1] = lst[0]
    for i in range(1,n-1):
        ans[i+1] = lst[i]
        if ans[i] > lst[i]:
            ans[i] = lst[i]
    print(sum(ans))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int n,m;
struct mm
{
	int x;
	int y;	
}a[100005];
mm b[100005];
int sum[100005];
int main()
{
	cin>>n>>m;
	for(int i=1;i<=n;i++)
	{
		cin>>a[i].x>>a[i].y;
	}
	for(int j=1;j<=m;j++)
	{
		cin>>b[j].x>>b[j].y;
	}
	for(int i=1;i<=n;i++)
	{
		int maxx=1<<30;
		for(int j=1;j<=m;j++)
		{
			if((abs(a[i].x-b[j].x)+abs(a[i].y-b[j].y))<maxx)
			{
				maxx=abs(a[i].x-b[j].x)+abs(a[i].y-b[j].y);
				sum[i]=j;
			}
			
		}
		cout<<sum[i]<<endl;
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
n , k = map(int,input().split())
s = input()
if s[k-1] == "A":
    print(s[:k-1] + "a" +s[k:])
elif s[k-1] == "B":
    print(s[:k-1] + "b" +s[k:])
elif s[k-1] == "C":
    print(s[:k-1] + "c" +s[k:])

Measured memory_bytes: 3060
/// Code By t_bone_289 (Tushar Singh)
/// An Immature Programmer.... I'm still developing !!
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define endl '\n'
#define M 1000000007
#define error(x) cout << #x << " = " << x << endl;
#define pi 3.14159265358979323846
typedef long long ll;
typedef double d;
typedef long double ld;
template <typename T>
void ContainerError(T &v){cout<<"{";for(auto &x:v){cout<<x<<',';}cout<<"}"<<endl;return;}
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}
ll mpow(ll base,ll exp){ll res=1;while(exp>0){if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return (res);}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll Count(ll n)
{
    ll x = 0;
    while(n)
    {
        n=n/10;
        x++;
    }
    return x;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin>>n;
    ll c=0;
    for(ll i=1;i<=n;i++)
    {
        if(Count(i)&1)
        {
            c++;
        }
    }
    cout<<c;
    return 0;
}



Measured memory_bytes: 256
using System;
using System.Linq;

public class AtCoder_159_A
{
    public static void Main()
    {
        int[] line1 = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
        int n = line1[0];
        int m = line1[1];

        Console.WriteLine(n * (n - 1) / 2 + m * (m - 1) / 2);
    }
}


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

int main(){
  int a,b,R;
  cin >> a >> b;
  R = a * b;
  
  if  (R%2 == 0 ){
    cout << "Even" << endl;
  }
  
  else{
    cout << "Odd" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_set>
using namespace std;
#define ll long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repeat(i,s,n) for(int (i)=s; (i)<(n); (i)++)
#define revrep(i,n) for(int (i)=(n)-1;i>=0; i--)

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<setprecision(std::numeric_limits<float>::max_digits10);
  cout<<fixed;
  int n;
  cin>>n;
  vector<int> h(n);
  rep(i,n)cin>>h[i];
  revrep(i,n-1) {
    if(h[i]>h[i+1]) {
      if(h[i]-1<=h[i+1]) {
	h[i]--;
      } else {
	cout << "No" << endl;
	return 0;
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n - 1); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
using namespace std;
using P = pair<int, int>;
typedef long long ll;

int main() {
  vector<ll> a(3);
  bool even = false;
  rep(i, 3){
    cin >> a[i];
    if (a[i] % 2 == 0)even = true;
  }
  sort(ALL(a));
  if (even)cout << 0 << endl;
  else cout << a[0] * a[1] << endl;
}

Measured memory_bytes: 3628
#pragma GCC optimize(2)
#include<bits/stdc++.h>
#define ll long long
#define maxn 200005
#define inf 1e9
#define eps 1e-10
using namespace std;

inline int read()
{
	int x=0,w=1; char c=getchar();
	while(c<'0'||c>'9') {if(c=='-') w=-1; c=getchar();}
	while(c<='9'&&c>='0') {x=(x<<1)+(x<<3)+c-'0'; c=getchar();}
	return w==1?x:-x;
}

ll a,b;

int main()
{
	cin>>a>>b;
	if(500*a>=b) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <vector>
#include <climits>

using namespace std;

typedef signed long long ll;

int main(void)
{
    int N = 0;

    cin >> N;

    vector<int> A(N, 0);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
        if (i > 0)
        {
            cout << " ";
        }
        cout << A[i];
    }
    cout << endl;

    for (int i = 1; i < N; i++)
    {
        int value = A[i];
        int j = i - 1;
        while (j >= 0 && A[j] > value)
        {
            A[j + 1] = A[j];
            j--;
        }
        A[j + 1] = value;
        for (int k = 0; k < N; k++)
        {
            if (k > 0)
            {
                cout << " ";
            }
            cout << A[k];
        }
        cout << endl;
    }

    return 0;
}

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

#define ff first
#define ss second
#define mp make_pair

using namespace std;

typedef long long ll;

vector<int> G[100005];
int dp[100005];
bool mark[100005];

int f(int v) {
	if(G[v].size() == 0) return 0;
	if(mark[v]) return dp[v];
	mark[v] = 1;
	int ret = 0;
	for(int x : G[v])
		ret = max(ret, f(x)+1);
	return dp[v] = ret;
}

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

	while(m--) {
		int a,b;
		scanf("%d%d", &a, &b);
		G[a].push_back(b);
	}

	int ans = 0;
	for(int i = 1; i <= n; i++)
		ans = max(ans, f(i));

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

    return 0;
}

Measured memory_bytes: 8192
#include<stdio.h>
#define M 10

main(){
  int i, first=0, second=0, third=0, data[M];

  for(i=0; i<M; i++){
    scanf("%d", &data[i]);
    if(data[i] > first){
      third = second;
      second = first;
      first = data[i];
    }else if(data[i] > second){
      third = second;
      second = data[i];
    }else if(data[i] > third){
      third = data[i];
    }
  }

  printf("%d\n%d\n%d\n", first, second, third);
  return 0;
}

Measured memory_bytes: 0
/*input
abcdefghijklmnopqrstuvwxyz
*/
#include <bits/stdc++.h>
#define up(i,a,b) for(int (i) = (a);(i)<=(b);++(i))
#define down(i,b,a) for(int (i) = (b);i>=(a);--i)
#define debug(x) cerr << (x) << '\n';
#define bits(x,i) ((x >> i) & 1)
#define mid ((l+r)/2)
#define pr pair<int,int>
using namespace std;
const int N = 200005;
const int INF = 1e9;
string s;
int nxt[N][30];
int dp[N];
int n;
void init(){
	n = s.size();
	for(int i=0;i<='z'-'a';++i) nxt[n][i] = n;
	for (int i=n-1;i>=0;--i){
		for (char c = 'a' ; c<= 'z'; ++c){
			if (c == s[i]) nxt[i][c - 'a'] = i;
			else nxt[i][c-'a'] = nxt[i+1][c-'a'];
		}
	}
}
string solve(){
	dp[n] = 1;
	for(int i=n-1;i>=0;--i){
		dp[i] = INF;
		for(int j=0;j<='z'-'a';++j){
			dp[i] = min(dp[nxt[i][j]+1] + 1, dp[i]);
		}
	}
	int curPos = 0;
	string ans;
	while (curPos < n){
		for(int j=0;j<='z'-'a';++j){
			if (dp[curPos] == dp[nxt[curPos][j] + 1] + 1){
				ans += (j + 'a');
				curPos = nxt[curPos][j] + 1;
				break;
			}
		}
	}
	return ans;
}
int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	// for(char c = 'a'; c<= 'z';++c) cout << c; cout << '\n';
	cin >> s;
	init();
	cout << solve();
}

Measured memory_bytes: 27976
k, n = map(int, input().split())
a = list(map(int, input().split())) # list()でリスト化、それを変数に代入。
sa = 0

for i in range(n-1):
    sa = max(sa, a[i+1]-a[i])

sa = max(sa, a[0]+k-a[-1])

print(k-sa)


Measured memory_bytes: 26436
from heapq import heappush,heappop,heapify
from collections import deque,defaultdict,Counter
from itertools import permutations,combinations,groupby
import sys,bisect,string,math,time,functools,random
def Golf():*a,=map(int,open(0))
def I():return int(input())
def S_():return input()
def IS():return input().split()
def LS():return [i for i in input().split()]
def LI():return [int(i) for i in input().split()]
def LI_():return [int(i)-1 for i in input().split()]
def NI(n):return [int(input()) for i in range(n)]
def NI_(n):return [int(input())-1 for i in range(n)]
def StoLI():return [ord(i)-97 for i in input()]
def ItoS(n):return chr(n+97)
def LtoS(ls):return ''.join([chr(i+97) for i in ls])
def GI(V,E,Directed=False,index=0):
    org_inp=[];g=[[] for i in range(n)]
    for i in range(E):
        inp=LI();org_inp.append(inp)
        if index==0:inp[0]-=1;inp[1]-=1
        if len(inp)==2:
            a,b=inp;g[a].append(b)
            if not Directed:g[b].append(a)
        elif len(inp)==3:
            a,b,c=inp;aa=(inp[0],inp[2]);bb=(inp[1],inp[2]);g[a].append(bb)
            if not Directed:g[b].append(aa)
    return g,org_inp
def GGI(h,w,boundary=1,search=[],replacement_of_found='.',mp_def={'#':1,'.':0}):
#h,w,g,sg=GGI(h,w,boundary=1,search=['S','G'],replacement_of_found='.',mp_def={'#':1,'.':0}) # sample usage
    mp=[boundary]*(w+2);found={}
    for i in range(h):
        s=input()
        for char in search:
            if char in s:
                found[char]=((i+1)*(w+2)+s.index(char)+1)
                mp_def[char]=mp_def[replacement_of_found]
        mp+=[boundary]+[mp_def[j] for j in s]+[boundary]
    mp+=[boundary]*(w+2)
    return h+2,w+2,mp,found
def TI(n):return GI(n,n-1)
def bit_combination(k,n=2):return [[tb//(n**bt)%n for bt in range(k)] for tb in range(n**k)]
def show(*inp,end='\n'):
    if show_flg:print(*inp,end=end)
def show2d(g,h,w):
    for i in range(h):show(g[i*w:i*w+w])

YN=['YES','NO'];Yn=['Yes','No']
mo=10**9+7
inf=float('inf')
l_alp=string.ascii_lowercase
#sys.setrecursionlimit(10**7)
input=lambda: sys.stdin.readline().rstrip()

def ran_input():
    n=random.randint(4,16)
    rmin,rmax=1,10
    a=[random.randint(rmin,rmax) for _ in range(n)]
    return n,a

show_flg=False
show_flg=True

ans=0



x,y,z=LI()
ans=z,x,y
    
print(*ans)


    
    

Measured memory_bytes: 39276
def insertionSort(A, N):
    print(' '.join([str(i) for i in A]))
    for i in range(1, N):
        # print(' '.join([str(i) for i in A]))
        v = A[i]
        j = i - 1
        while j >= 0 and A[j] > v:
            A[j + 1] = A[j]
            j -= 1
        A[j + 1] = v
        print(' '.join([str(i) for i in A]))
        

if __name__ == "__main__":
    N = int(input())
    A = [int(i) for i in input().strip().split()]
    insertionSort(A, N)


Measured memory_bytes: 5604
#include <iostream>
using namespace std;
int main(){
    int d,n,num=1,ans; cin>>d>>n;
    for (int i=0; i<d; i++) num *= 100;
    if (num==1){
        if (n==100) ans = n+1;
        else ans = n;
    }
    else {
        if (n==100) ans = num*(n+1);
        else ans = num*n;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import Data.List
main = do
  getLine
  as <- map read . words <$> getLine :: IO [Int]
  print $ if check as then solve (length as `div` 2) else 0
  
check :: [Int] -> Bool
check xs
  | even $ length xs =
      all (even . length) (group $ sort xs)
  | otherwise =
      (length (filter (==0) xs) == 1) && (all (even . length) (group $ sort $ delete 0 xs))

solve :: Int -> Int
solve 0 = 1
solve 1 = 2 `mod` (10^9+7)
solve n = 2 * solve (n-1) `mod` (10^9+7)

Measured memory_bytes: 46460
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
constexpr int MOD = 1000000007;
constexpr int INF = numeric_limits<int>::max() / 2;
typedef pair<int,int> P;
using Graph = vector<vector<int>>;
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; }
const double PI = acos(-1.0);
// cout << fixed << setprecision(14);

int Fe[100010];
int Sn[100010];

void dfs1(const Graph &G, int v, int p, int num){
    Fe[v] = num;
    for(auto e : G[v]){
        if(p == e) continue;
        dfs1(G, e, v, num+1);
    }
}

void dfs2(const Graph &G, int v, int p, int num){
    Sn[v] = num;
    for(auto e : G[v]){
        if(p == e) continue;
        dfs2(G, e, v, num+1);
    }
}
 
signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);

    int N;
    cin >> N;
    Graph G(N);
    rep(i,N-1){
        int a, b;
        cin >> a >> b;
        --a; --b;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    dfs1(G, 0, -1, 0);
    dfs2(G, N-1, -1, 0);
    int ans = 0;
    rep(i,N){
        if(Fe[i]-Sn[i]<=0) ans++;
        else --ans;
    }
    if(ans <= 0) cout << "Snuke" << endl;
    else cout << "Fennec" << endl;
}

Measured memory_bytes: 13568
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
using i64 = int64_t;
using ll = long long;
int main() {
  ll N;
  string S;
  cin >> N >> S;
  ll R_count = 0;
  rep(i,N){
    if(S.at(i) == 'R') R_count ++;
  }
  ll ans = 0;
  rep(i,R_count){
    if(S.at(i) == 'W') ans ++;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

typedef long long ll;

const double pi = 3.14159265358979323846;

#define rep(i, n) for (ll i = 0; i < n; i++)
#define mod 1000000007LL
#define PS(p) cout << setprecision(15) << fixed << p << endl;
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
#define ALL(c) c.begin(), c.end()

int main() {
  int N, M;

  map< int, int > m;

  cin >> N >> M;
  for (int i = 1; i <= M; i++) {
    m[i] = 0;
  }

  int K;
  int A;

  int maxA = 0;
  for (int i = 0; i < N; i++) {
    cin >> K;

    for (int j = 0; j < K; j++) {
      cin >> A;
      m[A]++;

      maxA = max(m[A], maxA);
    }
  }

  if (maxA != N) {
    cout << 0 << endl;
    return 0;
  }

  int count = 0;
  for (auto k : m) {
    if (k.second == maxA) {
      count++;
    }
  }

  cout << count << endl;

  return 0;
}


Measured memory_bytes: 256
class BinaryIndexedTree():  #1-indexed
    def __init__(self, n):
        self.n = n
        self.tree = [0 for _ in range(n + 1)]

    def sum(self, index):
        res = 0
        while index:
            res += self.tree[index]
            index -= index & -index
        return res

    def add(self, index, x):
        while index <= self.n:
            self.tree[index] += x
            index += index & -index

    def bisect_left(self, x):
        if x <= 0: return 0
        res, tmp = 0, 2**((self.n).bit_length() - 1)
        while tmp:
            if res + tmp <= self.n and self.tree[res + tmp] < x:
                x -= self.tree[res + tmp]
                res += tmp
            tmp >>= 1
        return res + 1


N, K = map(int, input().split())
P = list(map(lambda x: int(x) + 1, input().split()))

bit = BinaryIndexedTree(N + 1)
count = 1

for i in range(K):
    bit.add(P[i], 1)

for i in range(N - K):
    mi = bit.bisect_left(1)
    ma = bit.bisect_left(K)
    if P[i] != mi or P[K + i] < ma:
        count += 1
    bit.add(P[i], -1)
    bit.add(P[K + i], 1)

inc = 1
incseq = 0

for i in range(N - 1):
    if P[i] < P[i + 1]:
        inc += 1
        if inc == K:
            incseq += 1
    else:
        inc = 1

print(count - max(0, incseq - 1))

Measured memory_bytes: 86224
#include<bits/stdc++.h>
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[6] = {1, 0, -1, 0,1,1};
const int dy[6] = {0, 1, 0, -1,1,-1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
// ---------------------------------------------------------------------------

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N;
    cin >> N;
    while(N != 0){
        set<int> taro;
        for(int i=0; i<N; i++){
            int a;
            cin >> a;
            taro.insert(a);
        }
        set<int> hanako;
        for(int i=1; i<=2*N; i++){
            if(!taro.count(i)){
                hanako.insert(i);
            }
        }
        bool fst = true;
        int now = 0;
        while(1){
            bool did = false;
            if(fst){
                for(auto s: taro){
                    if(now <= s){
                        now = s;
                        taro.erase(s);
                        did = true;
                        break;
                    }
                }
                if(taro.size() == 0) break;
                if(!did) now = 0;
                fst = false;
            }else{
                for(auto s: hanako){
                    if(now <= s){
                        hanako.erase(s);
                        now = s;
                        did = true;
                        break;
                    }
                }
                if(hanako.size() == 0) break;
                if(!did) now = 0;
                fst = true;
            }
        }
        cout << hanako.size() << enld;
        cout << taro.size() << enld;
        cin >> N;
    }
    return 0;
}



Measured memory_bytes: 3104
#include <iostream>
#include <numeric>
#include <cmath>
#include <limits>
#include <stdio.h>
#include <iomanip>
#include <cstdlib>
#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
using namespace std;
using ll = long long;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
ll Max(ll(a), ll(b), ll(c)) {
	return max(max(a, b), c);
}
ll Min(ll(a), ll(b), ll(c)) {
	return min(min(a, b), c);
}





int main() {
	string S, T,L;
	cin >> S >> T;
	rep(i, S.size()) {
		L = S.substr(i, (S.size() - i)) + S.substr(0, i);
		if (L == T) {
			cout << "Yes" << endl; return 0;
		}
	}
	cout << "No" << endl;
}

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

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<(int)n ; i++)
#define rf(i,n,a) for(int i=n ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define d1(a) cout << a << "\n"
#define d2(a,b) cout << a << " " << b << "\n"
#define d3(a,b,c) cout << a << " " << b << " " << c << "\n"
#define d4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << "\n"
#define fast ios:: sync_with_stdio(false),cin.tie(nullptr);

typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;
const int N = 1e5 + 5;
int dp[N+1];

int32_t main(){
   fast;
   fill(dp , dp + N + 1 , inf64);
   int n,W;
   cin >> n >> W;
   dp[0] = 0;
   for(int i=0 ; i<n ; i++){
      int w,v;
      cin >> w >> v;
      for(int j=N ; j>=v ; j--){
         dp[j] = min(dp[j] , dp[j - v] + w);
      }      
   }
   int ans = 0;
   for(int i=1 ; i<=N ; i++){
      if(dp[i] <= W){
         ans = i;
      }
   }
   cout << ans << "\n";
}

Measured memory_bytes: 1024