akhauriyash/Code-Regression huggingface dataset:
using System;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using Debug = System.Diagnostics.Debug;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;


static class P
{
    static void Main()
    {
        var nm = Console.ReadLine().Split().Select(int.Parse).ToArray();
        UnionFind uf = new UnionFind(nm[0]);
        for (int i = 0; i < nm[1]; i++)
        {
            var xyz = Console.ReadLine().Split().Select(x => int.Parse(x) - 1).ToArray();
            uf.TryUnite(xyz[0], xyz[1]);
        }
        Console.WriteLine(uf.GroupCount);
    }
}


class UnionFind
{
    public int Size { get; private set; }
    public int GroupCount { get; private set; }
    List<int> Sizes;
    List<int> Parent;
    public UnionFind(int count)
    {
        Size = 0;
        GroupCount = 0;
        Parent = new List<int>(count);
        Sizes = new List<int>(count);
        ExtendSize(count);
    }
    public bool TryUnite(int x, int y)
    {
        int xp = Find(x);
        int yp = Find(y);
        if (yp == xp) return false;
        if (Sizes[xp] < Sizes[yp])
        {
            var tmp = xp;
            xp = yp;
            yp = tmp;
        }
        GroupCount--;
        Parent[yp] = xp;
        Sizes[xp] += Sizes[yp];
        return true;
    }
    public IEnumerable<int> AllRepresents => Parent.Where(x => x == Parent[x]);
    public int GetSize(int x) => Sizes[Find(x)];
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public int Find(int x)
    {
        while (x != Parent[x])
        {
            Parent[x] = Parent[Parent[x]];
            x = Parent[x];
        }
        return x;
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public void ExtendSize(int treeSize)
    {
        if (treeSize <= Size) return;
        Parent.Capacity = treeSize;
        Sizes.Capacity = treeSize;
        while (Size < treeSize)
        {
            Parent.Add(Size);
            Sizes.Add(1);
            Size++;
            GroupCount++;
        }
    }
}

Measured memory_bytes: 18016
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
  ll x;
  cin>>x;
  ll p=100;
  ll cnt=0;
  while(p<x)
  {
    p+=p/100;
  	cnt++;
  }
  cout<<cnt;
return 0;
}

Measured memory_bytes: 3596
#include<stdio.h>
#define M 10000000

int A[M];
void bubbleSort(int A[], int n);

int main()
{
	int n, i;
	
	scanf("%d", &n);
	
	for(i = 0; i < n; i++) {
		scanf("%d", &A[i]);
	}

	bubbleSort(A,n);
}

void bubbleSort(int A[], int n) {
	int flag = 1,p, j, cp, cnt= 0;
	while(flag) {
		flag = 0;
		for(j = n-1; j >= 1; j --) {
			if(A[j] < A[j-1]) {
				cp = A[j];
				A[j] = A[j-1];
				A[j-1] = cp;
				cnt ++;
				flag = 1;
			}
		}
	}
	
	for(p = 0; p < n-1; p++){
		printf("%d ", A[p]);
	}
	printf("%d", A[p]);
	printf("\n%d\n", cnt);
}




Measured memory_bytes: 2112
n,m=map(int,input().split())
X=list(map(int,input().split()))
Y=list(map(int,input().split()))
mod=10**9+7

X.sort()
Y.sort()

x=0
y=0
for i in range(1,n):
    x=(x+(X[i]-X[i-1])*i*(n-i))%mod

for i in range(1,m):
    y=(y+(Y[i]-Y[i-1])*i*(m-i))%mod

print(x*y%mod)

Measured memory_bytes: 18624
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        string s = sc.Next();

        int first = int.Parse(s[0].ToString());

        bool all9 = true;
        for (int i = 0; i < s.Length - 1; i++)
        {
            char c = s[i + 1];
            int num = int.Parse(c.ToString());
            if (num != 9)
            {
                all9 = false;
                break;
            }
        }

        int answer = first + 9 * (s.Length - 1);
        if (!all9)
        {
            answer--;
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}

Measured memory_bytes: 13140
x,y = (int(x) for x in input().split())
groupA = [1,3,5,7,8,10,12]
groupB = [4,6,9,11]
groupC = [2]

x_group, y_group = '',''

if x in groupA:
  x_group = 'A'
elif x in groupB:
  x_group = 'B'
elif x in groupC:
  x_group = 'C'
  
if y in groupA:
  y_group = 'A'
elif y in groupB:
  y_group = 'B'
elif y in groupC:
  y_group = 'C'
  
if x_group == y_group:
  print('Yes')
else:
  print('No')

Measured memory_bytes: 3064
import java.util.*

fun main(args:Array<String>){
    solve()
}

fun solve(){
    val a = readint()
    val b = readint()
    val h = readint()
    println((a + b) * h / 2)
}

fun read() = readLine()!!
fun reads() = readLine()!!.split(" ")
fun readint() = readLine()!!.toInt()
fun readints() = readLine()!!.split(" ").map{it.toInt()}
fun readlong() = readLine()!!.toLong()
fun readlongs() = readLine()!!.split(" ").map{it.toLong()}

Measured memory_bytes: 34508
# 入力
H, W, D = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(H)]
Q = int(input())
L, R = zip(*(map(int, input().split()) for _ in range(Q)))

# 各整数の座標を調べる
p = {A[i][j]: (i, j) for i in range(H) for j in range(W)}

# 各整数に対する累積和を求める
dp = [0 for _ in range(H * W + 1)]
for x in range(D + 1, H * W + 1):
    y = x - D
    dp[x] = dp[y] + abs(p[x][0] - p[y][0]) + abs(p[x][1] - p[y][1])

# 各クエリに対する解を累積和を用いて求める
ans = '\n'.join(str(dp[r] - dp[l]) for l, r in zip(L, R))

# 出力
print(ans)


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

int main() {
  int N, A, B;
  cin >> N >> A >> B;
  int sum;
  int result = 0;
  int n1, n2, n3, n4, n5;
  for (int i = 1; i <= N; i++) {
    n5 = i / 10000;
    n4 = (i - n5 * 10000)/ 1000;
    n3 = (i - n5 * 10000 - n4 * 1000) / 100;
    n2 = (i - n5 * 10000 - n4 * 1000 - n3 * 100) / 10;
    n1 = i - n5 * 10000 - n4 * 1000 - n3 * 100 - n2 * 10;
    sum = n1 + n2 + n3 + n4 + n5;
    if (A <= sum && sum <= B) {
      result += i;
    }
  }
  cout << result << endl;
}

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

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            SolveA();
            //SolveB();
            //SolveC();
            //SolveD();
        }
        private const long MOD = 1000000007;

        static void SolveA()
        {
            var n = ReadAndParseInt();
            long[] t = new long[n];
            for(int i=0;i<n;++i)
            {
                t[i] = ReadAndParseLong();
            }

            if( n == 1)
            {
                Console.WriteLine(t[0]);
                return;
            }
            long min = lcm(t[0], t[1]);
            for(int i=2;i<n;++i)
            {
                min = lcm(min, t[i]);
            }
            Console.WriteLine(min);
        }

        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if (x == 2) { return true; }
            if (x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while (i * i <= x)
            {
                if (x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }
        private static long pow(long x, long n)
        {
            if (n == 0) { return 1; }
            long res = pow(x * x % MOD, n / 2);
            if (n % 2 == 1)
            {
                res = res * x % MOD;
            }
            return res;
        }
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

Measured memory_bytes: 13140
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

char s[110];
int main(){
	ll n;
	scanf("%lld%s",&n,s);
	ll ans=0,crr=0;
	rep(i,0,n){
		if(s[i]=='I')crr++;
		else crr--;
		ans=max(ans,crr);
	}
	printf("%lld",ans);
}

Measured memory_bytes: 128
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <queue>
#include <cmath>
#include <map>
#include <set>
#include <deque>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main() {
  int n, k; cin >> n >> k;
  string  s; cin >> s;
  int score = 0;
  rep(i, n-1) {
    if(s[i] == s[i+1]) score++;
  }
  int ans = min(score+2*k, n-1);
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 512
#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))
//-------------------------------------------------------

void solve() {
	int i,j,k,l,r,x,y; string s;
	
	int N;
	cin>>N;
	if(N%10==9 || N/10==9) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


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: 892
#include <iostream>
#include <limits.h>
using namespace std;
int main(void){
    // Your code here!
    long MOD = 1000000007;
    int N;
    
    scanf("%d",&N);
    long ans = 1;
    long sub1 = 2;
    long sub2 = 1;
    
    for(int i = 0; i < N; i++)
    {
        ans = ans * 10 % MOD;
        sub1 = sub1 * 9 % MOD;
        sub2 = sub2 * 8 % MOD;
    }
    
    ans = ans - sub1;
    if(ans < 0)
        ans += MOD;
    ans = (ans + sub2) % MOD;
    
    printf("%ld\n", ans);
}


Measured memory_bytes: 3816
#include<iostream>
#include<algorithm>
using namespace std;
#define int64 long long
#define INF 1000000001

int main(){

  int n;
  cin >> n;
  
  int64 a[n+1];
  int dp[n+1];
  fill(dp,dp+n,INF);
  for(int i = 0;i < n;i++) cin >> a[i];
  
  for(int i = 0;i < n;i++){
    *lower_bound(dp,dp+n,a[i]) = a[i];
  }

  cout << lower_bound(dp,dp+n,INF)-dp << endl;
  return (0);
}
  

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

int main(){
	int n;
	string s;
	char before;
	cin >> n;
	cin >> s;
	std::string str(s);
	int count = 0;
	for(int i = 0; i < n; i++){
		char ss = str[i];
		if(i != 0){
			if(before == 'x' && ss == 'x'){
				break;
			}
		}
		count++;
		before = ss;
	}
	cout << count << endl;
}

Measured memory_bytes: 3320
import sys
from heapq import heappush,heappop

lines = []
for line in sys.stdin:
    lines.append(line.rstrip('\r\n'))
#print(lines)
n,m = lines[0].split()
n = int(n)
m = int(m)

a=[]
for i in range(n):
    x,y = lines[i+1].split()
    x = int(x)
    y = int(y)*(-1)
    a.append((x,y))
a.sort()
a.append((0,0))

h = []

cur = 0
summ = 0
for i in range(1,m+1):
    while(cur<n and a[cur][0]<=i):
        heappush(h,a[cur][1])
        cur+=1
    if(len(h)>0):
        summ+=heappop(h)*(-1)
print(summ)
    


Measured memory_bytes: 30716
using System;
using System.Collections.Generic;
using System.Linq;

namespace _0031
{
    class Program
    {
        readonly static int[] weights = { 512, 256, 128, 64, 32, 16, 8, 4, 2, 1 };
        readonly static int MAX_NUMBER = 10;

        static void Main(string[] args)
        {
            while (true)
            {
                var input = Console.ReadLine();
                var usedWeights = new List<int>();

                if (string.IsNullOrEmpty(input))
                {
                    break;
                }

                var inputWeight = int.Parse(input);
                for (int i = 0; i < MAX_NUMBER; i++)
                {
                    if ((inputWeight / weights[i]) == 1)
                    {
                        usedWeights.Add(weights[i]);
                    }
                    inputWeight %= weights[i];
                }
                usedWeights.Reverse();

                foreach (var usedWeight in usedWeights)
                {
                    if (usedWeight == usedWeights.First())
                    {
                        Console.Write(usedWeight);
                    }
                    else
                    {
                        Console.Write(" " + usedWeight);
                    }
                }
                Console.WriteLine();
            }
        }
    }
}

Measured memory_bytes: 5860
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <deque>
#include <bitset>
#include <iomanip>
#include <limits>
#include <chrono>
#include <random>
#include <array>
#include <unordered_map>
#include <functional>
#include <complex>

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

constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int inf = 1 << 28;
//constexpr long long mod = 1000000007LL;
//constexpr long long mod = 998244353LL;

using namespace std;
typedef unsigned long long ull;
typedef long long ll;


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

	ll n; scanf("%lld", &n);
	if (n == 0) puts("1");
	else if (n == 1) puts("2");
	else if (n == 2) puts("1");
	else puts("0");
	return 0;
}


Measured memory_bytes: 3168
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
const long long INF = 1LL << 60;
// const int INF=1010101010;
using Graph = vector<vector<int>>;

int main() {
  int a, b;
  cin >> a >> b;
  int aa = (double)a / 8 * 100;
  int ans = -1;
  for (int i = aa - 1000000; i < aa + 1000000; i++) {
    if (i < 0) continue;
    if ((int)(i * 0.08) == a && (int)(i * 0.1) == b) {
      ans = i;
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int i;
	int n, x;

	scanf("%d", &n);
	
	for (i = 1; i <= n; i++){
		if (i % 3 == 0){
			printf(" %d", i);
		}
		else {
			x = i;
			while (x > 0){
				if (x % 10 == 3){
					printf(" %d", i);
					break;
				}
				x /= 10;
			}
		}
	}
	printf("\n");
	
	return (0);
}

					



Measured memory_bytes: 2112
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#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, m, n) for (ll i = m; i < n; ++i)
#define FORR(i, m, n) for (ll i = m; i >= n; --i)
#define ALL(v) (v).begin(),(v).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;cin >> n;
    vector<ll> a(n),sm(n+1);
    REP(i,n){
        cin >> a[i];
        sm[i+1]=sm[i]+a[i];
    }
    map<ll,ll> mp;
    ll ans=0;
    REP(i,n+1){
        ans+=mp[sm[i]];
        mp[sm[i]]++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 18688
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
const int inf=1e9+7;
const ll mod=1e9+7;

int main() {
    long A, B, K;
    cin>>A>>B>>K;
    if(A >= K){
        A -= K;
    }
    else {
        K -= A;
        A = 0;
        B -= K;
        if(B<0) B = 0;
    }
    cout<<A<<" "<<B<<endl;
}



Measured memory_bytes: 256
N, C, K = map(int, input().split())
Tlist = sorted([int(input()) for _ in range(N)])
ans = 0
count = 0

for i in range(N):
    now = Tlist[i]
    if count == 0:
        rl = now + K
        count += 1
        continue
    else:
        if now <= rl <= now + K and count < C:
            count += 1
        else:
            ans += 1
            rl = now + K
            count = 1
print(ans + 1)


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

int main(){
	int n;
	std::vector<long long> aList;
	std::vector<long long> xList;

	std::cin>>n;
	aList.resize(n);

	for(int i=0; i<n; i++)
		std::cin>>aList[i];

	std::vector<bool> isDivisible(1000001, false);

	std::sort(aList.begin(), aList.end(), [](long long a, long long b){return a<b;});

	long long prev = -1;
	for(int i=0; i<n; i++){
		if(aList[i]==prev)
			isDivisible[aList[i]]= true;
		else
			xList.push_back(aList[i]);

		prev= aList[i];
	}

	for(int i=0; i< xList.size(); i++){
		long long div= xList[i];

		for(int j= div*2; j<1000001; j+= div)
			isDivisible[j]= true;
	}

	int ans= 0;

	for(int i=0; i< xList.size(); i++)
		if(!isDivisible[xList[i]])
			ans++;

	std::cout<<ans<<std::endl;

	return 0;
}

Measured memory_bytes: 6880
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define orta ((bas+son+1)/2)
#define inf 100000000000000007
#define N 100005
using namespace std;
typedef long long ll;
ll n, k, yap, v[N], w[N], dp[105][N+N];

ll f(ll x, ll kal){
	ll &r = dp[x][kal];
	if(r != -1)
		return r;
	if(x == n + 1){
		if(kal >= yap)
			return 0;
		return inf;
	}
	r = f(x + 1, kal);
	if(kal < yap)
		r = min(r, f(x + 1, kal + v[x]) + w[x]);
	return r;

}

bool yapp(ll kac){
	yap = kac;
	memset(dp, -1, sizeof dp);
	ll bul = f(1, 0);
	if(bul <= k)
		return 1;
	return 0;
}

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	scanf("%lld %lld",&n ,&k);
	for(ll i = 1; i <= n; i++)
		scanf("%lld %lld",w + i, v + i);
	ll bas = 0, son = N - 1;
	while(bas < son){
		if(yapp(orta))
			bas = orta;
		else
			son = orta - 1;
	}
	printf("%lld\n", orta);
	return 0;
}

Measured memory_bytes: 164352
#include <bits/stdc++.h>
using namespace std;
#define rep(it,st,en) for(int it=(st);it<(int)(en);++it)
#define allof(c) (c).begin(), (c).end()
#define mt make_tuple
#define mp make_pair
#define pb push_back
#define X first
#define Y second
typedef long long int ll; 
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
const int INF=(int)1e9; 
const double EPS=(ld)1e-7;

int n;

vvi bip;

int dfs(int x, int p, vvi& g){
    vi Q;
    int ret = x;
    for(int y:g[x]) if(y != p)
        Q.pb(dfs(y,x,g));
    g[x] = move(Q);
    if(g[x].size()%2){
        ret = g[x].back();
    }
    return ret;
}

vi vis;

void solve(vvi& g, int r){
    dfs(r,-1,g);
    rep(i,0,n){
        rep(j,0,g[i].size()/2){
            bip[g[i][2*j+0]].pb(g[i][2*j+1]);
            bip[g[i][2*j+1]].pb(g[i][2*j+0]);
        }
    }
}

void d(int x, int col = 1){
    if(vis[x]){
        assert(vis[x] == col);
        return;
    }
    vis[x] = col;
    for(int y:bip[x]) d(y,-col);
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    vi a(n),b(n);
    vvi ga(n), gb(n);
    int ra = -1, rb = -1;
    rep(i,0,n){ cin>>a[i]; --a[i]; if(a[i]>=0) ga[a[i]].pb(i); else ra = i; }
    rep(i,0,n){ cin>>b[i]; --b[i]; if(b[i]>=0) gb[b[i]].pb(i); else rb = i; }
    rep(i,0,n){
        if(ga[i].size()%2 != gb[i].size()%2){
            cout<<"IMPOSSIBLE"<<endl;
            return 0;
        }
    }
    bip.resize(n);
    vis.resize(n,0);
    solve(ga,ra);
    solve(gb,rb);
    rep(i,0,n) if(!vis[i]) d(i);

    cout<<"POSSIBLE"<<endl;
    rep(i,0,n){
        if(ga[i].size()%2==1) cout<<0<<" ";
        else cout<<vis[i]<<" ";
    }
    cout<<endl;
    return 0;
}


Measured memory_bytes: 18304
N, K = list(map(int,input().split()))
l = list()

c = 0
ans = 0
ab_list = list()

for n in range(N):
    a,b =list(map(int,input().split()))
    ab_list.append([a,b])

ab_list = sorted(ab_list, key=lambda x: x[0])

for a,b in ab_list:
    c += b
    if c >= K:
        ans = a    
        break

print(ans)

Measured memory_bytes: 22616
using System.Linq;
using System.Collections.Generic;
using System;

public class Hello
{
    public static void Main()
    {
        var a = "abcdefghijklmnopqrstuvwxyz";
        var n = int.Parse(Console.ReadLine().Trim());
        var d = new Dictionary<char, int[]>();
        for (int i = 0; i < 26; i++) d[a[i]] = new int[n];
        for (int i = 0; i < n; i++)
        {
            var s = Console.ReadLine().Trim();
            for (int j = 0; j < s.Length; j++)
                d[s[j]][i]++;
        }
        var ret = "";
        var alpha =0 ;
        foreach(var x in d.OrderBy(y =>y.Key))
        {
            var w = x.Value.Min();
            ret += new string(a[alpha++], w);
        }
        Console.WriteLine(ret);
    }
}

Measured memory_bytes: 13408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define repn(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) for(int i = 0; i < (a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'

int dp[100005];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	int n, k;
	cin >> n >> k;
	int a[n];
	rep(i, n){
		cin >> a[i];
	}
	repn(i, 1, k + 1){
		rep(j, n){
			if(i - a[j] >= 0 && !dp[i - a[j]]) dp[i] = 1;
		}
	}
	cout << (dp[k] ? "First" : "Second") << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 640
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;

void chmax(ll& x, ll y) {
    if (x < y) x = y;
}

int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    ll n, m; cin >> n >> m;
    vll a(n);
    REP(i, n) cin >> a[i], a[i] /= 2;

    ll g = a[0];
    REP(i, n) g = g / __gcd(g, a[i]) * a[i];

    REP(i, n) {
        if (~(g / a[i]) & 1) {
            print(0);
            return 0;
        }
    }

    print((m / g + 1) / 2);
}

Measured memory_bytes: 3968
using System;
using System.Collections.Generic;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {

            int w = int.Parse(Console.ReadLine());
            int n = int.Parse(Console.ReadLine());

            List<List<int>> abs = new List<List<int>>();

            for (int i = 0; i < n;i++ )
            {
                List<int> ab = new List<int>();
                string[] abStrs = Console.ReadLine().Split(',');
                foreach (string abStr in abStrs)
                {
                    ab.Add(int.Parse(abStr) - 1);
                }
                abs.Add(ab);
            }

            List<int> lots = new List<int>();

            for (int i = 1; i <= w; i++)
            {
                lots.Add(i);
            }

            foreach (List<int> ab in abs)
            {
                int temp = lots[ab[0]];
                lots[ab[0]] = lots[ab[1]];
                lots[ab[1]] = temp;
            }

            foreach (int lot in lots)
            {
                Console.WriteLine(lot);
            }

        }
    }
}

Measured memory_bytes: 5712
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    string S;cin >> S;
    char tmp = S[0];
    int ct = 0;
    rep(i,S.size()){
        if(i == 0)continue;
        if(tmp == S[i])continue;
        else {
            ct++;
            tmp = S[i];
        }
    }
    cout << ct << endl;
}



Measured memory_bytes: 512
#include<string>
#include<sstream>
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<ios>
#include<algorithm>
#include<stack>
#include<queue>
#include<cmath>
#include<type_traits>
#include<random>
#include<vector>
#include<map>

using namespace std;

	

int main()
{
	int N;
	cin >> N;
	int H[N];
	for(int i=0;i<N;i++)
	{
		cin >> H[i];
	}
	int result = 1;
	for(int i=1;i<N;i++)
	{
		bool judge = 1;
		for(int j=0;j<i;j++)
		{
			if(H[i]<H[j])
			{
				judge = 0;
			}
		}
		if(judge==1)
		{
			result = result + 1;
		}
	}
	cout << result << endl;
	
}


Measured memory_bytes: 256
//
//  main.cpp
//  ProCon
//
//  Created by hashimotoryoma on 2017/08/20.
//  Copyright © 2017年 hashimotoryoma. All rights reserved.
//

#include <iostream>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <queue>
#include <vector>

#define repeat(i,n) for (int i = 0; (i) < (n); ++ (i))

using namespace std;

typedef long long ll;

int group(int n){
    if(n==2)
        return 2;
    else if(n==4 || n==6 || n==9 || n==11)
        return 1;
    else
        return 0;

}

int main() {
    // insert code here...    return 0;
    //////
    // input from txt
    /*
     std::ifstream in("input.txt");
     std::cin.rdbuf(in.rdbuf());
     std::ofstream out("output.txt");
     std::cout.rdbuf(out.rdbuf());
     ////
     */
    int X,t;
    cin >> X >> t;
    cout << max(0,X-t) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <numeric>
#include <vector>

int main() {
	int x = 0;
	int n = 0;
	std::cin >> x >> n;
	std::vector<decltype(x)> vect(n);
	bool vect_contains_x = false;
	for (auto& elem : vect) {
		std::cin >> elem;
		if (elem == x) {
			vect_contains_x = true;
		}
	}
	int num = 0;
	if (!vect_contains_x) {
		num = x;
	}
	else {
		std::sort(vect.begin(), vect.end());
		while (1) {
			static int i = 1;
			if (std::find(vect.begin(), vect.end(), x - i) == vect.end()) {
				num = x - i;
				break;
			}
			else if (std::find(vect.begin(), vect.end(), x + i) == vect.end()) {
				num = x + i;
				break;
			}
			else {
				i += 1;
			}
		}
	}
	std::cout << num << "\n";
	return 0;
}

Measured memory_bytes: 3172
#include<iostream>
using namespace std;
#include<vector>
struct UF{
	int n;
	vector<int>parent,rank;
	UF(int n_=0):n(n_),parent(n_),rank(n_,0)
	{
		for(int i=0;i<n_;i++)parent[i]=i;
	}
	int find(int a)
	{
		return parent[a]!=a?parent[a]=find(parent[a]):a;
	}
	bool same(int a,int b)
	{
		return find(a)==find(b);
	}
	bool unite(int a,int b)
	{
		a=find(a),b=find(b);
		if(a==b)return false;
		if(rank[a]<rank[b])
		{
			parent[a]=b;
		}
		else
		{
			parent[b]=a;
			if(rank[a]==rank[b])rank[a]++;
		}
		return true;
	}
};
#include<algorithm>
#include<vector>
int n,m;
main()
{
	while(cin>>n>>m,n)
	{
		vector<pair<int,pair<int,int> > >e;
		for(int i=0;i<m;i++)
		{
			int a,b,c;cin>>a>>b>>c;
			e.push_back(make_pair(c,make_pair(a,b)));
		}
		UF uf(n);
		sort(e.begin(),e.end());
		int ans=0;
		for(int i=0;i<m;i++)
		{
			int a=e[i].second.first,b=e[i].second.second,c=e[i].first;
			if(uf.same(a,b))continue;
			uf.unite(a,b);
			ans+=c;
		}
		cout<<ans<<endl;
	}
}



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

#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n,k;
    cin >> n >> k;
    vector<ll> a(n);
    vector<ll> f(n);
    rep(i,0,n) cin >> a[i];
    rep(i,0,n) cin >> f[i];
    sort(all(a));
    sort(all(f),greater<ll>());

    auto ok = [&](ll t){ //okに関数を組み込み
        ll cnt = 0;
        rep(i,0,n) cnt += max(0LL,a[i] - t/f[i]);//a*f=t -> a - t/f = x(したい数字)
        return cnt <= k;//TorF
    };

    ll l = -1,r = 1e18;//にぶたん
    while(r - l > 1){
        ll t = (l+r) / 2;
        if(ok(t)) r = t; //mがkより小さいならrをまんなかへ
        else l = t;
    }
    cout << r << endl;
}

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

int main() {
  int A,B;
  cin >>A >> B;
  if (A == B) {
  cout <<A + B<<endl;
}
else if (A < B) {
  cout <<B*2-1<<endl;
}
else if (A > B) {
  cout <<A*2-1<<endl;
}}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long int;
#define rep(n,k) for(int i = (int)n;i<k;i++)
int main(){
   int n;cin>>n;
   int three=0;
   bool atta=false;
   for(int i=0;i<n;i++){
      int d1,d2;cin>>d1>>d2;
      if(d1==d2){
         three++;
      }
      else three=0;
      if(three==3){
         atta=true;
         break;
      }
   }
   if(atta){
      cout<<"Yes"<<endl;
   }
   else{
      cout<<"No"<<endl;
   }
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
bool kaibun(int n){
  string s = to_string(n);
  //cout<<s;
  string str=s;
  
  for(int i=0;i<s.size();i++){
    //cout<<s.size()<<endl<<s.at(s.size()-1-i);
    str.at(i)=s.at(s.size()-1-i);
  }
  return s==str;
}

int main(){
  int a,b;
  cin>>a>>b;
  int sum=0;
  
  for(int i=a;i<b+1;i++){
    if(kaibun(i))
      sum++;
  }
  cout<<sum;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  public static int n;
  public static int s;
  public static int count;
  public static int[] a = new int[10];

  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    while(true){
      n = scanner.nextInt();
      s = scanner.nextInt();
      count = 0;
      if(n == 0 && s == 0){break;}
      for (int i = 0; i < 10; i++)
        a[i] = i;

        dfs(0, 0, 0);
        System.out.println(count);
    }
  }
  static void dfs(int i, int sum, int k){
    if(n > 0 && k == n && sum == s){
      count++;
    }
    if(i == 10 || k == n || sum > s){return;}

    dfs(i + 1, sum + a[i], k + 1);
    dfs(i + 1, sum, k);
  }
}


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

int N,ret;

int count753(long i, bool _3, bool _5, bool _7) {
	if (i > N) {
		return 0;
	}
	if (_3 && _5 && _7) {
		ret++;
	}
	count753(i * 10 + 3, true, _5, _7);
	count753(i * 10 + 5, _3, true, _7);
	count753(i * 10 + 7, _3, _5, true);
	return ret;
}

int main() {
	cin >> N;
	cout << count753(0,false,false,false) << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
long long a[100010],b[100010];
int main(){
	int i,n;
	cin >> n;
	for(i=0;i<=n;i++){
		cin >> a[i];
	}
	for(i=0;i<n;i++){
		cin >> b[i];
	}
	long long ans = 0;
	for(i=0;i<n;i++){
		if(a[i]<b[i]){
			ans += a[i];
			b[i] -= a[i]; a[i] = 0;
		}else{
			ans += b[i];
			a[i] -= b[i]; b[i] = 0;
		}
		if(a[i + 1]<b[i]){
			ans += a[i + 1];
			b[i] -= a[i + 1]; a[i + 1] = 0;
		}else{
			ans += b[i];
			a[i + 1] -= b[i]; b[i] = 0;
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <list>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223300000000000000
#define INF 2140000000
#define MOD 1000000007
using namespace std;


int main(int argc, char* argv[])
{
    long n;
    scanf("%ld", &n);

    vector<long> b(n);
    long i, j;
    for(i=0; i<n; i++) {
        scanf("%ld", &b[i]);
    }

    vector<long> z;
    for(i=1; i<=n; i++) {
        vector<long> count(n,0);
        long cnt=0;
        long found=0;
        for(j=0; j<n; j++) {
            if(b[j]<i) {
                cnt++;
            }
            if(b[j]==i) {
                count[cnt]++;
                found++;
            }
        }
        if(i==1) {
            if(count[0]<1) {
                printf("-1\n"); return 0;
            }
            long k;
            for(k=0; k<count[0]; k++) {
                z.push_back( 1 );
            }
            continue;
        }
        if(found==0) {
            continue;
        }
        vector<long> znew;
        for(j=0; j<(long)z.size(); j++) {
            znew.push_back(z[j]);
            if(j>=i-2) {
                long pos = (long)z.size()-(j-(i-2));
                long k;
                for(k=0; k<count[pos]; k++) {
                    znew.push_back( i );
                }
            }
        }
        z.swap(znew);
    }

    if(n!=z.size()) {
        printf("-1\n"); return 0;
    }
    for(i=0; i<(long)z.size(); i++) {
        if(z[i]>i+1) {
            printf("-1\n"); return 0;
        }
    }

    for(i=0; i<(long)z.size(); i++) {
        printf("%ld\n", z[i]);
    }

    return 0;
}


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


int Len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}


int Sint(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}


int GCD(int a,int b)
{
  int r, tmp;
   /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
  return b;
}


int Factorial(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}


int Svec(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  int n,ans=0;
  cin>>n;
  int k=0;
  while(ans<n){
    k++;
    ans+=k;
  }
  cout<<k<<endl;
}
///////////////////////////


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<cstring>
#define ll long long
#define inf 1000000000
#define mod 1000000007
#define eps 1e-10
#define N 200005
#define rep(i, l, r) for(int i=l; i<r; ++i)
const double pi=acos(-1.0);

using namespace std;
int t;
int n;
char s[N];
int main(){
	scanf("%d", &n);
	scanf("%s", s);
	int cnt=0, ans=0;
	rep(i, 0, n){
		cnt+=(s[i]=='R');
	}
	rep(i, 0, cnt) ans+=(s[i]=='W');
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 1920
process.stdin.resume();
process.stdin.setEncoding('utf8');
var lines = [];
var reader = require('readline').createInterface({
    input: process.stdin,
    output: process.stdout,
    terminal: false
});
reader.on('line', (line) => {
    lines.push(line);
});
reader.on('close', () => {
    let K = parseInt(lines[0]);
    const S = lines[1];
    const s = S.length <= K ? S : S.slice(0,K) + "...";
    console.log(s);
});

Measured memory_bytes: 30068
#include <iostream>

using namespace std;

int main()
{
int a , b , c , d;
cin >> a >> b >> c >> d;
int area1 , area2;
area1 = a * b;
area2 = c * d;

if(area1 > area2)
    cout << area1;
else if(area2 > area1)
    cout << area2;
else
    cout << area1;



  return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
 
void swap(int* a,int* b){
  int tmp=*a;
  *a=*b;
  *b=tmp;
}
 
int partition(int *A,int p,int q){
	int x = *(A + q);
  int i=p-1,j;
  for(j=p;j<q;j++){
    if(*(A + j)<=x){
      i++;
      swap(A+i,A + j);
    }
  }
  swap(A+i+1, A+q);
  return i+1;
}
 
int main(){
  int n,i,a;
  int A[100000];
	
  scanf("%d",&n);
	
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  a=partition(A,0,n-1);
	
  for(i=0;i<n;i++){
    if(i)printf(" ");
  	
    if(i==a)printf("[");
 
    printf("%d",A[i]);
  	
    if(i==a)printf("]");
  }
  printf("\n");
  return 0;
}



Measured memory_bytes: 2104
#include<bits/stdc++.h>
using namespace std;
#define Elhabashy ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
void input()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
#endif
}
const int N=1e5+5,mod=1e9+7;
typedef long long ll;
int n,k,arr[110],dp[N][3];
int solve(int i=k,bool p=0){
    int &ret=dp[i][p];
    if(~ret)return ret;

    ret=!p;
    for(int x=1;x<=n;x++){
        if(arr[x]<=i){
            if(solve(i-arr[x],!p)==p){
                ret=p;
            }
        }
    }
    return ret;
}
int main()
{
    Elhabashy
    input();
    cin>>n>>k;
    for(int i=1;i<=n;i++)cin>>arr[i];
    memset(dp,-1,sizeof dp);
    if(solve())cout<<"Second\n";
    else cout<<"First\n";


}


Measured memory_bytes: 12468
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
using ll=long long;
constexpr ll mod=1000000007;
constexpr int inf=1000000000;
constexpr ll linf=1000000000000000000;

vector<ll> dijkstra(const vector<vector<pair<int,int>>> &graph,int s){
    int n=(int)graph.size();
    priority_queue<pair<ll,int>,vector<pair<ll,int>>,greater<pair<ll,int>>> pq;
    vector<ll> dist(n,linf);
    dist[s]=0;
    pq.push({0,s});
    while(pq.size()){
        auto p=pq.top();
        pq.pop();
        int v=p.second;
        if(dist[v]<p.first)continue;
        for(auto edge:graph[v]){
            int u=edge.first;
            int w=edge.second;
            if(dist[v]+w<dist[u]){
                dist[u]=dist[v]+w;
                pq.push({dist[u],u});
            }
        }
    }
    return dist;
}

int main(){
    int n;
    cin>>n;
    vector<vector<pair<int,int>>> g(n);
    for(int i=0;i<n-1;i++){
        g[i].push_back({i+1,1});
        g[i+1].push_back({i,1});
    }
    int x,y;
    cin>>x>>y;
    --x,--y;
    g[x].push_back({y,1});
    g[y].push_back({x,1});
    vector<vector<ll>> d(n);
    rep(i,n){
        d[i]=dijkstra(g,i);
    }
    int cnt[n]={};
    rep(i,n){
        for(int j=i+1;j<n;++j){
            ++cnt[d[i][j]];
        }
    }
    for(int i=1;i<n;++i){
        cout<<cnt[i]<<endl;
    }
}


Measured memory_bytes: 31744
#include <bits/stdc++.h>
#define INF (1e9 + 7)
#define rep(i, N) for(ll i = 0; i < N; i++)
#define rep2(i, j, k) for(ll i = j; i < k; i++)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long int ll;
using namespace std;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vs = vector<string>;
using vvs = vector<vector<string>>;

void solve(){
    
    ll N, res;
    cin >> N;
    vl v(N + 100);
    rep2(x, 1, 110){
        rep2(y, 1, 110){
            rep2(z, 1, 110){
                res = pow(x, 2) + pow(y, 2) + pow(z, 2) + x * y + y * z + z * x;
                if(res <= N + 50){
                    v[res] += 1;
                }
            }
        }
    }
    
    rep2(i, 1, N + 1){
        cout << v[i] << endl;
    }

}

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

Measured memory_bytes: 3648
n=int(input())
A=0
B=0
C=0
D=0
for i in range(n):
  m=input()
  if m =="AC":
     A +=1
  elif m=="WA":
    B+=1
  elif m=="TLE":
    C +=1
  elif m=="RE":
    D +=1

print("AC x ",A)
print("WA x ",B)
print("TLE x ",C)
print("RE x ",D)
  

Measured memory_bytes: 9100
import math
from functools import reduce
 
def gcd(*numbers):
    return reduce(math.gcd, numbers)
ans = 0
k = int(input())
for i in range(1,k+1):
    for j in range(1,k+1):
        for p in range(1,k+1):
            ans += gcd(i,j,p)
print(ans)

Measured memory_bytes: 69476
#include <bits/stdc++.h>
using namespace std;
const int maxx = 1e5 + 7;
char s[maxx], t[maxx];

int main() {
	while(scanf("%s %s", s, t) != EOF) {
		int flg = 0;
		int ls = strlen(s);
		int lt = strlen(t);
		if(ls > lt) puts("GREATER");
		else if(ls < lt) puts("LESS");
		else {
			for(int i = 0; i < ls; i++) {
				if(s[i] > t[i]) {
					flg = 1; break;
				}
				else if(s[i] < t[i]) {
					flg = -1; break;
				}
				else continue;
			}
			if(flg == 1) puts("GREATER");
			else if(flg == -1) puts("LESS");
			else puts("EQUAL");
		}
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
vector<string> freq;
map<string,int> ma ;
map<string,int> ::iterator it;
string s;
int t;

int main()
{
    cin>>s;
    cin>>t;
    int n=s.size();
    for(int i=0;i<n;i++)
    {
        int j=i;
        string tmp;
        for(j=i;j<i+5&&j<n;j++)
        {
            tmp+=s[j];
            ma[tmp]=1;
        }
    }
    for(it=ma.begin();it!=ma.end();it++)
    {
        freq.push_back(it->first);
    }
    sort(freq.begin(),freq.end());
    //for(int i=0;i<freq.size();i++)
    //{
      //  cout<<freq[i]<<" ";
    //}
    //cout<<endl;
    cout<<freq[t-1]<<endl;


}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
#define ll long long
//#define PI 3.14159265
#define PI 3.14159265358979
using namespace std;
 double angleClock(int hour, int minutes) 
 {
        double hourAngle = ((hour % 12) + minutes * 1.0/60) * 30;
        double minutesAngle = minutes * 6;
        double a = abs(hourAngle - minutesAngle);
        double b = 360 - a;
        return a < b ? a : b;
    }
int  main()
{    
  double  a,b;
  double h,m;
  cin>>a>>b>>h>>m;
  double c=angleClock(h,m);
  //cout<<c<<endl;
  double result = cos((PI*c)/180);
  //cout<<result;
  double d=sqrt((a*a+b*b)-(2*a*b)* result);
  printf("%0.20f",d);
  return 0;
  
}

Measured memory_bytes: 4212
#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()
using namespace std;
typedef long long ll;

int main() {
    ll n, m; cin >> n >> m;
    priority_queue<ll> q;   // greatest
    rep(i, n) {
        ll a; cin >> a;
        q.push(a);
    }
    rep(i, m) {
        ll top = q.top();
        q.pop();
        top /= 2;
        q.push(top);
    }
    ll ans = 0;
    rep(i, n) {
        ans += q.top();
        q.pop();
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1400
import java.util.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int y = Integer.parseInt(sc.next());
		sc.close();
		sc = null;
		int a = -1;
		int b = -1;
		int c = -1;
		LABEL:for(i = 0; i <= n; i++) {
			for(j = 0; j <= n-i; j++) {
				if(i*10000 + j*5000 +(n-i-j)*1000 == y) {
					a=i;
					b=j;
					c=n-i-j;
					break LABEL;
				}
			}
		}
		System.out.println(""+a+" "+b+" "+c);
	}
}

Measured memory_bytes: 25044
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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

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

stack<int> sta;

class Dis{
  public:
  vector<ll> rank,p,num;
  
  Dis(int s){
    rank.resize(s,0);
    p.resize(s,0);
    num.resize(s,1);
    rep(i,s) makeSet(i);
  }
  
  void makeSet(int x){
    p[x]=x;
    rank[x]=0;
  }
  
  bool same(int x,int y){
    return findSet(x)==findSet(y);
  }

  void unite(int x,int y){
    link(findSet(x),findSet(y));
  }
  
  void link(int x,int y){
    if(rank[x]>rank[y]){
      p[y]=x;
      sta.push(num[x]*num[y]);
      num[x]+=num[y];
    }
    else{
      p[x]=y;
      sta.push(num[x]*num[y]);
      num[y]+=num[x];
      if(rank[x]==rank[y]) rank[y]++;
    }
  }
  
  int findSet(int x){
    if(x != p[x]) p[x]=findSet(p[x]);
    return p[x];
  }

};


int main(){
  ll n,m;
  cin>>n>>m;
  
  Dis ds=Dis(n);
  
  vector<ll> A(m),B(m);
  ll a,b;
  rep(i,m){
    cin>>a>>b;
    a--,b--;
    A[i]=a,B[i]=b;
  }
  
  for(int i=m-1;i>=0;i--){
    if(ds.same(A[i],B[i])) sta.push(0);
    else ds.unite(A[i],B[i]);
  }
  
  ll t,ans=0;
  rep(i,m){
    t=sta.top(); sta.pop();
    ans+=t;
    cout<<ans<<endl;
  }

  return 0;
}

Measured memory_bytes: 7388
#include <iostream>
using namespace std;
int main(void){
    
    int n;
    cin >> n;
    
    for(int i = 0; i < 3; i++){
        if(n % 10 == 7){
            cout << "Yes" << endl;
            return 0;
        }
        n /= 10;
    }
    
    cout << "No" << endl;
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
LL func(LL A, LL B, LL x) {
    return A * x / B - A * (x / B);
}
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    LL A, B, n; cin >> A >> B >> n;
    LL x = n;
    x /= B, x *= B;
    x--;
    LL ans = func(A, B, n);
    if (x >= 0)
        ans = max(ans, func(A, B, x));
    cout << ans << '\n';

}

Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <array>
#include <queue>

int main(void){
  int x, y;
  std::cin >> x >> y;

  int count = 0;
  count += std::max(400000 - 100000 * x, 0);
  count += std::max(400000 - 100000 * y, 0);
  if(x == 1 && y == 1)
    count += 400000;

  std::cout << count << std::endl;

  return 0;
}


Measured memory_bytes: 256
n = int(input())
h = [int(i) for i in input().split()]
h.reverse()
next = h[0]
import sys
for i in h[1:]:
    if i - next > 1:
        print('No')
        sys.exit()
    elif i - next == 1:
        next = i - 1
    else:
        next = i
print('Yes')

Measured memory_bytes: 14252