akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
#define REP(i,n) for (int i = 1; i < (int)(n); i++)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define debug(var) do{cout << #var << " : "; view(var);}while(0)
template<class T> bool chmin(T &a, T b) {if(a>b) {a=b;return 1;}return 0;}
template<class T> bool chmax(T &a, T b) {if(a<b) {a=b;return 1;}return 0;}
using namespace std;
template<class T> void view(T e) {cout << e << endl;}
template<class T> void view(const vector<T> &v) {for(const auto &e : v){cout << e << " ";} cout << endl;}
template<class T> void view(const vector<vector<T>> &vv) {for(const auto &v : vv){view(v);}}
using vint = vector<int>;
using vvint = vector<vector<int>>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<int,int>;
const int inf = 1e9;
const ll inf_l = 1e18;
const int MAX = 1e5;

int main() {
    int n; cin >> n;
    vint a(n);
    rep(i,n) {
        int x; cin >> x;
        x--;
        a[i] = x;
    }
    int ans = 0;
    rep(i,n) {
        if (a[a[i]] == i) ans++;
    }
    ans /= 2;
    cout << ans << endl;
}

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

int main(void)
{
    char s[100][101],t[101];
    int n,l,i,j;
    scanf("%d%d",&n,&l);
    for(i=0;i<n;i++)scanf("%s",s[i]);
    for(i=0;i<n-1;i++){
        for(j=n-1;j>i;j--){
            if(strcmp(s[j-1],s[j])>0){
                strcpy(t,s[j-1]);
                strcpy(s[j-1],s[j]);
                strcpy(s[j],t);
            }
        }
    }
    for(i=0;i<n;i++)printf("%s",s[i]);
    return 0;
}

Measured memory_bytes: 128
n,x=map(int,input().split())
a=list(map(int,input().split()))
eat=0
for i in range(n-1):
  wa=a[i]+a[i+1]
  if wa>x:
    sa=wa-x
    eat+=sa
    if sa<=a[i+1]:
      a[i+1]-=sa
    else:
      a[i+1]=0
print(eat)


Measured memory_bytes: 14160
#include<iostream>

using namespace std;

int summorize(int rest,int AB,int smaller,int bigger_value)
{
   return 2 * AB * smaller + rest * bigger_value;
   
}

int summorize(int AB,int bigger)
{

	return 2 * AB * bigger;
	
}


int main(void){
	
	int A,B,AB;
	
	int X,Y;
	
	int sum1 = 0;
	int sum2 = 0;
	int rest;
	
	int c;
	
	cin >> A >> B >> AB >> X >> Y;
	
	if(2 * AB < A + B){
		
		if( X < Y){
			
			rest = Y - X;
			
			sum1  = summorize(rest,AB,X,B);
			sum2 = summorize(AB,Y);
			
			c = sum1 < sum2 ? sum1 : sum2;
			
			cout << c;
			
		}else{
					
			
			rest = X - Y;
			
			sum1 = summorize(rest,AB,Y,A);
			sum2 = summorize(AB,X);
			
			c = sum1 < sum2 ? sum1 : sum2;
			
			cout << c;
			
		}
		
	}else{
		
		
		cout << X * A + Y * B;
		
	}
	
	return 0;
	
}

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

void solve(){
	long long a1 = 1, a2 = 1, a3 = 1;
    int n;
    cin >> n;
    for (int i = 1; i <= n; i++) a1 = a1 * 10 % mod, a2 = a2 * 9 % mod, a3 = a3 * 8 % mod;
    a1 = a1 - a2 * 2 + a3;
    a1 %= mod;
    if (a1 < 0) a1 += mod;
    cout << a1 << endl;
}

int main(){

/*#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif*/
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	//int t;cin >> t;while(t--){solve();}
	solve();
	return 0;
}

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

int main() {
	uint32_t H, W;
	cin >> H >> W;

	uint32_t mod = pow(10, 9) + 7;

	vector<uint32_t> cmb(W);
	cmb[0] = 1;

	for(uint32_t i=0; i<H; i++) {
		string l;
		cin >> l;
		
		for(uint32_t j=0; j<W; j++) {
			if(l[j] != '.'){
				cmb[j] = 0;
			} else if(j > 0) {
				cmb[j] = (cmb[j-1] + cmb[j]) % mod;
			} else {
				cmb[j] = cmb[j];
			}
		}
	}

	cout << cmb[W-1] << endl;
	return 0;

}

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

int main() {
  int N;
  cin >> N;
  double a = N/2;
  
  cout << fixed << setprecision(10);
  if(N % 2 ==0) cout << a / N << endl;
  else cout << (a+1) /N << endl;
}

Measured memory_bytes: 3784
import sys
N = int(input())
L = list(map(int, input().split()))

isZero = False
for l in L:
    if (l == 0):
        isZero = True

if (isZero):
    print(0)
else:
    a = 1
    maxV = 1e+18
    for l in L:
        a *= l
        if (a > maxV):
            print(-1)
            sys.exit()

    print(a)


Measured memory_bytes: 21608
#include <stdio.h>

#define MIN_VAL -1000000
#define MAX_VAL  1000000


int main(void){

    int i, n;
    int min_a, max_a;
    long sum_a;

    //initialize
    min_a = MAX_VAL;
    max_a = MIN_VAL;

    //input
    scanf("%d", &n);
    int a[n];

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

        //calc_min
        if(a[i]<min_a){
            min_a = a[i];
        }

        //calc_max
        if(max_a<a[i]){
            max_a = a[i];
        }

        //calc_sum
        sum_a += a[i];

    }

    //output
    printf("%d %d %ld\n", min_a, max_a, sum_a);

    return 0;

}

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

int main() {

  while(1) {

    int n;
    cin >> n;
    if(n == 0) break;

    int min = 1000000;
    int fee;
    for(int i=0;i<=n/200+1;i++) {
      for(int j=0;j<=n/300+1;j++) {
	for(int k=0;k<=n/500+1;k++) {
	  if(i*200+j*300+k*500 == n) {
	    fee = i*380 + j*550 + k*850;
	    if(i>=5) fee += ((i/5)*5*380)*0.8 -(i/5*5*380);
	    if(j >=4)fee += ((j/4)*4*550)*0.85 -(j/4*4 * 550);
	    if(k>=3) fee += ((k/3)*3*850)*0.88 -(k/3*3 * 850);
	    //cout <<i<<"*"<<j<<"*"<<k<<"="<< fee << endl;
	    if(min > fee) min = fee;
	  }
	}
      }
    }

    cout << min << endl;
  }

  return 0;

}

Measured memory_bytes: 1160
# Template 1.0
import sys, re
from decimal import *
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, floor, trunc, log
from heapq import heappush, heappop, heapify, nlargest, nsmallest
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def sortListWithIndex(listOfTuples, idx):   return (sorted(listOfTuples, key=lambda x: x[idx]))
def sortDictWithVal(passedDic):
    temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
    toret = {}
    for tup in temp:
        toret[tup[0]] = tup[1]
    return toret
def sortDictWithKey(passedDic):
    return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


x = INT()
ans = 360
for i in range(1, 361):
    if((360*i)%x==0):
        ans = (360*i)//x
        break
print(ans)


'''

k = (360*n)/x

if x==7
    n is 7
    
    


'''

Measured memory_bytes: 77188
#include <cstdio>
using namespace std;
typedef long long ll;
const int NC = 1e7 + 5, Mod = 998244353;
int Ml(int x, int y) { return (ll)x * y % Mod; }
int Ad(int x, int y) { return ((x + y) > Mod) ? (x + y - Mod) : (x + y); }
int Dc(int x, int y) { return ((x - y) < 0) ? (x - y + Mod) : (x - y); }
int ksm(int x, int y) {
	int ret = 1;
	for (; y; y >>= 1, x = Ml(x, x))
		if (y & 1) ret = Ml(ret, x);
	return ret;
}
int N, half, fac[NC], ifac[NC];
void Init() {
	fac[0] = 1;
	for (int i = 1; i <= N; ++i)
		fac[i] = Ml(fac[i-1], i);
	ifac[N] = ksm(fac[N], Mod - 2);
	for (int i = N-1; i >= 0; --i)
		ifac[i] = Ml(ifac[i+1], i+1);
}
int binom(int x, int y) {
	if (x < 0 || y < 0 || x < y)
		return 0;
	else {
		return Ml(fac[x], Ml(ifac[y], ifac[x-y]));
	}
}
int main() {
	scanf("%d", &N);
	half = N / 2 + 1;
	int ans = 0;
	Init();
	for (int i = half; i <= N; ++i) {
		ans = Ad(ans, Ml(binom(N, i), ksm(2, N-i)));
	}
	ans = Dc(ksm(3, N), Ml(ans, 2));
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 81324
s = str(input())
  
if s == 'SAT':
  print('1')
  
elif s == 'FRI':
  print('2')
  
elif s == 'THU':
  print('3')
  
elif s == 'WED':
  print('4')

elif s == 'TUE':
  print('5')
  
elif s == 'MON':
  print('6')

else:
  print('7')


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

// -------------------
// ここから先は変更しない
// -------------------
int main() {
  string name;
  int A,B;
  int num = 0;
  cin >> A >> name >> B;
  if(name=="+"){
    num = A+B;
  }else if(name =="-"){
    num = A-B;
  }
  cout << num << endl;
}


Measured memory_bytes: 3604
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
using namespace std;

int main (void) {
  string s;
  cin >> s;
  bool flag= true;
  int N=s.length();
  sort(s.begin(), s.end());
  for (int i=0; i<=N-1; i++) {
    if (s[i] == s[i+1]){
      cout << "no";
      flag =false;
      break;
    }
  }
  if (flag) {
  cout << "yes";
  }
}

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

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

  cin >> a >> b >> c;

  if ( (a[a.length() - 1] == b[0])
       && (b[b.length() - 1] == c[0]) )
    cout << "YES" << endl;
  else
    cout << "NO" << endl;

  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream> 
#include <vector>

#define debug(...) fprintf(stderr, __VA_ARGS__)

using namespace std;

inline char nc()
{
//	return getchar();
	static char buf[100000], *l = buf, *r = buf;
	return l==r&&(r=(l=buf)+fread(buf,1,100000,stdin),l==r)?EOF:*l++;
}
template<class T> void read(T &x)
{
	x = 0; int f = 1, ch = nc();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=nc();}
	while(ch>='0'&&ch<='9'){x=x*10-'0'+ch;ch=nc();}
	x *= f; 
}

const int inf = 1e9;

const int MAXN = 100 + 5;
int N, M;
int B[MAXN][MAXN];
int C[MAXN][MAXN];
vector<int> cnt[MAXN][MAXN];

const int maxnode = MAXN << 1;
int st, ed;
int head[maxnode];
struct edge
{
	int to, nex, cap, flow;
	edge(int to=0,int nex=0,int cap=0,int flow=0):to(to),nex(nex),cap(cap),flow(flow){}
};
vector<edge> G;
inline void addedge(int u, int v, int w)
{
	G.push_back(edge(v, head[u], w, 0)), head[u] = G.size() - 1;
	G.push_back(edge(u, head[v], 0, 0)), head[v] = G.size() - 1;
}
namespace dinic
{
	int cur[maxnode];
	int dis[maxnode];
	bool BFS()
	{
		static int q[maxnode]; int hd = 0, tl = 0;
		memset(dis, -1, sizeof(dis));
		dis[st] = 0;
		q[tl++] = st;
		while(hd < tl)
		{
			int u = q[hd++];
			for(int i = head[u]; ~i; i = G[i].nex) if(G[i].cap != G[i].flow)
			{
				int v = G[i].to;
				if(dis[v] == -1)
				{
					dis[v] = dis[u] + 1;
					q[tl++] = v;
				}
			}
		}
		return dis[ed] != -1;
	}
	int DFS(int u, int flow)
	{
		if(u == ed || flow == 0) return flow;
		int rec = flow;
		for(int &i = cur[u]; ~i; i = G[i].nex)
		{
			int v = G[i].to;
			if(dis[v] == dis[u] + 1)
			{
				int d = DFS(v, min(flow, G[i].cap - G[i].flow));
				G[i].flow += d;
				G[i ^ 1].flow -= d;
				flow -= d;
				if(flow == 0) break;
			}
		}
		return rec - flow;
	}
	int maxflow()
	{
		int flow = 0;
		while(BFS())
		{
			memcpy(cur, head, sizeof(head));
			flow += DFS(st, inf);
		}
		return flow;
	}
}

void sol(int id)
{
	memset(head, -1, sizeof(head)), G.clear();
	st = 0, ed = (N << 1) + 1;
	for(int i = 1; i <= N; ++i)
	{
		addedge(st, i, 1);
		addedge(N + i, ed, 1);
		for(int j = 0; j < N; ++j) if(cnt[i][j].size())
		{
			addedge(i, N + j + 1, 1);
		}
	}
	dinic :: maxflow();
	for(int u = 1; u <= N; ++u)
	{
		for(int i = head[u]; ~i; i = G[i].nex) if(G[i].cap == G[i].flow)
		{
			int c = G[i].to - N - 1;
			B[u][id] = cnt[u][c].back();
			C[c + 1][id] = B[u][id];
			cnt[u][c].pop_back();
		}
	}
}

int main()
{
	read(N), read(M);
	for(int i = 1; i <= N; ++i) for(int j = 1; j <= M; ++j)
	{
		int x; read(x); 
		int c = (x - 1) / M;
		cnt[i][c].push_back(x);
	}
	for(int i = 1; i <= M; ++i) sol(i);
	for(int i = 1; i <= N; ++i)
	{
		for(int j = 1; j <= M; ++j)
		{
			if(j != 1) printf(" ");
			printf("%d", B[i][j]);
		}
		printf("\n");
	}
	for(int i = 1; i <= N; ++i)
	{
		for(int j = 1; j <= M; ++j)
		{
			if(j != 1) printf(" ");
			printf("%d", C[i][j]);
		}
		printf("\n");
	}
	return 0;
}

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


int main() {
  int N,M;
  cin >>N>>M;
  vector<int>a(M),b(M);
  rep(i,M){
    cin>>a.at(i)>>b.at(i);
    a.at(i)--;
    b.at(i)--;
  }
  int ans=0;
  rep(l,M){
  vector<vector<int>>d(N,vector<int>(N));
  rep(i,N){
    rep(j,N){
      if(i==j){
        d.at(i).at(j)=0;
      }
      else{
        d.at(i).at(j)=1001001001;
      }
    }
  }
  rep(i,M){
    if(i!=l){
    d.at(a.at(i)).at(b.at(i))=1;
    d.at(b.at(i)).at(a.at(i))=1;
    }
  }
  for(int k = 0; k < N; k++) {
    for(int i = 0; i < N; i++) {
      for(int j = 0; j < N; j++) {        
        d[i][j] =min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
  
  bool ch=false;
  rep(i,N){
    rep(j,N){
      if(d[i][j]==1001001001){
        ch=true;
      }
    }
  }
  if(ch){
    ans++;
  }
  }
  
    
  cout<<ans<<endl;
  
}



Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<cmath>
#include<algorithm>
#include <string>
#include <utility>
#define EPS (1e-7)
using namespace std;




int main() {

	int N;
	cin >> N;
	int a;
	int ans = 0;
	for (size_t i = 0; i < N; i++)
	{
		cin >> a;
		while (true) {
			if (a % 2 == 0) {
				a = a / 2;
				ans += 1;
			}
			else {
				break;
			}
		}
	}
	cout << ans <<endl;

	return 0;
}

Measured memory_bytes: 256
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
int main()
{
	lint n,a,mx=0;
	cin>>n;
	rep(i,5){
		cin>>a;mx=max(mx,(a+n-1)/a);
	}
	cout<<mx+4<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int n;
    int i;
    int a,b,c;
    int temp;
    
    scanf("%d",&n);
    
    for(i=0;i<n;i++){
        //長さの比較、cに最長の辺を入れる
        scanf("%d %d %d",&a,&b,&c);
        if(a>c){
            temp=c;
            c=a;
            a=temp;
        }
        if(b>c){
            temp=c;
            c=b;
            b=temp;
        }
        
        if(c*c==(a*a+b*b)){
            printf("YES\n");
        }else{
            printf("NO\n");
        }
    }
    
    return 0;
}

Measured memory_bytes: 576
S=input()
T=input()
a=[ord(i) for i in S]
b=[ord(i) for i in T]
N=len(a);M=len(b)
X=[[0 for j in range(M+1)] for i in range(N+1)]
Y=[[0 for j in range(M+1)] for i in range(N+1)]
for i in range(N):
    for j in range(M):
        if a[i]==b[j]:
            X[i+1][j+1]=X[i][j]+1
            Y[i+1][j+1]=0
        elif X[i+1][j]<X[i][j+1]:
            X[i+1][j+1]=X[i][j+1]
            Y[i+1][j+1]=+1
        else:
            X[i+1][j+1]=X[i+1][j]
            Y[i+1][j+1]=-1
c=[]
i=N;j=M
while(i>0 and j>0):
    if Y[i][j]>0:
        i-=1
    elif Y[i][j]<0:
        j-=1
    else:
        c.append(a[i-1])
        i-=1
        j-=1
print("".join([chr(i) for i in c[::-1]]))


Measured memory_bytes: 193800
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>
#include <unordered_map>

using namespace std;
using ll = long long;

int main() {
	int n, x;
	while (cin >> n >> x) {
		if (n == 0 && x == 0) break;
		int count = 0;
		for (int i = 1; i <= n - 2; i++) {
			for (int j = i + 1; j <= n - 1; j++) {
				for (int k = j + 1; k <= n; k++) {
					if (i + j + k == x) count++;
				}
			}
		}
		cout << count << endl;
	}
	return 0;
}


Measured memory_bytes: 3080
use std::io::{Read, Write};

fn run() {
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let n: usize = it.next().unwrap().parse().unwrap();
    let m: usize = it.next().unwrap().parse().unwrap();
    let l: u64 = it.next().unwrap().parse().unwrap();
    let inf = 1_000_000_000u64 * 300;
    let mut g = vec![vec![inf; n]; n];
    for i in 0..n {
        g[i][i] = 0;
    }
    for _ in 0..m {
        let a: usize = it.next().unwrap().parse::<usize>().unwrap() - 1;
        let b: usize = it.next().unwrap().parse::<usize>().unwrap() - 1;
        let c: u64 = it.next().unwrap().parse().unwrap();
        if c <= l {
            g[a][b] = c;
            g[b][a] = c;
        }
    }
    for k in 0..n {
        for i in 0..n {
            for j in 0..n {
                g[i][j] = std::cmp::min(g[i][j], g[i][k] + g[k][j]);
            }
        }
    }
    for i in 0..n {
        for j in 0..n {
            if g[i][j] > 0 && g[i][j] <= l {
                g[i][j] = 1;
            }
        }
    }
    for k in 0..n {
        for i in 0..n {
            for j in 0..n {
                g[i][j] = std::cmp::min(g[i][j], g[i][k] + g[k][j]);
            }
        }
    }
    let q: usize = it.next().unwrap().parse().unwrap();
    let out = std::io::stdout();
    let mut out = std::io::BufWriter::new(out.lock());
    for _ in 0..q {
        let s: usize = it.next().unwrap().parse::<usize>().unwrap() - 1;
        let t: usize = it.next().unwrap().parse::<usize>().unwrap() - 1;
        if g[s][t] < inf {
            writeln!(out, "{}", g[s][t] - 1).ok();
        } else {
            writeln!(out, "-1").ok();
        }
    }
}

fn main() {
    run();
}


Measured memory_bytes: 6652
#include"bits/stdc++.h"
#define int long long
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define itr(i,x) for(auto i=(x).begin();i!=(x).end();++i)
#define All(x) (x).begin(),(x).end()
using namespace std;
typedef pair<int,int> P;
const int mod=1000000007;
int gcd(int x,int y){return y?gcd(y,x%y):x;}
int lcm(int x,int y){return x*y/gcd(x,y);}

signed main(){
	string s;
	cin>>s;
	map<char,int> mp;
	rep(i,s.size()) mp[s[i]]++;
	string ans="None";
	rep(i,26){
		char c[1]={char('a'+i)};
		if(mp[c[0]]==0){
			ans =*c;
			break;
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 512
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input!{
        n: usize
    }
    let d = 1000000007;
    let mut tab: Vec<Vec<usize>> = vec![vec![0; 3] ;61];
    tab[60][0] = 1;
    for i in (0..60).rev() {
        let b = (n >> i) & 1;
        if b == 1 {
            tab[i][0] = tab[i + 1][0];
            tab[i][1] = (tab[i + 1][0] + tab[i + 1][1]) % d;
            tab[i][2] = (2 * tab[i + 1][1] + 3 * tab[i + 1][2]) % d;
        } else {
            tab[i][0] = (tab[i + 1][0] + tab[i + 1][1]) % d;
            tab[i][1] = tab[i + 1][1];
            tab[i][2] = (tab[i + 1][1] + 3 * tab[i + 1][2]) % d;
        }
    }
    println!("{}", tab[0].iter().sum::<usize>() % d);
}


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

#define rep(i,x,y) for(int i=(x);i<(y);++i)
#define debug(x) #x << "=" << (x)

#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define show(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define show(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
template<typename T> using vec=std::vector<T>;

const int inf=1<<30;
const long long int infll=1LL<<62;
const double eps=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
    	os << v << ",";
    }
    os << "]";
    return os;
}

vector<long long int> factorize(long long int n){
    vector<long long int> res;
    for(int i=2; i*i<=n; ++i){
        while(n%i==0){
            res.push_back(i);
            n/=i;
        }
    }
    if(n!=1) res.push_back(n);
    return res;
};

void solve(){
    int n;
    cin >> n;
    vector<ll> ans=factorize(n);
    cout << n << ":";
    for(auto x:ans) cout << " " << x;
    cout << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(10);
    solve();
    return 0;
}

Measured memory_bytes: 3176
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

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

    int t[100010] = {};
    for (int i=0; i<n; i++) {
        t[a[i]+2]++;
        t[a[i]+1]++;
        t[a[i]]++;
    }

    int ans = 0;
    for (int i=0; i<100010; i++) {
        ans = max(ans, t[i]);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
h,w = map(int,input().split())

d=[]

d.append("."*(w+2))

for i in range(h):
    r = input()
    d.append("."+r+".")
    
d.append("."*(w+2))

#print(d)

no = False

def isok(d,i,j):
    c = 0
    c = c+1 if d[i-1][j]=="#" else c
    c = c+1 if d[i][j-1]=="#" else c
    c = c+1 if d[i][j+1]=="#" else c
    c = c+1 if d[i+1][j]=="#" else c
    result= True if c > 0 else False
    return result
        
    
for i in range(1,h+2):
    if no == True:
        break
    for j in range(1,w+2):
        if no == True:
            break
        if d[i][j] == "#":
            a = isok(d,i,j)
            if a == False:
                no = True
                break


result = "No" if no==True else "Yes"
print(result)

Measured memory_bytes: 3064
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
// clang-format on
int N;
int C753[] = {7, 5, 3};

bool is753(ll s)
{
  ll ss = s;
  int cnt = 0;
  for (int i = 0; i < 3; i++) {
    ss = s;
    while (ss > 0) {
      if (ss % 10 == C753[i]) {
        cnt++;
        ss /= 10;
        break;
      }
      ss /= 10;
    }
  }
  return cnt == 3;
}

int dfs(ll s)
{
  // cout << s << endl;
  if (s > N) {
    return 0;
  }
  ll ret = is753(s) ? 1 : 0;
  for (int i = 0; i < 3; i++) {
    ret += dfs(s * 10 + C753[i]);
  }
  return ret;
}

void solve() { cout << dfs(0) << endl; }

int main(void)
{
  cin >> N;
  solve();
  return 0;
}


Measured memory_bytes: 888
from collections import Counter,defaultdict,deque
from heapq import heappop,heappush
from bisect import bisect_left,bisect_right 
import sys,math,itertools,fractions,pprint
sys.setrecursionlimit(10**8)
mod = 10**9+7
INF = float('inf')
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))

n = inp()
a = inpl()
a.sort()
res = 0
for i in range(n-2):
    for j in range(i+1,n-1):
        for k in range(j+1,n):
            if a[i] != a[j] != a[k]:
                if a[i] + a[j] > a[k]:
                    res += 1
print(res)

Measured memory_bytes: 10404
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

using namespace std;


int main() {
	string s;
	cin >> s;
	s.insert(s.begin() + 4, ' ');
	cout << s << endl;
	return 0;
}

Measured memory_bytes: 384
N, M, C = map(int, input().split())
B = [int(x) for x in input().split() ]
A = []
for i in range(N):
    A += [ [ int(x) for x in input().split() ] ]

cnt = 0

for i in A:
    tmp = 0
    for j, b in zip(i, B):
        tmp += j*b
    tmp += C
    if tmp > 0:
        cnt += 1

print (cnt)


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

#define PI 3.14159265358979323846264338327950L
#define ll long long
#define lli long long int

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int x, y;
    cin >> x >> y;
    string answer = "No";
    for (int i = 0; i <= x; i++) {
        if (i * 2 + (x - i) * 4 == y) {
            answer = "Yes";
            break;
        }
    }
    cout << answer << "\n";
    return 0;
}


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

using namespace std;

const ll mod=1000000007;
const ll inf=1e18;

vector<vector<ll>> soinsu(ll a){
  if(a<=0) return {};
  if(a==1) return {{1,1}};
  vector<ll> f;
  ll b=a;
  for(ll i=2;i*i<=a;i++){
    if(b%i==0){
      f.push_back(i);
      b=b/i;
      i--;
    }
  if(b==1)break;
  }
  if(b!=1)f.push_back(b);

  vector<vector<ll>> u;
  ll p=f[0];
  ll c=1;
  for(ll i=1;i<f.size();i++){
    if(f[i]==p)c++;
    else{
      u.push_back({p,c});
      p=f[i];
      c=1;
    }
  }
  u.push_back({p,c});

  return u;
}

int main(){

  ll n;
  cin >> n;
  ll c=0;
  for(ll i=1;i<=n;i++){
    if(i%2==0)continue;
    vector<vector<ll>> v=soinsu(i);
    if(v.size()==3){
      if(v[0][1]==1 && v[1][1]==1 && v[2][1]==1)c++;
    }
    if(v.size()==2){
      if(v[0][1]==1 && v[1][1]==3)c++;
      else if(v[0][1]==3 && v[1][1]==1)c++;
    }
    if(v.size()==1){
      if(v[0][1]==7)c++;
    }
  }
  cout << c << endl;

}

Measured memory_bytes: 3544
#include <stdio.h>

int
main(int argc, char *argv[])
{
  char c[3][4];
  for(int i = 0; i < 2; i++){
    scanf("%s", c[i]);
  }
  
  int l = 0;
  for(int i = 0; i < 3; i++){
    if(c[0][i] == c[1][2 - i]){
      l++;
    }
  }
  
  if(l == 3){
    printf("YES\n");
  }
  else{
    printf("NO\n");
  }
  
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define rep(i,n) for(int i=0;i<(int)n;i++)
const ll INF = (1LL<<31)-1;


int main(){
    int N, x; cin >> N >> x;
    vector<int> X(2*N-1,INF);

    if(x==1 || x==2*N-1){ cout << "No" << endl;}
    else {
        X[N-2] = x-1; X[N-1] = x; X[N] = x+1;
        set<int> num;
        for(int i=1;i<=2*N-1;i++){
            if(abs(x-i)>1) num.insert(i);
        }
        rep(i,2*N-1){
            int xi = *num.begin();
            if(X[i]==INF){
                X[i] = xi;
                num.erase(xi);
            }
        }
        cout << "Yes" << endl;
        rep(i,2*N-1) cout << X[i] << endl;
    }

}

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

using namespace std;

int main()
{
    for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
            printf("%dx%d=%d\n", i, j, i*j);
        }
    }
    return 0;
}

Measured memory_bytes: 3056
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int m500 = sc.nextInt();
        int m100 = sc.nextInt();
        int m50 = sc.nextInt();
      	int sum = sc.nextInt();
      	sc.close();
      	int count = 0;
      	for (int a=0; a<=m500; a++) {
        	for (int b=0; b<=m100; b++) {
              for (int c=0; c<=m50; c++) {
                if (500*a+100*b+50*c==sum) {
                  count++;
                }
              }
            }
        }
      	System.out.println(count);
	}
}

Measured memory_bytes: 35628
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 100005
#define tc printf("Case %d: ", cs)
#define tcn printf("Case %d:\n", cs);
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);

#define dbg1(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;
#define dbg4(w,x, y, z) cerr << #w << " = " << w << ", " <<#x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
	return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
	os << "{";
	for (auto it = v.begin(); it != v.end(); ++it) {
		if ( it != v.begin() ) os << ", ";
		os << *it;
	}
	return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
	os << "[";
	for (auto it = v.begin(); it != v.end(); ++it) {
		if ( it != v.begin()) os << ", ";
		os << *it;
	}
	return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
	os << "[";
	for (auto it = v.begin(); it != v.end(); ++it) {
		if ( it != v.begin() ) os << ", ";
		os << it -> first << " = " << it -> second ;
	}
	return os << "]";
}

#define dbg(args...) do {cerr << #args << " : "; faltu(args); } while(0)

clock_t tStart = clock();
#define timeStamp dbg("Execution Time: ", (double)(clock() - tStart)/CLOCKS_PER_SEC)

void faltu () { cerr << endl; }

template <typename T>
void faltu( T a[], int n ) {
	for (int i = 0; i < n; ++i) cerr << a[i] << ' ';
	cerr << endl;
}

template <typename T, typename ... hello>
void faltu( T arg, const hello &... rest) { cerr << arg << ' '; faltu(rest...); }
// Program showing a policy-based data structure.
#include <ext/pb_ds/assoc_container.hpp> // Common file 
#include <ext/pb_ds/tree_policy.hpp>
#include <functional> // for less 
#include <iostream>
using namespace __gnu_pbds;
using namespace std;
// GNU link : https://goo.gl/WVDL6g
typedef tree<int, null_type, less_equal<int>, rb_tree_tag,
        tree_order_statistics_node_update>
        new_data_set;

/**___________________________________________________**/



int main()
{
	FASTIO
	/*
#ifndef ONLINE_JUDGE
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
	freopen("error.txt", "w", stderr);
#endif
//*/
	int n;
	cin >> n;
	for (int i = 1; i <= 50005; i++) {
		int x = i * 1.08;
		if (x == n) {
			cout << i << endl;
			return 0;
		}
	}
	cout << ":(\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){ 
long long a,b,k;
cin>>a>>b>>k;
if(k>=a+b){
cout<<0<<" "<<0<<endl;
}else if(k>=a){
cout<<0<<" "<<b-(k-a)<<endl;
}else{
cout<<a-k<<" "<<b<<endl;  
}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MAX = 2e9;
typedef pair<int, int> pi;
int main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    char c;
    cin >> c;
    if (c >= 'A' && c <= 'Z')cout << 'A';
    else cout << 'a';
}

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

vector<vector<int>> tree;
vector<int> counter;
vector<int> ans;

void dfs(int n, int p){
    for(int nxt: tree[n]){
        if(nxt == p) continue;

        ans[nxt] = ans[n] + counter[nxt];
        dfs(nxt, n);
    }
}

int main(){
    int N, Q;
    cin >> N >> Q;
    tree.resize(N, vector<int>());
    for(int i=0; i<N-1; i++){
        int a, b;  cin >> a >> b;
        a--;  b--;
        tree[a].push_back(b);
        tree[b].push_back(a);
    }
    counter.resize(N, 0);
    for(int q=0; q<Q; q++){
        int p, x;  cin >> p >> x;
        p--;
        counter[p] += x;
    }

    ans.resize(N, 0);
    ans[0] = counter[0];
    dfs(0, -1);

    for(int a: ans){
        cout << a << " ";
    }cout << endl;
}


Measured memory_bytes: 24320
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}


int main() {
    int N;
    cin >> N;
    map<int,int> mp;
    REP(i,N) {
        int a;
        cin >> a;
        if (mp.count(a) == 0) mp[a] = 0;
        mp[a]++;
    }
    int ans = 0;
    for (const auto &it: mp) {
        ans += (it.second < it.first) ? it.second : (it.second-it.first);
    }

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


Measured memory_bytes: 4736
#include<iostream>
#include<algorithm>
#include<string>
#include<stack>
#include<cstdio>
#include<map>
#include<functional>
#include <sstream>

using namespace std;

string ans;

string IntToString(int number)
{
    stringstream ss;
    ss << number;
    return ss.str();
}


string sinsuu(int n){
    ans += IntToString(n%4);
    if (n==0){
        ans="0";
        return ans;
    }
    else if( (n/4) < 4 ){
        if ( (n/4) > 0 ) {
            ans += IntToString(n/4);
        }
        reverse( ans.begin(), ans.end());
        return ans;
    }
    else{
        n = n/4;
        return sinsuu(n);
    }
}

int main(){
	int n;
    while (1)
    {
        cin>>n;
        if(n<0)break;
        cout<<sinsuu(n)<<endl;
        ans.clear();
        
    }
	return 0;
}

Measured memory_bytes: 1220
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <list>
#include <iomanip>
#include <queue>
#include <cmath>
#include <numeric>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)

using namespace std;
using ll = long long;
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
const long long mod = 1e9 + 7;


int main() {

	ll N, D;
	cin >> N >> D;

	ll X, Y, ans = 0;
	double tmp;

	rep(i, N) {
		cin >> X >> Y;
		tmp = sqrt(X * X + Y * Y);
		if (tmp <= D) {
			ans++;
		}
	}

	cout << ans;


	return 0;
}


Measured memory_bytes: 3676
n=int(input())
kh=[]
dif=[]
current=0
for i in range(n):
    kh.append(list(map(int,input().split())))
    dif.append(kh[-1][0]-current)
    current=kh[-1][0]
    
   
current=[0,0]
flag=True
for i in range(n):
    need=abs(kh[i][1]-current[0])+abs(kh[i][2]-current[1])
    current=[kh[i][1],kh[i][2]]
    
    if dif[i] < need :
        flag = False
        break
    elif (dif[i] - need) % 2 != 0 :
        flag = False 
        break
if flag :
    print("Yes")
else:
    print("No")



Measured memory_bytes: 28092
//created by pyoxiao on 2020/05/02
#include<bits/stdc++.h>
#define LL long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define CL(a, b) memset(a, b, sizeof(a))
using namespace std;
const int mod = 1e9 + 7;
LL fpow(LL a, LL b, LL p = mod){LL ans = 1; a %= p; while(b) {if(b & 1) ans = ans * a % p; b >>= 1; a = a * a % p;} return ans;}
LL gcd(LL a, LL b){return b == 0 ? a : gcd(b, a % b);}
LL n;
void solve() {
    scanf("%lld", &n);
    LL cur = 100;
    for(int i = 1; ; i ++) {
        cur += (LL)cur * 0.01;
        if(cur >= n) {
            printf("%d\n", i);
            return;
        }
    }
}
int main() {
    int T = 1;
    // scanf("%d", &T);
    while(T --) 
        solve();
    return 0;
}

Measured memory_bytes: 3812
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=100+10;

int n,a[maxn];
double kq;

int main(){
  scanf("%d",&n);
  for(int i=1;i<=n;i++) scanf("%d",&a[i]);
  kq=0;
  for(int i=1;i<=n;i++) kq=kq+1.0/a[i];
  kq=1.0/kq;
  cout<<kq;
}


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<ll, ll> vll;
typedef pair<int, int> vii;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ub upper_bound
#define lb lower_bound
#define asd cout << "ok" << endl;

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define trav(it, m) for(auto it = m.begin(); it!= m.end(); it++)

const char nl = '\n';
const int MX = 2e5 +5;
const int MOD = 1e9 +7;
const int inf = 1e9;
const ll INF = 1e18;
const ld PI = acos((ld)-1);

int fenwick[MX] = {};




int main(){
   ios_base::sync_with_stdio(0); cin.tie(0);
   string s; cin >> s;
   int ans = 0;
   int cnt =0;
   for(int i = 0; i < 3; i++){
    if(s[i] == 'R')
      cnt++;
    else{
      ans = max(ans, cnt);
      cnt = 0;
    }

   }
   cout << max(ans,cnt) << nl;


}


Measured memory_bytes: 3620
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

int main(void){
	int n,a,b;
	cin >> n;
	if(n==1){
		cout << "Hello World" << endl;
	}else{
		cin >> a >> b;
		cout << (a+b) << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int arr[100005]={0};
int n;
cin>>n;
while(n--){
    int x;
    cin>>x;
    arr[x]++;
    arr[x-1]++;
    arr[x+1]++;
}
int z=INT_MIN;
for(int i=0;i<100005;++i){
z=max(z,arr[i]);
}
cout<<z;

}


Measured memory_bytes: 640
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
using System.Numerics;

namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
        static public (T1 a, T2 b) Slice<T1, T2>()
        {
            var t = ReadLine().Split();
            return (
            (T1)Convert.ChangeType(t[0], typeof(T1)),
            (T2)Convert.ChangeType(t[1], typeof(T2)));
        }
        static long Mod = (long)1e9 + 7;
        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            Solve();
            Out.Flush();
            Read();
        }
        static void Solve()
        {
            var rcrc = Sarray();
            var r1 = (int)rcrc[0];
            var c1 = (int)rcrc[1];
            var r2 = (int)rcrc[2];
            var c2 = (int)rcrc[3];
            var cmb = new Combination(2000007);
            long square(int x, int y) => cmb.nCk(x + y + 2, x + 1);
            var ans = square(r2, c2)
                    - square(r2, c1 - 1)
                    - square(r1 - 1, c2)
                    + square(r1 - 1, c1 - 1);
            WriteLine((ans % Mod + Mod) % Mod);
        }
        public class Combination
        {
            readonly long mod;
            readonly long[] fac, finv, inv;
            public Combination(long n, long mod = 1000000007)
            {
                long max = n + 1;
                this.mod = mod;
                fac = new long[max];
                finv = new long[max];
                inv = new long[max];
                fac[0] = fac[1] = 1;
                finv[0] = finv[1] = 1;
                inv[1] = 1;
                for (int i = 2; i < max; ++i)
                {
                    fac[i] = fac[i - 1] * i % mod;
                    inv[i] = mod - inv[mod % i] * (mod / i) % mod;
                    finv[i] = finv[i - 1] * inv[i] % mod;
                }
            }
            public long nCk(int n, int k)
            {
                if (n < k) return 0;
                if (n < 0 | k < 0) return 0;
                return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
            }
        }
    }
}

Measured memory_bytes: 75416
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define ld long double
#define vi vector<long long>
#define pi pair<long long, long long>
#define watch(x) cout << (#x) << " is " << (x) << endl; cout.flush()
#define endl '\n'
#define _ << ' '
#define min3(a, b, c) min(a, min(b, c))
#define min4(a, b, c, d) min(min(a, d), min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define max4(a, b, c, d) max(max(a, d), max(b, c))
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less_equal<int>, rb_tree_tag, tree_order_statistics_node_update> idxset;
//find_by_order(i) : iterator to the value at index i, order_of_key(x) : the index of value x
const ll mod = (ll)1e9+7;
const ll INF = (ll)1e18+1;

ll n, k, sum=0;
ll a[501];
vector<ll> factors;

bool check(ll x)
{
    multiset<ll> ms;
    for(int i=0; i<n; i++)
    {
        ms.insert(a[i]%x);
    }
    ll tot=0, rtot=0;
    for(auto i : ms) tot+=i;
    for(auto i = ms.rbegin(); i!= ms.rend(); i++)
    {
        tot-=*i;
        rtot+=x-*i;
        if(tot==rtot) return (k>=tot);
    }
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    #ifndef ONLINE_JUDGE
    //freopen("B.txt", "r", stdin);
    #endif
    cin >> n >> k;
    for(int i=0; i<n; i++)
    {
        cin >> a[i];
        sum+=a[i];
    }
    for(int i=1; i*i<=sum; i++)
    {
        if(sum%i==0)
        {
            factors.pb(i);
            if(i*i!=sum) factors.pb(sum/i);
        }
    }
    sort(all(factors));
    for(int i=(int)factors.size()-1; i>=0; i--)
    {
        if(check(factors[i]))
        {
            cout << factors[i];
            return 0;
        }
    }


}


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

using namespace std;

int main(){
    int N,K;
    int A[100000];
    int tmp=0;
    int cnt=0;

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

    tmp= N-K;
    cnt++;
    if(tmp==0){
        cout<<cnt<<endl;
        return 0;
    }

    if(tmp % (K-1) == 0 ){
        cnt += tmp / (K-1);
        cout<<cnt<<endl;
    }else if(tmp < (K-1)){
        cout<<cnt+1<<endl;
    }else{
        cnt += tmp / (K-1);
        cout<<cnt+1<<endl;
    }
}

Measured memory_bytes: 640
import math
n = int(input())
lst = list(map(int, input().split()))
sortlst = sorted(lst, reverse = True)
#print(sortlst)
ans = 0
for i in range(n - 1):
	point =sortlst[math.ceil(i / 2)]
#	print(point)
	ans += point

print(ans)	


Measured memory_bytes: 32960
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0);
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define INF 100000000
#define FOR(i,a,n) for(i=a;i<n;i++)
int comp(const void* a,const void* b){
	return *(int*)b-*(int*)a;
}
void fill(int a[],int b,int c){
	int i;
	FOR(i,0,b) a[i]=c;
	return;
}
int a[300000];
int main(void)
{
	int n,i;
	ll sum=0;
	scanf("%d",&n);
	FOR(i,0,3*n) scanf("%d",&a[i]);
	qsort(a,3*n,sizeof(int),comp);
	for(i=0;i<n;i++){
		sum+=a[i*2+1];
	}
	printf("%lld\n",sum);
	return 0;
}
    


Measured memory_bytes: 2556
/*
ID: skipian1
PROB: 
LANG: C++11
*/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF = 2000000000
#define sz(a) int((a).size())
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define X first
#define Y second

ll MOD = 1e9+7;

int main() {
  ll n;
  cin >> n;
  string str;
  cin >> str;
  bool paren[2*n];
  for (ll i = 0; i < 2*n; i++) {
    if (i == 0) {
      if (str.at(i) == 'W') {
	cout << 0 << "\n";
	return 0;
      }
      paren[0] = 0;
    } else {
      if (str.at(i) != str.at(i-1)) {
	paren[i] = paren[i-1];
      } else {
	paren[i] = !paren[i-1];
      }
    }
  }
  ll parens = 0;
  for (ll i = 0; i < 2*n; i++) {
    if (paren[i]) parens--;
    else parens++;
    if (parens < 0) {
      cout << 0 << "\n";
      return 0;
    }
  }
  if (parens != 0) {
    cout << 0 <<  "\n";
    return 0;
  }
  parens = 0;
  ll ans = 1;
  ll ind = 0;  
  for (ll i = 2*n-1; i >= 0; i--) {
    if (paren[i]) parens++;
    else {
      ans *= parens-ind;
      ind++;
      ans %= MOD;
    }
  }
  for (ll i = 1; i <= n; i++) {
    ans *= i;
    ans %= MOD;
  }
  cout << ans << "\n";
}


Measured memory_bytes: 772
from itertools import accumulate, tee


def pairwise(iterable):
    a, b = tee(iterable)
    next(b, None)
    return zip(a, b)


a, b = map(int, input().split())

towers = list(accumulate(range(1, 1000)))

for p, n in pairwise(towers):
    if n - p == b - a:
        print(p - a)
        break


Measured memory_bytes: 3060
N = int(input())
H = list(map(int, input().split()))
result = tmpResult = 0

for i in range(N - 1):
  if(H[i] >= H[i + 1]):
    tmpResult += 1
  else:
    result = max(tmpResult, result)
    tmpResult = 0

print(result if tmpResult < result else tmpResult)

Measured memory_bytes: 14224
#include <iostream>

int abso(int a) {
    return a > 0 ? a : -a;
}

int main() {
    int N;
    std::cin >> N;
    int t[N],x[N],y[N];
    t[0] = x[0] = y[0] = 0; 
    for(int i = 1; i < N+1; i++) {
        std::cin >> t[i] >> x[i] >> y[i];
        if( (x[i] + y[i] - t[i]) % 2 != 0 || abso(x[i] - x[i-1]) + abso(y[i] - y[i-1]) > t[i] - t[i-1] ) {
            std::cout << "No" << std::endl;
            return 0;
        }
    }
    std::cout << "Yes" << std::endl;
}

Measured memory_bytes: 1408
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
 
		Scanner sc = new Scanner(System.in);
 
		int A = Integer.parseInt(sc.next());
		int B = Integer.parseInt(sc.next());
		int X = Integer.parseInt(sc.next());
		
			System.out.println(A+B>=X&&A<=X?"YES":"NO");
	}
 
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define endl "\n"

int cache[10000005];
vector<int> v;

int dp(int n)
{
	if(n==0)
		return 0;
	int &ans=cache[n];
	if(ans!=-1)
		return ans;
	ans=1e9;
	for(int i=0;i<v.size();i++)
	{
		if(n-v[i]>=0)
			ans=min(ans,1+dp(n-v[i]));
	}
	return ans;
}

int32_t main()
{
	IOS;
	int n;
	cin>>n;
	memset(cache,-1,sizeof(cache));
	for(int i=0;i<9;i++)
		v.push_back(pow(6ll,i));
	for(int i=1;i<7;i++)
		v.push_back(pow(9ll,i));
	sort(v.begin(), v.end());
	for(int i=0;i<v.size();i++)
		cache[v[i]]=1;
	cout<<dp(n);
 	return 0;	
}

Measured memory_bytes: 81536