akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstring>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main(){
  int n, i, j, leng1=0, leng2=0, flag=0;
  cin >> n;
  int a[n];
  for(i=0; i<n; i++)
    cin >> a[i];
  sort(a, a+n);
  for(i=n-1; i>0; i--){
    if(a[i]==a[i-1]){
      if(leng1==0) leng1=a[i];
      else if(leng1==a[i]&&flag==0) flag++;
      else if(leng1==a[i]&&flag>0) leng2=a[i];
      else if(leng2==0) leng2=a[i];
    }
  }
  cout << (long long)leng1*leng2;
  return 0;
}

Measured memory_bytes: 640
#include <iostream>

using namespace std;

int main(void){
	char str[5];
	cin >> str;
	
	int i,j;
	
	char tmp;
	tmp = str[0];
	for(i = 1; i < 4; ++i){
		if(tmp == str[i]){
			printf("Bad\n");
			return 0;
		}
		tmp = str[i];
	}
	printf("Good\n");
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;

namespace ABC116C
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt;
            var h = ReadInts;

            int[,] map = new int[N + 1, 100];
            for (int i = 0; i < N; i++)
            {
                for (int j = 0; j < 100; j++)
                {
                    if (h[i] >= j + 1) map[i, j] = 1;
                }
            }
            Draw2D(map);
            int count = 0;
            for (int j = 0; j < 100; j++)
            {
                for (int i = 0; i < N; i++)
                {
                    if (map[i, j] == 1 && map[i + 1, j] == 0) count++;
                }
            }
            Console.WriteLine(count);
        }


    }


}

namespace Assistant
{
    static class Input
    {
        static List<string> line = new List<string>();
        static int index = 0;
        static String ReadNext()
        {
            if (line.Count <= index) line.AddRange(Console.ReadLine().Split());
            return line[index++];
        }
        public static int ReadInt => int.Parse(ReadNext());
        public static long ReadLong => long.Parse(ReadNext());
        public static int[] ReadInts => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static long[] ReadLongs => Console.ReadLine().Split().Select(long.Parse).ToArray();
    }

    static class Debug
    {
        static public void Draw2D(int[,] map, int mode = 1)
        {
#if DEBUG
            int W = map.GetLength(0);
            int H = map.GetLength(1);

            int[,] map2 = new int[W + 1, H + 1];
            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (i == 0 && j == 0) map2[i, j] = 0;
                    else if (i == 0) map2[i, j] = j - 1;
                    else if (j == 0) map2[i, j] = i - 1;
                    else map2[i, j] = map[i - 1, j - 1];
                }
            }

            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (mode == 0) Console.Write(map2[i, j] % 10);
                    if (mode == 1) Console.Write(map2[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
#endif
        }

        public static void Draw1D(int[] array, int mode = 0)
        {
#if DEBUG
            Console.WriteLine(string.Join(" ", array));
#endif
        }
    }
}


Measured memory_bytes: 13396
#include<bits/stdc++.h>
 
#define Vsort(a) sort(a.begin(), a.end())
#define Vreverse(a) reverse(a.begin(), a.end())
#define Srep(n) for(int i = 0; i < (n); i++)
#define Lrep(i,a,n) for(int i = (a); i < (n); i++)
#define Brep(n) for(int bit = 0; bit < (1<<n); bit++)
#define rep2nd(n,m) Srep(n) Lrep(j,0,m)
#define vi vector<int>
#define vi64 vector<int64_t>
#define vvi vector<vector<int>>
#define vvi64 vector<vector<int64_t>>
 
using namespace std;

int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  cout << (a + b == c + d ? "Balanced" : a + b > c + d ? "Left" : "Right") << endl;
}


Measured memory_bytes: 3556
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define deb(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;
typedef long long int ll;
typedef string str;

ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;     
  
    x = x % p;   
    while (y) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1;  
        x = (x*x) % p; 
    } 
    return res; 
} 
 
ll nCrModP(ll n, ll r, ll p) 
{ 
    if (!r) 
      return 1; 
  
	ll fac[n+1]; 
   	fac[0] = 1; 
    for (ll i=1 ; i<=n; i++) 
        fac[i] = fac[i-1]*i%p; 
  
    return (fac[n]* power(fac[r], p-2,p) % p * power(fac[n-r], p-2,p) % p) % p; 
}

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

void fast(){
	ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int main ()
{
	// ios::sync_with_stdio(0);
 //    cin.tie(0);
 //    cout.tie(0);
	ll t,n,m,k,i,a,b,j;
	str s,st;
	cin >> s >> st;
	n=0;
	for(i=0;i<s.size();i++)
	{
		if(s[i]!=st[i])
			n++;
	}
	cout << n << "\n";
	return 0;
}

Measured memory_bytes: 3832
#include <stdio.h>
#include <math.h>
#define NMAX 10000

int isPrime(int);

int main(void){

  int i,j,N,inp[NMAX],cnt = 0;

  scanf("%d",&N);
  for(i = 0;i < N;i++){
    scanf("%d",&inp[i]);
    j = isPrime(inp[i]);
    if(j == 1){
      cnt++;
    }
  }
  printf("%d\n",cnt);
  
  return 0;
}

int isPrime(int x){

  int i = 3;

  if(x == 2){
    return 1;
  }
  if((x < 2) ||(x % 2 == 0)){
    return 0;
  }
  while(i <= sqrt(x)){
    if(x % i == 0){
      return 0;
    }
    i += 2;
  }
  return 1;
}



Measured memory_bytes: 2104
mod = 1000000007
N = int(input())
A = []
B = []
for i in range(N):
	A.append(int(input()))
for i in range(N):
	B.append(int(input()))

A.sort()
B.sort()
A.append(mod)
B.append(mod)

ans = 1
a = 0
b = 0

while a != N or b != N:
	if A[a] < B[b]:
		a += 1
		if a > b:
			ans = ans * (a - b) % mod
	else:
		b += 1
		if b > a:
			ans = ans * (b - a) % mod
print(ans)
		

Measured memory_bytes: 62552
/* BISMILLAHIR RAHMANIR RAHIM */
#include<bits/stdc++.h>
#define ll long long
using namespace std;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
  int n,x=0,y=0;
  cin>>n;
   int a,b;
   for(int i=0;i<n;i++){
      cin>>a>>b;
      if(a==b)
         x++;
      else
            x=0;
      if(x>=3)
         y=1;
   }
   if(y)
      cout<<"Yes"<<endl;
   else
      cout<<"No"<<endl;



    return 0;
}


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

int main() {
 int N;
 cin >> N;
 vector<bool> vec(N+1);
 vec.at(1) = 1;
 int K = 2;
  while(K*K <= N){
    vec.at(K*K) = 1;
    K++;
  }
 
  for(int i = N;i>0;i--){
    if(vec.at(i) == 1){
      cout << i <<endl;
      break;
    }
  }
}


Measured memory_bytes: 122368
#include<stdio.h>
int main(void)
{
	int  A,B,C,D,x,y;
	scanf("%d %d %d %d",&A,&B,&C,&D);
	x=A*B;
	y=C*D;
	if(x>=y){
		printf("%d\n",x);
	}
	if(y>x){
		printf("%d\n",y);
	}
	return 0;
}

Measured memory_bytes: 128
n,k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
g = a[0]
for i in 1..n-1
    g = g.gcd(a[i])
end
m = 0
for i in 0..n-1
    m = a[i] if m < a[i]
end
puts (m >= k && (m-k)%g == 0 ? "POSSIBLE" : "IMPOSSIBLE")

Measured memory_bytes: 8452
#include<bits/stdc++.h>
using namespace std;
int main(void)
{
	char a[4];
	cin>>a;
	int x=strlen(a);
	if(x==3){
		swap(a[0],a[2]);
		cout<<a<<endl;
	}
	else{
		cout<<a<<endl;
	}
	return 0;
}

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

using namespace std;

int main() {
	int N;
	cin >> N;
	vector<int>A(N);
	for (int i = 0; i < N; ++i) {
		cin >> A[i];
	}
	sort(A.rbegin(), A.rend());
	int ans = 0;
	for (int i = 0; i < N; ++i) {
		for (int j = i + 1; j < N; ++j) {
			for (int k = j + 1; k < N; ++k) {
				if (A[i] == A[j]) {
					continue;
				}
				if (A[j] == A[k]) {
					continue;
				}
				if ((A[j] + A[k]) > A[i]){
					ans++;
					}
			}
		}
	}
	cout << ans << endl;
		return 0;
}

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

# define ll long long
ll mod=pow(10,9)+7;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    map<int,int> mp;
    mp[0]++;
    mp[1]++;
    mp[2]++;
    mp[3]++;
    mp[4]++;
    mp[5]++;

    int n=5;
    while(n--){
        int x;
        cin>>x;
        mp[x]--;
    }
    for(auto it: mp)
        if(it.second!=0)
        cout<<it.first<<endl;
}


Measured memory_bytes: 3572
# -*- coding: utf-8 -*-


def get_input() -> int:
    """
    標準入力を取得する.

    Returns:\n
        int: 標準入力
    """
    N = int(input())

    return N


def main(N: int) -> None:
    """
    求解処理.

    Args:\n
        N (int): 整数
    """
    # 求解処理
    ans = ""
    while N > 0:
        N -= 1
        ans += chr(ord("a") + N % 26)
        N //= 26
    ans = ans[::-1]

    # 結果出力
    print(ans)


if __name__ == "__main__":
    N = get_input()
    main(N)


Measured memory_bytes: 9080
#include"bits/stdc++.h"
using namespace std;
#define LL long long
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define PB push_back
#define MP make_pair
#define all(x) x.begin(),x.end()
#define MOD 1000000007

int main(){
	int v[5];
	for(int i=0; i<5; i++) cin >> v[i];
	int k;
	cin >> k;
	for(int i=0; i<5; i++){
		for(int j=0; j<5; j++){
			if(abs(v[i]-v[j]) > k){
				cout << ":(" << endl;
				return 0;
			}
		}
	}
	cout << "Yay!" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SIZE 5005
#define MOD 1000000007
using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

ll dp[SIZE];
int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i=1;i<=m;i++) dp[i]=1;
	for(int i=0;i<n;i++)
	{
		ll sum=0;
		for(int j=1;j<=m;j++)
		{
			ll nd=sum+dp[j]*(ll) (j+1);
			nd%=MOD;
			sum*=2LL;
			sum+=dp[j]*(ll) j%MOD;
			sum%=MOD;
			dp[j]=nd;
		}
	}
	printf("%lld\n",dp[m]);
}

Measured memory_bytes: 3860
N, M = map(int, input().split())

md = 10**9 + 7

def m_kaijyo(n) :
    p = 1
    for i in range(1, n + 1) :
        p = p % md * i %md
        p %= md        
    return p

if abs(N - M) in (0, 1) :
    if N == M : 
        print((((m_kaijyo(N) % md) * (m_kaijyo(N) % md)) % md * 2) % md)
    else :
        print(((m_kaijyo(N) % md) * (m_kaijyo(M) % md)) % md)
else :
    print("0")
    


Measured memory_bytes: 3188
b1 = [[0 for i in range(10)] for j in range(3)]
b2 = [[0 for i in range(10)] for j in range(3)]
b3 = [[0 for i in range(10)] for j in range(3)]
b4 = [[0 for i in range(10)] for j in range(3)]

n = int(input())
i = 1
while i <= n:
    b, f, r, v = map(int, input().split())
    if (b == 1):
        b1[f-1][r-1] += v
    elif (b == 2):
        b2[f-1][r-1] += v
    elif (b == 3):
        b3[f-1][r-1] += v
    elif (b == 4):
        b4[f-1][r-1] += v
    i += 1

for i in range(3):
    print('', ' '.join(map(str, b1[i])))
print('#' * 20)
for i in range(3):
    print('', ' '.join(map(str, b2[i])))
print('#' * 20)
for i in range(3):
    print('', ' '.join(map(str, b3[i])))
print('#' * 20)
for i in range(3):
    print('', ' '.join(map(str, b4[i])))

Measured memory_bytes: 7796
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N;scanf("%d",&N);
    long long A[N],B[N],C[N];
    for(int i=0;i<N;i++)scanf("%lld",&A[i]);
    for(int i=0;i<N;i++)scanf("%lld",&B[i]);
    for(int i=0;i<N;i++)scanf("%lld",&C[i]);
    sort(A,A+N),sort(B,B+N),sort(C,C+N);
    long long cntB[N];
    for(int i=0;i<N;i++){
        cntB[i]=C+N-upper_bound(C,C+N,B[i]);
    }
    for(int i=N-2;i>=0;i--)cntB[i]+=cntB[i+1];
    long long ans=0;
    for(int i=0;i<N;i++){
        int p=upper_bound(B,B+N,A[i])-B;
        if(p!=N)ans+=cntB[upper_bound(B,B+N,A[i])-B];
    }
    printf("%lld\n",ans);
    return 0;
}

Measured memory_bytes: 3456
#!/usr/bin/env python3.4

# abc127_b

import itertools

def main():
    # Input
    r, d, x2000 = [int(s) for s in input().split()]
    # Get ans
    ans = list(range(11))
    ans[0] = x2000
    def func(xi, xj):
        return r*xi - d
    ans = list(itertools.accumulate(ans, func))
    # Output
    for i in range(1, 11):
        print(ans[i])

if __name__ == '__main__':
    main()



Measured memory_bytes: 3060
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=LLONG_MAX;
const int inf=INT_MAX;
const int nmax=1e5+5;
const int mod=1e9+7;
using namespace std;
int n,m,i,j;
char a[501][501],b[501][501],c;
int main()
{
    //freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>n>>m;
	for(i=1;i<=n;i++)for(j=1;j<=m;j++)a[i][j]=b[i][j]='.';
	for(i=1;i<=n;i++)a[i][1]=b[i][m]='#';
	for(i=1;i<=n;i++)
	 for(j=2;j<m;j++)
	 {
	 	if(i&1)a[i][j]='#';
	    else b[i][j]='#';
	 }
	for(i=1;i<=n;i++)
	 for(j=1;j<=m;j++)
	 {
	 	cin>>c;
	 	if(c=='#')a[i][j]=b[i][j]='#';
	 }
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)cout<<a[i][j];
		cout<<endl;
	}
	cout<<endl<<endl;
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)cout<<b[i][j];
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    while(cin>>a>>b){
        if(a==0&&b==0)break;
        for(int i=0;i<a;i++){
            for(int j=0;j<b;j++) cout << '#';
            cout << endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
//---------------------------
using namespace std;
//---------------------------
#define REP(i,n) for(int i = 0; i < (n); i++)
#define P(x) cout << (x) << "\n"

#define MOD 1000000007 // 1e9+7
#define PI acos(-1.0)
#define ll long long int // 10^18
#define INF 1000000001 // 1e9+1

int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};
//---------------------------

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

  // ifstream in("input.txt");
  // cin.rdbuf(in.rdbuf());

  int a,b;cin>>a>>b;
  if(a+b<10){
    P(a+b);
  }else{
    P("error");
  }
  return 0;
}

Measured memory_bytes: 256
using System;
class Program
{
        static void Main(string[] args)
        {
                // 整数の入力
                //int a = int.Parse(Console.ReadLine());
                // スペース区切りの整数の入力
                string [] tmp = Console.ReadLine().Split(' ');
                long N = int.Parse(tmp[0]);
        long x = int.Parse(tmp[1]);
                string [] a = Console.ReadLine().Split(' ');
        long[,] b = new long[2001, 2001];

        for (int xx = 0; xx < 2001; xx++) {
            for (int yy = 0; yy < 2001; yy++) {
                b[xx, yy] = 0;
            }
        }

        long t = 0;
        long bl = 0;
                long s = 0;

        long ans = long.MaxValue;

        for (long k = 0; k < N; k++) {
            for (int i = 0; i < N; i++) {
                bl = (i < k) ? 1 : 0;
                t = i - k + N * bl;
                //Console.WriteLine(a[t]);
                if (k == 0) {
                    b[k, i] = int.Parse(a[t]);
                } else {
                    b[k, i] = Math.Min(b[k-1, i], int.Parse(a[t]));
                }
            }
            s = 0;
            for (int z = 0; z < N; z++) {
                s += b[k, z];
            }

            ans = Math.Min(s + x * k, ans);
            //Console.WriteLine(ans);
        }

                //出力
                Console.WriteLine(ans);
        }
}


Measured memory_bytes: 34264
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define INF 1e9

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;
typedef long long i64;
typedef vector<long long int> vll;

int main() {
	double n, m, d;
	cin >> n >> m >> d;
	if (d == 0) {
		cout << fixed << setprecision(20) << ((m - 1) / n) << endl;
	}
	else {
		cout << fixed << setprecision(20) << (2 * (n - d)*(m - 1) / n / n) << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    #define fio ios_base::sync_with_stdio(false), cin.tie(NULL)
    #define ll long long int
    #define ld long double
    #define f(a, b) for (ll i = a; i < b; i++)
    #define in(a, b) (b.find(a) != string::npos)
    #define X first
    #define Y second
    #define vi vector<int>
    #define fill(a, x) memset(a, x, sizeof(a))
    #define pb push_back
    #define pf push_front
    #define mp make_pair
    #define all(v) v.begin(), v.end()
    #define el "\n"
    const ll M = 1e9 + 7;
    using namespace std;

    int main() {
    fio;
    int n;string s;
    cin>>s;
    n=s.size();
    int cnt,mx=0;
    for(int i=0;i<n;i++){
        cnt=0;
        for(int j=i;j<n;j++){
            if(s[j]=='A' || s[j]=='C' || s[j]=='G' || s[j]=='T'){
                cnt++;
                mx=max(mx,cnt);
            }
            else{
                break;
            }
        }
    }
    cout<<mx<<el;
    return 0;
    }


Measured memory_bytes: 256
a = int(input())
b = int(input())
c = int(input())
x = int(input())
count = 0
for i in range(0, a+1):
  for j in range(0, b+1):
    for k in range(0, c+1):
      if (i*500 + j*100 + k*50) == x:
        count += 1
print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(void){
  int N;
  cin >> N;
  std::string c;
  cin >> c;


  int rn = 0;
  int cor_pos_r=0;
  int ans=0;

//  for(int i=0; i<N; i++) cout << c[i] << endl;
  for(int i=0; i<N; i++) if(c[i]=='R') rn++;
  for(int i=0; i<rn; i++) if(c[i]=='R') cor_pos_r++; 
  ans = rn-cor_pos_r;

  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3736
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<set>
#include<algorithm>
#include<numeric>
#include<limits>
#include<bitset>
#include<functional>
#include<type_traits>
#include<queue>
#include<stack>
#include<array>
#include<random>
#include<utility>
#include<cstdlib>
#include<ctime>

using namespace std;

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

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep2(i, begin_i, end_i) for (int i = (int)begin_i; i < (int)end_i; i++)

long long INF = 1LL<<60;
long long dp[100010];
int h[100010];
int main(){

    int a,b,c,d,out;
    string o;
    cin>>a>>b;
    out=a*a-b;
    cout<<out<<endl;
    return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
    /*#ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif*/
        /* 
        Ofcourse it's Hard.
        It's supposed to be Hard.
        If it's easy everyone would do it.
        HARD IS WHAT MAKES IT GREAT

        YESTERDAY U SAID TOMORROW

        SLOWLY BECOMING THE PERSON I 
        SHOULD HAVE BEEN A LONG TIME AGO

        SAME TASK CAN'T BE FOUND DIFFICULT TWICE

        BTBHWSITW

        SPRH TU KAB P

        CP IS ALL ABOUT THINKING 
        YOU HAVE MUCH MORE POTENTIAL THAN U THINK

        AJIT SHIDDAT 10

        UR DAILY ROUTINE 


        */

fast();
//ll t;cin>>t;while(t--)
{
    ll n,m,s=0;
    cin>>n>>m;
    for(int i=0;i<m;i++)
    {
        ll x;
        cin>>x;
        s+=x;
    }
    if(s<=n)
    {
        cout<<n-s<<endl;
    }
    else
    {
        cout<<-1<<endl;
    }
}
return 0;
}

Measured memory_bytes: 3652
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();

		if (N % 1000 == 0) {
			System.out.println(0);
		} else {
			System.out.println(1000 - (N % 1000));
		}

	}
}

Measured memory_bytes: 35544
/*
[diverta2019-2] B - Picking Up
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

const int MAX_N = 50;

int N;
int x[MAX_N], y[MAX_N];
map<pii, int> cnt;

ll solve() {
    int max_cnt = 0;
    pii max_p = {-1, -1};
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (i == j) {
                continue;
            }
            pii p = {x[i] - x[j], y[i] - y[j]};
            cnt[p]++;
            if (max_cnt < cnt[p]) {
                max_cnt = cnt[p];
                max_p = p;
            }
        }
    }

    return N - cnt[max_p];
}

int main() {
    cin >> N;
    for (int i = 0; i < N; i++) {
        cin >> x[i] >> y[i];
    }

    cout << solve() << endl;

    return 0;
}


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


int main(){
	int n,c=0;
	cin>>n;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		if((i+1)%2==1&&x%2==1)	c++;
	}
	cout<<c<<endl;
}

Measured memory_bytes: 3596
#input of int(split by space)
def get_i()
  return gets.chomp.split(" ").map(&:to_i)
end
#input of float(split by space)
def get_f()
  return gets.chomp.split(" ").map(&:to_f)
end
#input of string(split by space)
def get()
  return gets.chomp.split(" ")
end
#input of string(split per one character)
def get_nsp()
  return gets.chomp.split("")
end
#yes or no decision
def yn_judge(bool,y="Yes",n="No")
  return bool ? y : n 
end
#create of array
def array(size1,init=nil,size2=-1)
  if size2==-1
    return [init]*size1
  else
    return [[init]*size2]*size1
  end
end

def max(a,b)
    return a>b ? a : b
end

def min(a,b)
    return a>b ? b : a
end

INF=Float::INFINITY

N=gets.to_i
kind=Hash.new(0)
N.times do
    s=gets.chomp
    kind[s]+=1
end
M=gets.to_i
M.times do
    t=gets.chomp
    kind[t]-=1
end
max=0
kind.each do|k,v|
    max=max(max,v)
end
puts max

Measured memory_bytes: 1788
#include <bits/stdc++.h>
// from https://atcoder.jp/contests/abc143/submissions/8034843
using namespace std;
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
template<class T>
inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}
 
template<class T>
inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
 
const ll INF = 1e17;
ll N, M, L, Q;
ll fuel[305][305];
ll dist[305][305];
ll s[105000], t[105000];
ll A[100000], B[100000], C[100000];
 
void input() {
    cin >> N >> M >> L;
    for(int i = 1; i <= M; i++) cin >> A[i] >> B[i] >> C[i];
    cin >> Q;
    for(int i = 1; i <= Q; i++) cin >> s[i] >> t[i];
}
 
void solve() {
    input();
    for(int i = 1; i <= N; i++) {
        for(int j = 1; j <= N; j++) {
            fuel[i][j] = INF;
            dist[i][j] = INF;
        }
        fuel[i][i] = 0;
        dist[i][i] = 0;
    }
    for(int i = 1; i <= M; i++) {
        chmin(fuel[A[i]][B[i]], C[i]);
        chmin(fuel[B[i]][A[i]], C[i]);
    }
    for(int i = 1; i <= N; i++) {
        for(int j = 1; j <= N; j++) {
            for(int k = 1; k <= N; k++) {
                chmin(fuel[j][k], fuel[j][i] + fuel[i][k]);
            }
        }
    }
    for(int i = 1; i <= N; i++) {
        for(int j = 1; j <= N; j++) {
            if(i == j) continue;
            if(fuel[i][j] <= L) chmin(dist[i][j], 1LL);
        }
    }
    for(int i = 1; i <= N; i++) {
        for(int j = 1; j <= N; j++) {
            for(int k = 1; k <= N; k++) {
                chmin(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
    for(int i = 1; i <= Q; i++) {
        if(dist[t[i]][s[i]] < INF) cout << dist[t[i]][s[i]] - 1 << "\n";
        else cout << -1 << "\n";
    }
    return;
}
 
int main() {
    solve();
    return 0;
}

Measured memory_bytes: 4864
#include "bits/stdc++.h"
#include <random>
#define REP(i, n) for (ll i = 0; i < ll(n); ++i)
#define RREP(i, n) for (ll i = ll(n) - 1; i >= 0; --i)
#define FOR(i, m, n) for (ll i = m; i < ll(n); ++i)
#define RFOR(i, m, n) for (ll i = ll(n) - 1; i >= ll(m); --i)
#define ALL(v) (v).begin(), (v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)), v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

constexpr int dx[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };
constexpr int dy[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };

using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, k, s;
  cin >> n >> k >> s;
  int t;
  if (s == 1e9)t = 1;
  else t = s + 1;
  vi ans(n);
  REP(i, k)ans[i] = s;
  FOR(i, k, n)ans[i] = t;
  REP(i, n)cout << ans[i] << " ";
  cout << endl;
}


Measured memory_bytes: 1792
import java.util.Scanner;

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

    int N = scanner.nextInt();
    int T = scanner.nextInt();
    int[] a = new int[N];
    for (int i = 0; i < N; i++) a[i] = scanner.nextInt();

    int[] max = new int[N];
    max[N - 1] = a[N - 1];
    for (int i = N - 2; i >= 0; i--) max[i] = Math.max(a[i], max[i + 1]);
    int[] min = new int[N];
    min[0] = a[0];
    for (int i = 1; i < N; i++) min[i] = Math.min(a[i], min[i - 1]);

    int cnt1 = 0;
    int maxDiff = 0;
    for (int i = 0; i < N; i++) {
      int diff = max[i] - a[i];
      if (diff > maxDiff) {
        cnt1 = 1;
        maxDiff = diff;
      } else if (diff == maxDiff) {
        cnt1++;
      }
    }

    int cnt2 = 0;
    maxDiff = 0;
    for (int i = N - 1; i >= 0; i--) {
      int diff = a[i] - min[i];
      if (diff > maxDiff) {
        cnt2 = 1;
        maxDiff = diff;
      } else if (diff == maxDiff) {
        cnt2++;
      }
    }

    System.out.println(Math.min(cnt1, cnt2));
  }
}


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

using namespace std;

int my_max(int a, int b) {
    return a > b ? a : b;
}

int my_abs(int x) {
    return x < 0 ? -x : x;
}

int main() {

    int n;
    cin >> n;
    int datas[100000][3];
    for(int i=0; i<n; i++) {
        cin >> datas[i][0] >> datas[i][1] >> datas[i][2];
    }

    unsigned long long sum = 0;
    unsigned long long dp[100010][3] = {0};

    dp[0][0] = datas[0][0];
    dp[0][1] = datas[0][1];
    dp[0][2] = datas[0][2];

    for(int i=1; i<n; i++) {
//        dp[i][0] = max(datas[i][0]+dp[i-1][1], datas[i][0]+dp[i-1][2]);
//        dp[i][1] = max(datas[i][1]+dp[i-1][0], datas[i][1]+dp[i-1][2]);
//        dp[i][2] = max(datas[i][2]+dp[i-1][0], datas[i][2]+dp[i-1][1]);
        for(int j=0; j<3; j++) {
            for(int k=0; k<3; k++) {
                if(j!=k) {
                    dp[i][j] = max(dp[i][j], datas[i][j]+dp[i-1][k]);
                }
            }
        }
    }

    cout << max(max(dp[n-1][0], dp[n-1][1]), dp[n-1][2]) << endl;

    return 0;
}


Measured memory_bytes: 3712
#include<iostream>

using namespace std;

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

int main(){
    int n, k;
    cin >> n >> k;
    int num = (n - 1) * (n - 2);
    num /= 2;
    if (k > num) {
        cout << -1 << endl;
        return 0;
    }
    


    // 辺の数
    int m = (n - 1) + (num - k);

    pair<int, int> p[m];
    for(int i = 1; i < n; i++){
        p[i-1].first = 1;
        p[i-1].second = i + 1;
    }
    
    int idx = n - 1;
    if (idx == m) {
        cout << m << endl;
        for(int l = 0; l < m; l++){
            cout << p[l].first << ' ' << p[l].second << endl;
        }
        return 0;
    }
    for(int i = 1; i < n - 1; i++){
        for(int j = i + 1; j < n; j++){
            p[idx].first = i + 1;
            p[idx].second = j + 1;
            idx++;
            if (idx == m) {
                cout << m << endl;
                for(int l = 0; l < m; l++){
                    cout << p[l].first << ' ' << p[l].second << endl;
                }
                return 0;
            }
        }
    }
}

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

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

  for (int i = 0; i <= n; i++) {
    for (int j = 0; j <= m; j++) {
      if (i*(m-j)+j*(n-i) == k) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }

  cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 256
S = input()
ans = 0
while True:
  if len(S) <= 1:
    break
  if S[0] == 'x' and S[-1] != 'x':
    ans += 1
    S = S[1:]
  elif S[0] != 'x' and S[-1] == 'x':
    ans += 1
    S = S[:-1]
  elif S[0] == S[-1]:
    S = S[1:-1]
  else:
    ans = -1
    break
print(ans)

Measured memory_bytes: 3316
# frozen_string_literal: true

def z_algorithm(s)
  n = s.size
  return [] if n == 0
 
  z = [0]*n
  j = 0
  1.upto(n-1){ |i|
    z[i] = j+z[j] <= i ? 0 : j+z[j]-i < z[i-j] ? j+z[j]-i : z[i-j]
    z[i] += 1 while i+z[i]<n && s[z[i]]==s[i+z[i]]
    j = i if j+z[j] < i+z[i]
  }
  z[0] = n
  return z
end

s, t = $<.map &:chomp

ss = s+s
ss << s while ss.size < t.size*2
z = z_algorithm(t+ss)[t.size,s.size].map{ |z| z >= t.size }

vis = [false]*s.size

ans = (0 ... s.size).map{ |u|
  next if vis[u]
  vis[u] = true
  now = u
  cnt = 0
  while z[now]
    now = (now+t.size) % s.size
    vis[now] = true
    cnt += 1
    break if now == u
  end
  now==u && cnt.nonzero? ? 10**9 : cnt
}.compact.max

ans = -1 if ans >= 10**9
puts ans


Measured memory_bytes: 50756
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


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

    int ans = 1000-(n%1000);
    ans %= 1000;

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define ll long long

using namespace std;

const int maxn = 1e5+10;

int a[maxn],b[maxn],c[maxn],n;
ll res;

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>n;
    for (int i=1;i<=n;i++) cin>>a[i];
    for (int i=1;i<=n;i++) cin>>b[i];
    for (int i=1;i<=n;i++) cin>>c[i];
    sort(a+1,a+n+1);
    sort(b+1,b+n+1);
    sort(c+1,c+n+1);
    int ia=0,ic=0;
    for (int i=1;i<=n;i++) {
        while (ia+1<=n && a[ia+1] < b[i]) ia++;
        while (ic+1<=n && c[ic+1] <= b[i]) ic++;
        //cout<<b[i]<< " " <<ia<< " "<<ic<<endl;
        res += 1ll*ia*(n-ic);
    }
    cout<<res<<endl;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int a,b;

//int GCD (int x,int y) {
//    if (y == 0) return x;
//    if (x < y) return GCD(x,y%x);
//}
int main() {
    cin >> a >> b;
    int t = __gcd(a,b);
    printf("%d\n",t);
}



Measured memory_bytes: 3212
import java.util.Scanner;

public class Main {

     static Scanner scanner;

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

         int N=gi();
         long[] A=new long[N];

         long ans=0;
         int f=0;
         int t=0;
         int o=0;
         for (int i=0; i<N;i++) {
        	 A[i]=gi();
        	 if(A[i]%4==0) {
        		 f++;
        	 } else if(A[i]%2==0) {
        		 t++;
        	 } else {
        		 o++;
        	 }
         }
         if(t>0)o++;
         if((f!=0 && f+1>=o) || (t==N)) {
        	 System.out.println("Yes");
         } else {
        	 System.out.println("No");
         }
         
     }

     // 文字列として入力を取得
     public static String gs() {
          return scanner.next();
     }

     // intとして入力を取得
     public static int gi() {
          return Integer.parseInt(scanner.next());
     }

     // longとして入力を取得
     public static long gl() {
          return Long.parseLong(scanner.next());
     }

     // doubleとして入力を取得
     public static double gd() {
          return Double.parseDouble(scanner.next());
     }
}

Measured memory_bytes: 60188
use itertools::{iproduct, Itertools};
use proconio::input;

fn main() {
    input!(n: usize, k: usize, ijc: [(usize, usize, char); n]);
    let mut g = vec![vec![0; k + 1]; k + 1];
    let mut b_count = 0;
    let mut w_count = 0;
    for &(i, j, c) in &ijc {
        g[i % k + 1][j % k + 1] += if ((i / k + j / k) % 2 == 1) ^ (c == 'W') {
            w_count += 1;
            1
        } else {
            b_count += 1;
            -1
        };
    }
    for (i, j) in iproduct!(0..k, 0..k) {
        g[i + 1][j + 1] += g[i + 1][j] + g[i][j + 1] - g[i][j];
    }

    let (min, max) = iproduct!(0..k, 0..k)
        .map(|(i, j)| g[k][k] - g[i][k] - g[k][j] + 2 * g[i][j])
        .minmax()
        .into_option()
        .unwrap();
    println!("{}", std::cmp::max(-min + w_count, max + b_count));
}


Measured memory_bytes: 10228
## ABC113C - ID
import sys
input = sys.stdin.readline

def main():
    n, m = list(map(int, input().rstrip().split()))
    ans = [""] * m
    arr = []
    cnt = 1
    for i in range(m):
        p, y = list(map(int, input().split()))
        arr += [(p, y, i)]
    arr = sorted(arr)

    ans[arr[0][2]] = "{:06}{:06}".format(arr[0][0], cnt)
    for i in range(1, m):
        if arr[i - 1][0] == arr[i][0]:
            cnt += 1
        else:
            cnt = 1
        ans[arr[i][2]] = "{:06}{:06}".format(arr[i][0], cnt)

    for i in ans:
        print(i)


if __name__ == "__main__":
    main()

Measured memory_bytes: 29080
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
const int MOD = 1e9+7;
#define PI 3.14159265359
typedef long long ll;
using namespace std;

int coun1[21];

int digit(int x){
	int coun = 0;
	if (x == 0) return 1;
	while (x != 1){
		x /= 2;
		coun++;
	}
	return coun + 1;
}

bool is_ok(){
	for (int i = 0; i <= 20; i++){
		if (coun1[i] > 1) return false;
	}
	return true;
}

int main(){
	int n;
	cin >> n;
	vector<ll> a(n);
	for (int i = 0; i < n; i++){
		cin >> a[i];
	}
	int from = 0;
	ll ans = 0;
	for (int to = 0; to < n; to++){
		for (int i = 0; i < digit(a[to]); i++){
			if (a[to] & (1<<i)) coun1[i]++;
		}
		while (!is_ok()){
			for (int i = 0; i < digit(a[from]); i++){
				if (a[from] & (1<<i)) coun1[i]--;
			}
			from++;
		}
		ans += to - from + 1;
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
  char b;cin>>b;
  if(b=='A')cout<<"T";
  if(b=='T')cout<<"A";
  if(b=='G')cout<<"C";
  if(b=='C')cout<<"G";
}
      

Measured memory_bytes: 256
n = int(input())
s = input()
ans = 0
for i in range(n):
    a = list(set(s[:i]))
    b = list(set(s[i:]))
    l_a = len(a)
    l_b = len(b)
    c = list(set(a+b))
    l_c = len(c)
    ans = max(ans,l_a+l_b-l_c)
print(ans)

Measured memory_bytes: 38384
#include<stdio.h>
#include<string.h>

int main(void){
	char A[201],buf[201];
	int n,i,h;

	while(1){
		scanf("%s",A);
		if(strcmp(A,"-")==0) break;
		scanf("%d",&n);
		for(i=0;i<n;i++){
			scanf("%d",&h);
			strcpy(buf,A+h);
			strncat(buf,A,h);
			strcpy(A,buf);
		}
		printf("%s\n",A);
	}
	return 0;
}

Measured memory_bytes: 600
N,M,X = map(int,input().split())
C = [0]*N
A = []
for i in range(N):
    temp = list(map(int,input().split()))
    C[i] = temp[0]
    A.append(temp[1::])


t = 10e15 
count = 0

array = []
def dfs(v,n,value):
    global t
    global count
    if n == N-1:
        if len(v) != 0 and all([i >= X for i in [sum(j) for j in zip(*v)]]):
            t=min(t,value)
        return 
    v.append(A[n+1])
    dfs(v,n+1,value+C[n+1])
    v.pop()
    dfs(v,n+1,value)

a =[]
dfs([],-1,0)

print(t if t!=10e15 else -1)


Measured memory_bytes: 9160
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <list>
using namespace std;
static const int MAX = 10000;
static const int INFTY = (1<<29);

vector<int> G[MAX];
list<int> out;
bool V[MAX];
int N;
int indeg[MAX];

void bfs(int u) {
  queue<int> q;
  q.push(u);
  V[u] = true;
  while (!q.empty()) {
    int u = q.front(); q.pop();
    out.push_back(u);
    for (int i = 0; i < G[u].size(); i++) {
      int v = G[u][i];
      indeg[v]--;
      if (indeg[v] == 0 && !V[v]) {
        V[v] = true;
        q.push(v);
      }
    }
  }
}

void tsort() {
  for (int i = 0; i < N; i++) {
    indeg[i] = 0;
  }
  for (int u = 0; u < N; u++) {
    for (int i = 0; i < G[u].size(); i++) {
      int v = G[u][i];
      indeg[v]++;
    }
  }

  for (int u = 0; u < N; u++) {
    if (indeg[u] == 0 && !V[u]) bfs(u);
  }

  for (list<int>::iterator it = out.begin(); it != out.end(); it++) {
    cout << *it << endl;
  }
}

int main() {
  int s, t, M;
  cin >> N >> M;
  for (int i = 0; i < N; i++) {
    V[i] = false;
  }
  for (int i = 0; i < M; i++) {
    cin >> s >> t;
    G[s].push_back(t);
  }
  tsort();
  return 0;
}



Measured memory_bytes: 4116
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn =new Scanner(System.in);
		int n = scn.nextInt();
		int b = scn.nextInt();
		for(int i=0;i<=1000;i++){
		   if(Math.floor((i*0.08))==n && Math.floor((i*0.1))==b){
			   System.out.println(i);
			   return;
		   }
		}
		System.out.println("-1");
		

	}

}


Measured memory_bytes: 23888
//#include <bits/stdc++.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <string.h>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <queue>
#include <math.h>
#include <assert.h>
#define ff first
#define ss second
#define ll long long
#define mod 998244353
using namespace std;
ll x, y, a, b, c, aa[100009], bb[100009], cc[100009], ans;
int main () {
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
//    freopen("task2-test-input.txt", "r", stdin);
//    freopen("task2-test-output.txt", "w", stdout);
    cin>>x>>y>>a>>b>>c;
    for(int i=1;i<=a;i++)
        cin>>aa[i];
    for(int i=1;i<=b;i++)
        cin>>bb[i];
    for(int i=1;i<=c;i++)
        cin>>cc[i];
    sort(aa + 1, aa + a + 1);
    reverse(aa + 1, aa + a + 1);
    sort(bb + 1, bb + b + 1);
    reverse(bb + 1, bb + b + 1);
    sort(cc + 1, cc + c + 1);
    reverse(cc + 1, cc + c + 1);
    for(int i=1;i<=x;i++)
        ans += aa[i];
    for(int i=1;i<=y;i++)
        ans += bb[i];
    ll cnt = 0, ma = 0;
    for(int i = 1; i <= c; i++) {
        cnt += cc[i];
        if(x == 0 && y == 0)
            break;
        if((x && aa[x] < bb[y]) || y == 0) {
            cnt -= aa[x];
            x--;
        }
        else {
            cnt -= bb[y];
            y--;
        }
        ma = max(ma, cnt);
    }
    cout<<ans + ma;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
  #pragma GCC target ("avx2")
  #pragma GCC optimization ("O3")
  #pragma GCC optimization ("unroll-loops")
  using ll = long long;
  using ld = long double;
  #define whatis(x) cout << "> "<<#x << " ==> " << x << endl;
  #define br cout<< "\n";
  #define endl "\n"
  #define vi vector<int>
  #define vii vector<ll>
  #define pll pair<ll,ll>
  #define vpll vector<pll>
  #define pii pair<int,int>
  #define pcl pair<char,ll>
  #define pb push_back
  #define eb emplace_back
  #define mp make_pair
  #define lb lower_bound
  #define ub upper_bound
  #define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
  #define all(v) begin(v),end(v)
  #define minv(a) *min_element(all(a))
  #define maxv(a) *max_element(all(a))
  #define outputv(a) for(auto i:a) cout<<i<<" ";br;
  #define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  #define outputvp(a) for(auto j:a) {cout<<j.first<<" " << j.second << ",",br;}
  #define T ll t;cin>>t;while(t--)
  using namespace std;

  const ll mod = 1000000007;
  const ll inf = 1000000000000000000;
  const ll rk = 256;
  const ld PI = 3.141592653589793;
  

  int dr[]={1,-1,0,0};
  int dc[]={0,0,1,-1};

  // ll isPrime[1000001];

  // void primeDivisors(map<ll,ll> &mapi, ll n){
  //   while(n > 1){
  //     if(isPrime[n] == -1){
  //       mapi[n]+=1;
  //       break;
  //     }
  //     else{
  //       mapi[isPrime[n]]+=1;
  //       n/=isPrime[n]; 
  //     }
  //   }
  // }


// void seive(){
//   ll maxn = 10000001;
//   isPrime[0] = 0; isPrime[1] = 0;
//   rep(i,2,maxn) isPrime[i] = -1;
//   for(int i=2; i*i < maxn; i++){
//     if(isPrime[i] == -1){
//       for(int j=i*i; j < maxn; j+=i){
//         if(isPrime[j] == -1){
//           isPrime[j] = i;
//         }
//       } 
//     }
//   }

// }

 ll power( ll base, ll power, ll mod){
    ll res = 1;
    while( power ){
      if(power%2) res= (res*base)%mod, power--;
      else base= (base * base)%mod, power/=2;
    }

    return res;
  }

    void inout(){
      // seive();
      #ifndef ONLINE_JUDGE
          // for getting input from input.txt
          freopen("/home/logan/contest/ongoing/input.txt", "r", stdin);
          // for writing output to output.txt
          freopen("/home/logan/contest/ongoing/output.txt", "w", stdout);
      #endif
  }

  

  int main(){
     FastIO
     // seive();
    //inout();

    // T{
      ll n; cin >> n;
      ll tmp = 1000;
     while(tmp < n ){
      tmp+=1000;
     }
     cout << tmp - n << endl;


      

    // }
    





  return 0;
  }

 

Measured memory_bytes: 3652
#include <iostream>

int main() {
	int n, y;

	std::cin >> n;
	std::cin >> y;

	int m;
	int g;
	int s;
	for (m = n; m >= 0; m--) {
		if (m * 10000 > y) continue;
		for (g = n - m; g >= 0; g--) {
			if (m * 10000 + g * 5000 > y) continue;
			for (s = n - m - g; s >= 0; s--) {
				if (m * 10000 + g * 5000 + s * 1000 > y) continue;

				if (m * 10000 + g * 5000 + s * 1000 == y && m + g + s == n) {
					goto found;
				}
			}
		}
	}

	std::cout << "-1 -1 -1" << std::endl;

	return 0;

found:
	std::cout << m << " " << g << " " << s << std::endl;

	return 0;
}


Measured memory_bytes: 256
import sys
import os
import math
import bisect
import collections
import itertools

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: x * y / math.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def f(A, B, x):
    return math.floor(A * x / B) - A * math.floor(x / B)


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, K = il()
    A = collections.Counter(il())
    cnt = sorted([v for v in A.values()])

    ret = 0
    for i in range(len(cnt) - K):
        ret += cnt[i]

    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 34324
X,Y = (str(i) for i in input().split())

XY_dict = {"A":10,"B":11,"C":12,"D":13,"E":14,"F":15}

X_int = int(XY_dict[X])
Y_int = int(XY_dict[Y])

if X > Y:
  print(">")
elif X < Y:
  print("<")
else:
  print("=")


Measured memory_bytes: 3060
#include<cstdio>
using namespace std;

int main(){
  int h,w;
  int map[50][50];
  int ans[50][50];

  while(scanf(" %d %d ",&h,&w)!=EOF){
    
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	char c;
	scanf(" %c ",&c);
	map[i][j] = c-'0';
	ans[i][j] = 1<<31-1;
      }
    }

    ans[0][0] = 0;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	if(j && ans[i][j]>ans[i][j-1]+map[i][j])ans[i][j] = ans[i][j-1]+map[i][j];
	if(i && ans[i][j]>ans[i-1][j]+map[i][j])ans[i][j] = ans[i-1][j]+map[i][j];
      }
    }

    printf("%d\n",ans[h-1][w-1]);
  }
}

Measured memory_bytes: 0
if __name__ == '__main__':
    n = int(input())
    a = list(map(int, input().split()))
    b = list(map(int, input().split()))
    c = list(map(int, input().split()))
    d = a[0]
    sums = 0
    for i in range(1, n):
        if a[i] - d == 1:
            sums += c[a[i-1]-1]
        d = a[i]
    for j in range(n):
        sums += b[j]
    print(sums)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,cc,n) for(int i=cc;i<=n;++i)
#define drep(i,cc,n) for(int i=cc;i>=n;--i)
#define sz(s) (int)(s.size())
#define vecprint(v) rep(i,0,v.size()-1)cout << v[i] << " ";cout << endl;
#define mod 1000000007
using namespace std;

int main(){
    int n;

    cin >> n;

    int a,ans[n];

    rep(i,0,n-1){
        cin >> a;
        ans[a-1]=i+1;
    }

    rep(i,0,n-1)cout << ans[i] << endl;
//  printf("%.10f\n",ans);

    return 0;
}

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

int solve(string S1, string S2) { 
	int n = S1.size(), m = S2.size(); 
	int ans = INT_MAX; 

	for (int i = 0; i < m - n + 1; i++) { 
		int temor = 0; 
		for (int j = 0; j < n; j++) { 
			if (S1[j] != S2[i + j]) { 
				temor++; 
			} 
		} 

		ans = min(temor, ans); 
	} 
	return ans; 
} 

int main(){
    string s, t;
    cin >> s;
    cin >> t;
    cout << solve(t, s) << endl;
}

Measured memory_bytes: 3612