akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;
class Main{
	static final long MOD = 1_000_000_007; // 10^9+7
    static final int MAX = 2_147_483_646; // intMax 
    static final int INF = 1_000_000_000; // 10^9  
    public static void main(String[] args) throws Exception {
		hayami saori = new hayami();
		int k = saori.saori_hayami();
		int n = saori.saori_hayami();
		int[] a = new int[n];
		int[] sa = new int[n];
		int num = 0;
		for(int i = 0; i < n;i++){
			a[i] = saori.saori_hayami();
		}
		for(int i = 0;i < n-1;i++){
			sa[i] = a[i+1] - a[i];
		}
		sa[n-1] = a[0] + (k - a[n-1]);
		Arrays.sort(sa);
		for(int i = 0;i < n-1;i++){
			num += sa[i];
		}
		System.out.println(num);
		saori.close();
    }
}

class hayami implements Closeable {
	private final InputStream in = System.in;
	private final byte[] hayami = new byte[1024];
	private int Hayami = 0;
	private int saori = 0;
	private boolean HayamiSaori() {
		if (Hayami < saori) {
			return true;
		}else{
			Hayami = 0;
			try {
				saori = in.read(hayami);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (saori <= 0) {
				return false;
			}
		}
		return true;
	}
	private int SaoriHayami() { 
		if (HayamiSaori()) {
            return hayami[Hayami++];
         }else{
             return -1;
         }
	}
	private static boolean hayami_saori(int hayami) { 
		return 33 <= hayami && hayami <= 126;
	}
	public boolean hayamisaori() { 
		while(HayamiSaori() && !hayami_saori(hayami[Hayami])) Hayami++; return HayamiSaori();
	}
	public String nextHayami() {
		if (!hayamisaori()) throw new NoSuchElementException();
		StringBuilder hayamin = new StringBuilder();
		int saori = SaoriHayami();
		while(hayami_saori(saori)) {
			hayamin.appendCodePoint(saori);
			saori = SaoriHayami();
		}
		return hayamin.toString();
	}
	public long saorihayami() {//nextLong
		if (!hayamisaori()) throw new NoSuchElementException();
		long hayami = 0;
		boolean misao = false;
		int saori = SaoriHayami();
		if (saori == '-') {
			misao = true;
			saori = SaoriHayami();
		}
		if (saori < '0' || '9' < saori) {
			throw new NumberFormatException();
		}
		while(true){
			if ('0' <= saori && saori <= '9') {
				hayami *= 10;
				hayami += saori - '0';
			}else if(saori == -1 || !hayami_saori(saori)){
				return misao ? -hayami : hayami;
			}else{
				throw new NumberFormatException();
			}
			saori = SaoriHayami();
		}
	}
	public int saori_hayami() {//nextInt
		long hayami = saorihayami();
		if (hayami < Integer.MIN_VALUE || hayami > Integer.MAX_VALUE) throw new NumberFormatException();
		return (int) hayami;
	}
	public double Hayamin() { //nextDouble
		return Double.parseDouble(nextHayami());
	}
	public void close() {
		try {
			in.close();
		} catch (IOException e) {
		}
    }
    
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(){
	int a, b;
	cin >> a >> b;
	if(a>b) swap(a, b);
	for(int i=0; i<b; i++) cout << a;
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void){
	long long int n,h;
	cin>>n>>h;
	long long int*a = new long long int[n];
	long long int*b = new long long int[n];
	for(int i=0;i<n;i++){
		cin>>a[i]>>b[i];
	}
	sort(a,a+n);
	sort(b,b+n);
	long long int count=0;
	for(int i=0;i<n;i++){
		if(b[n-i-1] < a[n-1])break;
		h-=b[n-i-1];
		if(h<=0){
			count++;
			cout<<count<<endl;
			return 0;
		}
		count++;
	}
	long long int c2=h/a[n-1];
	if(h-a[n-1]*c2)c2++;
	cout<<count+c2<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)x.size())
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
typedef long long LL;
typedef pair<int,int> pa;
typedef vector<int> vec;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
int f[520][100010];
int n,N,M,tmp[55],q,ts,vv[500010],ww[500010],v[500010],w[500010],o[500010],V,L, ans;
int main(){
	cin>>n;
	FOR(i,1,n) getint(v[i]),getint(w[i]);
	N=1;
	while (1){
		if (n>(1<<N)-1) ++N; else break;
	}
	N=(N+1)/2;
	M=(1<<N)-1;
	FOR(i,1,M){
		int fa=i>>1;
		FOR(j,0,100000) f[i][j]=f[fa][j];
		FOR(j,w[i],100000) f[i][j]=max(f[i][j],f[fa][j-w[i]]+v[i]);
	}
	FOR(i,1,500000){
		FOR(j,0,22) if ((i>>j)&1){o[i]=j;break;}
	}
	cin>>q;
	while (q--){
		scanf("%d%d",&V,&L);
		if (V<=M){printf("%d\n",f[V][L]);continue;}
		ts=0;
		while (1){
			if (V<=M) break;
			tmp[ts++]=V;
			V>>=1;
		}
		vv[0]=0;
		ww[0]=0;
		FOR(i,1,(1<<ts)-1){
			vv[i]=vv[i-(1<<o[i])]+v[tmp[o[i]]];
			ww[i]=ww[i-(1<<o[i])]+w[tmp[o[i]]];
		}
		ans=0;
		FOR(i,0,(1<<ts)-1) if (ww[i]<=L) ans=max(ans,vv[i]+f[V][L-ww[i]]);
		printf("%d\n",ans);
	}
	return 0;
}

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

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

	int	n;
	cin >> n;
	vector<int>	S(n);
	rep(i, n)
		cin >> S.at(i);
	int	m;
	cin >> m;
	int	count;
	count = 0;
	rep(i, m)
	{
		int	x;

		cin >> x;
		if (*lower_bound(S.begin(), S.end(), x) == x)
			count++;
	}
	cout << count << endl;
}



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

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl


signed main(){

	int N;
	cin >> N;
	vector<int> place(N + 1, 0);
	for (int i = 1; i <= N; i++){
		int a; cin >> a;
		place[a] = i;
	}

	int ans = 0;
	set<int> used = { 0, N + 1 };	// すでに見た要素のplace
	for (int i = 1; i <= N; i++){
		// すでに使われた数（i未満の数）の中で、iの右側のindex
		auto index = used.lower_bound(place[i]);
		int right = *index;
		int left = *(--index);

		cerr << i << " " << place[i] << " " << left << " " << right << endl;
		ans += i * (right - place[i]) * (place[i] - left);

		used.insert(place[i]);
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
using ull = unsigned long long;
int main(){
    long double a, b, c; cin >> a >> b >> c;
    long double eps = 1.0E-14;
    if(sqrt(a)+sqrt(b) +eps < sqrt(c)){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
    return 0;
}

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

int main() {
	string s;
    cin >> s;
    if(s.size() == 3){
        reverse(s.begin(), s.end());
    }
    cout << s << endl;
}


Measured memory_bytes: 3584
from itertools import*
from math import*
from collections import*
from heapq import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = 10**18
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)

#ボードを上下真っ黒と真っ白にしてA-1マス(B-1マス)上下左右が接さないように穴を作る

A,B = map(int,input().split())
bd = []
for i in range(50):
    bd.append(["#" for _ in range(100)])
for i in range(50):
    bd.append(["." for _ in range(100)])

for i in range(A-1):
    bd[(i//50)*2][(i%50)*2] ="."
for i in range(B-1):
    bd[-((i//50)*2)-1][(i%50)*2] ="#"
print(100,100)

for b in bd:
    print(*b,sep="")


Measured memory_bytes: 40944
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <stdio.h>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

int main() {
	int a,b,h,m;
	double t=0,c=0,ans=0,pi=3.141592653589793;

	cin>>a>>b>>h>>m;
	t=(h*60+m)*0.5;

	c=m*6;
	t= (t-c)*pi/180;
	
	
	ans=double((a*a)+(b*b)-(2*a*b*cos(t)));
	
	printf("%.20f",sqrt(ans));
	//cout<<sqrt(ans)<<endl;
	
	// your code goes here
	return 0;
}

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

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

ll n, ans;
vector<pi> v;

int getNum(ll num) {
	ll sum = 0;
	ll tmp = 1;
	ll cnt = 1;
	
	while (true) {
		sum += tmp;
		if (sum > num) return cnt - 1;
		cnt++;
		tmp++;
	}

	return 0;
}

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

	cin >> n;

	ll mx = n;

	for (int i = 2; i <= sqrt(mx); i++) {
		int cnt = 0;

		while (n % i == 0) {
			n /= i;
			cnt++;
		}

		if(cnt>0) v.push_back({ i,cnt });

	}

	if (n > 1) v.push_back({ (int)n,1 });

	for (auto next : v) {
		ans += getNum(next.second);
	}

	cout << ans << "\n";


	return 0;
}

Measured memory_bytes: 3732
MOD = Math.pow(10, 9) + 7
input = require('fs').readFileSync('/dev/stdin', 'utf8')
lines = input.split('\n')
line = lines.shift().split(' ')
N = line[0] * 1
M = line[1] * 1 
if (Math.abs(N - M) >= 2) {
    console.log(0)
} else {
    ans = 1
    for (i=2; i<=N; i++) {
        ans = (ans * i) % MOD
    }
    for (i=2; i<=M; i++) {
        ans = (ans * i) % MOD
    }
    ans *= (N==M) ? 2 : 1
    ans = ans % MOD
    console.log(ans)
}


Measured memory_bytes: 10060
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<vector>
#define rep(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define REP(i,a) rep((i),0,(a)) 
#define ull unsigned long long 
using namespace std;
//global

ull gcd(ull n, ull m){
	return(m==0?n:gcd(m, n%m));
} 

vector<int>G[1010];
ull card[1001];
int match[1010];
int N, M;
bool used[1010];
bool dfs(int v){
	used[v] = true;
	rep( i,0, (int)G[v].size()){
		int u = G[v][i], w = match[u];
		if (w < 0 || !used[w] && dfs(w)){
			match[v] = u;
			match[u] = v;
			return true;
		}
	}
	return false;
}
int bm(){
	int res = 0;
	memset(match, -1, sizeof(match));
	rep(v, 0, 1000){
		if (match[v] < 0){
			memset(used, 0, sizeof(used));
			if (dfs(v))res++;
		}
	}
	return res;
}


int main(void){
	while (true){
		cin >> N >> M;
		if (N==0)return(0);


		rep(i, 0, N)cin >> card[i];
		rep(i, 500, 500+M){
			cin >> card[i];
			rep(j, 0, N)
				if (gcd(card[i], card[j]) != 1){
					G[i].push_back(j);
					G[j].push_back(i);
				}
		}
		cout << bm() << endl;
		rep(i, 0, 1010){
			G[i].clear();
		}
	}
}

Measured memory_bytes: 3376
#include <iostream>
#include <string>
using namespace std;
class Dice {
public:
	int top, bottom, west, east, south, north;
	Dice(){
		top = 1;bottom = 6;
		west = 4;east = 3; 
		south = 2;north = 5;
	}
	void North(){
		int tmp = top;
		top = south;
		south = bottom;
		bottom = north;
		north = tmp;
		return;
	}
	void East(){
		int tmp = top;
		top = west;
		west = bottom;
		bottom = east;
		east = tmp;
		return;
	}
	void West(){
		int tmp = top;
		top = east;
		east = bottom;
		bottom = west;
		west = tmp;
		return;
	}
	void South(){
		int tmp = top;
		top = north;
		north = bottom;
		bottom = south;
		south = tmp;
		return;
	}
	void Right(){
		int tmp = south;
		south = east;
		east = north;
		north = west;
		west = tmp;
		return;
	}
	void Left(){
		int tmp = south;
		south = west;
		west = north;
		north = east;
		east = tmp;
		return;
	}
};

int main(){
	int n;
	while(cin>>n, n){
		long long total = 1;
		Dice d;
		for(int i = 0; i < n; i++){
			string s;
			cin>>s;
			if(!s.compare("North"))
				d.North();
			else if(!s.compare("East"))
				d.East();
			else if(!s.compare("West"))
				d.West();
			else if(!s.compare("South"))
				d.South();
			else if(!s.compare("Right"))
				d.Right();
			else if(!s.compare("Left"))
				d.Left();
			total += d.top;
		}
		cout<<total<<endl;
	}
	return 0;
}

Measured memory_bytes: 3140
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e15;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1

int a, b, c;

int main() {
	cin >> a >> b >> c;
	if (a != b) {
		if (b == c)cout << a << endl;
		else cout << b << endl;
	}
	else cout << c << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<functional>
#include<string>
#include<cstring>
#include<cmath>
#include<set>
#include<map>
#include<sstream>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
const ll MOD=1000000007;
int ans=100000;
int h,w;
int dx[]={0,-1,0,1};
int sy,sx,gy,gx;
int dy[]={-1,0,1,0};
int moji[35][35];
void dfs(int y,int x,int cnt)//1,,,top 2...left 3...down 4...right
{
	if(cnt+1>=ans)return;
	//cout<<"nct :"<<cnt<<endl;
	for(int i=0;i<4;i++)
	{
		int nx=x+dx[i];
		int ny=y+dy[i];
		if(ny>=0&&nx>=0&&h>ny&&w>nx&&(moji[ny][nx]!=1))
		{
		while(ny>=0&&nx>=0&&h>ny&&w>nx)
		{
			if(moji[ny][nx]==3)
			{
				ans=min(ans,cnt+1);
				return;
			}
			//if(ny==gy&&nx==gx)return;
			//if(nx<0||ny<0||nx>=w||ny>=h)return -1;
			if(moji[ny][nx]==1)
			{
				moji[ny][nx]=0;
				//if(i==0)
				{
					 dfs(ny-dy[i],nx-dx[i],cnt+1);
				}
				moji[ny][nx]=1;
				break;
			}
			nx+=dx[i];
			ny+=dy[i];
		}
		}
//	A:;	
	}
	return;
}
int main()
{
	while(cin>>w>>h,w)
	{
		ans=11;
		rep(i,35)rep(j,35)moji[i][j]=0;
		rep(i,h)rep(j,w)
		{
			cin>>moji[i][j];
			if(moji[i][j]==2)
			{
				sx=j;
				sy=i;
				moji[i][j]=0;
			}
			/*else if(moji[i][j]==3)
			{
				gx=j;
				gy=i;
				moji[i][j]=0;
			}
			*/
		}
	dfs(sy,sx,0);
	cout<<(ans<=10?ans:-1)<<endl;
	}
	return 0;
}

Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a,b,x,p,q,ans;
    cin>>a>>b>>x;
    p=b/x;
    q=a/x;
    ans=p-q;

    if(a%x==0)
    {
        ans++;
    }
    cout<<ans<<endl;

    return 0;

}


Measured memory_bytes: 3664
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;

template<typename T>
using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;

#define ll long long
#define __   ios_base::sync_with_stdio(0);cin.tie();cout.tie();
#define mod 1000000007

ll Set(ll N,ll pos){ return N=N | (1<<pos); }
ll reset(ll N,ll pos){ return N= N & ~(1<<pos); }
bool check(ll N,ll pos){ return (bool)(N & (1<<pos)); }


ll ar[]={0,0,1,-1};
ll br[]={1,-1,0,0};

string s;
ll n,m;
ll arr[500000];
ll brr[500000];

int main()
{__
        ll i,j;
        string a,b;
        cin>>n;

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



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

int main(){
	int R,G,B,n;
	scanf("%d %d %d %d",&R,&G,&B,&n);
	int ans = 0;
	for (int r = 0; r <= n;r++){
		for (int g = 0;g <= n;g++){
			double b = (n - r*R - g*G)/(double)B;
			double dumy = floor(b);
			if ((b >= 0) && (b == dumy)){
				ans += 1;
			}
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

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

ll lcm(ll x, ll y) {
    return x / gcd(x,y) * y;
}

int main(void)
{
    IOS
    constexpr int ER = 1e6+5;
    vector<int> prime;
    vector<int> erato(ER+5);
    FOR(i,2,ER+1) {
        if (erato[i]) continue;
        prime.push_back(i);
        for(int j = 1; i * j <= ER; j++) erato[i*j] = i;
    }

    int N; cin >> N;
    vector<int> A(N);
    vector<int> pr(ER);
    REP(i,N) {
        cin >> A[i];
        int a = A[i];
        set<int> st;
        while(a != 1) {
            if (erato[a] > 1) {
                st.insert(erato[a]);
                a /= erato[a];
            }
        }
        for(auto p:st) pr[p]++;
    }

    REP(i,ER) {
        // pairwise coprime
        if (i == ER-1) {
            OUT("pairwise coprime")
            return 0;
        }
        if (pr[i] > 1) break;
    }

    ll allgcd = A[0];
    FOR(i,1,N) allgcd = gcd(allgcd,A[i]);
    if (allgcd == 1) {
        OUT("setwise coprime")
    } else {
        OUT("not coprime")
    }

    return 0;
}

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

Sr = "".join(list(reversed(S)))

wd = []
wdl = []

pw = 0
pwl = 0

for d in range(K):

    # 先詰めを探す
    while True:
        if S[pw] == ('o'):
            wd.append(pw)
            break
        pw += 1
    pw += C + 1
    
    # 後詰めを探す
    while True:
        if Sr[pwl] == ('o'):
            wdl.append((N-1) - pwl)
            break
        pwl += 1
    pwl += C + 1

wdl.sort()
    
for i in range(K):
    if wd[i] == wdl[i]:
        print(wd[i] + 1)

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

using namespace std;

typedef long long ll;

const int maxn = 1e5 + 100;

int main()
{
    char S[5];
    cin >> S;
    int ans = 700;
    int cnt = 0;
    for(int i = 0; i < 3; i ++)
        if(S[i] == 'o') cnt ++;
    ans += cnt * 100;
    cout << ans << endl;
    return 0;
}


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

int get_sum(int i){
    int sum = 0;
    while(i > 0){
        sum += i % 10;
        i /= 10;
    }
    return sum;
}

int main(){
    int N, min = 1000001;
    cin >> N;
    for(int i = 1; i <= N - 1; i++){
        int j = N - i;
        if(1 <= j && j <= N && i + j == N && min > get_sum(i) + get_sum(j)) min = get_sum(i) + get_sum(j);
    }
    cout << min << endl;
}

Measured memory_bytes: 256
def resolve():
	w, h, n = map(int, input().split())
	area = [[True]*w for _ in range(h)]
	for i in range(n):
		x, y, a = map(int, input().split())
		if a == 1:
			for j in range(h):
				for k in range(x):
					area[j][k] = False
		elif a == 2:
			for j in range(h):
				for k in range(x, w):
					area[j][k] = False
		elif a == 3:
			for j in range(y):
				for k in range(w):
					area[j][k] = False
		elif a == 4:
			for j in range(y, h):
				for k in range(w):
					area[j][k] = False
	ans = 0
	for r in area:
		ans += r.count(True)
	print(ans)
resolve()

Measured memory_bytes: 41712
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) (a).begin(),(a).end()
#define print(A,n) rep(i,0,n){cout<<(i ? " ":"")<<A[i];}cout<<endl;
#define pprint(A,m,n) rep(j,0,m){print(A[j],n);}
const long mod=1e9+7;
const int size=1e5;
const long inf=1e9;
int main(){
	int N;cin>>N;
	long x,l;
	pair<long,long> vp[N];
	rep(i,0,N){
		cin>>x>>l;
		vp[i] = {x+l,x-l};
	}
	sort(vp,vp+N);
	int cnt = 0; long temp=-inf;
	int i=0;
	while(true){
		while(i<N&&vp[i].second<temp){
            i++;
        }if(i>=N) break;
		temp=vp[i].first;
		cnt++;
	}cout<<cnt<<endl;
}

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

using namespace std;

int main(){
    long long n, a[200009],mn=1e16, mna=1e9;
    vector<long long> v;
    cin >> n;
    for(int i=0;i<n;i++){
        cin >> a[i];
        mna = min(a[i], mna);
    }
    for(int i=0;i<n;i++){
        v.push_back(a[i]-i);
    }
    sort(v.begin(), v.end());
    long long ans=0;
    if(n&1){
        for(int i=0;i<n;i++){
            ans += abs(v[i]-v[n/2]);
        }
    }
    else{
        long long tmp=0;
        for(int i=0;i<n;i++){
            ans += abs(v[i]-v[n/2-1]);
        }
        for(int i=0;i<n;i++){
            tmp += abs(v[i]-v[n/2]);
        }
        ans = min(ans, tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3956
//Nihal Mittal - nihal_47
//Strike First , Strike Hard , No Mercy !!

/**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀⠀⠀⠀⠀
⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀⠀⠀⠀
⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿⠀⠀
⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧⠀⠀
⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄⠀⠀
⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰⠀
⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧⠀⠀⠀
⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃⠀⠀⠀
⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀⠀⠀⠀
⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸⠀
**/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define all(v) (v).begin(),(v).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
#define pii pair<ll,ll>
#define vi(x) vector<x>
#define maxn 100005
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
using namespace std;
using namespace __gnu_pbds;

signed main()
{
    fast;
   
    ll n,i,j,k;
    cin>>n;
    ll a[n+2],ans=0;
    for(i=0;i<n;i++) cin>>a[i];
    for(i=0;i<n;i++)
    {
    	for(j=i+1;j<n;j++)
    	{
    		for(k=j+1;k<n;k++)
    		{
    			if(a[i]!=a[j] and a[j]!=a[k] and a[i]!=a[k])
    			{
    				if(a[i] < a[j]+a[k] and a[j]<a[i]+a[k] and a[k]<a[i]+a[j]) ans++;
    			}
    		}
    	}
    }
    cout<<ans;
}

Measured memory_bytes: 3696
($N,$C)=glob<>;
@D=map[glob<>],@@=0..$C-1;
for(<>){
	$j=0;
	for$x(glob){
		$k=($i+$j)%3;
		for(@@){
			$_[$k][$_]+=$D[$x-1][$_]
		}
		++$j
	}
	++$i
}
$\=1e15;
for$i(@@){
	for$j(@@){
		for(@@){
			$\-=$-=$i-$j&&$i-$_&&$j-$_&&$\-$_[0][$i]-$_[1][$j]-$_[2][$_]
		}
	}
}
print


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

using namespace std;

int main() {
	int x;
	scanf("%d", &x);
	
	for (int i = 1; ; i++) {
		long long tar = (long long)pow(i, 5) - 1LL * x;
		
		long long root = (long long)pow(abs(tar), 0.2);
		if (tar < 0) root *= -1;
		
		if (root * root * root * root * root == tar) return 0 * printf("%d %lld\n", i, root);
	}
}


Measured memory_bytes: 4128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
const ll mo=1000000007;
ll ans=0;
ll dp[0][0];

int main()
{
ll n;
cin >> n;
ll table[n]={};
ll mai;
ll a,b=0,ko=0;
rep(i,n) {
    cin >> a;
    if(a==0){
        ko++;
    }
    else {
        if(ko==0){
            table[b]=a;
            b++;
        }
        else{
            table[b]=ko*-1;
            ko=0;b++;
            table[b]=a;
            b++;
        }
    }
}
if(ko!=0){
    table[b]=ko*-1;
    b++;
    ans+=ko*(ko-1)/2;
}

/*  for (int i = 0; i < b; ++i) {
    cout << table[i] << " ";
}cout  << endl; */
ll temp; 

ll bai,sum;

rep(i,b-1){
 //   cout << ans <<' ';
    if(table[i]>0){
        sum=table[i];
        bai=1;
    }
    else{
        ans+=table[i]*(table[i]+1)/2;
        bai=table[i]*-1;
        sum=0;
    }
    for(int k=i+1;k<b;k++){
       // cout << ans <<' ';
        if(table[k]<0){
            ans-=table[k]*bai;
            continue;
        }
        temp=sum^table[k];
        if(temp==(sum|table[k])){
            ans+=bai;
            sum=temp;
        }
        else break;
    }
}
ans+=n;

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





Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define f(i,j,k) for(int i=j;i<k;i++)
using namespace std;
int main(){
    string o,e;
    cin>>o;
    cin>>e;
    string ans;
    f(i,0,o.size()+e.size()){
        if(i%2==0){
            ans=ans+o[i/2];
        }
        else{
            ans=ans+e[i/2];
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <ctype.h>
#include <ios> 
#include <iomanip>
using namespace std;

#define N_MAX   (100000)
#define LL_MAX_NUM (1LL<<60)
#define INF 1e7

typedef long long ll;
typedef long long int lli;

int main() {
	int  A ,B, C;
    string res = "No";
	cin >> A >> B >> C;
    if (A + B >= C) {res = "Yes";}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n=0; char s[3],t[3];
  for(int i=0;i<3;i++)cin>>s[i];
  for(int i=0;i<3;i++)cin>>t[i];
  for(int i=0;i<3;i++) if(s[i]==t[i]) n++;
  cout<<n<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll MOD = (1e+9)+7;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-11;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;
typedef pair<ld, ld> LDP;
int main() {
	int n, m; cin >> n >> m;
	string in;
	char a[50][50], b[50][50];
	bool out = false;
	rep(i, n) {
		cin >> in;
		rep(j, n) {
			a[i][j] = in[j];
		}
	}
	rep(i, m) {
		cin >> in;
		rep(j, m) {
			b[i][j] = in[j];
		}
	}
	rep(i, n - m + 1) {
		rep(j, n - m + 1) {
			bool f = true;
			rep(k, m) {
				rep(l, m) {
					if (a[i + k][j + l] != b[k][l])f = false;
				}
			}
			if (f)out = true;
		}
	}
	if (out)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD 1000000007
const int N = 50;  // Maximum size of matrix
struct matrix
{
    int m[N][N], r, c;
    matrix(int _r = N, int _c = N, bool iden = false)
    {
        r = _r; c = _c;
        memset(m, 0, sizeof(m));
        if (iden) while (_c--) m[_c][_c] = 1;
    }

    matrix operator * (const matrix &B) // Multiplication of two matrix
    {
        matrix C(r, B.c);
        for(int i = 0; i < r; i++)
            for(int k = 0; k < c; k++) if (m[i][k])
                for(int j = 0; j < B.c; j++)
                    C.m[i][j] = (1ll*C.m[i][j] + 1ll*m[i][k]*B.m[k][j]) % MOD;
        return C;
    }
};
matrix pow(matrix A, ll e)
{
    matrix ANS(A.r, A.c, true);
    while (e)
    {
        if (e&1) ANS = ANS * A;
        A = A * A;
        e >>= 1;
    }
    return ANS;
}


int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n; ll k;
	cin >> n >> k;
	matrix mat,caat;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			cin >> mat.m[i][j];
			caat.m[i][j]=mat.m[i][j];
		}
	}
	ll ans = 0;
	mat = pow(mat, k-1);
	ll d[n]; memset(d,0,sizeof d);
	for(int i=0;i<n;i++) for(int j=0;j<n;j++) if(caat.m[i][j]) d[i]++;
	for(int i = 0; i < n; i++)
    {
		for(int j = 0; j < n; j++)
        {
			ans = (ans + (mat.m[i][j]%MOD*d[j]%MOD)%MOD)%MOD;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 384
N, M = map(int, input().split())

AB = [tuple(map(int, input().split())) for _ in range(N)]
CD = [tuple(map(int, input().split())) for _ in range(M)]
INF = 1000000000

for a, b in AB:
    min_dist = INF
    min_cp = -1
    for cp in range(1, M+1):
        dist = abs(a-CD[cp-1][0]) + abs(b-CD[cp-1][1])
        if dist < min_dist:
            min_dist = dist
            min_cp = cp
    print(min_cp)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int N;
    cin >> N;
  	vector<int> t(N);
  	vector<int> x(N);
  	vector<int> y(N);
  	int flag =0;
  	int count=0;
  for(int i=0;i<N;i++){
   	cin >> t.at(i) >> x.at(i) >> y.at(i);       
  }
  for(int i=0;i<N;i++){
	if(t.at(i)%2 == (x.at(i)+y.at(i))%2){
    }
    else{
      count++;
    }
 }
  //flagチェック
  for(int i=0;i<N;i++){
    if(t.at(i) >= (x.at(i)+y.at(i))){
    }
    else{
      flag =1;
    }
  }
  if(count>=1 || flag ==1) cout << "No" << endl;
  else cout << "Yes" << endl;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,n) for(ll i = 0; i < n; i++)
#define rep2(i,start,end) for(ll i = start; i < end; i++)
#define dwn(i,n) for(int i = n; i >= 0; i--)
#define dwn2(i,start,end) for(ll i = start; i >= end; i--)
#define pll pair<ll,ll>
#define mk(x,y) make_pair(x,y)
#define pdl pair<double, ll>
const ll N = 4e5 + 200;
const ll INF = 0x3f3f3f3f;
const ll mod = 1e9 + 7;

ll a[N],b[N];
int main(){
	ll n,k;
	cin>>n>>k;
	ll sum = 0;
	a[0] = n;
	for(int i = 1; i <= n; i++){
		a[i] = a[i-1] + n - i;
//		a[i] %= mod;
	}
	b[0] = 0;
	for(int i = 1; i <= n; i++){
		b[i] = b[i-1] + i;
//		b[i] %= mod;
	}
	for(int i = k-1; i <= n; i++){
		ll tmp = a[i] - b[i] + 1;
		tmp %= mod;
//		cout<<tmp<<endl;
		sum += tmp;
		sum %= mod;
		
	}
	cout<<sum<<endl;


	return 0;
}

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

int main(void){
  long long int N;
  long long int P;

  scanf("%lld",&N);
  scanf("%lld",&P);

  long long int i = pow(P,1.0/N)+1;

  while(1){
    long long int j = pow(i,N);
    if(P%j == 0){
      printf("%lld\n",i);
      break;
    }
    i--;
  }

  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <cmath>
#include <iomanip>
#include <limits>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
using namespace std;

int main(){
    int N,T;
    cin >> N >> T;
    int c[N],t[N];
    for(int i=0;i<N;i++) cin >> c[i] >> t[i];

    int ans=10000;
    for(int i=0;i<N;i++){
        if(t[i] <= T) ans = min(ans,c[i]);
    }
    if(ans==10000) cout << "TLE" << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a),i##_end=(b);i<=i##_end;i++)
#define per(i,b,a) for(int i=(b),i##_st=(a);i>=i##_st;i--)
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define debug(x) cerr<<#x" = "<<x<<endl
#define Debug(...) fprintf(stderr, __VA_ARGS__)
#define Es(x,i) for(Edge *i=G[x];i;i=i->nex)
typedef pair<int,int> pii;
typedef long long ll;
const int inf=~0u>>1,MOD=1e9+7;/*
char *TT,*mo,but[(1<<15)+2];
#define getchar() ((TT==mo&&(mo=(TT=but)+fread(but,1,1<<15,stdin),TT==mo))?-1:*TT++)//*/
inline int rd() {
	int x=0,c=0,f=1;
	for(; c<'0'||c>'9'; c=getchar())f=c!='-';
	for(; c>='0'&&c<='9'; c=getchar())x=x*10+c-'0';
	return f?x:-x;
}
const int N=1e5+11;
int n,L,T;
int p[N];
int main(){
	n=rd(),L=rd(),T=rd();
	int tot=0;
	rep(i,1,n){
		p[i]=rd()+(rd()==1?T:-T);
		tot+=p[i]/L;tot%=n;
		p[i]%=L;tot-=p[i]<0;
		p[i]+=p[i]<0?L:0;
	}
	sort(p+1,p+n+1);
	rep(i,1,n)printf("%d\n",p[(i+tot-1+n)%n+1]);
}

Measured memory_bytes: 1536
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

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

int main(){
    ios_base::sync_with_stdio(0); cin.tie(0);
    ll n;
    cin>>n;
    int m=0;
    ll cn=n;
    while(cn>0){
        m+=cn%10;
        cn/=10;
    }
    if(n%m==0)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
#coding:utf-8

s = str(input())
string  = list(s)
string_unique = list(set(string))

#print(string_unique)

if len(string_unique) == 2:
    if string.count(string_unique[0]) == 1 or string.count(string_unique[0]) == 3:
        print("No")
    else:
        print("Yes")
else:
    print("No")


Measured memory_bytes: 2940
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.Optional;
import java.util.Scanner;

// https://atcoder.jp/contests/abc155/tasks/abc155_c
public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();

/////////////////////////////////////
		HashMap<String, Integer> map = new HashMap<>();
		for (int i = 0; i < N; i++) {
			String str = sc.next();
			if (map.containsKey(str)) {
				map.put(str, map.get(str)+1);
			} else {
				map.put(str, 1);
			}
		}
///////////////////////////////////////
		sc.close();

///////////////////////////////////////
		Optional<Entry<String, Integer>> maxEntry = map.entrySet()
				.stream().max((Entry<String, Integer> e1, Entry<String, Integer> e2) -> e1.getValue().compareTo(e2.getValue())
		        );
		int maxKey = maxEntry.get().getValue();
///////////////////////////////////////
		ArrayList<String> stateList = new ArrayList<String>();
		for(Map.Entry<String, Integer> entry : map.entrySet()){
			if(entry.getValue()==maxKey) {
				stateList.add(entry.getKey());
			}
		}
		Collections.sort(stateList);
		for(int i=0;i<stateList.size();i++){
			System.out.println(stateList.get(i));
		}
	}
}


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

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

  string S; cin >> S;
  if (S[0] != 'A' || S[1] == 'C' || S[S.size()-1] == 'C') {
    cout << "WA\n";
    return 0;
  }
  int count = 0;
  for (int i = 1; i < S.size(); i++) {
    if (S[i] == 'C') count++;
    else if (S[i] >= 'A' && S[i] <= 'Z') {
      cout << "WA\n";
      return 0;
    }
  }
  cout << (count == 1 ? "AC" : "WA") << "\n";
}

Measured memory_bytes: 256
from itertools import accumulate

def solve():
    MOD = 10**9 + 7

    Ss = input()

    dp = [0] * 13
    dp[0] = 1
    for d, Sd in enumerate(Ss):
        dp2 = [0] * 26
        for mod13 in range(13):
            if Sd != '?':
                x = int(Sd)
                mod13n = (10*mod13 + x) % 13
                dp2[mod13n] += dp[mod13]
                dp2[mod13n+1] -= dp[mod13]
            else:
                mod13n = (10*mod13 + 0) % 13
                dp2[mod13n] += dp[mod13]
                dp2[mod13n+10] -= dp[mod13]
        dp2 = list(accumulate(dp2))
        dp = [(a+b) % MOD for a, b in zip(dp2[:13], dp2[13:])]

    print(dp[5])


solve()


Measured memory_bytes: 3188
import numpy as np

def main():
    n = int(input())
    all_sum = (n * (n + 1)) // 2
    b_last = n - np.mod(n, 3)
    c_last = n - np.mod(n, 5)
    d_last = n - np.mod(n, 15)
    #print(b_last)
    #print(c_last)
    #print(d_last)
    #print(all_sum)
    if n >= 3:
        #print(((n - np.mod(n, 3)) // 3))
        #print(((3 + b_last) * ((n - np.mod(n, 3)) // 3)) // 2)
        all_sum -= ((3 + b_last) * ((n - np.mod(n, 3)))) // 6
    else:
        pass
    if n >= 5:
        all_sum -= ((5 + c_last) * ((n - np.mod(n, 5)))) // 10
    else:
        pass
    if n >= 15:
        all_sum += ((15 + d_last) * ((n - np.mod(n, 15)))) // 30
    else:
        pass
    """
    all_sum -= ((3 + b_last) * ((n - np.mod(n, 3)))) // 6
    print(((3 + b_last) * ((n - np.mod(n, 3)))) // 6)
    all_sum -= ((5 + b_last) * ((n - np.mod(n, 5)))) // 10
    print(((5 + c_last) * ((n - np.mod(n, 5)))) // 10)
    all_sum += ((15 + b_last) * ((n - np.mod(n, 15)))) // 30
    print(((15 + d_last) * ((n - np.mod(n, 15)))) // 30)
    """
    ans = all_sum

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

Measured memory_bytes: 27116
function main( input ) {
    const args = input.split('\n');
    const N = parseInt(args[0], 10);
    let arrays = new Array(N+1);
	arrays[0] = [0, 0, 0];
    for(let i = 0; i < N; i++ ){
        arrays[i+1] = args[i+1].split(' ').map( n => parseInt(n, 10)) ;
    }
  
    let isOK = true;

    for(let i = 1; i < N+1; i++ ){
         const bt = arrays[i-1][0];
         const bx = arrays[i-1][1];
         const by = arrays[i-1][2];
         const at = arrays[i][0];
         const ax = arrays[i][1];
         const ay = arrays[i][2];

         let len = Math.abs( ax - bx ) + Math.abs( ay - by );
         if( ax === bx && ay === by ) {
             len = 2;
         }

         if( at - bt < len ) {
             isOK = false;
             break;
         }

         if( (at - bt) % 2 !== (len % 2) ) {
            isOK = false;
            break;      
         }
    }

    console.log( (isOK) ? 'Yes' : 'No' );
}

main( require('fs').readFileSync('/dev/stdin', 'utf8') )

Measured memory_bytes: 61296
n1, n2, n3, n4 = [int(i) for i in input().split()]

x1 = [int(i) for i in input().split()]
y1 = [int(i) for i in input().split()]

x1.append(n3)
y1.append(n4)

x2 = max(x1)
y2 = min(y1)

if x2 < y2:
    print("No War")
else:
    print("War")

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

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

ll lcm(ll a,ll b){
  ll g = gcd(a,b);
  return a / g * b;
}

int main(){
  ll N,M;
  string s,t;
  cin >> N >> M >> s >> t;

  if(s[0] != t[0]){
    cout << "-1" << endl;
    return 0;
  }
  ll l;
  if(N >= M) l = lcm(N,M);
  else l = lcm(M,N);

  ll s_width = l / M;
  ll t_width = l / N;

  bool frag = true;
  ll sw = 0, tw = 0;
  while(frag == true){
    if(s[sw] != t[tw]){
      frag = false;
    }
    sw += s_width;
    tw += t_width;
    if(sw > N-1) break;
    if(tw > M-1) break;
  }
  if(frag) cout << l << endl;
  else cout << "-1" << endl;
  return 0;
}


Measured memory_bytes: 512
n,*s=map(int,open(0).read().split());s,t,f,g=[s[i*n:i*n+n]for i in range(4)];r=range(n);a=[n*[0]for _ in r];e=enumerate
for b in range(64):
 y=1<<b;u=[k&y for k in f];v=[k&y for k in g];l=[0]*n;m=l[:]
 for i,k in e(u):
  for j,h in e(v):
   if(k&h)|((s[i]^1)*k)|((t[j]^1)*h):a[i][j]|=y;l[i]+=1;m[j]+=1
 for i in r:
  if(l[i]==0)*s[i]*u[i]:
   for j in r:
    if(t[j]^1)*(n-m[j]>1):a[i][j]|=y;m[j]+=1;break
  if(m[i]==0)*t[i]*v[i]:
   for j in r:
    if(s[j]^1)*(n-l[j]>1):a[j][i]|=y;l[j]+=1;break
h=a[0][:];w=[i[0]for i in a]
for i,k in e(a):
 for j,l in e(k):w[i]=(l|w[i]if s[i]else w[i]&l);h[j]=(l|h[j]if t[j]else h[j]&l)
if(g!=h)|(f!=w):exit(print(-1))
for i in a:print(*i)

Measured memory_bytes: 99724
// abc103_a
#include <iostream>
#include <algorithm>
using namespace std;

int main(int argc, char *argv[])
{
  int a1, a2, a3;
  cin >> a1 >> a2 >> a3;
  cout << max({a1, a2, a3}) - min({a1, a2, a3}) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <fstream>
#include <stack>
#include <queue>
#include <string>
#include <deque>
#define  endl "\n"
using namespace std;

void FastInput() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}
void OutputFile()
{
    freopen("output.txt","w",stdout);
}


string bigIntegr(string x,string y)
{
    string ans="";
    reverse(x.begin(),x.end());
    reverse(y.begin(),y.end());
    int result=0,carry=0,temp=0;

    for(int i=0;i<x.length();i++)
    {
        temp=x[i]-'0'+y[i]-'0';
        temp+=carry;
        result=temp%10;
        carry=temp/10;
        ans.push_back(result+'0');

    }
    if(carry>0)
        ans.push_back(carry+'0');
    reverse(ans.begin(),ans.end());
    return ans;
}


int main()
{
   FastInput();
   int k,a,b;
   cin>>k>>a>>b;
   bool ans=0;
   for(int i=1;i<=1000;i++)
   {
       if(i*k>=a &&i*k<=b)
       {
           ans=1;
           break;
       }
   }

   ans?cout<<"OK\n":cout<<"NG\n";

    return 0;
}


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

int main(){
  string c;
  cin >> c;
  
  if(c == "a"||c=="e"||c=="i"||c=="o"||c=="u"){
    cout << "vowel" << endl;
  }
    else{cout << "consonant" << endl;}
  }

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll  long long
#define scan(n) scanf("%d",&n)
#define lscan(n) scanf("%lld",&n)
#define print(n) printf("%d ",n)
#define lprint(n) printf("%lld\n",n)
#define rep(i,a,n) for(int i=a;i<n;i++)
#define rev(i,a,n) for(int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define pi pair<int,int>
#define pll pair<ll,ll>
#define tc           ll t1; cin>>t1; while(t1--)
#define inp         ll n; cin>>n; ll arr[n]; rep(i,0,n) cin>>arr[i];
#define vect vector<ll>
#define sortv(v)       sort(v.begin(),v.end())
#define lower(v,n)    lower_bound(v.begin(),v.end(),n)-v.begin()
#define upper(v,n)    upper_bound(v.begin(),v.end(),n)-v.begin()
#define all(v)        v.begin(),v.end()
#define bitcount(n) __builtin_popcount(n)
#define ln <<endl
#define inf          INT_MAX
#define ninf         LONG_MIN
#define fast()         ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
const   ll mod=1e9+7;
const ll N=5e5+5;

int main() 
{ 
          fast();
        
          ll a,b,c,d;
          cin >> a >> b >> c >>d;
          ll ans=b*d;
          if(a*c>ans)
            ans=a*c;
          if(a*d>ans)
            ans=a*d;
          if(b*c>ans)
            ans=b*c;
          if(b*d>ans)
            ans=b*d;
          cout<<ans;
           return 0; 

} 

Measured memory_bytes: 3648
type 'a t = Empty | Node of (int * 'a * 'a t * 'a t)

let rec merge q1 q2 =
    match q1, q2 with
    | Empty, Empty            -> Empty
    | Node(_, _, _, _), Empty -> q1
    | Node(n1, v1, l1, r1), Node(n2, v2, l2, r2) ->
        if v1 < v2
        then Node(n1 + n2, v2, q1, merge l2 r2)
        else Node(n1 + n2, v1, q2, merge l1 r1)
    | _, _ -> failwith "merge"

let pop q =
    match q with
    | Empty -> failwith "pop"
    | Node(_, _, l, r) -> merge l r

let rec push x q =
    match q with
    | Empty -> Node(1, x, Empty, Empty)
    | Node(_, v, l, r) ->
        let large = max x v in
        let small = min x v in
        match l, r with
        | Empty, Empty         -> Node(2, large, Node(1, small, Empty, Empty), Empty)
        | Node(n, _, _, _), Empty -> Node(n + 2, large, l, Node(1, small, Empty, Empty))
        | Node(nl, _, _, _), Node(nr, _, _, _) ->
            if nl > nr
            then Node(nl + nr + 2, large, l, push small r)
            else Node(nl + nr + 2, large, push small l, r)
        | _, _ -> failwith "push"

let top q =
    match q with
    | Empty -> failwith "top"
    | Node(_, v, _, _) -> v

let rec insert_while i ws q =
    match ws with
    | w :: ws' when fst w = i ->
        insert_while i ws' (push (snd w) q)
    | _ -> (ws, q)

let rec solve ws m q i sum =
    if i > m then sum
    else
        let (ws', q') = insert_while i ws q in
        if q' = Empty
        then solve ws' m q' (i + 1) sum
        else solve ws' m (pop q') (i + 1) (sum + top q')

let rec input n =
    if n = 0 then []
    else Scanf.scanf "%d %d\n" @@ fun a b ->
        let ws = input (n - 1) in
        (a, b) :: ws

let () =
    Scanf.scanf "%d %d\n" @@ fun n m ->
    let ws = input n in
    let ws' = List.sort (fun a b -> compare (fst a) (fst b)) ws in
    Printf.printf "%d\n" @@ solve ws' m Empty 1 0


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

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


#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};


int main()
{
    std::cout << std::fixed;
    std::cout << std::setprecision(10);
    double l;
    cin>>l;
    cout<<pow(l/3.0,3)<<endl;
    
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
    int n,k;cin>>n>>k;
    vector<int> p;
    for(int i=0;i<n;i++){
        int t;cin>>t;
        p.push_back(t);
    }
    sort(p.begin(),p.end());
    int sum=0;
    for(int i=0;i<k;i++){
        sum+=p[i];
    }
    cout<<sum<<endl;
}

Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
/* clang-format off */
#define MOD 1000000007
#define INF 1000000000
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define ALL(a) (a).begin(), (a).end()
#define __DEBUG__
#ifdef __DEBUG__
#define CH_P(a) cout <<"check_point("<<#a<<")" << "\n";
#define DEBUG(x) cout<<#x<<":"<<x<<"\n"
#define DEBUGS(v) cout << #v << ":";for(auto x:v){cout<<x<<" ";}cout<<"\n"
#endif
#ifndef __DEBUG__
#define CH_P(a) 
#define DEBUG(x) 
#define DEBUGS(v) 
#endif
#define TIMER_S(start) chrono::system_clock::time_point start = chrono::system_clock::now();
#define TIMER_E(end) chrono::system_clock::time_point end = chrono::system_clock::now();
#define TIME(start, end) cout << static_cast<double>(chrono::duration_cast<chrono::microseconds>(end - start).count()) << "ms" << "\n";
/* clang-format on */

int main() {
  int x, n, ans = INF, difabs = INF;
  cin >> x >> n;
  vector<int> p(n);
  REP(i, n) { cin >> p[i]; }
  for (int i = x + 101;; i--) {
    bool f = true;
    REP(j, n) {
      if (i == p[j]) {
        f = false;
        break;
      }
    }
    if (!f) continue;
    if (difabs < abs(x - i)) {
      cout << ans << endl;
      return 0;
    }
    difabs = abs(x - i);
    ans = i;
  }
  return 0;
}


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

using namespace std;

typedef long long ll;

ll count(ll s, ll t, ll x) {
	ll a = (s - 1) / x;
	ll b = t / x;
	// cout << a << " " << b << endl;
	return b - a;
}

ll gcd(ll a, ll b) {
	return b ? gcd(b, a % b) : a;
}

int main() {
	ll a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << (b - a + 1) - count(a, b, c) - count(a, b, d) + count(a, b, c * d / gcd(c, d)) << endl;
	return 0;
}

Measured memory_bytes: 256
def g(m,n):
    x=max(m,n)
    y=min(m,n)
    if x%y==0:
        return y
    else:
        while x%y!=0:
            z=x%y
            x=y
            y=z
        else:
            return z
from decimal import Decimal
A,B,C,D=map(lambda x:Decimal(int(x)),input().split())



if A%C==0:
    x=B//C-A//C+1
else:
    x=B//C-A//C
if A%D==0:
    y=B//D-A//D+1
else:
    y=B//D-A//D
E=Decimal(C*D//g(C,D))
if A%E==0:
    z=B//E-A//E+1
else:
    z=B//E-A//E
print(B-A+1-(x+y-z))


Measured memory_bytes: 5076
#include <stdio.h>

#define MAXN 100
#define INF 2001
#define WHITE 0
#define BLACK 1

void prim(int *, int *, int *,int);

int main()
{
  int i, j, u, n, souwa = 0, d[MAXN], pi[MAXN], color[MAXN], M[MAXN][MAXN], mincost;

  scanf("%d",&n);

  for(i = 0; i < n; i++) {
    for(j = 0; j < n; j++) {
      scanf("%d",&M[i][j]);
    }
  }
  prim(d, pi, color, n);
  
  while(1) {
    mincost = INF;
    for(i = 0; i < n; i++) {
      if(color[i] != BLACK && d[i] < mincost) {
	mincost = d[i];
	u = i;
      }
    }

    if(mincost == INF) break;

    color[u] = BLACK;

    for(i = 0; i < n; i++) {
      if(color[i] != BLACK && M[u][i] < d[i] && M[u][i] >= 0) {
	pi[i] = u;
	d[i] = M[u][i];
      }
    }
    
  }

  for(i = 0; i < n; i++) {
    souwa += d[i];
  }
  printf("%d\n",souwa);
   
  return 0;
}

void prim(int *d, int *pi, int *color, int n)
{
  int i;

  for(i = 0; i < n; i++) {
    d[i] = INF;
    pi[i] = -1;
    color[i] = WHITE;
  }
  d[0] = 0;
}




Measured memory_bytes: 2080