akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.math.BigDecimal;
import java.math.RoundingMode;
import java.util.*;
import java.util.concurrent.Delayed;
import java.util.logging.Logger;

import javax.transaction.xa.Xid;


public class Main {
	static final long MOD=1000000007;//998244353;
	public static void main(String[] args){
		PrintWriter out = new PrintWriter(System.out);
		InputReader sc=new InputReader(System.in);
		char[] cs=sc.next().toCharArray();
		for (int i = 0; i < 3; i++) {
			System.out.print(cs[i]);
		}
 	}
	
	static class InputReader { 
		private InputStream in;
		private byte[] buffer = new byte[1024];
		private int curbuf;
		private int lenbuf;
		public InputReader(InputStream in) {
			this.in = in;
			this.curbuf = this.lenbuf = 0;
		}
 
		public boolean hasNextByte() {
			if (curbuf >= lenbuf) {
				curbuf = 0;
				try {
					lenbuf = in.read(buffer);
				} catch (IOException e) {
					throw new InputMismatchException();
				}
				if (lenbuf <= 0)
					return false;
			}
			return true;
		}
 
		private int readByte() {
			if (hasNextByte())
				return buffer[curbuf++];
			else
				return -1;
		}
 
		private boolean isSpaceChar(int c) {
			return !(c >= 33 && c <= 126);
		}
 
		private void skip() {
			while (hasNextByte() && isSpaceChar(buffer[curbuf]))
				curbuf++;
		}
 
		public boolean hasNext() {
			skip();
			return hasNextByte();
		}
 
		public String next() {
			if (!hasNext())
				throw new NoSuchElementException();
			StringBuilder sb = new StringBuilder();
			int b = readByte();
			while (!isSpaceChar(b)) {
				sb.appendCodePoint(b);
				b = readByte();
			}
			return sb.toString();
		}
 
		public int nextInt() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			int res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}
 
		public long nextLong() {
			if (!hasNext())
				throw new NoSuchElementException();
			int c = readByte();
			while (isSpaceChar(c))
				c = readByte();
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = readByte();
			}
			long res = 0;
			do {
				if (c < '0' || c > '9')
					throw new InputMismatchException();
				res = res * 10 + c - '0';
				c = readByte();
			} while (!isSpaceChar(c));
			return (minus) ? -res : res;
		}
 
		public double nextDouble() {
			return Double.parseDouble(next());
		}
 
		public int[] nextIntArray(int n) {
			int[] a = new int[n];
			for (int i = 0; i < n; i++)
				a[i] = nextInt();
			return a;
		}
 
		public long[] nextLongArray(int n) {
			long[] a = new long[n];
			for (int i = 0; i < n; i++)
				a[i] = nextLong();
			return a;
		}
 
		public char[][] nextCharMap(int n, int m) {
			char[][] map = new char[n][m];
			for (int i = 0; i < n; i++)
				map[i] = next().toCharArray();
			return map;
		}
	}
}


Measured memory_bytes: 32308
#include <bits/stdc++.h>
using namespace std;
#define rep(shoki,i,n) for(int i=shoki; i<n; i++)
#define _GLIBCXX_DEBUG
using ll = long long;
using vi = vector<int>;
using vs = vector<string>;

int main(){
    string s; cin>>s;
    string c = "abcdefghijklmnopqrstuvwxyz";
    int n_s = s.size();
    int n_c = c.size();
    vector<bool> check(n_c,false);
    sort(s.begin(),s.end());
    rep(0,i,n_s){
        rep(0,j,n_c){
            if(check[j]==false){
                if(s[i]==c[j]){
                    check[j]=true;
                }
            }
        }
    }

    bool INE = false;
    int idx;
    rep(0,i,n_c){
        if(!check[i]){
            INE = true;
            idx = i;
            break;
        }
    }

    if(INE){
        cout << c[idx] << endl;
    }else{
        cout << "None" << endl;
    }
}

Measured memory_bytes: 512
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

int main()
{
    char s[15],t[16];
    int i;
    scanf("%s",s);
    scanf("%s",t);
    for(i=0;i<strlen(s);i++){
        if(s[i]!=t[i])
        {
            printf("No");
            break;
        }
    }
    if(i==strlen(s)){
        if(strlen(t)==strlen(s)+1)
            printf("Yes");
        else printf("No");
    }
    return 0;
}


Measured memory_bytes: 1724
#!/usr/bin/env python3
import sys
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right
from itertools import accumulate

sys.setrecursionlimit(10**6)
INF = 10**12
m = 10**9 + 7

def main():
    N, K = map(int, input().split())
    V = list(map(int, input().split()))

    # 方針: 操作Aの回数・操作Bの回数で全探索
    ans = 0
    R = min(N,K)

    for i in range(R+1):
        for j in range(R+1-i):
            tmp = 0
            q = []# 価値が負の宝石をいれる(C)
            
            for k in range(i):
                tmp += V[k]
                if V[k] < 0:
                    q.append(V[k])
            for k in range(j):
                tmp += V[N-1-k]
                if V[N-1-k] < 0:
                    q.append(V[N-1-k])

            q.sort()
            tmp -= sum(q[:min(len(q),K-i-j)])
            ans = max(ans,tmp)
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 9400
#include<iostream>
#include<vector>
#include<cstdio>
#include<algorithm>
using namespace std;
 
 
int main() {
	int N, M, X, Y;
	cin >> N >> M >> X >> Y;
	vector<int> x(N);
	vector<int> y(M);
	for (int i = 0; i < N; i++)
	{
		cin >> x[i];
	}
	for (int i = 0; i < M; i++)
	{
		cin >> y[i];
	}
 
	int XMAX = X;
	int YMIN = Y;
	for (int i = 0; i < N; i++)
	{
		XMAX = max(XMAX, x[i]);
	}
	for (int i = 0; i < M; i++)
	{
		YMIN = min(YMIN, y[i]);
	}
 
	if (XMAX < YMIN) cout << "No War" << endl;
	else cout << "War" << endl;
}

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

#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

const int N = 1e5 + 5;

int n, k;
bitset<N> taken;
ll base, groups, ans;

int main() {
	cin.tie(0)->sync_with_stdio(0);
    cin >> n >> k;
    taken.reset();
    set<ll> gc;
    multiset<ll> extra;
    priority_queue<pair<ll, ll>, vector<pair<ll, ll>>> q;
    rep(i, 0, n) {
        ll a, b;
        cin >> a >> b;
        gc.insert(a);
        q.push({b, a});
    }

    rep(i, 0, k) {
        pii v = q.top();
        q.pop();
        base += v.first;
        if (!taken[v.second]) {
            ++groups;
            taken[v.second] = 1;
        } else {
            extra.insert(v.first);
        }
    }
    
    ans = base + (groups * groups);
    
    while (groups < min(sz(gc), k)) {
        pii v = q.top();
        q.pop();
        if (taken[v.second]) continue;
    
        taken[v.second] = 1;
        base -= *extra.begin();
        extra.erase(extra.begin());
        base += v.first;
        ++groups;
        ans = max(ans, base + (groups * groups));
    }

    cout << ans;
}


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

int main()
{
	int ans=0;
	string s;
	cin>>s;
	
	for(int i=0;i<s.length();i++)
	{
		if(s[i]=='1')
			ans++;
	}
	cout<<ans;
	return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a[105],ans; 
int main(){
	int i,x;
	ios::sync_with_stdio(0);
	cin >> i,i <<= 1; while (i--) cin >> x,++a[x];
	for (x = 0,i = 100; i ; --i){
		ans += i * (a[i]>>1);
		if (a[i] & 1){ if (!x) x = 1; else ans += i,x = 0; }
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 3616
#include <iostream>

using namespace std;

int main() {
    int h, a;
    int ans = 0;

    cin >> h >> a;
    
    ans = int(h/a);
    if( h % a != 0){
        ans += 1;
    }
   

    cout << ans << "\n";
    
    return 0;
}


Measured memory_bytes: 256
import math
import fractions
mod=1000000007
(n,m)=map(int,input().split())
a=[0]*(n+2)
b=[0]*(n+2)
for i in range(m):
    t=int(input())
    a[t]=1
b[0]=1
for i in range(n+1):
    if(a[i]==1):
        b[i]=0
        continue
    if(i==0):
        continue
    if(i==1):
        b[i]=b[i-1]
        continue
    b[i]=(b[i-1]+b[i-2])%mod

print(b[n]%mod)



Measured memory_bytes: 9760
#include <iostream>
#include <algorithm>
#include <map>
#include <utility>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)



int main() {

    int X;
    cin >> X;

    if (X == 2) {
        cout << 2 << endl;
        return 0;
    }
    

    for (int i = X; i <= 100003; i++) {
        for (int j = 2; j <=i; j++) {
            if (i%j != 0) {
                if (i-1 == j) {
                   
                    cout << i << endl;
                    return 0;
                } else {
                    continue;
                }
            } else {
                break;
            }
        }
    }




    
    return 0;


}

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

int main()
{
    int N;cin>>N;
    ll ans=0;
    for (int i=1;i<N+1;i++)
    {
        if (i%15!=0 && i%3!=0 && i%5!=0) ans+=i;
       
    } 
    cout << ans << endl;
        return 0;
}

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

using namespace std;

int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

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

	int k;
	cin >> k;
	cout << a[k - 1];

	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		String S[] = new String[N];
		int result = 1;

		for (int i = 0; i < N; i++) {
			S[i] = scan.next();
		}
		
		Arrays.sort(S);

		for (int i = 0; i < N - 1; i++) {
			if (!(S[i].equals(S[i + 1]))) {
				result++;
			}
		}

		System.out.println(result);

	}

}


Measured memory_bytes: 70108
#include <iostream>
#include <algorithm>
#include <unordered_set>
#include <cstring>
using namespace std;
typedef long long LL;

int main() {
    int x;
    cin >> x;
    
    for (LL i = -200; i <= 200; i++) {
        for (LL j = -200; j <= 200; j++) {
            if (i*i*i*i*i - j*j*j*j*j == x) {
                cout << i << " " << j << endl;
                return 0;
            }
        }
    }
    return 0;
} 

Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
int f(int s)
{
	return (s%2 == 0)?s/2:(s*3+1);
}
int main()
{
	int s;
	cin>>s;
	int i=2;
	map<int,int> mp;
	mp[s]++;
	int ans = f(s);
	while(mp[ans] == 0)
	{
		i++;
		mp[ans]++;
		ans = f(ans);
	}
	cout<<i<<endl;
 } 

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int a,b,c,t;
    cin>>a>>b>>c;
    t=a;
    a=b;
    b=t;
    t=a;
    a=c;
    c=t;
    cout<<a<<" "<<b<<" "<<c<<endl;
    return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{Ordering};

#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};

#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Write};

#[allow(unused_imports)]
use std::iter::FromIterator;

#[allow(unused_macros)]
macro_rules! min {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::min($x, min!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! max {
    ($x: expr) => ($x);
    ($x: expr, $($z: expr),+) => {{
        std::cmp::max($x, max!($($z),*))
    }}
}

#[allow(unused_macros)]
macro_rules! get { 
    ([$t: ty]) => { 
        { 
            let mut line = String::new(); 
            stdin().read_line(&mut line).unwrap(); 
            line.split_whitespace().map(|t|t.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    };
    ([$t: ty];$n: expr) => {
        (0..$n).map(|_|get!([$t])).collect::<Vec<_>>()
    };
    ($t: ty) => {
        {
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            line.trim().parse::<$t>().unwrap()
        }
    };
    ($($t: ty),*) => {
        { 
            let mut line = String::new();
            stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*)
        }
    };
    ($t: ty; $n: expr) => {
        (0..$n).map(|_|get!($t)).collect::<Vec<_>>()
    };
    ($($t: ty),*; $n: expr) => {
        (0..$n).map(|_|get!($($t),*)).collect::<Vec<_>>()
    };
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*).unwrap();
    }
}

const BIG_STACK_SIZE: bool = true;

#[allow(dead_code)]
fn main() {
    use std::thread;
    if BIG_STACK_SIZE {
        thread::Builder::new()
            .stack_size(32 * 1024 * 1024)
            .name("solve".into())
            .spawn(solve)
            .unwrap()
            .join()
            .unwrap();
    } else {
        solve();
    }
}

fn solve() {
    let (n,m,d) = get!(f64, usize, f64);
    
    if d == 0.0 {
        println!("{}", (n-d)*(m-1) as f64/(n*n));
    } else {
        println!("{}", 2.0*(n-d)*(m-1) as f64/(n*n));
    }
}


Measured memory_bytes: 8572
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <sstream>
#include <map>
#include <set>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <numeric>
#include <bitset>
#include <ext/algorithm>
#include <ext/numeric>
#define ffor(_a,_f,_t) for(int _a=(_f),__t=(_t);_a<__t;_a++)
#define all(_v) (_v).begin() , (_v).end()
#define sz size()
#define pb push_back
#define SET(__set, val) memset(__set, val, sizeof(__set))
#define FOR(__i, __n) ffor (__i, 0, __n)
typedef long long LL; using namespace std;

int N;

const int MAXN = 204000;

vector<int> g[MAXN];
vector<int> gb[MAXN];

int rrun = 0;
int visited[MAXN];
bool stop_dfs;
bool circle[MAXN];
bool collect;
int start_from;

void dfs(int v) {
	visited[v] = rrun;
	if (stop_dfs)
		return;
	FOR (i, g[v].sz) {
		int w = g[v][i];
		if (visited[w] == rrun) {
			stop_dfs = true;
			start_from = w;
			collect = true;
		}
		else if (visited[w])
			continue;
		else
			dfs(w);
		if (collect)
			circle[v] = true;
		if (v == start_from)
			collect = false;
		if (stop_dfs)
			break;
	}
}

int number[MAXN];

int computeNumber(int v) {
	vector<int> vals;
	FOR (i, g[v].sz) {
		int w = g[v][i];
		if (circle[w])
			continue;
		vals.pb(computeNumber(w));
	}
	sort(all(vals));
	int val = 0, next = 0;
	int i = 0;
	while (i < vals.sz) {
		while (i < vals.sz && vals[i] == next)
			i++;
		if (i && vals[i - 1] == next) {
			next++;
			val++;
		}
		else
			break;
	}
	number[v] = val;
	return val;
}

int value;

bool possible(int v, int prev_val) {
	int myval = number[v];
	if (prev_val == myval)
		myval++;
	if (v == start_from)
		return myval == value;

	FOR (i, gb[v].sz) {
		int w = gb[v][i];
		if (circle[w])
			return possible(w, myval);
	}
}

int main() {
	cin >> N;
	FOR (i, MAXN) {
		g[i].clear();
		gb[i].clear();
	}
	int a;
	FOR (i, N) {
		cin >> a;
		a--;
		g[a].pb(i);
		gb[i].pb(a);
	}
	
	SET(visited, 0);
	SET(circle, 0);
	stop_dfs = false;
	collect = false;
	
	FOR (i, N)
		if (!visited[i]) {
			rrun++;
			dfs(i);
		}
	FOR (i, N)
		if (circle[i])
			computeNumber(i);
			
	int ww;
	FOR (i, gb[start_from].sz) {
		ww = gb[start_from][i];
		if (circle[ww])
			break;
	}

	value = number[start_from];
	if (possible(ww, number[start_from])) {
		cout << "POSSIBLE" << endl;
		return 0;
	}
	value = number[start_from] + 1;
	if (possible(ww, number[start_from] + 1)) {
		cout << "POSSIBLE" << endl;
		return 0;
	}
	cout << "IMPOSSIBLE" << endl;
	return 0;
}

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

using namespace std;

#define endl '\n'

typedef long long ll;

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

	int n;
	cin >> n;
	vector<vector<ll>> a(n, vector<ll>(n));

	for(int i = 0; i < n; i++)
		for(int j = 0; j < n; j++)
			cin >> a[i][j];
	
	vector<ll> dp(1 << n), cost(1 << n);
	
	for(int i = 0; i < 1 << n; i++){
		for(int j = 0; j < n; j++)
			for(int k = j + 1; k < n; k++)
				if( (i & (1 << j)) && (i & (1 << k)) )
					cost[i] += a[j][k];
		dp[i] = cost[i];
	}
	
	for(int i = 1; i < 1 << n; i++){
		int b = __builtin_popcount(i);
		
		if(b == 1)
			continue;	
		
		int s_mask = i;
		
		while(s_mask){
			s_mask = (s_mask - 1) & i;
			dp[i] = max(dp[i], dp[s_mask] + cost[i ^ s_mask]);
		}
	}
	
	cout << dp[ (1 << n) - 1] << endl;

	return 0;
}

Measured memory_bytes: 1280
h,w=map(int,input().split())
c=[list(map(int,input().split())) for _ in [0]*10]
a=[list(map(int,input().split())) for _ in [0]*h]
cost=[float('inf')]*10
cost[1]=0
for _ in [0]*9:
    for i in range(10):
        cost[i]=min(c[i][j]+cost[j] for j in range(10))
ans=0
for i in range(h):
    for j in range(w):
        if a[i][j]>=0:
            ans+=cost[a[i][j]]
print(ans)

Measured memory_bytes: 3444
# coding: utf-8

n = int(raw_input())
for i in range(n):
	data = map(int, raw_input().split())
	if data[0]**2 == data[1]**2 + data[2]**2:
		print("YES")
	elif data[1]**2 == data[2]**2 + data[0]**2:
		print("YES")
	elif data[2]**2 == data[0]**2 + data[1]**2:
		print("YES")
	else:
		print("NO")

Measured memory_bytes: 4668
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<utility>
#include<tuple>
#include<algorithm>
using namespace std;
#define INF 1e9

int main(){
    int N,M,X;
    cin>>N>>M>>X;
    vector<int> C(N);
    int A[N][M];
    for(int i=0;i<N;i++){
        cin>>C[i];
        for(int j=0;j<M;j++){
            cin>>A[i][j];
        }
    }
    int m=INF;
    for(int b=0;b<(1<<N);b++){
        vector<int> r(M,0);
        int tmp=0;
        for(int i=0;i<N;i++){
            if((b>>i)&1){
                for(int j=0;j<M;j++){
                    r[j]+=A[i][j];
                }
                tmp+=C[i];
            } 
        }
        bool flag=true;
        for(int j=0;j<M;j++)if(r[j]<X){
            flag=false;
            break;
        }
        if(flag){
            if(m>tmp){
                m=tmp;
            }
        }
    }
    if(m==INF) cout<<-1<<endl;
    else cout<<m<<endl;
}

Measured memory_bytes: 3132
#include <cstdio>

template<long long N>
struct sum_sequence
{
  long long sum[N + 1];
  constexpr sum_sequence() : sum()
  {
    for (long long i = 0; i <= N; ++i)
    {
      sum[i] = i * (i + 1) / 2;
    }
  }
};

sum_sequence<4500> ss;

int main()
{
  int n;
  scanf("%d", &n);
  
  for (long long i = 1; true; ++i)
  {
    if (ss.sum[i] <= n && n < ss.sum[i + 1])
    {
      for (long long j = 1; j <= i; ++j)
      {
        printf("%lld\n", j + (j >= ss.sum[i + 1] - n ? 1 : 0));
      }
      return 0;
    }
  }
}

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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define fin(ans) cout << (ans) << endl;
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef long long lli;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, str>> vpls;
typedef vector<tuple<str, ll, ll>> vtsl;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

//実行部
void Main()
{
  str a, b, c; cin >> a >> b >> c;
  cout<<(char)(a[0]-32)<<(char)(b[0]-32)<<(char)(c[0]-32)<<endl;
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}


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

#define MOD_BY 1000000007

int add(int a, int b) {
	return a + b - MOD_BY * (a + b >= MOD_BY);
}

int sub(int a, int b) {
	return b == 0 ? a : add(a, MOD_BY - b);
}

int mul(int a, int b) {
	int r = 0;
	while (b > 0) {
		if (b & 1) r = add(r, a);
		a = add(a, a);
		b >>= 1;
	}
	return r;
}

int power(int a, int n) {
	int r = 1;
	while (n > 0) {
		if (n & 1) r = mul(r, a);
		a = mul(a, a);
		n >>= 1;
	}
	return r;
}

int inv(int a) {
	return power(a, MOD_BY - 2);
}

int divide(int a, int b) {
	return mul(a, inv(b));
}

int nCr(int n, int r) {
	int answer = 1;
	int i;
	if (r < 0 || n < r) return 0;
	for (i = 0; i < r; i++) {
		answer = mul(answer, n - i);
	}
	for (i = 2; i <= r; i++) {
		answer = divide(answer, i);
	}
	return answer;
}

int main(void) {
	int H, W, A, B;
	int answer;
	int ng1, ng2;
	int* ng;
	int i;
	if (scanf("%d%d%d%d", &H, &W, &A, &B) != 4) return 1;
	ng = malloc(sizeof(int) * B);
	if (ng == NULL) return 2;
	for (i = 0; i < B; i++) ng[i] = 1;
	answer = nCr(add(H - 1, W - 1), H - 1);
	ng1 = nCr((H - 1) - A, 0); /* NGエリアの最上部に上から来る方法 */
	ng2 = nCr((A - 1) + ((W - 1) - (B - 1)), (W - 1) - (B - 1)); /* NGエリアの最上部からゴールに行く方法 */
	for (i = 0; i < B; i++) {
		ng[i] = mul(ng[i], ng1);
		ng[B - 1 - i] = mul(ng[B - 1 - i], ng2);
		/* (n+1)C(r+1) = nCr * (n+1) / (r+1) */
		ng1 = divide(mul(ng1, ((H - 1) - A) + i + 1), i + 1);
		ng2 = divide(mul(ng2, ((A - 1) + ((W - 1) - (B - 1))) + i + 1), ((W - 1) - (B - 1)) + (i + 1));
	}
	for (i = 0; i < B; i++) {
		answer = sub(answer, ng[i]);
	}
	printf("%d\n", answer);
	free(ng);
	return 0;
}


Measured memory_bytes: 512
n = int(input())
a = [int(i) for i in input().split()]
q = int(input())
count = 0
b = [int(j) for j in input().split()]
for j in range(0,q):
    for i in range(0,n):
        if a[i] == b[j]:
            count = count + 1
            break
print(count)


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#define int long long
#define endl "\n"

int32_t main()
{
    IOS;
    
    int h,w,n;
    cin>>h>>w>>n;
    
    int l=max(h,w);
    int ans=n/l;
    ans++;
    if(n%l==0)
        ans--;
    cout<<ans;
    return 0;
}

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

#define FOR(i, l, r) for(size_t i = (l); i < (r); i = i + 1)
#define REP(i, n) FOR(i, 0, n)
using ll = long long;

int main() {
    string S;
    cin >> S;
    if(S == "ABC") {
        cout << "ARC" << endl;
    }
    else {
        cout << "ABC" << endl;
    }
    return 0;
}

Measured memory_bytes: 3596
H , W = map(int,input().split())
stage = list(input() for _ in range(H))
dy_list = [1,1,0,-1,-1,-1,0,1]
dx_list = [0,1,1,1,0,-1,-1,-1]

for y in range(H):
    for x in range(W):
        cnt = 0
        Flag = False
        for dx , dy in zip(dy_list , dx_list):
            if stage[y][x] == "#":
                break
            Flag = True
            if 0 <= y + dy < H and 0 <= x + dx < W:
                if stage[y + dy][x + dx] == "#":
                    cnt += 1
        if Flag:
            print(cnt , end = "")
        else:
            print("#" ,end = "")
    print()

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

#define INF ((1<<31)-1)  //int32_t
#define MOD 1000000007
#define MOD2  

#define all(a)  (a).begin(),(a).end()

#define mkp make_pair
#define pb push_back

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;



int main(){
    bool flag=true;
    ll ans=0,sum=0;
    int n,m;
    cin >>n>>m;
    int a[n];



    //cout <<fixed<<setprecision(16)<< << endl;
    cout << n-m+1 << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;
    
    return 0;
}


Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>
using namespace std;

typedef long long ll;
#define tr(container, it) \
        for (auto it = container.begin(); it != container.end(); it++)
#define scontains(c, x) ((c).find(x) != (c).end())   //O(log n)
#define contains(c, x) (find((c).begin(),(c).end(),x) != (c).end()) //O(n)
#define pll pair<ll,ll>
#define pii pair<int,int>
#define mll map<ll,ll>
#define intv(x, a, b)((x)>=a && (x)<=b)
#define  rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define  _for(i, end) for (__typeof(end) i = 0; i < (end); i += 1)
#define all(x) (x).begin(),(x).end()
//#define len(array)  (sizeof(array)/sizeof((array)[0]))
#define what_is(x) cerr << #x << " is " << x << endl;
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define mod(x, m) ((((x) % (m)) + (m)) % (m))
const double PI = 2 * acos(.0);
const int INF = 0x3f3f3f3f;
const ll LLINF = 1000000000000000005LL;;
const ll MOD = (ll) (1e9) + 7;
void _mod(ll &x){x = mod(x, MOD);}
//const ll MOD = (ll) 998244353 ;
const double EPS = 1e-10;

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *) array, (T *) (array + N), val);
}


//#define int ll

class CTogether {
public:
//        array<int, 202020> A;
        int N;
        map<int, int> A;
void solve(std::istream& cin, std::ostream& cout) {
    cin >> N;
    _for(i,N){
        int t;
        cin >> t;
        A[t] ++;
    }
    int mx = -1;
    rep(i,1,101010)mx = max(mx, A[i-1] + A[i] + A[i+1]);
    cout << mx << endl;
}
};


#undef int
int main() {
	CTogether solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 4992
from collections import Counter
n = int(input().strip())
vs = [int(i) for i in input().split(' ')]
vs1 = vs[::2]
vs2 = vs[1::2]
a = Counter(vs1).most_common()
b = Counter(vs2).most_common()

if a[0][0] != b[0][0]:
    print(n - a[0][1] - b[0][1])
else:
    candidates = []
    if len(a) != 1:
        candidates.append(n - a[1][1] - b[0][1])
    if len(b) != 1:
        candidates.append(n - a[0][1] - b[1][1])
    if len(candidates) != 0:
        print(min(candidates))
    else:
        print(n//2)


Measured memory_bytes: 64364
fn read_stdin() -> String {
    use std::io::Read;
    let mut input = String::new();
    std::io::stdin().read_to_string(&mut input).unwrap();
    input
}

fn scan<'a, I: Iterator<Item = &'a str>, T: std::str::FromStr>(tokens: &mut I) -> T {
    tokens.next().unwrap().parse().ok().unwrap()
}

fn main() {
    let input = read_stdin();
    let tokens = &mut input.split_whitespace();
    let k: usize = scan(tokens);
    let mut d: Vec<usize> = vec![0; 64];
    d[0] = 1;
    let mut max = 0;
    for _ in 1..k {
        let mut cur = 0;
        while cur < max && d[cur] == std::cmp::min(d[cur + 1] + 1, 9) {
            cur += 1;
        }
        if cur == max && d[cur] == 9 {
            max += 1;
            cur += 1;
            d[cur] = 1;
            for i in 0..cur {
                d[i] = 0;
            }
        } else {
            d[cur] += 1;
            for i in (0..cur).rev() {
                d[i] = std::cmp::max(d[i + 1], 1) - 1;
            }
        }
    }
    for i in (0..max + 1).rev() {
        print!("{}", d[i]);
    }
    println!("");
}


Measured memory_bytes: 4352
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {

	public static void main(String[] args) throws IOException {
		// TODO ?????????????????????????????????????????????
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		while(true){
			String[] tmpArray = br.readLine().split(" ");

			int n = Integer.parseInt(tmpArray[0]);
			int m = Integer.parseInt(tmpArray[1]);

			if(n == 0 && m == 0){
				break;
			}

			String[] packets = new String[m];
			for(int i = 0; i < m; i++){
				packets[i] = br.readLine();
			}

			System.out.println(solve(n, packets));
		}
	}

	static int solve(int n, String[] input){
		int result = 1;
		boolean infected[] = new boolean[n + 1];

		infected[1] = true;

		Packet[] packets = new Packet[input.length];

		for(int i = 0; i < packets.length; i++){
			packets[i] = new Packet(input[i]);
		}

		Arrays.sort(packets);

		for(int i = 0; i < packets.length; i++){
			Packet p = packets[i];

			if(infected[p.source] &&!infected[p.dest]){
				result++;
				infected[p.dest] = true;
			}
		}

		return result;
	}

}

class Packet implements Comparable<Packet>{
	int time;
	int source;
	int dest;

	public Packet (String str){
		String[] tmpArray = str.split(" ");

		time = Integer.parseInt(tmpArray[0]);
		source = Integer.parseInt(tmpArray[1]);
		dest = Integer.parseInt(tmpArray[2]);

	}

	@Override
	public int compareTo(Packet p) {

		return this.time - p.time;
	}
}

Measured memory_bytes: 79984
#include <stdio.h>
#define N 100

int main(){
  int M[N][N];
  int n,u,v,k;
  int i,j;

  scanf("%d",&n);

  for(i=0; i<n; i++){
    for(j=0; j<n; j++){
      M[i][j] = 0;
    }
  }

  for(i=0; i<n; i++){
    scanf("%d%d",&u,&k);
    u--;
    for(j=0; j<k; j++){
      scanf("%d",&v);
      v--;
      M[u][v] = 1;
    }
  }

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

  return 0;
}



Measured memory_bytes: 2112
N = int(input())
A = input()
B = input()
C = input()

num_changes = 0
for a, b, c in zip(A, B, C):
    if a == b and b == c:
        continue
    elif a == b or b == c or c == a:
        num_changes += 1
    else:
        num_changes += 2

print(num_changes)


Measured memory_bytes: 38384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace contest16
{
    class Program
    {
        static void Main(string[] args)
        {
            double Pos_x = 0.0;
            double Pos_y = 0.0;

            int rotate = 0;

            while (true)
            {
                var read_line_origin = Console.ReadLine();

                string[] read_line = read_line_origin.Split(',');

                int r = int.Parse(read_line[0]);
                int kakudo = int.Parse(read_line[1]);

                //データ入力終わりの合図
                if (r == 0 && kakudo == 0)
                {
                    break; 
                }

                //最初は北を向いている
                //ｒ進んでからkakudo回転する

                Pos_x += r * Math.Sin(rotate * Math.PI / 180);
                Pos_y += r * Math.Cos(rotate * Math.PI / 180);

                rotate += kakudo;
            }

            Console.WriteLine("{0}", (int)Pos_x);
            Console.WriteLine("{0}", (int)Pos_y);
//            Console.ReadKey();
        }
    }
}

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

int main(void){

char s[105],p[105],ss[215]="";
//int i;

//for(i=0;i<105;i++){s[i]='\0';p[i]='\0';}
//for(i=105;i<205;i++){s[i]='\0';}

scanf("%s",s);
scanf("%s",p);

strcat(ss,s);
strcat(ss,s);

if(strstr(ss,p)!='\0'){
	printf("Yes\n");}
else{printf("No\n");}

return 0;
}

Measured memory_bytes: 532
#pragma region template 2.4
#include <bits/stdc++.h>
using namespace std;
template <typename T>
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> ii;
typedef vector<ii> vii;
typedef vector<string> vs;
#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP1(i, n) for (ll i = 1; i <= (n); ++i)
#define FOR(i, a) for (auto &i : a)
#define CH(f, x, y) x = f(x, y)
#define IN(T, x) \
    T x;         \
    cin >> x;
#define AIN(T, a, n) \
    vector<T> a(n);  \
    FOR(i, a)        \
    cin >> i;
#define A2IN(T1, a, T2, b, n) \
    vector<T1> a(n);          \
    vector<T2> b(n);          \
    REP(i, n)                 \
    cin >> a[i] >> b[i];
#define OUT(x) cout << (x) << endl;
#define FOUT(x) cout << fixed << setprecision(15) << (x) << endl;
#define ALL(a) (a).begin(), (a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) \
    SORT(a);     \
    reverse(ALL(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define DUMPA(a)          \
    cout << #a << " = {"; \
    JOUT(ALL(a), ", ", cout) << "}" << endl;

template <typename T>
ostream &JOUT(T s, T e, string sep = " ", ostream &os = cout)
{
    if (s != e)
    {
        os << *s;
        ++s;
    }
    while (s != e)
    {
        os << sep << *s;
        ++s;
    }
    return os;
}

ostream &YES(bool cond, string yes = "Yes", string no = "No", ostream &os = cout)
{
    if (cond)
    {
        os << yes << endl;
    }
    else
    {
        os << no << endl;
    }
    return os;
}

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

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v)
{
    os << '[';
    JOUT(ALL(v), ", ", os) << ']';
    return os;
}

const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#pragma endregion template

int main()
{
    IN(ll, L);
    IN(ll, R);
    IN(ll, d);
    ll ans = 0;
    for (ll i = L; i <= R; ++i)
    {
        ans += i % d == 0;
    }
    OUT(ans);
}

Measured memory_bytes: 3588
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<string.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
long long int mod=1e9+7;
bool debug=false;
typedef long long ll;
int main(){
	int a,b;
	cin>>a>>b;
	b--;
	a--;
	if(b%a==0){
		cout<<b/a<<endl;
	}else{
		cout<<b/a+1<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std::literals::string_literals;
using i64 = long long;
using std::cout;
using std::endl;
using std::cin;

template<typename T>
std::vector<T> make_v(size_t a){return std::vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return std::vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

int main() {
	std::string s; cin >> s;
	
	bool ans = true;
	for(int i = 0; i < (int)s.size() - 1; i++) ans &= (s[i] != s[i + 1]);
	
	if(ans) printf("Good\n");
	else printf("Bad\n");
	return 0;
}


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

int a,b,c,d,e,f,answ,anss;
vector<int> w,s;
double tmp = -1;

main() {
    cin >> a >> b >> c >> d >> e >> f;
    for(int i=0;;i++) {
        if (i*a > f) break;
        for(int j=0;;j++) {
            if (!i && !j) break;
            if ((i*a+j*b)*100 > f) break;
            w.pb((i*a+j*b)*100);
        }
    }
    for(int i=0;;i++) {
        if (i*c > f) break;
        for(int j=0;;j++) {
            if (i*c+j*d > f) break;
            s.pb(i*c+j*d);
        }
    }
    sort(all(w));
    sort(all(s));
    vdelete(w);
    vdelete(s);
    rep(i,w.size()) rep(j,s.size()) {
        if (w[i]+s[j] > f || w[i]/100*e < s[j]) continue;

        if (tmp < (double)s[j]/(s[j]+w[i])*100) {
            tmp = (double)s[j]/(s[j]+w[i])*100;
            answ = w[i]+s[j];
            anss = s[j];
        }
    }
    cout << answ << " " << anss << endl;
}


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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P,VECP,greater<P> > PQP;
typedef priority_queue<ll, VECLL, greater<ll> > PQll;

#define rep(i,a,n) for(ll i = a;i < n;i++)   
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second


int main(){
    ll h,w;
    cin >> h >> w;
    char c[h+2][w+2];
    rep(i,0,h+2) rep(j,0,w+2) c[i][j] = '#';

    rep(i,1,h+1){
        rep(j,1,w+1){
            cin >> c[i][j];
        }
    }

    rep(i,0,h+2){
        rep(j,0,w+2){
            cout << c[i][j];
        }
        cout << endl;
    }
    return 0;
}


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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

int n;
string s;

int main(void) {
  // Here your code !
  scanf("%d", &n);

  cin >> s;

  if (n % 2 == 1) {
    printf("No\n");
    return 0;
  }

  int half = n / 2;

  for (int i = 0; i < half; ++i) {
    if (s[i] != s[half + i]) {
      printf("No\n");
      return 0;
    }
  }

  printf("Yes\n");

  return 0;
}


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

#define ll long long int
#define str string
#define ALL(a)  (a).begin(),(a).end()
#define P pair<ll,ll>

using Graph = vector<vector<int>>;

const int dy[] = { 0, 0, 1, -1 }, dx[] = { 1, -1, 0, 0 };
ll INFL = 1ll << 60, INF = 1 << 30, mod = 1e9 + 7, Min = INFL, Max = -1;
ll a, b, c ,n, sum, A[500010], B[500000],rui[500000],  dp[5000];
str S,T,U;bool check = true;	vector<ll> v;



int main() {
	//Code Line
cin >> a  >> b;
if(a >= 10)cout << b << endl;
else cout << b + (10-a)*100 << endl;


	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef  long long LL;
typedef  unsigned long long ULL;
typedef  double db;
typedef  long double ld;
#pragma comment(linker, "/STACK:102400000,102400000")
#define fuck(x) cout<<x<<endl
#define fuck1(x,y) cout<<x<<" "<<y<<endl
#define lson root<<1,l,mid
#define rson root<<1|1,mid+1,r
#define MP(a,b) make_pair(a,b)
#define PII pair<int,int>
#define PLL pair<ll,ll>
#define MP make_pair
#define se second
#define fi first
#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
const int INF = 0x3f3f3f3f3f,mod = 1e9+7,maxn = 3e5+100;
const double eps  =1e-6,PI = acos(-1);
template<typename T> inline void read(T &x){
    x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}
int N,val[maxn],cnt[20];
int d[maxn],ss[maxn];
int main(){
    read(N);
    for(int i = 0;i<N-1;i++){
        int x,y,a;
        read(x),read(y),read(a);
        val[x]^=a;
        val[y]^=a;
    }
    for(int i = 0;i<N;i++){
        if(val[i])cnt[val[i]]++;
    }
    int ans = 0,st = 0;
    for(int i = 0;i<16;i++){
        ans+=cnt[i]/2;
        if(cnt[i]&1)st = st|(1<<i);
    }
    for(int i = 1;i<=(1<<16);i++)d[i] = d[i>>1]+(i&1);
    for(int i = 1;i<=(1<<16);i++)d[i]--;
    for(int i = 1;i<=(1<<16);i++){
        for(int j = 0;j<=15;j++){
            if(i&(1<<j))ss[i]^=(j);
        }
    }
    for(int i = 1;i<=(1<<16);i++){
        if(ss[i]!=0)continue;
        for(int k = (i-1)&i;k;k = (k-1)&i){
            if(ss[k]==0)d[i] = min(d[i],d[k]+d[i^k]);
        }
    }
    printf("%d\n",ans+d[st]);
    return 0;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int H1, M1, H2, M2, K;
    cin >> H1 >> M1 >> H2 >> M2 >> K;
    int a1 = H1 * 60 + M1;
    int a2 = H2 * 60 + M2;

    if (H1 < H2 || (H1 <= H2 && M1 < M2))
        cout << max(a2 - a1 - K, 0) << endl;
    else {
        a2 += 24 * 60;
        cout << max(a2 - a1 - K, 0) << endl;
    }

    return 0;
}


Measured memory_bytes: 3584
import java.util.*;
import java.lang.*;


public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int t[] = new int[n];
        int x[] = new int[n];
        int y[] = new int[n];
        for (int i = 0; i < n; i++) {
            t[i] = sc.nextInt();
            x[i] = sc.nextInt();
            y[i] = sc.nextInt();
        }
        int xg = 0;
        int yg = 0;
        int tg = 0;
        boolean no = false;
        for (int i = 0; i < n; i++) {
            int hun = t[i] - tg - (Math.abs(x[i] - xg) + Math.abs(y[i] - yg));
            if (hun < 0 || hun % 2 != 0) {
                no = true;
                break;
            } else {
                xg = x[i];
                yg = y[i];
                tg = t[i];
            }
        }
        if (no) {
            System.out.println("No");
        } else {
            System.out.println("Yes");
        }
    }
}


Measured memory_bytes: 91184
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using boost::multiprecision::cpp_int;

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;

const ll INF = LLONG_MAX;
const ll MOD = 1e9+7;

int main() {
    // input, ready
    int N,M;
    cin >> N >> M;

    int combn = 0;
    int combm = 0;
    if (N>1) combn = (N*(N-1))/2;
    if (M>1) combm = (M*(M-1))/2;

    cout << combn+combm << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int h[100000], mCost[100000];
int Nstones, k;

int main() {

	scanf("%d %d", &Nstones, &k);
	for (int i = 0; i < Nstones; i++) {
		scanf("%d", &h[i]);
	}
	for (int i = 1; i < Nstones; i++) {
        	mCost[i] = 10000000000;
        	for (int j = i - 1; j >= max(i-k, 0); j--){
            		mCost[i] = min(mCost[j] + abs(h[j] - h[i]), mCost[i]);
        	}
	}
	printf("%d", mCost[Nstones - 1]);
}

Measured memory_bytes: 1024
path1 = [int(x) for x in input().split(' ')]
path2 = [int(x) for x in input().split(' ')]
path3 = [int(x) for x in input().split(' ')]

path1.sort()
path2.sort()
path3.sort()

result = True

allpath = path1 + path2 + path3
for i in [1,2,3,4]:
    if i not in allpath:
        result = False
    if allpath.count(i) == 3:
        result = False

if result:
    print('YES')
else:
    print('NO')

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

int main()
{
   int N, D;
   int man;
   cin >> N >> D;
   if ((N % (2*D + 1)) ==  0){
    man = N / (2*D + 1);
   }else{
       man = N / (2*D + 1) + 1;
   }
   cout << man << endl;
}

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

#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define RFOR(i, a, b) for (int i = a; i > b; --i)
#define REP(i, n) for (int i = 0; i < n; ++i)

int N;
int ans;

int main() {
  cin >> N;

  ans = N/3;

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


Measured memory_bytes: 256
from sys import exit, setrecursionlimit
from functools import reduce
from itertools import *
from collections import defaultdict
from bisect import bisect

def read():
  return int(input())

def reads():
  return [int(x) for x in input().split()]

setrecursionlimit(1000000)

N = read()
dic = defaultdict(int)

for i in range(N):
  s = input()
  dic[s[0]] += 1

result = 0
for a, b, c in combinations("MARCH", 3):
  result += dic[a] * dic[b] * dic[c]

print(result)

Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
#define maxn 200010
int a[maxn],n,i,k,ans=0,s=0;
int main()
{
	scanf("%d",&n);
	for (i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for (k=1;k<=n;k++)
		if (a[k]>0) break;
	if (k>n) k--;
	if (k==1) k++;
	for (i=1;i<k;i++)
		ans-=a[i];
	for (i=k;i<=n;i++)
		ans+=a[i];
	printf("%d\n",ans);
	s=a[1];
	for (i=k;i<n;i++)
	{
		printf("%d %d\n",s,a[i]);
		s-=a[i];
	}
	printf("%d %d\n",a[n],s);
	s=a[n]-s;
	for (i=2;i<k;i++)
	{
		printf("%d %d\n",s,a[i]);
		s-=a[i];
	}
	return 0;
}

Measured memory_bytes: 2304
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int [] a = new int[4];
        for(int i =0; i<4; i++)
        { a[i] = sc.nextInt();}
		int e = sc.nextInt();
		int k = sc.nextInt();
		sc.close();
		for(int i =0; i<4; i++)
        {if(e-a[i]>k) 
        {System.out.println(":(");
        System.exit(0);}
        }
		
		System.out.println("Yay!");
        
	}

}


Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;

/* short */
#define pb push_back
#define mp make_pair
#define Fi first
#define Se second
#define ALL(v) begin(v), end(v)
#define RALL(v) rbegin(v), rend(v)

/* REPmacro */
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define FORR(i, a, b) for(int i = (a); i >= (b); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOREACH(x, a) for(auto x : a)

/* exchange */
#define CHMIN(a, b) (a) = min((ll)(a), (ll)(b))
#define CHMAX(a, b) (a) = max((ll)(a), (ll)(b))

/* function */
#define IN(x) cin >> x
#define DEBUG(x) cerr << (x) << " "
#define LN() cerr << "\n"
#define PRINT(x) cout << (x) << endl
#define BR cout << endl

/* const */
const int ARRAY = 100005;
const int INF = 1001001001; // 10^9
const ll LINF = 1001001001001001001; // 10^18
const int MOD = 1e9 + 7;

ll N = 0;
ll K = 0;
ll t;
ll ret = 0;
string s;
ll dp[200005];
vl p;
ll M = 0;

void input() {
  IN(N);
  IN(K);
  REP(i, N) {
    IN(t);
    p.pb(t);
  }
}

void solve() {
  dp[0] = 0;
  REP(i, K) {
    dp[0] += p[i];
  }
  CHMAX(M, dp[0]);

  FOR(i, 1, N-K+1) {
    dp[i] = dp[i-1] - p[i-1] + p[i+K-1];
    CHMAX(M, dp[i]);
  }

  // REP(i, N-K+1) {
  //   DEBUG(dp[i]);
  // }

  double sum = (double)(M + K) / 2.0;
  cout << fixed << setprecision(6) << sum << endl;
}

int main(void){
  input();
  solve();
}


Measured memory_bytes: 3952
#include<bits/stdc++.h>
using namespace std;
 
#define REP(i,n) for(int i = 0;i < n;i++)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all(x) (x).begin(),(x).end()

template<class T> bool chmax(T& a,T b){ if(a < b){ a = b; return true; }else return false; }
template<class T> bool chmin(T& a,T b){ if(a > b){ a = b; return true; }else return false; }
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vl = vector<ll>;
using Pi = pair<int,int>;
using Pl = pair<ll,ll>;
using vpi = vector<Pi>;
using vpl = vector<Pl>;
 
#define debug(arr) cout << #arr << " = " << arr << '\n'
#define debug2(a,b) cout << "[" << #a << "," << #b << "] = " << "[" << a << "," << b << "]" << '\n'
template<class T> ostream &operator << (ostream& out, const vector<T>& arr) {
	cout << "{"; for (int i = 0; i < arr.size(); i++)cout << (!i ? "" : ", ") << arr[i]; cout << "}";
	return out;
}
template<class T> ostream &operator << (ostream& out, const vector<vector<T> >& arr) {
	cout << "{\n"; for (auto& vec : arr)cout << "  " << vec << ",\n"; cout << "}";
	return out;
}
template<class S,class T> ostream &operator << (ostream& out, const pair<S,T>& p){
  cout << "{" << p.first << "," << p.second << "}" << '\n';
  return out;
}
template<class T> istream &operator >> (istream& in, vector<T>& arr) {
	for (auto& i : arr)cin >> i; return in;
}

/////////////////////////////////////////////////////////////////////////
int main(void){
  cin.tie(0);
  ios::sync_with_stdio(false);
  //cout << fixed << setprecision(20);
  
  ll n,q;cin >> n >> q;
  ll ans = (n-2)*(n-2);
  set<Pi> X,Y;
  X.emplace(1,n);
  X.emplace(n,n);
  Y.emplace(1,n);
  Y.emplace(n,n);
  REP(t,q){
    int c,x;cin >> c >> x;
    if(c == 1){
      auto ele = *(--X.lower_bound(mp(x,n)));
      ll hit =  ele.second;
      ans -= (hit - 2);
      X.emplace(x,hit);
      if(ele == *X.begin()){
        auto ele2 = *Y.begin();
        Y.erase(ele2);
        Y.emplace(ele2.first,x);
      }
    }else{
      auto ele = *(--Y.lower_bound(mp(x,n)));
      ll hit =  ele.second;
      ans -= (hit - 2);
      Y.emplace(x,hit);
      if(ele == *Y.begin()){
        auto ele2 = *X.begin();
        X.erase(ele2);
        X.emplace(ele2.first,x);
      }
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 12976