akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

int W, H;
vector< vs32 > field(50, vs32(50));

void dfs(int y, int x)
{
    field[y][x] = 0;

    for (int dy = -1; dy <= 1; ++dy)
    {
        for (int dx = -1; dx <= 1; ++dx)
        {
            int nx = x + dx;
            int ny = y + dy;
            if (IN(0, W, nx) && IN(0, H, ny) && field[ny][nx] == 1)
            {
                dfs(ny, nx);
            }
        }
    }

    return;
}

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

    while (true)
    {
        cin >> W >> H;
        if (H == 0 || W == 0) break;

        rep (i, H) rep (j, W) cin >> field[i][j];

        int ans = 0;
        rep (i, H)
        {
            rep (j, W)
            {
                if (field[i][j] == 1)
                {
                    dfs(i, j);
                    ++ans;
                }
            }
        }
        cout << ans << "\n";
    }

    return 0;
}



Measured memory_bytes: 3232
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <limits>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
#define DBG(X) cout << #X << "=" << (X) << '\n';
#define SAY(X) cout << (X) << '\n';
#else
#define DBG(X)
#define SAY(X)
#endif

#define M_PI       3.14159265358979323846

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

bool solve()
{
    std::string s;
    std::cin >> s;

    for (int i = 0; i < s.length(); i += 2)
    {
        if (s[i] == 'L')
            return false;
    }
    for (int i = 1; i < s.length(); i += 2)
    {
        if (s[i] == 'R')
            return false;
    }

    return true;
}

int main()
{
    if (solve())
        std::cout << "Yes" << std::endl;
    else
        std::cout << "No" << std::endl;

    return 0;
}


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

int main(void)
{
    int i = 0;
    int a = 0;
    int b = 0;
    int c = 0;
    char str[200][7] = {};
    int len = 0;

    while(scanf("%d %d",&a, &b) == 2){
        fflush(stdin);
        c = a + b;
        sprintf(str[i],"%d",c);
        len = strlen(str[i]);
        printf("%d\n", len);
        i++;
    }

    return 0;
}


Measured memory_bytes: 2032
ri = lambda: int(input())
rl = lambda: list(map(int,input().split()))
rr = lambda N: [ri() for _ in range(N)]
YN = lambda b: print('YES') if b else print('NO')
yn = lambda b: print('Yes') if b else print('No')
OE = lambda x: print('Odd') if x%2 else print('Even')
INF = 10**18
MOD=10**9+7

A,B=rl()
if A>=13:
    print(B)
elif A>=6:
    print(B//2)
else:
    print(0)

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

int main() {
    int N;
    cin >> N;
    int half=0;
    int result=0;
    for (int i=0;i<N;i++){
        int p;
        cin >> p;
        result+=p;
        if (half<p){
            half = p;
        }
    }
    cout << result-half*0.5 <<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#define MAX_N 1000000
int prime[MAX_N];
int is_prime[MAX_N + 1];

int main(){
	int p = 0;
	int n,i,j;

	while(scanf("%d",&n) != EOF){
		p=0;
		for(i=0; i<=n; i++){
			is_prime[i] = 1;
		}

		is_prime[0] = 0;
		is_prime[1] = 0;

		for(i=2; i<=n; i++){
			if(is_prime[i] == 1){
				p++;
				prime[p] = i;
				for(j=2*i; j<=n; j+=i){
					is_prime[j] = 0;
				}
			}
		}

		printf("%d\n",p);
	}
	
	return 0;
}

Measured memory_bytes: 6736
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) for(int i=(n)-1;0<=i;--i)
#define each(e,v) for(auto&& e:(v))
#define all(v) begin(v),end(v)
#define dump(x) cerr<<#x<<": "<<(x)<<endl
using namespace std;
using vint = vector<int>;
using ll = long long;
using vll = vector<ll>;
template <class T> void chmin(T& a, const T& b) { a = min(a, b); }
template <class T> void chmax(T& a, const T& b) { a = max(a, b); }
void yes() { cout << "Yes" << endl; exit(0); }
void no() { cout << "No" << endl; exit(0); }

int main() {
    int h, w, d; cin >> h >> w >> d;
    const int hw = h * w + 1;
    vint px(hw), py(hw);
    rep(y, h) rep(x, w) {
        int a; cin >> a;
        px[a] = x;
        py[a] = y;
    }
    int q; cin >> q;
    vint l(q), r(q);
    rep(i, q) cin >> l[i] >> r[i];

    vint cum(hw, 0);
    rep(i, hw - d) {
        cum[i+d] = cum[i] + abs(px[i+d] - px[i]) + abs(py[i+d] - py[i]);
    }

    rep(i, q) {
        cout << cum[r[i]] - cum[l[i]] << endl;
    }
    return 0;
}


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

using namespace std;

const int N = 100005;
vector <int> v[N];
int dp[N];

int cal(int x) {
	int &ret = dp[x];
	if (ret > -1e9) {
		return ret;
	}
	int sz = v[x].size();
	ret = 0;
	for (int i = 0; i < sz; i++) {
		ret = max(ret, cal(v[x][i]) + 1);
	}
	return ret;
}

int main() {
	int n, m;
	scanf("%d %d", &n, &m);
	for (int i = 1; i <= n; i++) {
		dp[i] = -1e9;
	}
	for (int i = 0; i < m; i++) {
		int x, y;
		scanf("%d %d", &x, &y);
		v[x].push_back(y);
	}
	int mx = -1e9;
	for (int i = 1; i <= n; i++) {
		mx = max(mx, cal(i));
	}
	printf("%d", mx);
	return 0;
}


Measured memory_bytes: 8192
S = input()
S = S[:-1]
for i in range(len(S)):
  if len(S) % 2 != 0:
    S = S[:-1]
  else:
    if S[:int(len(S)/2)] == S[int(len(S)/2):]:
      print(len(S))
      break
    else:
      S = S[:-2]
  

Measured memory_bytes: 2940
/*
  Compete against Yourself.
  Author - Aryan Choudhary (@aryanc403)
*/

#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")

#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define fo(i,n)   for(i=0;i<(n);++i)
#define repA(i,j,n)   for(i=(j);i<=(n);++i)
#define repD(i,j,n)   for(i=(j);i>=(n);--i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define endl "\n"

typedef long long int lli;
typedef long double mytype;
typedef pair<lli,lli> ii;
typedef vector<ii> vii;
typedef vector<lli> vi;

clock_t time_p=clock();
void aryanc403()
{
#ifdef ARYANC403
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
#endif
}

#ifdef ARYANC403
#include "/home/aryan/codes/PastCodes/header.h"
#else
    #define dbg(args...)
#endif

const lli INF = 0xFFFFFFFFFFFFFFFL;

lli seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline lli rnd(lli l=0,lli r=INF)
{return uniform_int_distribution<lli>(l,r)(rng);}

class CMP
{public:
bool operator()(ii a , ii b) //For min priority_queue .
{    return ! ( a.X < b.X || ( a.X==b.X && a.Y <= b.Y ));   }};

void add( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt==m.end())         m.insert({x,cnt});
    else                    jt->Y+=cnt;
}

void del( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt->Y<=cnt)            m.erase(jt);
    else                      jt->Y-=cnt;
}

bool cmp(const ii &a,const ii &b)
{
    return a.X<b.X||(a.X==b.X&&a.Y<b.Y);
}

const lli mod = 1000000007L;
// const lli maxN = 1000000007L;

    lli T,n,i,j,k,in,cnt,l,r,u,v,x,y;
    lli m;
    string s;
    vi a;
    //priority_queue < ii , vector < ii > , CMP > pq;// min priority_queue .

int main(void) {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    // freopen("txt.in", "r", stdin);
    // freopen("txt.out", "w", stdout);
// cout<<std::fixed<<std::setprecision(35);
// cin>>T;while(T--)
{

    cin>>m>>n;
    // a.clear();a.reserve(n);

    fo(i,n)
    {
        cin>>in;
        m-=in;
        // a.pb(in);
    }

    if(m>0)
        cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;

}   aryanc403();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll MOD = 1e9 + 7/*998244353*/;
const ll INF = 1LL << 60;
ll mod_pow(ll, ll, ll); ll mod_fact(ll, ll); ll mod_inv(ll, ll); ll gcd(ll, ll); ll lcm(ll, ll);
//
int main(){
    int n;
    cin >> n;
    vector<ll> s(n), l(n), p(n);
    for(int i = 0; i < n; i++) cin >> s[i] >> l[i] >> p[i];
    int m;
    cin >> m;
    vector<ll> w(m);
    ll wmx = 0;
    for(int i = 0; i < m; i++) {cin >> w[i]; wmx = max(wmx, w[i]);}
    vector<vector<ll>> dp(n + 1, vector<ll>(wmx + 1, -1));
    dp[0][0] = 0;
    for(int i = 1; i <= n; i++){
        int cs = s[i - 1], cl = l[i - 1], cp = p[i - 1];
        for(int j = 0; j <= wmx; j++){
            dp[i][j] = dp[i - 1][j];
            for(int k = j - cs; k >= 0 && k >= j - cl; k--){
                dp[i][j] = max(dp[i][j], dp[i][k] + cp);
            }
        }
    }
    for(int i = 0; i < m; i++) if(dp[n][w[i]] == -1) {cout << -1 << "\n"; return 0;}
    for(int i = 0; i < m; i++) cout << dp[n][w[i]] << "\n";
}


Measured memory_bytes: 4020
N = int(input())
h = list(map(int,input().split()))
dp=[0]*N
dp[1]=abs(h[1]-h[0])
for i in range(2,N):
    s1=dp[i-1]+abs(h[i]-h[i-1])
    s2=dp[i-2]+abs(h[i]-h[i-2])
    if s1<s2:
        dp[i]=s1
    else:
        dp[i]=s2

print(dp[N-1])

Measured memory_bytes: 13980
/* ~ Programmer >> Tushar Mahajan */
#include <iostream>
#include <bits/stdc++.h> 
using namespace std;
#define ll long long int
#define MOD 1000000007
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL); 

int main() {
	ios;
	ll n,q;
	ll sum=0;
	cin>>n;
	ll a[n];
	map<ll,ll> m; 
	for(int i=0;i<n;i++)
	{
	    cin>>a[i];
	    m[a[i]]++;
	    sum += a[i];
	}
	cin>>q;
	while(q--)
	{
	    ll b1,c1;
	    cin>>b1>>c1;
	    ll value = m[b1];
        sum = sum-(b1*value);
        sum = sum+(c1*value);
        m.erase(b1);
        m[c1] += value;
        cout<<sum<<endl;
	}
	return 0;
}


Measured memory_bytes: 8408
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <vector>
#include <cstring>
#include <algorithm>
#define Inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
int a[100010];
int vis[100010];
bool check(int n)
{
    while(n)
    {
        if(vis[n%10])
            return false;
        n/=10;
    }
    return true;
}
int main()
{
    int n,k;
    scanf("%d %d",&n,&k);
    memset(vis,0,sizeof(vis));
    for(int i=0; i<k; i++)
    {
        scanf("%d",&a[i]);
        vis[a[i]]=1;
    }
    for(int i=n; ; i++)
    {
        if(check(i))
        {
            printf("%d\n",i);
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	//freopen("input.txt", "r", stdin);
//	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	int x;
	cin >> x;
	puts((x < 1200) ? "ABC" : "ARC");
 
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int num1 = scan.nextInt();
        int num2 = scan.nextInt();
        int S = num1*num2;
        int L = 2*(num1+num2);
        System.out.println(S+" "+L);
        scan.close();
    }
}


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

int main() {
	// your code goes here
	int n;
	cin>>n;
	int f=0;
  long long int sum=0;
    for(long long int h=1;h<=n;h++)
    {
      if(h%3 !=0 && h%5 !=0)
        sum+=h;
    } 
    cout<<sum<<endl; 
	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define pb push_back

using namespace std;
typedef long long ll;

const int N=2e5+5,P=1e9+7;
inline int fpow(int a,int t){static int r;for(r=1;t;t>>=1,a=(ll)a*a%P)if(t&1)r=(ll)r*a%P;return r;}
int n,fac[N],ifac[N],ans=1,m,now;
inline int C(int n,int m){return (ll)fac[n]*ifac[m]%P*ifac[n-m]%P;}

bool vi[N];
vector<int>e[N];
int id[N],idc,s1,s2,fa[N],pa[N];

void dfs(int x){
	vi[x]=true;id[++idc]=x;
	if(x<=n)s1++;else s2++;
	sort(e[x].begin(),e[x].end());
	for(int v:e[x])if(fa[x]!=v){
		fa[v]=x;if(!vi[v])dfs(v);
	}
}
int find(int x){
	if(vi[x])return x; 
	vi[x]=true;
	int t=0;
	for(int v:e[x])if(pa[x]!=v){pa[v]=x,t=find(v);if(t)break;}
	vi[x]=false;
	return t;
}

int sz[N],in[N];
vector<int>E[N];

int solve(int x){
	int r=1;
	for(int v:E[x]){
		r=(ll)r*solve(v)%P;
		r=(ll)r*C(sz[x]+sz[v],sz[v])%P;
		sz[x]+=sz[v];
	}
	sz[x]++;
	return r;
}

int calc(){
	for(int i=1,u;i<=idc;i++)
		for(int x:e[u=id[i]]){
			if(x==fa[u])break;
			E[u].pb(x),in[x]++;
		}
	for(int i=1,u;i<=idc;i++)if(!in[u=id[i]])E[0].pb(u),in[u]++;
	int ans=solve(0);
	for(int i=0,u;i<=idc;i++)E[u=id[i]].clear(),in[u]=sz[u]=0;
	return ans;
}

int main(){
	scanf("%d",&n);
	fac[0]=1;
	for(int i=1;i<=2*n;i++)fac[i]=(ll)fac[i-1]*i%P;
	ifac[2*n]=fpow(fac[2*n],P-2);
	for(int i=2*n;i>=1;i--)ifac[i-1]=(ll)ifac[i]*i%P;
	for(int i=1,x,y;i<=2*n;i++)scanf("%d%d",&x,&y),e[x].pb(y+n),e[y+n].pb(x);
	for(int i=1;i<=2*n;i++)if(!vi[i]){
		int R=find(i);
		if(!R){ans=0;break;}
		dfs(R);
		int se=0;
		for(int k=1;k<=idc;k++)se+=e[id[k]].size();se>>=1;
		if(se!=s1+s2){ans=0;break;}
		now=calc();
		for(int x=pa[R]=fa[R];x!=R;x=pa[x]=fa[x]);
		fa[pa[R]]=R;
		for(int x=pa[R];x!=R;x=pa[x])fa[pa[x]]=x;
		now=(now+calc())%P;
		ans=(ll)ans*now%P*C(m+idc,m)%P;
		m+=idc;
		while(idc)id[idc--]=0;s1=s2=0;
	}
	printf("%d\n",ans);
	return 0;
}

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

public class Main {
	public static void main(String args[]) {

		FastScanner sc = new FastScanner();
		int n = sc.nextInt();
		int k = sc.nextInt();
		int q = sc.nextInt();

		int a[] = new int[n];
		for (int i = 0; i < q; i++) {
			a[sc.nextInt() - 1]++;
		}
		for (int x : a) {
			System.out.println(k + x - q <= 0 ? "No" : "Yes");
		}
	}
}

class FastScanner {
	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: 42944
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
int gcd(int a,int b){
    int GCD=1;
    rep(i,min(a,b)){
        if(a%(i+1)==0 && b%(i+1)==0) GCD=i+1;
    }
    return GCD;
}
int main(){
    int k;
    cin>>k;
    long long ans=0;
    rep(i,k){
        rep(j,k){
            rep(l,k){
                ans+=gcd((i+1),gcd(j+1,l+1));
            }
        }
    }
    cout<<ans;
}

Measured memory_bytes: 3608
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
import math
import bisect
import random
from itertools import permutations, accumulate, combinations
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor


INF = float('inf')
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LIM(): return list(map(lambda x:int(x) - 1, sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def S(): return sys.stdin.readline().strip()
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def LIRM(n): return [LIM() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 1000000007


s = S()
ans = 1
flag = 0
for i in range(1, len(s)):
    if flag:
        ans += 1
        flag -= 1
    elif s[i] != s[i-1]:
        ans += 1
    else:
        flag = 2



print(ans)

Measured memory_bytes: 40944
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>
#include<utility>
#include<numeric>

#define PB push_back
#define all(a)  (a).begin(),(a).end()
#define ALL(v) begin(v), end(v)
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)
#define V vector<int>
#define VV vector<V>
#define VVV vector<VV>

using namespace std;

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

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int inf = (int)1e9;
const ll INF = (ll)1e18;
const ll MOD{ (ll)1e9 + 7 };
const long double EPS = 1e-10;

int main() {
	int N, M, X, Y;
	cin >> N >> M >> X >> Y;
	int x[101], y[101];
	rep(i, N) cin >> x[i];
	rep(i, M) cin >> y[i];

	sort(x, x + N, greater<int>());
	sort(y, y + M);

	int num1 = x[0] + 1;
	int num2 = y[0];

	bool ans = false;
	
	if (num1 <= num2) {
		for (int i = num1; i <= num2; i++) {
			if (X < i && i <= Y) {
				ans = true;
				break;
			}
		}
	}

	if (ans) {
		cout << "No War" << endl;
	}
	else {
		cout << "War" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>

using namespace std;

template <class T>
using lp_queue=priority_queue<T, deque<T>, greater<T>>;

using Weight=long long;
static const Weight INF=1LL<<57;

struct Edge {
    size_t src, dst;
    Weight weight;
    Edge() {}
    Edge(size_t src, size_t dst, Weight weight=1):
        src(src), dst(dst), weight(weight)
    {}
};

bool operator<(const Edge &e, const Edge &f) {
    if (e.weight != f.weight) {
        return e.weight > f.weight;
    } else {
        return e.src!=f.src? e.src<f.src : e.dst<f.dst;
    }
}

using Edges=vector<Edge>;
using Vertex=vector<Edge>;
using Graph=vector<Vertex>;

void join(Graph &g, size_t s, size_t d, Weight w=1) {
    // non-directed
    g[s].push_back(Edge(s, d, w));
    g[d].push_back(Edge(d, s, w));
}

void connect(Graph &g, size_t s, size_t d, Weight w=1) {
    // directed
    g[s].push_back(Edge(s, d, w));
}

Weight visit(const Graph &g, Graph &h, size_t i, size_t j) {
    if (h[i][j].weight >= 0) return h[i][j].weight;

    h[i][j].weight = g[i][j].weight;
    size_t u=h[i][j].dst;
    for (size_t k=0; k<h[u].size(); ++k) {
        if (h[u][k].dst == i) continue;
        h[i][j].weight = max(h[i][j].weight, visit(g, h, u, k)+g[i][j].weight);
    }

    return h[i][j].weight;
}

vector<Weight> get_treeheight(const Graph &g) {
    size_t V=g.size();
    Graph h(g);
    for (size_t i=0; i<V; ++i)
        for (Edge &e: h[i])
            e.weight = -INF;

    for (size_t i=0; i<V; ++i)
        for (size_t j=0; j<h[i].size(); ++j)
            if (h[i][j].weight < 0)
                h[i][j].weight = visit(g, h, i, j);

    vector<Weight> height(V);
    for (size_t i=0; i<V; ++i)
        for (Edge &e: h[i])
            height[i] = max(height[i], e.weight);

    return height;
}

int main() {
    size_t V, E;
    scanf("%zu", &V);
    E = V-1;

    Graph g(V);
    for (size_t i=0; i<E; ++i) {
        size_t s, t, w;
        scanf("%zu %zu %lld", &s, &t, &w);

        join(g, s, t, w);
    }

    vector<Weight> height=get_treeheight(g);

    for (Weight w: height)
        printf("%lld\n", w);

    return 0;
}

Measured memory_bytes: 4988
#include<stdio.h>
#include<math.h>

#define M_PI 3.14159265358979

int main(void)
{
    int step, dig;
    double x, y, angle;

    x = 0;
    y = 0;
    angle = 0;

    while (1){
        scanf("%d,%d", &step, &dig);

        if (step == 0 && dig == 0){
            break;
        }

        x += (double)step * sin(angle * (M_PI / 180));
        y += (double)step * cos(angle * (M_PI / 180));
        angle += (double)dig;
    }

    printf("%d\n%d\n", (int)x, (int)y);

    return 0;
}

Measured memory_bytes: 1032
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.AGC_Challenge
{
    class _022_B
    {
        static void Main(string[] args)
        {
            Method(args);
            ReadLine();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            int[] res = new int[n];
            res[0] = 2;
            res[1] = 3;
            res[2] = 25;
            int i = 3;
            if (n % 2 == 0)
            {
                res[i] = 30;
                i++;
            }
            int now = 32;
            for (; i < n; i += 2)
            {
                while ((now % 2 > 0) && (now % 3 > 0) && (now % 5 > 0)) now++;
                res[i] = now;
                res[i + 1] = 30000 - now;
                now++;
            }
            for(int j = 0; j < n; j++)
            {
                Write(res[j]);
                if (j < n - 1) Write(" ");
            }
            WriteLine();
        }

        private static string Read() { return ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 13308
import java.util.*;
public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    if(a==b){
      System.out.println(c);
    }else if(b==c){
      System.out.println(a);
    }else{
      System.out.println(b);
    }
  }
}


Measured memory_bytes: 21716
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int D = sc.nextInt();
        int G = sc.nextInt();
        int[] p = new int[D];
        int[] c = new int[D];

        for (int i = 0; i<D; i++) {
            p[i] = sc.nextInt();
            c[i] = sc.nextInt();
        }

        System.out.println(solve(D, G, p, c));
    }

    private static int solve(int D, int G, int[] p, int[] c) {
        int ans = Integer.MAX_VALUE;

        for (int mask=0; mask<(1<<D); mask++) {
            int score = 0, num = 0, rest_max = -1;

            for (int i=0; i<D; i++) {
                if ((mask>>i & 1) == 1) {
                    score += 100 * (i+1) * p[i] + c[i];
                    num += p[i];
                } else {
                    rest_max = i;
                }
            }

            if (score < G) {
                int s1 = 100 * (rest_max + 1);
                int need = (G - score + s1 - 1) / s1;
                if (need >= p[rest_max]) {
                    continue;
                }

                num += need;
            }
            ans = Math.min(ans, num);
        }

        return ans;
    }
}


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

int main() {
  int n, t;
  cin >> n;
  vector<int> x(n), y(n), h(n);
  rep(i, n) {
    cin >> x[i] >> y[i] >> h[i];
    if (h[i] > 0) t = i;
  }

  rep(cx, 101) rep(cy, 101) {
    ll H = h[t] + abs(x[t] - cx) + abs(y[t] - cy);
    bool flag = true;
    rep(j, n) flag &= (h[j] == max(H - abs(x[j] - cx) - abs(y[j] - cy), 0LL));
    if (flag) {
      cout << cx << " " << cy << " " << H << endl;
      return 0;
    }
  }
  return 0;
}


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

int main(void){
    int line_number;
    int l, m, n;
    
    cin >> line_number; 

    for(int i = 0; i < line_number; i++){
        // gets input
        cin >> l >> m >> n;
        
        // check
        if(l*l+m*m==n*n || m*m+n*n==l*l || n*n+l*l==m*m){
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 3088
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a[200000],n,m,x,t,k;
    cin>>n>>k;

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

    sort(a,a+n);
    m = a[n-1];

    for(int i = 0; i < n; i++)
    {
        if(i+k-1 >= n)
        {
            break;
        }
        else
        {

            if(a[i+k-1]-a[i] < m)
            {
                m = a[i+k-1]-a[i];
                //cout<<a[i+k-1]<<" "<<a[i]<<" "<<i+k-1<<endl;
            }

        }
    }

    cout<<m<<endl;


}


Measured memory_bytes: 640
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define int long long
using namespace std;
const int N = 5e3 + 5, mod = 1e9 + 7;
int read() {
	int x = 0, f = 1; char ch;
	while(! isdigit(ch = getchar())) (ch == '-') && (f = -f);
	for(x = ch ^ 48; isdigit(ch = getchar()); x = (x << 3) + (x << 1) + (ch ^ 48));
	return x * f;
}
template <class T> T Max(T a, T b) { return a > b ? a : b; }
template <class T> T Min(T a, T b) { return a < b ? a : b; }
struct Edge {
	int to;
	Edge *nxt;
	Edge(int to, Edge *nxt) : to(to), nxt(nxt) {}
} *head[N];
void add(int x, int y) {head[x] = new Edge(y, head[x]);}
int n, g[N], siz[N], tmp[N], f[N][N];
void dfs(int x, int fa) {
	f[x][siz[x] = 1] = 1;
	for(Edge *i = head[x]; i; i = i->nxt) {
		if(i->to == fa) continue;
		dfs(i->to, x);
		for(int j = 0; j <= siz[x] + siz[i->to]; ++ j) tmp[j] = 0;
		for(int j = 1; j <= siz[x]; ++ j) {
			for(int k = 0; k <= siz[i->to]; ++ k) {
				(tmp[j + k] += f[x][j] * f[i->to][k]) %= mod;
			}
		}
		for(int j = 1; j <= n; ++ j) f[x][j] = tmp[j];
		siz[x] += siz[i->to];
	}
	for(int i = 2; i <= siz[x]; i += 2) (f[x][0] += mod - f[x][i] * g[i] % mod) %= mod;
}
signed main() {
	n = read();
	for(int i = 1, x, y; i < n; ++ i) x = read(), y = read(), add(x, y), add(y, x);
	for(int i = 2; i <= n; i += 2) g[i] = (i == 2) ? 1 : g[i - 2] * (i - 1) % mod;
	dfs(1, 0);
	printf("%lld\n", mod - f[1][0]); 
	return 0;
}


Measured memory_bytes: 196608
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n[3],m;
  rep(i,3) R n[i];
  R m;
  vector<ll> v[3];
  rep(k,3) {
    rep(i,n[k]) {
      ll x;
      R x;
      v[k].pb(x);
    }
  }
  priority_queue<ll,vector<ll>,greater<ll> > que;
  rep(i,n[0]) {
    rep(j,n[1]) {
      que.push(v[0][i]+v[1][j]);
      while(que.size()>m) que.pop();
    }
  }
  vector<ll> ans;
  while(!que.empty()) {
    ll x=que.top();que.pop();
    rep(i,n[2]) ans.pb(x+v[2][i]);
  }
  sort(all(ans),greater<ll>());
  rep(i,m) pr(ans[i]);
}

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


Measured memory_bytes: 35080
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    static Scanner in = new Scanner(System.in);
    public static void main(String[] args) {
        int N = in.nextInt();
        long K = in.nextInt();
        int Q = in.nextInt();
        long[] counts = new long[N];
        Arrays.fill(counts,0);
        for (int i = 0; i < Q; i++) counts[in.nextInt() - 1]++;
        for (int i = 0; i < N; i++) {
            if (K - ((long)Q - counts[i]) > 0L) {
                System.out.println("Yes");
            } else {
                System.out.println("No");
            }
        }
    }
}


Measured memory_bytes: 60132
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<functional>
using namespace std;
int flg[1000000];
int main(void)
{
	int n,i,j,cnt;
	while(scanf("%d",&n)!=EOF){
		for(i=2;i<=n;i++) flg[i]=1;
		for(i=2;i*i<=n;i++){
			if(flg[i]==1){
				for(j=2;i*j<=n;j++){
					flg[i*j]=0;
				}
			}
		}
		cnt=0;
		for(i=2;i<=n;i++){
			if(flg[i]==1) cnt++;
		}
		printf("%d\n",cnt);
	}
	return 0;
}
		

Measured memory_bytes: 4928
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pii;
const int N = 330;
ll dp[N][N];
struct edge {
  ll to, cost;
};
ll d[N], re[N];
vector<edge> G[N];
void bellman(int s, int n, int l) {
  vector<bool> used(n + 1);
  queue<int> que; que.push(s);
  used[s] = 1;
  while (que.size()) {
    int u = que.front(); que.pop();
    used[u] = 0;
    for (auto &e: G[u]) {
      int v = e.to, w = e.cost;
      if (re[u] >= w) {
        if (dp[s][v] == -1 || dp[s][v] > dp[s][u] || dp[s][v] == dp[s][u] && re[v] < re[u] - w) {
          dp[s][v] = dp[s][u];
          re[v] = re[u] - w;
          if (!used[v]) {
            que.push(v);
            used[v] = 1;
          }
        }
      } else {
        if (dp[s][v] == -1 || dp[s][v] > dp[s][u] + 1 || dp[s][v] == dp[s][u] + 1 && re[v] < l - w) {
          dp[s][v] = dp[s][u] + 1;
          re[v] = l - w;
          if (!used[v]) {
            que.push(v);
            used[v] = 1;
          }
        }
      }
    }
  }
}

int main() {
  ios::sync_with_stdio(false); cin.tie(0);
  int n, m, l, u, v, w;
  cin >> n >> m >> l;
  for (int i = 0; i < m; i++) {
    cin >> u >> v >> w;
    if (w <= l) G[u].push_back({v, w}), G[v].push_back({u, w});
  }
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= n; j++) {
      if (i != j) dp[i][j] = -1;
      re[j] = 0;
    }
    re[i] = l;
    bellman(i, n, l);
  }
  int q;
  cin >> q;
  while (q--) {
    cin >> u >> v;
    cout << dp[u][v] << '\n';
  }
}


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

string s;
int a[105];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin >> s;
    for(int i =0;i<s.length();i++){
        a[i]=(int)(s[i]-'a');
    }
    int ans = 105;
    for(int i= 0; i<26;i++){
        int tem=0,cnt = 0;
        for(int j= 0;j<s.length();j++ ){
            cnt ++;
            if(a[j] == i)cnt = 0;
            tem = max(tem , cnt);
        }
        ans = min(ans,tem);
    }
    cout<<ans<<endl;


    return 0;
}


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

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

const int INF = 1e9;
const long long LLINF = 1e18;

using namespace std;

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

/*==================================================*/
/*variable*/
int N;
int a[55];
/*==================================================*/
/*function*/

/*==================================================*/

int main() {
    cin>>N;

    int ti = 0, mx = 0;
    bool p = true;
    REP(i,0,N){
        cin>>a[i];
        if(mx < abs(a[i])){
            mx = abs(a[i]);
            ti = i;
            if(a[i] < 0) p = false;
            else p = true;
        }
    }


    cout<<(N-1)*2<<endl;
    REP(i,0,N){
        if(i != ti) cout<<ti+1<<" "<<i+1<<endl;
    }
    if(p) REP(i,0,N-1) cout<<i+1<<" "<<i+2<<endl;
    else RREP(i,0,N-1) cout<<i+2<<" "<<i+1<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a[500010];
struct Node{
	int l,r,no;
}b[500010];
int la[500010],val[500010],ans[500010],n,q;
bool cmp(Node a,Node b){
	if(a.r==b.r)return a.l<b.l;
	return a.r<b.r;
}
void upd(int i,int k){
	while(i<=n){
		val[i]+=k;
		i+=i&(-i);
	}
}
int getsum(int i){
	int ans=0;
	while(i){
		ans+=val[i];
		i-=i&(-i);
	}
	return ans;
}
int main(){
	scanf("%d%d",&n,&q);
	for(int i=1;i<=n;i++)scanf("%d",&a[i]);
	for(int i=0;i<q;i++){
		scanf("%d%d",&b[i].l,&b[i].r);
		b[i].no=i;
	}
	sort(b,b+q,cmp);
	int r=0;
	for(int i=0;i<q;i++){
		while(r<b[i].r){
			r++;
			if(la[a[r]])upd(la[a[r]],-1);
			upd(r,1);
			la[a[r]]=r;
		}
		ans[b[i].no]=getsum(b[i].r)-getsum(b[i].l-1);
	}
	for(int i=0;i<q;i++)printf("%d\n",ans[i]);
} 

Measured memory_bytes: 17408
function Main(input) {
    // inputにはすべての入力の文字列が与えられるので必要に応じて input.split("\n") などで分割する。

    var data = input.split("\n")

    var first_line = data[0].split(" ")



    console.log(Math.ceil(first_line[0]/first_line[1]));
}

// Don't edit this line!
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

ll compute(int ind, set<int> &st){
	auto rit = st.upper_bound(ind);
	auto lit = st.upper_bound(ind); lit--;
	int r1 = *rit; rit++;
	int l1 = *lit;
	if(rit == st.end()){
		lit--; int l2 = *lit;
		return (r1 - ind)*1LL*(l1 - l2);
	}
	if(lit == st.begin()){
		int r2 = *rit;
		return (ind - l1)*1LL*(r2 - r1);
	}
	int r2 = *rit;
	lit--; int l2 = *lit;
	return (r1 - ind)*1LL*(l1 - l2) + (ind - l1)*1LL*(r2 - r1);
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	cout<<setprecision(32);

	int n; cin>>n;
	vector<int> p(n + 1);
	for(int i = 1; i <= n; i++){
		int x; cin>>x;
		p[x] = i;
	}
	set<int> st;
	st.insert(0);
	st.insert(p[n]);
	st.insert(n + 1);
	ll ans = 0;
	for(int i = n - 1; i >= 1; i--){
		ans += i*compute(p[i], st);
		st.insert(p[i]);
	}
	cout<<ans<<endl;

	return 0;
}

Measured memory_bytes: 5376
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<queue>
#include<iomanip>
#include<cstring>
using namespace std;
int cmp(long long a,long long b){
	return a>b;
}
long long C(long long a,long long b){
	long long ans=1;
	for(int i=1;i<=a;i++){
		ans*=(b-i+1);ans/=i;
	}
	return ans;
}
int n;
long long a,b;
long long s[100001];
int main()
{
   scanf("%d%lld%lld",&n,&a,&b);
   for(int i=1;i<=n;i++){
   	scanf("%lld",&s[i]);
   }
   sort(s+1,s+n+1,cmp);
   if(s[1]==s[a]){
   	cout<<fixed<<setprecision(6)<<double(s[1])<<endl;
   	long long t=0;
	   long long ans=0; 
   	s[n+1]=s[1]+1;
   	for(int i=1;i<=n+1;i++){
   	   if(s[i]!=s[1]){
   	   	t=i-1;
   	   	break;
	   } 	
	}
	for(int i=a;i<=min(b,t);i++){
		ans+=C(t-i,t);
	}
	cout<<ans;
   }
   else {
   	double ans=0;
   	   for(int i=1;i<=a;i++){
              ans+=s[i];  	
	   }
	   ans/=a;
	   cout<<fixed<<setprecision(6)<<ans<<endl;
	   long long l=0;
	   int place=111111;
	   for(int i=1;i<=n;i++){
	   	   if(s[i]==s[a]) l++,place=min(place,i);
	   } 
	   ans=C(a-place+1,l);
	   cout<<(long long)(ans);
   } 
	return 0;
}

Measured memory_bytes: 256
def calc(start, C, S, F):
    time = 0
    pos = start
    while pos < N:
        #駅posから駅pos+1に移動
        #電車を待つところから到着するまでの経過を記述
        if time == 0: #初期位置
            time += S[start] + C[start]
        else:
            if time < S[pos]:
                time = S[pos] + C[pos]
            else:
                if (time - S[pos]) % F[pos] != 0:
                    time += F[pos] - ((time - S[pos]) % F[pos]) + C[pos]
                else:
                    time += C[pos] 
        pos += 1
    return time

N = int(input())
C = [0]
S = [0]
F = [0]
for i in range(1, N):
    temp = list(map(int,input().split()))
    C.append(temp[0])
    S.append(temp[1])
    F.append(temp[2])

for i in range(1, N+1):
    print(str(calc(i, C, S, F)))

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

int size = 1;
vector<long> segtree;

void change(int k, long x){
    k += size - 1;
    segtree[k] += x;
    while(k > 0){
        k = (k - 1) / 2;
        segtree[k] = segtree[k * 2 + 1] + segtree[k * 2 + 2];
    }
}

long sum(int a, int b, int l, int r, int now){
    if(r <= a || b <= l){
        return 0;
    }else if(a <= l && r <= b){
        return segtree[now];
    }else{
        return sum(a, b, l, (l + r) / 2, now * 2 + 1) + sum(a, b, (l + r) / 2, r, now * 2 + 2);
    }
}

int main(){
    int n, q;
    cin >> n >> q;
    while(size < n){
        size *= 2;
    }
    segtree.resize(size * 2 - 1, 0);
    for(int i = 0; i < q; i++){
        int com;
        cin >> com;
        if(com){
            int x, y;
            cin >> x >> y;
            cout << sum(x - 1, y, 0, size, 0) << endl;
        }else{
            int x, y;
            cin >> x >> y;
            change(x - 1, y);
        }
    }
}



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

using namespace std;
using ll = long long;

#define rep(i,N) for(int i=0;i<(int)N;++i)

ll GCD(ll x, ll y) {
    if (y == 0) return x;
    else return GCD(y, x % y);
}
int main()
{
    string N;
    cin >> N;

    if (N[0] == N[2]) { cout << "Yes" << endl; }
    else { cout << "No" << endl; }

}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	char s[200001],t[200001];
	int change[26]={-1},change2[26],i;
	for(i=0;i<26;i++){
		change[i]=-1;
		change2[i]=-1;
	}
	scanf("%s%s",s,t);
	for(i=0;s[i]!=0;i++){
		if(change[s[i]-'a']==-1||change[s[i]-'a']==t[i]-'a'){
			change[s[i]-'a']=t[i]-'a';
		}else {
			puts("No");
			return 0;
		}
		if(change2[t[i]-'a']==-1||change2[t[i]-'a']==s[i]-'a'){
			change2[t[i]-'a']=s[i]-'a';
		}else {
			puts("No");
			return 0;
		}
	}
	puts("Yes");
	return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<string>
#include<queue>
#include<algorithm>
#include<utility>
#include<vector>
#include<list>
using namespace std;
int main() {
	int a[8], hit = 0, blow = 0, k = 0, f, cnt=0;
	while (cin >> f) {
		a[k] = f;
		k++;
		if (k % 8 == 0) {
			for (int i = 0; i < 4; ++i) {
				if (a[i] == a[i+4]) {
					hit++;
					a[i] = -1;
					a[i+4] = -1;
					continue;
				}
				for (int j = 0; j < 4; ++j) {
					if (a[i] == a[j+4] )blow++;
				}
			}
			cout << hit << " " << blow << endl;
			k = 0;
			hit = 0;
			blow = 0;
		}
	}
	return 0;
}


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

#define REP(i,n) for(int i = 0; i < n; i++)
#define ll long long
#define PI 3.141592653589

#define MAX_M 10
#define MAX_N 100000
#define INF 200000

using namespace std;

int main(){
    int X, m = 6, c[MAX_M];
    cin >> X ;
    for (int i = 0; i < m; ++i) {
        c[i] = 100 + i;
    }
    int dp[MAX_M + 1][MAX_N + 1];
    fill(dp[0], dp[0] + X + 1, INF);
    dp[0][0] = 0;
    for (int i = 0; i < m; ++i) {
        for (int j = 0; j <= X; ++j) {
            if (j >= c[i]) {
                dp[i + 1][j] = min(dp[i][j], dp[i + 1][j - c[i]] + 1);
            } else {
                dp[i + 1][j] = dp[i][j];
            }
        }
    }
    if(dp[m][X] == INF) cout << 0;
    else cout << 1;
    return 0;
}

Measured memory_bytes: 4352
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
using ll = long long;
#define rep(i,n) for (ll i=0;i<n;i++)
using namespace std;

void solve(){

}
int main (){
    ios::sync_with_stdio(0);
    cin.tie(0);
    ll n;
    cin >> n;
    // vector<pair<ll,ll>> a(n);
    vector<ll> w(n);
    vector<ll> q(n);
    rep(i,n){
        // cin >> a[i].first >> a[i].second;
        ll a,b;
        cin >> a >> b;
        w[i] = a+b;
        q[i] = a-b;

    }
    sort(w.begin(),w.end());
    sort(q.begin(),q.end());
    ll ans;
    ans = w[n-1] - w[0];
    ans = max(ans,q[n-1]-q[0]);

    cout << ans << endl;


    return 0;
}

Measured memory_bytes: 6344
// 105
// 所要時間 分
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); ++i)
#define REP(i, d, n) for(int i=(d); i<(n); ++i)
#define all(v) v.begin(), v.end()
using ll = long long;
using P = pair<int, int>;

int main() {

    int n;
    cin >> n;

    int ans = 0;
    for(int i=105; i<=n; ++i){
        if(i % 2 == 0){
            continue;
        }
        int cnt = 0;
        for(int j=1; j<=i; ++j){
            if(i % j == 0){
                cnt++;
            }
        }
        if(cnt == 8){
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
//#include<tuple>
#include<string>
#include<assert.h>
//#include<chrono>
//#include<functional>
//#include<iterator>
//#include<random>
//#include<unordered_set>
//#include<unordered_map>
//#include<array>
//#include<map>
//#include<bitset>
//#include<iomanip>
//#include<list>
//#include<numeric>
using namespace std;
typedef unsigned long long int ulint;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=(int)1e9+7;
const llint big=(llint)(2.19e15+1);
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
/*template <class T,class U>bool mineq(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool maxeq(T& a,U b){if(a<b){a=b;return true;}return false;}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
llint gcd(llint a,llint b){if(a%b==0){return b;}else{return gcd(b,a%b);}}
llint lcm(llint a,llint b){return a/gcd(a,b) *b;}
template<class T,class U> auto LB(T& ve,U in){return lower_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto UB(T& ve,U in){return upper_bound(ve.begin(),ve.end(),in);}
template<class T,class U> auto LBI(T& ve,U in){return LB(ve,in)-ve.begin();}
template<class T,class U> auto UBI(T& ve,U in){return UB(ve,in)-ve.begin();}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}*/
bool mineq(llint& a,llint b){if(a>b){a=b;return true;}return false;}
bool maxeq(llint& a,llint b){if(a<b){a=b;return true;}return false;}
int main(void){
	int n,i;cin>>n;
	llint ans=-big,sai=big;
	for(i=0;i<n;i++){
		llint a;cin>>a;
		maxeq(ans,a-sai);
		mineq(sai,a);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3100