akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UncheckedIOException;
import java.util.StringTokenizer;

class Main{
	public static void main(String[] args) {
		SC sc=new SC(System.in);
		int a,b,c;
		a=sc.nextInt();
		b=sc.nextInt();
		c=sc.nextInt();
		pl(a*b/2);
	}
	public static void pl(Object o) {
		System.out.println(o);
	}
	public static void pl() {
		System.out.println();
	}
	public static void p(Object o) {
		System.out.print(o);
	}
	static class SC {
		private BufferedReader reader = null;
		private StringTokenizer tokenizer = null;
		public SC(InputStream in) {
			reader = new BufferedReader(new InputStreamReader(in));
		}
		public String next() {
			if (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new UncheckedIOException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		public double nextDouble() {
			return Double.parseDouble(next());
		}
		public String nextLine() {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new UncheckedIOException(e);
			}
		}
	}
}


Measured memory_bytes: 23252
a, b, k = gets.split.map(&:to_i)

pnt = a

k.times do |i|
    puts pnt
    break if a + i > b - k
    pnt += 1
end

puts pnt if b - k == a + k - 1

aaa = b - pnt
cnt = [aaa, k].min
pnt = b - cnt + 1

cnt.times do |i|
     puts pnt + i
end


Measured memory_bytes: 3836
import java.util.*;
public class Main{
	public static void main(String[]$){
		Scanner c=new Scanner(System.in);
		String s=c.next();
		int n=s.length(),t=n,i=n;
		while(i-->1)t=Math.min(t,s.charAt(i-1)!=s.charAt(i)?Math.max(i,n-i):n);
		System.out.println(t);
	}
}

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

const int maxn = 2e5 + 5;

int p[maxn], q[maxn], rp[maxn], rq[maxn];
int n;
int rA[maxn], A[maxn], B[maxn];

void power(int b){
	if (b == 0)
		return;
	power(b / 2);
	for (int i = 1; i <= n; i++)
		B[i] = A[A[i]];
	for (int i = 1; i <= n; i++)
		A[i] = B[i];
	if (b & 1){
		for (int i = 1; i <= n; i++)
			B[i] = A[q[rp[rq[p[i]]]]];
		for (int i = 1; i <= n; i++)
			A[i] = B[i];
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	int k;
	cin >> n >> k;
	for (int i = 1; i <= n; i++){
		cin >> p[i];
		rp[p[i]] = i;
	}
	for (int i = 1; i <= n; i++){
		cin >> q[i];
		rq[q[i]] = i;
	}
	for (int i = 1; i <= n; i++)
		A[i] = i;
	power((k - 1) / 6);
	if (k % 6 == 4){
		for (int i = 1; i <= n; i++)
			B[i] = A[q[i]];
		for (int i = 1; i <= n; i++)
			A[i] = B[i];
	}
	if (k % 6 == 5 or k % 6 == 0){
		for (int i = 1; i <= n; i++)
			B[i] = A[q[rp[i]]];
		for (int i = 1; i <= n; i++)
			A[i] = B[i];
	}
	for (int i = 1; i <= n; i++)
		rA[A[i]] = i;
	k %= 6;
	if (k == 1)
		for (int i = 1; i <= n; i++)
			B[i] = p[i];
	else if (k == 2)
		for (int i = 1; i <= n; i++)
			B[i] = q[i];
	else if (k == 3)
		for (int i = 1; i <= n; i++)
			B[i] = q[rp[i]];
	else if (k == 4)
		for (int i = 1; i <= n; i++)
			B[i] = rp[i];
	else if (k == 5)
		for (int i = 1; i <= n; i++)
			B[i] = rq[i];
	else
		for (int i = 1; i <= n; i++)
			B[i] = rq[p[i]];
	for (int i = 1; i <= n; i++)
		cout << A[B[rA[i]]] << " ";
	cout << endl;
}


Measured memory_bytes: 4736
while True:
  try:
    n = int(input())
    count = 0
    for a in range(10):
      for b in range(10):
        for c in range(10):
          for d in range(10):
           if a+b+c+d==n:
              count += 1
    print(count)
  except EOFError:
    break


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

using namespace std;

typedef long long ll;
const ll INF = 1LL<<60;

ll gcd(ll a, ll b) {
  if(b == 0) return a;
  return gcd(b, a % b);
}

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; }

ll modpow(ll a, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % mod;
    a = a * a % mod;
    n >>= 1;
  }
  return res;
}

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

  int H, W;
  cin >> H >> W;
  int ans_h, ans_w;
  string s;
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      cin >> s;
      if(s == "snuke"){
        ans_h = i+1;
        ans_w = j;
        break;
      }
    }
  }

  cout << char('A'+ans_w) << ans_h << endl;

  return 0;
}


Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
#define all(v) v.begin(), v.end()
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    string s; cin>>s;
    if(s[0]==s[1]&&s[1]==s[2]) {
        cout<<"No"<<endl;
    }
    else cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
N = int(input())
prices = list(map(int, input().split()))

cash = 1000

low_p = prices[0]
share = cash // low_p

for price in prices:
    if low_p > price:
        low_p = price
        share = cash // price

    if low_p < price:
        cash += (price - low_p) * share
        low_p = price

print(cash)

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

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define mp make_pair
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define MOD 1000000007

int n;
vector<int> a,b;

int main(){
  cin >> n;
  vector<int> a(n);
  vector<int> b(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
    a[i] = a[i]-1;
    b[a[i]] = i;
  }
  sort(a.begin(),a.end());
  for(int i = 0; i <n; i++){
    cout << b[a[i]]+1;
    if(i!=n-1) cout << " ";
  }
  cout << endl;
  return 0;
}


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

public class Main{
	public static void main(String[] args)throws IOException{
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader reader = new BufferedReader(isr);
		String string;
		int n, ans;
		double res, min;
		
		while(!(string = reader.readLine()).equals("0")){
			n = Integer.valueOf(string);
			
			min = 1 << 29;
			ans = 0;
			for(int i = 0; i < n; i++){
				String str[] = reader.readLine().split(" ");
				
				res = Double.valueOf(str[2]) / Math.pow(Double.valueOf(str[1]) / 100 , 2);
				res = 22. > res ? 22. - res : res - 22.;
				if(min > res){
					min = res;
					ans = Integer.valueOf(str[0]);
				}
			}
			System.out.println(ans);
		}
		reader.close();
	}
}

Measured memory_bytes: 27484
#include <iostream>

using namespace std;

int n, m, c;
int b[25];
int a[25];

int main(void)
{
	cin >> n >> m >> c;
	for(int j = 1; j <= m; j++) cin >> b[j];
	
	int cnt = 0;
	for(int i = 1; i <= n; i++){
		for(int j = 1; j <= m; j++){
			cin >> a[j];
		}
		int ans = 0;
		for(int j = 1; j <= m; j++) ans += a[j]*b[j];
		if(ans > -c) cnt++;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define INF 1000000000
#define debug(x) cerr << #x << ": " << x << '\n';
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int MAX_N = (int)2e5;
ll A[MAX_N + 10];

int main(void){
	int N; cin >> N;
	for(int i = 0; i < N; i++){
		int a; cin >> a;
		A[i] = a - (i + 1);
	}

	sort(A, A + N);
	ll b = A[N/2];
	ll res = 0;
	for(int i = 0; i < N; i++){
		res += abs(A[i] - b);
	}

	cout << res << '\n';

	return 0;
}


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

void solve() {
  double w, h, x, y;
  cin >> w >> h >> x >> y;
  double ans = (double) w * h / 2;
  cout << fixed << setprecision(10) << ans << " ";
  if ((double) w / 2 == x && (double) h / 2 == y) {
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }
}

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


Measured memory_bytes: 256
import numpy as np

N = 5
data = [int(input()) for i in range(N)]
data_1 = []
sum = 0

for i in range(N):
    temp = 0
    temp = data[i] - int(np.floor(data[i] / 10) * 10)
    data_1.append(temp)
    sum += int(np.ceil(data[i] / 10 ) * 10)
    
last_index = -1
for i in range(N):
    if data_1[i] != 0:
        if last_index == -1:
            last_index = i
        elif data_1[i] < data_1[last_index]:
            last_index = i
if last_index == -1:
    last_index =0
sum = int(sum - np.ceil(data[last_index] / 10) * 10 + data[last_index])
print(sum)    

Measured memory_bytes: 21740
#include<stdio.h>
 
int n, a[50];
 
int solve(int i, int m) 
{
   if( m == 0 ) return 1;
   if( i >= n ) return 0;

   int res = solve(i + 1, m) || solve(i + 1, m - a[i]);
   return res;
}
 

int main()
{
int q, m, i;
 
   scanf("%d", &n);
   for( i = 0; i < n; i++ ){
      scanf("%d", &a[i]);
  }
 
   scanf("%d", &q);
   for(i = 0; i < q; i++){
      scanf("%d", &m);
      if( solve(0, m) )
         printf("yes\n");
      else
         printf("no\n");
 
     
  }
  return 0;
}

Measured memory_bytes: 1740
h,w=map(int,input().split())
S=[]
for i in range(h):
    S.append(list(input()))
dx=[1,0,-1,0]
dy=[0,1,0,-1]
for i in range(1,h-1):
    for j in range(1,w-1):
        if S[i][j]=='#':
            if all(S[i+dx[k]][j+dy[k]]=='.' for k in range(4)):
                print("No")
                exit()
print("Yes")

Measured memory_bytes: 9064
N = gets.to_i
A = gets.split.map(&:to_i)
Amax = A.max
D = Array.new(Amax + 1,&:itself)
(2 .. Integer.sqrt(Amax)).each do |i|
  next if D[i] < i
  s = i
  while s < D.size
    D[s] = i if D[s] == s
    s += i
  end
end

dp = Array.new(Amax + 1, 0)
A.each do |a|
  while a > 1
    m = D[a]
    dp[m] += 1
    while a % m == 0
      a /= m
    end
  end
end
dpmax = dp.max
if dpmax <= 1 
  puts 'pairwise coprime'
elsif dpmax == N
  puts 'not coprime'
else
  puts 'setwise coprime'
end


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll H, W, K; cin >> H >> W >> K;

    ll HMAX = 7;
    vector<ll> vec(HMAX); vec.at(0) = 0;

    rep2(w, 1, HMAX){ // 間の個数がw
        ll cnt = 0;
        for (int bit = 0; bit < (1<<w); ++bit) { // 1を左に2回シフトすると100
            vector<int> S;
            for (int i = 0; i < HMAX; ++i) {
                if (bit & (1<<i)) { // 列挙に i が含まれるか
                    S.push_back(i);
                }
            }
            ll prev = -2;
            bool flag = true;
            for (auto s: S){
                if (s == prev + 1){flag = false; break;}
                prev = s;
            }
            if (flag){cnt++;}
        }
        vec.at(w) = cnt;
        // cout << cnt << endl;
    }

    ll dp[H + 1][W]; rep(i, H + 1){rep(j, W){dp[i][j] = 0;}}
    dp[0][0] = 1;

    rep(i, H){rep(j, W){
        ll tmp, l, r;
        if (j - 1 >= 0){ // 左から流入
            tmp = 1;
            l = ((j - 1) - 0) - 1; if (l > 0){tmp *= vec.at(l);}
            r = ((W - 1) - j) - 1; if (r > 0){tmp *= vec.at(r);}
            dp[i + 1][j] += tmp * dp[i][j - 1] % MOD;
            dp[i + 1][j] %= MOD;
        }
        if (j + 1 <= W - 1){ // 右から流入
            tmp = 1;
            l = (j - 0) - 1; if (l > 0){tmp *= vec.at(l);}
            r = ((W - 1) - (j + 1)) - 1; if (r > 0){tmp *= vec.at(r);}
            dp[i + 1][j] += tmp * dp[i][j + 1] % MOD;
            dp[i + 1][j] %= MOD;
        }

        // 同じ所から流入
        tmp = 1;
        l = (j - 0) - 1; if (l > 0){tmp *= vec.at(l);}
        r = ((W - 1) - j) - 1; if (r > 0){tmp *= vec.at(r);}
        dp[i + 1][j] += tmp * dp[i][j] % MOD;
        dp[i + 1][j] %= MOD;
    }}

    // rep(j, W){cout << dp[H][j] << " ";}
    // cout << endl;
    cout << dp[H][K - 1] << endl;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N, M; cin >> N >> M;
  vector<tuple<int, int, int>> MY(M);
  for(int i=0;i<M;i++){
    cin >> get<0>(MY[i]) >> get<1>(MY[i]);
    get<2>(MY[i])=i;
  }
  sort(MY.begin(), MY.end());
  get<1>(MY[0])=1;
  for(int i=1;i<M;i++){
    if(get<0>(MY[i-1])==get<0>(MY[i])){
      get<1>(MY[i])=get<1>(MY[i-1])+1;
    }
    else get<1>(MY[i])=1;
  }
  for(int i=0;i<M;i++){
    swap(get<0>(MY[i]),get<2>(MY[i]));
  }
  sort(MY.begin(),MY.end());
  for(int i=0;i<M;i++){
    cout << setfill('0') << right << setw(6) << get<2>(MY[i]) << setfill('0') << right << setw(6) << get<1>(MY[i]) << endl;
  }
}

Measured memory_bytes: 2688
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define INF (1e9)
typedef long long ll;
typedef struct{
    int x;
    int y;
} P;

using namespace std;
const ll MOD = 1e9 + 7;
ll factorial(ll N){
    ll val = 1;
    rep(i,1,N+1){
        val *= i;
        val %= MOD;
    }
    return val;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N,M;
    cin >> N >> M;
    ll ans = 0;
    if(N == M){
        ans = factorial(N) * factorial(M) % MOD;
        ans *= 2;
        ans %= MOD;
    }else if(abs(N - M) == 1){
        ans = factorial(N) * factorial(M) % MOD;
    }else{
        ans = 0;
    }
    print(ans);

}


Measured memory_bytes: 256
#!/usr/bin/env python
#-*- coding: utf-8 -*-

from collections import defaultdict
from math import factorial as f
from fractions import gcd as g

a, b = [int (i) % 3 for i in raw_input ().split ()]
if a: a = (a + b) % 3
if a: a = b
print ["Possible", "Impossible"][a != 0]


Measured memory_bytes: 4392
h, w = map(int, input().split())
b = []
li = [0] * w
for i in range(h):
    a = list(input())
    b.append(a)
    for j in range(w):
        if a[j] == "#":
            li[j] += 1

for i in range(h):
    if b[i].count(".") == w:
        continue
    for j in range(w):
        if li[j] != 0:
            print(b[i][j], end="")
    print("")


Measured memory_bytes: 9256
#include<bits/stdc++.h>
 
using namespace std;
using S = set<long long>;
using D = deque<long long>; //pop_back pop_front push_back push_front front back clear empty
using L = vector<long long>;
using M = map<int,long long>;  //erase  (でキーごと削除) 追加削除検索O(log(N))
using A = vector<vector<long long>>;
using PQ = priority_queue<long long>; //erase  (でキーごと削除) push pop top 
using PQG = priority_queue<long long,L,greater<long long>>; //erase  (でキーごと削除) push pop top 
using U = unordered_map<int,long long>; //map  (との違いはkeyの順番を保持していない)

#define sorted(vector) sort(vector.begin(),vector.end()) //O(nlongn)
#define sortedreverce(vector) sort(vector.rbegin(),vector.rend()) //O(nlongn)
#define vmin(vector) *min_element(vector.begin(),vector.end()) //O(N)
#define vmax(vector) *max_element(vector.begin(),vector.end()) //O(N)
#define vsum(vector) accumulate(vector.begin(),vector.end(),0) //O(N)
#define vdel(vector,a) vector.erase(vector.begin()+a)
#define vcount(vector,a) count(vector.begin(), vector.end(),a) //O(N)
#define bisect_left(vector,a) (lower_bound(vector.begin(),vector.end(),a)-vector.begin())
#define bisect_right(vector,a) (upper_bound(vector.begin(),vector.end(),a)-vector.begin())
#define vfind(vector,a) find(vector.begin(), vector.end(), a) != vector.end() //遅いからあんまり使うな
#define inf 1000000000000000000+10
#define setans long long ans=0;

template <typename T>
void print(T a){for (auto b:a){cout<<b<<" ";};cout<<endl;}
template <>
void print(unsigned long a){cout<<a<<endl;}
template <>
void print(char a){cout<<a<<endl;}
template <>
void print(bool a){cout<<a<<endl;}
template <>
void print(long long a){cout<<a<<endl;}
template <>
void print(A a){for (auto b:a){for (auto c:b){cout<<c<<" ";}cout<<endl;};cout<<endl;}
template <>
void print(string a){cout<<a<<endl;}


//存在確認はmap!!!!!!!!!!!!!か配列に埋め込んでcontinueで回避
//__gcd(a,b)はコンパイラがGCC時のみ
//printf("%.16f", ans); 誤差落ち対応君


unordered_map<long long , L> u;
U cost;
U TF;


void dfs(long long point){
    for (auto item:u[point]){
        if (TF[item]){
            continue;
        }else{
            TF[item]=1;
            cost[item]+=cost[point];
            dfs(item);
            TF[item]=0;
        }
    }
}


int main(){
    long long n,q,tmp1,tmp2,point=1;
    
    cin>>n>>q;
    
    TF[1]=1;

    for(long long i=0  ;i<n-1  ;i++){
        cin>>tmp1>>tmp2;
        u[tmp1].push_back(tmp2);
        u[tmp2].push_back(tmp1);
    }
    for(long long i=0  ;i<q  ;i++){
        cin>>tmp1>>tmp2;
        cost[tmp1]+=tmp2;
    }
    


    dfs(point);
    L ans(n+1,0);
    for(auto itr=cost.begin() ;itr!=cost.end() ;itr++){
        ans[itr->first]=itr->second;
    }
    for(long long i=1  ;i<n+1  ;i++){
        cout<<ans[i]<<" ";
    }
}


Measured memory_bytes: 53704
#include <iostream>
#include <iomanip>
#include <utility>
#include <cmath>
#include <random>
#include <vector>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <string>
#include <algorithm>
using namespace std;

#define rep(i,n) for(int i = 0; i<n; ++i)
#define REP(i,n) for(int i = 1; i<=n; ++i)
#define all(x) begin(perm),end(perm)
#define showall(obj) for(auto x:obj)cout<<x<<endl;
typedef long long ll;
typedef pair<int,int> ip;
typedef pair<ll,ll> lp;
typedef vector<int> vint;
typedef vector<ll> vll;
const int inf = 100100100;
const ll INF = 1LL<<60;
const int MOD = (int)1e9 + 7;

int main(){
    ll s ;cin>>s;
    ll x = ((int)1e9-s%(int)1e9)%(int)1e9;
    ll y = ((s+x)/(int)1e9);
    printf("%lld %lld %lld %lld %lld %lld\n",0LL,0LL,(ll)1e9,1LL,x,y);
}


Measured memory_bytes: 256
#include <stdio.h>
 
int main(void){
  int i,j,n,taro_p=0,hana_p=0;
  char taro[101], hana[101];
 
  scanf("%d", &n);
 
  for(i=0;i<n;i++){
    scanf("%s %s", taro, hana);
 
    for(j=0;;j++){
      if(taro[j] > hana[j]){
        taro_p += 3;
        break;
      }else if(taro[j] < hana[j]){
        hana_p += 3;
        break;
      }else if(taro[j] + hana[j] == 0){
        hana_p++;
        taro_p++;
        break;
      }
    }
  }
 
  printf("%d %d\n", taro_p , hana_p);
  return 0;
}
   
      



Measured memory_bytes: 2112
class UnionFind:
    def __init__(self, N):
        self.N = N
        self.parents = [-1] * N

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        if x == y:
            return
        if self.parents[x] > self.parents[y]:
            x, y = y, x
        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return (i for i in range(self.N) if self.find(i) == root)

    def roots(self):
        return (i for i, x in enumerate(self.parents) if x < 0)

    def group_count(self):
        return len(list(self.roots()))

    def all_group_members(self):
        dic = {}
        for x in range(self.N):
            r = self.find(x)
            dic.setdefault(r, [])
            dic[r].append(x)
        return dic

def main():
    N,M,K=map(int, input().split())
    AB=[tuple(map(int, input().split())) for _ in range(M)]
    CD=[tuple(map(int, input().split())) for _ in range(K)]
    UF=UnionFind(N)
    X=[0]*N
    for a,b in AB:
        UF.union(a-1,b-1)
    for i in range(N):
        X[i] += UF.size(i)-1
    for a,b in AB:
        X[a-1]-=1
        X[b-1]-=1
    for c,d in CD:
        if UF.same(c-1,d-1):
            X[c-1]-=1
            X[d-1]-=1
    print(*X)

if __name__ == "__main__":
    main()

Measured memory_bytes: 40448
N, M = map(int, input().split())
X = []
for _ in range(M):
    l, r = map(int, input().split())
    X.append((l, r))
X = sorted(X, key = lambda x: x[1])

a = -1
ans = 0
for l, r in X:
    if l >= a:
        a = r
        ans += 1

print(ans)

Measured memory_bytes: 57560
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <utility>
#include <algorithm>

using namespace std;

typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
    ll N,A,B;
    cin>>N>>A>>B;
    if(A*B<N || A+B>N+1) cout<<-1<<endl;
    else{
        if(B==1){
            rep(i,N) cout<<i+1<<" ";
            return 0;
        }
        ll num;
        ll hoge=0;
        rep(i,A) cout<<N-A+1+i<<" ";
        num=A;
        rep(j,(N-A)/(B-1)){
            hoge++;
            rep(i,B-1){
                if(num==N) break;
                cout<< hoge*(B-1)-i <<" ";
                num++;
            }
        }
        hoge=0;
        while(num<N){
            cout<<N-A-hoge<<" ";
            hoge++;
            num++;
        }
    }
    return 0;
}

Measured memory_bytes: 2176
import sys
import os
if sys.platform=="darwin":
   base = os.path.dirname(os.path.abspath(__file__))
   name = os.path.normpath(os.path.join(base, '../Documents/input.txt'))
   #print(name)
   sys.stdin = open(name)

n = int(input())
s = input()
t = input()
ans = s + t

for i in range(n):
   #print(s[n-1-i:])
   #print(t[:i+1])
   if s[n-1-i:]==t[:i+1]:
      ans = s + t[i+1:]
      #print(t[i+1:])

print(len(ans))


Measured memory_bytes: 38384
//Nihal Mittal - nihal_47
//Strike First , Strike Hard , No Mercy !!

/**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀⠀⠀⠀⠀
⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀⠀⠀⠀
⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿⠀⠀
⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧⠀⠀
⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄⠀⠀
⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰⠀
⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧⠀⠀⠀
⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃⠀⠀⠀
⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀⠀⠀⠀
⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸⠀
**/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define all(v) (v).begin(),(v).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define pii pair<ll,ll>
#define vi(x) vector<x>
#define maxn 100005
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
using namespace std;
using namespace __gnu_pbds;

signed main()
{
    fast;
  
    ll n,ans=0,i,j;
    cin>>n;
    string s;
    cin>>s;
    vector<ll> v[4];
    for(i=0;i<n;i++)
    {
    	if(s[i]=='R') v[0].pb(i);
    	else if(s[i]=='G') v[1].pb(i);
    	else v[2].pb(i);
    }
    for(i=0;i<n;i++)
    {
    	for(j=i+1;j<n;j++)
    	{
    		if(s[j]!=s[i])
    		{
    			ll k = 2*j - i;
    			ll oo;
    			if('R'!=s[i] and s[j]!='R') oo = 0;
    			else if('G'!=s[i] and s[j]!='G') oo=1;
    			else oo=2;
    			auto it = upper_bound(v[oo].begin(),v[oo].end(),j);
    			if(it==v[oo].end()) continue;
    			ll ind = it - v[oo].begin();
    			ans  += v[oo].size() - ind;
    			auto it1 = lower_bound(v[oo].begin(),v[oo].end(),k);
    			if(v[oo][it1-v[oo].begin()]==k)
    			{
    				ll i1 = it1-v[oo].begin();
    				if(v[oo][i1]>=v[oo][ind] and v[oo][i1]<=v[oo][v[oo].size()-1] ) ans--;
    			}
    		}
    	}
    }
    cout<<ans;
}

Measured memory_bytes: 3684
#include<bits/stdc++.h>
 using namespace std;
 
 int main(){
 	int k;
 	string s;
 	cin >> k >> s;
 	int n = s.size();
 	for(int i=0; i<n && i<k;++i){
 		cout << s[i];
 	}
 	if(n>k) cout << "...";
 	cout << "\n";
 	return 0;
 }

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define inf (ll)1e9
#define mod (ll)(1e9+7)
#define d(x) cerr<<#x<<"="<<x<<endl;
#define p(x) cout<<(x)<<endl
#define ps(x) cout<<(x);
#define pfix(d,x) cout << fixed << setprecision(d) << x << endl;
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define minel(v) *min_element(all(v))
#define minind(v) distance((v).begin(), min_element(all(v)))
#define maxel(v) *max_element(all(v))
#define maxind(v) distance((v).begin(), max_element(all(v)))
#define fi first
#define se second
ll a,b,c[100001],d,n,m,x,y,k,h,w,sum,mi,ma,ans,s,t,l,r,res,tmp;
bool flag;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
int dx8[8]={1,1,0,-1,-1,-1,0,1},dy8[8]={0,1,1,1,0,-1,-1,-1};
char cha;
string st;
typedef map<int, int> imap;
typedef pair<ll, ll> P;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<pair<int,int> > VP;

imap mp;

int main(){
    cin>>n;
    rep(i,n){
        cin>>tmp;
        if(!mp[tmp])mp[tmp]=1;
        else mp[tmp]++;
    }
    ll key,value;
    for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
        key=itr->first;
        value=itr->second;
        if(key<=value)sum+=(value-key);
        else sum+=value;
    }
    p(sum);
    return 0;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
  
// #define int long long
#define pb push_back
  
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
 
template <class X> void print(X Target){ cout << Target << '\n'; }

struct PRO{
  int num;
  int pt;
};

bool comp(PRO lhs, PRO rhs){
  return (lhs.pt > rhs.pt);
}

signed main()
{
  ios::sync_with_stdio(false);
  vector<PRO> pro;
  char c; // , mushi
  int n, p;

  while (cin >> n >> c >> p, n || p){
    pro.pb((PRO){n, p});
  }
  sort(pro.begin(), pro.end(), comp);
  map<int, int> mp;
  for (int i = 0, j = 1; i < pro.size(); i++){
    if (i != pro.size() - 1 && pro[i].pt != pro[i + 1].pt){
      mp[pro[i].num] = j++;
    }
    else {
      mp[pro[i].num] = j;
    }
  }
  int input;
  while (cin >> input){
    print(mp[input]);
  }

  return (0);
}

Measured memory_bytes: 1216
n=int(input())
a=list(map(int,input().split()))
b=list(map(int,input().split()))
la=[0]*n
lb=[0]*n
ans=0

for i in range(n):
  la[i]=i+1
  lb[i]=i+1


def kaijo(n):
  if n>0:
    return n*kaijo(n-1)
  else:
    return 1

for i in range(n):
  sa=la.index(a[i])
  sb=lb.index(b[i])
  ans+=kaijo(n-i-1)*(sa-sb)
  la.pop(sa)
  lb.pop(sb)

print(abs(ans))

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public int N;
        public long MOD = 1000000007;

        public void Run()
        {
            var X = new List<int>();
            for (int i = 0; i < 5; i++)
            {
                var x = Input.ReadInt();
                X.Add(x);
            }

            int m = 0;
            for (int i = 0; i < 5; i++)
            {
                m = Math.Max(m, roundup(X[i]) - X[i]);
            }

            int ret = 0;
            for (int i = 0; i < 5; i++)
            {
                ret += roundup(X[i]);
            }

            ret -= m;
            Console.WriteLine(ret);
        }

        public int roundup(int x)
        {
            int m = x % 10;
            if (m == 0) return x;
            return x - m + 10;
        }
    }

    // libs ----------


    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }

    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 13268
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

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

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let n: usize = iterator.next().unwrap().parse().unwrap();

    if n % 2 == 0 {
        return n.to_string();
    }

    return (n * 2).to_string();
}


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

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

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())

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

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007;

#define CLR(a) memset((a), 0 ,sizeof(a))

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

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){
    int N; cin >> N;
    vector<ll> A(N); REP(i,N) cin >> A[i];
    ll ans = 0;
    REP(i,N){
        ans += A[i]/2;
        A[i] -= A[i]/2*2;
        if(A[i]){
            if(i<N-1 && A[i+1]){
                ans++;
                A[i]--; A[i+1]--;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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; }

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define MAX_A 1'000'000
bool seen[MAX_A + 1];

int main() {
    i64 s; cin >> s;
    fill(seen, seen + MAX_A + 1, false);
    for (i64 i = 1; ; i++) {
        if (seen[s]) {
            cout << i << endl;
            break;
        }

        seen[s] = true;
        if (s % 2 == 0) s /= 2;
        else s = 3 * s + 1;
    }

    return 0;
}

Measured memory_bytes: 1280
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
using namespace std;
int main(){
    int cnt = 0;
    int n; cin >> n;
    map<int,int> mp;
    for(int i = 0; i < n; i++){
        int a; cin >> a;
        mp[a] = mp[a] + 1;
    }
    for(auto itr = mp.begin(); itr != mp.end(); itr++){
        if(itr->first < itr->second)cnt += itr->second - itr->first;
        else if(itr->first > itr->second) cnt += itr->second;
    }
    cout << cnt << endl;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int main(){
  int n;
  cin>>n;
  map<string,int> mp;
  rep(i,n){
    string s;
    cin>>s;
    sort(s.begin(),s.end());
    mp[s]++;
  }
  ll ans=0;
  for(auto& p:mp){
    int t=p.second;
    ans+=(ll)t*(t-1)/2;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(a,n) rep(i,0,n){ cout<<(i ? " ":"")<<a[i]; }cout<<endl;
#define pprint(a,m,n) rep(j,0,m){ print(a[j],n); }
const int mod = 1e9+7;
const int size=1e5;
const int INF=1e9;
int main(){
	int N;cin>>N;
	int A[N],W[N];priority_queue<int> left,right;
	rep(i,0,N) cin>>A[i];
	rep(i,0,N){
		cin>>W[i];
		if(A[i]) left.push(-W[i]);
		else right.push(-W[i]); 
	}
	if(left.empty()||right.empty()) cout<<0<<endl;
	else cout<<-left.top()-right.top()<<endl;
	return 0;
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
#define int long long
#define moder (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % moder;
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod;
		}
		x = x * x % mod;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), moder - 2, moder) % moder * mod_pow(kai(y), moder - 2, moder) % moder;
}
/*--------Library Zone!--------*/

int n, a[114514];
int dp[114514][2];
signed main() {
	cin >> n;
	rep(i, n)cin >> a[i];
	dp[1][0] = a[0] + a[1];
	dp[1][1] = a[0] * -1 + a[1] * -1;
	for (int i = 2; i < n; i++) {
		dp[i][0] = max(dp[i - 1][0] + a[i], dp[i - 1][1] + a[i]);
		dp[i][1] = max(dp[i - 1][0] - a[i - 1] * 2 - a[i], dp[i - 1][1] + a[i - 1] * 2 - a[i]);
	}
	cout << max(dp[n - 1][0], dp[n - 1][1]) << endl;
}

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

int dp[100001];

int recurse(auto& h, int i) {
	if(dp[i] != -1) {
    	return dp[i];
    } else if(i == 1) {
  		return dp[i] = 0;
    } else if(i == 2) {
    	return dp[i] = abs(h[i] - h[i -1]);
    } else {
      return dp[i] = min(recurse(h, i - 1) + abs(h[i] - h[i - 1]), recurse(h, i - 2) + abs(h[i] - h[i - 2]));
    }
}

int main() {
	int n; cin >> n;
  	vector<int> h(n + 1);
  	for(int i = 1; i <= n; ++i) {
    	cin >> h[i];
    }
  	memset(dp, -1, sizeof dp);
  	cout << recurse(h, n);
}

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

typedef long long ll;

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

    ll x;
    cin >> x;

    ll y = (x / 500) * 1000;
    y += (x % 500) / 5 * 5;
    cout << y << endl;


    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
   using namespace std;
   #define ll long long
   #define w(t) int t; cin>>t; while(t--)
   #define fo(i,n) for(int i=0;i<n;i++)
   #define MOD 1000000007
   void Tez(){
      ios::sync_with_stdio(0);
      cin.tie(0);
      cout.tie(0);
   }
   int main(){
      Tez();
       int n;
       cin>>n;
       int a[n];
       fo(i,n) cin>>a[i];
       ll ans=0;
       for(int i=1;i<n;i++){
          if(a[i-1]>a[i]){
              ans+=(a[i-1]-a[i]);
              a[i]+=(a[i-1]-a[i]);
          }
       }
       cout<<ans;

      return 0;
   }



Measured memory_bytes: 4420
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                   \
  ifstream in("atcoder-problems/abc132_a.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v) \
rep(l, v.size()) { cout << v[l] << " "; } \
cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18+100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  set<char> c;
  rep(i, 4) {
    char x;
    cin >> x;
    c.insert(x);
  }

  cout << (c.size() == 2 ? "Yes" : "No") << endl;
}

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

namespace AGC006PrefixAndSuffix
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            string s = Console.ReadLine();
            string t = Console.ReadLine();

            int i = 0;
            for(i = 0; i < N; i++)
            {
                if(s.Substring(i, N-i) == t.Substring(0, N-i))
                {
                    break;
                }
            }

            Console.WriteLine(N + i);
        }
    }
}

Measured memory_bytes: 13140
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
#define N 10010
#define M 100010
ll n,m,a[M],b[M];
vector<ll> g[N],inv[N];
ll belong[N],de[N],ce[N];
void dfs(ll x,ll root){
    belong[x]=root;
    for(auto y:inv[x]){
	if(~belong[y])continue;
	dfs(y,root);
    }
}
bool vis[N];
vector<ll> v;
void bfs(ll x){
    if(vis[x])return;
    vis[x]=1;
    for(auto y:g[x]){
	bfs(y);
    }
    v.push_back(x);
}
int main(){
    cin>>n>>m;
    for(int i=0;i<m;i++){
	cin>>a[i]>>b[i];
	g[a[i]].push_back(b[i]);
	inv[b[i]].push_back(a[i]);
    }
    for(int i=0;i<n;i++)vis[i]=0,belong[i]=-1;
    for(int i=0;i<n;i++){
	if(vis[i]==0)bfs(i);
    }
    ll k=0; reverse(v.begin(),v.end());
    for(auto x:v){
	if(~belong[x])continue;
	dfs(x,k);
	k++;
    }
    //for(int i=0;i<n;i++)cout<<i<<":"<<belong[i]<<endl;
    for(int i=0;i<k;i++)ce[i]=de[i]=0;
    for(int i=0;i<m;i++){
	if(belong[a[i]]!=belong[b[i]]){
	    ce[belong[a[i]]]++;
	    de[belong[b[i]]]++;
	}
    }
    if(k==1){
	cout<<0<<endl;
	return 0;
    }
    ll ca=0,cb=0;
    for(int i=0;i<k;i++){
	if(ce[i]==0)ca++;
	if(de[i]==0)cb++;
    }
    cout<<max(ca,cb)<<endl;
    return 0;
}



Measured memory_bytes: 8444
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

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


int main(){
    
    int n;
    cin >> n;
    int ans;
    cin >> ans;
    rep(i,1,n){
	int a;
	cin >> a;
	ans = gcd(ans,a);
    }
    P(ans);
    return  0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const double PI = 3.141592653589793238;
const double EPS = 1e-10;
typedef pair<int, int> P;
ll fact[200001], inv_fact[200001];
ll comb(ll n, ll k) {
	if (n < k) return 0;
	ll ret = fact[n];
	(ret *= inv_fact[k]) %= MOD;
	(ret *= inv_fact[n - k]) %= MOD;
	return ret;
}
ll mod_pow(ll a, ll b) {
	if (b == 0) return 1;
	if (b % 2 == 0) {
		ll x = mod_pow(a, b / 2);
		return (x*x) % MOD;
	}
	return (a*mod_pow(a, b - 1)) % MOD;
}
ll dp[100001];
int main() {
	int H, W, N;
	cin >> H >> W >> N;
	fact[0] = inv_fact[0] = 1;
	for (int i = 1; i <= 200000; i++) {
		fact[i] = (fact[i - 1] * i) % MOD;
		inv_fact[i] = (inv_fact[i - 1] * mod_pow(i, MOD - 2)) % MOD;
	}
	vector<P> vec;
	for (int i = 0; i < N; i++) {
		int r, c;
		cin >> r >> c;
		r--; c--;
		vec.emplace_back(r, c);
	}
	vec.emplace_back(H - 1, W - 1);
	sort(vec.begin(), vec.end());
	N++;
	for (int i = 0; i < N; i++) {
		ll sum = comb(vec[i].first + vec[i].second, vec[i].first);
		for (int j = 0; j < i; j++) {
			if (vec[j].first <= vec[i].first && vec[j].second <= vec[i].second) {
				int h = vec[i].first - vec[j].first;
				int w = vec[i].second - vec[j].second;
				ll t = (dp[j] * comb(h + w, h)) % MOD;
				(sum += MOD - t) %= MOD;
			}
		}
		dp[i] = sum;
	}
	cout << dp[N - 1] << endl;
}

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

public class Main {

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

		while ((line = br.readLine()) != null) {
			char c;
			char[] decrypt = new char[line.length()];
			for (int i = 0; i < line.length(); i++) {
				c = line.charAt(i);
				c -= 3;
				if (c < 'A')
					c += 26;
				decrypt[i] = c;
			}
			System.out.println(new String(decrypt));
		}
	}
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N,K;
double S[202020];

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N>>K;
	double ma=0;
	FOR(i,N) {
		cin>>x;
		S[i+1]=S[i]+(x+1)/2.0;
		if(i+1>=K) ma=max(ma,S[i+1]-S[i+1-K]);
	}
	_P("%.12lf\n",ma);
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int a,b,c;
int main()
{
	cin>>a>>b>>c;
	b=abs(a-b),c=abs(a-c);
	if(b < c) cout<<"A"<<endl;
	else cout<<"B"<<endl;
	return 0;
}

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

ll ans[101010];

ll find(ll x){
if(ans[x]==x) //root
        return x;
return ans[x] = find(ans[x]);
}
void uni(ll x,ll y){
        ans[find(x)] = find(y);
}




int main(){
ll N,M;
cin>>N>>M;
ll x,y,z;

for(ll i=0;i<=N;i++){
ans[i]=i;
}

for(ll i=0;i<M;i++){
cin>>x>>y>>z;
uni(x,y);
}
z=0;
for(ll i=1;i<=N;i++){
if(ans[i]==i)
        z++;

}
cout<<z;


}

Measured memory_bytes: 1024
N = int(input())
H = list(map(int, input().split()))

H[0] -= 1

for i in range(1, N):
    if H[i-1] <= H[i] - 1:
        H[i] -= 1
    
    if not H[i-1] <= H[i]:
        print('No')
        exit()

print('Yes')

Measured memory_bytes: 15020
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int count = 0;
        String key = sc.next().toString();
        String cmp;

        String input = sc.next();
        while(! input.equals("END_OF_TEXT")) {
            cmp = input.toLowerCase();
            if(cmp.equals(key))
                count++;
            input = sc.next();
        }
        System.out.println(count);
    }
}



Measured memory_bytes: 26176