akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define MAX 10000

using namespace std;
typedef long long ll;

int main(){

 int n = 5,k;
 int a[n];

 for(int i=0;i<5;i++)
    cin>>a[i];

    cin>>k;

 for(int i=0;i<n-1;i++)
 {
    for(int j=i+1;j<n;j++)
    {
        if(a[j] - a[i] > k){
        cout<<":("<<endl;
         return 0; }
    }
 }

 cout<<"Yay!"<<endl;


return 0;
}

Measured memory_bytes: 3572
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
	string a,b;
	cin>>a>>b;
	int i=0,j=0;
	while(i<a.length()||j<b.length())
	{
		if(i<a.length())
		cout<<a[i];
		if(j<b.length())
		cout<<b[j];
		i++;
		j++;
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main
{
	int N,M;
	int[] C,x;
	int[][] dp;
	public void solve()
	{
		Scanner cin = new Scanner(System.in);
		while(true)
		{
			N = cin.nextInt();
			M = cin.nextInt();
			if(N == 0 && M == 0)break;
			C = new int[M];
			x = new int[N];
			dp = new int[N + 1][600];
			for(int i = 0;i < M;i++)C[i] = cin.nextInt();
			for(int i = 0;i < N;i++)x[i] = cin.nextInt();
			for(int i = 0;i < N + 1;i++)
			{
				for(int j =0;j < 600;j++)
				{
					if(i == 0)
					{
						dp[i][j] = 0;
						continue;
					}
					dp[i][j] = Integer.MAX_VALUE;
				}
			}
			for(int i = 0;i < N;i++)
			{
				if(i == 0)
				{
					for(int k = 0;k < M;k++)
					{
						int next = 128 + C[k];
						if(128 + C[k] <= 0)next = 0;
						else if(128 + C[k] >= 255)next = 255;
						dp[i + 1][next] = 
							Math.min(dp[i + 1][next],dp[i][128] + (x[i] - next) * (x[i] - next));
					}
				}else
				{
					for(int j = 0; j<= 255;j++)
					{
						if(dp[i][j] == Integer.MAX_VALUE)continue;
						for(int k = 0;k < M;k++)
						{
							int next = j + C[k];
							if(next <= 0) next = 0;
							else if(next >= 255) next = 255;
							dp[i + 1][next] = 
								Math.min(dp[i + 1][next],dp[i][j] + (x[i] - next) * (x[i] - next));
						}
					}
				}
			}
			int ans = Integer.MAX_VALUE;
			for(int i = 0;i <= 255;i++)
			{
				//System.out.println(i + " : " + dp[N][i]);
				ans = Math.min(ans,dp[N][i]);
			}
			System.out.println(ans);
			//System.out.println(dfs(0,128));
		}
		
		
	}
	public static void main(String[] args)
	{
		new Main().solve();
	}
}

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


int main() {
    long long A,B,C,D;
    cin >> A >> B >> C >> D;
    
    if(((B+C-1)/B) <= ((A+D-1)/D)) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 200200;
int n , m ;
char s[N] , t[N];


int main(){

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

ll k = 1ll*n/__gcd(n,m)*m;

map<ll,char>mp;
ll j=0;
for(int i=0;i<n;i++,j+=k/n)mp[j]=s[i];

j=0;
for(int i=0;i<m;i++,j+=k/m)
if( mp.count(j) && mp[j] != t[i] ){
    printf("-1\n");
    return 0;
}

printf("%lld\n",k);
return 0;
}


Measured memory_bytes: 6144
# by the authority of GOD     author: manhar singh sachdev #

import os,sys
from io import BytesIO, IOBase

def main():
    n,k = map(int,input().split())
    p = list(map(int,input().split()))
    c = list(map(int,input().split()))
    ans = -10**20
    for i in range(1,n+1):
        cou = 1
        se = {i}
        ne = p[i-1]
        su = [c[ne-1]]
        maxi = c[ne-1]
        while ne not in se and cou < k:
            se.add(ne)
            ne = p[ne-1]
            su.append(su[-1]+c[ne-1])
            maxi = max(maxi,su[-1])
            cou += 1
        if su[-1] > 0 and cou<k:
            maxi = max(maxi,su[-1]*(k//len(su))+max(su[:k%len(su)]+[-10**20]),su[-1]*(k//len(su)-1)+max(su))
        ans = max(ans,maxi)
    print(ans)

#Fast IO Region
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

if __name__ == '__main__':
    main()

Measured memory_bytes: 173060
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast") 
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n;i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
# define PI  3.14159265358979323846
#define MOD 1000000007
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
const int N = 2e6+5;
const int INF = 1e18L;
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}
int ar[N];
int dp[N];
signed main(){
	// #ifndef ONLINE_JUDGE
	// freopen("input.txt","r",stdin);
	// freopen("output.txt","w",stdout);
	// #endif
	IOS;
	int T=1;
	// cin >> T;
	while(T--){
		int a, b,c,d;
		cin >>a>>b>>c>>d;
		while(a >0 && b>0){
			c-=b;
			if(c<=0)break;
			a-=d;
			if(a<=0)break;
		}
		if(a>0){
			cout <<"Yes";
		}else
		cout<<"No";
	
	
	}
	cerr << "Time Taken : " << 1.0 * clock() / CLOCKS_PER_SEC << " sec \n";
	return 0;
}

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

int X;
int expo[1023];
int main(){
    scanf("%d", &X);
    expo[1] = true;
    for(int b =2; b<X; b++){
        int x=b;
        while(x*b<=X){
            x*=b;
            expo[x] = true;
        }
    }
    for(int i=X; i>0; i--){
        if(expo[i]){
            printf("%d", i);
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <algorithm>
const int MAX = 2e5 + 10;
using namespace std;

int main()
{
	string s; cin>>s;

	int n = s.length();

	int i=0; int a[MAX] = {0};

	while(i < n) {
		int j = i; int b = 0;
		while(s[j] == 'R') j++;


		int re = j-1;
		int le = j;
		while(s[j] == 'L') j++;
		
		b += j-i;	
		a[re] = b/2;
		a[le] = b/2;	
		if(b%2 == 1) {
			int nr = re-i+1;
			int nl = j-le;
			if(nr > nl) {
				if(nr%2) a[re]++;
				else a[le]++;
			}
			else{
				if(nl%2) a[le]++;
				else a[re]++;
			}
		}
		i = j;
	}

	for(int i=0;i<n;i++) cout<<a[i]<<" ";
}


Measured memory_bytes: 1408
def read_values():
    return map(int, input().split())


def read_list():
    return list(map(int, input().split()))


def main():
    N, T = read_values()
    A = read_list()

    m = A[0]
    p = 0
    D = {}
    for a in A:
        if m > a:
            D[p - m] = D.setdefault(p - m, 0) + 1
            m = a
            p = a
        else:
            p = max(p, a)
    D[p - m] = D.setdefault(p - m, 0) + 1

    k = max(D.keys())
    print(D[k])


if __name__ == "__main__":
    main()


Measured memory_bytes: 14252
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}

/*------------------------------------------------------------------*/

int main(){
    ll a, b, n; cin >> a >> b >> n;
    ll ans;
    if(n >= b){ 
        ans = (a * (b - 1) / b) - a * ((b - 1) / b);
    }else{
        ans = (a * n / b) - a * (n / b);
    }
    cout << ans << endl;
}

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

int main(void) {
  int sx, sy, tx, ty;
  cin>>sx>>sy>>tx>>ty;
  const int dx = tx - sx, dy = ty - sy;

  cout << string(dy, 'U') << string(dx, 'R');
  cout << string(dy, 'D') << string(dx, 'L');
  cout << 'L' << string(dy + 1, 'U') << string(dx + 1, 'R') << 'D';
  cout << 'R' << string(dy + 1, 'D') << string(dx + 1, 'L') << 'U';
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
li=input()
n=len(li)
child_li=[0]*n



ruiseki=0
for i in range(n-1):
    if li[i]=='R':
        ruiseki+=1
        if li[i+1]=='L':
            child_li[i+1]=ruiseki//2
            child_li[i]=(ruiseki+1)//2
    else:
        ruiseki=0


ruiseki=0
for i in range(n-1, 0, -1):
    if li[i]=='L':
        ruiseki+=1
        if li[i-1]=='R':
            child_li[i-1]+=ruiseki//2
            child_li[i]+=(ruiseki+1)//2
    else:
        ruiseki=0

print(*child_li)


Measured memory_bytes: 6400
package main

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

const (
	defaultBufferSize = 1024
	maxBufferSize     = 1e6
	Mod               = 1e9 + 7
)

var sc = bufio.NewScanner(os.Stdin)

// sc.Buffer(make([]byte, defaultBufferSize), maxBufferSize)

func readInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func readString() string {
	sc.Scan()
	return sc.Text()
}

func readInt64() int64 {
	sc.Scan()
	i, err := strconv.ParseInt(sc.Text(), 10, 64)
	if err != nil {
		panic(err)
	}
	return int64(i)
}

func readfloat64() float64 {
	sc.Scan()
	f, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}
	return f
}

func abs(a int) int {
	if a < 0 {
		return a * -1
	}
	return a
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

func gcd(x, y int) int {
	if y == 0 {
		return x
	}
	return gcd(y, x%y)
}

func ModComb(n, k int) int {
	if k == 0 {
		return 1
	}
	x, y := n, k
	for i := 1; i < k; i++ {
		x = x * (n - i) % Mod
		y = y * (k - i) % Mod
	}
	inv := ModInv(y)
	return x * inv % Mod
}

func ModFact(x int) int {
	fact := 1
	for i := 1; i <= x; i++ {
		fact = fact * i % Mod
	}
	return fact
}

func ModInv(x int) int {
	return ModPow(x, Mod-2)
}

func ModPow(a, n int) int {
	res := 1
	for n > 0 {
		if n%2 != 0 {
			res = res * a % Mod
		}
		a = a * a % Mod
		n /= 2
	}
	return res
}

func pow(a, n int) int {
	if n == 0 {
		return 1
	}

	ans := 0
	if n%2 == 0 {
		ans = pow(a*a, n/2)
	} else {
		ans = a * pow(a*a, (n-1)/2)
	}
	return ans
}

func intSliceReverse(slice []int) []int {
	for i, j := 0, len(slice)-1; i < j; i, j = i+1, j-1 {
		slice[i], slice[j] = slice[j], slice[i]
	}
	return slice
}

func stringReverse(str string) string {
	runes := []rune(str)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func primeFactorization(x int) map[int]int {
	result := make(map[int]int, 0)
	for i := 2; i*i <= x; i++ {
		for x%i == 0 {
			result[i]++
			x /= i
		}
	}
	if x != 1 {
		result[x]++
	}
	return result
}

func isPrime(x int) bool {
	if x == 1 {
		return false
	}
	for i := 2; i*i <= x; i++ {
		if i == x {
			continue
		}
		if x%i == 0 {
			return false
		}
	}
	return true
}

func main() {
	sc.Split(bufio.ScanWords)
	n := readInt()
	a := make([]int, n)
	for i, _ := range a {
		a[i] = readInt()
	}
	aa := make([]int, n)
	copy(aa, a)
	sort.Sort(sort.Reverse(sort.IntSlice(aa)))

	first := aa[0]
	second := aa[1]
	for _, v := range a {
		if v == first {
			fmt.Println(second)
		} else {
			fmt.Println(first)
		}
	}
}


Measured memory_bytes: 7488
process.stdin.resume();
process.stdin.setEncoding('utf8');
// Your code here!

var lines = [];
var reader = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout
});
reader.on('line', (line) => {
    // ここで入力を処理する
    lines.push(line);
});
reader.on('close', () => {
    // ここで出力する
    var a = lines[1].split(" ").map(function(a){return parseInt(a);});
    var n = parseInt(lines[0]);
    
    insertSort(a,n);
});

function insertSort(a, n){
    for (var i = 0;i < n;i++){
        var v = a[i];
        var j = i-1;
        while(j >= 0){
            if (a[j] <= v) break;
            a[j+1] = a[j];
            j--;
        }
        a[j+1] = v;
        console.log(a.join(" "));
    }
}


Measured memory_bytes: 17000
#include "bits/stdc++.h"
using namespace std;
/////////////////// TYPES & MACROS ///////////////////////////////
#define mp make_pair
#define eb emplace_back
#define pb push_back
#define all(x) x.begin(),x.end()
#define ff first
#define ss second
#define vv vector
#define exist(s,e) (s.find(e)!=s.end())
#define sz(x) ((int)(x).size())
#define int ll
typedef long long ll; typedef long double ld; typedef double dd;typedef vector<int> vi; typedef pair<int, int> pii;typedef pair<ll,ll> pll;
ll INFLL=(ll)4e18, MOD=1e9+7; const int INF=0x3f6f6f6f;
//////////////////// DEBUG /////////////////////////////////////////
#define D(x) cerr<<#x<<" is:\t"<<x<<'\n';
#define DD(x,y) cerr<<'('<<#x<<','<<#y<<") are:\t"<<x<<' '<<y<<'\n';
#define DDD(x,y,z) cerr<<'('<<#x<<','<<#y<<','<<#z<<") are:\t"<<x<<' '<<y<<' '<<z<<'\n';
/////////////////// VARIABLES & FUNCTIONS//////////////////////////
vv<vv<int>> adj; vi vis, color, level; int dx8[]={0,1,1,1,0,-1,-1,-1}, dy8[]={1,1,0,-1,-1,-1,0,1},dx4[]={0,1,0,-1}, dy4[]={1,0,-1,0};
inline ll mexp(ll x,ll n,ll m=MOD){ll res=1;x%=m;while(n){if(n&1)res=(res*x)%m;n>>=1;x=(x*x)%m;}return res;}
inline ll gcd(ll a, ll b){while (a>0 && b>0){if(a>b)a%=b;else b%=a;}return a+b;}



///////////////////// MAIN STARTS //////////////////////////////////
int32_t main(void){
ios_base::sync_with_stdio(false);cin.tie(NULL); cout.tie(NULL);
cout<<fixed;cerr<<fixed; cout<<setprecision(1); cerr<<setprecision(3);
mt19937 genr(chrono::high_resolution_clock::now().time_since_epoch().count());


ll n,w; cin>>n>>w;
vv<ll> dp(w+1,-INFLL);
dp[0]=0;
for(int i=0;i<n;++i){
    ll wt, v; cin>>wt>>v;
    for(int i = w-wt; i >= 0; i--){
        dp[i+wt]=max(dp[i+wt], dp[i]+v);
    }
}
cout<< *max_element(all(dp))<<'\n'; 



return 0;
}


Measured memory_bytes: 1024
from operator import mul
from functools import reduce
n,k = map(int,input().split())
p = 1000000007


def cmb(x,y):
    if x < 0 or y < 0: return 0
    y = min(x-y,y)
    if y == 0: return 1
    over = reduce(mul, range(x, x - y, -1))
    under = reduce(mul, range(1,y + 1))
    return (over // under)%p


for i in range(1,k+1):
  print((cmb(k-1,i-1)*cmb(n-k+1,n-k-i+1))%p)

Measured memory_bytes: 3944
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int n,m=0,a=0,aa[110000],cnt=0;
pair<int,string> p[220000];
string s,ss[220000];
char c;
signed main(){
    cin>>n;
    rep(i,n){
        cin>>ss[i];
    }
    sort(ss,ss+n);
    rep(i,n){
        if(p[m].second!=ss[i]){
            p[m].first=cnt;
            a=max(a,cnt);
            m++;
            p[m].second=ss[i];
            cnt=1;
        }else{
            cnt++;
        }
    }
    p[m].first=cnt;
    a=max(a,cnt);
    rep(i,m+1){
        if(p[i].first==a){
            cout<<p[i].second<<endl;
        }
    }
}

Measured memory_bytes: 17920
#include<bits/stdc++.h>
using namespace std;
int main(){
  int w,h,c,i,num,hd,wd;
  int sum = 0;
  cin >> w >> h >> c;
  hd = h;
  wd = w;
  if(hd == wd) cout << c << endl;
  else{
    while(1){
      if(w>h){
	if(w%h == 0){
	  num = h;
	  break;
	}
	w = w%h;
      }
      if(h>w){
	if(h%w == 0){
	  num =w;
	  break;
	}
	h = h%w;
      }
    }
 

  cout << ((hd*wd)/(num*num))*c << endl;
  }
  return 0;
}



Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
string a,b;
int lena,lenb;
int main()
{
    getline(cin,a);
    getline(cin,b);
    sort(a.begin(),a.end());
    sort(b.begin(),b.end(),greater<char>());
    if(a<b)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define endl '\n'
typedef long long ll;
using namespace std;
int main()
{
    FASTIO
    ll n, k;
    cin >> n >> k;
    n %= k;
    cout << min(n, abs(n - k)) << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cassert>
#include<stdexcept>
#include<utility>
#include<functional>
#include<numeric>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<array>
#include<stack>
#include<queue>
#include<deque>
#include<vector>
#include<complex>
#include<set>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include<string>
#include<bitset>
using namespace std;
using ll=long long;

const ll MOD=1e9+7;

void add(ll& lhs,ll rhs){
    lhs=(lhs+rhs)%MOD;
}
int main(){
    int n,k;
    cin>>n>>k;
    vector<vector<vector<ll>>> dp(n+1,vector<vector<ll>>(n+1,vector<ll>(n*n+1)));

    dp[0][0][0]=1;
    for(int i=0;i<n;i++){
        for(int j=0;j<=n;j++){
            for(int s=0;s<=n*n;s++){
                if(j+1<=n && s+2*(j+1)<=n*n){
                    add(dp[i+1][j+1][s+2*(j+1)],dp[i][j][s]);
                }
                if(s+2*j<=n*n){
                    add(dp[i+1][j][s+2*j],dp[i][j][s]*j+dp[i][j][s]*(j+1));
                }
                if(j-1>=0 && s+2*(j-1)<=n*n){
                    add(dp[i+1][j-1][s+2*(j-1)],dp[i][j][s]*j%MOD*j);
                }
            }
        }
    }
    cout<<dp[n][0][k]<<endl;
    return 0;
}


Measured memory_bytes: 52224
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#include <queue>

using namespace std;
//ifstream cin("1.in");
//ofstream cout("1.out");

const int MAXN = 1e5 + 10;
vector <int> v[MAXN];
vector <int> p[MAXN * 2];
vector <int> be[MAXN];

int st[MAXN];
class Edges{
public:
	int next , to , c;
};
Edges edge[MAXN * 4];
int g[MAXN * 4] , rk[MAXN * 4];
int first[MAXN] , n , m , te = 1 , dis[MAXN] , q[MAXN] , l , r , block = 0;
bool flag[MAXN * 4];

void add(int s , int t , int c){
	++ te;
	edge[te].next = first[s];
	edge[te].to = t;
	edge[te].c = c;
	g[te] = c;
	first[s] = te;
	v[s].push_back(te);
}

bool cmp(int t1 , int t2){
	return edge[t1].c < edge[t2].c;
}

bool cmp1(int x , int y){
	return g[x] < g[y];
}

void work(int po , int c){
//	cout << po << " " << c << endl;
//	cin.get();
//	cin.get();
	p[block].push_back(po);
	be[po].push_back(block);
	int len = v[po].size();
	while(st[po] < len){
		int e = v[po][st[po]];
		if(edge[e].c == c){
			st[po] ++;
			if(!flag[e]){
				flag[e] = flag[1 ^ e] = 1;
				work(edge[e].to , c);
			}
		}
		else
			break;
	}
}

int main(){
	ios::sync_with_stdio(0);
	cin >> n >> m;
	for(int i = 1 ; i <= m ; ++ i){
		int p , q , s;
		cin >> p >> q >> s;
		add(p , q , s);
		add(q , p , s);
	}
	for(int i = 1 ; i <= n ; ++ i)
		sort(v[i].begin() , v[i].end() , cmp);
	for(int i = 1 ; i < te ; ++ i)
		rk[i] = i + 1;
	sort(rk + 1 , rk + te , cmp1);
	for(int i = 1 ; i < te ; ++ i)
		if(!flag[rk[i]]){
			int p = edge[rk[i]].to;
			++ block;
//			cout << "Now : " << block << endl;
			work(p , edge[rk[i]].c);
		}
	memset(dis , -1 , sizeof dis);
	dis[1] = 0;
	l = 0 , r = 0;
	q[++ r] = 1;
	memset(flag , 0 , sizeof flag);
	while(l < r){
		++ l;
		int t = q[l] , len = be[t].size();
		for(int i = 0 ; i < len ; ++ i){
			int now = be[t][i] , len1 = p[now].size();
			if(flag[now]) continue;
			else{
				flag[now] = 1;
				for(int j = 0 ; j < len1 ; ++ j){
					int np = p[now][j];
//					cout << now << " " << np << endl;
					if(dis[np] == -1){
						++ r;
						q[r] = np;
						dis[np] = dis[t] + 1;
//						cout << "Dis : " << np << " " << dis[np] << " " << t << endl;
					}
				}			
			}
		}
	}
	cout << dis[n] << endl;
	return 0;
}

Measured memory_bytes: 33780
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define krep(i,k,n,m) for(int i=k;i<n;i+=m)
#define erep(i,k,n) for(int i=k;i<n;i++)
#define mod 1000000007;
//最大公約数
int gcd(int s,int b){
    if(b==0)return s;
    return gcd(b,s%b);
}
signed main() {
    int n;
    cin>>n;
    int a[n];
    rep(i,n){
        cin>>a[i];
    }
    for(int i=n-2;i>=0;i--){
        if(a[i+1]<a[i]){
            a[i]--;
        }
    }
    rep(i,n-1){
        if(a[i]>a[i+1]){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
}


Measured memory_bytes: 1024
#include<stdio.h>
int main()
{
    int A,B,C;
    scanf("%d %d %d",&A,&B,&C);
    if(A==5&&B==7&&C==5||A==5&&B==5&&C==7||A==7&&B==5&&C==5)
       
          printf("YES\n");
       
    else
       
          printf("NO\n");
       
    return 0;
 }

Measured memory_bytes: 1644
'use strict'
function main(inp) {
  const lcm = (a, b) => {
    const gcd = (x, y) => y === 0 ? x : gcd(y, x%y);
    return (a * b) / gcd(a, b)
  }
  
  inp = inp.trim().split(' ').map(n => Number(n))
  
  console.log(lcm(...inp))
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));


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

using namespace std;

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

	vector<int> a(n), b(n), c(m), d(m);
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}
	for (int i = 0; i < m; i++) {
		cin >> c[i] >> d[i];
	}

	vector<int> ans(n, -1);
	for (int i = 0; i < n; i++) {
		int pos = -1;
		int min_dist = 1e9;
		for (int j = 0; j < m; j++) {
			int dist = abs(a[i] - c[j]) + abs(b[i] - d[j]);
			if (dist < min_dist) {
				min_dist = dist;
				pos = j;
			}
		}
		ans[i] = pos + 1;
	}

	for (auto e : ans) {
		cout << e << endl;
	}

	return 0;
}


Measured memory_bytes: 256
using System;

namespace Test
{
    
    class MainClass
    {
        public static void Main(string[] args)
        {
            var inputs = Array.ConvertAll(Console.ReadLine().Split(), double.Parse);

            var a = inputs[0];
            var b = inputs[1];
            var C = inputs[2];
            var Crad = C * (Math.PI / 180);
            var c = Math.Sqrt(a * a + b * b - (2 * a * b * Math.Cos(Crad)));
            var L = a + b + c;
            var h = Math.Sin(Crad) * b;
            var a1 = Math.Cos(Crad) * b;
            var a2 = a - a1;
            var S = ((a1 * h) / 2) + ((a2 * h) / 2);

            Console.WriteLine("{0} {1} {2}", S, L, h);
        }
    }
}

Measured memory_bytes: 5776
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <queue>
#include <map>
#include <string>
#include <algorithm>
#include <cmath>
using namespace std;

int n, m, k;
int main(int argc, char const *argv[])
{
    cin >> n >> m >> k;
    for (int i = 0; i <= n; i++) {
        for (int j = 0; j <= m; j++) {
            if (i * m + j * n - i * j - i * j == k) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
n = int(input())
s = sorted([int(input()) for _ in range(n)])

grade = 0 if sum(s) % 10 == 0 else (sum(s))

if grade == 0:
    for i in s:
        if i % 10 != 0:
            print(sum(s) - i)
            exit()

print(grade)


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

int a, b;
int main()
{
	cin >> a >> b;
	if (a == 1) a = 14;
	if (b == 1) b = 14;
	if (a == b) cout << "Draw";
	else if (a > b) cout << "Alice";
	else cout << "Bob";
	cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
typedef long long ll;
#define REP(i,n) for(int i = 0;i < (n);i++)
#define rep(i,m,n) for(int i = (m);i < (n);i++)
#define P pair<int,int>
#define pb push_back
#define mk make_pair
using namespace std;
#define Vec(a) vector <int> a
const int INF = 1 << 20;
const int MOD = 1e9+7;





int main(){
  int rz,w,c,r;
  while(cin >> rz >> w >> c >> r,w){
    double d = (rz)/w;
    if(d >= c){
      cout << 0 << endl;
    }
    else{
      int k = 1;
      while(k*r <  c*w-rz){
	k++;
      }
      cout << k << endl;
    }
  }
  return 0;
}



Measured memory_bytes: 3080
process.stdin.resume();
process.stdin.setEncoding('utf8');
var is = '';

process.stdin.on('data', (ch) => {
  is += ch;
});

process.stdin.on('end', () => {
  var l = is.split('\n')
    , n = l[0]
    , a =l[1];
  console.log(n % 500 - a <= 0 ? 'Yes' : 'No');
});

Measured memory_bytes: 7500
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

ll inf=1ll<<60;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	ll n,i,j,t,m;
	cin>>n;
	vector<vector<ll>> p(n,vector<ll> (26,0));
	vector<string> g(n);
	for (i=0;i<n;i++){
		cin>>g[i];
	}
	for (i=0;i<n;i++){
		for (j=0;j<g[i].size();j++){
			t=g[i][j]-'0';
			t-=49;
			p[i][t]++;
		}
	}
	for (i=0;i<26;i++){
		m=inf;
		for (j=0;j<n;j++){
			m=min(m,p[j][i]);
		}
		for (j=0;j<m;j++){
			cout<<(char)(i+97);
		}
	}
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Console = System.Console;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var r = ReadStringArray();
            var A = int.Parse(r[0]);
            var B = int.Parse(r[2]);
            if (r[1] == "+")
            {
                Console.WriteLine(A + B);
            }
            else
            {
                Console.WriteLine(A - B);
            }
        }

        private static readonly Func<string> Read = () => Console.ReadLine();
        private static readonly Func<string[]> ReadStringArray = () => Console.ReadLine().Split();
        private static readonly Func<int> ReadInt = () => int.Parse(Console.ReadLine());
        private static readonly Func<long> ReadLong = () => long.Parse(Console.ReadLine());
        private static readonly Func<int[]> ReadIntArray = () => Console.ReadLine().Split().Select(int.Parse).ToArray();
        private static readonly Func<long[]> ReadLongArray = () => Console.ReadLine().Split().Select(long.Parse).ToArray();
        private static readonly Action<string> Cw = str => Console.WriteLine(str);
    }
}

Measured memory_bytes: 11220
#include<bits/stdc++.h>
typedef long long ll;
typedef long double ld;
using namespace std;

using Pii = pair<int, int>;
using Pll = pair<ll, ll>;

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

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

template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    int n; cin >> n;
    vector<ll> lis(n);
    REP(i, 0, n){scanf("%lld", &lis[i]);}
    ll setwise = lis[0];
    REP(i, 1, n){
        setwise = gcd(setwise, lis[i]);
    }
    vector<int> flag(2 * 1e6, 0);
    int f = 1;
    REP(i, 0, n){
        if(f == 0){break;}
        ll dd = 2;
        ll cp = lis[i];
        while(dd *dd <= cp+10){
            if(cp % dd == 0){
                while(cp % dd == 0){
                    cp /= dd;
                }
                if(flag[dd] != 0 && cp!= 1){
                    f = 0;
                    break;
                }
                flag[dd]++;
            }else{
                dd++;
            }
        }
        if(flag[cp] != 0 && cp != 1){
            f = 0;
            break;
        }
        flag[cp]++;
    }
    if(f == 1){
        cout << "pairwise coprime" << endl;
    }else if(setwise == 1){
        cout << "setwise coprime" << endl;
    }else{
        cout << "not coprime" << endl;
    }
}


Measured memory_bytes: 18832
#include <iostream>
using namespace std;
int main() {
    int n = 0;
    cin >> n;
    int height[n] = {0};
    int count = 0;
    for (int i = 0; i < n; ++i) {
        cin >> height[i];
    }
    int max = height[0];
    for (int j = 0; j < n; ++j) {
        if(max <= height[j]){
            count++;
            max = height[j];
        }
    }

    cout<<count;
    return 0;
}

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


int main() {
    int n;
    cin >> n;
    int count = 0;
    for (int i = 1; i <= n; i++) {
        string si = to_string(i);
        if (si.size() % 2) count++;
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<functional>
#include<math.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pf(n) printf("%d\n",n)
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1001001001;
const double PI = acos(-1);

int main() {
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i];
	bool exist = false;
	rep(i, n) {
		if (a[i] == 1) exist = true;
	}
	if (!exist) {
		cout << -1 << endl;
		return 0;
	}

	int cnt = 0;
	int num = 1;
	rep(i, n) {
		if (a[i] == num) {
			num++;
			continue;
		}
		cnt++;
	}
	pf(cnt);

	return 0;
}

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


int main(){

    ll n ,t,i ;
    string r ,s ;
    cin >> n ;
    ll sm= INT_MAX ,x,ans=0;
    for(i=0;i<n;i++){
        cin >> x ;

        if (x<sm)
            ans++ ;
        sm=min(sm,x) ;
    }
    cout << ans << endl ;
    return 0 ;
}


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


int main(void) {
  int n, m;
  cin >> n >> m;
  vector<int> v(n, 0);
  rep(i, m) {
    int a, b;
    cin >> a >> b;
    v[--a]++;
    v[--b]++;
  }

  rep(i, n) {
    cout << v[i] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(a) a.begin(), a.end()
#define mod 1000000007
#define MOD 998244353
#define INF 40000000000000000
int dx8[8] = {-1, 0, 1, 1, 1, 0, -1, -1};
int dy8[8] = {1, 1, 1, 0, -1, -1, -1, 0};
int dx4[4] = {-1, 0, 1, 0};
int dy4[4] = {0, -1, 0, 1};
template <class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
int sum(int n){
    int res=0;
    while(n>0){
        res+=n%10;
        n/=10;
    }
    return res;
}
signed main() {
    int a,b;cin>>a>>b;
    int N;cin>>N;
    rep(i,N){
        int fi,en;cin>>fi>>en;
        if(b<=fi||en<=a)continue;
        cout<<1<<endl;
        return 0;
    }
    cout<<0<<endl;
}



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

using namespace std;

char s[11], lit[]="ACGT";
int lmax = 0;
int main()
{
    cin>>s;
    int ll = 0;
    for (int i=0; i<strlen(s); i++)
    {
        if (strchr(lit, s[i])!=NULL)
        {
            ll++;
            if (ll>lmax) lmax = ll;
        }
        else
        {
            ll=0;
        }
    }
    cout<<lmax;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
    string s;
    getline(cin,s);
    int codd=0,ceven=0;
    int sodd=0,seven=0;
    for(int i=0;i<s.length();i++)
    {
        if(i%2!=0)
        {   seven++;
            if(s[i]=='L'||s[i]=='U'||s[i]=='D')
                ceven++;
        }
        if(i%2==0)
        {   sodd++;
            if(s[i]=='R'||s[i]=='U'||s[i]=='D')
                codd++;   
        }
       

    }
    
    if(seven==ceven&&sodd==codd)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <utility>
#include <stack>
#include <vector>
#include <queue>
#include <algorithm>
#include <map>
#include <climits>
#include <set>
#include <cmath>
using namespace std;

int S[2000];
int T[2000];

long long MOD = 1000000007;

long long dp[2000][2000];
int main(){
    int N;
    int M;
    cin >> N >> M;
    for(int i = 0; i < N; i++){
        cin >> S[i];
    }
    for(int i = 0; i < M; i++){
        cin >> T[i];
    }

    if(S[0] == T[0]){
        dp[0][0] = 2;
    } else {
        dp[0][0] = 1;
    }
    for(int i = 1; i < N; i++){
        if(S[i] == T[0]){
            dp[i][0] = dp[i - 1][0] + 1;
        } else {
            dp[i][0] = dp[i - 1][0];
        }
    }
    for(int i = 1; i < M; i++){
        if(T[i] == S[0]){
            dp[0][i] = dp[0][i - 1] + 1;
        } else {
            dp[0][i] = dp[0][i - 1];
        }
    }

    for(int i = 1; i < N; i++){
        for(int j = 1; j < M; j++){
            if(S[i] != T[j]){
                dp[i][j] = ((((dp[i - 1][j] + dp[i][j - 1]) % MOD) - dp[i - 1][j - 1]) % MOD + MOD) % MOD;
            } else {
                dp[i][j] = (dp[i - 1][j] + dp[i][j - 1]) % MOD;
            }
        }
    }

    cout << dp[N - 1][M - 1] << endl;
    return 0;
}


Measured memory_bytes: 31488
Scanf.scanf "%d %d" (fun k s ->
    let rec loop_z z acc =
        let rec loop_y y acc =
            if y < 0 then acc else
                let x = s - z - y in
                let acc = if x >= 0 && x <= k then acc + 1 else acc in
                loop_y (y - 1) acc
        in
        if z < 0 then acc else loop_z (z - 1) (loop_y k acc)
    in
    loop_z k 0 |> Printf.printf "%d\n"
)

Measured memory_bytes: 3984
#include<iostream>
using namespace std;
long long pow(long long x,long long y){
  long long z = 1,now = x;
  while(y){
    if(y%2) z *= now;
    y >>= 1;
    now = now*now;
  }
  return z;
}
long long convi(long long h,long long w){
  long long q = 1,i;
  for(i=0;i<w;i++) q = q*(h-i)/(i+1);
  return q;
}
int main(){
  long long n,p,a,odd=0,even=0,j;cin >> n >> p;
  while(cin >> a){
    if(a%2) odd++;
    else even++;
  }
  long long ans = 0;
  for(j=p;j<=odd;j+=2) ans += convi(odd,j);
  cout << ans*pow(2,even) << endl;
}

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

int main() {
  int N,M;
  cin >> N >> M;
  vector<int> cities(N);
  
  for(int i=0; i<M; i++){
    int x,y;
    cin >> x >> y;
    cities.at(x-1)++;
    cities.at(y-1)++;
  }
  
  for(int i=0; i<N; i++){
    cout << cities.at(i) << endl;
  }
}


Measured memory_bytes: 256
import numpy as np
 
n = int(input())
 
l = [list(map(int,input().split())) for _ in range(n)]

l = np.array(l)
l = l[np.argsort(l[:,1],axis=0)]
ans = l[:,1]-np.cumsum(l[:,0])
ans = np.where(ans<0)[0]
 
print("Yes" if ans.shape[0]==0 else "No")

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

long double V(int a,int b){
  long double A=1;
  for(int i=0;i<b;i++){
    A*=a;
  }
  return A;
}

int main() {
  long double N,K,ans=0;
  cin>>N>>K;
  for(int i=1;i<=N;i++){
    int j=i,c=0;
    while(j<K){
      j*=2;
      c++;
    }
    ans+=1/V(2,c);
  }
  cout<<fixed<<setprecision(12)<<ans/N;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <limits>
#include <sstream>
#include <string>
#include <vector>

using namespace std;

#define rep(i, n) for (int i = 0; i < n; i++)
#define REP(i, a, n) for (int i = a; i < n; i++)
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define eps 1e-15

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef tuple<int, int, int> ti3;

int main()
{
    int a, b;
    scanf("%d %d", &a, &b);
    if(a<=8&&b<=8) {
        printf("Yay!\n");
    } else {
        printf(":(\n");
    }
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
  
int main(){
  
int a,b,c,tr;
  
scanf("%d",&a);
scanf("%d",&b);
scanf("%d",&c);


if(a>b){
  tr=a;
  a=b;
  b=tr;
}
if(b>c){
  tr=c;
  c=b;
  b=tr;
}
if(a>b){
  tr=a;
  a=b;
  b=tr;
}

printf("%d %d %d\n",a,b,c);
}

Measured memory_bytes: 2708
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
    sizeは(int)とキャストしよう
    cin.tie(0);
    ios::sync_with_stdio(false);<- これら、printfとかと併用しない方が良さそう

*/

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */


const int MAX = 5000005;

long long fac[MAX], finv[MAX], inv[MAX];
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++){
        fac[i] = fac[i-1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod/i) % mod;
        finv[i] = finv[i-1] * inv[i] % mod;
    }

}
long long COM(int n, int k){
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod;
}


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

    ll X, Y; cin >> X >> Y;
    if((X+Y)%3 != 0) { cout << 0 << endl; return 0; }

    COMinit();
    ll ans = 0;
    for(ll a=0; a<=(X+Y)/3; ++a){
        if((X-a)%2 == 1 || (X-a)/2 != Y-2*a) continue;
        ll b = Y-2*a;
        if(b < 0) continue;
        ans += COM(a+b, a);
        chmod(ans);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 117504
#include <stdio.h>

int main (void)
{
  int h , w;
  scanf("%d %d",&h,&w);
  
  char c[h][w];
  
  for(int i =0;i < h;i ++){
  scanf("%s",c[i]);
   printf("%s\n%s\n",c[i],c[i]);
  }
  
  return 0;
}

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

namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var bossInput = Console.ReadLine().Split(' ');
            var bossNum = new int[N - 1];
            for (int i = 0; i < N - 1; i++) //直属の上司の番号を格納している
            {
                bossNum[i] = int.Parse(bossInput[i]);
            }

            var ans = new int[N - 1];
            for (int i = 0; i < N - 1; i++)
            {
                ans[bossNum[i] - 1]++;
            }

            for (int i = 0; i < N - 1; i++)
            {
                Console.WriteLine(ans[i]);
            }
            Console.WriteLine(0);
        }
    }
}


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

int main(){
    int n;
    cin>>n;
    ll ans=0;
    REP(i,n){
        if(i%3!=0&&i%5!=0){
            ans+=i;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3596
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n+1)]
        self.rank = [0] * (n+1)

    # 検索
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
        else:
            self.par[y] = x
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1

    # 同じ集合に属するか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)

    
    
n, m = map(int, input().split())
lang = []
for _ in range(n):
    a = [int(i) for i in input().split()[1:]]
    lang.append(a)    
un = UnionFind(n + m)

for i in range(n):
    for l in lang[i]:
        un.union(i, l + n)

ans = set([])
for i in range(n):
    k = un.find(i)
    ans.add(k)
    
if len(ans) == 1:
    print('YES')
else:
    print('NO')

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

int main(){
	while(1){
	int H,W,s,k;
	cin>>H>>W;
	
	if(W==0&&H==0){break;}
	for(k=0;k<H;k++){
	for(s=0;s<W;s++){
		
		if((s+k)%2==1){cout<<".";}
		else{cout<<"#";}
    }
	cout<<endl;
	
	}
	cout<<endl;
	}
	return 0;
}


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

#define int long long
#define itn int
#define For(i, a, b) for (int i = (a); i <= static_cast<int>(b); i++)
#define Forr(i, a, b) for (int i = (a); i >= static_cast<int>(b); i--)
#define rep(i, n) For(i, 0, n - 1)
#define repall(i, arr) for (auto& i : (arr))
#define all(x) (x).begin(), (x).end()
#define pb push_back
#define dump(x) cerr << #x << " = " << (x) << '\n'
#define dump2(x, y) \
    cerr << #x << " = " << (x) << " " << #y << " = " << (y) << '\n'
#define SZ(x) ((int)(x).size())
#define bit(n) (1LL << (n))
constexpr int MOD = 1e9 + 7;

template <typename T>
using pq = priority_queue<T>;
template <typename T>
using pqr = priority_queue<T, vector<T>, greater<T>>;
const int INF = LLONG_MAX / 2;
using P = pair<int, int>;
using vec = vector<int>;
template <typename T>
using mat = vector<vector<T>>;

// clang-format off
template <typename T1, typename T2>
ostream& operator<<(ostream& stream, const pair<T1, T2>& p) { return stream << p.first << "," << p.second; }
template <typename T>
void print(const vector<T> vec) { rep (i, vec.size() - 1) cout << vec[i] << ' '; cout << vec[vec.size() - 1] << '\n'; }
template <typename Arg>
void print(const Arg arg) { cout << arg << '\n'; }
template <typename Head, typename... Args>
void print(const Head head, const Args... args) { cout << head << " "; print(args...); }
template <typename T, typename U>
void init(vector<T>& v, vector<U>& w) { rep (i, v.size()) cin >> v[i] >> w[i]; }
template <typename T>
void init(vector<T>& v) { rep (i, v.size()) cin >> v[i]; }
template <typename T>
T sum_(vector<T> vec, T init = 0) { return std::accumulate(all(vec), T(init)); }
template<typename T>
bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; } return false; }
template<typename T>
bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; } return false; }
template <typename T>
int index(const T& vec, const typename T::iterator it) { return distance(vec.begin(), it); }
template <typename T = int>
mat<T> mmat(int n, int m=0) { return mat<T>(n, vector<T>(m)); }
template <typename T = int>
vector<T> ivec(int n) { vector<T> v(n); init(v); return v; }
// clang-format on

void yn(bool tf) { print(tf ? "Yes" : "No"); }
void YN(bool tf) { print(tf ? "YES" : "NO"); }

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
// -------------------------------------------------------------------
// sort 1 2 3 4
// pqr 1 2 3 must impl >

signed main() {
    cin.tie(0), cout.tie(0), ios::sync_with_stdio(false);
    int n;
    cin >> n;
    string s;
    map<string, int> mp;

    rep (i, n) {
        cin >> s;
        mp[s]++;
    }
    int ma = 0;
    repall (e, mp) { chmax(ma, e.second); }
    repall (e, mp) {
        if (ma == e.second) print(e.first);
    }

    return 0;
}


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

int main (){
    int k,s,m,cnt=0;
cin>>k>>s;
int v=k;
for (int i=0;i<=k;i++){
      for (int j=0;j<=k;j++){
           m=s-(i+j);
           if (m>=0&&m<=k&&i+j+m==s)
             cnt++;


}}
cout<<cnt;
return 0;
}


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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define MX              200005
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;

void c_p_c()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

int n,q;
int arr[200001];
vi adj[200001];


void dfs(int n,int p)
{ 
    arr[n] += arr[p];

    for(auto ch : adj[n])
        if(ch!=p)
            dfs(ch,n);
}

int32_t main()
{
    //c_p_c();
    cin>>n>>q;

    for(int i=0;i<n-1;++i)
    {
        int a,b; cin>>a>>b;
        adj[a].pb(b);
        adj[b].pb(a);
    }

    while(q--)
    {
        int p,x; cin>>p>>x;
        arr[p] += x;
    }

    dfs(1,0);

    for(int i=1;i<=n;++i)
        cout << arr[i] << ' ';

    return 0;
}

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

int main(){
  int n;
  cin>>n;
  string base="abcdefghijklmnopqrstuvwxyz";
  int a=base.size();
  long long count[a],ans[a];
  for(int j=0;j<base.size();j++){
      ans[j]=100;
      count[j]=0;
  }
  for(int i=0;i<n;i++){
    string s;
    cin>>s;
    for(int j=0;j<s.size();j++){
      count[s.at(j)-'a']++;
    }
    for(int j=0;j<base.size();j++){
      ans[j]=min(ans[j],count[j]);
      count[j]=0;
    }
  }
  for(int i=0;i<base.size();i++){
      for(int j=0;j<ans[i];j++){
        cout<<base.at(i);
      }
  }cout<<endl;
}

Measured memory_bytes: 256