akhauriyash/Code-Regression huggingface dataset:
// ABC 49 C

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

typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const long long INF = 1LL<<60;

int main()
{
  int n;
  cin >> n;
  int pt = 0;
  int px = 0;
  int py = 0;
  rep(i, n) {
    int t, x, y;
    cin >> t >> x >> y;
    int yk = (abs(px - x) + abs(py - y));
    int dt = abs(pt - t);

    if (yk > dt || yk % 2 != dt % 2) {
      cout << "No" << endl;
      return 0;
    }
    pt = t; px = x; py = y;
  }
  cout << "Yes" << endl;
  return 0;
}


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

vector<int> f(int n) {
  vector<int> res(30);
  for (int i = 0; i < 30; i++) {
    res[i] = (n >> i) & 1;
  }
  return res;
}

int main() {
  int n, k; cin >> n >> k;
  auto K = f(k);
  vector<ll> sum(30);
  ll res = 0;
  for (int i = 0; i < n; i++) {
    int x, y; cin >> x >> y; auto X = f(x);
    if (k == (k | x)) res += y;
    for (int i = 29; i >= 0; i--) {
      if (!K[i] && X[i]) break;
      if (K[i] && !X[i]) {
        sum[i] += y;
      }
    }
  }
  cout << max(res, *max_element(sum.begin(), sum.end())) << endl;
}

Measured memory_bytes: 256
fun main() {
    val input: List<Long> = readLine()!!.split(" ").map { it.toLong() }
    val allcolum=input[0]+1-input[1]+1
    var ans=0L
    for (i in 0 until allcolum){
        ans+=((input[0]-(input[1]+i)+1)*(input[1]+i)+1)
    }
    println(ans%1000000007)
}

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

int a[110],b[110];

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

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

    bool ans=true;

    for(int i=n-1;i>=0;i--)
    {
        int pos=i+1;
        for(int j=n-1;j>=0;j--)
        {
            if(b[j]==pos)
            {
                a[i]=b[j];
                b[j]=0;
                break;
            }
            else if(b[j]!=0)pos--;
        }
        if(pos==0){ans=false;break;}
    }

    if(ans)for(int i=0;i<n;i++)cout<<a[i]<<"\n";
    else cout<<-1<<"\n";

    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ll long long

using namespace std;

const int N = 4e3 + 5, oo = 1e9;

char s[N];
string c = "RGB";
int sum[3][N];

int main()
{
    ll n, ans = 0;
    scanf("%lld\n%s", &n, s);
    for(int i = 0 ; i < n ; i++)
    {
        sum[c.find(s[i])][i]++;
        for(int j = 0 ; j < 3 ; j++)
        {
            if(i) sum[j][i] += sum[j][i - 1];
        }
    }
    for(int i = 0 ; i < n ; i++)
    {
        for(int j = i + 2 ; j < n ; j++)
        {
            if(s[i] == s[j]) continue;
            for(int k = 0 ; k < 3 ; k++)
            {
                if(c[k] == s[i] or c[k] == s[j]) continue;
                ans += (sum[k][j] - sum[k][i]);
                if((j - i) % 2 == 0)
                {
                    if(s[i + (j - i) / 2] == c[k]) ans--;
                }
            }
        }
    }
    printf("%lld\n", ans);
    return 0;
}


Measured memory_bytes: 3792
#include <iostream>

using namespace std;

typedef long long ll;

int main(int argc, char *argv[])
{
	ll N;
	ll A[100005];

	cin >> N;

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

	int m = 1;
	ll R = 0;
	for (int i = 0; i < N; i++) {
		R += A[i] * m;
		m = -m;
	}
	printf("%lld ", R);
	for (int i = 0; i < N - 1; i++) {
		R = (A[i] - (R / 2)) * 2;
		printf("%lld ", R);
	}
	puts("");

	return 0;
}


Measured memory_bytes: 2176
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<math.h>
#include<stdio.h>
#include<string.h>
#include<iostream>
#include<algorithm>
using namespace std;
const int P=139;
const int mod=149;
const int maxn=1e6+5;
typedef long long ll;
const int inf=0x3f3f3f3f;
const int minn=0xc0c0c0c0;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll a,b,c,d;
    cin>>a>>b>>c>>d;
    ll x=max(a*c,b*d);
    ll y=max(a*d,b*c);
    cout<<max(x,y)<<endl;;
    return 0;
}

Measured memory_bytes: 3648
// dile a la jardinera que traigo flores

#include <bits/stdc++.h>
#define ff first
#define ss second
#define pb push_back
#define sz(x) int(x.size())
#define all(v) (v).begin(),(v).end()
#define trace(x) cout << #x << " = " << x << endl
#define fastio ios_base::sync_with_stdio(0);cin.tie(0)
#define FER(i,a,b) for(int i = int(a); i < int(b); ++i)
#define IFR(i,a,b) for(int i = int(a); i >= int(b); i--)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> ii;



int main(){
	int x,y;cin>>x>>y;
	cout<<x+y/2<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define REP(i, a, n) for(int i = (a); i < (n); i++)
using namespace std;
typedef long long ll;

string S;
int d[80001];
ll dp[80001][2][10];

int main(void) {
  while(cin >> S, S != "0") {

    REP(i, 0, S.length()) d[i] = S[i] - '0';
    REP(i, 0, S.length() + 1) REP(j, 0, 2) REP(k, 0, 10) dp[i][j][k] = 0;

    ll ans = 0;
    for(int i = S.length() - 1; i >= 0; i--) {
      REP(j, 0, 2) REP(k, 0, 10) {
        if(k == d[i] - j && d[i] != 0) ans += dp[i + 1][j][k];
        int nj = 0, nk = d[i] - j - k;
        if(nk < 0) {
          nk += 10;
          nj = 1;
        }
        dp[i][nj][nk] += dp[i + 1][j][k];
      }
      dp[i][0][d[i]]++;
    }
    cout << ans << endl;
  }
  return 0;
}

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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define ALL(v) v.begin(),v.end()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cout<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct Edge{ll from, to, cost;};
struct node{ll cost, to;
  bool friend operator>(node a, node b){
    return a.cost>b.cost;
  }
};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N, A, B;
  cin >> N >> A >> B;
  ll ans = 0;
  ll tmp1;
  cin >> tmp1;
  rep(i, N-1){
    ll tmp2;
    cin >> tmp2;
    ans += min((tmp2 - tmp1)*A, B);
    tmp1 = tmp2;
  }

  cout << ans;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int table[500001];
int main(){
	table[1]=-1;
	table[0]=-1;
	for(int i=2;i<500001;i++){
		if(table[i]==0){
			table[i]=1;
			for(int j=i*2;j<500001;j+=i)table[j]=-1;
		}
	}
	int a;
	while(scanf("%d",&a),a){
		int ret=0;
		for(int i=1;i<=a/2;i++){
			if(table[i]==1&&table[a-i]==1)ret++;
		}
		printf("%d\n",ret);
	}
}

Measured memory_bytes: 2712
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long x ;
  cin>>x;
  long long sum=0;
  long long mon=100;
  while(mon<x) 
  {
    mon+=mon/100;
    sum++;
  }
  cout<<sum<<endl;
  return 0;
}

Measured memory_bytes: 3636
#include<iostream>
using namespace std;
int main(){
    int W,H,x,y,r;
    cin >> W >> H >> x >> y >> r;
    if(r<=x && x<=W-r && r<=y && y<=H-r){
        cout <<"Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}


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

using namespace std;

int main()
{
    int n;
    cin >> n;

    auto numberOfDaysInYear = [](int y) {
        if (y % 3 == 0) {
            return 20 * 10;
        }
        else {
            return 20 * 5 + 19 * 5;
        }
    };

    vector<int> ym(1001, 0);
    ym[1] = numberOfDaysInYear(1000 - 1);
    for (int i = 2; i < ym.size(); ++i) {
        ym[i] = numberOfDaysInYear(1000 - i) + ym[i - 1];
    }

    auto remainDays = [&numberOfDaysInYear, &ym](int y, int m, int d) {
        auto num = numberOfDaysInYear(y);
        auto days = 0;
        if (y % 3 == 0) {
            days = (10 - m) * 20 + 20 - d;
        }
        else {
            if (m % 2 == 0) {
                days = (10 - m) * 20 - ((10 - m) / 2 + 1) + 20 - d;
            }
            else {
                days = (10 - m) * 20 - ((10 - m) / 2) + 19 - d;
            }
        }

        return days + ym[1000 - y - 1] + 1;
    };

    for (int i = 0; i < n; ++i) {
        int y, m, d;
        cin >> y >> m >> d;
        cout << remainDays(y, m, d) << endl;
    }
}

Measured memory_bytes: 3112
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>

using namespace std;



int main() {

  int a, b;
  cin >> a >> b;

  int N = 15;

  if(a*b == 15) {
    cout << "*" << endl;
  }
  else if(a+b == 15) {
    cout << "+" << endl;
  }
  else {
    cout << "x" << endl;
  }


}


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

bool isPrimeNumber(int n);
int nextPrime(int n);

int main()
{
    int n;
    cin >> n;
    cout << nextPrime(n) << endl;
}

bool isPrimeNumber(int n)
{
    for(int i = 2; i < n; i++)
    {
        if(!(n % i)) return false; 
    }
    return true;
}

int nextPrime(int n)
{
    for(int i = n; ; i++)
    {
        if(isPrimeNumber(i)) return i;
    }
}

Measured memory_bytes: 256
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace AtCoder
{
    class Program
    {
        public static void Main()
        {
            string[] str = Console.ReadLine().Split(' ');
            int r = int.Parse(str[0]);
            int g = int.Parse(str[1]);
            int b = int.Parse(str[2]);

            int Num = 100 * r + 10 * g + 1 * b;
            if (Num % 4 == 0)
            {
                Console.WriteLine("YES");
            }
            else
            {
                Console.WriteLine("NO");
            }
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h> 
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
 
#define nl '\n'
 
#define y1 aza_ibagaliev
 
#define f first
#define s second
	
#define ed end()
#define bg begin()
#define rbg rbegin()
 
#define rv reverse
#define mp make_pair
#define pb push_back
#define ppb pop_back
#define ppf pop_front
 
#define sz size()
#define all(x) x.bg, x.ed
 
#define pll pair < ll, ll >
#define pii pair < int, int >
 
#define sqr(x) ((x) * 1ll * (x))
#define sqrd(x) ((x) * 1.0 * (x))
 
#define speed ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
 
#define rnl cout << "----------------------------------------" << nl
 
#define bit __builtin_popcount
 
inline ll bip(ll x, ll n, ll mod){ll res=1;while(n){if(n & 1){res=(res*x)%mod;}x=(x*x)%mod;n>>=1;}return res;}
        	
const int ppr = 257;
const ll INF = 2e18;
const int inf = 2e9;
const int mod = 1e9 + 7;
const int N = 1e6 + 123;
const ld pi = acos(-1.0);
 
const int dx[] = {1, 0, -1, 0};
const int dy[] = {0, 1, 0, -1};

string s;
bool a, b;
 
main() {             	
//  freopen(".in", "r", stdin);
//  freopen(".out", "w", stdout);
 
//	srand(time(NULL));

//	speed;

	cin >> s;

	a = b = 1;

	if(s[2] > '1' || (s[2] == '1' && s[3] > '2') || (s[2] == '0' && s[3] == '0')) a = 0;
	if(s[0] > '1' || (s[0] == '1' && s[1] > '2') || (s[0] == '0' && s[1] == '0')) b = 0;

	if(a == b) {
		cout << (a ? "AMBIGUOUS" : "NA");
	} else {
		cout << (a ? "YYMM" : "MMYY");
	}

    return 0;                                        
}

Measured memory_bytes: 256
def f(s):
    ret = 0
    n = len(s)
    for i in range(n):
        if s[i] == "W":
            ret += i
    return ret

s = list(input())
nW = s.count("W")
ans = 0
ans += f(s)
for i in range(1, nW):
    ans -= i
print(ans)

"""
BWBWBW
WBWBWB
WWBWBB
WWWBBB

先頭までの距離（i）- 何番目のWか+1
ni - 1~nW +1
"""

Measured memory_bytes: 61400
n = int(input())
a = list(map(int,input().split()))
s,temp = [],0
for i in range(n):
    temp += a[i]
    s.append(temp)
sn,mi = s[n-1],2000000001
for i in range(n-1):
    snuke = s[i]
    arai = sn-s[i]
    if abs(snuke-arai)<mi:
        mi = abs(snuke-arai)
print(mi)

Measured memory_bytes: 24824
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
#define mod 1000000007  
int main()
{  
	int n,k;
	cin>>n>>k;
	int d,i;
	int a[n];
	memset(a,0,sizeof(a));
	for(i=0;i<k;i++)
	{
		cin>>d;
		int t;
		for(int j=0;j<d;j++)
		{
			cin>>t;
			a[t-1]++;
		}
	}	
	int ans = 0;
	for(i=0;i<n;i++)
		if(a[i]==0)
			ans++;
		cout<<ans;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define all(v) v.begin(),v.end()
#define ll long long
#define pb(a) push_back(a)
#define pf(a) push_flont(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

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


Measured memory_bytes: 256
fun main(args: Array<String>){
    val input :MutableList<Int> = mutableListOf()
    repeat(5){
        input.add(readLine()!!.toInt())
    }
    val k = readLine()!!.toInt()

    for(i in 0..4){
        for(j in 0..4){
            if(Math.abs(input[i] - input[j]) > k){
                println(":(")
                return
            }
        }
    }
    println("Yay!")
}

Measured memory_bytes: 31824
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))

typedef long long int ll;

int read_int()
{
    int a;
    scanf("%d", &a);
    return a;
}

int read_lint()
{
    ll a;
    scanf("%lld", &a);
    return a;
}

int read_float()
{
    float a;
    scanf("%f", &a);
    return a;
}

int read_double()
{
    double a;
    scanf("%lf", &a);
    return a;
}

int main()
{
    int n = read_int();
    printf("%d", n % 1000 == 0 ? 0 : 1000 - n % 1000);
    return 0;
}

Measured memory_bytes: 1708
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,s,t) for(int i = s; i < t ; ++i)
#define ALL(a) a.begin(),a.end()
#define SORT(a) sort(ALL(a))
#define UNIQ(a) a.erase(unique(ALL(a)),a.end())
#define debug(a) cerr<<#a":="<<a<<endl;
#define SZ(a) (int)a.size()
using LL = long long; template<class T> using V = vector <T>; template <class T> using VV = V<V<T>>;
using ll = LL;


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

	LL N; cin >> N;
	const int INF = 1e9;
	using VI = vector<int>;
	using VVI = vector<vector<int>>;

	VI a(N);
	FOR(i, 0, N) {
		string s; cin >> s;
		int b = s.front() - 'a';
		a[i] = b;
	}
	VVI dp(N + 1, VI(2, INF));
	dp[0][0] = 0;
	dp[0][1] = 0;
	VI MinC(26, INF); // for dp : c
	FOR(i, 0, N) {
		dp[i + 1][0] = min(dp[i + 1][0], MinC[a[i]]);
		dp[i + 1][1] = min(dp[i + 1][1], dp[i][0]+1);
		dp[i + 1][0] = min(dp[i + 1][1], dp[i+1][0]);
		MinC[a[i]] = min(MinC[a[i]], dp[i + 1][0]);
	}


	LL ans = min(dp[N][0],dp[N][1]);

	cout << ans << endl;
}



Measured memory_bytes: 8724
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

int main(){
    int num = std::pow(10,5), n;
    std::cin >> n;

    std::vector<int> a(num + 2, 0);
    for(int i = 0; i < n; ++i){
        int val;
        std::cin >> val;
        ++a.at(val + 1);
    }

    int ans = 0;
    for(int i = 1; i <= num; ++i){
        ans = std::max(ans, a.at(i - 1) + a.at(i) + a.at(i + 1));
    }

    std::cout << ans << std::endl;

    return 0;
}

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

using namespace std;
#define all(a)a.begin(),a.end()
const int INF = 1<<30;
const int mod= int(1e9)+7;

int main(){
    while(1){
       int n,r;cin >>n>>r;
       if(n==0&&r==0)break;
       vector<int>card(n);
        for (int i = 0; i < n; ++i) {
            card[i]=n-i;
        }
//        for (int j = 0; j < n; ++j) {
//            cout <<card[j]<<" ";
//        }cout <<endl;
        for (int i = 0; i < r; ++i) {
            int p,c;cin >>p>>c;
            vector<int>b;
            for (int j =0; j <c; ++j) {
                b.push_back(card[j+p-1]);
            }
            for (int j = p-2; j>=0; --j) {
                card[j+c]=card[j];
            }
//            for (int j = 0; j < n; ++j) {
//                  cout <<card[j]<<" ";
//            }cout <<endl;
            for (int j = 0; j < c; ++j) {
                card[j]=b[j];
            }
//            for (int j = 0; j < n; ++j) {
//                cout <<card[j]<<" ";
//            }
//            cout <<endl;
        }
        cout <<card[0]<<endl;
    }
}



Measured memory_bytes: 3144
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i=0; i<(n); i++)
struct node{
  ll key;
  node *parent, *left, *right;
};

node *root;
node* treeSearch(ll x){
	node* u = root;
	while (u != NULL){
		if (u->key == x) return u;
		else if (u->key < x){
			u = u->right;
		}
		else u = u->left;
	}
	return NULL;
}
node* get_right_min(node* u){
	while(u->left != NULL)u = u->left;
	return u;
}

node* getSuccessor(node *u){
  if(u->right != NULL) return get_right_min(u->right);
  node *p = u->parent;
  while(p != NULL && p->right == u){
    u = p;
    p = p->parent;
  }
  return p;
}
void treeDelete(node* u){
	node* target;
	node* child = NULL;
	
	  // 削除対象ノードを決める
  // 子ノードが無い or 1個だけの場合, 削除対象ノードはuそのもの
  // 子が２つある場合, uの右部分木のうち最小要素をuと入れ替え、uを削除する
  	if(u->left == NULL || u->right == NULL){ // 子ノードがない or 1個
    	target = u;
	}
  	else target = getSuccessor(u);
  // 削除対象ノードの子ノードを求める、この時点で削除対象ノードの子は１つか無し
  if(target->left != NULL){
    child = target->left;
  }
  else{
    child = target->right;
  }
  // 子ノードがある場合, 子ノードの親ノードを削除対象ノードの親ノードにする
  if(child != NULL){
    child->parent = target->parent;
  }
  // 左 or 右のノードに子ノードを格納
  if(target->parent == NULL){
    root = child;    
  }else{
    if(target == target->parent->left){
      target->parent->left = child;
    }else{
      target->parent->right = child;
    }
  }
  //子が二つある場合、値を移動
  if(target != u) u->key = target->key;
  free(target); //malloc関数でメモリを確保したので、free関数で解放して削除
}
void insert(ll x){
  node *root_tmp = root;//比較対象に使うノード
  node *elem;

  elem = (node *)malloc(sizeof(node));
  elem->key = x;//入れたいノード
  elem->left = NULL;
  elem->right = NULL;
  
  node *prev = NULL;//後で親にするノード

  while(root_tmp != NULL){
    prev = root_tmp;
    if(elem->key < root_tmp->key){
      root_tmp = root_tmp->left;
    }else{
      root_tmp = root_tmp->right;
    }
  }

  elem->parent = prev;

  if(elem->parent == NULL){
    root = elem;
  }else{
    if(elem->parent->key < elem->key){
      elem->parent->right = elem;
    }else{
      elem->parent->left = elem;
    }
  }
}
// 先行巡回
void preorder(node *u){
  if(u == NULL) return; 
  cout << " " << u->key;
  preorder(u->left);
  preorder(u->right);
}

// 中間巡回
void inorder(node *u){
  if(u == NULL) return; 
  inorder(u->left);
  cout << " " << u->key;
  inorder(u->right);
}

signed main(){
  int n;
  string command;
  ll elem;

  cin >> n;
  rep(i, n){
    cin >> command;
    if(command == "insert"){
      cin >> elem;
      insert(elem);
    }else if(command == "find"){
      cin >> elem;
      if(treeSearch(elem)!=NULL) cout << "yes" << endl;
      else cout << "no" << endl;
    }else if(command == "delete"){
      cin >> elem;
      treeDelete(treeSearch(elem));
    }else{
      inorder(root);
      cout << "\n";
      preorder(root);
      cout << "\n";
    }
  }
}


Measured memory_bytes: 21856
N, K, C = map(int, input().split())
S = input()

l = [0]*K
i = 0
for j in range(K):
    while S[i] == "x":
        i += 1
    l[j] = i
    i += C+1

r = [0]*K
i = N-1
for j in range(K-1, -1, -1):
    while S[i] == "x":
        i -= 1
    r[j] = i
    i -= C+1
# print(l, r)
[print(l_i+1) for l_i, r_i in zip(l, r) if l_i == r_i]



Measured memory_bytes: 26548
#include <iomanip>
#include <random>
#include <time.h>
#include <vector>
#include <queue>
#include <functional>
#include <map>
#include <string>
#include <cstdlib>
#include <typeinfo>
#include <math.h>
#include <algorithm>
#include <iostream>
#include <list>
#include <stack>
#include <set>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
using namespace std;
int main() {
	string a, b, A[110], B[110];
	cin >> a >> b;
	for (int i = 0; i < a.size(); i++) {
		A[i] = a[i];
	}
	for (int i = 0; i < b.size(); i++) {
		B[i] = b[i];
	}
	sort(A, A + a.size());
	sort(B, B + b.size());
	for (int i = 1; i < a.size(); i++) {
		A[0] += A[i];
	}
	for (int i = 1; i < b.size(); i++) {
		B[0] += B[i];
	}
	reverse(B[0].begin(), B[0].end());
	if (A[0] < B[0])cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
def gcd(a,b)
    return a if b == 0
    gcd(b,a%b)
end

def lcm(a,b)
    a * b / gcd(a,b)
end

n,m=gets.chomp.split.map(&:to_i)
s=gets.chomp.split("")
t=gets.chomp.split("")

ss={}
tt={}
l = lcm(n,m)
0.upto(s.size-1) do |i|
    ss[i*l/s.size]  = i
end
0.upto(t.size-1) do |i|
    tt[i*l/t.size] = i
end


ss.each do |k, v|
    if tt.has_key?(k)
        if s[ss[k]] != t[tt[k]]
            puts -1
            exit
        end
    end
end
puts l


Measured memory_bytes: 21372
#include <bits/stdc++.h>
using namespace std;
int n,ans,a[1010],tmp[3];
int main(){
	cin>>n;
	for(int i=1;i<=n;++i){
		cin>>a[i];
	}
	for(int i=1;i<=n;++i)
	{	
		for(int j=i+1;j<=n;++j){
			for(int k=j+1;k<=n;++k){
				tmp[1]=a[i];
				tmp[2]=a[j];
				tmp[3]=a[k];
				sort(tmp+1,tmp+3+1);
				if(a[i]!=a[j]&&a[i]!=a[k]&&a[j]!=a[k]&&tmp[1]+tmp[2]>tmp[3])
					ans++;
			}
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
typedef pair<int, double> Pid;
typedef pair<double, int> Pdi;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<int, pair<int, int>> PP;
typedef pair<P, int> PPi;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define chadd(x, y) x = (x + y) % mod

ll __pow(ll x, ll n){
    ll res = 1;
    while(n){
        if(n & 1)   res *= x;
        x *= x;
        n >>= 1;
    }
    return res;
}

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

    ll n, p;
    cin >> n >> p;
    map<ll, ll> mp;
    for(ll i = 2; i * i <= p; ++i){
        while(p % i == 0){
            ++mp[i];
            p /= i;
        }
    }
    if(p != 1)  ++mp[p];
    ll ans = 1;
    for(auto it : mp)   ans *= __pow(it.first, it.second / n);
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <fstream>

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

int n, k;

const int MAX = 2000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


int main() {

    COMinit();

    cin >> n >> k;

    REP(i, k) {
        ll tmp = (COM(k - 1, i) * COM(n - k + 1, i + 1)) % MOD;
        cout << tmp << endl;
    }


    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm>
using namespace std;
#define ll long long
#define maxn 0x3f3f3f3f
int main()
{
    int n,k;
    ll ans=1;
    scanf("%d%d",&n,&k);
    for(int i=0;i<n;i++)
    {
        ans=min(ans*2,ans+k);
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;

int main(void){
	string s;
	cin >> s;
	int count = 0;
	for(int i=0;i<s.length();i++){
		if(s.at(i) == '1'){
			count++;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 256
var
  a:array[1..87] of int64;
  n,i:longint;
begin
  readln(n);
  a[1]:=2;
  a[2]:=1;
  for i:=3 to n+1 do a[i]:=a[i-1]+a[i-2];
  writeln(a[n+1]);
end.

Measured memory_bytes: 128
#include<stdio.h>
int a[100001];
int main(void)
{
	int n,k,sum,max=0,i,j;
	while(1){
		scanf("%d%d",&n,&k);
		if(n==0&&k==0) break;
		for(i=1;i<=n;i++){
			scanf("%d",&a[i]);
		}
		for(i=1;i<=n-k;i++){
			sum=0;
			if(i+k<=n){
				for(j=i;j<i+k;j++){
					sum+=a[j];
				}
				if(max<sum){
					max=sum;
				}
			}
		}
		printf("%d\n",max);
	}
	return 0;
}

Measured memory_bytes: 2952
import re 
T=input() 



T=T.replace("???", "DDD")
T=T.replace("??", "DD")

T=T.replace('D?D', 'DPD')
T=T.replace('D?P', 'DDP')
T=T.replace('P?D', 'PDD')
T=T.replace('P?P', 'PDP')

T=T.replace('?P', 'DP')
T=T.replace('?D', 'PD')

T=T.replace('P?', 'PD')
T=T.replace('D?', 'DD')

T=T.replace('?', 'D')

#T=re.sub("?", "D",T)
#T.replace('P?P', 'PDP')

print(T)

Measured memory_bytes: 10040
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
using namespace __gnu_pbds;
using namespace std;
/*
int dx[]={-1,1,0,0};
int dy[]={0,0,-1,1};
*/
#define ull unsigned long long int
#define ll long long int
#define MAX 1000000007
//1e9+7
#define pll pair<ll,ll>
#define pii pair<int,int>
#define IO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define FO ifstream fin("a.in");ofstream fout("a.out");
#define TEST int testcase;cin>>testcase;while(testcase--)
#define all(x) (x).begin(),(x).end()
#define mset0(x) memset((x), 0, sizeof((x)));
#define mset1(x) memset((x), -1, sizeof((x)));
#define endl "\n"
typedef tree<ll,null_type,less<ll>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
int fa[301],sizes[301];
int root(int node){
    while(node!=fa[node]){
        fa[node]=fa[fa[node]];
        node=fa[node];
    }
    return(node);
}
void link(int i,int j){
    i=root(i);j=root(j);
    if(i==j) return;
    if(sizes[i]>sizes[j]) swap(i,j);
    sizes[j]+=sizes[i];
    fa[i]=j;
    return;
}
void solve(){
    ll N,K;
    cin>>N>>K;
    string s;
    cin>>s;
    vector<int> v,w;
    int cnt0=0,cnt1=0;
    if(s[0]=='0') cnt0++;
    else cnt1++;
    for(int i=1;i<N;i++){
        if(s[i]=='0'){
            if(cnt0==0){
                v.push_back(cnt1);
                cnt1=0;
                w.push_back(1);
            }
            cnt0++;
        }
        else{
            if(cnt1==0){
                v.push_back(cnt0);
                cnt0=0;
                w.push_back(0);
            }
            cnt1++;
        }

    }
    if(cnt1) {v.push_back(cnt1);w.push_back(1);}
    if(cnt0) {v.push_back(cnt0);w.push_back(0);}
    /*
    for(auto x:v) cout<<x<<" ";
    cout<<endl;
    */
    int m=v.size();
    int dp[m+1];
    dp[0]=0;
    for(int i=0;i<m;i++)
        dp[i+1]=dp[i]+v[i];

    int maxx=0;
    for(int i=0;i<m;i++){
        int k=K*2;
        if(w[i]) k++;
        maxx=max(maxx,dp[min(m,i+k)]-dp[i]);
    }
    cout<<maxx;
    return;
}
int main(){
    IO
    //TEST
    solve();
    return(0);
}


Measured memory_bytes: 1748
s=input()
n=len(s)
first_half=s[0:n//2]
second_half=s[n//2+1:n]
def is_flyer(s):
    for i in range(len(s)//2):
        if s[i]!=s[len(s)-1-i]:
            return False
    return True
judge=is_flyer(first_half)
if judge==True:
    judge=is_flyer(second_half)
if judge==True and is_flyer(s)==True:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;

struct ManageMethod {
	bool is_multi;
	double ratio;
	int cost;
};

ManageMethod methods[101];

int main() {
	int m;
	cin >> m;
	while(m--) {
		int init_capital, manage_year, n;
		cin >> init_capital >> manage_year >> n;
		for (int i = 0; i < n; i++) {
			cin >> methods[i].is_multi >> methods[i].ratio >> methods[i].cost;
		}

		int max_capital = 0;

		for (int i = 0; i < n; i++) {
			int current_capital = init_capital;
			int sum_r = 0;
			for (int j = 0; j < manage_year; j++) {
				int r = (int)floor(current_capital * methods[i].ratio);
				if(methods[i].is_multi) {
					current_capital += r;
				}
				else {
					sum_r += r;
				}
				current_capital -= methods[i].cost;
			}
			current_capital += sum_r;

			if(max_capital < current_capital) {
				max_capital = current_capital;
			}
		}
		cout << max_capital << endl;
	}
	return 0;
}

Measured memory_bytes: 0
# -*- coding: utf-8 -*-
# モジュールのインポート
import itertools

while True:
    # 標準入力を取得
    n, x = list(map(int, input().split()))

    # n, xがともに0のとき終了
    if (n == 0) and (x == 0):
        break

    # 求解処理
    ans = 0
    for i, j, k in itertools.combinations(range(1, n + 1), r=3):
        if i + j + k == x:
            ans += 1

    # 結果出力
    print(ans)


Measured memory_bytes: 5632
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
int main(){
    ios::sync_with_stdio(false);
    int n,k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,n) {
        cin >> a[i];
    }
    rep(i,k) {
        bool end_flag = true;
        vector<int> s(n,0); //a[i] = s[0] + s[1] + ... + s[i]
        rep(i,n) {
            s[max(0,i-a[i])]++;
            if(i+a[i]+1 < n) s[i+a[i]+1]--;
        }
        a[0] = s[0];
        rep(i,n-1) {
            a[i+1] = a[i] + s[i+1];
        }
        rep(i,n) if(a[i] != n) end_flag = false;
        if(end_flag) break;
    }
    rep(i,n) {
        cout << a[i] << endl;
    }
}


Measured memory_bytes: 4836
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int k = sc.nextInt();
		int[] v = new int[n];
		for (int i = 0; i < n; i++) {
			v[i] = sc.nextInt();
		}
		sc.close();

		int ans = 0;
		for (int a = 0; a <= n && a <= k; a++) {
			for (int b = 0; b <= n && b <= k; b++) {
				int x = a + b;
				if (x > k || x > n) {
					break;
				}

				int val = 0;
				List<Integer> list = new ArrayList<Integer>(a + b);
				for (int i = 0; i < a; i++) {
					val += v[i];
					list.add(v[i]);
				}
				for (int i = n - 1; i >= n - b; i--) {
					val += v[i];
					list.add(v[i]);
				}

				Collections.sort(list);
				for (int i = 0; i < k - x && i < list.size(); i++) {
					int m = list.get(i);
					if (m < 0) {
						val -= m;
					} else {
						break;
					}
				}
				ans = Math.max(ans, val);
			}
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 24532
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<cmath>
#define mid ((l+r)/2)
using namespace std;
const int maxn=50+10;
int n,d[maxn];
bool cmp(int a,int b){
	return a>b;
}
int cal(int a,int b){
	return ((a-b)%24+24)%24;
}
bool check(int c){
	int a[maxn]={0},last=d[1];
	for(int i=1;i<=n;i++)
		a[i]=d[i];
	for(int i=2;i<=n;i++)
		if(last-a[i]<c)a[i]*=-1;
		else last=a[i];
	for(int i=0;i<=n;i++)
		for(int j=0;j<=n;j++)
			if(i!=j && min(cal(a[i],a[j]),cal(a[j],a[i]))<c)
	return false;
	return true;
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&d[i]);
	sort(d+1,d+n+1,cmp);
	int l=0,r=12;
	while(l+1<r){
		if(check(mid))l=mid;
		else r=mid-1;
	}
	if(check(r))printf("%d\n",r);
	else printf("%d\n",l);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1e9
#define pb push_back
#define mp  make_pair
#define loop(a,n) for(long long i=a;i<n;i++)
#define vil vector<long long int>
#define vi vector<int>
#define sz(v) v.size()
using namespace std;
ll gcd(ll a,ll b){
    if(a==0)return b;
    return gcd(b%a,a);
}
bool isperfect(ll n){
    ll y=sqrt(n);
    if(n%y==0&&y*y==n)return true;
    return false;
}
bool comp(pair<ll,ll> a,pair<ll,ll> b){
    return a.second<b.second;
}
ll powi(ll a,ll b){
    ll ans=1;
    while(b>0){
        if(b&1)ans=ans*a;
        b=(b>>1);
        a=a*a;
    }
    return ans;
}

int main() {
  ll x;
  cin>>x;
  //cout<<powi(2,5);
  for(int i=-1000;i<1000;i++){
      for(int j=-1000;j<1000;j++){
          ll t=powi(i,5);
          ll o=powi(j,5);
          if(t-o==x){
              cout<<i<<" "<<j;
              return 0;
          }
      }
  }
}



Measured memory_bytes: 3652
//ABC - 143
//19 - 10 - 2019
#include <bits/stdc++.h>
using namespace std;

#define ll long long int
#define MOD 1000000007

int main() {
	int a,b;
	cin >> a >> b;
	cout << max(0,a - 2*b);
	return 0;
}

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(){
  int n;
  cin >> n;
  vector <int> x(n);
  vector <int> l(n);
  vector <P> p(n);
  rep(i,n)cin >> x[i] >> l[i];
  rep(i,n){
    p[i]=P(x[i]+l[i],x[i]-l[i]);
  }
  sort(p.begin(),p.end());
  int right=p[0].first;
  int ans=1;
  for(int i=1;i<n;i++){
    if(p[i].second<right)continue;
    right=p[i].first;
    ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 1792
/*Remember: The Struggle is Important*/

//CF,CC,AtC,SPOJ: hp1999
//HE: hemant269
//HR: hemant2132

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

#define     int          long long int
#define     fast()       ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define     all(x)       x.begin(),x.end()
#define     mem(a,b)     memset(a,b,sizeof(a))
#define     gcd(a,b)     __gcd((a),(b))
#define     lcm(a,b)     ((a)*(b))/gcd((a),(b))
#define     pb           push_back
#define     ins          insert
#define     F            first
#define     S            second

const int inf=1e18,MOD=1e9+7;

void solve()
{
 int n;
 cin>>n;

 vector<pair<string,pair<int,int>>> v(n);

 for(int i=0;i<n;++i)
 {
  cin>>v[i].F>>v[i].S.F;
  v[i].S.F*=-1;
  v[i].S.S=i;
 }
 sort(all(v));

 for(int i=0;i<n;++i)
 cout<<v[i].S.S+1<<"\n";

}

int32_t main()
{
 fast();

 int t=1;
 //cin>>t;
 while(t--)
 {
  solve();
 }

 return 0;
}



Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include "bits/stdc++.h"

#define REP(i,x,y) for(int i=(x);i<(y);i++)
#define RREP(i,x,y) for(int i=(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
//#define int long long

using namespace std;

// conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

typedef long long ll;

const ll MOD = 1e9 + 7;

class CAverageLength {
public:
	void solve(std::istream& in, std::ostream& out) {
	    int N;
	    in >> N;
	    vector<int> x(N), y(N);
	    REP(i,0,N) in >> x[i] >> y[i];
	    double distanceSum = 0;
	    REP(i,0,N) {
	        REP(j,i+1,N) {
	            distanceSum += pow((double)(pow(x[i] - x[j], 2) + pow(y[i] - y[j], 2)), 0.5);
	        }
	    }
	    double distanceAvg = distanceSum / (N * (N-1) / 2);
	    out << fixed << setprecision(10) << distanceAvg * (N-1) << "\n";
	}
};


signed main() {
	CAverageLength solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 512
import java.util.*;
public class Main{
	public static void main(String[] args){
      Scanner i = new Scanner(System.in);
      int A = i.nextInt();
      int B = i.nextInt();
      int C = i.nextInt();
      int D = i.nextInt();
      boolean ta = false;
      for(int j=1;true;j++){
      	C-=B;
        if(C<=0){ta=true;break;}
        A-=D;
        if(A<=0){ta=false;break;}
      }
      System.out.println(ta?"Yes":"No");
    }
}

Measured memory_bytes: 35716
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) {
		FScanner sc = new FScanner();
		int N = sc.nextInt();
		long K = sc.nextLong();
		long Q = sc.nextLong();
		long[] P = new long[N];
		for (int i = 0; i < Q; i++) {
			int seikaisya = sc.nextInt();
			P[seikaisya - 1] += 1;
		}
		for (int i = 0; i < P.length; i++) {
			long point = K - (Q - P[i]);
			if (point <= 0) {
				System.out.println("No");
			} else {
				System.out.println("Yes");
			}
		}
	}

}

class FScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

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

int main() {
  int n;
  cin>>n;
  int a[n];
  int b[n];
  for(int i=0;i<n;i++){
    cin>>a[i];
  }
  for(int i=0;i<n;i++){
    cin>>b[i];
  }
  int c[]={1,2,6,24,120,720,5040};
  int p=0;
  for(int i=0;i<n-1;i++){
    int q=0;
    for(int j=i+1;j<n;j++){
      if(a[i]>a[j]){
        q++;
      }
    }
    p+=q*c[n-i-2];
  }
  int r=0;
  for(int i=0;i<n-1;i++){
    int q=0;
    for(int j=i+1;j<n;j++){
      if(b[i]>b[j]){
        q++;
      }
    }
    r+=q*c[n-i-2];
  }
  cout<<max(r-p,p-r)<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cstdlib>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <stack>
#include <math.h>
#include <string.h>
#include <map>
#include <set>
#include <bitset>
#include <queue>


#define ln cout<<'\n'
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (n); ++i)
//ASCII a=97, A=65
// int H[N]; rep(i,N) scanf("%d", &H[i]);
// int max_x = *std::max_element(x.begin(), x.end());
// int min_y = *std::min_element(y.begin(), y.end());
// sort(vec.begin(), vec.end()); std::greater<>()
// reverse(vec.begin(), vec.end());
// scanf("%s",s);
// printf("%d\n",end-start+1);
// ceil (a + (b - 1)) / b

using namespace std;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
using pll = pair<long long, long long>;

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 GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
const long long INF = 1LL << 60;
const int MOD = 1000000007;

struct UnionFind {
    vector<int> par;
    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    
    int rt(int x) {
        if (par[x] < 0) return x;
        else return par[x] = rt(par[x]);
    }
    
    bool issame(int x, int y) {
        return rt(x) == rt(y);
    }
    
    bool unite(int x, int y) {
        x = rt(x);
        y = rt(y);
        if (x == y)  return false;
        
        if (par[x] > par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[rt(x)];
    }
};

int main() {
    int N, M, L; cin >> N >> M >> L;
    UnionFind uf_tr(N), uf_rd(N);
    rep (i, M) {
        int a, b; cin >> a >> b, --a, --b;
        uf_tr.unite(a, b);
    }
    rep (i, L) {
        int a, b; cin >> a >> b, --a, --b;
        uf_rd.unite(a, b);
    }
    
    map < pair<int, int>, int> mp;
    rep (i, N) {
        pair<int, int> p(uf_tr.rt(i), uf_rd.rt(i));
        mp[p]++;
    }
    rep (i, N) {
        pair<int, int> p(uf_tr.rt(i), uf_rd.rt(i));
        cout << mp[p] << " ";
    }
}



Measured memory_bytes: 13568
def solve():
    a, b = read()
    result = think(a, b)
    write(result)


def read():
    return read_int(2)


def read_int(n):
    return list(map(lambda x: int(x), read_line().split(' ')))[:n]


def read_float(n):
    return list(map(lambda x: float(x), read_line().split(' ')))[:n]


def read_line(n=0):
    if n == 0:
        return input().rstrip()
    else:
        return input().rstrip()[:n]


def think(a, b):
    return max([a + b, a - b, a * b])


def write(result):
    print(result)


if __name__ == '__main__':
    solve()

Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int max_n=100005;
int n;
vector<int> G[max_n];
int dis[max_n];
int d[2][max_n];
void dfs(int u,int fa){
    for(auto v:G[u]){
        if(v==fa)continue;
        dis[v]=dis[u]+1;
        dfs(v,u);
    }
}
void work(int s,int d[]){
    dis[s]=0;
    dfs(s,0);
    for(int i=1;i<=n;i++)d[i]=dis[i];
}
int main(){
    scanf("%d",&n);
    for(int i=1;i<n;i++){
        int u,v;scanf("%d%d",&u,&v);
        G[u].push_back(v),G[v].push_back(u);
    }
    work(1,d[0]),work(n,d[1]);
    int cnt=0;
    for(int i=1;i<=n;i++)if(d[0][i]<=d[1][i])cnt++;
    if(cnt>n-cnt)printf("Fennec\n");
    else printf("Snuke\n");
    return 0;
}

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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int A, B;
  cin >> A >> B;
  cout << (A + B) % 24 << endl;

  return 0;
}


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

int main(){
 int n,tl,c,t,cm=1001;
  cin>>n>>tl;
  for(int i=0;i<n;i++){
    cin>>c>>t;
    if(c<cm && t<=tl)cm=c;
  }
  if(cm>1000)cout<<"TLE"<<endl;
  else cout <<cm<<endl;
  return 0;
}
  

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

int main() {
    long long N; cin >> N;
    long long a = 0;
    for(long long i = 1; i*i <= N; ++i) {
        if(N % i == 0) a = max(a, i);
    }
    long long b = N / a;
    cout << (a - 1) + (b - 1) << endl;
}


Measured memory_bytes: 256
using System;

namespace tst
{
    class Program
    {
        public static void Main()
        {
            string[] In = Console.ReadLine().Split(' ');
            int n = int.Parse(In[0]);//偶数
            int m = int.Parse(In[1]);//奇数
            int res = 0;
            if (n >= 2)
            {
                int temp = n * (n - 1) / 2;
                res += temp;
            }
            if (m >= 2)
            {
                int temp = m * (m - 1) / 2;
                res += temp;
            }
            Console.WriteLine(res);
        }
    }
}

Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define rep(i, n) for (lli i = 0; i < (n); i++)
#define rrep(i, n) for (lli i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
vector<int> e[105];
bool f[105] = {};
void dfs(int u){
    if(f[u])return;
    f[u] = true;
    for(auto s:e[u]){
        dfs(s);
    }
}
int main() {
    int n,k;cin >> n >> k;
    vector<pair<int,int>> ans;
    rep(i,n)rep(j,i){
        if(k==0){
            ans.push_back(make_pair(i+1,j+1));
            e[i].push_back(j);
            e[j].push_back(i);
        }else {
            k--;
        }
    }
    dfs(0);
    rep(i,n){
        if(!f[i]){
            cout << -1 << endl;
            return 0;
        }
    }
    if(k){
        cout << -1 << endl;
        return 0;
    }
    cout << ans.size()<<endl;
    for(auto s:ans){
        cout << s.first << " " << s.second << endl;
    }
}


Measured memory_bytes: 384
K,X=map(int, input().split())
a=()
m=-1000000 if X-K+1<-1000000 else X-K+1
h=1000000 if X+K-1>1000000 else X+K-1
L=[]
for i in range(m, h+1):
  L.append(str(i))

a=' '.join(L)
print(a)

Measured memory_bytes: 2940
S = input()
Q = int(input())

flipped = False
head = ''
tail = ''

for _ in range(Q):
    tmp = input()
    if tmp[0] == '1':
        flipped = not flipped
    else:
        _, f, c = tmp.split()

        if (f == '1' and not flipped) or (f == '2' and flipped):
            head += c
        else:
            tail += c

if not flipped:
    print(head[::-1] + S + tail)
else:
    print(tail[::-1] + S[::-1] + head)


Measured memory_bytes: 4340
N = int(input())
X = [[0 for j in range(10)] for i in range(10)]

for k in range(1,N+1):
    X[int(str(k)[0])][int(str(k)[-1])] +=1

Ans = 0
for i in range(10):
    for j in range(10):
        Ans += X[i][j]*X[j][i]
print(Ans)

Measured memory_bytes: 3064
# -*- coding: utf-8 -*-
"""
Created on Sun May 10 20:50:47 2020
"""

import sys
#import numpy as np

sys.setrecursionlimit(10 ** 9)
#def input():
#    return sys.stdin.readline()[:-1]
mod = 10**9+7

A,B,C,K = map(int,input().split())

if K <= A:
    ans = K
elif K <= A + B:
    ans = A
else:
    ans = A - (K-A-B)
print(ans)


Measured memory_bytes: 9116
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define NMAX 110000
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
typedef long long int ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

struct rest{
    ll num;
    string S;
    ll p;

    bool operator<(const rest& right) const{
        if(this->S!=right.S) return this->S < right.S;
        else return this->p > right.p;
    }
};

int main()
{	
    ll n; cin >> n;
    vector<rest> R(n);
    for(int i=0; i<n; i++){
        cin >> R[i].S >> R[i].p;
    }
    for(int i=0; i<n; i++) R[i].num = i+1;

    sort(R.begin(), R.end());

    for(int i=0; i<n; i++){
        cout << R[i].num << endl;
    }

    return 0;
}

Measured memory_bytes: 256