akhauriyash/Code-Regression huggingface dataset:
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
using namespace std;
using ll = long long;
#define pi 3.141592653589793
#define eps 0.00000001
#define LONG_INF 3000000000000000000
#define rep(i,n) for(long long i = 0;i < n;++i)    
#define seg_size 524288

int main(){
    double a,b,x;
    cin>>a>>b>>x;
    
    double na;
    double nb;
    //cout<<a<<endl<<b<<endl;
    if(2*x>a*a*b){
        na=a*a*a;
        nb=2*(a*a*b-x);
    }
    else{
        na=2*x/(a*b);
        nb=b;
    }
    
    double ans=0;
    ans=atan(na/nb);
    //cout<<ans<<endl;
    ans=90-ans/pi*180;
    printf("%.10f\n",ans);

    return 0;
}

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

int main() {
  int N;
  cin >> N;
  int total = 0;
  vector<int> xs;
  for(int n = 1; n <= N; ++n) {
    total += n;
    xs.push_back(n);
    if(total >= N) {
      break;
    }
  }
  int y = total - N;
  for(auto x : xs) {
    if(x != y) {
      cout << x << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <algorithm>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

int A, B, K;

int gcd( int a, int b )
{ return b ? gcd(b,a%b) : a; }

int main()
{
  scanf( "%d%d%d", &A, &B, &K );

  int cnt = 0;

  for( int i = std::min(A,B); i >= 1; --i ) if( A % i == 0 && B % i == 0 )
  {
    ++cnt;

    if( cnt == K )
      printf( "%d\n", i );
  }

  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<math.h>

using namespace std;

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

int INF = 10e8;
int sig[20001];
int code[16];
int dp[20001][256];

int cut(int i){
    if(i>=255){
        return 255;
    } else if(i<=0){
        return 0;
    } else {
        return i;
    }
}

int main(){
    while(1){
        int n, m;
        cin >> n >> m;
        if(n==0) break;

        REP(i, m){
            int c;
            cin >> c;
            code[i] = c;
        }

        REP(i, n){
            int s;
            cin >> s;
            sig[i+1] = s;
        }

        REP(i, n+1){
            REP(j, 256){
                dp[i][j] = INF;
            }
        }
        dp[0][128] = 0;

        REP(i, n){
            REP(j, 256){
                if(dp[i][j] != INF){
                    REP(k, m){
                        int tmpsig = cut(j+code[k]);
                        int sd = dp[i][j] + pow(tmpsig - sig[i+1], 2);
                        if(sd < dp[i+1][tmpsig]){
                            dp[i+1][tmpsig] = sd;
                        }
                    }
                }
            }
        }

        /*
        REP(i, 256){
            REP(j, n){
                cout << dp[j][i] << " ";
            }
            cout << endl;
        }
        */

        int output = INF;
        REP(i, 256){
            if(dp[n][i] < output){
                output = dp[n][i];
            }
        }
        cout << output << endl;
    }
}

Measured memory_bytes: 23140
#include <bits/stdc++.h>
#define maxn 200005
using namespace std;
typedef long long ll;
ll a[maxn]={0};
int main()
{
   ll n,i;
   cin>>n;
   for(i=1;i<=n;i++)
   {
       scanf("%lld",&a[i]);
   }
   ll sum1=0,sum2=0;
   ll ans1=0,ans2=0;
   for(i=1;i<=n;i++)
   {   sum1+=a[i];
       if(i%2==0&&sum1>=0)
       {
           ans1+=abs(sum1)+1;
           sum1=-1;
       }
       else if(i%2!=0&&sum1<=0)
       {
           ans1+=1+abs(sum1);
           sum1=1;
       }
   }
   for(i=1;i<=n;i++)
   {
       sum2+=a[i];
       if(i%2==0&&sum2<=0)
       {
           ans2+=1+abs(sum2);
           sum2=1;
       }
       else if(i%2==1&&sum2>=0)
       {
           ans2+=abs(sum2)+1;
           sum2=-1;
       }
   }
   cout<<min(ans1,ans2)<<endl;
   return 0;
}


Measured memory_bytes: 1024
def main():
    N = int(input())
    A = list(map(int, input().split()))

    # C[x]: 書かれている整数がxであるカードの枚数
    C = [0] * (N + 1)
    D = [0] * (N + 1)
    for a in A:
        C[a] += 1
        D[C[a]] += 1

    # AからK(1<=K<=N)枚ずつカードを抜いてったときに、
    # x回以上抜くことができるか判定する。
    # 抜くことができると判定されたxの最大値が答えになる。

    # 例えば、A = [1 1 1 1 1 2 2 3] とする。
    # -> C = [5 2 1 0 0 0 0 0]
    # ここから2枚ずつカードを抜ける回数を考えるとき、
    # 「3回抜く」とすると、数字の1は、どうやっても2個は絶対余る
    # そこで、絶対余る部分を捨ててCを作り直す(=Eとする)と、
    # E = [3 2 1 0 0 0 0 0]
    # ここから2枚ずつ3回抜けるか判定するなら、
    # sum(E) >= 2 * 3 = 6
    # であるか見ればよい。今回の場合ちょうど6なので、2枚ずつ3回は抜ける。
    
    # 3枚ずつ2回ぬけるか調べる場合、
    # E = [2 2 1] となり、sum(E) = 5 < 3 * 2 = 6 なので、抜けないことが分かる

    # よって、
    # sum(min(C[i], x)) >= K * x であれば抜くことができる
    # S(x) = sum(min(C[i], x)) とすると、
    # S(x) = S(x-1) + [Cの中でC[i] >= x であるものの個数]
    # となることから、Cの中でC[i] >= x であるものの個数 = D(x) とすると、
    # S(x) = sum_(1~x) D(i) となる。
    # つまり、S(x)は、D(x) を最初に全部計算しておいて、累積和をとることで高速に計算できる。

    # S(x) >= K * x となるxの最大値を、kを1からNまで動かして見つければよい。
    # ここで、xを左辺にもっていって、
    # S(x) / x >= Kとなるxの最大値を見つけるようにする。
    # また、S(x) / x = f(x) とおく。

    # 最大値を見つけるために2分探索してもいいが、
    # Kが増えると、答えは以前の値以下になるはずなので、
    # K+1のとき、Kでの答えの位置から0へと探索していけば、O(N)で答えが見つかる
    S = [0] * (N + 1)
    f = [0] * (N + 1)
    for x in range(1, N+1):
        S[x] = S[x-1] + D[x]
        f[x] = S[x] // x

    ans = []
    prev_ans = N
    for K in range(1, N+1):
        a = prev_ans
        while True:
            if f[a] >= K or a == 0:
                break
            a -= 1
        ans.append(a)
        prev_ans = a

    print(*ans, sep='\n')

if __name__ == '__main__':
    main()

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

using namespace std;

int main(void)
{
    double a,b,h,m;
    cin>>a>>b>>h>>m;
    h = h * 30.0 + m * 0.5;
    m = m * 6.0;

    double sa;
    if(h < m){
        sa = m- h;
    }
    else{
        sa = h - m;
    }
    if(sa > 180.0){
        sa = 360.0 - sa;
    }
    double kaku = (double)sa * M_PI/ 180.0;
    double aa = (double)a;
    double bb = (double)b;
    //cout<<"aa = "<<aa<<", bb = "<<bb<<endl;
    //cout<<"cos = " << cos(kaku)<<endl;
    //cout<<"kaku = "<<kaku<<endl;
    //cout<<"sa = "<<sa<<endl;

    double ans = aa*aa + bb*bb - 2.0 * aa * bb * cos(kaku);
    ans = sqrt(ans);

    printf("%.10lf\n",ans);

    return 0;
}

Measured memory_bytes: 4212
import sys

def input():
    return sys.stdin.readline().strip()

def main():
    N,W = map(int,input().split())
    goods = [list(map(int,input().split())) for _ in range(N)]

    dp = [[0 for _ in range(W+1)] for _ in range(N+1)]

    for i in range(N):
        for w in range(W+1):
            if w >= goods[i][0]:
                dp[i+1][w] = max(dp[i][w-goods[i][0]]+goods[i][1],dp[i][w])
            else:
                dp[i+1][w] = dp[i][w]
    print(dp[N][W])

if __name__ == "__main__":
    main()

Measured memory_bytes: 171528
#include <stdio.h>
                                                                                                
  
int main(void){
                                                                                                
   
    long long a, b, c, d, m;
         
   
    scanf("%lld %lld %lld %lld", &a, &b, &c, &d );
   

    m = a * b;

    if( m < c * d ){

        m = c * d;

        printf("%lld\n", m );

        return 0;

        }

    else{

          printf("%lld\n", m );

          return 0;

          }

    return 0;
                                                          
}

Measured memory_bytes: 128
#include <stdio.h>


int main(){
	
	int i,a,max=0,min=1001,n[101];
	
	scanf("%d",&a);
	
	for(i=0;i<a;i++){
		scanf("%d",&n[i]);
		if(n[i]>max)max=n[i];
		if(n[i]<min)min=n[i];
	}
	
	printf("%d\n",max-min);
	
	return 0;
}


Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS

//#define DEBUG
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>


int main() {
#ifdef DEBUG

#endif
	int N;
	scanf("%d", &N);

	long long int L[87] = { 0 };
	L[0] = 2;
	L[1] = 1;
	int i;
	for (i = 2; i < 87; i++) {
		L[i] = L[i - 2] + L[i - 1];
	}
	printf("%lld\n", L[N]);

}

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

int main(){
    int M;
    cin >> M;
    vector<int64_t> D(M), C(M);
    for(int i=0; i<M; i++) cin >> D[i] >> C[i];

    int64_t sum = 0, dig = 0;
    for(int i=0; i<M; i++){
        dig += C[i];
        sum += D[i]*C[i];
    }

    int64_t ans = (sum-1)/9 + dig - 1;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3328
#include<bits/stdc++.h>
using namespace std;
int n,a[20000010];
bool x(int i,int j,int k) {
    return a[i]<=k&&a[j]<=k;
}
bool y(int i,int j,int k){
    return a[i]>k&&a[j]>k;
} 
bool check(int a){
    for(int i=0;i<n-1;i++){
        if(y(n+i,n+i+1,a)||y(n-i,n-i-1,a)) return 0;
        if(x(n+i,n+i+1,a)||x(n-i,n-i-1,a)) return 1;
    }
    return x(1,1,a);
}
int main(){
    scanf("%d",&n);
    for(int i=1;i<=2*n-1;i++) scanf("%d",&a[i]);
    int l=1,r=2*n-1,mid;
    while(l<r){
	 	mid=(l+r)/2;
        if(check(mid)) r=mid;
        else l=mid+1;
    }
    printf("%d",l);
    return 0; 
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
#define int long long int
#define pb push_back
#define mp make_pair
#define mem(a,b) memset(a,b,sizeof(a))
#define MOD 1000000007
using namespace std;
void fun(int w,int a[],int b[],int n ){
    int dp[w+1][n+1];
    for(int i=0;i<=w;i++){
        for(int j=0;j<=n;j++){
            if(i==0 || j==0){
                dp[i][j]=0;
            }
            else if(a[j-1]>i){
                dp[i][j]=dp[i][j-1];
            }
            else{
                dp[i][j]=max(b[j-1]+dp[i-a[j-1]][j-1],dp[i][j-1]);
            }
        }
    }
    cout<<dp[w][n];
}
int32_t main(){
    int n,w,i;
    cin>>n>>w;
    int a[n],b[n];
    for(i=0;i<n;i++){
        cin>>a[i]>>b[i];
    }
    fun(w,a,b,n);
}

Measured memory_bytes: 79104
#include<bits/stdc++.h>
using namespace std;
#define   int      long long
#define   fast()   ios_base::sync_with_stdio(0);cin.tie(0)
int INF=1e9;
int N,A,B,C;
vector<int> v;
int dfs(int cur,int a,int b,int c)
{if(cur==N)
 {if(min({a,b,c})>0)
  return abs(A-a)+abs(B-b)+abs(C-c)-30;
  return INF;
 }
 int w=dfs(cur+1,a,b,c);
 int x=dfs(cur+1,a+v[cur],b,c)+10;
 int y=dfs(cur+1,a,b+v[cur],c)+10;
 int z=dfs(cur+1,a,b,c+v[cur])+10;
 return min({w,x,y,z});
}
int32_t main()
{int i;
 fast();
 cin>>N>>A>>B>>C;
 v=vector<int>(N);
 for(i=0;i<N;++i)
 cin>>v[i];
 cout<<dfs(0,0,0,0);
 return 0;
}





Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
const int INF=999999999;

int main() {
 int x1,y1,x2,y2;
 cin>>x1>>y1>>x2>>y2;
 
 int dx=x2-x1;
 int dy=y2-y1;
 int x3=x2-dy;int y3=y2+dx;
 int x4=x3-dx;int y4=y3-dy;
 cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4<<endl;
 return 0;}

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

int main(){
  int a,b;
  cin>>a>>b;
  if(a<0 || a>9){
    cout<<-1<<endl;
  }
  else if(b<0 || b>9){
    cout<<-1<<endl;
  }
  else{
    cout<<a*b<<endl;
  }  
  
  return 0;
}

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

int main(){
string s1,s2;
  cin >>s1>>s2;
 if(s1.at(0)==s2.at(2) && s1.at(1)==s2.at(1) && s1.at(2)==s2.at(0)){
 cout <<"YES"<<endl;
}
  else{
  cout<<"NO"<<endl;
  }
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int N,i=1;
    long long A,M=1;
    cin >> N;
    while(cin >> A){
        if(A==0){
            M=0;
            break;
        }else if(A<=1000000000000000000/M && M>0){    
            M=M*A;
            i++;
            if(i>N) break;
        }else{
            M=-1;
            i++;
            if(i>N) break;
        }   
    }
    /*掛け算する前にけりを付ける！*/
        cout << M << endl;
    return 0;
}

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

#define INF_LL (int64)1e18
#define INF (int32)1e9
#define REP(i, n) for(int64 i = 0;i < (n);i++)
#define FOR(i, a, b) for(int64 i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
#define fs first
#define sc second

using int32 = int_fast32_t;
using uint32 = uint_fast32_t;
using int64 = int_fast64_t;
using uint64 = uint_fast64_t;
using PII = pair<int32, int32>;
using PLL = pair<int64, int64>;

const double eps = 1e-10;

template<typename A, typename B>inline void chmin(A &a, B b){if(a > b) a = b;}
template<typename A, typename B>inline void chmax(A &a, B b){if(a < b) a = b;}

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value!=0>::type
fill_v(U &u,const V... v){u=U(v...);}

template<typename T,typename U,typename... V>
typename enable_if<is_same<T, U>::value==0>::type
fill_v(U &u,const V... v){
  for(auto &e:u) fill_v<T>(e,v...);
}

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

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

  int64 N, W, H;
  cin >> N >> W >> H;
  vector<int64> X(W+2, 0), Y(H+2, 0);
  REP(i, N) {
    int64 x, y, w;
    cin >> x >> y >> w;
    X[max((int64)0, x-w)]++;
    X[min((int64)W+1, x+w)]--;
    Y[max((int64)0, y-w)]++;
    Y[min((int64)H+1, y+w)]--;
  }
  REP(i, W) X[i+1] += X[i];
  REP(i, H) Y[i+1] += Y[i];
  bool ok1 = 1, ok2 = 1;
  REP(i, W) {
    if (X[i] <= 0) ok1 = 0;
  }
  REP(i, H) {
    if (Y[i] <= 0) ok2 = 0;
  }
  if (ok1 || ok2) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}



Measured memory_bytes: 4412
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint n;
    cin >> n;
    n++;
    deque<int> ret;
    int curr = 1;
    int fst  = 64 - __builtin_clzll(n) - 1;
    for (int i = fst; i >= 0; --i) {
        if ((n >> (i)) & 1) {
            ret.push_front(curr++);
        }
        if (i != 0 && i != fst)
            ret.push_back(curr++);
    }
    int nr = ret.size();
    for (int i = 0; i < nr; ++i) {
        ret.push_back(i + 1);
    }
    assert((int)ret.size() <= 200);
    cout << ret.size() << "\n";
    for (int i = 0; i < (int)ret.size(); ++i) {
        if (i)
            cout << " ";
        cout << ret[i];
    }
    cout << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 45

int F[N];
int fibonacci(int n){
  if(n==0||n==1)
    return F[n]=1;
  if(F[n]!=0)
    return F[n];
  return F[n]=fibonacci(n-2)+fibonacci(n-1);
}

int main(){
  int n,i;
  for(i=0;i<N;i++)
    F[i]=0;
  scanf("%d",&n);
  printf("%d\n",fibonacci(n));
  return 0;
}



Measured memory_bytes: 2112
#include<bits/stdc++.h>
#define FAST_IO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define INF (1e10+5)
#define F first
#define S second
#define pb push_back
#define MP make_pair
#define FRL(i,a,n) for(i=a;i<n;i++)
#define FR(i,n) FRL(i,0,n)
#define RFRL(i,n) for(i=n;i>=0;i--)
#define MOD 1000000007
#define fill(a) memset(dp,a,sizeof(dp));

using namespace std;

typedef long long int  ll;

typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef vector< pair<ll,ll> > vpi;
typedef set<ll> st;
typedef map<ll,ll> mp;
typedef unordered_map<ll,ll> ump;

template< class T>
T minn(T a,T b)
{
	return (a>b)?b:a;
}
template< class T>
T maxx(T a,T b)
{
	return (a>b)?a:b;
}


void FILE_OP()
{
	#ifndef ONLINE_JUDGE
        freopen("inputf.txt", "r", stdin);
        freopen("output2.txt", "w", stdout);
    #endif
}
ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}
ll n;
vi v(100005);
ll dp[100005];
/*ll frog(ll i,ll c)
{
	if(i>n)
		return 0;
	
	c=c+minn(frog(i+1,abs(v[i-1]-v[i])),frog(i+2,abs(v[i-2]-v[i])));
	return c;

}*/




void SOLVE()
{

	
	ll tt,m,i,j,k,a,b,c,d,l,r;
	//cin>>tt;
	tt=1;
	fill(0)
	while(tt--)
	{
		cin>>n;
		
		FR(i,n)
			cin>>v[i];
		dp[0]=0;dp[1]=abs(v[1]-v[0]);
		for(i=2;i<n;i++)
		{
			dp[i]+=minn(dp[i-1]+abs(v[i]-v[i-1]),dp[i-2]+abs(v[i]-v[i-2]));
		}
		cout<<dp[n-1];
		
	}


		
}

int main()
{
	FAST_IO
	//FILE_OP();
	SOLVE();
	
	return 0;
}

Measured memory_bytes: 1792
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;

namespace AtCoder
{
    class Program
    {
        static void Main()
        {
            var S = ReadLine();
            if (S[2] == S[3] && S[4] == S[5]) WriteLine("Yes");
            else WriteLine("No");
        }
    }
}

Measured memory_bytes: 11092
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    int n, m;
    cin >> n >> m;
    vector<int> cnt(1e5+1, 0);
    rep(i, m) {
        int a, b;
        cin >> a >> b;
        ++cnt[a], ++cnt[b];
    }
    rep(i, 1e5+1) {
        if (cnt[i]&1) {
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
    return 0;
}


Measured memory_bytes: 3788
import java.util.*;

public class Main {

    public static void main(String[] args) {
        final long INF = (long) 1e15;

        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] a = new int[n+1];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }
        a[n] = 0;

        long ans = 0;
        int l = 0;
        int r = 0;
        int tmp = a[0];
        while(l < n){
            if((tmp&a[r+1]) == 0 && r < n-1){
                r++;
                tmp |= a[r];
            }else{
                ans += r-l+1;
                tmp ^= a[l];
                l++;
            }
        }

        System.out.println(ans);
    }
}


Measured memory_bytes: 83236
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))
ans = 0
for i in range(N):
    if A[i] <= B[i]:
        ans += A[i]
        B[i] -= A[i]
        if A[i+1] >= B[i]:
            ans += B[i]
            A[i+1] -= B[i]
        else:
            ans += A[i+1]
            A[i+1] = 0
    else:
        ans += B[i]

print(ans)


Measured memory_bytes: 24220
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <math.h>
#include <stdlib.h>
#include <algorithm>
#define rep(i,n) for (int i = 0; i < (n); ++i)
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; }

//INT_MAX	2,147,483,647 = 2*1.0e9

int main(){
  int N, M;
  cin >> N >> M;

  vector<ll> A(N);
  rep(i, N) cin >> A[i];

  vector<pair<ll, ll>> BC(M);
  rep(i, M){
    ll B, C;
    cin >> B >> C;
    BC.push_back(make_pair(C, B));
  }

  sort(A.begin(), A.end());
  sort(BC.rbegin(), BC.rend());

  int pos = 0;
  bool done = false;
  for(int i = 0; i < M; i++){
    pair<ll, ll> cp = BC[i];
    ll cpc = cp.first; ll cpb = cp.second;
    for(int j = 0; j < cpb; j++){
      if(A[pos] < cpc){
        A[pos] = cpc;
        pos += 1;
      } else {
        done = true;
        break;
      }
      if(pos == N){
        done = true;
        break;
      }
    }
    if(done) break;
  }
  ll ans = 0;
  for(int i = 0; i < N; i++) ans += A[i];

  cout << ans <<endl;

  return 0;
}



Measured memory_bytes: 5760
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
#define N 55
inline int read(){
	int x=0,f=1;
	char c=getchar();
	while(c<'0'||c>'9'){
		if(c=='-')f=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9'){
		x=(x<<1)+(x<<3)+c-'0';
		c=getchar();
	}
	return x*f;
}
int n,x[N],y[N],ans;
int Solve(int p,int q){
	int tot=n;
	for(int i=1;i<=n;++i){
		for(int j=1;j<=n;++j){
			if(x[i]+p==x[j]&&y[i]+q==y[j]){
				--tot;
				break;
			}
		}
	}
	return tot;
}
int main(){
	n=read();
	for(int i=1;i<=n;++i){
		x[i]=read(),y[i]=read();
	}
	ans=n;
	for(int i=1;i<=n;++i){
		for(int j=1;j<i;++j){
			ans=min(ans,Solve(x[i]-x[j],y[i]-y[j]));
		}
	}
	printf("%d\n",ans);
	return 0;
}



Measured memory_bytes: 3760
#include <iostream>
#include <algorithm>
#define N 100005
using namespace std;

struct Node{
	int x; int t;
	Node(){t = 0;}
}a[N], b[N];
bool cmp(Node w, Node q) {
	return w.t > q.t;
}
int main() {
	int n, x, y, ans = 0;
	cin >> n;
	for(int i = 1; i <= n/2; i++) {
		cin >> x >> y;
		a[x].t++, a[x].x = x;
		b[y].t++, b[y].x = y;		
	}
	sort(a+1, a+1+N, cmp);
	sort(b+1, b+1+N, cmp);
	int i = 1, j = 1;
	while(a[i].x == b[j].x) {
		if(a[i+1].t > b[j+1].t)
			i ++;
		else j ++;
	}
	ans = n - a[i].t - b[j].t;
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define NL            "\n"
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
map<string,int>sad;
int a[100005];
int main()
{
    _SAD()
    string s;
    cin>>s;
    for(int i=0;i<SZ(s);i++)
    {
        if(s[i]=='9')
        {
            cout<<"Yes"<<NL;
            return 0;
        }
    }
    cout<<"No"<<NL;
    return 0;
}


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

using namespace std;
typedef pair<int,int> pii;
typedef long long int ll;

#define INF 1 << 30
#define REP(i,n) for(ll i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(ll i=(k);i<(int)(n);i++)

string s;

int main(){
  cin >> s;
  int a,b;
  a=b=0;
  REP(i,s.size()){
    if(s[i]=='0') a++;
    if(s[i]=='1') b++;
  }
  cout << min(a,b)*2 <<endl;
}


Measured memory_bytes: 512
r, c = map(int, input().split())
a = []
rsum = []

for i in range(r):
    a.append(list(map(int, input().split())))
    a[i].append(sum(a[i]))
    print(" ".join(list(map(str, a[i]))))

csum = []
for j in range(c+1):
    su = 0
    for i in range(r):
        su += a[i][j]
    csum.append(su)

print(" ".join(list(map(str, csum))))


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

typedef long long lint;

lint s[200010],ans=0;
int x[200010],n;

int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		int a;
		scanf("%d",&a);
		s[i]=s[i-1]+a;
		x[i]=x[i-1]^a;
	}
	int end=1;
	for(int start=1;start<=n;start++){
		for(;(s[start]-s[end-1])!=(x[start]^x[end-1]);end++);
		ans+=start-end+1;
	}
	printf("%lld",ans);
	return 0;
}


Measured memory_bytes: 2560
fun main(args: Array<String>) {
    val out = java.io.PrintWriter(System.out)
    solve(java.util.Scanner(System.`in`), out)
    out.flush()
}

fun solve(sc: java.util.Scanner, pw: java.io.PrintWriter) {
    val N = sc.nextInt()
    val X = (0 until N).map { sc.nextLong() }

    val Xs = X.sorted()
    val midL = Xs[N / 2 - 1]
    val midR = Xs[N / 2]

    for (i in 0 until N) {
        pw.println(if (X[i] < midR) midR else midL)
    }
}


Measured memory_bytes: 82528
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,a,b) for(int i=(a),_end_=(b);i<=_end_;i++)
#define DREP(i,a,b) for(int i=(a),_end_=(b);i>=_end_;i--)
#define EREP(i,u) for(int i=start[u];i;i=e[i].next)
#define fi first
#define se second
#define mkr(a,b) make_pair(a,b)
#define SZ(A) ((int)A.size())
template<class T>inline void chkmin(T &a,T b){ if(a>b)a=b;}
template<class T>inline void chkmax(T &a,T b){ if(a<b)a=b;}
inline int read()
{
	int s=0,f=1;char ch=getchar();
	while(!isdigit(ch) && ch!='-')ch=getchar();
	if(ch=='-')ch=getchar(),f=-1;
	while(isdigit(ch))s=s*10+ch-'0',ch=getchar();
	return ~f?s:-s;
}

const int maxn=3e5+20;

int n,L;
int x[maxn],t[maxn];
int a[maxn],b[maxn],vis[maxn];
ll ans;

inline void init()
{
	n=read();L=read();
	REP(i,1,n)x[i]=read();
	REP(i,1,n)
	{
		t[i]=read();
		ans+=t[i]/(L<<1);
		t[i]%=L<<1;
		if(!t[i]){ vis[i]=1; continue;}
		if(t[i]<=2*(L-x[i]))a[i]=1;//右进左出
		if(t[i]<=2*x[i])b[i]=1;//左进右出
		if(a[i]+b[i]==0){ vis[i]=1; ans++; continue;}
	}
	vector<int>t01;
	queue<int>t11;
	
	REP(i,1,n-1)
	{
		if(a[i] || b[i])
		{
			if(b[i])
			{
				if(a[i])t11.push(i);
				else t01.push_back(i);
			}else
			{
				if(!t01.empty())vis[t01.back()]=1,vis[i]=1,t01.pop_back(),ans++;
				else if(!t11.empty())vis[t11.front()]=1,vis[i]=1,t11.pop(),ans++;
				//else;
			}
		}
	}
	t01.clear(); while(!t11.empty())t11.pop();
	REP(i,1,n-1)if(!vis[i])
	{
		if(b[i])
		{
			if(a[i])
			{
			 	if(!t01.empty())vis[t01.back()]=1,vis[i]=1,t01.pop_back(),ans++;
			 	else t11.push(i);
			}else t01.push_back(i);
		}//else if(!t11.empty())vis[t11.front()]=1,vis[i]=1,t11.pop(),ans++;
	}
	while(SZ(t11)>=2)
	{
		int x=t11.front(); t11.pop();
		int y=t11.front(); t11.pop();
		vis[x]=1; vis[y]=1; ans++;
	}
	/*
	if(vis[n]==0 && a[n])
	{
		REP(i,1,n-1)if(vis[i]==0 && b[i])
		{
			vis[i]=vis[n]=1;
			ans++;
			break;
		}
		}*/
	REP(i,1,n)
	{
		if(!vis[i])
		{
			ans++;
		}
	}
	ans+=(vis[n] || !a[n]);
	printf("%lld\n",ans*(L<<1));
}

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


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

#define FORE(i, a) for (auto i = a.begin(); i != a.end(); ++i)
#define REPU(i, a, b) for (int i = (a); i < (b); ++i)
#define REPD(i, a, b) for (int i = (a); i > (b); --i)
#define MEM(a, x) memset(a, x, sizeof(a))
#define ALL(a) a.begin(), a.end()
#define UNIQUE(a) a.erase(unique(ALL(a)), a.end())

vector<string> split(const string &s, char c) {
	vector<string> v;
	stringstream ss(s);
	string x;
	while (getline(ss, x, c)) v.push_back(x);
	return v;
}

#define DEBUG(args...) { vector<string> _v = split(#args, ','); err(_v.begin(), args); }

void err(vector<string>::iterator it) {}

template<typename T, typename... Args>
void err(vector<string>::iterator it, T a, Args... args) {
	cerr << "[DEBUG] " << it -> substr((*it)[0] == ' ', it -> length()) << " = " << a << '\n';
	err(++it, args...);
}

typedef long long ll;
const int MOD = 1000000007;

template<class T, class U> inline T tmin(T a, U b) { return (a < b) ? a : b; }
template<class T, class U> inline T tmax(T a, U b) { return (a > b) ? a : b; }
template<class T, class U> inline void amax(T &a, U b) { if (b > a) a = b; }
template<class T, class U> inline void amin(T &a, U b) { if (b < a) a = b; }
template<class T> inline T tabs(T a) { return (a > 0) ? a : -a; }
template<class T> T gcd(T a, T b) { while (b != 0) { T c = a; a = b; b = c % b; } return a; }

int main(int argc, char *argv[]) {
	ios_base::sync_with_stdio(false);

	int w, h;
	cin >> h >> w;
	vector<string> a(h);
	REPU(i, 0, h) cin >> a[i];
	REPU(i, 1, h) {
		int last = -1;
		REPU(j, 0, w) if (a[i - 1][j] == '#') {
			last = j;
		}
		REPU(j, 0, last) if (a[i][j] == '#') {
			puts("Impossible"); return 0;
		}
	}
	puts("Possible");

	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<vector>
#define DIM 300005
using namespace std;
int n, m, i, x, y, s, t, j, nod, vecin, p, u;
int c[DIM], d[DIM];
vector<int> v[DIM];
int main(){
    cin>> n >> m;
    for(i = 1; i <= m; i++){
        cin>> x >> y;
        for(j = 0; j < 3; j++){
            v[x * 3 + j].push_back(y * 3 + (j + 1) % 3);
        }
    }
    cin>> s >> t;
    d[s * 3] = 1;
    p = u = 1;
    c[1] = s * 3;
    while(p <= u){
        nod = c[p];
        p++;
        for(i = 0; i < v[nod].size(); i++){
            vecin = v[nod][i];
            if(d[vecin] == 0){
                d[vecin] = d[nod] + 1;
                c[++u] = vecin;
            }
        }
    }
    if(d[t * 3] == 0){
        cout<< -1;
    }
    else{
        cout<< d[t * 3] / 3;
    }
}


Measured memory_bytes: 18944
h,w,k = map(int, input().split())
s = []
ans = [[0]*w for i in range(h)]
stroberry = [False]*h

for i in range(h):
    _input = list(input())
    s.append(_input)
    if '#' in set(_input):
        stroberry[i] = True

num = 1
for height in range(h):
    if stroberry[height] is True:
        First = True
        for width in range(w):
            if s[height][width] == '.':
                ans[height][width] = num
            else:
                if First:
                    ans[height][width] = num
                    First = False
                else:
                    num += 1
                    ans[height][width] = num
        num += 1
    elif height!=0:
        ans[height] = ans[height-1]

zero_num = 0
end_cake = 0
for i in range(h):
    if ans[i][0]==0:
        zero_num+=1
    else:
        end_cake = i
        break
for g in range(zero_num):
    ans[g] = ans[end_cake]

for l in range(h):
    print(*ans[l])
        

Measured memory_bytes: 8272
#include <stdio.h>

int main(){
  int K,A,B;
  scanf("%d %d %d",&K,&A,&B);
  
  int L=K;
  int sw=0;
  
  while(L<=B){
    if(A<=L){
      sw=1;
    }
    
    L=L+K;
  }
  
  if(sw==1){
    printf("OK\n");
  }else{
    printf("NG\n");
  }
  return 0;
}

Measured memory_bytes: 1660
using System;
using System.Collections.Generic;
using System.Text;

namespace AOJ
{
    class Program
    {
        static void Main(string[] args)
        {
            var inputLine = Console.In.ReadLine();
            var inputs = inputLine.Split(new char[] { ' ', '\t', '　' });
            if (inputs.Length != 3)
            {
                return;
            }

            var integers = new List<int>();
            foreach (var s in inputs)
            {
                integers.Add(int.Parse(s));
            }

            var start = integers[0];
            var end = integers[1];
            var target = integers[2];

            int count = 0;
            for (int i = start; i <= end; ++i)
            {
                if ((target % i) == 0)
                {
                    ++count;
                }
            }

            Console.WriteLine(count.ToString());
        }
    }
}


Measured memory_bytes: 17932
// template version 1.6
// {{{ define basic macro
using namespace std;
#include <iostream>
#include <bits/stdc++.h>
// varibable settings
#define int long long
#define INF 1000000000000000000LL
// #define INF 2147483647
#define MOD 1000000007LL
// #define MOD 998244353LL
#define infile "../test/sample-1.in"

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)
template<class T, size_t N> size_t sza(const T (&array)[N]) { return N; }
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
template<class T=int> T in() {T x; cin>>x; return (x);}
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

// dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
#define fi first
#define se second

// }}}

int solve(){
  int a,b,c;cin>>a>>b>>c;
  cout << (a*b)/2 << endl;

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


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

int main() {
  int N, T, A;
  cin >> N >> T >> A;
  vector<int> h(N);
  for (int i = 0; i < N; i++) {
    cin >> h.at(i);
  }

  vector<float> t(N);
  int ans;
  float mint = 1000;
  
  for (int i = 0; i < N; i++) {
    t.at(i) = abs(A-(T-h.at(i)*0.006));
    if (mint > t.at(i)) {
      mint = t.at(i);
      ans = i+1;
    }
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int a[10000];
  int n,i,max,min;
  long long int sum;

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

  max = min = sum = a[0];
  
  for(i=1;i<n;i++){
    if(max < a[i]) max = a[i];
    if(min > a[i]) min = a[i];
    sum += a[i];
  }

  printf("%d %d %lld\n",min,max,sum);
  
  return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define int long long
#define vec(a,n) vector<int> (a)((n));
#define Vec(a,n) vector<string> (a)((n));
#define twovec(a,n,m) vector<vector<int>> a(n,vector<int>(m,0));
#define Twovec(a,n,m) vector<vector<double>> a(n,vector<double>(m,0));
#define P pair<int,int>
#define All(a) (a).begin(),(a).end()
#define Sort(a) sort(All(a));
#define Reverse(a) reverse(All(a));
#define PQ(n) priority_queue<P,vector<P>,greater<P>> (n)
#define pq(n) priority_queue<int> (n)
#define print(a) cout << (a) << endl
#define printD(a) cout << setprecision(15) << (a) << endl;
using namespace std;
int max_int = 2147483647;
int prime = 998244353;
void Debug(auto a);
double PI = 3.14159265358979;
int n;


signed main(){
    set<P> s;
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    int h,w,m;
    cin >> h >> w >> m;
    // twovec(a,h,w);
    vec(c,h+1);
    vec(d,w+1);
    REP(i,m){
        int x,y;
        cin >> x >> y;
        x--;y--;
        // a[x][y]++;
        c[x]++;
        d[y]++;
        s.insert(P(x,y));
    }
    int tmpc = -1 * INT_MAX;
    REP(i,h+1){
        if(c[i]> tmpc){
            tmpc = c[i];
        }
    }
    int tmpd = -1 * INT_MAX;
    REP(i,w+1){
        if(d[i]> tmpd){
            tmpd = d[i];
        }
    }
    vector<int> e = {};
    vector<int> f = {};
    // print(tmpc);
    // print(tmpd);
    int ans = tmpc + tmpd;
    REP(i,h+1){
        if(c[i] == tmpc){
            e.push_back(i);
        }
    }
    REP(i,w+1){
        if(d[i] == tmpd){
            f.push_back(i);
        }
    }
    bool is = true;
    // Debug(f);
    
        REP(i,e.size()){
            REP(j,f.size()){
                if(s.count(P(e[i],f[j])) == 0){
                    //print("come");
                    is = false;
                    goto end;
                }
            }
        }
    end:
    if(is) ans--;
    print(ans);
    return 0;
}

void Debug(auto a){
    cout << "{ ";
    for(auto b: a){
        cout << b << " ";
    }
    cout << "}" << endl;
}

Measured memory_bytes: 34980
#include<iostream>
#include<cstdio>
#include<cstring>
#include<queue>
#include<map>
using namespace std;
typedef long long ll;
inline ll read(){
    ll x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9'){
        if(c=='-')f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9'){
        x=(x<<3)+(x<<1)+c-'0';
        c=getchar();
    }
    return x*f;
}
int T;
ll n,A,B,C,D;
priority_queue<pair<ll,ll>,vector<pair<ll,ll> >,greater<pair<ll,ll> > > q;
map<ll,ll> mp;
inline ll Abs(ll x){
	return x>=0?x:-x;
}
int main(){
	T=read();
	while(T--){
		mp.clear();
		n=read(),A=read(),B=read(),C=read(),D=read();
		while(!q.empty())q.pop();
		q.push(make_pair(0,n));
		ll ans=0x3f3f3f3f3f3f3f3f;
		mp[n]=0;
		while(true){
			ll u=q.top().second,w=q.top().first;
			if((double)u*D+w<=4e18)ans=min(ans,u*D+w);
			q.pop();
			if(w>ans){
				printf("%lld\n",ans);
				break;
			}
			for(ll i=max(0LL,u-10);i<=u+10;++i){
				ll k=Abs(i-u)*D;
				if(i%2==0&&(!mp.count(i/2)||mp[i/2]>w+k+A))mp[i/2]=w+k+A,q.push(make_pair(w+k+A,i/2));
				if(i%3==0&&(!mp.count(i/3)||mp[i/3]>w+k+B))mp[i/3]=w+k+B,q.push(make_pair(w+k+B,i/3));
				if(i%5==0&&(!mp.count(i/5)||mp[i/5]>w+k+C))mp[i/5]=w+k+C,q.push(make_pair(w+k+C,i/5));
			}
		}
	} 
	return 0;
}


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

using namespace std;


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

  int prev = 110000;
  int ans = 0;
  rep(i, n - 1) {
    int b; cin >> b;
    ans += min(b, prev);
    prev = b;
  }
  ans += prev;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main()
{
  string s,res="Good";
  cin >> s;
  for(int i=0;i<s.size()-1;i++)
    if(s.substr(i,1)==s.substr(i+1,1))
      res="Bad";
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;


int main(){	
	long long N;
	long long L;
	scanf("%lld",&N);
	vector<long long> a(N-1+1);
	scanf("%lld",&L);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&a[i]);
	}
	
	ll idx = -1;
	rep(i, N-1) {
		if (a[i]+a[i+1] >= L) {
			idx = i;
			break;
		}
	}
	if (idx == -1) {
		cout << "Impossible" << endl;
	} else {
		cout << "Possible" << endl;
		rep(i, idx) {
			cout << i+1 << endl;
		}
		for (ll i = N-2; i>idx; i--) {
			cout << i+1 << endl;
		}
		cout << idx+1 << endl;
	}

	return 0;
}



Measured memory_bytes: 1664
import java.*;
import java.io.*;
import java.util.*; 
 
public class Main
{
	public static void main(String args[]) throws Exception{
		new Main().run();
	}
	
	
	public void run()
	{
		Scanner cin=new Scanner(System.in);
		while(true){
			int a,b;
			a = cin.nextInt();
			b = cin.nextInt();
			if(a==0 && b==0) return;
			int[] taro = new int[a];
			int[] hanako = new int[b];
			int sumt = 0, sumh = 0;
			int i,j;
			for(i=0;i<a;i++){
				sumt += taro[i] = cin.nextInt();
			}
			for(i=0;i<b;i++){
				sumh += hanako[i] = cin.nextInt();
			}
			boolean flag = false;
			for(i=0;i<a;i++){
				for(j=0;j<b;j++){
					if(sumt-sumh==(taro[i]-hanako[j])*2){
						if(!flag){
							flag = true;
							System.out.println(taro[i] + " " + hanako[j]);
						}
					}
				}
			}
			if(!flag) System.out.println(-1);
		}
	}
	
}

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

namespace Atcoder_0404
{
    class Program
    {

        static long mod = 1000000000 + 7;
        static void Main(string[] args)
        {
            HashSet<string> _getList = new HashSet<string>();
            var N = GetInput_long()[0];
            for(long i = 0; i < N; i++)
            {
                _getList.Add(GetInput_string()[0]);
            }

            Console.WriteLine(_getList.Count);
        }
        #region input
        

        static string[] GetInput_string()
        {
            var input = Console.ReadLine().Split(' ');
            return input;
        }

        static int[] GetInput_int()
        {
            var input = GetInput_string();
            var result = new int[input.Length];
            for (int i = 0; i < result.Length; i++)
            {
                result[i] = int.Parse(input[i]);
            }
            return result;
        }
        static long[] GetInput_long()
        {
            var input = GetInput_string();
            var result = new long[input.Length];
            for (int i = 0; i < result.Length; i++)
            {
                result[i] = long.Parse(input[i]);
            }
            return result;
        }
        #endregion
        #region sonota
        static void Swap_array<T>(T[] target, int a, int b)
        {
            T temp = target[a];
            target[a] = target[b];
            target[b] = temp;
        }
        static void Swap_list<T>(List<T> target, int a, int b)
        {
            T temp = target[a];
            target[a] = target[b];
            target[b] = temp;
        }
        /// <summary>
        /// 最大公約数
        /// </summary>
        public static int GCD(int a, int b)
        {

            /* 自然数 a > b を確認・入替 */
            if (a < b)
            {
                int tmp = a;
                a = b;
                b = tmp;
            }

            /* ユークリッドの互除法 */
            int r = a % b;
            while (r != 0)
            {
                a = b;
                b = r;
                r = a % b;
            }
            return b;
        }

        /// <summary>
        /// 最小公倍数
        /// </summary>
        public static int LCM(int a, int b)
        {
            int x = a * b;
            b = GCD(a, b);
            return x / b;

        }
        #endregion
    }
}

Measured memory_bytes: 50832
#include<bits/stdc++.h>
    using namespace std;
    long long m=1000000007;

    #define boost ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #define MAX(a,b) ((a)>(b)?(a):(b))
    #define MIN(a,b) ((a)<(b)?(a):(b))
    #define pb  push_back
    typedef long long ll;
    typedef long double ld; 
    long long M=1e9+7;			
    #define deb_(x)       cerr<< #x <<" : "<< x << endl;
    #define deb(A,N)    cerr <<" :[";for(int i = 0; i<N;i++) cerr<<A[i]<<" "; cerr<<"]\n";
    #define deb2(A,N,M) cerr<< #A << " : \n"; for(int i=0;i<N;i++){cerr<<"[";for(int j=0;j<M;++j) cerr<<A[i][j]<<" ";cerr<<"]\n";}																				
    #define rep(n) for(int i=0;i<n;i++)																		
    #define range(a,b) for(int i=a;i<=b;i++)																	
    #define loop(i,n) for(int i=0;i<n;i++)
	int code();
	   
    int main()
    {   
    	boost;
       ll t=1;
       // cin>>t;
       while(t--){
       	ll b=code();
       }
     
       return 0;
    }

   
    int code(){
    	ll n;
    	cin>>n;
    	ll temp=1,A[n];
    	rep(n){
    		ll x;
    		cin>>x;
    		A[i]=x;
    		if(x==0){
    	cout<<"0"<<endl;
    	return 0;}


    	}  rep(n)
    		{if(A[i]!=0 && temp>1000000000000000000/A[i]){
    		    		
    		
    		    			cout<<"-1"<<endl;
    		    			return 0;
    		    		}
    		    		temp*=A[i];}
    	cout<<temp<<endl;
    	return 0;
    		}
    



Measured memory_bytes: 4400
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<"\n"
using namespace std; typedef long long ll; typedef vector<int> vi; typedef vector<ll> vll;
template<class T>using vv = vector<vector<T>>; template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T>bool chmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
template<class T>bool chmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;
ll mpow(ll x, ll n) { ll y = 1; for (; n > 0; n /= 2) { y = n % 2 ? y * x % MOD : y; x = x * x % MOD; } return y; }

struct Combination {
    vector<ll> fact, ifact;
    Combination(int n) : fact(n + 1), ifact(n + 1) {
        fact[0] = 1;
        for (int i = 0; i < n; ++i) fact[i + 1] = fact[i] * (i + 1) % MOD;
        ifact[n] = mpow(fact[n], MOD - 2);
        for (int i = n; i > 0; --i) ifact[i - 1] = ifact[i] * i % MOD;
    }
    ll operator ()(int n, int k) { return fact[n] * ifact[n - k] % MOD * ifact[k] % MOD; }
} C(2019);

int N, K;

int main() {
    cin >> N >> K;
    int M = N - K;

    rep(i, 1, K + 1) {
        if (i == 1) {
            write(M > 0 ? M + 1 : 1);
            continue;
        }
        else if (K < i) {
            write(0);
            continue;
        }

        ll ans = 0;

        // 青の分け方
        ll b = C(K - 1, i - 1);

        rep(j, 0, M - (i - 1) + 1) {
            int m = M - j;
            ll r = m > 0 ? C(m - 1, i - 2) : 1;

            ans = (ans + (j + 1) * b % MOD * r % MOD) % MOD;
        }

        write(ans);
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <algorithm>
#include <assert.h>
#include <cmath>
#include <deque>
#include <iostream>
#include <limits.h>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define LL long long

#define REP(e,v) for(auto e:v)
#define pii pair<int,int>
#define pLL pair<LL,LL>
#define mp make_pair
#define mt make_tuple
#define pq priority_queue<LL>
#define pqg priority_queue<int,vector<int>,greater<int>>
#define pb push_back
#define vec vector<int>
#define vecll vector<LL>
#define vecpii vector<pii>
#define vecpLL vector<pLL>
#define vecbL vector<bool>
#define endl "\n"

using namespace std;

int inp(){
	int x;
	scanf("%d",&x);
	return x;
}

void outp(int i){
	printf("%d",i);
}

void loutp(LL i){
	printf("%lld",i);
}

LL mod(LL i){
	return i % 1000000007;
}



int Lucky_7(){
	LL N = inp();

	while(N > 0){
		int i = N % 10;
		if(i == 7) {
			printf("Yes");
			return 0;
		}
		N = N / 10;
	}
	printf("No");

	return 0;

}

int FizzBuzz_Sum(){
	LL N = inp();

	LL sum = 0;

	for(int i = 1;i <= N;i++){
		if(i % 3 != 0 && i % 5 != 0){
				sum += i;
		}
	}

	loutp(sum);

	return 0;

}

int gcd(int i,int j){
	if(j != 0)
		return gcd(j, i % j);
	else
		return i;
}

int SogoT(){

	int K = inp();
	int sum = 0;
	for(int i = 1;i <= K ;i++){
		for(int j = 1;j <= K ;j++){
			for(int k = 1;k <= K ;k++){
					sum += gcd(gcd(i,j), k);
			}
		}
	}

	outp(sum);

	return 0;
}


signed main() {
	//Lucky_7();
	//FizzBuzz_Sum();
	SogoT();
	return 0;
}


Measured memory_bytes: 3760
function Main(input){
	var xs = input.trim().split(' ').map(v=>parseInt(v,10));
    var ans = 0;
    if(xs[1]==xs[2]){
    ans = xs[0];
    }else if(xs[0]==xs[2]){
    ans = xs[1];
    }else if(xs[0]==xs[1]){
    ans = xs[2];
    }
    console.log(ans);  
}
Main(require("fs").readFileSync("/dev/stdin","utf8"));

Measured memory_bytes: 7372
#include<bits/stdc++.h>
using namespace std;
#define loop(i,x,z) for (int i=x;i<z;i++)
using ll = long long;
const ll M = 1000000007;
ll n, A[200002], s = 0;
int main()
{
	cin >> n;
	loop(i, 0, n)cin >> A[i],s+=A[i];
	s %= M;
	ll ans = 0;
	loop(i, 0, n)
	{
		s -= A[i];
		s = (s + M) % M;
		ans += A[i] * (s)%M;
		ans %= M;
	}
	cout << ans;
}

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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n, m;
	cin >> n >> m;
	vvl adj(n);
	while (m--) {
		ll a, b;
		cin >> a >> b;
		a--, b--;
		adj[a].pb(b);
	}
	
	vector<double> dp(n);
	FORD(i,0,n-1) {
		double sum = 0;
		for (ll j: adj[i]) sum += dp[j];
		dp[i] = 1 + sum/sz(adj[i]);
	}
	
	double res = dp[0];
	FOR(m,0,n-1) {
		if (sz(adj[m]) == 1) continue;
		vector<double> ndp = dp;

		double sum = 0, worst = 0;
		for (ll j: adj[m]) {
			sum += dp[j];
			worst = max(worst, dp[j]);
		}
		ndp[m] = 1 + (sum-worst) / (sz(adj[m])-1);
		
		FORD(i,0,m) {
			double sum = 0;
			for (ll j: adj[i]) sum += ndp[j];
			ndp[i] = 1 + sum/sz(adj[i]);
		}
		res = min(res, ndp[0]);
	}
	
	cout << fixed << setprecision(10) << res << endl;
}



Measured memory_bytes: 2560