akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; ++i)
#define REPR(i, n) for (int i = n - 1; i >= 0; --i)
#define FOR(i, a, b) for (int i = a; i < b; ++i)
#define FORR(i, a, b) for (int i = b - 1; i >= a; --i)
#define SORT(v) sort(v.begin(), v.end())
#define SORTR(v) sort(v.rbegin(), v.rend())
#define REV(v) reverse(v.begin(), v.end())
#define ITER(itr, v) for (auto itr = v.begin(); itr != v.end(); ++itr)
#define LB(v, x) (lower_bound(v.begin(), v.end(), x) - v.begin())
#define UB(v, x) (upper_bound(v.begin(), v.end(), x) - v.begin())
#define SZ(v) (int)v.size()
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

	int N;
	string S;
	cin >> N >> S;
	int res = 0;
	REP(i, 10) {
		int l = 0;
		while (l < N && S[l] != i + '0') ++l;
		if (l == N) continue;
		REP(j, 10) {
			int m = l + 1;
			while (m < N && S[m] != j + '0') ++m;
			if (m == N) continue;
			REP(k, 10) {
				int r = m + 1;
				while (r < N && S[r] != k + '0') ++r;
				if (r == N) continue;
				++res;
			}
		}
	}
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    bool ans =false;
    for(int i=0; i<3; ++i){
        if(s.at(i) == s.at(i+1)) ans=true;
    }

    if(ans) cout << "Bad" << endl;
    else    cout << "Good" << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;

/*
色が連続してる部分はまとめても良い
*/

ll n,mod=1e9+7,ans=1,before=0,dp[200010]={};
vector<ll> c;
string s;

int main(void){
	cin>>n;
	rep(i,n){
		ll d;
		cin>>d;
		if(d!=before){
			before=d;
			c.push_back(d);
		}
	}
	//
	dp[0]=1;
	rep(i,c.size()){
		ll d = (dp[c[i]]+dp[0]) % mod;
		dp[0]=(dp[0]+dp[c[i]]) % mod;
		dp[c[i]] = d;
	}
	//
	cout<<dp[0]<<endl;
	return 0;
}

Measured memory_bytes: 4200
A,B = map(int,input().split())

ans = 0
a = 0
b = 0
for i in range(41):
    j = 40-i
    if (A-1)&(1<<j):
        a = j
        break

for i in range(41):
    j = 40-i
    if B&(1<<j):
        b = j
        break

def bit(N,n,bi):
    if bi==0:
        return (N+1)//2
    if N==-1 or (n<bi):
        return 0
    num = 0
    c = 0
    for i in range(bi+1):
        if N&(1<<i):
            num += (1<<i)
    c += max(num-((1<<bi)-1),0)
    c += (n-bi)*((1<<(bi)))
 #   print(N,bi,num,c)
    return c


for i in range(b+1):
    j = b-i
    c = 0
    c = bit(B,b,j)-bit(A-1,a,j)
    if c%2==1:
        ans += (1<<j)
print(ans)
    

Measured memory_bytes: 3064
N,M,K = map(int,input().split())
AB = [list(map(int,input().split())) for i in range(M)]
CD = [list(map(int,input().split())) for i in range(K)]

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(self.roots())
    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}
    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

uf = UnionFind(N)
for i in range(M):
    uf.union(AB[i][0]-1,AB[i][1]-1)
pot = [uf.size(i)-1 for i in range(N)]
for i in range(M):
    A,B = AB[i][0],AB[i][1]
    if uf.find(A-1) == uf.find(B-1):
        pot[A-1] -= 1
        pot[B-1] -= 1
for i in range(K):
    C,D = CD[i][0],CD[i][1]
    if uf.find(C-1) == uf.find(D-1):
        pot[C-1] -= 1
        pot[D-1] -= 1
print(*pot)

Measured memory_bytes: 62124
use proconio::input;

fn main() {
    input! {
        n: usize,
        xs: [usize; n-1],
    }
    let mut counts = vec![0;n];
    for x in xs {
        counts[x-1] += 1;
    }
    counts.iter().for_each(|n| { println!("{}", n); });
}

Measured memory_bytes: 5540
function main()
	lines=readlines()
	H,W=map(x->parse(Int,x),split(shift!(lines)))
	A=[map(x->parse(Int,x),split(s)) for s=lines]
	x=y=1
	d=1
	S=Array{Tuple{Int,Int,Int,Int}}(0)
	while true
		tx=x
		ty=y+d
		if ty<1||ty>W
			d*=-1
			ty=y
			tx+=1
		end
		if tx>H
			break
		end
		if A[x][y]%2==1
			push!(S,(x,y,tx,ty))
			A[tx][ty]+=1
		end
		x,y=tx,ty
	end
	println(length(S))
	for t=S
		println(join(t,' '))
	end
end
main()


Measured memory_bytes: 158060
a,b,k = gets.chomp.split(/\s/).map{|x| x.to_i}

j = 0
for i in 1..k
    a -= 1 unless a % 2 == 0
    a = a/2
    b += a

    j += 1
    break if j >= k

    b -= 1 unless b % 2 == 0
    b = b/2
    a += b

    j += 1
    break if j >= k
end

print "#{a} #{b}\n"

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

using namespace std;


int arr[200005];

int  main() {
	int n,k;
	cin >> n >> k;
	for(int i=0;i<n;i++){
		int a;
		cin >> a;
		arr[a]++;
	}
	int count=0;
	for(int i=1;i<=n;i++){
		if(arr[i]!=0)
			count++;
	}
	if(count-k<=0)
		cout << 0;
	else{
		sort(arr,arr+n+1);
		int ind=count-k;
		int ans=0,i=0;
		while(arr[i]==0)
			i++;
		ind+=i;
		for(i;i<ind;i++)
			ans+=arr[i];
		cout << ans;
	}

}

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

int main() {
	int n, k, m;
	while(cin >> n >> k >> m && (n || k || m)){
		vector<int> vec;
		for(int i = 1; i <= n; ++i)
			vec.push_back(i);
		
		unsigned int now = m - 1;
		while(vec.size() > 1){
			vec.erase(vec.begin() + now);
			now = (now + k - 1) % vec.size();
		}
		cout << vec[0] << endl;
	}
	return 0;
}

Measured memory_bytes: 1320
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

int main()
{
	int a, b;
	scanf("%d%d", &a, &b);
	int diff = a - b * 2;
	if (diff < 0)
		diff = 0;
		
	printf("%d\n", diff);
	
	return 0;
}


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

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

    int n;
    cin >> n;
    vi x(n);
    rep(i, n) cin >> x[i];
    int ans = 1001001001;
    rep1(p, 100) {
        int now = 0;
        rep(j, n) now += (x[j] - p) * (x[j] - p);
        ans = min(ans, now);
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
N,Y=input().split()
N=int(N)
Y=int(Y)
def roop():
    for a in range(N+1):
        a_amount=10000*a
        for b in range(N+1-a):
            b_amount=5000*b
            c=N-a-b
            c_amount=1000*c
            amount_tot=a_amount+b_amount+c_amount
            X=[a,b,c]
            if Y==amount_tot and a+b+c==N:
                return X
    return -1,-1,-1
roop()
ans=roop()
print(' '.join(map(str,ans)))

Measured memory_bytes: 9180
#include <iostream>
#include <vector> 
#include <cmath>
#include <algorithm>
#include <set>
#include <map>
#include <cerrno>
#include <cfenv>
#include <math.h>
#include <iomanip>
#include <limits>
#include <queue>
#define ll long long int
#define pb push_back
#define mp make_pair

using namespace std;

int d1[] = {-1,0,1,0};
int d2[] = {0,-1,0,1};

int main(){

    int n;

    while(1){

        cin >> n;

        if(n == 0){
            break;
        }
        int x[200];
        int y[201];
        x[0] = 0;
        y[0] = 0;
        int ni,di;
        int xmax,xmin,ymin,ymax;
        xmax = xmin = ymin = ymax = 0;
        
        for(int i=1;i<n;i++){
            cin >> ni >> di;
            x[i] = x[ni] + d1[di];
            y[i] = y[ni] + d2[di];
            if(x[i]>xmax)xmax = x[i];
            if(x[i]<xmin)xmin = x[i];
            if(y[i]>ymax)ymax = y[i];
            if(y[i]<ymin)ymin = y[i];
        }
        
        cout << xmax - xmin + 1 << " " << ymax - ymin + 1 << endl;
    }
  
    return 0;
}


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define mem(a,x) memset(a,x,sizeof(a))
#define rep(i, x, y) for (decay<decltype(y)>::type i = (x), _##i = (y); i <= _##i; ++i)
#define repd(i, x, y) for (decay<decltype(y)>::type i = (x), _##i = (y); i >= _##i; --i)
#define debug(x...) printf("["#x"]="),print(x);
#define ios ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fcout cout<<setprecision(4)<<fixed
using namespace std;
typedef long long ll;
//======================================
namespace FastIO{
char print_f[105];void read() {}void print() {putchar('\n');}
template <typename T, typename... T2>
inline void read(T &x, T2 &... oth){x = 0;char ch = getchar();ll f = 1;while (!isdigit(ch)){if (ch == '-')f *= -1;ch = getchar();}while (isdigit(ch)){x = x * 10 + ch - 48;ch = getchar();}x *= f;read(oth...);}
template <typename T, typename... T2>
inline void print(T x, T2... oth){ll p3=-1;if(x<0) putchar('-'),x=-x;do{print_f[++p3] = x%10 + 48;}while(x/=10);while(p3>=0) putchar(print_f[p3--]);if(sizeof...(T2)) putchar(' ');print(oth...);}} // namespace FastIO

using FastIO::print;
using FastIO::read;
//======================================
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
const int maxn = 1e6+5;

ll fx(ll x,ll mod){
    x%=mod;
    return x*x%mod;
}
ll a[maxn],sum[maxn];
ll n,m;
unordered_map<int,int>mp;
ll get(int l,int r){
    if(l>r) return 0;
    return sum[r]-sum[l-1];
}
ll ans=0;
void solve(){
    ll last,net;
    for(ll i=2;;i++){
        a[i]=fx(a[i-1],m);
        sum[i]=sum[i-1]+a[i];
        if(mp.count(a[i])){
            last=mp[a[i]];
            net=i-1;
            break;
        }
        mp[a[i]]=i;
    }
    // debug(net,last)
    ll len=net-last+1;
    ans=get(1,last-1)+(n-last+1)/len*get(last,net)+get(last,(last+(n-last+1)%len-1));
}
int main() {
#ifndef ONLINE_JUDGE
    freopen("H:\\code\\in.in", "r", stdin);
    freopen("H:\\code\\out.out", "w", stdout);
    clock_t c1 = clock();
#endif
//**************************************
    read(n,a[1],m);
    sum[1]=a[1];
    mp[a[1]]=1;
    solve();
    print(ans);
//**************************************
    
#ifndef ONLINE_JUDGE
    cerr << "Time:" << clock() - c1 << "ms" << endl;
#endif
    return 0;
}


Measured memory_bytes: 5948
#include<bits/stdc++.h>
using namespace std;
#define int unsigned long long
int vec[200005];

int32_t main()
{
   int n,k;
   cin>>n>>k;


   vec[0]=1;
   vector<int>res;

   int a, ans=1;

   for(int i=1; i<=n; i++){
      cin>>vec[i];
   }


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

      //cout<<i<<" "<<i-k<<endl;
      if(vec[i]>vec[i-k]) cout<<"Yes"<<endl;
      else cout<<"No"<<endl;
   }




    return 0;
}


Measured memory_bytes: 5152
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
x = I()
div = x // 11
ans = div * 2
x -= div * 11
if x > 6:
    ans += 2
elif x >= 1:
    ans += 1
else:
    ans += 0
print(ans)


Measured memory_bytes: 10400
from collections import Counter
n = int(input())
C = [Counter(input()) for _ in range(n)]
dic = {}
for key in C[0]:
    dic[key] = C[0][key]
for c in C[1:]:
    dl = []
    for key in dic:
        if key in c:
            dic[key] = min(dic[key], c[key])
        else:
            dl.append(key)
    for key in dl:
        del dic[key]
dic = sorted(dic.items(), key = lambda x: x[0])
ans = ''
for x in dic:
    ans += x[0] * x[1]
print(ans)

Measured memory_bytes: 39664
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;
import java.util.function.IntToDoubleFunction;
import java.util.stream.Collectors;
import java.util.stream.Stream;
 
/**
 * @author yoshizaki
 *
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner= new Scanner(System.in);
        scanner.nextLine();
        List<Double> values = new ArrayList<Double>();
        String[] valueString = scanner.nextLine().split(" ");
        Stream<String> stream = Arrays.stream(valueString);
        values = stream.map(v -> Double.parseDouble(v)).collect(Collectors.toList());
        Collections.sort(values);
        Double ans = values.stream().reduce(values.get(0), (val, elm) -> (val + elm)/2);
        System.out.println(ans);
    }
}

Measured memory_bytes: 29268
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    ll d = b - a;
    if (d % 2 == 0) {
        cout << d / 2 << endl;
    } else {
        ll x = min(n - a, b - 1);
        ll y = min(a - 1, n - b) + 1 + (d - 1) / 2;
        cout << min(x, y) << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.util.*;

public class Main {
    static Input in = new Input(System.in);
    static PrintWriter out = new PrintWriter(System.out);

    public static void main(String[] args) {
        long N = in.nextLong();

        String ans = "";
        while (N != 0) {
            long n = (N - 1) % 26 + 1;
            char c = (char) ('a' - 1 + n);
            ans = c + ans;
            N -= n;
            N /= 26;
        }
        out.println(ans);

        out.flush();
    }

    static class Input {
        private BufferedReader br;
        private String[] buff;
        private int index = 0;

        Input(InputStream is) {
            br = new BufferedReader(new InputStreamReader(is));
        }
        String nextLine() {
            try {
                return br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return null;
        }
        String next() {
            while (buff == null || index >= buff.length) {
                buff = nextLine().split(" ");
                index = 0;
            }
            return buff[index++];
        }
        byte nextByte() {
            return Byte.parseByte(next());
        }
        short nextShort() {
            return Short.parseShort(next());
        }
        int nextInt() {
            return Integer.parseInt(next());
        }
        long nextLong() {
            return Long.parseLong(next());
        }
        float nextFloat() {
            return Float.parseFloat(next());
        }
        double nextDouble() {
            return Double.parseDouble(next());
        }
        BigInteger nextBigInteger() {
            return new BigInteger(next());
        }
        BigDecimal nextBigDecimal() {
            return new BigDecimal(next());
        }
    }
}



Measured memory_bytes: 37268
#include<iostream>
#include<cstdio>
#include<cmath>
#include<stdio.h>
using namespace std;
int main(){
    double a, b, c, C, S, L, h;
    double PI = acos(-1);
    cin >> a >> b >> C;
    double rad = C * PI/180;
    
    S = 0.5 * a * b * sin(rad);
    c = sqrt(pow(a,2) + pow(b,2) - 2*a*b*cos(rad));
    L = a + b + c;
    h = S * 2 * 1/a;
    
    printf("%.5f %.5f %.5f\n", S, L, h);
    
    return 0;
}


Measured memory_bytes: 3428
import scala.collection.mutable

object Main extends App {
  import scala.io.StdIn._
  solve
  def solve: Unit = {
    val Array(n, m, p) = readLine.trim.split(' ').map(_.toInt)
    if (n == 0) return
    val edges = Array.tabulate(n){_ ⇒ Nil: List[(Int, Int)]}
    for (_ ← 0 until m){
      val Array(u, v, w) = readLine.trim.split(' ').map(_.toInt)
      edges(u) ::= (v, w)
      edges(v) ::= (u, w)
    }
    val children = Array.tabulate(p){_ ⇒ readInt}
    solve(edges, children)
    println()
    solve
  }
  def solve(array: Array[List[(Int, Int)]], children: Array[Int]): Unit = {
    val minCost = Array.tabulate(array.length){_ ⇒ Int.MaxValue}.also(a ⇒ a(0) = 0)
    val queue = mutable.PriorityQueue()(Ordering.by[(Int, Int), Int](_._2).reverse).also(q ⇒ q.enqueue((0, 0)))
    val prevEdges = Array.tabulate(array.length){_ ⇒ Nil: List[Int]}
    while (queue.nonEmpty) {
      val (current, cost) = queue.dequeue()
      if (minCost(current) == cost){
        for ((next, c) ← array(current)){
          if (minCost(next) > cost + c) {
            minCost(next) = cost + c
            prevEdges(next) = List(current)
            queue.enqueue((next, minCost(next)))
          }else if (minCost(next) == cost + c){
            prevEdges(next) ::= current
          }
        }
      }
    }
    val prevPath = Array.tabulate(array.length){_ ⇒ 0D}.also(a ⇒ a(0) = 1)
    val nextPath = Array.tabulate(array.length){_ ⇒ 0D}.also(a ⇒ a(a.length - 1) = 1)
    val nextEdges = Array.tabulate(array.length){_ ⇒ Nil: List[Int]}
    for (next ← prevEdges.indices){
      for (prev ← prevEdges(next)){
        nextEdges(prev) ::= next
      }
    }
    def calPrevPath(current: Int): Unit = {
      for (prev ← prevEdges(current)) {
        calPrevPath(prev)
        prevPath(current) += prevPath(prev)
      }
      prevEdges(current) = Nil
    }
    def calNextPath(current: Int): Unit = {
      for (next ← nextEdges(current)){
        calNextPath(next)
        nextPath(current) += nextPath(next)
      }
      nextEdges(current) = Nil
    }
    calPrevPath(array.length - 1)
    calNextPath(0)
    val wholePath = prevPath.last
    println(children.map(i ⇒ prevPath(i) * nextPath(i).toDouble / wholePath).mkString("\n"))
  }
  implicit class Scope[T](val value: T) extends AnyVal {
    @inline def also(@inline func: T ⇒ Unit): T = {
      func(value)
      value
    }
    @inline def let[A](@inline func: T ⇒ A): A = func(value)
  }
}


Measured memory_bytes: 65748
#include <iostream>
#include<cmath>
using namespace std;
int main()
{
    long long n,k,x,cnt=0;
    cin>>n>>k;
    
    if(k==0)cout<<n*n<<endl;
    else
    {
        for(long long i=k+1;i<=n;i++)
        {
            x=n/i;
            cnt+=x*(i-k);
            if(n%i>=k)cnt+=n%i+1-k;
        }
        cout<<cnt<<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 a, b;
  cin >> a >> b;
  int ans = a + b;
  if(ans > 23) ans -= 24;
  
  cout << ans << endl;
  return 0;
  
}

Measured memory_bytes: 256
// includes
#include <cstdio>
#include <cstdint>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <functional>
#include <cmath>
#include <climits>
#include <bitset>

// macros
#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue
#define FOR(i, a, b) for(int i=(a); i<(b);++i)
#define rep(i, n) FOR(i, 0, n)

using namespace std;

//  types
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
 
// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;

// solve
typedef struct UnionFind_ {
	vector<int> par;
	vector<int> rank_;
	UnionFind_(int n): rank_(n, 0) {
    for(int i = 0; i < n; i++)par.push_back(i);
	}
	int find(int x) {
    if(par[x] == x)return x;
    else return par[x] = find(par[x]);
	}
	bool same(int x, int y) {
    if(find(x) == find(y))return true;
    else return false;
	}
	bool unite(int x, int y){
    int xp = find(x);
    int yp = find(y);
    if(xp == yp)return false;
    if(rank_[xp] > rank_[yp])par[yp] = xp;
    else if(rank_[xp] < rank_[yp])par[xp] = yp;
    else {
      par[yp] = xp;
      rank_[xp]++;
    }
    return true;
	}
} UnionFind;

int main(int argc, char const* argv[])
{
  int n, m;
  cin >> n >> m;
  vector<ll> a(n);
  rep(i, n)cin >> a[i];
  UnionFind uf(n);
  rep(i, m){
    int x, y;
    cin >> x >> y;
    uf.unite(x, y);
  }
  unordered_map<int , int> mp;
  rep(i, n){
    if(uf.find(i) == i){
      int tmp = mp.size();
      mp[i] = tmp;
    }
  }
  vector<vector<P> > vec(mp.size());
  rep(i, n){
    vec[mp[uf.find(i)]].pb(mk(a[i], i));
  }
  if(vec.size() == 1){
    cout << 0 << endl;
    return 0;
  }
  vector<bool> used = vector<bool>(n, false);
  ll res = 0;
  rep(i, vec.size()){
    sort(vec[i].begin(), vec[i].end());
    res += vec[i][0].first;
    used[vec[i][0].second] = true;
  }
  vector<P> v;
  rep(i, n)v.pb(mk(a[i], used[i]));
  sort(v.begin(), v.end());

  int j = 0;
  rep(i, n){
    if(2 * vec.size() == j + vec.size() + 2){
      cout << res << endl;
      return 0;
    }
    if(v[i].second)continue;
    res += v[i].first;
    j++;
  }
  if(2 * vec.size() == j + vec.size() + 2){
    cout << res << endl;
  }else cout << "Impossible" << endl;

	return 0;
}


Measured memory_bytes: 12944
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
	string s,t;	cin>>s>>t;
	vector<int> ss(s.size()+1,0),tt(t.size()+1,0);
	for(int i=0;i<s.size();i++){
		if(s[i]=='A')	ss[i+1]=ss[i]+1;
		else 	ss[i+1]=ss[i]+2;
	}
	for(int i=0;i<t.size();i++){
		if(t[i]=='A')	tt[i+1]=tt[i]+1;
		else 	tt[i+1]=tt[i]+2;
	}
	int q;	cin>>q;
	for(int i=0;i<q;i++){
		int a,b,c,d;	cin>>a>>b>>c>>d;
		a--;	c--;
		int ns=ss[b]-ss[a];
		int nt=tt[d]-tt[c];
		if(ns%3==nt%3)	cout<<"YES"<<endl;
		else 	cout<<"NO"<<endl;
	}
	return 0;
}


Measured memory_bytes: 1664
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using static System.Console;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        int N = ReadLineParseInt();
        int[] A = ReadLineParseIntArray();
        int sum = 0;
        int min = int.MaxValue;
        for(int i = -100; i <= 100; i++)
        {
            for(int j = 0; j < N; j++)
            {
                sum += Power(A[j] - i, 2);
            }
            min = Min(min, sum);
            sum = 0;
        }
        WriteLine(min);
    }

    static int ReadLineParseInt() => int.Parse(ReadLine());
    static int[] ReadLineParseIntArray() => ReadLine().Split(' ').Select(int.Parse).ToArray();
    static int Power(int _base, int _index)
    {
        int ans = 1;
        for(int i = 0; i < _index; i++)
        {
            ans *= _base;
        }
        return ans;
    }
}

Measured memory_bytes: 13396
#define f first
#define s second
#include<bits/stdc++.h>
using namespace std;

int main(){
  int n;cin>>n;
  vector<pair<long double,long double>> v;
  vector<int> p;
  for(int i=0;i<n;i++){
    long double a,b;
    cin>>a>>b;
    v.push_back({a,b});
    p.push_back(i);
  }
  long double sum=0;
  long double fact=0;
  do{
    for(int i=0;i<n-1;i++){
        long double x=v[p[i]].f-v[p[i+1]].f;
        long double y=v[p[i]].s-v[p[i+1]].s;
        sum+=sqrt(x*x+y*y);
    }
    fact+=1;
  }while(next_permutation(p.begin(),p.end()));
  //cout<<fact<<" "<<sum<<endl;
  cout<<setprecision(20)<<sum/fact;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
#include <queue>
using namespace std;
int main() {
	int n;
    cin >> n;
    int answer = 0;
    for(int i = 1; i <= n; i+=2){
        int counter = 0;
        for(int j = 1; j <= i; j++){
            if(i%j == 0){
                counter = counter+ 1;
            }
        }
        if(counter == 8){
            answer = answer + 1;
        }
    }
    cout << answer << endl;
}

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

#define ll long long
#define ld long double
#define ft first
#define sd second
#define pb push_back
using namespace std;
const ll mod = 1e9+7;

ll power(ll a, ll b, ll m = mod) {
    ll x = 1;
    while(b) {
        if(b & 1) {
            x = 1ll * x * a % m;
        }
        a = 1ll * a * a % m;
        b /= 2;
    }
    return x;
}

const int N = 1e6+9;
// int a[N];

signed main() {  
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);    
    
    int r; cin >> r;
    cout << r * r << endl;
    
    
    


    return 0;
    
}


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

#define int long long
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define rf(i,n,a) for(int i=n ; i>=a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()
#define fast ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)

typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;

const int inf = 1e9;
const int inf64 = 1e18;
const int MOD = inf + 7;

int fun(int n){
   int res = 0;
   for(int i=1 ; i<=n ; i++){
      if(i * (i + 1) / 2 <= n) res= i;
   }
   return res;
}
int32_t main(){
   fast;
   int n;
   cin >> n;
   int ans = 0;
   for(int i=2 ; i*i<=n ; i++){
      if(n % i == 0){
         int cnt = 0;
         while(n % i == 0) cnt++ , n /= i;
         ans += fun(cnt);
      }
   }
   if(n > 1) ans++;
   cout << ans << "\n";
}

Measured memory_bytes: 3652
/* package codechef; // don't place package name! */

import java.util.*;
import java.lang.*;
import java.io.*;

/* Name of the class has to be "Main" only if the class is public. */
public class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
		int maxWeight = scn.nextInt();
		int[][] itemvaw = new int[n+1][2];
		
		for(int i=1;i<=n;i++){
		    itemvaw[i][0] = scn.nextInt();
		    itemvaw[i][1] = scn.nextInt();
		}
		System.out.println(knapsack_dp(itemvaw,maxWeight));
	}
	
	public static long knapsack_dp(int[][] itemvaw, int capacity) {
		int n = itemvaw.length - 1;
		long[][] memo = new long[n + 1][capacity + 1];
		for (int cii = n; cii > 0; cii--) {
			for (int capacityLeft = capacity; capacityLeft > 0; capacityLeft--) {
				if (cii == n) {
					memo[cii][capacityLeft] = capacityLeft >= itemvaw[cii][0] ? itemvaw[cii][1] : 0;
					continue;
				}
				long o1 = capacityLeft - itemvaw[cii][0] >= 0 ?
				          itemvaw[cii][1] + memo[cii + 1][capacityLeft - itemvaw[cii][0]] : Integer.MIN_VALUE;
				// knapsack_memoized(cii + 1, itemvaw, capacityLeft - itemvaw[cii][0], memo)
				long o2 = memo[cii + 1][capacityLeft];
				// knapsack_memoized(cii + 1, itemvaw, capacityLeft, memo);
				memo[cii][capacityLeft] = Math.max(o1, o2);
			}
		}
		return memo[1][capacity];
	}
}


Measured memory_bytes: 140800
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  ll N;
  cin >> N;
  int a[3*N];
  for(int i=0;i<3*N;i++){
    cin >> a[i];
  }
  sort(a,a+3*N);
  ll ans=0;
  for(int i=N;i<3*N;i+=2){
    ans+=a[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <sstream>
#include <queue>
#include <deque>
#include <bitset>
#include <iterator>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <functional>
#include <numeric>
#include <utility>
#include <limits>
#include <time.h>
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
//#include <bits/stdc++.h>

#define ll long long int
#define pb push_back
#define llu unsigned long long int
#define fo(i,n) for(int i=0;i<n;i++)
#define eb emplace_back
#define M 1000000007
#define vi vector<int>
#define vlli vector<lli>
#define pi pair<int,int>
#define mp make_pair
#define mapi map<int,int>

using namespace std;
int min(int x,int y)
{
	if(x<y)
		return x;
	return y;
}
int max(int x,int y)
{
	if(x>y)
		return x;
	return y;
}
int main()
{
	ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    //const unsigned int M=1000000007;
	string s,t;
	getline(cin,s);
    getline(cin,t);
    int n=s.length(),count=0;
    for(int i=0;i<n;i++)
    {
    	if(s[i]!=t[i])	count++;
	}
	cout << count;
	return 0;
}



Measured memory_bytes: 3248
#include<iostream>
#include<vector>
using namespace std;
int main(void){
  string a;
  cin>> a;
  
  if (a[0]==a[1]){
      if(a[2]==a[3]){
          if(a[1]==a[2]){
              cout<<"No"<<endl;
          }else{
          cout<<"Yes"<<endl;
          }
      }else{
          cout<<"No"<<endl;
      }
  }else if(a[0]==a[2]){
       if(a[1]==a[3]){
          cout<<"Yes"<<endl;
      }else{
          cout<<"No"<<endl;
      }
  }else if(a[0]==a[3]){
       if(a[1]==a[2]){
          cout<< "Yes"<<endl;
      }else{
          cout<<"No"<<endl;
      }
  }else{
      cout <<"No"<<endl;
  }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * 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 factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    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(nullptr);
    ios::sync_with_stdio(false);
    ll n; cin >> n;
    ll one = 0, two = 0, four = 0;
    rep(i, n) {
        ll a; cin >> a;
        if (a % 4 == 0) four++;
        else if (a % 2 == 0) two++;
        else one++;
    }
    if (two == 0) {
        if (one <= four+1) { puts("Yes"); return 0;}
    } else {
        if (one <= four) { puts("Yes"); return 0; }
    } 
    puts("No"); return 0;
}

Measured memory_bytes: 256
#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 solve() {
    ll N, M;
    cin >> N >> M;
    map<P, vector<P>> graph;
    rep(i, M) {
        ll u, v;
        cin >> u >> v;
        u--;
        v--;
        graph[make_pair(u, 0)].push_back(make_pair(v, 1));
        graph[make_pair(u, 1)].push_back(make_pair(v, 2));
        graph[make_pair(u, 2)].push_back(make_pair(v, 0));
    }
    ll S, T;
    cin >> S >> T;
    S--;
    T--;
    queue<pair<P, ll>> que;
    que.push(make_pair(make_pair(S, 0), 0));
    map<P, bool> visited;
    visited[make_pair(S, 0)] = true;
    while (!que.empty()) {
        auto X = que.front();
        que.pop();
        if (X.first.first == T && X.first.second == 0) {
            cout << X.second << '\n';
            return;
        }
        for (auto Y : graph[X.first]) {
            if (!visited[Y]) {
                visited[Y] = true;
                que.push(make_pair(make_pair(Y.first, (X.first.second + 1) % 3),
                                   (X.first.second == 0 ? X.second + 1 : X.second)));
            }
        }
    }
    cout << -1 << '\n';
}

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


Measured memory_bytes: 51840
package main

import (
	"bufio"
	"fmt"
    "os"
)

func main() {
	var N int
	fmt.Scan(&N)
	A_LIST := make([]float64, N)
	var sc = bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	for i := 0; i < N; i++ {
		fmt.Scan(&A_LIST[i])
	}
    ans := 0.0
	for i := 0; i < N; i++ {
        ans += 1 / A_LIST[i]
    }
    ans = 1.0 / ans
	fmt.Println(ans)
}

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

#define EPS (1e-10)
#define rep(i, a, b) for (int i = a; i < (int)(b); ++i)
#define rrep(i, a, b) for (int i = b - 1; i >= (int)(a); --i)

using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vd = vector<double>;
using vvi = vector<vi>;

constexpr int MOD = 1000000007;

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

    int x;
    cin >> x;

    int ans = 0;
    if (x >= 500) {
        ans += 1000 * (x / 500);
        x %= 500;
    }
    ans += 5 * (x / 5);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
l = [[[0 for i in range(10)] for j in range(3)] for k in range(4)]
n = int(input())
a = [[int(i) for i in input().split()] for _ in range(n)]
for i in a:
    l[i[0] - 1][i[1] - 1][i[2] - 1] += i[3]
for i in range(len(l)):
    for j in l[i]:
        print(''.join(map(lambda x: ' ' + str(x), j)))
    if 0 <= i <= len(l) - 2:
        print('#' * 20)



Measured memory_bytes: 5636
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = (s); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) for(int i = (n); i >= 0; i--)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int N, M;
    cin >> N >> M;
    vector<int> A(M);
    REP(i,N) {
        int K; cin >> K;
        REP(j,K) {
            int a; cin >> a;
            a--;
            A[a]++;
        }
    }
    int ans = 0;
    REP(i,M) if (A[i] == N) ans++;
    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 256
/* ITP1_7_B:How many ways */
/* 20181123 AOJ */

#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>

int main(void) {
	int n, x, i, j, k, sum, cnt;

	while(1) {
		scanf("%d %d", &n, &x);
		if(n == 0 && x == 0) {
			break;
		} else {
			cnt = 0;
			for(i = 1; i <= n - 2; i++) {
				for(j = i + 1; j <= n - 1; j++) {
					for(k = j + 1; k <= n; k++) {
						sum = i + j + k;
						if(sum == x) cnt++;
					}
				}
			}
		}
		printf("%d\n", cnt);
	}

	
}


Measured memory_bytes: 2044
#include<bits/stdc++.h>
using namespace std;
int n, r;

int main () {
    cin >> n >> r;
    if (n >= 10) {
        cout << r ;
        return 0;
    }
    /// inner = 100 * (10 - n) + display
    cout << (100)  * (10 - n) + r << '\n';
}
/*
    Good Luck
        -Lucina
*/


Measured memory_bytes: 256
import java.util.*;
import java.io.*;
public class Main{
    public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		PrintWriter ou = new PrintWriter(System.out);
		long a = Long.parseLong(sc.next()) - 1;
		long b = Long.parseLong(sc.next());
		sc.close();
		long zero = (a + 1) / 2 + (b + 1) / 2;
		zero %= 2;
		if(a % 2 == 0) zero ^= a;
		if(b % 2 == 0) zero ^= b;
		ou.print(zero + "\n");
		ou.flush();
    }
}

Measured memory_bytes: 38484
def main():
    s = input()
    K = int(input())
    a = ord("a")
    code = [ord(c) - a for c in s]
    for i in range(len(s)):
        x = (26 - code[i]) % 26
        if x <= K:
            code[i] = 0
            K -= x
    code[-1] = code[-1] + K % 26
    ans = "".join([chr(a + x) for x in code])
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 47284
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <queue>
#include <stack>
#include <vector>
#define LL long long
#define pii pair<int, int>
#define MAXN (10000 + 5)
using namespace std;
int main()
{
	int n, a[MAXN], ans = 0;
	scanf("%d", &n);
	for (int i = 1; i <= n; i++)
	{
		scanf("%d", &a[i]);
		while (a[i] % 2 == 0)
			a[i] /= 2, ++ans;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9+7;
int main() {
    int n;
    cin >> n;
    vector<int>a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    vector<int>cnt(a[n-1]+10,0);
    for(int i=0;i<n;i++){
        cnt[a[i]]++;
    }
    int ans=0;
    for(int i=1;i<=a[n-1];i++){
        ans = max(ans,cnt[i-1]+cnt[i]+cnt[i+1]);
    }
  ans=max(ans,cnt[0]+cnt[1]);
    cout << ans << endl;
}


Measured memory_bytes: 3996
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

int main()
{
	int x[32] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	int K;
	cin >> K;

	cout << x[K-1] << endl;

}






Measured memory_bytes: 3616
#include<iostream>
#include <algorithm>
#include <vector>
#include <deque>
using namespace std;

int main()
{
    // 整数の入力
    long long  N,A,B,total;
    cin >> N >> A >>B;

    if ((A < B && N > 1) || A == B){
        cout << (B - A) * (N-2) + 1 << endl;
    }else{
        cout << 0 << endl;
    }

    return 0;
}

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

int main() {
  ll h, w, a, b;
  cin >> h >> w >> a >> b;

  vector<vector<int>> s(h, vector<int>(w, 0));

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (i < b && a <= j) s[i][j] = 1;
      if (b <= i && j < a) s[i][j] = 1;
    }
  }

  rep(i, h) {
    rep(j, w) cout << s[i][j];
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 7504
#include<stdio.h>
#include<string.h>
int main()
{
	char str1[15], str2[15], trash[15];
	int balls1, balls2;
	scanf("%s %s", str1, str2);
	scanf("%d %d", &balls1, &balls2);
	scanf("%s", trash);
	(strcmp(trash, str1) == 0) ? balls1-- : balls2--;
	printf("%d %d\n", balls1, balls2 );
	
	return 0;
	
}

Measured memory_bytes: 3228
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define double long double
#define SZ(x) ((int)(x).size())
#define rep(i,m,n) for(int i=(m);i<(n);++i)
#define fore(i,a) for(auto &i:a)
#define Yes cout << "Yes" << endl;
#define No cout << "No" << endl;
#define answer cout << ans << endl;
void _main(); signed main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> using v = vector<T>;
template<class T> using vv = vector<v<T>>;
const int MOD=1e9+7;
const long long INF = 1LL << 60;

class UnionFind {
public:
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

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

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

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

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

void _main(){
  int N,M; cin >> N >> M;
  int p[N];
  UnionFind tree(N);
  rep(i,0,N){
    cin >> p[i];
    p[i]--;
  }
  rep(i,0,M){
    int x,y;
    cin >> x >> y;
    x--;y--;
    tree.unite(x,y);
  }
  int ans=0;
  rep(i,0,N){
    if(tree.same(i,p[i])) ans++;
  }
  answer
  return;
}


Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<vector>
#include<math.h>
#include<string>
#include<limits.h>
#define ll long long
#define rep(i,n) for(int i=0;i<n;i++)
#define nrep(i,a,b) for(int i=a;i<b;i++)
#define mrep(i,a) for(int i=a;i<=0;i++)
#define INF LLONG_MAX
using namespace std;

ll w, h, ans;
vector<pair<ll, ll> > idou(8);

void dfs(vector<vector<ll> > &map, ll tate, ll yoko) {
	map[tate][yoko] = ans;
	rep(i, 8) {
		ll t = tate + idou[i].first;
		ll y = yoko + idou[i].second;
		if (0 <= t && t < h && 0 <= y && y < w && !map[t][y]) dfs(map, t, y);
	}
}

int main() {
	//???
	idou[0].first = -1;
	idou[0].second = 0;
	//??????
	idou[1].first = -1;
	idou[1].second = 1;
	//???
	idou[2].first = 0;
	idou[2].second = 1;
	//??????
	idou[3].first = 1;
	idou[3].second = 1;
	//???
	idou[4].first = 1;
	idou[4].second = 0;
	//??????
	idou[5].first = 1;
	idou[5].second = -1;
	//???
	idou[6].first = 0;
	idou[6].second = -1;
	//??????
	idou[7].first = -1;
	idou[7].second = -1;

	while (1) {
		cin >> w >> h;
		if (!w && !h) break;
		ans = 0;
		vector<vector<ll> > map(h, vector<ll>(w, -1));
		rep(i, h) rep(j, w) {
			ll temp; cin >> temp;
			if (temp) map[i][j] = 0;
		}rep(i, h) rep(j, w) {
			if (!map[i][j]) {
				ans++;
				dfs(map, i, j);
			}
		}cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3260
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <chrono>
#include <stack>
#include <string>
#include <bitset>
#include <unordered_map>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <tuple>
#include <iomanip>
#include <random>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <fstream>
#include <numeric>

using namespace std;

int u[111];

typedef long long ll;
const int maxn = (int) 1e5 + 1;
const int inf = (int)1e9+7;


double a[111], b[111];

int cnt[maxn];

string s, t;

int ans = 0, sum1, sum2, sum3;

int n, k;

int dp[maxn];

vector < int > v;

bool isprime(int x){
    if(x < 100){
        return 0;
    }
    for(int i = 2; i <= sqrt(x); i++){
        if(x % i == 0)
            return 0;
    }
    return 1;
}

int now = 0;

int GCD(int u, int v) {
    while ( v != 0) {
        int r = u % v;
        u = v;
        v = r;
    }
    return u;
}
int main(){
    cin >> n >> k;
    for(int i = 1; i <= n; i++){
        int x;
        cin >> x;
        if(x >= k){
            ans++;
        }
    }
    cout << ans;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0; i<(int)(n); ++i)

using namespace std;

typedef complex<double> Point;
const double INF = 1e16;
const double EPS = 1e-8;
double cross(Point a, Point b){
    return imag(conj(a) * b);
}

int main(){
    int N, M;
    while(cin >> N >> M && N){
        vector<Point> ps(N);
        REP(i, N){
            double arg;
            cin >> arg;
            ps[i] = polar(1.0, 2.0 * M_PI * arg);
        }
        double ans = 0;
        for(int begin = 0; begin < N; begin++){
            double dp[50][50] = {}; // last, total
            REP(i, N) REP(j, M + 1) dp[i][j] = -INF;
            dp[begin][1] = 0;

            for(int curr = begin + 1; curr < N; curr++)
                for(int total = M - 1; total >= 1; total--)
                    for(int last = curr - 1; last >= begin; last--)
                        if(dp[last][total] > -INF)
                            dp[curr][total + 1] = max(dp[curr][total + 1], dp[last][total] + cross(ps[last], ps[curr]) / 2);

            for(int last = begin + 1; last < N; last++)
                if(dp[last][M] > -INF)
                    ans = max(ans, dp[last][M] + cross(ps[last], ps[begin]) / 2);
        }
        printf("%.6f\n", ans);
    }
    return 0;
}

Measured memory_bytes: 1284
#include <iostream>
#include <vector>
#include <algorithm>
#include <list>
#include <iomanip>
#include <string>



using namespace std;

int main() {

    int H[100],W[100];
    int count = 0;
    while (1) {
        cin >> H[count] >> W[count];
        if (H[count] == 0 && W[count] == 0) {
            break;
        }
        count++;
    }
     
    for (int k = 0; k < count; k++) {
        for (int i = 0; i < H[k]; i++) {
            for (int j = 0; j < W[k]; j++) {
                cout << '#';
            }
            cout << endl;
        }
        cout << endl;
    }
        
    

    
}


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(int i=a;i<n;i++)
#define ve vector
#define ss second 
#define ff first
#define pf pop_front
#define pob pop_back
#define psf push_front
#define res(x) cout<<x<<'\n'
#define read(t) ll t;cin>>t
string rev(string s){
    string temp="";
    for(int i=s.length()-1;i>=0;i--){
        temp=temp+s[i];
    }
    return temp;
}

int main(){
    
    string s;
    cin>>s;
    int n=s.length();
    string temp="";
    string temp2="";
    for(int i=((n+1)/2)-2;i>=0;i--){
         temp=temp+s[i];
    }
    for(int i=(n+1)/2;i<n;i++){
         temp2=temp2+s[i];
    }
    string rev1=rev(temp);
    string rev2=rev(temp2);
    if(rev1==temp&&rev2==temp2&&rev1==temp2){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }

    
}

Measured memory_bytes: 256