akhauriyash/Code-Regression huggingface dataset:
int parse(char *p){
  int r=0,i=1;
  for(;*p;p++){
    if(isdigit(*p)){i=*p-'0';continue;}
    switch(*p){
      case 'm':r+=i*1000;break;
      case 'c':r+=i*100;break;
      case 'x':r+=i*10;break;
      case 'i':r+=i;break;
    }
    i=1;
  }
  return r;
}

void output(int n){
  int i,x;
  if(x=n/1000){
    if(x>1)printf("%d",x);
    printf("m");
  }
  if(x=n/100%10){
    if(x>1)printf("%d",x);
    printf("c");
  }
  if(x=n/10%10){
    if(x>1)printf("%d",x);
    printf("x");
  }
  if(x=n%10){
    if(x>1)printf("%d",x);
    printf("i");
  }
  puts("");
}

int main(n){
  char p[9],q[9];
  scanf("%d",&n);
  for(;n;n--){
    scanf("%s%s",p,q);
    output(parse(p)+parse(q));
  }
  return 0;
}

Measured memory_bytes: 616
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]


def eratosthenes(n):
    sieve = [True for _ in range(n + 1)]
    sieve[0] = False
    sieve[1] = False

    def _update(p):
        if sieve[p]:
            for i in range(p * 2, n + 1, p):
                sieve[i] = False

    if n > 1:
        _update(2)
    p = 3
    while p * p <= n:
        _update(p)
        p += 2
    return sieve


x = ri()

sieve = eratosthenes(10**6)
for i in range(x, 10**6):
    if sieve[i]:
        print(i)
        exit()

Measured memory_bytes: 11032
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let mut s: String = read();
    let n: usize = read();
    let mut tmp_s: String = "".to_string();

    let mut reversed = false;

    for _ in 0..n {
        let t: usize = read();
        if t == 1 {
            reversed = !reversed;
            if tmp_s.len() > 0 {
                s = format!("{}{}", tmp_s.chars().rev().collect::<String>(), s);
                tmp_s = "".to_string();
            }
        } else {
            let f: usize = read();
            let c: String = read();
            if f == 1 {
                if reversed {
                    s.push_str(&c);
                } else {
                    tmp_s.push_str(&c);
                }
            } else {
                if reversed {
                    tmp_s.push_str(&c);
                } else {
                    s.push_str(&c);
                }
            }
        }
    }
    if tmp_s.len() > 0 {
        s = format!("{}{}", tmp_s.chars().rev().collect::<String>(), s);
    }
    if reversed {
        s = s.chars().rev().collect::<String>();
    }

    println!("{}", s);
}


Measured memory_bytes: 4604
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
#define double long double
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
typedef pair<lint, lint> pll;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

int main(){
    int n, m;
    scanf("%d", &n);
    map<string, deque<int>> mp;
    rep(i, n){
        string c; int d;
        cin >> c >> d;
        mp[c].push_back(d);
    }
    for(auto &p: mp) sort(p.se.begin(), p.se.end());

    int tmp = 0;
    scanf("%d", &m);
    rep(_, m){
        string s;
        cin >> s;
        auto &dq = mp[s];
        while(!dq.empty() && dq.front() <= tmp) dq.pop_front();
        if(dq.empty()){
            puts("No");
            return 0;
        }
        tmp = dq.front();
        dq.pop_front();
    }
    puts("Yes");
}


Measured memory_bytes: 82936
N, A, B = map(int, input().split())
Ss = input()

anss = ['No'] * N
numA = numB = 0
for i, S in enumerate(Ss):
    if S == 'a':
        if numA + numB < A + B:
            anss[i] = 'Yes'
            numA += 1
    elif S == 'b':
        if numA + numB < A + B and numB < B:
            anss[i] = 'Yes'
            numB += 1

print('\n'.join(anss))


Measured memory_bytes: 5108
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    n = int(input())
    ans = {'AC':0, 'WA':0, 'TLE':0, 'RE':0,}
    for i in range(n):
        s = input()
        ans[s] += 1
    print('AC x ' + str(ans['AC']))
    print('WA x ' + str(ans['WA']))
    print('TLE x ' + str(ans['TLE']))
    print('RE x ' + str(ans['RE']))
if __name__ == '__main__':
    main()


Measured memory_bytes: 68004
#include <bits/stdc++.h>
using namespace std;
 
int main(void){
 int A,B;
  cin >> A >> B;
  if(A==1){
    if(B==2){
      cout << "3" <<endl;
    }else{
      cout << "2" <<endl;
    }
  }else if(A==2){
      if(B==1){
      cout << "3" <<endl;
    }else{
      cout << "1" <<endl;
    }
  }else{
    if(B==2){
      cout << "1" <<endl;
    }else{
      cout << "2" <<endl;
    }
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <map>
#include<cmath>
#include <queue>
#include <numeric>

using lli = long long int;
int inf = 1000000007;
using namespace std;
int NextInt() { int x; cin >> x; return x; }
#define sort(X) sort(X.begin(),X.end())

int N, Q;

int main()
{
	cin >> N >> Q;
	vector<vector<int>> event;
	for (int i = 0; i < N; i++) {
		int s, t, x;
		cin >> s >> t >> x;
		vector<int> e0 = { s - x,1,x };
		vector<int> e1 = { t - x,0,x };
		event.push_back(e0);
		event.push_back(e1);
	}
	sort(event);
	set<int> s;
	auto it = event.begin();
	for (int i = 0; i < Q; i++) {
		int d = NextInt();
		while (it != event.end() && (*it)[0] <= d) {
			auto e = (*it);
			if (e[1] == 1)s.insert(e[2]);
			else if (e[1] == 0)s.erase(e[2]);
			it++;
		}
		if (s.size() == 0)cout << -1 << endl;
		else cout << *s.begin() << endl;

	}
	return 0;
}

Measured memory_bytes: 34216
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

#define f(i, q) for(int i = 0; i < q; i++)  

typedef long long ll;

// 昇順にソート
int asc_comp(const void* a, const void* b){
    ll x = *(ll*)a;
    ll y = *(ll*)b;
    return x - y;
}
// 降順にソート
int dec_comp(const void* a, const void* b){
    ll x = *(ll*)a;
    ll y = *(ll*)b;
    return y - x;
}

int main() {
    ll i, ans = 0;
    // qsort(in, a, sizeof(ll), dec_comp);
    scanf("%lld", &i);
    ans += i;
    ans += i * i;
    ans += i * i* i;

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


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

int main() {
  long X;
  cin >> X;
  long N = 1001, v = -501;
  vector<long> V(N);
  for (long i = 0; i < N; i++) {
    V.at(i) = ++v;
  }
  for (long i = 0; i < N; i++) {
    for (long j = 0; j < N; j++) {
      if (pow(V.at(i), 5) - pow(V.at(j), 5) == X) {
        return cout << V.at(i) << " " << V.at(j) << "\n", 0;
      }
    }
  }
}

Measured memory_bytes: 3992
#include <bits/stdc++.h>
#pragma once
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef long double lb;
#define int long long
#define double long double
#define endn "\n"
typedef pair<int,int> P;
const int MOD = 1000000007;
const ll INF = 1e16;
const double EPS = 1e-10;
const double PI = 3.141592653589793;
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b;return 1;}return 0;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b;return 1;}return 0;}
const pair<int,int> fd[] = {make_pair(1,0),make_pair(-1,0),make_pair(0,1),make_pair(0,-1)}; 


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


signed main(){
  string s;cin>>s;bool b = true;
  int n = s.length();
  reverse(s.begin(), s.end());
  rep(i,n){
    if(s.substr(i,5) == "esare" || s.substr(i,5) == "maerd"){
      i += 4;
    }else if(s.substr(i,6) == "resare"){
      i += 5;
    }else if(s.substr(i,7) == "remaerd"){
      i += 6;
    }else{
      b = false;break;
    }
  }
  cout << (b ? "YES" : "NO") << endl;
}


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

using namespace std; 
// Function to find the number of divisors 
// of all numbers in the range [1, n] 

void findDivisors(long long int n) 
{ 

  

    // Array to store the count 

    // of divisors 

    long long int div[n + 1]; 

    memset(div, 0, sizeof div); 

  

    // For every number from 1 to n 

    for (long long int i = 1; i <= n; i++) { 

  

        // Increase divisors count for 

        // every number divisible by i 

        for (long long int j = 1; j * i <= n; j++) 

            div[i * j]++; 

    } 

  long long int ans=0;

    // Print the divisors 

    for (long long int i = 1; i <= n; i++) 

        ans+=i*(div[i]) ;
     cout<<ans; 
} 


  
// Driver code 

int main() 
{ 
   long long int n; 
    cin>>n; 

    findDivisors(n); 

  

    return 0; 
} 


Measured memory_bytes: 81692
#include<cmath>
#include<cctype>
#include<cstdlib>
#include<cstdio>
#include<climits>
#include<iostream>
#include<algorithm>
#include<vector>
#include<deque>
#include<string>
#include<queue>
#include<map>
#include<set>
#include<utility>
#include<queue>

using namespace std;

char moji(char x,int n){
  //x を nかい押したときに入力された時の文字
  if(x == '1'){
    switch ((n-1)%5){
    case 0:return '.';
    case 1:return ',';
    case 2:return '!';
    case 3:return '?';
    case 4:return ' ';
    }
  }
  if(x == '2')return 'a' + (n-1)%3;
  if(x == '3')return 'd' + (n-1)%3;
  if(x == '4')return 'g' + (n-1)%3;
  if(x == '5')return 'j' + (n-1)%3;
  if(x == '6')return 'm' + (n-1)%3;
  if(x == '7')return 'p' + (n-1)%4;
  if(x == '8')return 't' + (n-1)%3;
  if(x == '9')return 'w' + (n-1)%4;
  cout<< "error:" << x << ','<< n << endl;
  return -1;
}

string solve(const string &input){
  string output = "";
  int prev = input[0];//直前の入力
  int count = 0;//連続して入力された回数

  for(size_t i = 0;i < input.size();i++){
    const char &cur = input[i];

    if(cur == '0'){
      if(prev != '0')
	output.append(1, moji(prev,count));
      if(i < input.size()-1)prev = input[i+1];
      count = 0;
    }else if(cur == prev){
      //
      count++;
    }else{
      //入力が直前と異なる
      prev = cur;
      output.append(1, moji(cur,count));
      count = 0;
    }
  }
  return output;
}


int main(){
  ios::sync_with_stdio(false);
  int x;
  cin >> x; 
  for(int i = 0;i < x; ++i){
    string input;
    cin.ignore();
    cin >> input;
    //cin.ignore();
    cout << solve(input) << endl;
  }

  return 0;
}

Measured memory_bytes: 1216
s=input()


from collections import Counter

c=Counter(s)
if len(list(c.keys()))==1:
    print(0)
    exit(0)


cnt=101
targets=list(c.keys())

for t in targets:
    tmp_cnt=0
    prev=s
    minus=1
    while True:
        tmp=''
        tmp_cnt+=1
        for i in range(len(s)-minus):
            if prev[i]==t or prev[i+1]==t:
                tmp+=t
            else:
                tmp+=prev[i]

        tmp_c=Counter(tmp)
        if len(list(tmp_c.keys()))==1:
            break
        else:
            minus+=1
            prev=tmp

    cnt=min(cnt,tmp_cnt)

print(cnt)

Measured memory_bytes: 9264
fn main() {
    let mut input = String::new();
    std::io::stdin().read_line(&mut input).expect("Error input");
    let total: u32 = input.trim().parse().expect("Not a number");
    let mut dict = std::collections::HashMap::<String, bool>::new();
    for _ in 0..total {
        input = String::new();
        std::io::stdin().read_line(&mut input).expect("Error input");
        let v: Vec<&str> = input.trim().split_whitespace().collect();
        let (query, key): (&str, &str) = (v[0], v[1]);
        match query {
            "insert" => {
                dict.insert(key.to_string(), true);
            }
            "find" => {
                println!(
                    "{}",
                    match dict.contains_key(key) {
                        true => "yes",
                        false => "no",
                    }
                );
            }
            &_ => panic!("ERROR"),
        };
    }
}



Measured memory_bytes: 37364
/*
Author: Racer5x
 ***************************************   UNAUTHORISED COPYING OF CODE PROHIBITED   **********************************
*/
 
// #pragma GCC optimize("O3")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
#include<bits/stdc++.h>
#define int         long long
#define double      long double
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
#define x           first
#define y           second
#define endl        '\n'
#define hell        998244353 
#define PI          3.141592653589
#define tezz        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MAX         2000000000000000000
#define M           1000000007
using namespace std;
 
signed main()
{
    tezz
    
    string s;
    cin>>s;

    if(s[0] == s[1] && s[1] == s[2] && s[1] == 'R') cout<<3;
    else if((s[0] == s[1] || s[1] == s[2]) && s[1] == 'R') cout<<2;
    else if(s[0] == 'R' || s[1] == 'R' || s[2] == 'R') cout<<1;
    else cout<<0;
} 

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

int main() {
	// your code goes here
	int n;
	cin>>n;
	vector<int> order;
	vector<int> satis;
	vector<int> nextsatis;
	//int satis[n={0};
	//int nextsatis[n]={0};
	for(int x=0;x<n;x++)
	{
		int f;
		cin>>f;
		order.push_back(f);
	}
	for(int x=0;x<n;x++)
	{
		int f;
		cin>>f;
		satis.push_back(f);
	}
	for(int x=0;x<n-1;x++)
	{
		int f;
		cin>>f;
		nextsatis.push_back(f);
	}
	nextsatis.push_back(0);
	int tot=0;
	int i;
	int f=0;
	int pre=-1;
	for(int x=0;x<n;x++)
	{
		i=order[x]-1;
		tot+=satis[i];
		
		if(f!=0)
		{
			if((pre+1)==(i))
			tot+=nextsatis[pre];
		}
		pre=i;
		f++;
	}
	cout<<tot<<endl;
	return 0;
}

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

int main() {
	int N,K,r=0;
	cin >> N >> K;
	vector<int> l(N);

	rep(i,N)
		cin >> l.at(i);
	sort(l.begin(), l.end(), greater<int>());

	rep(i,K)
		r += l.at(i);
	
	cout << r << endl;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
	private static void solve(){
	//Implement solution here.
		char[] ca = next().toCharArray();
		Map<Character,Integer> cMap = new HashMap<>();
		for(char c:ca) {
			if(cMap.containsKey(c)) {
				cMap.put(c, cMap.get(c) + 1);
			}else {
				cMap.put(c, 1);
			}
		}	
		if(cMap.keySet().size() == 2) {
			for(char c:cMap.keySet()) {
				if(cMap.get(c) != 2) {
					System.out.println("No");
					return;
				}
			}
		}else {
			System.out.println("No");
			return;
		}
		System.out.println("Yes");		
	}

    //Switch input source (stdin/file)
	private static BufferedReader br  = new BufferedReader(new InputStreamReader(System.in));
	public static void main(String[] args){
        String debugDataPath = System.getenv("DD_PATH");        
        if(debugDataPath != null){
            try{
            	br = new BufferedReader(new InputStreamReader(new FileInputStream(new File(debugDataPath))));
            }catch(Exception e){
                throw new RuntimeException(e);
            }
        }
        solve();
	}

    //Input read utility
	private static StringTokenizer tokenizer = null;
	public static String next() {
		while (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(br.readLine());
			} catch (Exception e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}
    //Get next single int
	private static int ni() {
		return Integer.parseInt(next());
	}
    //Get next single long
	private static long nl() {
		return Long.parseLong(next());
	}
    //Get next single double
	private static double nd() {
		return Double.parseDouble(next());
	}
    //Get next int array from one line
	private static int[] na(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = ni();
		return a;
	}
	//Get next char array from one line
	private static char[] ns() {
		return next().toCharArray();
	}
    //Get next long array from one line
	private static long[] nal(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nl();
		return a;
	}
}

Measured memory_bytes: 21332
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int a,b;
  cin >> a >> b;
  cout << max({a+b,2*a-1,2*b-1}) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define     __        ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define     pi        acos(-1)
#define     ll        long long int
#define     f0(n)     for(int i=0;i<n;i++)
#define     mem(a)    memset(a,0,sizeof(a))
#define     mems(a)   memset(a,-1,sizeof(a))

int main()
{
   /* #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif  */
     __

     int d;
     cin>>d;
     if(d==22) cout<<"Christmas Eve Eve Eve"<<endl;
     else if(d==23) cout<<"Christmas Eve Eve\n";
     else if(d==24) cout<<"Christmas Eve\n";
     else cout<<"Christmas\n";

    return 0;
}


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

#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

#define MAX_N 1002020

ll f[MAX_N], invf[MAX_N];
ll p = 1e9 + 7;

ll mod_pow(ll x, ll n, ll p)
{
    if (n == 0)
        return 1;
    ll res = mod_pow(x * x % p, n / 2, p);
    if (n & 1)
        res = res * x % p;
    return res;
}

void init()
{
    f[0] = 1;
    invf[0] = 1;
    for (ll i = 1; i <= MAX_N - 10; i++)
    {
        f[i] = f[i - 1] * i % p;
        invf[i] = (mod_pow(i, p - 2, p) * invf[i - 1]) % p;
    }
}

ll mod_conv(ll n, ll k)
{
    ll tmp = invf[n - k] * invf[k] % p;

    return f[n] * tmp % p;
}

int main()
{

    ll h, w, a, b;
    cin >> h >> w >> a >> b;
    ll ans = 0;
    init();

    for (ll i = b; i < w; i++)
    {
        (ans += (mod_conv(w - i - 1 + a - 1, a - 1) * mod_conv(i + h - a - 1, i)) % p) %= p;
    }
    OP(ans);

    return 0;
}

Measured memory_bytes: 15872
#include <stdio.h>

#define NUM 5

int main(void){

	int a[NUM];
	int i, j;
	
	for(i=0; i<NUM; i++)
		scanf("%d", &a[i]);
		
	for(i=0; i<NUM-1; i++) {
		for(j=NUM-1; j>i; j--) {
			if(a[j-1] < a[j]){
				int temp = a[j-1];
				a[j-1] = a[j];
				a[j] = temp;
			}
		}
	}
	
	for(i=0; i<NUM; i++){
		printf("%d", a[i]);
	if(i==NUM-1) break;
		printf(" ");
	}
	printf("\n");
		
	return 0;
}

Measured memory_bytes: 600
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(int i = 0; i < x; i++)
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
const ll N = 1e9+7;
const int n_max = 1e5+10;

struct UnionFind{
private:
    vector<int> par;
    vector<int> rank;

public:
    //n要素で親を初期化、par[x]はxの親を表す
    UnionFind(int n){
        par.resize(n,0);
        rank.resize(n,0);
        rep(i,n){
            par[i] = i;
        }
    }

    //木の根を求める
    int root(int x){
        if(par[x] == x) return x;
        else return par[x] = root(par[x]);
    }

    //xとyの属する集合を併合
    void unite(int x, int y){
        x = root(x);
        y = root(y);
        if(x == y) return;
        else{
            par[y] = x;
            if(rank[x] == rank[y]) rank[x]++;
        }
    }

    //xとyが同じ集合に属するか否か
    bool same(int x, int y){
        return root(x) == root(y);
    }

};

int main(){
    int n,k,l;cin >> n >> k >> l;
    UnionFind road(n);
    UnionFind train(n);
    UnionFind train_road(n);
    // vvi root(n,vector<int>(n,0));
    rep(i,k){
        int p,q;cin >> p >> q;
        p--;q--;
        road.unite(p,q);
    }
    rep(i,l){
        int r,s;cin >> r >> s;
        r--;s--;
        // if(road.same(r,s))train_road.unite(r,s);
        train.unite(r,s);
    }
    // int root[n] = {};
    // int ans[n] = {};
    // rep(i,n){
    //     int temp = train_road.root(i);
    //     root[temp]++;
    // }
    // rep(i,n){
    //     int temp = train_road.root(i);
    //     ans[i] = root[temp];
    //     cout << ans[i] <<"\n";
    // }
    // int ans[n] = {};
    // rep(i,n){
    //     rep(j,n){
    //         if(road.same(i,j) && train.same(i,j)) ans[i]++;
    //     }
    //     cout << ans[i] << "\n";
    // }
    map<P,int> rtmap;
    rep(i,n){
        rtmap[P(road.root(i),train.root(i))]++;
    }
    rep(i,n){
        cout << rtmap[P(road.root(i),train.root(i))] << "\n";
    }
    return 0;
    

}


Measured memory_bytes: 16640
import java.util.*;

public class Main {
  
  public static void main(String[] args) {
         
      Scanner sc = new Scanner(System.in);
      
      String str = sc.next();
      
      int count = 0;
      
      for(int i = 0;i < str.length();i++){
          char ch = str.charAt(i);
          if(ch == 'g'){
              count++;
          }          
      }
      
      if(str.length()%2 == 1){
           System.out.println(count - (str.length()/2 + 1));       
      }else{
           System.out.println(count - str.length()/2);    
      }
         
  }  
}

Measured memory_bytes: 25032
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define test int t;cin>>t;while(t--)
#define REP(i,n) for (int i = 1; i <= n; i++)
#define MOD 1000000007
#define ll long long
#define ld long double
#define int ll
#define pb push_back
#define ii pair<int,int>
#define llll pair<ll,ll>
#define vi vector<int>
#define vl vector<ll>
#define vii vector<ii>
#define vllll vector<llll>
#define ff first
#define ss second
#define INF 1000000000
#define HINF 1000000000000000
#define mem(a,b) memset(a,b,sizeof(a))
#define arrin(x,n) int x[n]; for(int o=0;o<n;o++) cin>>x[o]
#define arrout(x,n) for(int o=0;o<n;o++) cout<<x[o]<<" "; cout<<endl
#define all(x) x.begin(),x.end()
#define deb(x) cout<<#x<<'='<<x<<endl
#define deb2(x,y) cout<<#x<<'='<<x<<" "<<#y<<'='<<y<<endl
#define deb3(x,y,z) cout<<#x<<'='<<x<<" "<<#y<<'='<<y<<" "<<#z<<'='<<z<<endl
#define debarr(arr,n) for(int o=0;o<n;o++) deb2(o,arr[o])
const double pi = 3.14159265358979323846;

ll power(ll a, ll b){//a^b
    ll res=1;
    //a=a%MOD;
    while(b>0){
        if(b&1)
		{res=(res*a);
		//res%=MOD;
		b--;}
        a=(a*a);
        //a%=MOD;
        b>>=1;
    }
    return res;
}
ll fermat_inv(ll y){return power(y,MOD-2);}
ll gcd(ll a, ll b){return (b==0)?a:gcd(b,a%b);}
int C(int n,int k)
{
	int ans=1;
	if(k>n-k)
	k=n-k;
	for(int i=1;i<=k;i++)
	ans*=(n-i+1),ans/=i;
	return ans;
}

void solve()
{

	int i=0,j=0,k=0,m,n,p,sum=0,cnt=0;
	cin>>n;
	if(n<600)
	{
	    cout<<8;
	    return;
	}
	if(n<800)
	{
	    cout<<7; return;
	}
	if(n<1000)
	{
	    cout<<6; return;
	}
	if(n<1200)
	{
	    cout<<5; return;
	}
	if(n<1400)
	{
	    cout<<4; return;
	}
	if(n<1600)
	{
	    cout<<3; return;
	}
	if(n<1800)
	{
	    cout<<2; return;
	}
	if(n<2000)
	{
	    cout<<1; return;
	}
	
}
int32_t main() {
    fast
    //freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w+", stdout);
	//cout<<fixed<<setprecision(6);
    //test
    {
        
        solve();
		
		      
    }
    return 0;
}
  

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

int main() {
  int a,b,c,d,e;
  cin >>a;
  b=a%10;
  c=(a-b)%100;
  d=a-b-c;
  e=b+c/10+d/100;
  cout <<e<<endl;
}


Measured memory_bytes: 256
// #include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <string>
#include <functional>
#include <math.h>
#include <map>

typedef long long ll;
typedef unsigned long long ull;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n)   FOR(i,0,n)
#define RREP(i,n)   RFOR(i,0,n)

const int INF = 1e9;
const int MOD = 1e9+7;

using namespace std;

template <typename _Ty>
ostream& operator << (ostream& ostr, const vector<_Ty>& v) {if (v.empty()) {ostr << "{ }"; return ostr;}
   ostr << "{" << v.front(); for (auto itr = ++v.begin(); itr != v.end(); itr++) {ostr << ", " << *itr;}
   ostr << "}";
   return ostr;}

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


int main(void){
 ios::sync_with_stdio(false);

 ll N, K;
 cin >> N >> K;

 vector<ll> h(N);
 REP(i, N) {cin >> h.at(i);}

 vector<ll> dp(N);
 REP(i, N) {dp[i] = INF;}
 dp[0] = 0;

 REP(i,N){
   FOR(j, 1, K+1){
       chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));}
 }

 cout << dp[N-1] << endl;




 return 0;
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ff(i,n) for(i=0;i<n;i++)
#define pb push_back
ll bg =  998244353;
ll fac[300000];
ll power(ll x,ll y)
{
    if(y==0)
	    return 1;
	ll d = power(x,y/2)%bg;
	ll f = (d*d)%bg;
	if(y%2==0)
	  return f;
	else
	  return (f*x)%bg;	 	
}
ll modinv(ll m)
{
	return power(m,bg-2);	
}
ll ncr(ll n,ll r)
{
	ll s1 = fac[n],s2 = fac[r],s3 = fac[n-r];
	ll d1 = (s1*modinv(((s2*s3)%bg)))%bg;
	return d1;
}
int main()
{
	fac[0]=1;
	for(ll j=1;j<300000;j++)
	  fac[j] = (j*fac[j-1])%bg;
	ll t;
	t=1;
	while(t--)
	{
		string s;
        cin>>s;
		if(s=="ABC")
		   cout<<"ARC";
		else
		   cout<<"ABC";   
	}
	 return 0;
}

Measured memory_bytes: 5948
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;

int a,b,c;

int main(){
	
	cin>>a>>b>>c;
	a=a*10+b;
	a=a*10+c;
	if(a%4==0)cout<<"YES";
	else cout<<"NO";
	return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

#include <algorithm>
#include <bitset>
#include <complex>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

#include <cassert>
#include <functional>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

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

template<typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  int N, K;

  cin >> N >> K;

  int ans = 0;

  while (N) {
    N /= K;
    ans++;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// long long m=1000000007;
int main(){
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    cout.tie(NULL);
    long long t,m,n,i,j,k,temp,sum=0,flag=0,count=0,mi,x,y;
    cin >>n>>m>>k;
    if(k<1000000000)
    for(i=0;i<n;i++){
        if(i<m)
        cout << k <<" ";
        else cout << k+1<< " ";
    }
    else{
        for(i=0;i<n;i++){
        if(i<m)
        cout << k <<" ";
        else cout <<  "1 ";
    }
    }
}

Measured memory_bytes: 1280
def main():
    a = list(map(int, input().split()))
    a.sort()
    a = a[::-1]

    cost = 0

    for i in range(len(a)):
        if (i == 0):
            continue
        cost += a[i-1]-a[i]

    print(cost)


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
//هوالحق
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
    int n, s = 0;
    cin >> n;
    vector<int> V(n);
    for(int i = 0, x; i < n; i++){
        cin >> x;
        s += x;
        V[i] = (i)? V[i-1] + x: x;
    }
    int r = 100000;
    for(int i = 0; i < n; i++) r = min(r, abs(s - 2 * V[i]));
    cout << r;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define PI 3.14159265358979323846
const ll MAX = 1e5+10;
const ll INF = 1e18;
const ll MOD = 1e9+7;

vector<ll> a[MAX];
ll dp[MAX][2];
ll visited[MAX];

void dfs(int node)
{
  visited[node]=1;
  for(int i=0;i<a[node].size();i++)
  {
    if(visited[a[node][i]]==1)
      continue;
   	dfs(a[node][i]);
    ll k = a[node][i];
    ll w = dp[k][0]+dp[k][1];
    ll b = dp[k][0];
    dp[node][0]=(dp[node][0]*w)%MOD;
    dp[node][1]=(dp[node][1]*b)%MOD;
  }
}

int main()
{
  ll n,i,j,k,l,p,q,x,y;
  cin >> n;
  for(i=0;i<n-1;i++)
  {
    cin >> x >> y;
    a[x].push_back(y);
    a[y].push_back(x);
  }
  for(i=0;i<MAX;i++)
  {
    dp[i][0]=1;dp[i][1]=1;
  }
  dfs(1);
  p = dp[1][0]+dp[1][1];
  p = p%MOD;
  cout << p;
}

Measured memory_bytes: 12288
//ABC088A
#include <bits/stdc++.h>
#include <iostream>
#include <iomanip>
#include <numeric>
#include <math.h>
#include <stdio.h>
#include <climits>
#include <cfloat>
#include <string>
using namespace std;

int main(){
	int n, a;
	cin >> n >> a;
	if(n%500 <= a){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define prt_cs                  printf("Case %lld: ",cs)
#define sqr(x)                  (x)*(x)
#define ms(a,b)                 memset(a, b, sizeof(a))
#define db                      double
#define ll                      long long int
#define MOD                     100000007
#define PI                      2*acos(0.0)
#define pii                     pair< int, int >
#define READ                    freopen("in.txt","r",stdin)
#define WRITE                   freopen("out.txt","w",stdout)
#define gcd(a, b)               __gcd(a, b)
#define lcm(a, b)               (((a)*(b))/gcd(a,b))
#define MAX                     100005

using namespace std;

int d[101];

int main()
{
//    READ;
//    WRITE;
    int n;
    scanf("%d",&n);
    for(int i=0;i<n;i++)
        scanf("%d",&d[i]);
    ll sum=0;
    for(int i=0;i<n;i++)
    {
        for(int j=i+1;j<n;j++)
        {
            sum+=d[i]*d[j];
        }
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int H, W;  // H: 縦, W: 横

int main()
{
  cin>>H>>W;
  vector<string> a(H);
  for(int i=0; i<H; i++)  cin>>a[i];
  cout<<endl;

  vector<string> AnsH;
  // 各行をみていく
  for(int i=0; i<H; i++){
    bool b = true;
    for(int j=0; j<W; j++){
      if(a[i][j]=='#'){
        b = false;
        break;
      }
    }
    if(!b){  // b==false -> '#'があったとき
      AnsH.push_back(a[i]);  // AnsH に追加
    }
  }

  vector<int> x(AnsH[0].length(), 1);
  // 各列をみていく
  for(int j=0; j<AnsH[0].length(); j++){
    bool b = true;
    for(int i=0; i<AnsH.size(); i++){
      if(AnsH[i][j]=='#'){
        b = false;
        break;
      }
    }
    if(b){  // b==ture -> '#'がなかったとき
      x[j] = 0;
    }
  }
  
  for(int i=0; i<AnsH.size(); i++){
    for(int j=0; j<AnsH[0].length(); j++){
      if(AnsH[i][j]=='#')  cout<<AnsH[i][j];
      else{
        if(x[j])  cout<<AnsH[i][j];
      }
    }
    cout<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const double pi=2*acos(0.0);
double inff=1.0/0.0;
#define ll           long long int
#define inf          1000000000000000008
#define MOD          1000000007
#define pb           push_back
#define sz(x)        (int)x.size()
#define mp           make_pair
#define lbd          lower_bound
#define ubd          upper_bound
#define ipair        pair<ll,ll> 
#define all(v)       v.begin(),v.end()
#define watch(x)     cout<<(#x)<<" is "<<(x)<<endl;
#define rep(a,b,c)   for(a=(int)b;a<(int)c;a++)
#define rep2(a,b,c)  for(a=(int)b;a<(int)c;a+=2)  
#define bac(a,b,c)   for(a=(int)b;a>=(int)c;a--)
#define se           second
#define f            first
#define ios          ios::sync_with_stdio(false), cout.tie(0), cin.tie(0);
#define mem(a,val)   memset(a,val,sizeof a)
#define endl         "\n"
#define mxn          100005
#define vi           vector<ll>
#define vii          vector<ipair> 
#define si           set<ll> 
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
/*Variables Start*/
ll x,y,n,i,z,j,k,w,u,q,m,t;
ll a[mxn],b[mxn];
/*Variables End*/
void solve()
{
 	cin>>n;
 	rep(i,1,n+2) cin>>a[i];
 	rep(i,1,n+1) cin>>b[i];
 	w=0;
 	rep(i,1,n+2)
 	{
 		if(i!=1)
 		{
 			y=max(0LL,a[i]-b[i-1]);
 			w+=a[i]-y;
 			a[i]=y;	
 		} 
 		if(i!=n+1)
 		{
	 		x=max(0LL,a[i]-b[i]);
	 		w+=a[i]-x;
	 		b[i]-=a[i]-x;
	 		a[i]=x;	
 		}
 	}
 	cout<<w<<endl;
}
int main() 
{ 
  int TESTS=1;
  ios;  
  while(TESTS--)
  {
    solve();
  }  
}

Measured memory_bytes: 1792
n, t = map(int,input().split())
dat = list(map(int, input().split()))
l = dat[0]
lt = dat[0]
res = 0
deteta = 0
for i in range(n):
    deteta = min(t,  dat[i] - lt)
    res += deteta
    l = dat[i] + t
    lt = dat[i]
print(t + res)

Measured memory_bytes: 85584
#ifndef ATCODER_DSU_HPP
#define ATCODER_DSU_HPP 1

#include <algorithm>
#include <cassert>
#include <vector>
#include <iostream>

using namespace std;
using ll = long long;

namespace atcoder {

// Implement (union by size) + (path compression)
// Reference:
// Zvi Galil and Giuseppe F. Italiano,
// Data structures and algorithms for disjoint set union problems


struct dsu { // dsu の正式名称 disjoint-set Union  //(Union-Find = グループ分けのデータ構造）
  public:
    dsu() : _n(0) {}
    dsu(int n) : _n(n), parent_or_size(n, -1) {}

    int merge(int a, int b) {
        assert(0 <= a && a < _n);
        assert(0 <= b && b < _n);
        int x = leader(a), y = leader(b);
        if (x == y) return x;
        if (-parent_or_size[x] < -parent_or_size[y]) std::swap(x, y);
        parent_or_size[x] += parent_or_size[y];
        parent_or_size[y] = x;
        return x;
    }

    bool same(int a, int b) {
        assert(0 <= a && a < _n);
        assert(0 <= b && b < _n);
        return leader(a) == leader(b);
    }

    int leader(int a) {
        assert(0 <= a && a < _n);
        if (parent_or_size[a] < 0) return a;
        return parent_or_size[a] = leader(parent_or_size[a]);
    }

    int size(int a) {
        assert(0 <= a && a < _n);
        return -parent_or_size[leader(a)];
    }

    std::vector<std::vector<int>> groups() {
        std::vector<int> leader_buf(_n), group_size(_n);
        for (int i = 0; i < _n; i++) {
            leader_buf[i] = leader(i);
            group_size[leader_buf[i]]++;
        }
        std::vector<std::vector<int>> result(_n);
        for (int i = 0; i < _n; i++) {
            result[i].reserve(group_size[i]);
        }
        for (int i = 0; i < _n; i++) {
            result[leader_buf[i]].push_back(i);
        }
        result.erase(
            std::remove_if(result.begin(), result.end(),
                           [&](const std::vector<int>& v) { return v.empty(); }),
            result.end());
        return result;
    }

  private:
    int _n;
    // root node: -1 * component size
    // otherwise: parent
    std::vector<int> parent_or_size;
};

}  // namespace atcoder

#endif  // ATCODER_DSU_HPP

int main() {
   
    ll N, M, A, B;
    cin >> N >> M;
    atcoder::dsu d(N);//頂点N個を生成

    for (int i = 0; i < M; ++i) {
        cin >> A >> B;//入力する点

        --A; --B; //配列は0始まりのため、問題文の要素数と合わせるために行う これをしないと配列の枠をはみ出して実行エラーになる

        d.merge(A, B); //入力した点と点を線でつなげる                 
    }       
    
    int cnt = 0; 
    for (int i = 0; i < N; ++i) {
        
        if(d.leader(i) == i) ++cnt; //頂点の数をカウント = 連結成分の数 （連結成分とはざっくり言うとグループのこと）
            //cout << i  << "  " << d.size(i) << endl; //連結部分の全体数を表示できる 3-2-4 がくっついているならどこの要素で問い合わせしても3を返す
            //cout << i  << "  " << d.leader(i) << endl; 連結成分の各リーダ（頂点）の確認 無向グラフのためどの要素が頂点でもよい
            // d.groups()を利用して解くことも可能
    }  
    
    int ans;
    ans =  cnt - 1;
    cout << ans << endl;
    
    return 0;
}

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

int count(vector<int>vec,int n){
  int ans = 0;
  for(int i = 0;i < n-1;i++){
    int kai = 1,c = 0;
    for(int j = 1;j < n-i;j++){
      kai *= j;
    }
    for(int j = i+1;j < n;j++){
      if(vec.at(j) < vec.at(i)) c++;
    }
    ans += c*kai;
  }
  return ans;
}
int main(){
  int n,ap,aq;
  cin >> n;
  vector<int>p(n);
  vector<int>q(n);
  for(int i = 0;i < n;i++){
    cin >> p.at(i);
  }
  for(int i = 0;i < n;i++){
    cin >> q.at(i);
  }
  ap = count(p,n);
  aq = count(q,n);
  cout << abs(ap-aq) << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	public static void main(String[] args) { 
		Scanner sc = new Scanner(System.in);
		while(true){
			int n=sc.nextInt();	
			int k=sc.nextInt();
			if(n==0&&k==0)break;
			int blood[]=new int [k];
			for(int i=0;i<k;i++)
				blood[i]=sc.nextInt();
			int vamp_b[][]=new int[n][k];
			int max_b[]=new int[k];
			for(int i=0;i<n;i++){
				for(int j=0;j<k;j++){
					vamp_b[i][j]=sc.nextInt();
					max_b[j]+=vamp_b[i][j];
				}
			}
			String ans="Yes";
			for(int i=0;i<k;i++){
				if(max_b[i]>blood[i])ans="No";
//				System.out.println(max_b[i]+" "+blood[i]);
			}
			System.out.println(ans);
			
		
		
		}
	}
}

Measured memory_bytes: 96968
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
#define N 200050
typedef long long ll;
int n,a[N];
ll s[N];
ll Abs(ll x) {return x>0?x:-x;}
ll _max(ll a,ll b,ll c,ll d) {
	if(a<b) a=b; if(a<c) a=c; if(a<d) a=d;
	return a;
}
ll _min(ll a,ll b,ll c,ll d) {
	if(a>b) a=b; if(a>c) a=c; if(a>d) a=d;
	return a;
}
int main() {
	scanf("%d",&n);
	int i,j=1,k=3,l,p;
	ll ans=1ll<<60;
	for(i=1;i<=n;i++) scanf("%d",&a[i]),s[i]=s[i-1]+a[i];
	for(i=2;i<n-1;i++) {
		while(s[j]<s[i]-s[j]) j++;
		while(s[k]-s[i]<s[n]-s[k]) k++;
		for(l=-2;l<=2;l++) {
			for(p=-2;p<=2;p++) {
				int l1=j+l,l2=k+p;
				if(l1<1||l1>i-1||l2<i+1||l2>n-1) continue;
				ll P=s[l1],Q=s[i]-s[l1],R=s[l2]-s[i],S=s[n]-s[l2];
				ans=min(ans,_max(P,Q,S,R)-_min(P,Q,S,R));
			}
		}
	}
	printf("%lld\n",ans);
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define inf 1<<28
vector <int> G[200010];
int dist[200010];
//int parent[100];
int distance[200010];
bool visit[200010];
int BFS(int source, int destination)
{
    queue <int> Q;
    memset(dist,inf,sizeof dist);
    Q.push(source);
    dist[source] = 0;
    visit[source] = true;

    while(!Q.empty())
    {
        int u = Q.front();
        Q.pop();
        for(size_t i=0; i<G[u].size(); i++)
        {
            int v = G[u][i];

            while(!visit[v])
            {
                dist[v] = dist[u] + 1;
                visit[v] = true;
               // parent[v] = u;
                Q.push(v);
            }
        }
    }
    return dist[destination];
}
int main()
{
    int node,edge;
    cin>>node>>edge;
    for(int i=0; i<edge; i++)
    {
        int x,y;
        cin>> x >> y;
        G[x].push_back(y);
        G[y].push_back(x);
    }

    int s,d;
    s=1;
    d=node;
    int ans=BFS(s,d);
   // cout<<"ans = "<<ans<<endl;
    if(ans==0 || ans>2) cout<<"IMPOSSIBLE"<<endl;
    else cout<<"POSSIBLE"<<endl;
}


Measured memory_bytes: 13424
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;
#define all(v) v.begin(), v.end()
#define repi(i, n, init) for (ll i = init; i < (n); i++)
#define repd(i, n, init) for (ll i = (n); i >= init; i--)
#define repm(i, m) for (auto i = m.begin(); i != m.end(); i++)

int main()
{
    ll a, b, c;
    cin >> a >> b >> c;
    map<int, int> paints;
    paints.insert(make_pair(a, 1));
    paints.insert(make_pair(b, 1));
    paints.insert(make_pair(c, 1));
    cout << paints.size() << endl;
    return 0;
}

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

int main()
{
  int a, b, c;
  cin>>a>>b>>c;
  if(a == 5 && b == 7 && c == 5) cout<<"YES";
  else if(a == 7 && b == 5 && c == 5) cout<<"YES";
  else if(a == 5 && b == 5 && c == 7) cout<<"YES";
  else cout<<"NO";
}

Measured memory_bytes: 3536
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int K;cin >> K;
  vector<ll> v(K);
  rep(i,K)cin >> v[i];

  auto f = [&](ll X){
    rep(i,K) X = (X/v[i])*v[i];
    return X>=2;
  };

  ll l = 0, r = MAX_LL/2;
  while(r-l>1){
    ll m = (l+r)/2;
    if(f(m))r = m;
    else l = m;
  }
  ll in = r;

  auto g = [&](ll X){
    rep(i,K) X = (X/v[i])*v[i];
    return X<=2;
  };

  l = 0, r = MAX_LL/2;
  while(r-l>1){
    ll m = (l+r)/2;
    if(g(m))l = m;
    else r = m;
  }
  ll ax = l;
  if(ax-in<0)cout << -1 << endl;
  else cout << in SP ax << endl;
  return 0;
}



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

using namespace std;

#define endl     "\n"
#define mod      1000000007
#define fi       first
#define se       second
#define pb       push_back
#define mp		 make_pair
#define bs       binary_search
#define lbnd     lower_bound
#define ubnd	 upper_bound
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/__gcd((a),(b))
#define sz		 size

typedef long long ll;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);cout.tie(NULL);
	string s;
	ll n;
	cin>>s;
	cin>>n;
	string str;
	for(ll i=0;i<s.length();i+=n)
		str+=s[i];
	cout<<str<<endl;
	return 0;
}


Measured memory_bytes: 256
while True:
    n, m = map(int, raw_input().split())
    if (n, m) == (0, 0):
        break
    r = [0] * m
    for i in range(n):
        q = map(int, raw_input().split())
        for j in range(m):
            r[j] -= q[j]
    r = sorted([(r[i],i+1)for i in range(m)])
    print ' '.join(map(str, [rr[1] for rr in r]))

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



int main() {
    int N,X,Y;
    cin>>N>>X>>Y;
    --X;--Y;
    vector<vector<int>> dis(N,vector<int>(N,0));
    rep(i,N){
        rep(j,N){
            if(i<=X){
                if(j<=X){
                    dis.at(i).at(j)=abs(i-j);
                }
                else if(X<j && j<Y){
                    dis.at(i).at(j)=X-i+Y-j+1;
                    dis.at(i).at(j)=min(dis.at(i).at(j),abs(i-j));
                }
                else{
                    dis.at(i).at(j)=X-i+j-Y+1;
                }
            }
            else if(X<i && i<Y){
                if(j<=X){
                    dis.at(i).at(j)=Y-i+X-j+1;
                    dis.at(i).at(j)=min(dis.at(i).at(j),abs(i-j));
                }
                else if(X<j && j<Y){
                    if(i<=j){dis.at(i).at(j)=i-X+Y-j+1;}
                    else{dis.at(i).at(j)=Y-i+j-X+1;}
                    dis.at(i).at(j)=min(dis.at(i).at(j),abs(i-j));
                }
                else{
                    dis.at(i).at(j)=j-Y+i-X+1;
                    dis.at(i).at(j)=min(dis.at(i).at(j),abs(i-j));
                }
            }
            else{
                if(j<=X){
                    dis.at(i).at(j)=X-j+i-Y+1;;
                }
                else if(X<j && j<Y){
                    dis.at(i).at(j)=i-Y+j-X+1;
                    dis.at(i).at(j)=min(dis.at(i).at(j),abs(i-j));
                }
                else{
                    dis.at(i).at(j)=abs(i-j);
                }
            }
        }
    }

    vector<int> kyo(N);
    rep(i,N){
        rep(j,N){
            kyo.at(dis.at(i).at(j))++;
        }
    }
    rep(i,N-1){
        cout<<kyo.at(i+1)/2<<endl;
    }

    /*rep(i,N){
        rep(j,N){
            cout<<dis.at(i).at(j)<<" ";
        }
        cout<<endl;
    }*/
}

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

int main(){
  int H,W;  cin >> H >> W;
  string C[100];

  for(int i = 0;i < H;i++){
    cin >> C[i];
  }

  for(int i = 0;i < 2 * H;i++){
    for(int j = 0;j < W;j++){
      cout << C[i/2][j];
      if(j == W-1)cout << '\n';
    }
  }
  
}

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

namespace ALDS1_3_A
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split();
            int[] stack = new int[str.Length];
            int pointer = 0;
            for (int i = 0; i < str.Length; i++)
            {
                if (str[i] == "+") { stack[pointer - 2] = stack[pointer - 2] + stack[pointer - 1]; stack[pointer - 1] = new int(); pointer -= 2; }
                else if (str[i] == "*") { stack[pointer - 2] = stack[pointer - 2] * stack[pointer - 1]; stack[pointer - 1] = new int(); pointer -= 2; }
                else if (str[i] == "-") { stack[pointer - 2] = stack[pointer - 2] - stack[pointer - 1]; stack[pointer - 1] = new int(); pointer -= 2; }
                else { stack[pointer] = int.Parse(str[i]); }
                pointer++;
            }
            Console.WriteLine(stack[0]);
        }
    }
}



Measured memory_bytes: 17936