akhauriyash/Code-Regression huggingface dataset:
//2019.9.2 by ljz
//email 573902690@qq.com
//if you find any bug in my code
//please tell me
#include<bits/stdc++.h>
//#include<ext/pb_ds/tree_policy.hpp>
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
//using namespace __gnu_cxx;
#define res register int
#define LL long long
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f
#define unl __int128
#define eps 5.6e-8
#define RG register
#define db double
#define pc(x) __builtin_popcount(x)
//#define pc(x) __builtin_popcountll(x)
typedef pair<int,int> Pair;
#define mp make_pair
#define fi first
#define se second
#define pi acos(-1.0)
#define pb push_back
#define ull unsigned LL
#define gc getchar
//template <class T>using Tree=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
//inline char gc() {
//    static char buf[100000],*p1,*p2;
//    return p1==p2&&(p2=(p1=buf)+fread(buf,1,100000,stdin),p1==p2)?EOF:*p1++;
//}
//inline int read() {
//    res s=0,ch=gc();
//    while(ch<'0'||ch>'9')ch=gc();
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s;
//}
inline int read() {
    res s=0,ch=gc(),w=1;
    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=gc();}
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
    return s*w;
}
inline LL Read() {
    RG LL s=0;
    res ch=gc();
    while(ch<'0'||ch>'9')ch=gc();
    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
    return s;
}
//inline LL Read() {
//    RG LL s=0;
//    res ch=gc(),w=1;
//    while(ch<'0'||ch>'9'){if(ch=='-')w=-1;ch=gc();}
//    while(ch>='0'&&ch<='9')s=s*10+ch-'0',ch=gc();
//    return s*w;
//}
//inline void write(RG unl x){
//    if(x>10)write(x/10);
//    putchar(int(x%10)+'0');
//}
inline void swap(res &x,res &y) {
    x^=y^=x^=y;
}
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//clock_t start=clock();
//inline void ck(){
//    if(1.0*(clock()-start)/CLOCKS_PER_SEC>0.1)exit(0);
//}
const int N=2e3+10;
namespace MAIN{
    int n,a[N];
    bitset<4000000+10> A,B;
    int sum;
    inline void MAIN(){
        n=read();
        for(res i=1;i<=n;i++)a[i]=read(),sum+=a[i];
        A.set(0);
        for(res i=1;i<=n;i++)B=A,B<<=a[i],A|=B;
        for(res i=(sum+1)/2;i<=sum;i++)if(A[i]){printf("%d\n",i);return;}
    }
}
int main(){
//    srand(19260817);
//    freopen("signin.in","r",stdin);
//    freopen("signin.out","w",stdout);
    MAIN::MAIN();
    return 0;
}

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

const int dx[] = {-1, 1, 0, 0};
const int dy[] = {0, 0, -1, 1};
char land[20][20];

void dfs(int y, int x) {
   land[y][x] = '0';
   for (int i = 0; i < 4; i++) {
      int ny = y + dy[i], nx = x + dx[i];
      if (ny >= 0 && ny < 12 && nx >= 0 && nx < 12 && land[ny][nx] == '1') {
         dfs(ny, nx);
      }
   }
   return;
}

int main() {
   while (cin >> land[0]) {
      for (int i = 1; i < 12; i++) {
         cin >> land[i];
      }

      int cnt = 0;
      for (int i = 0; i < 12; i++) {
         for (int j = 0; j < 12; j++) {
            if (land[i][j] == '1') {
               cnt++;
               dfs(i ,j);
            }
         }
      }
      cout << cnt << endl;
   }

   return 0;
}


Measured memory_bytes: 3020
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

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

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

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

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

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

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

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

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

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

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

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

fn main() {
    input!{
        n: usize,
        s: [u64; n],
    }
    let sum = s.iter().sum::<u64>();
    if sum % 10 != 0 {
        println!("{}", sum);
        return;
    }
    let mut ans = 0;
    for i in 0..n {
        let mut acc = sum - s[i];
        acc = if acc % 10 == 0 { 0 } else { acc };
        ans = max(ans, acc)
    }
    println!("{}", ans);
}


Measured memory_bytes: 4352
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n, r, p, c, x;
		List<Integer> cards = new ArrayList<Integer>();
		
		while(true){
			n=sc.nextInt(); //???????????°
			r=sc.nextInt(); //???????????????????????°
			
			if(n==0&&r==0){break;}
			
			for(int i=0;i<n;i++){
				cards.add(i+1);
			}
			
			for(int i=0;i<r;i++){
				p=sc.nextInt(); //p??????????????????
				c=sc.nextInt(); //c??????????????????
				for(int j=0;j<c;j++){
					x=cards.get(n-p-c+1);
					cards.remove(n-p-c+1);
					cards.add(x);
				}
			}
			System.out.println(cards.get(n-1));
			cards.clear();
		}
	}
}

Measured memory_bytes: 27712
S=list(map(int,input().split()))
A=S[0]
B=S[1]
if A%2==0:
    C=int(A/0.08)
    E=int((A+1)/0.08)
else:
    C=int(A/0.08)+1
    E=int((A+1)/0.08)-1
D=int(B/0.1)
n=max(C,D)

F=int((B+1)/0.1)-1
m=min(E,F)
if n<=m:
    print(int(n))
else:
    print(-1)


Measured memory_bytes: 38384
#include <iostream>
#include <string.h>
#include <vector>

using namespace std;

int br[200000];

int main()
{
    int n,m;
    cin>>n>>m;
    int mi=200000;
    memset(br,0,sizeof(br));
    int l,r;
    for(int i=1;i<=m;i++)
    {
        cin>>l>>r;
        mi=min(mi,l);
        if(br[l]==0)
            br[l]=r;
        else if(br[l]>r)
            br[l]=r;
    }
    int k=br[mi],ans=1;
    for(int i=1;i<=n;i++)
    {
        if(br[i]==0)
            continue;
        if(i>=k)
        {
            ans++;
            k=br[i];
        }
        else if(br[i]<k)
            k=br[i];
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 1024
from math import gcd

n=int(input())
mod = 10**9+7

d = dict()
zeros=0
for _ in range(n):
  a,b=map(int,input().split())
  if not any((a,b)):
    zeros+=1
    continue
  if all((a,b)):
    g = gcd(a,b)*(a//abs(a))
  elif a: g = a
  else: g = b
  
  p = a//g,b//g
  d[p] = d.get(p,0)+1

ans = 1
done = set()
for (a,b),v in d.items():
  if (-b,a) in done or (b,-a) in done:
    continue
  done.add((a,b))
  w=d.get((-b,a),0)+d.get((b,-a),0)
  ans *= (pow(2,v,mod)+pow(2,w,mod)-1)
  ans %= mod
print((ans+zeros-1+mod)%mod)
  
  

Measured memory_bytes: 72020
#include <bits/stdc++.h>
#define int long long
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define INF (((ll)1<<31)-1)
#define eps LDBL_EPSILON
#define moder (1000000007)
#define pie 3.141592653589793238462643383279
#define P std::pair<int,int>
#define prique priority_queue
#define ggr getchar();getchar();return 0;
using namespace std;
double a,b,c,d,e,f;
signed main(){
    while(cin>>a>>b>>c>>d>>e>>f){
        double ans1=(c*e-b*f)/(a*e-b*d),ans2=(c*d-a*f)/(b*d-a*e);
        if(c*e==b*f)ans1=0;
        if(c*d==a*f)ans2=0;
        if((int)(ans1*10000)%10>=5)ans1=(int)(ans1*1000)+1;
        else ans1=(int)(ans1*1000);
        if((int)(ans2*10000)%10>=5)ans2=(int)(ans2*1000)+1;
        else ans2=(int)(ans2*1000);
        printf("%.3lf %.3lf\n",ans1/1000,ans2/1000);
    }
    ggr;
}


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

#define ll long long
#define rep(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

using namespace std;

/////////////////////////////////////////////////////

ll N,K;
ll A[202020];

ll i, j, k;


bool calc(ll aa){
    ll k = K, i;
    rep(i,0,N){
        ll c = (A[i] - 1) / aa;
        k -= c;
        if(k<0)
            return false;
    }
    return true;
}

int main(){
    scanf("%lld%lld", &N, &K);
    rep(i,0,N){
        scanf("%lld", &A[i]);
    }
    ll l = 1, r = 1e12;
    while(l<r){
        ll c = (l + r) / 2;
        if(calc(c)){
            r = c;
        }else{
            l = c + 1;
        }
    }
    printf("%lld\n", l);

    return 0;
}

Measured memory_bytes: 5320
D=int(input())
clist=list(map(int,input().split()))
smat=[[int(x) for x in input().split()] for _ in range(D)]
#print(clist)
#print(smat)

index_set=set(range(26))
for d in range(D):
  max_index=-1
  max_sd=-1
  for i in index_set:
    if max_sd<smat[d][i]:
      max_index=i
      max_sd=smat[d][i]
      
  max_index2=-1
  max_sd2=-1
  for i in range(26):
    if max_sd2<smat[d][i]:
      max_index2=i
      max_sd2=smat[d][i]
      
  if max_index==max_index2:
    print(max_index+1)
    index_set.remove(max_index)
  else:
    if max_sd2>4*max_sd:
      print(max_index2+1)
    else:
      print(max_index+1)
      index_set.remove(max_index)      
      
  if not index_set:
    index_set=set(range(26))
  else:
    max_c=0
    for i in index_set:
      max_c=max(max_c,clist[i])
    if max_c<25:
      index_set=set(range(26))

Measured memory_bytes: 69368
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int n=scan.nextInt();
        int k=scan.nextInt();
        int l=scan.nextInt();
        UnionFind u1=new UnionFind(n),u2=new UnionFind(n);
        for(int i=0;i<k;++i){
            int u=scan.nextInt()-1;
            int v=scan.nextInt()-1;
            u1.unify(u,v);
        }
        for(int i=0;i<l;++i){
            int u=scan.nextInt()-1;
            int v=scan.nextInt()-1;
            u2.unify(u,v);
        }
        Map<Long,Integer>hm=new HashMap<Long,Integer>();
        for(int i=0;i<n;++i){
            long h=(long)u1.root(i)<<32|u2.root(i);
            if(hm.containsKey(h))
                hm.put(h,hm.get(h)+1);
            else
                hm.put(h,1);
        }
        for(int i=0;i<n;++i){
            long h=(long)u1.root(i)<<32|u2.root(i);
            System.out.print(hm.get(h)+(i==n-1?"\n":" "));
        }
    }
}
class UnionFind {
    int[] parent;
    int[] rank;
    UnionFind(int n) {
	this.parent = new int[n];
	this.rank = new int[n];
	this.clear();
    }
    void clear() {
	int n = this.parent.length;
	for (int i = 0; i < n; ++i) {
	    this.parent[i] = i;
	    this.rank[i] = 0;
	}
    }
    void unify(int x, int y) {
	int rootX = this.root(x);
	int rootY = this.root(y);
	if (rootX == rootY) {
	    return;
	}
	if (this.rank[rootX] < this.rank[rootY]) {
	    this.parent[rootX] = rootY;
	} else {
	    this.parent[rootY] = rootX;
	    if (this.rank[rootX] == this.rank[rootY]) {
		this.rank[rootX]++;
	    }
	}
    }
    int root(int x) {
	if (this.parent[x] == x) {
	    return x;
	}
	return this.parent[x] = this.root(this.parent[x]);
    }
}


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

main(){
  bool C[3];
  C[1] = C[2] = false;
  C[0] = true;
  char s, t, k;
  while( cin >> s >> k >> t ) swap(C[s-'A'], C[t-'A']);
  if ( C[0] ) cout << "A" << endl;
  if ( C[1] ) cout << "B" << endl;
  if ( C[2] ) cout << "C" << endl;
}

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

using namespace std;

typedef vector<int>::iterator ITE;

void print(vector<int> V){
  for(int i = 0; i < V.size(); i++)
    cout << V[i] << " ";
  cout << endl;
}

void input(vector<int>& V, int n){
  while(n--){
    int in;
    cin >> in;
    V.push_back(in);
  }
} 

void make(vector<int>& V){

  int Lim = V.size();
  for(int i = 0; i < Lim-1; i++){
    int sum = V[i];
    for(int j = i+1; j < Lim; j++){
      sum += V[j];
      V.push_back(sum);
    }
  }
  sort(V.begin(),V.end());
}

int main(){
  int n,m;
  while(cin >> n >> m && n+m){
    vector<int> W,H;

    input(H,n);
    input(W,m);

    make(H);
    make(W);

  
    int ans = 0;

    sort(W.begin(),W.end());
    sort(H.begin(),H.end());

    ITE ite = W.begin();

    //  print(W);
    //  print(H);

    while(ite < W.end()){
      ans += upper_bound(H.begin(),H.end(),*ite)-lower_bound(H.begin(),H.end(),*ite);
      //ite = upper_bound(W.begin(),W.end(),*ite);
      ite++;
    }

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

Measured memory_bytes: 20336
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int a, b, c, d;
  cin>>a>>b>>c>>d;
  int k=0;
  while(a>0 && c>0){
  	if(k%2 == 0){
  		c-=b;
  		k++;
  	}
  	else{
  		a-=d;
  		k++;
  	}
  }
  if(a<=0)
  	cout<<"No";
  else
  	cout<<"Yes";
  return 0;
}


Measured memory_bytes: 3592
#include <iostream>
#include <iterator>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <numeric>
#include <iomanip>
#include <limits>
#include <set>
#include <map>
#include <type_traits>
#include <cstdint>
#include <queue>
#define _USE_MATH_DEFINES
#include <math.h>

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

using namespace std;

//素因数分解
void factoring(ll n, map<ll, ll>& mp) {
	for (ll i = 2; i * i <= n; i++) {
		while (n % i == 0) {
			mp[i]++;
			n /= i;
		}
	}
	if (n != 1) mp[n]++;
}

//絶対値
template<class T, class U = std::make_unsigned_t<T>>
U SafeAbs( T x ) {
    return x < 0 ? -static_cast<uintmax_t>(x) : x;
}

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

//xのn乗
ll mod_pow(ll x, ll n, ll mod) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}
//xの逆元
ll mod_inv(ll x, ll mod) {//O(log(mod))
    return mod_pow(x, mod - 2, mod);
}

//nCr
ll ncr(ll n, ll r, ll mod){
	ll res=1;
	ll num=1,den=1;
	for(ll i=n;i>=n-r+1;i--){
		(den*=i)%=mod;
	}
	for(ll i=1;i<=r;i++){
		(num*=i)%=mod;
	}
	
	res=den*mod_inv(num,mod);

	return res%mod;
}


//二分探索
bool isOk(ll index, ll key,vector<ll> &a){
	
	if(a[index]>key){
		return true;
	}
	
	return false;
}

ll bin_search(ll key, vector<ll> &a){
	
	ll l=-1;
	ll r=a.size();

	while(abs(r-l)>1){
		ll mid = (l+r)/2;
		if(isOk(mid, key, a)){
			r=mid;
		}
		else{
			l=mid;
		}
	}
	return r;
}

/*
//深さ優先探索
void dfs(vector<vector<ll>> &gra,vector<bool> &seen, ll v){

	seen[v]=true;

	for(auto next : gra[v]){
		if(seen[next]){
			continue;
		}

		dfs(gra,seen,next);
	}
	
}
*/
const ll MOD=1000000007;

ll min(ll a, ll b){
	if(a>=b){
		return b;
	}
	else{
		return a;
	}
}

bool over(ll a,ll b){
	ll p=a*b;
	if(p/a==b){
		return false;
	}
	else{
		return true;
	}
}

void solve(){

	ll x,n;
	cin>>x>>n;
	vector<ll> p(n,0);
	ll near=0;
	bool c=false;
	for(ll i=0;i<n;i++){
		cin>>p[i];
		if(p[i]==x){
			c=true;
		}
	}
	
	if(!c || n==0){
		cout<<x<<endl;
	}
	else{
		ll l=x+1,r=x-1;
		bool lc=false, rc=false;;
		while(l<=101){
			for(ll i=0;i<n;i++){
				if(p[i]==l){
					lc=true;
					break;
				}
			}
			if(lc){
				lc=false;
				l++;
			}
			else{
				break;
			}
		}

		while(r>=0){
			for(ll i=0;i<n;i++){
				if(p[i]==r){
					rc=true;
					break;
				}
			}
			if(rc){
				rc=false;
				r--;
			}
			else{
				break;
			}
		}
		if(abs(r-x)>abs(l-x)){
			cout<<l<<endl;
		}
		else{
			cout<<r<<endl;
		}
	}
	

}


int main(){
	
	solve();
	
    return 0;
}


Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			long a = scan.nextLong();
			long b = scan.nextLong();
			long x = scan.nextLong();
			
			long B = b==0?1:b/x+1;
			long A = a==0?1:a/x+1;
			if(a%x==0)A--;
			
			
			System.out.println(B-A);
			
			
			
		}
		
		
	}
		

}


Measured memory_bytes: 23124
H, W=map(int, input().split())
A=[['#' for _ in range(W+2)]]+[["#"]+list(input())+["#"] for _ in range(H)]+[['#' for _ in range(W+2)]]
for i in range(H+2):
    for j in range(W+2):
        print(A[i][j], end='')
    print('')


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

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
        #define eprintf(...) 42
#endif

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define all(x) (x).begin(),(x).end()
#define foreach(u,v) for(auto (u) : (v))
#define pb push_back
#define mp make_pair
#define mt make_tuple

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<ll, ll> pll;
typedef vector<ll> vl;

const int inf = 1e9;
const ll linf = 1LL<<60;
const ll mod = 1e9 + 7;
const double eps = 1e-9;

/*
*/

int main()
{
  int a, b;
  cin >> a >> b;

  bool ans = false;
  if(a == 1 and b == 13) ans = true;
  else if(a == 13 and b == 1) ans = false;
  else if(a == b){
    cout << "Draw" << endl;
    return 0;
  }
  else ans = a > b;

  cout << (ans ? "Alice" : "Bob") << endl;
  return 0;
}


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

const int N_MAX = 1e5;

int main(){
    int N, K;
    cin >> N >> K;
    int h[N_MAX];
    int ans = 0;

    for (int i = 0; i < N; i++) cin >> h[i];

    for (int i = 0; i < N; i++) {
        if (h[i] >= K) ans++;
    }

    cout << ans << "\n";

    return 0;

}


Measured memory_bytes: 640
#include<cstdio>
#include <iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<cstdlib>
#include<list>
#include<set>
#include<numeric>

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

ll x[100010], y[100010];
ll ans_x,ans_y;
const int MOD = 1000000007;

int main()
{
	int N, M;  cin >> N >> M;
	for (int i = 1; i <= N; i++) {
		cin >> x[i];
	}
	for (int i = 1; i <= M; i++) {
		cin >> y[i];
	}

	for (int i = 1; i <= N; i++) {
		ans_x += (i - 1)*x[i] - (N - i)*x[i];
		ans_x %= MOD;
	}

	for (int i = 1; i <= M; i++) {
		ans_y += (i - 1)*y[i] - (M - i)*y[i];
		ans_y %= MOD;
	}
	
	cout << (ans_x * ans_y)%MOD << endl;
	return 0;
}

Measured memory_bytes: 1792
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
B+=[0]
count=0
power0=0
for n in range(N+1):
    enemy=A[n]
    power1=B[n]
    if power0+power1>=enemy:
        count+=enemy
        power0=power1-max(enemy-power0,0)
    else:
        count+=power0+power1
        power0=0
print(count)

Measured memory_bytes: 18624
#include<cstdio>
#include<map>
#include<set>
#include<queue>
#include<algorithm>
#define MAXN 100006
using namespace std;
int n,fa[MAXN],u,v,top,p[MAXN];
map<int,int> h[MAXN];
set<int> e[MAXN];
queue<pair<int,int> > q;
void link(int u,int v)
{
	e[u].insert(v);
	e[v].insert(u);
	if(u>v) swap(u,v);
	++h[u][v];
	if(h[u][v]==2) q.push(make_pair(u,v));
	if(h[u][v]>2)
	{
		printf("NO");
		exit(0);
	}
}
void cut(int u,int v)
{
	e[u].erase(v);
	if(u>v) swap(u,v);
	h[u].erase(v);
}
int find(int x)
{
	if(x!=fa[x]) fa[x]=find(fa[x]);
	return fa[x];
}
int main()
{
	//freopen("bluered.in","r",stdin);
	//freopen("bluered.out","w",stdout);
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		fa[i]=i;
	for(int i=1;i<n;i++)
	{
		scanf("%d%d",&u,&v);
		link(u,v);
	}
	for(int i=1;i<n;i++)
	{
		scanf("%d%d",&u,&v);
		link(u,v);
	}
	for(int i=1;i<n;i++)
	{
		do
		{
			if(q.empty())
			{
				printf("NO");
				return 0;
			}
			u=q.front().first;
			v=q.front().second;
			u=find(u);
			v=find(v);
			q.pop();
		}while(u==v);
		if(e[u].size()>e[v].size()) swap(u,v);
		fa[u]=v;
		cut(v,u);
		top=0;		
		for(set<int>::iterator it=e[u].begin();it!=e[u].end();it++)
			p[++top]=*it;
		for(int i=1;i<=top;i++)
		{
			int x=p[i];
			x=find(x);
			if(x==v) continue;
			link(x,v);
			cut(x,u);
		}
		e[u].clear();
	}
	printf("YES");
}

Measured memory_bytes: 40192
#include <iostream>
#include <vector>
#include <algorithm>
int INF = 10000;
int n;

int recursion(int i, int a, int b, int c);
int absolution(int z);

std::vector<int> A(3),bam(10);


int main(){
  std::cin>>n;
  for (int i = 0; i < 3; i++){
    std::cin>>A[i];
  }
  for (int i = 0; i < n; i++){
    std::cin>>bam[i];
  }
  std::cout<<recursion(0,0,0,0)<<std::endl;

  return 0;

}

int recursion(int i, int a, int b, int c){

  if(i == n){
    if(std::min({a,b,c}) == 0){
      return INF;
    }else{
      return absolution(a-A[0]) + absolution(b-A[1]) + absolution(c-A[2]) - 30;
    }
  }else{
    int temp0 = recursion(i+1,a,b,c);
    int temp1 = recursion(i+1,a+bam[i],b,c) + 10;
    int temp2 = recursion(i+1,a,b+bam[i],c) + 10;
    int temp3 = recursion(i+1,a,b,c+bam[i]) + 10;
    return std::min({temp0,temp1,temp2,temp3});
  }
}

int absolution(int z){
  if(z >= 0){
    return z;
  }else{
    return -z;
  }
}


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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 998244353;
struct mint {
    ll x;  // typedef long long ll;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}
    mint operator-() const { return mint(-x); }
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod - a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const { return mint(*this) += a; }
    mint operator-(const mint a) const { return mint(*this) -= a; }
    mint operator*(const mint a) const { return mint(*this) *= a; }
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t & 1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod - 2); }
    mint& operator/=(const mint a) { return *this *= a.inv(); }
    mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> l(k), r(k);
    rep(i, k) cin >> l[i] >> r[i];
    vector<mint> dp(n + 1);
    vector<mint> dpsum(n + 1);
    dp[1] = 1;
    dpsum[1] = 1;
    for (int i = 2; i <= n; ++i) {
        rep(j, k) {
            // [l[i], r[i]]
            int li = i - r[j];
            int ri = i - l[j];
            if (ri < 0) continue;
            li = max(li, 1);
            dp[i] += dpsum[ri] - dpsum[li - 1];  // dp[li]~dp[ri];
        }
        dpsum[i] = dpsum[i - 1] + dp[i];
    }
    cout << dp[n] << endl;
    return 0;
}


Measured memory_bytes: 6428
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

int main() {
	int n;
	cin >> n;
	vector<int> l(n);
	int ans = 0;
	for (int i = 0; i < n; i++) {
		cin >> l.at(i);
	}
	sort(l.begin(), l.end());
	reverse(l.begin(), l.end());
	for (int i = 0; i < n - 2; i++) {
		for (int j = i + 1; j < n - 1; j++){
			int t = l.at(i) - l.at(j);
			for (int k = j+1; k < n; k++) {
				if (l.at(k) > t) {
					ans++;
					//cout << l.at(i) << ' ' << l.at(j) << ' ' << l.at(k) << endl;
					//cout << i << ' ' << j << ' ' << k << endl;
				}
				else {
					break;
				}
			}
		}
	}
	cout << ans;
}

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

#define ln                '\n'
#define all(dat)           dat.begin(), dat.end()
#define loop(i, to)        for (int i = 0; i < to; ++i)
#define cont(i, to)        for (int i = 1; i <= to; ++i)
#define circ(i, fr, to)    for (num i = fr; i <= to; ++i)
#define foreach(i, dat)    for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long          num;

using namespace std;

const int nsz = 1e5;
int n;
bool vis[nsz + 5];
num a[nsz + 5], b[nsz + 5], pre[nsz + 5], ans[nsz + 5], sum, del;

int main() {
    ios_base::sync_with_stdio(0);
    cin >> n;
    loop (i, n) {
        cin >> a[i];
    }
    loop (i, n) {
        sum += a[i];
        b[i] = (a[(i + 1) % n] - a[i]) * 2;
    }
    int i = 0;
    num del = 0, pre = 0;
    while (!vis[i]) {
        vis[i] = 1;
        pre += del;
        del += b[i];
        i = (i + 2) % n;
    }
    memset(vis, 0, sizeof(vis));
    ans[0] = (sum - pre) / n;
    i = 2;
    vis[0] = 1;
    while (!vis[i]) {
        vis[i] = 1;
        ans[i] = ans[((i - 2) + n) % n] + b[((i - 2) + n) % n];
        i = (i + 2) % n;
    }
    loop (i, n) {
        cout << ans[i] << ' ';
    }
    cout << ln;
}


Measured memory_bytes: 3840
import java.util.Scanner;
class Main{
  public static void main(String args[])
  {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int M = sc.nextInt();
    if(N == M)
    {
      System.out.println("Yes");
    }
    else{
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#define debug(x) cout << #x " => " << (x) << endl
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
#endif
using lint = long long;
constexpr int MOD = (int)1e9 + 7;
constexpr double EPS = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  string s;
  cin >> s;
  string s2(s.rbegin(), s.rend());
  int cnt = 0;
  rep (i, (s.length() + 1) / 2) {
    if (s[i] == s2[i]) ++cnt;
  }
  cout << (s.length() + 1) / 2 - cnt << endl;
  return 0;
}

Measured memory_bytes: 256
//
//  ABC061B.cpp
//  programing
//
//  Created by 毛利源 on 2019/01/29.
//

#include<iostream>
using namespace std;

int main(){
  int N,M;
  std::cin >> N>>M;
  pair<int,int> road[M];
  for (int i = 0; i < M; i++) {
    std::cin>> road[i].first >>road[i].second;
  }
  int city[N];
  for(int i=0;i<N;i++){
    city[i] = 0;
  }
    for (int i = 0; i < M; i++) {
      city[road[i].first-1]++;
      city[road[i].second-1]++;
    }
    for (int i = 0; i < N; i++) {
      std::cout <<city[i] << '\n';
    }
    return 0;
}


Measured memory_bytes: 256
a,b = map(int, input().split())

def gcd(a,b):
    '''
    3 個以上の値の最大公約数を求めるためには、
    res = 0 と初期化
    各 i に対して res = GCD(res, x[i]) と更新する
    '''
    while b!=0:
        a,b = b,a%b
    return a

 #最小公倍数
def lcm(a,b):
    return a*b // gcd(a,b)

print(lcm(a,b))

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

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

#define FOR(i, n, m) for (ll(i) = (m); (i) < (n); ++(i))
#define REP(i, n) FOR(i, n, 0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll)1e15;

ll A[100005];
ll B[100005];

int main()
{
    string S;
    cin >> S;
    memset(A, 0, sizeof(A));
    memset(B, 0, sizeof(B));
    ll r = 0, l = 0;
    ll N = S.length();
    REP(i, N)
    {
        if (S[i] == 'R')
            r++;
        if (S[N - 1 - i] == 'L')
            l++;
        if (i == N - 1)
            continue;
        if (S[i + 1] == 'L')
        {
            A[i] += r;
            r = 0;
        }
        if (S[N - 2 - i] == 'R')
        {
            A[N - 1 - i] += l;
            l = 0;
        }
    }

    REP(i, N)
    {
        if (A[i] == 0)
            continue;
        if (S[i] == 'R')
        {
            B[i] += A[i] / 2 + A[i] % 2;
            B[i + 1] += A[i] / 2;
        }
        if (S[i] == 'L')
        {
            B[i] += A[i] / 2 + A[i] % 2;
            B[i - 1] += A[i] / 2;
        }
    }

    REP(i, N)
    {
        cout << B[i] << " ";
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 2176
a, b, k = gets.split.map(&:to_i)
x = []
if a == b then
	k = 1
elsif k > b - a then
	k = b - a
end
for i in 0...k
	x.push(a + i)
	x.push(b - i)
end
x.uniq!
x.sort!
puts x

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

int main() {
    int x1,x2,x3,x4,x5;
    for (int i=0; i<5; i++) {
        int c;
        cin >> c;
        if (c==0) {
            cout << i+1 << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3544
import math
N = int(input())
x = list(map(int,input().split()))

list.sort(x, reverse=True)
l = len(x)
if N == 1:
    print(0)
elif N == 2:
    print(x[0])
elif N%2==0:
    ans = 0
    for i in range(math.floor(N/2)):
        ans += 2 * x[i]
    print(ans - x[0])
else:
    ans = 0
    for i in range(math.floor(N/2)+1):
        ans += 2 * x[i]
    print(ans - x[0] - x[math.floor(N/2)])

Measured memory_bytes: 33064
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

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

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;



int main(void) {
	int N,A;
	cin >> N;
	cin >> A;
	cout << N * N - A << endl;
	return 0;
}

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

// int/long:		-2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

#define	INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define	MOD 1000000007

#define	Rep0(i, n)	for (auto i=0; i<n; i++)
#define	Rep1(i, n)	for (auto i=1; i<=n; i++)
#define Sort(P)	sort(P.begin(), P.end())
#define Rev(P)	reverse(P.begin(), P.end())

int	main() {
	int H, W, K;
	cin >>H >>W >>K;
	vector<vector<int>> c(H, vector<int> (W, 0));
	Rep0(i, H) {
		string S;
		cin >>S;
		Rep0(j, W)
			if ('#'==S.at(j))
				c.at(i).at(j)=1;
	}
	int S=0;
	int HH=pow(2, H);
	int WW=pow(2, W);
	Rep0(i, HH) {
		vector<int> h(H, 0);
		int HHH=i;
		int HX=0;
		while (HHH>0) {
			if (1==HHH%2)
				h.at(HX)=1;
			HHH /=2;
			HX++;
		}
		Rep0(j, WW) {
			vector<int> w(W, 0);
			int WWW=j;
			int WX=0;
			while (WWW>0) {
				if (1==WWW%2)
					w.at(WX)=1;
				WWW /=2;
				WX++;
			}
			int SS=0;
			Rep0(ii, H)
				Rep0(jj, W)
					if (1==c.at(ii).at(jj)) {
						if ((0==h.at(ii))&&((0==w.at(jj))))
							SS++;
					}
			if (SS==K)
				S++;
		}
	}
	cout <<S <<endl;
	return 0;
}



Measured memory_bytes: 4048
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <string>

std::string S, T;
bool ans = true;


int main() {
  std::cin >> S >> T;
  int size_s = S.length();
  for (int i = 0; i < size_s; i++) {
    if (S[i] != T[i]) {
      ans = false;
    }
  }
  std::cout << (ans ? "Yes" : "No") << std::endl;
}

Measured memory_bytes: 3624
S = input()
lenS = len(S)
firstis0 = 0
firstis1 = 0

for i in range(len(S)):
    if i % 2 == 0 and S[i] == "1":
        firstis0 += 1
    elif i % 2 == 0 and S[i] == "0":
        firstis1 += 1
    elif i % 2 == 1 and S[i] == "0":
        firstis0 += 1
    else:
        firstis1 += 1
print(str(min(firstis0, firstis1)))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
 using namespace std;
 #define rep(i,N) for(int i=0;i<int(N);++i)
 using ll = long long;
 const int INF = 2147483647;
 const ll MOD = 1000000007;
 // const ll INF = 1000000000000000000LL;
 
 int main(){
	string s,t;
	cin >> s >> t;
	int s_size = s.size();
	int t_size = t.size();
	int nin = t.size();
	if(s_size==t_size){
		int ans = s.size();
		for(int i=0;i<s.size();i++){
			if(s[i]==t[i]) ans--;
		}
		cout << ans << endl;
		return 0;
	}
	for(int i=0;i<(s_size-t_size);i++){
		int cnt=t_size;
		for(int j=0;j<t_size;j++){
				if(s[i+j]==t[j])
					cnt--;
		}
		nin = min(nin,cnt);
	}
	cout << nin << endl;
 }

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

int main() {
	int a,b,k;
	cin >> a >> b >> k;
	if (a < b) {
		swap(a, b);
	}
	vector<int> ans;
	for (int i = 1; i <= b; i++) {
		if (!(a % i) && !(b%i)) {
			ans.push_back(i);
		}
	}
	cout << ans[ans.size() - k] << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> pp;

int main() {
    int N;
    cin >> N;
    vector<pp> R(N),B(N);

    for(int i=0; i<N; ++i) {
        int a,b; cin >> a >> b;
        R[i] = pp(b,a);
    }
    sort(R.begin(), R.end(), greater<pp>());

    for(int i=0; i<N; ++i) {
        int a,b; cin >> a >> b;
        B[i] = pp(a,b);
    }
    sort(B.begin(), B.end());

    int res = 0;
    for(int i=0; i<N; ++i) {
        int x = B[i].first;
        int y = B[i].second;
        for(int i=0; i<N; ++i) {
            if(R[i].first != -1 && R[i].second < x && R[i].first < y) {
                R[i].first = -1;
                ++res;
                break;
            }
        }
    }

    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int n = Integer.parseInt(str[0]);
    int k = Integer.parseInt(str[1]);
    String s = in.readLine();
    String tmp = String.valueOf(s.charAt(k-1)).toLowerCase();
    System.out.println(s.substring(0,k-1) + tmp + s.substring(k));
  }
}

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

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'

signed main() {
  string s;
  cin >> s;
  int n = s.size() + 1;
  vi a(n);
  int cnt = 0;
  rep (i, n - 1) {
    if (s[i] == '<') {
      cnt++;
    }
    else cnt = 0;
    a[i + 1] = cnt;
  }

  cnt = 0;
  rrep (i, n - 1) {
    if (s[i] == '>') cnt++;
    else cnt = 0;
    chmax(a[i], cnt);
  }

  int sum = 0;
  rep (i, n) {
    sum += a[i];
  }
  cout << sum << endl;
}

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

using namespace std;

int main()
{
  uint64_t N;
  cin >> N;
  
  uint64_t M = N / 3;
  
  set<uint64_t> Aset;
  multiset<uint64_t> Amset;
  for (uint64_t n = 0; n < N; ++n) {
    uint64_t A;
    cin >> A;
    
    Aset.insert(A);
    Amset.insert(A);
  }
  
  uint64_t K = Aset.size();
  uint64_t A1 = *Aset.begin(); Aset.erase(Aset.begin());
  
  if ((K == 1) && (A1 == 0)) {
    cout << "Yes" << endl;
    return 0;
  }
  
  if ((N % 3) != 0) {
    cout << "No" << endl;
    return 0;
  }
  
  if (K > 3) {
    cout << "No" << endl;
    return 0;
  }

  if (K == 1) {
    cout << "No" << endl;
    return 0;
  } else if (K == 2) {
    if (A1 != 0) {
      cout << "No" << endl;
      return 0;
    }
    
    uint64_t C1 = Amset.count(A1);
    if (C1 != M) {
      cout << "No" << endl;
      return 0;
    }
    
    cout << "Yes" << endl;
  } else if (K == 3) {
    uint64_t A2 = *Aset.begin(); Aset.erase(Aset.begin());
    uint64_t A3 = *Aset.begin(); Aset.erase(Aset.begin());
    
    if ((A1 ^ A2 ^ A3) != 0) {
      cout << "No" << endl;
      return 0;
    }
    
    uint64_t C1 = Amset.count(A1);
    uint64_t C2 = Amset.count(A2);
    if ((C1 != M) || (C2 != M)) {
      cout << "No" << endl;
      return 0;
    }
    
    cout << "Yes" << endl;
  }
  
  return 0;
}

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

typedef unsigned 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
#define Vec(a) vector <int> a
#define F first
#define S second
const int INF = 1 << 20;
const int MOD = 1e9+7;

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

	char k[] = "keyence";

	unsigned int a = 0;
	for(int i = 0; i < 7; ++i) {
		if (s[i] != k[i])
			break;
		a++;
	}
	unsigned int b = 0;
	for(int i = 0; i < 7; ++i) {
		if (s[s.length() - i - 1] != k[6-i])
			break;
		b++;
	}

	// cerr << a << ", " << b << endl;
	if (a + b >= 7)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
	return 0;
}


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

using namespace std;
int main(void){

    int n, a, b;
    cin >> n >> a >> b;

    int result = 0;
    for(int i=1; i<=n; i++) {
        string s = to_string(i);
        int sum = 0;
        for(int j=0; j<s.size(); j++) {
            sum += stoi(s.substr(s.size()-j-1, 1));
        }
        if(sum >= a && sum <= b) result += i;
    }
    
    cout << result << endl;

    return 0;
    
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
using namespace std;
typedef long long ll;
int INF=1<<29;

int main(){
	int n,ans=0;
	cin>>n;
	vector<int> v(n),c(n);
	for(int i=0;i<n;i++) cin>>v[i];
	for(int i=0;i<n;i++) cin>>c[i];
	for(int bit=0;bit<(1<<n);bit++){
		int x=0,y=0;
		for(int i=0;i<n;i++){
			if(bit&(1<<i)){
				x+=v[i];
				y+=c[i];
			}
		}
		ans=max(ans,x-y);
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(){
    int a,b,c;
    cin>>a>>b>>c;
    for(int i=b;i<=c;i++){
    	if(i%a==0){
    		cout<<"OK";
    		return 0;
		}
	}
	cout<<"NG";
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>

using namespace std;

int main(){
  int N;
  cin >> N;
  int x[N], y[N], h[N];
  for(int i=0; i<N; i++)
    cin >> x[i] >> y[i] >> h[i];
  //入力終わり

  int H;
  int cx, cy;

  int tmpH;
  //center座標の全探索
  for(cx=0; cx<=100; cx++){
    for(cy=0; cy<=100; cy++){
      //全ての点からHを全探索で計算
      for(int i=0; i<N; i++){
	//その点の高さが0ならHとの関連性はない
	if(h[i] == 0)
	  continue;

	//0でない高さからHを計算できたら一回roopを出る
	H = h[i] + abs(x[i]-cx) + abs(y[i]-cy);
	break;
	
      } //i roop

      //上で求めたHに対して，任意の点で条件を満たすか確かめる
      bool flag = true;
      for(int i=0; i<N; i++){
	//満たさなければ次のループへ
	if(h[i] != max(H - abs(cx-x[i] ) - abs(cy-y[i] ), 0 ) ){
	  flag = false;
	  break;
	}
      }
      
      if(flag)
	goto end;
    } //cy roop
  } //cx roop

 end :

  cout << cx << " " << cy << " " << H << endl;

  return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#define ll long long
ll a,b,x;
int main()
{
	scanf("%lld%lld%lld",&a,&b,&x);
	a=((a+x-1)/x)*x;
	b=b/x*x;
	printf("%lld\n",(b-a)/x+1);
	return 0;
}

Measured memory_bytes: 128
MOD = 10**9+7
def resolve():
    N, K = list(map(int, input().split()))
    R, S, P = list(map(int, input().split()))
    T = list(input())
    
    score = 0
    hands = {
        "r": ("p", P),
        "s": ("r", R),
        "p": ("s", S)
    }
    hist = []
    for i, t in enumerate(T):
        hand, point = hands[t]
        if i >= K and hand == hist[-K]:
            hist.append("*")
            continue
        score += point
        hist.append(hand)
    #print(hist)
    print(score)
    

if '__main__' == __name__:
    resolve()

Measured memory_bytes: 10528
// BEGINNING WITH THE NAME OF ALMIGHTY GOD ALLAH
// AUTHOR:: MOHAMMAD FAISAL
#include<bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.flush();
	
  	int n,i;cin >> n >> i;
  	cout<<(n-i)+1;
	return 0;
	// BYE BYE
}


Measured memory_bytes: 256
;; -*- coding: utf-8 -*-
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (ql:quickload '(:cl-debug-print :fiveam))
  #-swank (set-dispatch-macro-character #\# #\> (lambda (s c p) (declare (ignore c p)) (read s nil (values) t))))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)
#-swank (disable-debugger) ; for CS Academy

;; BEGIN_INSERTED_CONTENTS
(defmacro dbg (&rest forms)
  #+swank
  (if (= (length forms) 1)
      `(format *error-output* "~A => ~A~%" ',(car forms) ,(car forms))
      `(format *error-output* "~A => ~A~%" ',forms `(,,@forms)))
  #-swank (declare (ignore forms)))

(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(declaim (inline println))
(defun println (obj &optional (stream *standard-output*))
  (let ((*read-default-float-format* 'double-float))
    (prog1 (princ obj stream) (terpri stream))))

(defconstant +mod+ 1000000007)

;; Body
;;;
;;; Arithmetic operations with static modulus
;;;

(defmacro define-mod-operations (&optional (divisor 1000000007))
  `(progn
     (defun mod* (&rest args)
       (reduce (lambda (x y) (mod (* x y) ,divisor)) args))

     (sb-c:define-source-transform mod* (&rest args)
       (if (null args)
           1
           (reduce (lambda (x y) `(mod (* ,x ,y) ,',divisor)) args)))

     (defun mod+ (&rest args)
       (reduce (lambda (x y) (mod (+ x y) ,divisor)) args))

     (sb-c:define-source-transform mod+ (&rest args)
       (if (null args)
           0
           (reduce (lambda (x y) `(mod (+ ,x ,y) ,',divisor)) args)))

     (define-modify-macro incfmod (delta divisor)
       (lambda (x y divisor) (mod (+ x y) divisor)))

     (define-modify-macro decfmod (delta divisor)
       (lambda (x y divisor) (mod (- x y) divisor)))))

(define-mod-operations)

(defun main ()
  (let* ((s (read-line))
         (n (length s))
         (dp (make-array (list (+ n 1) 13) :element-type 'uint32 :initial-element 0)))
    (declare (simple-string s)
             (uint31 n))
    (setf (aref dp 0 0) 1)
    (do ((pos 0 (+ pos 1))
         (base 1 (mod (* base 10) 13)))
        ((= pos n))
      (declare (uint32 pos base))
      (if (char= #\? (aref s (- n pos 1)))
          (dotimes (d 10)
            (let ((num (mod (* d base) 13)))
              (dotimes (m 13)
                (incfmod (aref dp (+ pos 1) (mod (+ m num) 13))
                         (aref dp pos m)
                         +mod+))))
          (let* ((d (digit-char-p (aref s (- n pos 1))))
                 (num (mod (* d base) 13)))
            (dotimes (m 13)
              (setf (aref dp (+ pos 1) (mod (+ m num) 13))
                    (aref dp pos m))))))
    (println (aref dp n 5))))

#-swank (main)


Measured memory_bytes: 21472