akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define NUM 2520
#define INF (1LL<<50)
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define TO_STRING(VariableName) # VariableName
#define LOG(x) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<endl;
#define LOG2(x,y) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<endl;
#define LOG3(x,y,z) if(DEBUG)cout<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;
#define LOG4(w,x,y,z) if(DEBUG)cout<<TO_STRING(w)<<"="<<w<<" "<<TO_STRING(x)<<"="<<x<<" "<<TO_STRING(y)<<"="<<y<<" "<<TO_STRING(z)<<"="<<z<<endl;

template<class T>bool chmax(T & a, const T & b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }



void func(long long N, long long A, long long B){

    cout<<(N/(A+B))*A + min(A,N%(A+B))<<endl;

}

int main(){
    // cout << fixed << setprecision(5);

    long long N;
    scanf("%lld",&N);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    func(N, A, B);
    return 0;
}


Measured memory_bytes: 256
// D - Friend Suggestions
// UnionFinde version (with rank)
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
#define rp(i,s,e) for(int i=(s);i<(e);++i)

class UnionFind{//union-find class (rank)
	vector<int> parent_or_size;// <0: root&-(size), >=0: parent number
	vector<int> rank;//rank
	public:
	UnionFind(int n){
		parent_or_size.resize(n);
		rank.resize(n);
		for(int v=0; v<parent_or_size.size(); ++v){
			parent_or_size[v] = -1;
			rank[v] = 0;
		}
	}
	int root(int v){return parent_or_size[v] < 0? v: parent_or_size[v] = root(parent_or_size[v]);}
	bool unite(int v, int u){
		v = root(v); u = root(u);
		if(v == u) return false;
		if(rank[v] < rank[u]) swap(v, u);
		parent_or_size[v] += parent_or_size[u];
		parent_or_size[u] = v;
		if(rank[v] == rank[u]) rank[v]++;
		return true;
	}
	bool same(int v, int u){return root(v)==root(u);}
	int size(int v){return -parent_or_size[root(v)];}
};

int main(){
	int N,M,K; scanf("%d%d%d",&N,&M,&K);
	UnionFind uf(N);
	vi C(N);
	int s,t;
	rp(i,0,M){
		scanf("%d%d",&s,&t); s--; t--;
		uf.unite(s,t);
		C[s]++; C[t]++;
	}
	rp(i,0,K){
		scanf("%d%d",&s,&t); s--; t--;
		if(uf.same(s,t)) C[s]++, C[t]++;
	}
	rp(i,0,N) printf("%d ",uf.size(i)-C[i]-1);
}

Measured memory_bytes: 2048
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
 


public class Main {
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");//1 1 2 3 5
	//static long mod =1000000007;
	//static 	ArrayList<Integer> cc = new ArrayList<>(100);
	
	
	
	public static void main(String[] args) {
		//int N=sc.nextInt();for(int i=0;i<N;i++) {}
		//M 77 || //A 65 || //R 82 || //C 67 || //H 72 || 
		int W=sc.nextInt();
		int H=sc.nextInt();
		int N=sc.nextInt();
		
		int x[]=new int[N];
		int y[]=new int[N];
		int a[]=new int[N];
		
		int x1=0;//saidai
		int x2=100000009;//saisyou
		int y1=0;//saidai
		int y2=100000009;//saisyou
		for(int i=0;i<N;i++) {
			x[i]=sc.nextInt();
			y[i]=sc.nextInt();
			a[i]=sc.nextInt();
			
			if(a[i]==1) {
				x1=Math.max(x1, x[i]);
			}else if(a[i]==2) {
		
				x2=Math.min(x2, x[i]);
				
			}else if(a[i]==3) {
				y1=Math.max(y1, y[i]);
			}else if(a[i]==4) {
				
				y2=Math.min(y2, y[i]);
			}
		}
		
		x2=Math.min(x2,W);
		y2=Math.min(y2,H);
		
		if(y1>y2||x1>x2)p(0);
		else p((y2-y1)*(x2-x1));
		
		
		
		
		
	}

	

	public static long gcd(long a, long b) {
        return b == 0 ? a: gcd(b, a % b);
	}
	
	
	

	


	
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
	
}
	


Measured memory_bytes: 22740
#include <bits/stdc++.h>
using namespace std;
#define sz(x) ((int) (x).size())
#define forn(i,n) for (int i = 0; i < int(n); ++i)
typedef long long ll;
typedef long long i64;
typedef long double ld;
const int inf = int(1e9) + int(1e5);
const ll infl = ll(2e18) + ll(1e10);

int main() {
    #ifdef LOCAL
    assert(freopen("f.in", "r", stdin));
    #else
    #endif
    int x;
    cin >> x;
    ll L = 2, R = 1e18;
    while (L + 1 < R) {
        ll c = (L + R) / 2;
        ll a = c;
        int n = 0;
        while (a > 2) {
            --a;
            a /= 2;
            ++n;
        }
        if (n > x)
            R = c;
        else
            L = c;
    }
    cout << L << '\n';
}


Measured memory_bytes: 384
#include<iostream>

int main(){

	std::uint16_t n, a, b;
	std::cin >> n;

	std::uint16_t zorome_{};
	for( int i{}; i < n; ++i )
	{
		std::cin >> a >> b;

		zorome_ = a == b ? zorome_ + 1 : 0;
		if( 3 <= zorome_ )
			break;
	}

	std::cout << ( zorome_ >= 3 ? "Yes" : "No" ) << "\n";

	return 0;
}

Measured memory_bytes: 3088
#include<stdio.h>
#include<string.h>
#pragma GCC optimize("O3")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define rep(i,N) for(int i=0;i<(int)N;i++)
static inline void PUT(char c)
{
  static char buf[1<<15],*ptr=buf;
  if(ptr==buf+strlen(buf)||c==0){fwrite(buf,1,ptr-buf,stdout),ptr=buf;}*ptr++=c;
}
static inline int IN(void)
{
  int x=0,f=0,c=getchar();while(c<48||c>57){f^=c==45,c=getchar();}
  while(c>47&&c<58){x=x*10+c-48,c=getchar();}return f?-x:x;
}
static inline void OUT(int a)
{
  if(a<0)PUT('-'),a=-a;
  int d[40],i=0;do{d[i++]=a%10;}while(a/=10);
  while(i--){PUT(d[i]+48);}PUT('\n');
}
const int MOD=998244353;
int main()
{
  int N=IN(),K=IN(),l=0,r=0,range[K][2]={{0}},dp[N]={0};
  dp[0]=1;dp[1]=-1;
  rep(i,K){range[i][0]=IN(),range[i][1]=IN()+1;} 
  rep(i,N)
  {
    if(i){dp[i]=(1l*dp[i]+dp[i-1])%MOD;}
    rep(j,K)
    {
      l=range[j][0],r=range[j][1];
      if(i+l<N){dp[i+l]=(1l*dp[i+l]+dp[i])%MOD;}
      if(i+r<N){dp[i+r]=(1l*dp[i+r]-dp[i])%MOD;}
    }
  }
  return OUT(dp[N-1]<0?dp[N-1]+MOD:dp[N-1]),0;
}

Measured memory_bytes: 2312
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
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; }
//const ll INF = 1LL << 60;
//const int INF = 1001001001;

int main(void){
    int n,m;
    cin >> n >> m;
    priority_queue<int> q;
    REP(i,n){
        int a;
        cin >> a;
        q.push(a);
    }
    REP(i,m){
        int tmp=q.top();
        q.pop();
        q.push(tmp/2);
    }
    ll ans=0;
    while(!(q.empty())){
        ans+=q.top();
        q.pop();
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 3820
x = input()

if x == 'SUN':
    a = 7
elif x == 'MON':
    a = 1
elif x == 'TUE':
    a = 2
elif x == 'WED':
    a = 3
elif x == 'THU':
    a = 4
elif x == 'FRI':
    a = 5
elif x == 'SAT':
    a = 6
b = 7 - a
if b == 0:
    print(7)
else:
    print(b)


Measured memory_bytes: 3188
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<map>
#include<queue>
#include<stack>
#include<iomanip>
#include<set>
using namespace std ;

long long n , x , y ;

void input ( ) {
    scanf ( "%lld%lld%lld" , &n , &x , &y ) ;
}

void solve ( ) {
    if ( x > y ) { swap ( x , y ) ; }
    if ( ( y - x ) % 2 == 0 ) { printf ( "%lld\n" , ( y - x ) / 2 ) ; }
    else {
        long long h1 = x + ( y - x ) / 2 ;
        long long h2 = n - y + 1 + ( n - ( x + ( n - y + 1 ) ) ) / 2 ;
        printf ( "%lld\n" , min ( h1 , h2 ) ) ;
    }
}

int main ( ) {
    ios_base :: sync_with_stdio ( false ) ;
    cin.tie ( NULL ) ;
    input ( ) ;
    solve ( ) ;
    return 0 ;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(){
	int i[100], n, a, c = 0;
	scanf("%d",&n);
	while(c < n){
		scanf("%d",&a);
		i[c] = a;
		c++;
	}
	c--;
	while(c >= 0){
		printf("%d",i[c]);
		if(c > 0) {
			printf(" ");
		}
		c--;
	}
	printf("\n");
	return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> a(N);
    for(int i = 0; i < N; i++) {
        cin >> a.at(i);
    }
    int all = 0;
    for(int i = 0; i < N; i++) {
        all ^= a.at(i);
    }
    // cout << all << endl;

    for(int i = 0; i < N; i++) {
        cout << (all ^ a.at(i)) << endl;
    }

    return 0;
}

Measured memory_bytes: 3956
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
#define show(x) {for(auto i: x){cout << i << " ";} cout << endl;}
using namespace std;
using ll = long long;
using P = pair<int, int>;

const int V = 100005;
vector<int> to[V*2];
bool visited[V*2];

vector<int> cnt;
void dfs(int x) {
  if (visited[x]) return;
  visited[x] = true;
  cnt[x/V]++;
  for (int y : to[x]) {
    if (!visited[y]) dfs(y);
  }
}

int main() {
  // yに+100005、to[]にx→yを入れる、同じグループのx座標の数とy座標の数の積
  int N;
  cin >> N;
  rep(i, N) {
    int X, Y;
    cin >> X >> Y;
    Y += V;
    to[X].push_back(Y);
    to[Y].push_back(X);
  }
  ll ans = 0;
  for (int i = 1; i < V+1; i++) {
    if (visited[i]) continue;
    cnt = vector<int> (2);
    dfs(i);
    ans += (ll)cnt[0] * cnt[1];
  }
  ans -= N;
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 13384
#include <stdio.h>
 
int call(int);
 
int main(void) {
    int i, n;
    for(i = scanf("%d", &n); i <= n; i++) {
        call(i) && printf(" %d", i);
    }
    printf("\n");
    return 0;
}
 
int call(int x) {
    int rslt = 0;
    x % 3 || (rslt = 1);
    for(x *= 10; (x /= 10) > 0; x % 10 == 3 && (rslt = 1));
    return rslt;
}


Measured memory_bytes: 2044
#include<stdio.h>
#define MAX 2000000
#define INF (1<<30)

int H, S[MAX+1];

void swap(int *a, int *b){
  int temp;
  temp = *a;
  *a = *b;
  *b = temp;
}

void maxHeapify(int i){
  int l = i * 2, r = i * 2 + 1, largest, temp;
  if(l <= H && S[l] > S[i])
    largest = l;
  else
    largest = i;

  if(r <= H && S[r] > S[largest])
    largest = r;
  if(largest != i){
    swap(&S[i], &S[largest]);
    maxHeapify(largest);
  }
}

int extractMax(){
  int maxid;
  if(H < 1) return -INF;
  
  maxid = S[1];
  S[1] = S[H--];
  maxHeapify(1);
  return maxid;
}

void increaseKey(int i, int key){
  if(key < S[i]) return;
  S[i] = key;
  while(i > 1 && S[i / 2] < S[i]){
    swap(&S[i], &S[i / 2]);
    i = i / 2;
  }
}

void insert(int key){
  H++;
  S[H] = -INF;
  increaseKey(H, key);
}

int main(){
  int key;
  char order[8];
  while(1){
    scanf(" %s", order);
    if(order[0] == 'e' && order[1] == 'n'){
      break;
    }
    if(order[0] == 'i'){
      scanf("%d", &key);
      insert(key);
    }else if(order[0] == 'e'){
      printf("%d\n", extractMax());
    }
  }
  return 0;
}



Measured memory_bytes: 5612
#include<iostream>

#define MAX 105
using namespace std;
int num[MAX]; 

int main( )
{
	int n;
	cin >> n;
	bool ok = true;
	for(int i = 0; i < n; i++){
		cin >> num[i];
		if(num[i]%2 == 0){
			if(num[i]%3 != 0 && num[i]%5 != 0){
				ok = false;
			}
		}
	}
	if(ok){
		cout << "APPROVED" << endl;
	}else{
		cout << "DENIED" << endl;
	}
}

 

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

ll n;
vector <ll> arr;
vector <ll> dp;

void init()
{
	for(int i = 0; i < dp.size(); i++)
	dp[i] = -1;
}

ll solve(ll i)
{
	if(dp[i] != -1)
	return dp[i];
	if(i <= 0)
	return dp[i] = 0;
	else if(i == 1)
	return dp[i] = abs(arr[1] - arr[0]);
	else
	{
		return dp[i] = min(solve(i - 1) + abs(arr[i] - arr[i - 1]), solve(i - 2) + abs(arr[i] - arr[i - 2]));
	}
}

int main()
{
	cin>>n;
	arr.resize(n);
	dp.resize(n);
	init();
	
	for(ll i = 0; i < n; i++)
		cin>>arr[i];
	cout<<solve(n - 1)<<"\n";
}

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

using namespace std;

#define pb push_back
#define mp make_pair
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int n;
int a[200];

int main() {
    scanf("%d", &n);
    n += n;
    REP(i, n) scanf("%d", a + i);
    sort(a, a + n);
    int ans = 0;
    for (int i = n - 2; i >= 0; i -= 2) {
        ans += a[i];
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

#define INF 1001000100010001000
#define MOD 1000000007
#define EPS 1e-10
#define int long long
#define rep(i, N) for (int i = 0; i < N; i++)
#define Rep(i, N) for (int i = 1; i < N; i++)
#define For(i, a, b) for (int i = (a); i < (b); i++)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define i_i pair<int, int>
#define vi vector<int>
#define vvi vector<vi >
#define vb vector<bool>
#define vvb vector<vb >
#define vp vector< i_i >
#define all(a) (a).begin(), (a).end()
#define Int(x) int x; cin >> x;
#define int2(x, y) Int(x); Int(y);
#define int3(x, y, z) Int(x); int2(y, z);
#define fir first
#define sec second
#define ffir first.first
#define fsec first.second
#define sfir second.first
#define ssec second.second

//int dxy[5] = {0, 1, 0, -1, 0};
// cmd

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

    Int(n);
    int a = 2, b = 1;

    if (n == 1) {
        std::cout << b << std::endl;
    } else {
        for (int i = 2; i <= n; i++) {
            int tmp = a + b;
            a = b; b = tmp;
        }
        std::cout << b << std::endl;
    }

    return 0;
}




Measured memory_bytes: 256
//Robs Code
#include<bits/stdc++.h>
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long int
#define fri(l,k) for (i=l;i<=k;i++)
#define frj(l,k) for (j=l;j>=k;j--)
#define all(x) x.begin(),x.end()
#define ed cout<<"\n";
#define pb push_back
#define pii pair<ll,ll>
#define _1 first
#define _2 second
#define maxi 100000007
/**********************************************************/
using namespace std;
ll i,j,k,n,m,q,t,a,b,cnt,sum,tot;
int main() 
{
    speed;
    cin>>n>>m;
    map<ll,ll> mp;
    for(i=0;i<n;i++){
        cin>>a;
        for(j=0;j<a;j++){
            cin>>b;
            mp[b]++;
        }
    }
    for(auto x : mp){
        if(x._2 == n){
            cnt++;
        }
    }
    cout<<cnt;
    return 0;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    var N = nextInt()
    var buf = StringBuilder()
    while (N != 0) {
        if (N % 2 != 0) {
            N -= 1
            buf.append("1")
        }
        else buf.append("0")
        N /= -2
    }
    val ans = if (buf.toString().length == 0) "0" else buf.toString().reversed()
    println(ans)
}

fun next() = readLine()!!
fun nextInt() = next().toInt()
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }


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

fn gcd(a: i64, b: i64) -> i64 {
    let mut a = a;
    let mut b = b;
    while b != 0 {
        let t = a % b;
        a = b;
        b = t;
    }
    a
}
fn main() {
    let (n, x) = get!(usize, i64);
    let v = get!([i64]);
    if x == 1 {
        println!("{}", v[0] - x);
        return;
    }
    let prev = (x - v[0]).abs();
    let mut ans = prev;
    for i in 1..n {
        let now = (v[i] - v[i - 1]).abs();
        ans = gcd(ans, now);
    }
    println!("{}", ans);
}


Measured memory_bytes: 8444
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;

int main() {
    int x;
    cin >> x;

    if(x < 1200) {
        cout << "ABC";
    }
    else {
        cout << "ARC";
    }
    
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
ll rand_int(ll l, ll r) //[l, r]
{
    static mt19937_64 gen(chrono::steady_clock::now().time_since_epoch().count());
    return uniform_int_distribution<ll>(l, r)(gen);
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
const int maxn=4e3+7;
const int mod=998244353;
ll C[maxn][maxn];
ll two[maxn];
void init()
{
    for(int i=0;i<maxn;i++)
    {
        C[i][0]=1;
        for(int j=1;j<=i;j++)
            C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
    }
    two[0]=1;
    for(int i=1;i<maxn;i++) two[i]=two[i-1]*2%mod;
}
inline ll bno(int n,int m)
{
    if(m>n||n<0||m<0) return 0;
    //dbg(n,m,C[n][m]);
    return C[n][m];
}
int main()
{
    init();
    int k,n;
    cin>>k>>n;
    for(int i=2;i<=2*k;i++)
    {
        ll ans=0;
        if(i&1)
        {
            int tc=(i-1)/2-max(0,i-k-1);
            for(int j=0;j<=tc;j++)
                ans=(ans+bno(tc,j)*bno(n+k-2*tc-1,k-2*tc+j-1)%mod*two[j]%mod)%mod;
        }
        else{
            int tc=(i-1)/2-max(0,i-k-1);
            //dbg(i,tc);
            for(int j=0;j<=tc;j++)
                ans=(ans+(bno(n+k-2*tc-2,k+j-2-2*tc)+bno(n-1+k-2*tc-2,k+j-2-2*tc))%mod*two[j]%mod*bno(tc,j)%mod)%mod;
        }
        print(ans);
    }
}

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

#define name ""
#define ini freopen(name".inp","r",stdin); freopen(name".out","w",stdout)
#define long long long
#define db double
#define pii pair <int, int>
#define pll pair <long, long>
#define all(c) c.begin(), c.end()
#define fastio ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
template <class T> inline void chmin(T &a, const T& val) { if (a > val) a = val; }
template <class T> inline void chmax(T &a, const T& val) { if (a < val) a = val; }
template <class T> long sqr(T a) { return 1ll * a * a; }
template <class T> void compress(T &a){
  sort(all(a)); a.resize(unique(all(a)) - a.begin());  
}

const db pi = acos(-1.00);
const db eps = 1e-6;
const int INF = 1e9;
const int MOD = 1e9+7;
const int dx[4] = {0, 0, -1, 1};
const int dy[4] = {-1, 1, 0, 0};

const int N = 1e7+1;
int cnt[N], n;

int main()
{
  fastio;
  cin >> n;
  for (int i = 1; i <= n; i++){
    for (int j = i; j <= n; j += i){
      cnt[j]++;
    }
  }
  long res = 0;
  for (int i = 1; i <= n; i++) res += 1ll * cnt[i] * i;
  cout << res;
  return 0;
}

Measured memory_bytes: 42644
abcd = input()

a = int(abcd[0])
b = int(abcd[1])
c = int(abcd[2])
d = int(abcd[3])

counter = 0
if a - b - c - d == 7 and counter == 0:
    print(str(a)+'-'+str(b)+'-'+str(c)+'-'+str(d)+'=7')
    counter += 1

if a - b - c + d == 7 and counter == 0:
    print(str(a)+'-'+str(b)+'-'+str(c)+'+'+str(d)+'=7')
    counter += 1

if a - b + c - d == 7 and counter == 0:
    print(str(a)+'-'+str(b)+'+'+str(c)+'-'+str(d)+'=7')
    counter += 1

if a - b + c + d == 7 and counter == 0:
    print(str(a)+'-'+str(b)+'+'+str(c)+'+'+str(d)+'=7')
    counter += 1

if a + b - c - d == 7 and counter == 0:
    print(str(a)+'+'+str(b)+'-'+str(c)+'-'+str(d)+'=7')
    counter += 1

if a + b - c + d == 7 and counter == 0:
    print(str(a)+'+'+str(b)+'-'+str(c)+'+'+str(d)+'=7')
    counter += 1

if a + b + c - d == 7 and counter == 0:
    print(str(a)+'+'+str(b)+'+'+str(c)+'-'+str(d)+'=7')
    counter += 1

if a + b + c + d == 7 and counter == 0:
    print(str(a)+'+'+str(b)+'+'+str(c)+'+'+str(d)+'=7')
    counter += 1

Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
const int maxn=100000+2;
char s[maxn],t[maxn];
int cs[2][maxn],ct[2][maxn];
int main(int argc,char *argv[]){
	if(argc>=2){freopen(argv[1],"r",stdin);}
	if(argc>=3){freopen(argv[2],"w",stdout);}
	scanf("%s%s",s+1,t+1);
	for(int i=1;s[i];++i){
		cs[0][i]=cs[0][i-1];
		cs[1][i]=cs[1][i-1];
		cs[s[i]-'A'][i]++;
	}
	for(int i=1;t[i];++i){
		ct[0][i]=ct[0][i-1];
		ct[1][i]=ct[1][i-1];
		ct[t[i]-'A'][i]++;
	}
	int q;scanf("%d",&q);
	while(q--){
		int a,b,c,d;
		scanf("%d%d%d%d",&a,&b,&c,&d);
		int csA=cs[0][b]-cs[0][a-1];
		int csB=cs[1][b]-cs[1][a-1];
		int ctA=ct[0][d]-ct[0][c-1];
		int ctB=ct[1][d]-ct[1][c-1];
		int dA=ctA-csA;dA%=3;dA+=3;dA%=3;
		int dB=ctB-csB;dB%=3;dB+=3;dB%=3;
		if(dA==dB)printf("YES\n");else printf("NO\n");
	}
	fclose(stdin);fclose(stdout);
	return 0;
}


Measured memory_bytes: 2304
#include<functional>
#include<algorithm>
#include<iostream>
#include<utility>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
#define pb push_back
#define pf push_front
#define int long long
using namespace std;
const int INF=1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


signed main(){
  int n;
  cin>>n;
  cout<<"ABC"<<n<<endl;

  return 0;
}




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

#define _CRT_SECURE_NO_WARNINGS
#define TLong long long 

// fact(n)
int fact(int n){
	if(n == 1)	return 1;
	else return (n * fact(n - 1));
}

// combination(n,r)
int combination(int n, int r){
	if(r == 0 || r == n)	return 1;
	else if(r == 1)	return n;
	return (combination(n - 1, r - 1) + combination(n - 1, r));
}

TLong gcd(TLong a,TLong b){
	if(!(a % b)) return b;
	return gcd(b,a % b);
}

// lcm(a.b)
int lcm(int a,int b){
	return (a * b) / gcd(a,b);
}

// qsort(array, size, sizeof(int),comp);
int comp(const int *a,const int *b){
	return (*a - *b);
}

// append(array,*size,addNum)
void append(int *array,int *size,int num){
	realloc(array, sizeof(int) * (*size + 1));
	array[(*size)] = num;
	++(*size);
}

// pop(array,*size) & nongetpop(array,*size)
int pop(int *array,int *size){
	int temp = array[(*size - 1)];
	realloc(array,sizeof(int) * (*size - 1));
	--(*size);
	return temp;
}

void nongetpop(int *array,int *size){
	realloc(array,sizeof(int) * (*size - 1));
	--(*size);
}

int main(int argc, char const *argv[]){
	int n;
	TLong ans,t;
 
	scanf("%d %lld",&n,&ans);
	for(int i = 0; i < n - 1; ++i){
		scanf(" %lld",&t);
		ans = ans / gcd(ans,t) * t;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 128
//おまじない
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#define INF 1e9+7
#define roop(i,m,n) for(int i=m;i<n;i++)
#define mroop(i,m,n) for(int i=m;i<n;i--)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
using namespace std;
typedef long long int ll;

//(int)'a'は97 (int)'A'は65
//おまじない



int main() {
	
	int x, y;
	cin >> x >> y;
	int count = 0;
	int a[] = { 1,3,5,7,8,10,12 };
	int b[] = { 4 ,6, 9, 11 };
	int c[] = { 2 };

	roop(i, 0, 7) {
		if (x == a[i]) {
			count++;
		}
		else if (y == a[i]) {
			count++;
		}
	}

	if (count == 2) {
		Yes; return 0;
	}
	else if (count == 1) {
		No; return 0;
	}

	roop(i, 0, 4) {
		if (x == b[i]) {
			count++;
		}
		else if (y == b[i]) {
			count++;
		}
	}

	if (count == 2) {
		Yes; return 0;
	}
	else if (count == 1) {
		No; return 0;
	}

	if (x == y&&x==2) {
		Yes;
	}

	return 0;
}


Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)

	if a == b && b == c {
		fmt.Println("No")
	} else if a == b || b == c || c == a {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <complex>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
#include <limits>
#include <time.h>
#include <cstdint>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(ll i=n-1;i>=0;i--)
#define rRep(i,a,b) for(ll i=b-1;i>=a;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
//constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}



int main(){
  ld A,B,H,M;
  cin >> A >> B >> H >> M;
  ld pi = 2.0 * asin(1.0); 
  ld K=abs(M/60-(H*60+M)/720);
  ld dis=2*pi*min(K,2*pi-K);
  ld X=cos(dis);
  cout << stpr(15) << sqrt(A*A+B*B-2*A*B*X) << endl;
}

Measured memory_bytes: 4140
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1000000000;
const double EPS = 1e-8;
const double PI = 3.14159;
//int dx[4]={-1, 0, 1, 0}, dy[4]={0, -1, 0, 1};
using namespace std;
//typedef pair<int, int> P;

/** Problem1046 : Ghost Buster! **/
int dx[]={-1, 0, 1, 0, 0}, dy[]={0, -1, 0, 1, 0};

int W, H;
string s;

struct P {
	int x, y;
	P(){}
	P(int _x, int _y) : x(_x), y(_y) {}
};

struct S {
	P p;
	int time;
	S(){}
	S(P _p, int _time) : p(_p), time(_time) {}
};

typedef pair<S, S> SS;

int main()
{
	
	while (cin>>H>>W, W||H) {
		char field[20][20];
		
		S A, B;
		
		rep(i, H) rep(j, W) {
			cin>>field[i][j];
			if (field[i][j] == 'A')
				A = S(P(j, i), 0);
			else if (field[i][j] == 'B')
				B = S(P(j, i), 0);
		}
		cin>>s;
		int N = (int)s.size();
		
		queue<SS> Q;
		bool vis[H][W][H][W][10];
		memset(vis, 0, sizeof(vis));
		
		Q.push(SS(A, B));
		vis[A.p.y][A.p.x][B.p.y][B.p.x][0] = true;
		
		while (Q.size()) {
			SS ss = Q.front(); Q.pop();
			S a = ss.first, b = ss.second;

			//cerr << "(" << a.p.x << ", " << a.p.y << ")" << " ";
			//cerr << "(" << b.p.x << ", " << b.p.y << ")" << " " << a.time << endl;
			
			if (a.p.x == b.p.x && a.p.y == b.p.y) {
				cout << a.time << " " << a.p.y << " " << a.p.x << endl;
				goto end;
			}
						
			// Move Ghost
			if (s[b.time%N] == '8' && b.p.y>0)
				b.p.y--;
			else if (s[b.time%N] == '6' && b.p.x<W-1)
				b.p.x++;
			else if (s[b.time%N] == '4' && b.p.x>0)
				b.p.x--;
			else if (s[b.time%N] == '2' && b.p.y<H-1)
				b.p.y++;
			b.time++;
			
			// Move Girl
			a.time++;
			rep(i, 5) {
				int nx = a.p.x + dx[i], ny = a.p.y + dy[i];
				if_range(nx, ny, W, H) {
					if (!vis[ny][nx][b.p.y][b.p.x][a.time%N] && field[ny][nx] != '#') {
						Q.push(SS(S(P(nx, ny), a.time), b));
						vis[ny][nx][b.p.y][b.p.x][a.time%N] = true;
					}
				}
			}
			
			if (!vis[a.p.y][a.p.x][b.p.y][b.p.x][b.time%N]) {
				Q.push(SS(a, b));
				vis[a.p.y][a.p.x][b.p.y][b.p.x][b.time%N] = true;
			}
		}
		cout << "impossible" << endl;
	end:;
	}
}

Measured memory_bytes: 2804
X = int(input())
E = [1] * (2 * X)
for i, e in enumerate(E):
  if i < 2:
    continue
  if e < 1:
    continue
  for j in range(2 * i, 2 * X, i):
    E[j] = 0
for i, e in enumerate(E):
  if i < X:
    continue
  if e < 1:
    continue
  print(i)
  break


Measured memory_bytes: 4596
#pragma GCC optimize ("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
using namespace std;
using Int = long long;
typedef pair<int,int> P; typedef pair<Int,Int> Pl;
static const int mod = 1e9+7;
#define END {cout<<ans<<'\n'; return 0;}
#define ALL(v) (v).begin(),(v).end()
#define Pr(t) priority_queue<t>
#define gPr(t) priority_queue<t,vector<t>,greater<t>>
#define V(t) vector<t>
#define rep(i,n) for(int i=0; i<n; i++)
#define rer(i,l,r) for(int i=l; i<=r; i++)
#define gnr(i,l,r) for(int i=r; i>=l; i--)
#define eb emplace_back
#define pri1(a) cout<<(a)<<'\n'
#define pri2(a,n) rep(i,n-1)cout<<a[i]<<' '; cout<<a[n-1]<<'\n'
#define prip(p) cout<<p.first<<' '<<p.second<<'\n'
template<class T> inline bool cmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool cmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n,m,_,x,y,q;
string s,sb;
bool ok;
char ch;



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

  cin>>n>>m; V(int)g[n]; int h[n]={}; bool ed[n][n]={};
	rep(i,m){
		cin>>x>>y;
		g[--x].eb(--y); h[y]++;
		ed[x][y]=1;
	}
	V(int)to; stack<int>st;
	rep(i,n)if(!h[i])st.push(i);
	while(!st.empty()){
		q=st.top(); st.pop();
		for(int v:g[q]){
			h[v]--;
			if(!h[v])st.push(v);
		}
		to.eb(q);
	}
	rep(i,n)pri1(to[i]+1);
	rep(i,n-1){
		if(!ed[to[i]][to[i+1]]){pri1(1); return 0;}
	}
	pri1(0);
}


Measured memory_bytes: 28216
/*
author: Apoorv Singh
*/

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

typedef vector <int> vi;
typedef vector <long long> vl;
typedef pair <int, int> pii;
typedef pair <long long, long long> pll;
#define ll long long
#define pb push_back   
#define all(c) c.begin(), c.end()
#define watch(x) cout << (#x) << " " << (x) << endl;
#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 um unordered_map
#define F first
#define S second

ll modulo = 1e9 + 7;

template <class X>

void printarr(X arr[], int n)
{
    for (int i = 0; i < n; ++i)
        cout << arr[i] << " ";
    cout << endl;
}

ll fpow(ll a, ll n)
{
    ll ans = 1;
    while (n)
    {
        if (n&1)
            ans = (ans * a)%modulo;
        a = (a*a)%modulo;
        n = n >> 1;
    }
    return ans;
}

/*
const int M = 1e6 + 10;
int composite[M] = {0};

void sieve()
{
    FOR(i,2,M)
    {
        if (!composite[i])
        {
            for (int j = 2*i; j < M; j += i)
                composite[j] = max(composite[j], i);
        }
    }
}
*/

ll black, white;
int h, w;
const int M = 410;
int arr[M][M], visited[M][M], x[] = {1,-1,0,0}, y[] = {0,0,-1,1};

void dfs(int i, int j)
{
	if (arr[i][j] == 1)
		++white;
	else 
		++black;
	visited[i][j] = 1;
	FOR(k,0,4)
	{
		int p1 = i + x[k], p2 = j + y[k];
		if ((p1 >= 0 and p1 < h) and (p2 >= 0 and p2 < w))
		{
			if (!visited[p1][p2] and ((arr[p1][p2] == 1 and arr[i][j] == 0) or (arr[p1][p2] == 0 and arr[i][j] == 1)))
				dfs(p1,p2);
		}

	}
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> h >> w;
    FOR(i,0,h)
    {
    	string s;
    	cin >> s;
    	FOR(j,0,w)
    	{
    		if (s[j] == '#')
    			arr[i][j] = 0;
    		else
    			arr[i][j] = 1;
    	}
    }
    ll ans = 0;
    FOR(i,0,h)
    {
    	FOR(j,0,w)
    	{
    		if (arr[i][j] == 1 or visited[i][j] == 1)
    			continue;
    		black = 0; white = 0;
    		dfs(i,j);
    		ans += black*white;
    	}
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define all(x) x.begin(),x.end()
#define pll  pair <long long,long long>
#define ss second
#define ff first
#define inf 9223372036854775807
#define maa 1000000007
#define ld long double
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);
#define bug(x) cout << #x <<": " << x << '\n';
const ll N=51 ;
int main()
{
   fast ;
   ll ans=INT_MAX ;
   ll n,m ; cin>>n>>m ;
   ll st[m],c[m] ;
   for(ll i=0;i<m;i++) cin>>st[i]>>c[i] ;


   for(ll i=0;i<1000;i++){
    string s=to_string(i) ;
    if(s.length()!=n) continue ;

     ll f=1 ;
     for(ll j=0;j<m;j++){
        if(s[st[j]-1]-'0'!=c[j]) f=0 ;
     }
     if(f==1)
     {
         ans=min(ans,i) ;
     }

   }
   if(ans!=INT_MAX)
   cout<<ans ;
   else cout<<"-1" ;

}




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

int max(int a,int b){
  if(a>b) return a;
  else return b;
}
int absolute(int a,int b){
  if(a-b<0) return -(a-b);
  else return a-b;
}
void Yes(){
  cout << "Yes" << endl;
}
void YES(){
  cout << "YES" << endl;
}
void No(){
  cout << "No" << endl;
}
void NO(){
  cout << "NO" << endl;
}
int main(){
  int A,B;
  char c;
  cin >> A >> c >> B;
  
  if(c == '+') cout << A+B << endl;
  else cout << A-B << endl;
}

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_0 = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//以降 cin の入力元が 'input.txt' になる
//std::ifstream in("input.txt");
//std::cin.rdbuf(in.rdbuf());

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    UnionFind(int N) : par(N),siz(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++){
             par[i] = i;
             siz[i] = 1;
        }
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        // merge technique（小を大にくっつける）
        if (siz[rx] < siz[ry]) swap(rx, ry);
        siz[rx] += siz[ry];
        par[ry] = rx;
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }

    ll size(ll x){
        return siz[root(x)];
    }
};

signed main()
{   
    gearup;
    ll n,k,l; cin >> n >> k >> l;
    UnionFind uf1(n),uf2(n);
    rep(i,k){
        int a,b;cin>> a >> b;
        a--;b--;
        uf1.unite(a,b);
    }
    rep(i,l){
        int a,b; cin >> a >> b;
        a--;b--;
        uf2.unite(a,b);
    }
    map<pair<int,int>, int> p;
    rep(i,n){
        int u = uf1.root(i);
        int v = uf2.root(i);
        p[{u,v}]++;
    }
    rep(i,n){
        int u = uf1.root(i);
        int v = uf2.root(i);
        cout << p[{u,v}] << endl;
    }
}



Measured memory_bytes: 19200
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define mp make_pair
using namespace std;
int a,b,c;
int main(){
    cin >> a >> b >> c;
    cout << c - min(a-b,c) << "\n";
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<queue>
#include<list>
#include<stack>
#include<algorithm>
#include<cmath>
#include<memory>
#include<array>

using namespace std;


bool isStraight( const array<int,5>& cs )
{
  if ( cs[0] == 1 && cs[1] == 10 && cs[2] == 11 && cs[3] == 12 && cs[4] == 13 )
    return true;
  
  for ( auto i = 0; i < 4; ++i )
    {
      if ( cs[i] + 1 != cs[i+1] )
        return false;
    }

  return true;
}

bool isOnePair( const array<int,5>& cs )
{
  for ( auto i = 0; i < 4; ++i )
    {
      if ( cs[i] == cs[i+1] )
        return true;
    }

  return false;
}

bool isTwoPair( const array<int,5>& cs )
{
  for ( auto i = 0; i < 2; ++i )
    {
      for ( auto j = i + 2; j < 4; ++j )
        {
          if ( cs[i] == cs[i+1] && cs[j] == cs[j+1] )
            return true;
        }
    }

  return false;
}

bool isThreeCard( const array<int,5>& cs )
{
  for ( auto i = 0; i < 3; ++i )
    {
      if ( cs[i] == cs[i+1] && cs[i+1] == cs[i+2] )
        return true;
    }

  return false;
}

int main()
{
  array<int,5> card;
  char c;

  while ( cin >> card[0] >> c >> card[1] >> c >> card[2] >> c >> card[3] >> c >> card[4] )
    {
      sort( card.begin(), card.end() );
      
      if ( card[0] == card[1] && card[1] == card[2] && card[2] == card[3] )
        cout << "four card" << endl;
      else if ( card[1] == card[2] && card[2] == card[3] && card[3] == card[4] )
        cout << "four card" << endl;
      else if ( card[0] == card[1] && card[1] == card[2] && card[3] == card[4] )
        cout << "full house" << endl;
      else if ( card[0] == card[1] && card[2] == card[3] && card[3] == card[4] )
        cout << "full house" << endl;
      else if ( isStraight( card ) )
        cout << "straight" << endl;
      else if ( isThreeCard( card ) )
        cout << "three card" << endl;
      else if ( isTwoPair( card ) )
        cout << "two pair" << endl;
      else if ( isOnePair( card ) )
        cout << "one pair" << endl;
      else
        cout << "null" << endl;
    }
  
  return 0;
}

Measured memory_bytes: 1172
#include<iostream>
#include<vector>
using namespace std;
int main()
{
  int n;
  cin>>n;
  
  long long *hi=new long long[n];
  for(int i=0;i<n;i++)
    cin>>hi[i];
  
  int flag=0;
  for(int i=n-2;i>=0;i--)
  {
    if(hi[i]>hi[i+1])
    {
      if(hi[i]==hi[i+1]+1)
      {
  		hi[i]=hi[i]-1;      
      }
      else
      {
        flag=1;
        break;
      }
    }
  }
  if(flag)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
  return 0;
}

Measured memory_bytes: 1024
N,M,X,Y = map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))

mx = max(x)
my = min(y)

if my - mx > 0:
    Z = mx
    for i in range(my - mx):
        Z += 1
        if X < Z and Z <= Y and mx < Z and Z <= my:
            print("No War")
            exit()
print("War")


Measured memory_bytes: 3064
#include<stdio.h>

int main(void){
  char A,B;
  scanf("%c %c",&A,&B);
  if((int)A==(int)B){
    printf("=\n");
  }else if((int)A>(int)B){
    printf(">\n");
  }else{
    printf("<\n");
  }
  return 0;
}

Measured memory_bytes: 128
// https://atcoder.jp/contests/abc173/tasks/abc173_d

use proconio::input;

fn main() {
    input! {
        n: usize,
        mut a_s: [u64; n],
    }
    a_s.sort_unstable_by(|a, b| b.cmp(a));
    let mut sum: u64 = a_s[1..n / 2].iter().map(|&a| a * 2).sum();
    sum += a_s[0];
    if n % 2 != 0 {
        sum += a_s[n / 2];
    }
    println!("{}", sum);
}


Measured memory_bytes: 5576
#include<bits/stdc++.h>
using namespace std; 
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
#define ll long long
#define pb push_back
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define rep2(i,a,b) for(int i=a;i>=b;i--)
void pf(string s)
{
	rep2(i,s.length()-1,0)
	{cout<<s[i];
	}
}
int main(int argc, char** argv) {
	
	string s,bf,ed;
	cin>>s;
	int q;
	cin>>q;
	int fg=0;
	while(q--)
	{
		int op;
		scanf("%d",&op);
		if(op==1)
		{
			fg^=1;
		}
		else
		{
			int p;
			char c;
			scanf("%d",&p);
			cin>>c;
			if((p-1)^fg==0)
			{
				bf+=c;
			}
			else
			{
				ed+=c;
			}
		}
	}
	if(!fg)
	{
		pf(bf);
		cout<<s<<ed;
	}
	else {
		pf(ed);
		pf(s);
		cout<<bf;
	}
	return 0;
}

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

using namespace std;

void rwFile() {
    freopen("INP.inp", "r", stdin);
    freopen("OUT.out", "w", stdout);
}

void solveA() {
    int k, x;
    cin >> k >> x;
    if (k * 500 >= x) cout << "Yes";
    else cout << "No";
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr); cout.tie(nullptr);
    ///rwFile();
    solveA();
}


Measured memory_bytes: 256
N, M = map(int, input().split())
D = []
for i in range(N):
    t, v = map(int, input().split())
    D.append((t, v))

D.sort(key=lambda x:x[0])

DP = [[0 for j in range(M)] for i in range(N + 1)]

for i in range(1, N + 1):
    for j in range(1, M):
        if j - D[i - 1][0] >= 0:
            DP[i][j] = max(DP[i - 1][j], DP[i - 1][j - D[i - 1][0]] + D[i - 1][1])
        else:
            DP[i][j] = DP[i - 1][j]
mv = 0
for l in range(N): #ラストオーダー
    mv = max(DP[l][M - 1] + D[l][1], mv)

print(mv)





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

#define LL long long


//128
int main() {
	LL N, M;

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

	unsigned int relation[11]; //index->switch No.
	memset(relation, 0, sizeof(relation));

	for (int i = 1; i <= M; i++) {
		LL k;
		scanf("%lld", &k);

		for (int j = 1; j <= k; j++) {
			unsigned int s;
			scanf("%d", &s);

			relation[s] |= (1 << (i - 1));
		}
	}

	unsigned int P = 0;
	for (int i = 1; i <= M; i++) {
		unsigned p;
		scanf("%d", &p);

		if (p > 0) {
			P |= (1 << (i - 1));
		}
	}

	LL result = 0;

	for (unsigned int pattern = 0; pattern < (unsigned int)pow(2, N); pattern++) {
		unsigned int on_off = 0; //bit��0�Ȃ�_��

		for (int i = 1; i <= N; i++) {
			if (((1 << (i - 1)) & pattern) != 0) {
				on_off ^= relation[i];
			}
		}

		on_off ^= P;

		if (on_off == 0) {
			result++;
		}
	}

	printf("%lld\n", result);

}


//127
/*
int main() {
	LL N, M;

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

	LL pass_count[100010];
	memset(pass_count, 0, sizeof(pass_count));

	for (int i = 1; i <= M; i++) {
		LL L, R;

		scanf("%lld %lld", &L, &R);

		pass_count[L]++;
		pass_count[R + 1]--;
	}

	LL result = 0;
	for (int i = 1; i <= N; i++) {
		pass_count[i] += pass_count[i - 1];
		if (pass_count[i] == M) {
			result++;
		}
	}

	printf("%lld\n", result);

	return 0;
}
*/


//126
/*
int main() {
	LL N, K;

	cin >> N >> K;

	static double dp[200100];
	memset(dp, 0, sizeof(dp));

	for (int i = 1; i <= N; i++) {
		dp[i] = 1.0 / (double)N;
	}

	for (LL i = 1; i < K; i++) {
		dp[i * 2] += dp[i] * 0.5;
	}

	double result = 0;

	for (LL i = K; i < 200100; i++) {
		result += dp[i];
	}

	printf("%0.11f\n", result);

	return 0;
}
*/

Measured memory_bytes: 384
#include <stdlib.h>
#include <iostream>
using namespace std;

void insertion_sort(int *array, int currentNum);
void print_array(int *array, int size);
int main(){
	int n;

	cin >> n;

	int* array = (int*)malloc(n * sizeof(int));

	if(n < 1){
		return 0;
	}

	for(int i = 0; i < n; i++){
		cin >> array[i];
	}
	for(int i = 0; i < n; i++){
		insertion_sort(array, i);
		print_array(array, n);
	}
	return 0;
}

void insertion_sort(int *array, int currentNum){
	for(int i = 0; i < currentNum; i++){
		if(array[i] > array[currentNum]){
			swap(array[i], array[currentNum]);
		}
	}
}

void print_array(int *array, int size){
	for(int i = 0; i < size; i++){
		cout <<  array[i];
		if(i != size - 1){
		cout << " " ;
		}
	}
	cout << endl;
}

Measured memory_bytes: 1188
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
using namespace std;
#define INF 2000000007
#define LINF 100000000000000007
#define MOD 1000000007
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repb(i, n) for (int i = n - 1; i >= 0; i--)
#define MODE 0
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define ARDEB(i,X) cout<< #X <<"["<<i<<"]: "<<X[i]<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define ARDEB(i,X) {}
#define END {}
#endif
typedef long long ll;
typedef pair<int,int> P;
struct edge{int to,cost;};
int ceil2(int a,int b){if(a%b){return a/b+1;}else{return a/b;}}
using namespace std;

int n,ans;
string s;
int extra[211111];
signed main(){
	cin>>s;
	reverse(s.begin(),s.end());
	int now=0,te=1;
	rep(i,s.size()){
		now=(s[i]-'0')*te+now;
		now%=2019;
		//cout<<s[i];
		extra[i]=now;
		te*=10;
		te%=2019;
	}
	//rep(i,s.size())cout<<i+1<<":"<<extra[i]<<endl;
	int cnt[2300]={0};
	cnt[0]++;
	rep(i,s.size()){
		cnt[extra[i]]++;
	}
	for(int i=0;i<=2019;i++){
		ans+=cnt[i]*(cnt[i]-1)/2;
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 5304