akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<stack>
using namespace std;
typedef long long ll;

ll mod = 1e9+7;  // 1e9+9

ll add(ll x,ll y){return (x+y)%mod;}
ll mul(ll x,ll y){return (x*y)%mod;}

ll mpow(ll x,ll y){
  ll v=1;
  for(;y;x=mul(x,x),y>>=1)
    if(y&1)v=mul(v,x);
  return v;
}

ll divi(ll x,ll y){return mul(x,mpow(y,mod-2));}
/*
ll ncr[5000][5000];

ll nCr(ll n,ll r){
  if(n==r)return 1;
  if(r==0)return 1;
  if(ncr[n][r])return ncr[n][r];
  ncr[n][r]=(nCr(n-1,r-1)+nCr(n-1,r))%mod;
  return ncr[n][r];
}
*/

/*
ll nCr(ll n,ll r){
  r=min(r,n-r);
  ll A=1,B=1;
  for(ll i=0;i<r;i++){
    A=mul(A, (n-i)%mod );
    B=mul(B, (i+1)%mod );
  }
  return divi(A,B);
}
*/


ll fact[10000000]={1}, factc=0;
ll Fact(ll x){
  while( factc < x ){
    factc++;
    fact[factc]=mul( fact[factc-1] , factc );
  }
  return fact[x];
}

ll nCr(ll n,ll r){
  return divi( Fact(n) , mul( Fact(n-r) , Fact(r) )   );
}


/*
ll nHr(ll n,ll r){
  return nCr( n+r-1 , n );
}
*/

ll dp[1001][1001];
int main(){
  ll n,k;
  cin>>n>>k;
  cout<<(n<=k)<<endl;
  return 0;
}



Measured memory_bytes: 3160
import java.util.*;
public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		long t1=sc.nextLong();
		long t2=sc.nextLong();
		long a1=sc.nextLong();
		long a2=sc.nextLong();
		long b1=sc.nextLong();
		long b2=sc.nextLong();
		if((a1>b1 && a1*t1+a2*t2>b1*t1+b2*t2) || (b1>a1 && a1*t1+a2*t2<b1*t1+b2*t2)){
			System.out.println(0);
		}else if(a1*t1+a2*t2==b1*t1+b2*t2){
			System.out.println("infinity");
		}else{
			long kk=0;
			if((Math.abs(a1*t1-b1*t1)%Math.abs(a1*t1+a2*t2-(b1*t1+b2*t2)))==0){
				kk=-1;
			}
			System.out.println(kk+1+2*(Math.abs(a1*t1-b1*t1)/Math.abs(a1*t1+a2*t2-(b1*t1+b2*t2))));
		}
	}
}


Measured memory_bytes: 22996
#include <iostream>
using namespace std;
typedef long long ll;

int main() {
  string s; cin >> s;
  int n = s.size();
  ll an = 0, nw = 0;
  for(ll i=0; i<n; i++) {
    if (s[i] == '<') {
      nw++; an += nw;
    } else {
      ll j=1;
      while(i < n && s[i] == '>') {
        i++; j++;
      }
      //cout << "(" << i << " " << j << endl;
      if (nw >= j) an += (j-2)*(j-1)/2;
      else an -= nw, an += j*(j-1)/2;
      nw = 0; i--;
    }
    //cout << an << " " << nw << " ";
  }
  //cout << endl;
  //for(int x:a) cout << x << " ";
  //cout << endl;
  cout << an << endl;
}

Measured memory_bytes: 900
#include<iostream>
#include<queue>
#include<vector>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
LL mod=1000000007;
LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};


struct edge {int to;int cost;};
const int M_N=300;
int L;

vector<edge> G[M_N+1];

struct Dijkstra{

    P d[M_N+1];

    void dijkstra(int s){
        for (int i = 0; i < M_N; i++) {
            d[i] = mp(INF,INF);
        }
        priority_queue<pair<P,int> ,vector<pair<P,int>>,greater<pair<P,int>>> que;
        que.push({{0,-L},s});
        while(!que.empty()){
            pair<P,int> p=que.top();que.pop();
            int v=p.second;
            int t=-p.first.second;
            int l=p.first.first;
            if(d[v].first<l) continue;
            else if(d[v].first==l&&d[v].second>t) continue;
            d[v] = P(l,t);
            for(int i=0;i<G[v].size();i++){
                edge e=G[v][i];
                if(e.cost>t){
                    if(d[e.to].fs>l+1||(d[e.to].fs==l+1&&d[e.to].sc<L-e.cost)) que.push({{l+1,-(L-e.cost)},e.to});
                }
                else{
                    if(d[e.to].fs>l||(d[e.to].fs==l&&d[e.to].sc<t-e.cost)) que.push({{l,-(t-e.cost)},e.to});
                }
            }
        }
    }

};




int main(){
    int n,m;cin >> n >> m >> L;
    for (int i = 0; i < m; i++) {
        int x,y;cin >> x >> y;
        x--,y--;
        int c;cin >> c;
        if(c>L) continue;
        G[x].pb({y,c});
        G[y].pb({x,c});
    }
    Dijkstra Ds[M_N];
    for (int i = 0; i < n; i++) {
        Ds[i].dijkstra(i);
    }
    int q;cin >> q;
    for (int i = 0; i < q; i++) {
        int x,y;cin >> x >> y;
        x--,y--;
        int ans = Ds[x].d[y].first;
        if(ans == INF) cout << -1 << endl;
        else cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 3528
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

//Code Short
#define REP(i,n) for(int i = 0;i < n;++i)
#define PB(s) push_back(s)
#define DSORT(n) sort(n.begin(),n.end())
#define QECHO(n) cout << n
#define QECHOS(n) cout << n << " "

//Define Math
const double EPS = 1e-10;
const double PI  = acos(-1.0);

using namespace std;
typedef long long ll;
/* prototype */
int EDSum(ll);//各桁の和
vector<int> SOE(int,int);//素数 (Min,Max)
int MinCM(int,int);//最小公倍数(num1,num2)
int MaxCD(int,int);//最大公約数(num1,num2)
vector<int> igets(int);//cin * N
ll nPr(ll,ll); //(n,r)
ll nE(ll); //(n)
ll nCr(ll,ll); //(n,r)

void solve(){
    //START
    int a,b,c;
    cin >> a >> b >> c;
    if(abs(a-b) < abs(a-c) )QECHO("A\n"); else QECHO("B\n");
}

int main(void){cin.tie(0);ios::sync_with_stdio(false);solve();}
int EDSum(ll number) {
  int ans = 0;
  while (1) {
    ans += number % 10;
    number /= 10;
    if (number == 0) break;
  }
  return ans;
}

vector < int > SOE(int min, int max) {
  if (min < 2) min = 2;
  vector < int > int_array;
  for (int i = min; i <= max; i++) int_array.push_back(i);
  vector < int > sosu;
  double stop = sqrt(max);
  while (true) {
    sosu.push_back(int_array.front());
    int_array.erase(int_array.begin());
    if (stop < (double)(sosu.back())) break;
    for (int i = 0; i < (int) int_array.size(); i++) {
      if (int_array[i] % sosu.back() == 0)
        int_array.erase(int_array.begin() + i);
    }
  }
  sosu.insert(sosu.end(), int_array.begin(), int_array.end());
  return sosu;
}

int MinCM(int a, int b) {
  int c = a * b;
  if (a < b)
    swap(a, b);
  int r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return c / b;
}

int MaxCD(int a, int b) {
  if (a < b)
    swap(a, b);
  int r = a % b;
  while (r != 0) {
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}
vector < int > igets(int N) {
  vector < int > A;
  int temp;
  for (int i = 0; i < N; ++i) {
    cin >> temp;
    A.push_back(temp);
  }
  return A;
}

ll nPr(ll n, ll r) {
  ll ans = 1;
  r = n - r;
  while (n != r) {
    ans *= n;
    --n;
  }
  return ans;
}

ll nE(ll n) {
  return nPr(n, n);
}

ll nCr(ll n, ll r) {
  if (r == 0) return -1;
  else {
    if (0 != n - r && n - r < r) r = n - r;
    return nPr(n, r) / nE(r);
  }
}

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

using namespace std;



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

	int n, m;
	cin >> n >> m;

	int r1 = n * (n - 1);
	int r2 = m * (m - 1);

	cout << r1/2 + r2/2 << '\n';



	return 0;	
}

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

int main(void){
    int n; string s;
    long long r=0, g=0, b=0, ans;
    cin >> n >> s;
    for (int i=0; i<n; i++) {
        if (s[i] == 'R') r++;
        else if (s[i] == 'G') g++;
        else b++;
    }
    ans = r * g * b;
    
    for (int i=0; i<n; i++) {
        for (int j=i+1; j<n; j++) {
            int k = 2 * j - i;
            if (k<n && s[i] != s[j] && s[j] != s[k] && s[k] != s[i]) 
                ans--;
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
class SegTree:
    def __init__(self, init_val, segfunc, ide_ele):
        n = len(init_val)
        self.segfunc = segfunc
        self.ide_ele = ide_ele
        self.num = 1 << (n - 1).bit_length()
        self.tree = [ide_ele] * 2 * self.num
        # 配列の値を葉にセット
        for i in range(n):
            self.tree[self.num + i] = init_val[i]
        # 構築していく
        for i in range(self.num - 1, 0, -1):
            self.tree[i] = self.segfunc(self.tree[2 * i], self.tree[2 * i + 1])

    def update(self, k, x):
        k += self.num
        self.tree[k] = x
        while k > 1:
            self.tree[k >> 1] = self.segfunc(self.tree[k], self.tree[k ^ 1])
            k >>= 1

    def query(self, l, r):
        res = self.ide_ele

        l += self.num
        r += self.num
        while l < r:
            if l & 1:
                res = self.segfunc(res, self.tree[l])
                l += 1
            if r & 1:
                res = self.segfunc(res, self.tree[r - 1])
            l >>= 1
            r >>= 1
        return res

def segfunc(x, y):
    return max(x, y)

def main():

    N, K = map(int, input().split())
    B = []
    for _ in range(N): B.append(int(input()))
    a = [0 for _ in range(max(B)+1)]
    ide_ele = 0
    seg = SegTree(a, segfunc, ide_ele)

    ans = 0
    for i in range(N):
        l = max(0, B[i]-K)
        r = min(len(a), B[i]+K)
        v = seg.query(l, r+1)
        ans = max(ans, max(1, v+1))
        seg.update(B[i], max(1, v+1))
        # print(ans)

    return ans

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

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

int main() {
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(abs(a-c)<=d){
    cout<<"Yes"<<endl;
  }
  else if(abs(a-b)<=d&&abs(b-c)<=d){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
  
}


Measured memory_bytes: 256
#include <stdio.h>
const int maxn = 100010;
int main()
{
    int n;
    char p[maxn];
    scanf("%d", &n);
    scanf("%s", p);
    char c = p[0];
    int num = 1;
    for(int i = 1; i < n; i++){
        if(p[i] != c){
            num++;
            c = p[i];
        }
    }
    printf("%d", num);
    return 0;
}


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

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
   int a;
   cin>>a;
int L=a/100;
int R=a%100;
if(1<=L&&L<=12){
if(1<=R&&R<=12)cout<<"AMBIGUOUS";
else cout<<"MMYY";
}else{
if(1<=R&&R<=12)cout<<"YYMM";
else cout<<"NA";}

    
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int office[4][3][10]={0};
    int n, b,f,r,v;

    cin >>n;

    while(n>0){
        cin >> b >> f >> r >> v;

        office[b-1][f-1][r-1] += v;

        n--;
    }

    for(int i=0;i<4;i++){
        for(int j=0;j<3;j++){
            for(int k=0;k<10;k++){
                cout << " "<<office[i][j][k];
            }
            cout<<endl;
        }

        if(i<3){
            cout <<"####################"<<endl;
        }
    }


    return 0;
}



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

int main() {
  string S;
  cin >> S;
  if (S.at(2) == S.at(3) && S.at(4) == S.at(5)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,m;
char s[105];
int cnt[100];
int main()
{
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        cin>>s;
        for(int j=0;j<m;j++)
        {
            cnt[s[j]-'a'+1]++;
        }
    }
    if(n%2==0&&m%2==0)
    {
        for(int j=1;j<=26;j++)
        {
            if(cnt[j]%4!=0)
            {
                puts("No");
                return 0;
            }
        }
        puts("Yes");
        return 0;
    }
    else if(n%2==1&&m%2==1)
    {
        int tmp=0,tt=0;
        for(int i=1;i<=26;i++)
        {
            if(cnt[i]%2==1)tt++;
            tmp+=cnt[i]/4;
        }
        if(tt>1||tmp<(n-1)*(m-1)/4)puts("No");
        else puts("Yes");
    }
    else
    {
        if(n%2==0)swap(n,m);
        int tmp=0;
        for(int i=1;i<=26;i++)
        {
            if(cnt[i]%2==1)
            {
                puts("No");
                return 0;
            }
            else tmp+=cnt[i]/4;
        }
        if(tmp<(n-1)*m/4)puts("No");
        else puts("Yes");
    }
    return 0;
}

Measured memory_bytes: 3636
n,m  = map(int, input().split())
INF = 1000000007
broken_stairs = set([int(input()) for i in range(m)])

dp = [0] * (n + 1)
dp[0] = 1
if 1 not in broken_stairs:
	dp[1] = 1
else:
	dp[1] = 0
for i in range(2, n + 1):
	if i in broken_stairs:
		continue
	dp[i] = dp[i - 1] + dp[i - 2]
	dp[i] %= INF
print(dp[n])


Measured memory_bytes: 13216
#include <bits/stdc++.h>
#define LL long long
#define ULL unsigned long long
#define UI unsigned int
#define mem(i, j) memset(i, j, sizeof(i))
#define rep(i, j, k) for(int i = j; i <= k; i++)
#define dep(i, j, k) for(int i = k; i >= j; i--)
#define pb push_back
#define make make_pair
#define INF 0x3f3f3f3f
#define inf LLONG_MAX
#define PI acos(-1)
#define fir first
#define sec second
#define lb(x) ((x) & (-(x)))
#define dbg(x) cout<<#x<<" = "<<x<<endl;
using namespace std;

const int N = 1e6 + 5;

int n, m;

int cnt[N], L[N], R[N];

map < int, int > mp;

void solve() {

    scanf("%d %d", &n, &m);

    rep(i, 1, n) scanf("%d %d", &L[i], &R[i]);

    rep(i, 0, m - 1) mp[i] = i;

    cnt[0] = m;

    int ans = 0;

    rep(i, 1, n) {

        auto it = mp.lower_bound(L[i] - 1);

        int r = -1;

        while(it != mp.end() and it->fir <= R[i]) {

            cnt[it->fir - it->sec]--;

            r = max(r, it->sec);

            it = mp.erase(it);

        }

        if(r >= 0 && R[i] < m) {

            mp[R[i]] = r;

            cnt[R[i] - r]++;

        }

        while(ans < m && cnt[ans] == 0) ans++;

        if(ans == m) puts("-1");

        else printf("%d\n", i + ans);

    }

}


int main() {

//    int _; scanf("%d", &_);
//    while(_--) solve();

    solve();

    return 0;
}


Measured memory_bytes: 15380
#include <iostream>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <utility>
#include <numeric>
#include <string>
#include <set>
#include <map>
#include <tuple>
#include <queue>
#include <stack>
#define rep(i, a, n) for(int (i) = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int (i) = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int (i) = (int)(a);(x);++(i))
#define repr(i, a, n) for(int (i) = (int)(a);(i) > (int)(n);--(i))
#define reper(i, a, n) for(int (i) = (int)(a);(i) >= (int)(n);--(i))
#define SIZE(x) ((int)(x).size())
#define ALL(x) (x).begin(), (x).end()
#define RNG(x, n) &((x)[0]), &((x)[n])
#define BRK(x) { (x); break; }
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl;
#define no cout << "no" << endl;
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define EPS (1e-20)
#define INF 2147483647
#define MOD 1000000007
using llint = long long;
using VI = std::vector<int>;
using PII = std::pair<int, int>;
using SI = std::set<int>;
using MII = std::map<int, int>;
using TIII = std::tuple<int, int, int>;
using VLL = std::vector<llint>;
using namespace std;


int N;
int a[200010];
llint acc[200010];


void makeAcc(){
	repe(i, 1, N) acc[i] = a[i-1]+acc[i-1];
}


llint solve(){
	llint ans = INF;
	rep(i, 1, N){
		llint x = acc[i];
		llint y = acc[N]-acc[i];
		ans = min(ans, abs(x-y));
	}
	return ans;
}


signed main(){
	cin >> N;
	rep(i, 0, N) cin >> a[i];
	
	makeAcc();
	
	cout << solve() << endl;
	
	return 0;
}

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

class Program
{
	static long N;
	static List<long[]>[] pathArr;
	static int[] color;

	//深さ優先探索
	static void DFS(long node){
		List<long[]> goals = pathArr[node];

		foreach(long[] path in goals){
				long point = path[0];
				long dist = path[1];
				int col = color[point];

				if(col != -1){
						//探索ずみの場合
						continue;
				}
				else{
						if(dist % 2 == 0){
								//同じ色にする必要
								color[point] = color[node];
						}
						else{
								//違う色にする
								color[point] = (color[node]==0) ? 1 : 0; 
						}

						//次の地点を探索
						DFS(point);
				}
		}
		return;
	}

	//Main
	static void Main(string[] args)
	{
		//読み込む
		N = long.Parse(Console.ReadLine());

		//初期化
		pathArr = new List<long[]>[N];
		color = new int[N];
		for(long i=0; i<N; i++){
				pathArr[i] = new List<long[]>();
				//未探索状態を-1で表現
				color[i] = -1;
		}

		//辺を読み込む
		for(long i=0; i<N-1; i++){
			string[] line = Console.ReadLine().Split(' ');
			long ui = long.Parse(line[0]) - 1;
			long vi = long.Parse(line[1]) - 1;
			long wi = long.Parse(line[2]);

			//行き先と距離とを追加
			long[] path1 = new long[2]{vi, wi};
			long[] path2 = new long[2]{ui, wi};

			pathArr[ui].Add(path1);
			pathArr[vi].Add(path2);
		}

		//最初の頂点から探索開始
		color[0] = 0;
		DFS(0);

		foreach(int col in color){
				Console.WriteLine(col);
		}
	}
}



Measured memory_bytes: 43936
#include <math.h>
#include <bits/stdc++.h>
#include <deque>
#define ll long long
#define l long double
#define pi 3.14159265358979323846
#define mod 1000000007
#define val 1000000000000000000
using namespace std;
int main()
{
    ll k,x;
    cin>>k>>x;
    ll l1,l2;
    l1=x-k+1;
    l2=x+k-1;
    for(int i=l1;i<=l2;i++)
    cout<<i<<" ";
    cout<<endl;
}

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

long isPrime(long n);

long nextPrime(long n) {
	// return the next prime
	long i;
	for (i = n+1; i < LONG_MAX; i++) {
		if (isPrime(i)) return i;
	}
	return 0;
}

long isPrime (long n) {
    int i;
    if (n < 2) return 0;
    else if (n == 2) return 1;
    if (n % 2 == 0) return 0;
    for (i = 3; i <= n / i; i += 2)
         if (n % i == 0) return 0;
    return 1;
}
/*
   36 % 2 = 0
-> 18 % 2 = 0
-> 9 % 2 = 1
-> n != 1
-> 9 % nextPrime(2)
-> 9 % 3 = 0
-> 3 % 3 = 0
-> 1 % 3 = 1
-> n == 1 
-> break
*/

/* 
   n = 13
   sqrt(13) ~~ 3.60
   13 % 2 = 1
-> 13 != 1
-> nextPrime(2) = 3 < sqrt(13)
-> 13 % 3 = 1
-> 13 != 1
-> nextPrime(3) = 5 > sqrt(13)
-> cout << n; break;
*/

int main() {
	long n;
	cin >> n;
	// round up sqrt(n)
	long limit = ceil(sqrt(n));
	long divisor = 2;
	cout << n << ':';
	while (1) {
		if (n % divisor == 0) {
			cout << ' ' << divisor;
			n /= divisor;
		} else if ((n != 1) && (nextPrime(divisor) < limit)) {
			divisor = nextPrime(divisor);
		} else {
			if (n != 1) cout << ' ' << n << '\n';
			else cout << '\n';
			break;
		}
	}
	return 0;
}

Measured memory_bytes: 3112
n,m,l=map(int,input().split())
a={i+1:list(map(int,input().split())) for i in range(n)}
b={i+1:list(map(int,input().split())) for i in range(m)}
for i in range(n):
    cl=[]
    for j in range(l):
        ci=0
        for k in range(m):
            cij=a[i+1][k]*b[k+1][j]
            ci+=cij
        cl.append(ci)
    print(" ".join(map(str,cl)))


Measured memory_bytes: 6248
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
#define all(x) (x).begin(), (x).end()
#define endl '\n'
const ll inf = LLONG_MAX;
const long double pi = M_PI;
void Yes() {cout << "Yes" << endl;}
void No() {cout << "No" << endl;}
void YES() {cout << "YES" << endl;}
void NO() {cout << "NO" << endl;}

int main() {
  ll n, p = 1e9 + 7;
  cin >> n;
  ll power = 1;
  for (ll i = 0; i < n; i++) {
    power *= i + 1;
    power %= p;
  }
  cout << power << endl;
}

Measured memory_bytes: 256
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <memory.h>

using namespace std;

int n, ar[1000001], l, r, ans, c, k;

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

    long long sum = ar[0];
    ans = n;
    for(int i = 1; i < n; i++)
    {
        if(sum * 2 < ar[i])
            ans = n - i;
        sum += ar[i];
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <tuple>
#include <vector>
#include <cstdint>

int main() {
  std::ios_base::sync_with_stdio(false);
  int N;
  std::cin >> N;
  std::vector<std::tuple<std::int64_t, std::int64_t>> points(N);
  for (int i = 0; i < N; ++i) {
    int x, y;
    std::cin >> x >> y;
    points[i] = {x, y};
  }
  const auto distance = [](const auto& p0, const auto& p1) {
    const auto [x0, y0] = p0;
    const auto [x1, y1] = p1;
    return std::abs(x0 - x1) + std::abs(y0 - y1);
  };
  std::sort(points.begin(), points.end(), [](const auto& p0, const auto& p1) {
    const auto [x0, y0] = p0;
    const auto [x1, y1] = p1;
    return x0 + y0 < x1 + y1;
  });
  auto max_distance = distance(*points.begin(), *points.rbegin());
  std::sort(points.begin(), points.end(), [](const auto& p0, const auto& p1) {
    const auto [x0, y0] = p0;
    const auto [x1, y1] = p1;
    return x0 - y0 < x1 - y1;
  });
  max_distance = std::max(max_distance, distance(*points.begin(), *points.rbegin()));
  std::cout << max_distance << std::endl;
  return 0;
}


Measured memory_bytes: 6428
#include <iostream>

using lint = long long;

void solve() {
    int n;
    lint d;
    std::cin >> n >> d;

    int ans = 0;
    while (n--) {
        lint x, y;
        std::cin >> x >> y;
        if (x * x + y * y <= d * d) ++ans;
    }

    std::cout << ans << "\n";
}

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

    solve();

    return 0;
}


Measured memory_bytes: 3664
#include <cstdio>

constexpr int MOD = 1000000007;

char cRow[1010];
int ways[1010];

int main() {
	ways[0] = 1;
	int h, w; scanf("%d %d", &h, &w);
	for (int i = 0; i < h; ++i) {
		scanf("%s", cRow);
		ways[0] = (cRow[0] == '#' ? 0 : ways[0]);
		for (int j = 1; j < w; ++j) {
			if (cRow[j] == '#') ways[j] = 0;
			else ways[j] = (ways[j] + ways[j-1]) % MOD;
		}
	}
	printf("%d\n", ways[w-1]);
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include <stdio.h>
#include<algorithm>
#include<cstring>
#include <string>
#include<cmath>
#include<cstdlib>
#include<queue>
#include<map>
#include<vector>
#include<bits/stdc++.h>
#include <set>
#define ll   long long
#define IO ios::sync_with_stdio(false);cin.tie();cout.tie(0)
#define inf 0x3f3f3f
#define pi 3.1415926535898

using namespace std;
const int N = 1e3 + 5;
const int M = 2e4 + 5;
int n,m;
ll dp[N][M];
int  a[8500],b[5000];
int main()
{
    cin>>n>>m;
    memset(dp,inf,sizeof(dp));
    for(int i=1;i<=m;i++)
    {
        cin>>a[i]>>b[i];
    }
    dp[0][0]=0;
    for(ll i=1;i<=m;i++)
    {
        for(int  j=0;j<=n;j++)
        {
            dp[i][j]=dp[i-1][j];
            dp[i][j]=min(dp[i][j],dp[i][max(0,j-a[i])]+b[i]);
        }
    }
    cout<<dp[m][n]<<endl;
    return 0;
}


Measured memory_bytes: 160672
#include <iostream>
using namespace std;
int main(){
	int a, b;
	cin >> a >> b;
	if(a<b){
		cout << "a < b\n";
	}
	else if(a>b){
		cout << "a > b\n";
	}
	else{
		cout << "a == b\n";
	}

return 0;
}

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

#define ll long long

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

    ll flavor = 0, mn = 500;
    int pos = 0;
    for (int i = 1; i <= n; i++){
        flavor += (l + i - 1);
        if (abs(l + i -1) < mn){
            mn = abs(l + i - 1);
            pos = i;
        }
    }
    ll pie = 0;
    for (int i = 1; i <= n; i++){
        if (i == pos) continue;
        pie += (l + i -1);
    }
    cout << pie << endl;
    return 0;
}


Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

// x ** n % mods を求める
fn mod_pow(x: i64, n: i64, mods: i64) -> i64 {
    if n == 0 {
        return 1;
    }
    let mut res = mod_pow(x * x % mods, n / 2, mods);
    if n % 2 == 1 {
        res = res * x % mods;
    }
    return res;
}

// (1/n) % mods を求める
fn mod_inv(n: i64, mods: i64) -> i64 {
    return mod_pow(n, mods-2, mods);
}

// nCk % mods を求める
fn mod_comb(n: i64, k: i64, mods: i64) -> i64 {
    let sum1 = (n-k+1..n+1).fold(1, |ac, x| ac * x % mods);
    let sum2 = (1..k+1).fold(1, |ac, x| ac * x % mods);
    return sum1 * mod_inv(sum2, mods) % mods;
}

// nCk の組み合わせを列挙する
fn combination(n: usize, k: usize) -> Vec<Vec<usize>> {
    let mut ans = Vec::new();
    if k == 1 {
        for i in 1..n+1 {
            let mut tmp = Vec::new();
            tmp.push(i);
            ans.push(tmp);
        }
    }
    else {
        for iter in combination(n-1, k-1) {
            let max = iter.iter().max().unwrap();
            for j in *max+1..n+1 {
                let mut tmp = iter.clone();
                tmp.push(j);
                ans.push(tmp);
            }
        }
    }
    ans
}


fn main() {
    input!{
        n: usize,
        m: usize,
        x: usize,
        ca: [[usize; m+1]; n]
    }
    let mut ans = 10000000;
    for bit in 0..2_i64.pow(n as u32) {
//        let mut tmp: [usize; m+1] = [0; m+1];
        let mut tmp = vec![0; m+1];
        for i in 0..n {
            let mask = 1 << i;
//            println!("{}", bit & mask);
            if bit & mask > 0 {
                for j in 0..m+1 {
                    tmp[j] = tmp[j] + ca[i][j];
                }
            }
        }
        let mut flag = 1;
        for j in 1..m+1 {
            if tmp[j] < x {
                flag = 0;
            }
        }
        if flag == 1 && tmp[0] < ans {
            ans = tmp[0];
        }
    }
    if ans == 10000000 {
        println!("-1");
    } else {
        println!("{}", ans);
    }
}


Measured memory_bytes: 2176
from collections import deque

def main():
    n, m = list(map(int, input().split(" ")))
    v_set = [set([]) for _ in range(n)]
    for _ in range(m):
        a, b = list(map(int, input().split(" ")))
        v_set[a-1].add(b-1)
        v_set[b-1].add(a-1)

    max_num = 0
    checked = [0]*n
    for ni in range(n):
        if checked[ni]:
            continue
        stack = deque([ni])
        checked[ni] = 1
        f = 1
        while stack:
            cur = stack.pop()
            for next_i in v_set[cur]:
                if checked[next_i]:
                    continue
                stack.append(next_i)
                checked[next_i] = 1
                f+=1
        max_num = max(max_num, f)

    print(max_num)

if __name__=="__main__":
    main()


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

int main() {
  int n,k,ans = 0;
  cin >> n >> k;
  vector<int>data(n);
  for(int i = 0;i < n;i++) cin >> data[i];
  sort(data.begin(),data.end());
  reverse(data.begin(),data.end());
  for(int i = 0;i < k;i++) ans += data[i];
  cout << ans << endl;
}


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

int is_iwi(string s);

map<char, char> my_map;

int main(int argc, char const* argv[])
{
    string s;
    cin >> s;

my_map['i'] = 'i';
my_map['w'] = 'w';
my_map[' '] = ' ';
my_map['('] = ')';
my_map[')'] = '(';

    //char dir[5];
    //dir[0] = 'i';
    //dir[1] = 'w';
    //dir[2] = ' ';
    //dir[3] = ')';
    //dir[4] = '(';

    //if (is_iwi(s)) 
    //{
    //    cout << 0 << endl;
    //    return 0;
    //}

    int count=0; 
    int size=s.size();
    for (int i = 0; i < size / 2; i++) 
    {
        if ( my_map[s[i]] != s[size -1 -i] ) 
        {
            //i番目が対称で無かったら、カウント
            count++;
        }
    }
    if (size % 2 == 1) 
    {
        if (s[size/2] == 'i' || s[size/2] == 'w' || s[size/2] == ' ') 
        {
            
        }else{
            count++;
        }
    }
    cout << count << endl;
    return 0;

    //my_map<string, int> my_map;

    //queue<int> q;
    //while ( !q.empty() ) 
    //{
    //    //string::iterator ite=s.begin();
    //    //for (ite = s.begin(); ite < s.end(); ite++) 
    //    //{
    //    //    ite
    //    //}
    //    for (int i = 0; i < size / 2; i++) 
    //    {
    //        if ( my_map[s[i]] != s[size -1 -i] ) 
    //        {
    //            //i番目が対称で無かったら、順番に試す
    //            for (int j = 0; j < 5; j++) 
    //            {
    //                
    //            } 
    //        }
    //    }
    //}
}

int is_iwi(string s)
{
    int size = s.size();
    for (int i = 0; i < size / 2; i++) 
    {
        if ( my_map[s[i]] != s[size -1 -i] ) {return 0;}
    }
    return 0;
}

Measured memory_bytes: 1188
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func receiveInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func removeDuplicates(a []int) []int {
	sort.Ints(a)
	j := 0
	for i := 1; i < len(a); i++ {
		if a[j] == a[i] {
			continue
		}
		j++
		a[j] = a[i]
	}
	return a[:j+1]
}

func main() {
	sc.Split(bufio.ScanWords)
	n := receiveInt()

	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = receiveInt()
	}
	sort.Ints(a)

	fmt.Println(len(removeDuplicates(a)))
}


Measured memory_bytes: 640
import numpy as np


##get int
first_input = list(map(lambda x:int(x), input().split(" ")))
#second_input = list(map(lambda x:int(x), input().split(" ")))

##get float
#first_input = list(map(lambda x:float(x), input().split(" ")))
#second_input = list(map(lambda x:float(x), input().split(" ")))

##get string
#first_input = input().split(" ")

N = first_input[0]

number_sum = 0
for i in range(1,N+1):
    if i%5!=0 and i%3!=0:
        number_sum = number_sum+i

print(number_sum)


Measured memory_bytes: 27136
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int N;
    cin >> N;
    vector<int> card(N);
    for(int i = 0;i<N;i++){
        cin >> card.at(i);
    }
    sort(card.begin(),card.end());
    reverse(card.begin(),card.end());
    int alice = 0;
    int bob = 0;
    for(int i = 0;i<card.size();i+=2){
        alice += card.at(i);
    }
    for(int i = 1;i<card.size();i+=2){
        bob += card.at(i);
    }
    cout << alice-bob << endl;
    return 0;
}
/*int main(){
    int N;
    cin >> N;
    vector<int> card(N);
    int i,j;
    for(i=0;i<N;i++){
        cin >> card.at(i);
    }
    for(i=0;i<N;i++){
        for(j=0;j<N-i-1;j++){
            if(card.at(j)<card.at(j+1)){
                int swap = card.at(j);
                card.at(j) = card.at(j+1);
                card.at(j+1) = swap;
            }
        }
    }
    int alice = 0,bob = 0;
    for(i=0;i<N;i=i+2){
        alice += card.at(i);
    }
    for(i=1;i<N;i=i+2){
        bob += card.at(i);
    }
    cout << alice - bob << endl;
    return 0;
}*/

Measured memory_bytes: 3612
#include <stdio.h>
int n, a[50];

int rec(int i, int b) {
  int res = 0;
  if (b == 0) {
    res = 1;
    return res;
  }
  if (i >= n) {
    return res;
  }
  return rec(i + 1, b) || rec(i + 1, b - a[i]);
}

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

  for (int i = 0; i < m; i++) {
    if (rec(0, b[i])) {
      printf("%s\n", "yes");
    } else {
      printf("%s\n", "no");
    }
  }
  return 0;
}



Measured memory_bytes: 2040
#include <bits/stdc++.h>
using namespace std;
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; }
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
const int MAX=2e5;
const ll MOD=1e9+7;
const int INF=1<<30;

int main(){
  string S,T;
  cin >> S >> T;
  cout << T+S << endl;
  
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
static const int MAX = 100;
static const int INFTY = (1 << 21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;
int n, M[MAX][MAX];

int prim()
{
    int u, minv;
    int d[MAX], p[MAX], color[MAX];
    for (int i = 0; i != n; ++i)
    {
        d[i] = INFTY;
        p[i] = -1;
        color[i] = WHITE;
    }
    d[0] = 0;
    while(true)
    {
        minv = INFTY;
        u = -1;
        for (int i = 0; i != n; ++i)
        {
            if (minv > d[i] && color[i] != BLACK)
            {
                u = i;
                minv = d[i];
            }
        }
        if (u == -1)
        {
            break;
        }
        for (int v = 0; v != n; ++v)
        {
            if (M[u][v] != INFTY && color[v] != BLACK)
            {
                if (d[v] > M[u][v])
                {
                    d[v] = M[u][v];
                    color[v] = GRAY;
                    p[v] = u;
                }
            }
        }
        color[u] = BLACK;
    }
    int sum = 0;
    for (int i = 0; i != n; ++i)
    {
        if (p[i] != -1) sum += M[i][p[i]];
    }
    return sum;
}

int main()
{
    cin >> n;
    for (int i = 0; i != n; ++i)
    {
        for (int j = 0; j != n; ++j)
        {
            int e;
            cin >> e;
            M[i][j] = (e == -1) ? INFTY : e;
        }
    }
    cout << prim() << endl;
    return 0;
}


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

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

#define ALL(c)   c.begin(), c.end()
#define SORT(c)  std::sort(ALL(c))
#define RSORT(c) std::sort(ALL(c), std::greater<decltype(c)::value_type>())

using namespace std;
using ll = long long;

const int MOD  = (int)1e9 + 7;
const int INF  = (int)1e9 + 1;
const ll  LINF = (long long)1e18 + 1;

class UnionFind {
public:
    struct Node {
        long long parent, rank, weight;
        Node() = default;
        Node(const long long& _parent,
             const long long& _rank,
             const long long& _weight = 0) :
            parent(_parent),
            rank(_rank),
            weight(_weight) { }
    };

    std::vector<Node> node;

    UnionFind(const long long& num_node) :
        node(num_node) {
        for(long long i = 0; i < num_node; i++) {
            node[i].parent = i;
        }
    }

    long long searchAndZipRoot(const long long& x) {
        if(node[x].parent == x) {
            return x;
        }
        else {
            auto r = searchAndZipRoot(node[x].parent);
            node[x].weight += node[node[x].parent].weight;
            return node[x].parent = r;
        }
    }

    long long calcWeight(const long long& x) {
        searchAndZipRoot(x);
        return node[x].weight;
    }

    void unite(const long long& x,
               const long long& y,
               const long long& weight = 0) {
        auto rx = searchAndZipRoot(x);
        auto ry = searchAndZipRoot(y);
        if(rx != ry) {
            auto yw = weight + calcWeight(x) - calcWeight(y);
            if(node[rx].rank < node[ry].rank) {
                std::swap(rx, ry);
                yw *= -1;
            }
            node[ry].parent = rx;
            node[ry].weight = yw;
            if(node[rx].rank == node[ry].rank) {
                node[rx].rank++;
            }
        }
    }

    long long calcDiff(const long long& x,
                       const long long& y) {
        return std::abs(calcWeight(x) - calcWeight(y));
    }

    template<class... A>
    bool checkWhetherRootIsSame(const A&... nodes) {
        auto node_list = std::initializer_list<long long>{nodes...};
        if(node_list.size() < 2) return false;
        auto v = searchAndZipRoot(*node_list.begin());
        for(size_t i = 1; i < node_list.size(); i++) {
            if(v != searchAndZipRoot(*(node_list.begin() + i))) return false;
        }
        return true;
    }
};

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

    int N, M;
    std::cin >> N >> M;

    UnionFind tree(N);

    string ans = "Yes";
    REP(i, M) {
        int l, r, d;
        std::cin >> l >> r >> d;
        l--; r--;

        if(!tree.checkWhetherRootIsSame(l, r)) {
            tree.unite(l, r, d);
        }
        else {
            if(tree.calcDiff(l, r) != d) {
                ans = "No";
                break;
            }
        }
    }

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

    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define PRINT(V) for (auto v : (V)) cout << v << " "
typedef long long ll;

int main()
{
    int n, m; cin >> n >> m;
    VI h(n), a(m), b(m);
    vector<bool> v(n, true);
    rep(i, n) cin >> h[i];
    rep(i, m) {
        cin >> a[i] >> b[i];
        --a[i]; --b[i];
        if (h[a[i]] <= h[b[i]]) v[a[i]] = false;
        if (h[a[i]] >= h[b[i]]) v[b[i]] = false;
    }

    int c = 0;
    rep(i, n) if (v[i] == true) ++c;
    cout << c << endl;
    return 0;
}


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

int main() {
    int n, m, x;
    cin >> n >> m >> x;

    vector<int> price(n);
    vector<vector<int>> a(n, vector<int>(m));
    rep(i, n) {
        cin >> price[i];
        rep(j, m) cin >> a[i][j];
    }

    ll ans = INF;
    for (int bit = 0; bit < (1 << n); ++bit) {
        ll now = 0;
        vector<int> exp(m);
        rep(i, n) {
            if (bit & (1 << i)) {
                now += price[i];
                rep(j, m) exp[j] += a[i][j];
            }
        }

        bool flag = true;
        rep(i, m) {
            if (exp[i] < x)
                flag = false;
        }

        if (flag)
            ans = min(ans, now);
    }

    if (ans == INF)
        cout << -1 << endl;
    else
        cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3632
//  ABC104C All Green
//
//

#include <iostream>
#include <string>
#include <bitset>
#include <sstream>
#include <cmath>
#include <vector>
#include <utility>     // makepair
#include <algorithm>   // sort

using namespace std;

class Problems {
public:
	int point;		//得点
	int num;			//問題数
	int bonus;		//ボーナス得点

	Problems(int p, int c, int b) {
		point= p;
		num = c;
		bonus = b;
	}

	int point_calc(int n) {  // n問解いた時の得点を計算
		if (n == num) {
			return point * n + bonus;
		} else {
			return point * n;
		}
	}

	int num_calc(int p) {  // 得点p以下となる最大の問題数を求める
		int ans = p / point;
		if (ans > num) ans = num;
		return ans;
	}

private:

};

bool pb_compare(const Problems& aa, const Problems& bb) {
	return (aa.point >  bb.point);  			// ポイントの降順
}


int main() {
	int D,G;
	cin >> D >> G;

	vector<Problems> pb;  		// 個別配点、問題数,ボーナスを格納する配列
	int N=0;							// 総問題数
	for(int i=0; i<D; i++) {
		int x,y;
		cin >> x >> y ;
		Problems q(100*(i+1),x,y);
		N += x;
		pb.push_back(q);
	}
	sort(pb.begin(), pb.end(), pb_compare);

	int minCount=N+1;		// 解くべき問題数
	int minPoint;       // その時の得点
	vector<int> ansTBL(D);

	for(int bit=0; bit < (1<<D); ++bit) {
		vector<int> tbl(D);

        // 素得点の大きい問題から解いて、ゴールにたどり着くか計算する
		int sum=0;
		int pcount=0;
		for(int j=0; j<D; j++) {
			if(bit & 1 << j) {
				// 問題 pb[j]について考える。
				int x = pb[j].num_calc(G - sum);  // ゴールとのギャップを埋める問題数を求める
				sum += pb[j].point_calc(x);
				pcount += x;
				tbl[j] = x;

				if(sum >G) 	break;
			}
		}
		// 回答の判定
		if ( sum >= G ) {
			if ( pcount < minCount ) {
				minCount = pcount;
				minPoint = sum;
				copy(tbl.begin(), tbl.end(), ansTBL.begin());
			}
		}
	}
	cout << minCount << "\n";
	return 0;
}


Measured memory_bytes: 256
s=input()
q=int(input())
for _ in range(0,q):
    ops = input().split()
    if ops[0] == 'print':
        a,b=map(int,ops[1:3])
        print(s[a:b+1])
    if ops[0] == 'reverse':
        a,b=map(int,ops[1:3])
        s = s[0:a] + s[a:b+1][::-1] + s[b+1:]
    if ops[0] == 'replace':
        a,b=map(int,ops[1:3])
        s = s[0:a] + ops[3] + s[b+1:]

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

int main(){
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	if((a+b) > (c+d)) cout << "Left" << endl;
	else if((a+b) == (c+d)) cout << "Balanced" << endl;
	else cout << "Right" << endl;
}

Measured memory_bytes: 256
import sys
input=sys.stdin.readline

def main():
    N = int(input())
    V = list(map(int, input().split()))
    C = list(map(int, input().split()))
    ans = 0
    for i in range(N):
        if V[i] > C[i]:
            ans += V[i] - C[i]
    print(ans)

if __name__ == '__main__':
    main()


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

using namespace std;
typedef long long ll;
int n;
ll sum0,sum1;
ll ans0,ans1;


int main() {
  cin >> n;
  for(int i = 0; i < n; i++) {
    ll a;
    cin >> a;
    sum0 += a; sum1 += a;
    if(i % 2 == 0) {
      if(sum0 >= 0) ans0 += sum0+1, sum0 = -1;
      if(sum1 <= 0) ans1 += 1-sum1, sum1 = 1;
    }
    else {
      if(sum0 <= 0) ans0 += 1-sum0, sum0 = 1;
      if(sum1 >= 0) ans1 += sum1+1, sum1 = -1;
    }
  }
      
  cout << min(ans0,ans1) << endl;
}
  


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;

int main()
{
	int X,A;
	cin >> X >> A;
	if (X < A) {
		cout << 0;
	}
	else {
		cout << 10;
	}
	return 0;
}


Measured memory_bytes: 256
/*
　　　  ∧＿∧　やあ
　　 （´・ω・｀)　　　　　/　　　　　ようこそ、バーボンハウスへ。
　　 ／∇y:::::＼　　　 [￣]　　　　　このテキーラはサービスだから、まず飲んで落ち着いて欲しい。
　　 |:⊃:|:::::|　　　|──|
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|　うん、「また」なんだ。済まない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣￣|￣　  仏の顔もって言うしね、謝って許してもらおうとも思っていない。
￣￣￣￣￣￣￣￣￣￣￣￣￣￣／|
　　　　∇　∇　∇　∇　　　／.／|　　　でも、この提出を見たとき、君は、きっと言葉では言い表せない
　　　　┴　┴　┴　┴　／ ／　  |　　　「ときめき」みたいなものを感じてくれたと思う。
￣￣￣￣￣￣￣￣￣￣|／　　  |　　　殺伐としたコンテストの中で、そういう気持ちを忘れないで欲しい
￣￣￣￣￣￣￣￣￣￣　　　　 |　　　そう思って、この提出を投げたんだ。
　　　(⊆⊇)　(⊆⊇)　(⊆⊇)　　|
　    ||　　 ||　　||　　|　　　 じゃあ、判定を聞こうか。
　　.／|＼　／|＼ ／|＼
*/

#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <array>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <ctype.h>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define fst first
#define snd second
#define ALL(obj) (obj).begin(),(obj).end()
#define debug(x) cerr << #x << " -> " << x << " (line:" << __LINE__ << ")" << '\n';
#define debugpair(x, y) cerr << "(" << #x << ", " << #y << ") -> (" << x << ", " << y << ") (line:" << __LINE__ << ")" << '\n';
typedef long long lint;
typedef priority_queue<int> p_que;
typedef priority_queue<int, vector<int>, greater<int>()> p_que_rev;
// const int INF = INT_MAX;
const lint LINF = LLONG_MAX;
const lint MOD = 1000000000 + 7;
const double EPS = 1e-9;
const double PI = acos(-1);
const int di[]{0, -1, 0, 1, -1, -1, 1, 1};
const int dj[]{1, 0, -1, 0, 1, -1, -1, 1};


int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    if(a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0){
        cout << "Possible" << endl;
    }
    else {
        cout << "Impossible" << endl;
    }
    return 0;
}

Measured memory_bytes: 504
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    m,n = LI()
    dp = collections.defaultdict(list)
    dm = collections.defaultdict(list)
    for i in range(m):
        k = I()
        for _ in range(k):
            s, c, t = LS()
            if c == '<=':
                dm[int(s)].append((int(t), i))
            else:
                dp[int(s)].append((int(t), i))

    e = collections.defaultdict(set)
    for k in list(dm.keys()):
        ml = dm[k]
        pl = dp[k]
        for tm, i in ml:
            for tp, j in pl:
                if tm < tp:
                    e[i].add(j)

    v = collections.defaultdict(int)

    def f(i):
        if v[i] == 2:
            return True
        if v[i] == 1:
            return False
        v[i] = 1

        for n in e[i]:
            if not f(n):
                return False
        v[i] = 2
        return True

    for i in range(m):
        if not f(i):
            return 'No'

    return 'Yes'




print(main())



Measured memory_bytes: 10644
from functools import lru_cache


@lru_cache(None)
def f(n):
    if n == 0:
        return 1
    elif n == 1:
        return 2
    elif n % 2 == 0:
        return (2 * f(n // 2 - 1) + f(n // 2)) % 1000000007
    else:
        return (2 * f(n // 2) + f(n // 2 - 1)) % 1000000007


n = int(input())
print(f(n))

Measured memory_bytes: 3684
import Control.Applicative
import Control.Monad
import Data.List

eval :: String -> Int
eval xs = sum . fmap read . words
        $ fmap (\c -> if c == '+' then ' ' else c) xs

f :: String -> [Bool] -> String
f xs bs = concat $ zipWith (\x b -> (g b) ++ [x]) xs bs
  where
    g True  = "+"
    g False = ""

main :: IO ()
main = do
    ss <- getLine
    let bss = fmap (False:) $ sequence (replicate (length ss - 1) [True, False])
    let cs = fmap (f ss) bss
    let ds = fmap eval cs
    print (sum ds)

Measured memory_bytes: 1020
n = gets.to_i
a = gets.chomp.split(" ").map(&:to_i)

#b = Array.new(n+1).map{Array.new}
h = Hash.new{|k,v| k[v]=0}

a.each_with_index do |n, i|
  t = [n, i+1].sort!
  h[t] += 1
  #b[n] << i+1
  #b[i+1] << n
end
p h.to_a.select{|t| t[1]==2}.size


#b.select{|t| }


Measured memory_bytes: 24196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 3e3 + 50;
const ll MOD = 998244353;

ll x;


int main() {
    cin>>x;
    ll a = x / 500;
    x = x - a * 500;
    ll b = x / 5;
    cout<<a * 1000 + 5 * b<<endl;

	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
typedef long long LL;
const int N = 200010;
const LL inf = 0x3f3f3f3f3f3f3f3f;
LL a[N];
LL sum[N];
LL g(int l,int r){
	return sum[r]-sum[l-1];
}
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int n;
	cin>>n;
	sum[0]=0;
	for(int i=1;i<=n;i++){
		scanf("%lld",&a[i]);
		sum[i]=sum[i-1]+a[i];
	}
	LL ans=inf;
	for(int i=1;i<n;i++){
		LL t=abs(g(i+1,n)-g(1,i));
		ans=min(ans,t);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3328
using System;

public class Test
{
	public static void Main()
	{
		// your code goes here
		int trout, playerA, playerB, difference;
		string[] line = Console.ReadLine().Split(' ');
		trout = int.Parse(line[0]);
		playerA = int.Parse(line[1]);
		playerB = int.Parse(line[2]);
		
		difference = Math.Abs(playerA - playerB);
		if((difference-1)%2==1)
		{
			Console.WriteLine("Alice");
		}
		else
		{
			Console.WriteLine("Borys");
		}
		//Console.WriteLine(difference-1);
	}
}

Measured memory_bytes: 11092