akhauriyash/Code-Regression huggingface dataset:
/**
 *	@file: A.cpp
 *	@author: Huy Le
 *	@created: 2020-09-13 19:21
**/

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

#define ll long long
#define ld long double
#define sz(x) (int)(x).size()
const char newl = '\n';

void DEBUGLOCAL() { cerr << ")" << newl; }
template<class A, class... B> 
void DEBUGLOCAL(A argc, B... argv) {
	cerr << argc;
	if(sizeof...(argv))
		cerr << ", ";
	DEBUGLOCAL(argv...);
}
#ifdef _DEBUG
#define dbg(...) cerr << "LINE(" << __LINE__ << ") [" << __FUNCTION__ << "] -> (" << #__VA_ARGS__ << "): (",DEBUGLOCAL(__VA_ARGS__)
#else
#define dbg(...) 0
#endif

int ts;
ld x;

void solve() {
    cin >> x;
    cout << (x==0) << newl;
}

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

		solve();
}


Measured memory_bytes: 3816
n = int(input())
data = {'M':0 , 'A':0 , 'R':0 , 'C':0 , 'H':0 }
for i in range(n):
  s = input()
  if(s[0] == 'M'):
    data['M'] += 1
  if(s[0] == 'A'):
    data['A'] += 1
  if(s[0] == 'R'):
    data['R'] += 1
  if(s[0] == 'C'):
    data['C'] += 1
  if(s[0] == 'H'):
    data['H'] += 1
Data = sorted(data.values())
ans = 0
for i in range(0,5):
  for j in range(i+1,5):
    for k in range(j+1,5):
      ans += Data[i]*Data[j]*Data[k]
      
print(ans)

Measured memory_bytes: 3064
import java.util.HashMap;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		long[] a = new long[n];
		HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();
		for (int i = 0; i < n; i++) {
			int temp = sc.nextInt();
			if (map.containsKey(temp)) {
				map.put(temp, map.get(temp) + 1);
			} else {
				map.put(temp, 1);
			}
		}
		boolean b = false;
		if (map.size() == 1) {
			if (map.containsKey(0)) {
				b = true;
			}
		} else if (map.size() == 2 && n % 3 == 0) {
			if (map.containsKey(0) && map.get(0) == n / 3) {
				b = true;
			}

		} else if (map.size() == 3 && n % 3 == 0) {
			int temp = (int)map.keySet().toArray()[0]^(int)map.keySet().toArray()[1]^(int)map.keySet().toArray()[2];
			if(temp == 0) {
				if((int)map.values().toArray()[0] == (int)map.values().toArray()[1] && (int)map.values().toArray()[1] == (int)map.values().toArray()[2]) {
					b=true;
				}
			}
		}
		if(b) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}
}

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

#define L 1000
  
long long getValue(long long x){
  if ( x <= L ) return x +1;
  else return L - x%(L+1);
}
  
main(){
  int n;
  
  while( cin >> n){

    long long cnt = 0;
  
    for ( int i = 0; i <= 2*L; i++ ){
      int t = n - i;
      if ( 0 <= t && t <= 2*L ){
	cnt += getValue(i) * getValue(t);
      }
    }
    
    cout << cnt << endl;
  }
}

Measured memory_bytes: 1156
import math
import time

def rpt_fact(a,b):
    mod = 10 ** 9 + 7
    txt = bin(b)[2:]
    ls = [a]
    res = []
    for i in range(len(txt)):
        ls.append(ls[-1]**2 % mod)
    for i in range(1,len(txt)+1):
        if txt[-i] == "1":
            res.append(ls[i-1])
    ans = 1
    for i in res:
        ans *= i
        ans % mod
    return ans


[x,y] = [int(i) for i in input().split()]
st = time.time()
mod = 10 ** 9 + 7


if (x + y) % 3 != 0:
    print(0)
else:
    #(1,2)がa回,(2,1)がb回
    #-a+b
    _atb = x - y
    atb = (x + y)//3
    a = (atb - _atb)//2
    b = (atb + _atb)//2
    #a+b C a
    if a < 0 or b < 0:
        print(0)
    elif a == 0 or b == 0:
        print(1)
    else:
        n = a + b
        r = min(a,b)
        son = n
        mom = r

        for i in range(1,r):
            son *= (n - i)
            mom *= i
            son %= mod
            mom %= mod
        mom = rpt_fact(mom,mod-2) % mod
        # mom ** (mod - 2)
        print(son*mom % mod)
        #print(time.time()-st)


Measured memory_bytes: 40296
#include<bits/stdc++.h>
#include <stdio.h>
#include <algorithm>

#define all(x) x.begin(),x.end()
#define sc(x) scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define pr(x) printf("%d",x)
#define prl(x) printf("%lld",x)
#define LL long long
#define pb push_back
#define PB pop_back
#define PF pop_front
#define F first
#define S second
#define inrow(vec)    for(int i=0;i<vec.size();i++)cout<<vec[i]<<" ";
#define incoloum(vec) for(int i=0;i<vec.size();i++)cout<<vec[i]<<endl;

const double PI=3.1415926;
const int KL=1e6;

using namespace std;

LL q,x,y,z,n,m,k,p[KL],mn=1e9,mx=-1e9,ans;
string t;
vector <int> vec;
set <int> s;
map <int,int> M;

int main()
{
    cin>>n;
    cin>>t;
    LL cnt=0;
    for(int i=0;i<n-2;i++)
    {
        if(t[i]=='A' && t[i+1]=='B' && t[i+2]=='C')cnt++;
    }
    cout<<cnt;
    return 0;
}


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

  struct input{
  }

class MainClass {

  public static void Main (string[] args) {
    var N = Console.ReadLine();
    var list = Console.ReadLine().Split(' ').Select(long.Parse);
    
    var ans = list.Max() - list.Min();
    
    Console.WriteLine(ans);
  }
}

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

int n,m;

signed main(){
  cin>>n>>m;
  int r=0;
  if(n==1&&m==1)r=1;
  else if(n==1)r=m-2;
  else if(m==1)r=n-2;
  else r=(n-2)*(m-2);
  cout<<r<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

/**
 *
 * @author Administrator
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        // TODO code application logic here
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        int x=0,y=0,t=0,f=0;
        for(int i=0,tt,tx,ty;i<n;i++){
            tt=sc.nextInt();
            tx=sc.nextInt();
            ty=sc.nextInt();
            if(((Math.abs((tx-x))+Math.abs((ty-y)))%2!=(tt-t)%2)||(Math.abs(tx-x)+Math.abs(ty-y)>(tt-t))){
                 f=1;
        }
            t=tt;
            x=tx;
            y=ty;
        }
        if(f==0)System.out.println("Yes");
        else System.out.println("No");
        


        }
        
    }
    



Measured memory_bytes: 88240
// atcoder/abc135/C/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  while (cin >> n) {
    vector<lli> a(n+1);
    cin >> a;
    vector<lli> b(n);
    cin >> b;

    lli sum = 0;
    for (int i = 0; i < b.size(); ++i) {
      {
        lli mn = min(a[i], b[i]);
        a[i] -= mn;
        b[i] -= mn;
        sum += mn;
      }
      {
        lli mn = min(a[i+1], b[i]);
        a[i+1] -= mn;
        b[i] -= mn;
        sum += mn;
      }
    }
    cout << sum << endl;
  }

  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;
 
int main() {
	int N, A[5][105];
    cin >> N;

    for (int i = 1; i <= 2; ++i) {
        for (int j = 1; j <= N; ++j) {
            cin >> A[i][j];
        }
    }

    int cum_sum;
    int max_sum = 0;
    for (int j = 1; j <= N; ++j) {
        cum_sum = 0;
        for (int jj = 1; jj <= j; ++jj) {
            cum_sum += A[1][jj];
        }
        for (int jj = j; jj <= N; ++jj) {
            cum_sum += A[2][jj];
        }
        if (cum_sum > max_sum) max_sum = cum_sum;
    }

    cout << max_sum << endl;


    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <algorithm>
#include <functional>
#include <map>
#include <iomanip>
#include <array>

using namespace std;
int main() {
	int h1, h2, m1, m2, s1, s2;
	for (int i = 0; i < 3; ++i) {
		cin >> h1 >> m1 >> s1 >> h2 >> m2 >> s2;
		if (s1 > s2) {
			m2 -= 1;
			if (m2 < 0) {
				h2 -= 1;
				m2 += 60;
			}
			s2 += 60;
		}
		if (m1 > m2) {
			h2 -= 1;
			m2 += 60;
		}
		cout << h2 - h1 << " " << m2 - m1 << " " << s2 - s1 << endl;
	}
	return 0;
}

Measured memory_bytes: 3108
#include <stdio.h>
int main(void){
    int N;
    long int L[87];
    L[0]=2;
    L[1]=1;
    int i=2;
    scanf("%d",&N);
    while(i<N+1){
        L[i]=L[i-1]+L[i-2];
        i++;
    }
    printf("%ld\n",L[N]);
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <utility>
#include <map>
#include <vector>
#include <cstring>
#include <climits>
#include <queue>
#include <cmath>
#include <iomanip>
#include <set>
#include <bitset>

using namespace std;


typedef long long LL;
typedef pair<int, int> pii;

const LL MOD = 1000000007;
const int MAXN = 2000005;

LL pow25[MAXN];
LL pow26[MAXN];
LL fact[MAXN];

LL expsq(LL x, LL p, LL M) {
  LL res = 1LL;
  while (p > 0LL) {
    if (p & 1LL) {
      res = (res * x) % M;
    }
    x = (x * x) % M;
    p /= 2LL;
  }
  return res;
}

LL modinv(LL x, LL M) {
  return expsq(x, M - 2, M);
}

LL nCr_fermat(int N, int K, LL M) {
  return (fact[N] * modinv(fact[K] * fact[N - K] % M, M)) % M;
}

int main() {
  ios::sync_with_stdio(false);
  string S;
  int K;
  cin >> K >> S;
  int Z = S.size();
  int N = K + Z;

  pow25[0] = pow26[0] = 1LL;
  fact[0] = 1LL;
  for (int i = 1; i <= N; i++) {
    pow25[i] = (pow25[i - 1] * 25LL) % MOD;
    pow26[i] = (pow26[i - 1] * 26LL) % MOD;
    fact[i] = (fact[i - 1] * (LL)i) % MOD;
  }
  LL ans = 0;
  for (int x = Z - 1; x < N; x++) {
    LL res = 1LL;
    res = (res * nCr_fermat(x, Z - 1, MOD)) % MOD;
    res = (res * pow25[x - Z + 1]) % MOD;
    res = (res * pow26[N - x - 1]) % MOD;
    ans = (ans + res) % MOD;
  }
  cout << ans << endl;
}

Measured memory_bytes: 51236
//Md Fahad
// CSE 18

#include<bits/stdc++.h>

using  namespace  std;

#define PI              acos(-1.0)
#define lcm(a,b)        (a * (b / __gcd(a,b)))
#define en '\n'

#define READ_IN freopen("Input.txt","r",stdin);
#define READ_OUT freopen("Output.txt","w",stdout);
#define Infi                0x3f3f3f3f

const int dx[] = {+1,-1,+0,+0};                         // 4 X directions
const int dy[] = {+0,+0,+1,-1};                         // 4 Y directions
const int dx8[] = {+0,+0,+1,-1,-1,+1,-1,+1};            // King X Moves
const int dy8[] = {-1,+1,+0,+0,+1,+1,-1,-1};            // King Y Moves
const int kx[] = {-2, -2, -1, -1,  1,  1,  2,  2};      // Knight X Moves
const int ky[] = {-1,  1, -2,  2, -2,  2, -1,  1};      // Knight Y Moves



int  Set    (int N,int pos) {return N=N | (1<<pos);}    /// turn a bit on
int  reset  (int N,int pos) {return N= N & ~(1<<pos);}  /// turn a bit off
bool check  (int N,int pos) {return (bool)(N & (1<<pos));} /// check, if a bit is on or not

void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define trace(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define trace(x...)
#endif

typedef long long int           ll;
typedef unsigned long long int  llu;




int main(void)
{
  // READ_IN;
    //READ_OUT;

    int n,k;
    cin >> n >> k;

    if(n>=10){
        cout << k << endl;
    }
    else{
        cout << 100*(10-n)+k << endl;
    }


    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<climits>
#include<cmath>
#include<map>
#include<vector>
#define INF INT_MAX
using namespace std;

double a, b, c, d, e, f;
double x, y;
double A;

int main(){
	while (cin >> a >> b >> c >> d >> e >> f){
		A = a*e - b*d;
		x = c*e - b*f;
		x /= A;
		y = a*f - c*d;
		y /= A;
		if (x == 0)x = 0;
		if (y == 0)y = 0;
		printf("%.3lf %.3lf\n", x, y);
	}

	return 0;
}


Measured memory_bytes: 3164
#include <iostream>
#include <unordered_map>
#include <vector>
#include <set>
#include <string.h>
#include <algorithm>
#define mod 1000000007
#define ll long long
#define pr pair<int,int>
#define all vec.begin(),vec.end()
#define REP(i,a,b) for (int i = a; i < b; i++)
#define fi first
#define se second
#define pushb push_back
#define makep make_pair

using namespace std;

int main(){
	int n,m;
	cin >> n >> m;
	int arr[n+1];
	memset(arr,0,sizeof(arr));
	int c1,c2;
	while(cin >> c1 >> c2){
		arr[c1]++, arr[c2]++;
	}
	REP(i,1,n+1)
		cout << arr[i] << endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  if(abs(a-c)<=d){
    cout<<"Yes"<<endl;
    return 0;
  }
  if(abs(b-a)<=d&&abs(b-c)<=d){
    cout<<"Yes"<<endl;
    return 0;
  }
  cout<<"No"<<endl;
}

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

int main() {
  int N; cin >> N;
  vector<long> H(N); 
  long maxH = 0;
  bool check = false;
  for (int i =0; i<N; i++) {
    cin >> H.at(i);
    maxH = max(H.at(i),maxH);
    if (maxH - H.at(i) >= 2) {
      check = true;
      break;
    }
  }
  if (check) {
    cout << "No" << endl;
  } else {
    cout << "Yes" << endl;
  } 
}

Measured memory_bytes: 4052
def gcd(a,b):
    return gcd(b,a % b) if b else abs(a)
def lcm(a,b):
    return (a*b) // gcd(a,b)
n = int(input())
t = []
for i in range(n):
    a = int(input())
    t.append(a)
b = t[0]
for i in range(1,n):
    b = lcm(b,t[i])
print(b)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
int n,ans;
double x[101],y[101],a[101][101];
int main(){
  while(cin>>n,n){
    ans=0;
    r(i,n)scanf("%lf,%lf",&x[i],&y[i]);
    r(i,1000)r(j,1000){
      int a=0;
      r(k,n)if((x[k]-(double)i/10)*(x[k]-(double)i/10)+(y[k]-(double)j/10)*(y[k]-(double)j/10)<=1)a++;
      ans=max(a,ans);
    }
    cout<<ans<<endl;
  }
}

Measured memory_bytes: 3076
#include<bits/stdc++.h>
        #define ll long long int
        using namespace std;
        #define mod 1000000007
        #define pb push_back
        #define ff first
        #define ss second
        #define mp make_pair
        #define f(i,p,n) for(ll i=p;i<n;i++)
        ll exp(ll a,ll b,ll m);
        #define vector <ll> vl
        #define pll pair <ll,ll>

        int ans[100005];
        void solve(){

        	int n,m;
        	cin>>n>>m;
        	bool a[n+1]={false};
        	int b[n+1]={0};
        	int no;
        	int ac=0,pen=0;
        	string s;
        	f(i,0,m){
        		cin>>no>>s;
        		if(s=="AC" && !a[no])
        		{
        			a[no]=true;
        			ac++;
        			pen+=b[no];
        		}
        		else if(s=="WA" && !a[no]){
        			b[no]++;
        		}

        	}	
        	cout<<ac<<" "<<pen<<endl;



        }
 
       int main(){
           
 
            int t=1;
 			//cin>>t;
            while(t--)
               solve();
    
    		return 0;
		}
 
		

Measured memory_bytes: 768
import heapq

n,m=map(int,input().split())
a=list(map(int,input().split()))

h=[]

for i in range(n):
  heapq.heappush(h,-1*a[i])

for i in range(m):
  t=heapq.heappop(h)
  heapq.heappush(h,(t+1)//2)

print(-1*sum(h))

Measured memory_bytes: 14180
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
        static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }

        static readonly long Mod = 1000000000 + 7;

        static void Main(string[] args)
        {
            SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
            var N = Sarray()[0];
            var dct = new Dictionary<string, long>();
            for (var i = 0; i < N; ++i)
            {
                var str = ReadLine();
                if (dct.ContainsKey(str))
                    ++dct[str];
                else
                    dct[str] = 1;
            }
            var max = dct.Max(d => d.Value);
            var cnd = dct.Where(d => d.Value == max).Select(d => d.Key).ToList();
            cnd.Sort(StringComparer.OrdinalIgnoreCase);
            foreach (var s in cnd)
                WriteLine(s);
            Out.Flush();
        }
    }
}

Measured memory_bytes: 39516
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws Exception {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        execute(br);
    }
    static void execute(BufferedReader br) throws Exception {
        do {
            String str = br.readLine();
            if (str.equals("")) { break; }
            double[] xyxy = convertDouble(str.split(" "));
            double x1 = xyxy[0];
            double y1 = xyxy[1];
            double x2 = xyxy[2];
            double y2 = xyxy[3];
            double a = Math.abs(x1 - x2);
            double b = Math.abs(y1 - y2);
            double c = Math.pow(a, 2) + Math.pow(b, 2);
            System.out.println(Math.sqrt(c));
        } while (br.ready());   
    }
    static double[] convertDouble(String[] str) {
        double[] doubles = new double[str.length];
        for (int i = 0; i < str.length; i++) {
            doubles[i] = Double.parseDouble(str[i]);
        }
        return doubles;
    }
}

Measured memory_bytes: 24424
#include<stdio.h>
int main(void){
	int i;
	int score;
	int sum = 0;
	int ave;
	for(i = 0; i < 5;i++){
		scanf("%d",&score);
		if(score < 40){
			score = 40;
		}
		sum += score;
	}
	ave = sum / 5;
	printf("%d\n",ave);
	return 0;
}

Measured memory_bytes: 596
N, A, B = map(int, input().split())
S = list(input())
f_cnt = 0
s_cnt = 0
for s in S:
  if s == 'a' and s_cnt < A + B:
    print('Yes')
    s_cnt += 1
  elif s == 'b' and s_cnt < A + B and f_cnt < B:
    print('Yes')
    s_cnt += 1
    f_cnt += 1
  else:
    print('No')
    

Measured memory_bytes: 79300
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n; i >= 0; i--)
#define reprr(i, m, n) for (ll i = m; i < n; i++)
#define inf 2e9
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    string N; cin >> N;
    char l = N[N.size()-1];
    if (l == '2' || l == '4' || l == '5' || l == '7' || l == '9') cout << "hon" << endl;
    else if (l == '0' || l == '1' || l == '6' || l == '8') cout << "pon" << endl;
    else cout << "bon" << endl;
    return 0;
}

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

int main(){
  	int N, sum = 0;
  	cin >> N;
  	int tmp = N;
  	while(1){
      	sum += tmp%10;
      	if(tmp/10 == 0) break;
      	else tmp/=10;
    }
  	if(N%sum==0) cout << "Yes" << endl;
  	else cout << "No" << endl;
}

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

#define rep(i,n) for(int i=0; i<(n); ++i)
using ll = long long;
using P = pair<int, int>;

int main() {
  int d, g;
  cin >> d >> g;
  vector<P> prob(d);
  rep(i,d) cin >> prob[i].first >> prob[i].second;

  ll res = 1<<29;
  rep(bit, 1<<d) {
    ll sum = 0;
    ll num = 0;
    rep(i,d) {
      if (bit & (1<<i)) {
	sum += prob[i].second + prob[i].first * 100 * (i+1);
	num += prob[i].first;
      }
    }
    if (sum >= g) res = min(res, num);
    else {
      for (int i=d-1; i>=0; --i) {
	if (bit & (1<<i)) continue;
	rep(j, prob[i].first) {
	  if (sum >= g) break;
	  sum += 100 * (i+1);
	  ++num;
	}
      }
      res = min(res, num);
    }
  }
  cout << res << endl;
  return 0;
}


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

#define M_PI       3.14159265358979323846   // pi

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> VI;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> t3;
typedef tuple<ll, ll, ll, ll> t4;

#define rep(a,n) for(ll a = 0;a < n;a++)
#define repi(a,b,n) for(ll a = b;a < n;a++)

static const ll INF = 1e15;
const ll mod = 1e9 + 7;

int main(void)
{
	ll n;
	cin >> n;
	ll sum = 0;
	rep(i, n) {
		ll a = i + 1;
		if (a % 5  && a % 3 ) {
			sum += a;
		}
	}
	cout << sum << endl;
	return 0;
}


Measured memory_bytes: 3620
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> ump;
typedef pair<ll, ll> P;

ump mp;

void solve() {
}

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
        mp = ump();
#pragma clang diagnostic pop
#endif
        ll n;
        cin >> n;
        vector<ll> a(n);
        rep(i, n) cin >> a[i];

        ll ans = ll_inf;
        rep(i, 2) {
            bool increase = i;
            bool reset = false;
            ll temp = 1;
            ll idx = 0;
            while (idx + 1 < n) {
                if (a[idx + 1] == a[idx]) {
                    idx++;
                    continue;
                }
                if (reset) {
                    increase = a[idx + 1] > a[idx];
                    idx++, reset = false;
                    continue;
                }
                if (a[idx + 1] >= a[idx] && increase) idx++;
                else if (a[idx + 1] <= a[idx] && !increase) idx++;
                else if (a[idx + 1] < a[idx] && increase) {
                    increase = false, idx++;
                    reset = true;
                    temp++;
                } else if (a[idx + 1] > a[idx] && !increase) {
                    increase = true, idx++;
                    reset = true;
                    temp++;
                }
            }
            ans = min(ans, temp);
        }
        cout << ans << endl;

#ifdef MY_DEBUG
    }
#endif
    return 0;
}

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

int main(){
	int a[4];
	a[0] = 	6000;
	a[1] = 4000;
	a[2] = 3000;
	a[3] = 2000;
	for(int i = 0; i < 4; i++){
		int m,n;
		cin >> m>>n;
		cout << a[m-1] *n <<endl;
	}
	return 0;
}


Measured memory_bytes: 3084
N=int(input())

A=list(map(int,input().split()))

SUM=sum(A)
MIN=[10**10]*2
L=0
R=SUM
for i in range(N-1):
    L+=A[i]
    R-=A[i]
    if(MIN[0]>abs(L-R)):
        MIN[0]=abs(L-R)
        MIN[1]=i
print(MIN[0])

Measured memory_bytes: 24824
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i, n) for (int i = 0; i < n; i++)

using namespace std;

int main()
{
  int p, q, r;
  cin >> p >> q >> r;
  
  int res = p + q + r - max({p, q, r});
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
inline void prep ()
{
  cin.tie (0);
  cin.sync_with_stdio (0);
};
const double pi = acos(-1.);
//printf(%.12lf\n,mid);
// __builtin_popcount(int) count 1's in binary
// get decimal part of number
/*
double intpart;
double thiss = modf((double)(n*m)/(double)k, &intpart);
*/
// round = (int)(num+.5)
long long mod = 1000000007;
 
// 32 mil = ~1 sec 
long long mymod(long long num){
  if (num< 0 && !(num%mod == 0)){
    if (mod == 1){
      return 0;
    }
    return mod-abs(num)%mod;
  }else{
    return num%mod;
  }
}
 
/*string sentence = And I feel fine...;
    istringstream iss(sentence);
*/  
 
double eps = .000000001;
int h, n;
int a[10001];
int b[10001];
bool memoo[10001];
long long memo[10001];
long long func(int health){
    if (health <= 0){
        return 0;
    }
    if (memoo[health]){
        return memo[health];
    }
    long long res = 1000000000000000000LL;
    for (int i=0; i<n; i++){
        res = min(res, b[i]+func(health-a[i]));
    }
    memoo[health] = true;
    memo[health] = res;
    return res;
}


int main ()
{
  prep();
  
  cin >> h >> n;
  for (int i=0; i<n; i++){
      cin >> a[i] >> b[i];
  }
  cout << func(h);
  return 0; 
}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep2(i, a, n) for(ll i = a; i < (ll)(n); i++)
#define memi cout << endl
#define kono(n) cout << fixed << setprecision(n)
#define all(c) (c).begin(), (c).end()
#define pb push_back
#define hina cout << ' '
#define in(n) cin >> n
#define in2(n, m) cin >> n >> m
#define in3(n, m, l) cin >> n >> m >> l
#define out(n) cout << n
const ll mei = (ll)1e9 + 7;

int main(){
  ll n, m, a;
  in2(n, m);
  vector<ll> c(m), t(n + 1, 0);
  t[0] = 1;
  rep(i, m)
    in(c[i]);
  c.pb(99999999999);
  a = 0;
  if(c[0] == 1)
    a++;
  else
    t[1] = 1;
  rep2(i, 2, n + 1){
    if(c[a] == i){
      a++;
      continue;
    }
    t[i] = t[i - 1] + t[i - 2];
    t[i] %= mei;
  }
  out(t[n]);
  memi;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
#define PI 3.141592653589793
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}
const int INF = 1<<30;
const int MOD = 1000000007;
int dx[4] = {0,0,-1,1};
int dy[4] = {-1,1,0,0};

int n,m,s,t;

int main(){
  cin >> n >> m;
  vector<int> g[100005];
  int d[100005][3];
  rep(i,n)rep(j,3){
    d[i][j] = INF;
  }
  
  rep(i,m){
    int u,v; cin >> u >> v;
    u--,v--;
    g[u].push_back(v);   
  }
  cin >> s >> t;
  s--;t--;
  
  queue<pair<int,int>> q;
  q.push({s,0});
  d[s][0] = 0;
  
  while(!q.empty()){
    int now = q.front().first;
    int step = q.front().second;
    q.pop();
    for(int to:g[now]){
      int ns = (step+1)%3;
      if(d[to][ns] != INF) continue;
      d[to][ns] = d[now][step]+1;
      q.push({to,ns});
    }
  }
  int ans = d[t][0];
  if(ans == INF){
    ans = -1;
  }else{
    ans /= 3;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6912
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>

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

using namespace std;
#define int long long
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repr(i,n) for(ll i=n;i>=0;i--)
#define P pair<ll, ll>
#define sz(x) (ll)x.size()
#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define VE vector<ll>
#define COUT(x) cout<<(x)<<endl
#define MA map<ll,ll>
#define SE set<ll>
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,VE,greater<ll>>
#define COUT(x) cout<<(x)<<endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define EPS (1e-10)
#define pb push_back

const long long MOD = 1000000007;
//const long long MOD = 998244353;
const long long INF = 1LL << 60;


long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a * g / b;
}
bool prime(ll n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}




const long double PI = 3.14159265359;
const int MAX_N = 100010;


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n, k; cin >> n >> k;
	int a = 0; int b = 0;
	rep(i, n) {
		
		if ((i+1)%k == 0)a++;
		else if (k % 2 == 0 && (i+1)%k== k / 2)b++;
	}
	cout << a * a*a + b * b*b << endl;
	return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned ll
#define IO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
using namespace std;
const int N = 1e5 + 5, M = 1e5 + 5;

char a[5], b[5];
int main(){
    scanf("%s%s", &a, &b);
    int cnt = 0;
    for(int i = 0 ; i < 3 ; ++i)
        cnt += (a[i] == b[i]);
    printf("%d\n", cnt);
}

Measured memory_bytes: 256
/*
 * 	Heart beats fast
 * 		Colors and promises
 * 			How to be brave
 * 				How can I love when I am afraid to fall...
*/
#include<bits/stdc++.h>
// #include<boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
using namespace std;
#define int long long
#define mod 1000000007
#define FAST ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f(i,n) for(int i=0;i<n;i++)
#define fp(i,k,n) for(int i=k;i<=n;i++)
#define fr(i,k,n) for(int i=k;i>=n;i--)
#define pb push_back
#define F first
#define S second

void solve()
{
  int a,b;
  cin >> a>> b;
  int ans= max((100*a)/8,(10*b)) ;
  ans=max(ans-10,1ll);
  fp(i,ans,ans+20)
  {
    if(((i*8)/100)==a && (((i*10)/100)==b))
      {cout << i;return;}
    }
    cout << -1;
  return;
}

signed main()
{
  FAST;
	int T=1;
	// cin >> T;
	while(T--)
	{
		solve();
	}
    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];
    }

    int cnt = 0;
    int ans = 1000000;
    for(int i=0;i<n;i++){
        cnt = 0;
        while(true){
            if(A[i]%2 == 0){
                A[i] = A[i]/2;
                cnt++;
            }else{
                ans = min(ans,cnt);
                break;
            }
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 256
#B - Coins
A = int(input())
B = int(input())
C = int(input())
X = int(input())

count = 0
for i in range(A+1):
    for j in range(B+1):
        for k in range(C+1):
            if 500*i + 100*j + 50*k == X:
                count += 1
print(count)

Measured memory_bytes: 9112
# abc122_a.py
# https://atcoder.jp/contests/abc122/tasks/abc122_a

# A - Double Helix /
# 実行時間制限: 2 sec / メモリ制限: 1024 MB
# 配点 : 100点

# 問題文
# AtCoder 星には四種類の塩基 A, C, G, T が存在し、A と T、C と G がそれぞれ対になります。
# 文字 bが入力されます。
# これは A, C, G, T のいずれかです。塩基 bと対になる塩基を表す文字を出力するプログラムを書いてください。

# 制約
#     bは文字 A, C, G, T のいずれかである。

# 入力
# 入力は以下の形式で標準入力から与えられる。
# b

# 出力
# 塩基 bと対になる塩基を表す文字を出力せよ。

# 入力例 1
# A

# 出力例 1
# T

# 入力例 2
# G

# 出力例 2
# C


def calculation(lines):
    line = lines[0]
    # N = int(lines[0])
    # N, M = list(map(int, lines[0].split()))
    # values = list(map(int, lines[1].split()))
    # values = list(map(int, lines[1].split()))
    # values = list()
    # for i in range(N):
    #     values.append(int(lines[i+1]))
    # valueses = list()
    # for i in range(N):
    #     valueses.append(list(map(int, lines[i+1].split())))

    if line == 'A':
        result = 'T'
    if line == 'T':
        result = 'A'
    if line == 'C':
        result = 'G'
    if line == 'G':
        result = 'C'

    return [result]


# 引数を取得
def get_input_lines(lines_count):
    lines = list()
    for _ in range(lines_count):
        lines.append(input())
    return lines


# テストデータ
def get_testdata(pattern):
    if pattern == 1:
        lines_input = ['A']
        lines_export = ['T']
    if pattern == 2:
        lines_input = ['G']
        lines_export = ['C']
    return lines_input, lines_export


# 動作モード判別
def get_mode():
    import sys
    args = sys.argv
    if len(args) == 1:
        mode = 0
    else:
        mode = int(args[1])
    return mode


# 主処理
def main():
    import time
    started = time.time()
    mode = get_mode()
    if mode == 0:
        lines_input = get_input_lines(1)
    else:
        lines_input, lines_export = get_testdata(mode)

    lines_result = calculation(lines_input)

    for line_result in lines_result:
        print(line_result)

    # if mode > 0:
    #     print(f'lines_input=[{lines_input}]')
    #     print(f'lines_export=[{lines_export}]')
    #     print(f'lines_result=[{lines_result}]')
    #     if lines_result == lines_export:
    #         print('OK')
    #     else:
    #         print('NG')
    # finished = time.time()
    # duration = finished - started
    # print(f'duration=[{duration}]')


# 起動処理
if __name__ == '__main__':
    main()


Measured memory_bytes: 8940
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<map>
#include<queue>
using namespace std;
typedef long long ll;

int main(){
	ll n,t;
	cin>>n>>t;
	ll sum=0,Max=0;
	for(int i=1;i<=n;i++){
		ll x; scanf("%lld",&x);
		sum+=x;
		Max=max(Max,x);
		ll ans=1;
		if(t>=sum) ans=(ll)floor((t-sum)*1.0/Max)+2;
		printf("%lld\n",ans);
	}
}


Measured memory_bytes: 3204
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

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

string pow(string s, int n) {
        if (n == 0) {
                return "";
        } else {
                return s + pow(s, n - 1);
        }
}

int main() {
        int a, b;
        cin >> a >> b;

        if (a < b) {
                cout << pow(to_string(a), b) << endl;
        } else {
                cout << pow(to_string(b), a) << endl;
        }

        return 0;
}


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

int main(){
  string s; cin>>s;
  vector<bool> a(26,false);
  for(int i=0;i<s.size();i++){
    a[s[i]-'a']=true;
  }
  for(int i=0;i<26;i++){
    if(!a[i]){
      cout<<char(i+'a')<<endl;
      return 0;
    }
  }
  cout<<"None"<<endl;
}

Measured memory_bytes: 512
n = int(input())

t = [0] * (n+1)
for j in range(2, n+1):
  y = j
  for i in range(2, n+1):
    while y % i == 0:
      t[i] += 1
      y = y//i
ans = 1
p = 10**9 + 7
for i in t:
  if i != 0:
    ans *= (i+1)
    ans %= p
print(ans)

Measured memory_bytes: 9056
arrayNM = list(map(int, input().split()))
array = list(map(int, input().split()))
soutoku = 0
for num in array:
  soutoku += num
tokuhyousuu = soutoku / (4 * float(arrayNM[1]))
ninnkiCounter = 0
for num in array:
  if (float(num) >= tokuhyousuu):
    ninnkiCounter += 1
    

if (arrayNM[1] <= ninnkiCounter):
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define forinc(i,a,b) for(int i=a;i<=b;++i)
#define forout(i,a,b) for(int i=a;i>=b;--i)
#define task ""
#define pii pair<int,int>
#define fi first
#define se second
#define sz(s) (int)(s.size())
#define pb push_back
using namespace std;
const int N=1e5+1;
int n,a[N],b[N],c[N],f[N][4],cnt;
main()
{
    cin>>n;
    forinc(i,1,n) cin>>a[i]>>b[i]>>c[i];
    forinc(i,1,n)
    {
        f[i][1]=max(f[i-1][2]+a[i],f[i-1][3]+a[i]);
        f[i][2]=max(f[i-1][1]+b[i],f[i-1][3]+b[i]);
        f[i][3]=max(f[i-1][1]+c[i],f[i-1][2]+c[i]);
    }
    cout<<max({f[n][1],f[n][2],f[n][3]})<<"\n";
}


Measured memory_bytes: 2944
#include<iostream>
using namespace std;int main(){int n,a,b,c,x,i,l,f,y[100];for(;;){cin>>n>>a>>b>>c>>x;if(n==0&&a==0&&b==0&&c==0&&x==0)break;for(i=0;i<n;i++){cin>>y[i];}l=i=0;f=1;for(;;){if(l==10001){f=0;break;}if(y[i]==x){i++;x=(a*x+b)%c;if(i==n)break;l++;}else{l++;x=(a*x+b)%c;}}if(f==1)cout<<l<<endl;else cout<<"-1"<<endl;}}

Measured memory_bytes: 0
#include <iostream>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    while (true) {
        if ((c -= b) <= 0) {
            cout << "Yes\n";
            return 0;
        } else if ((a -= d) <= 0) {
            cout << "No\n";
            return 0;
        }
    }
    return 0;
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
const long long MOD=1e9+7;
int main(){
    long long n,k;
    cin >> n >> k;
    vector<long long>a(n);
    vector<long long>pos;//0以上の数を受け取る
    vector<long long>neg;//負の値を受け取る
    for(long long i=0;i<n;i++){
        long long x;
        cin >> x;
        a[i]=x;
        if(x>=0)pos.push_back(x);
        else neg.push_back(x);
    }
    sort(pos.begin(),pos.end());
    sort(neg.begin(),neg.end());//絶対値が大きい順
    reverse(pos.begin(),pos.end());//大きい順にする
    long long ans=1;
    //k=nの時
    if(k==n){
        for(long long i=0;i<n;i++){
            ans*=MOD+a[i];
            ans%=MOD;
        }
        cout << ans << endl;
        return 0;
    }
    //正の数がないとき
    if(pos.empty()){
        //答えが負になるとき絶対値の小さい順
        if(k%2){
            reverse(neg.begin(),neg.end());
            for(long long i=0;i<k;i++){
                ans*=(MOD+neg[i]);
                ans%=MOD;
            }
            cout << ans << endl;
            return 0;
        }
        //答えが正になるとき大きい順でとる
        else{
            for(long long i=0;i<k;i++){
                ans*=(MOD+neg[i]);
                ans%=MOD;
            }
            cout << ans << endl;
            return 0;
        }
    }

    //kが奇数の時正の数の最大値をあらかじめ取っておく
    if(k%2){
        ans*=pos[0];
        pos.erase(pos.begin());
    }

    long long p=pos.size();
    long long ne=neg.size();
    vector<long long>pos_pair(p/2);
    vector<long long>neg_pair(ne/2);
    for(long long i=0;i<p/2;i++){
        pos_pair[i]=(pos[i*2]*pos[i*2+1]);
    }
    for(long long i=0;i<ne/2;i++){
        neg_pair[i]=(neg[i*2]*neg[i*2+1]);
    }
    long long pk=0,nk=0;
    for(long long i=0;i<k/2;i++){
        if(pk==p/2){
            neg_pair[nk]%=MOD;
            ans*=neg_pair[nk];
            ans%=MOD;
            nk++;
        }
        else if(nk==ne/2){
            pos_pair[pk]%=MOD;
            ans*=pos_pair[pk];
            ans%=MOD;
            pk++;
        }
        else{
            if(pos_pair[pk]>neg_pair[nk]){
                pos_pair[pk]%=MOD;
                ans*=pos_pair[pk];
                ans%=MOD;
                pk++;
            }
            else{
                neg_pair[nk]%=MOD;
                ans*=neg_pair[nk];
                ans%=MOD;
                nk++;
            }
        }
    }
    cout << ans << endl;
}


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

int n, j = 0, z = 0;
int a[100000];
long long s = 0, m = 1000000000;

int main()
{
	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> a[i];

		if (a[i] < 0) {
			j++;
			s += -a[i];
			if (m > - a[i])
				m = - a[i];
		}
		else if (a[i] == 0) {
			z++;
			m = 0;
		}
		else {
			s += a[i];
			if (m > a[i])
				m = a[i];
		}
	}

	if (j % 2 == 0 || z > 0)
		cout << s << endl;
	else
		cout << s - m * 2 << endl;

	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <set>
#include <cmath>
 
class PrimeNumberChecker {
public:
    PrimeNumberChecker() {
        m_checkedPrimeNumSet.insert(2);
    }
    ~PrimeNumberChecker() {}
    bool isPrimeNumber(const int& x);
private:
    std::set<int> m_checkedPrimeNumSet;
};
 
bool PrimeNumberChecker::isPrimeNumber(const int& x) {
    if (x <= 1) {
        return false;
    }
    if (m_checkedPrimeNumSet.find(x) != m_checkedPrimeNumSet.end()) {
        return true;
    }
    if (x % 2 == 0) {
        return false;
    }
    for (int i = 3; i <= std::sqrt(x); i++) {
        if (x % i == 0) {
            return false;
        }
    }
    m_checkedPrimeNumSet.insert(x);
    return true;
}
 
int main(int argc, const char *argv[]) {
    int n;
    std::cin >> n;
    PrimeNumberChecker checker;
    int ret = 0;
    for (int i = 0, x; i < n && std::cin >> x; i++) {
        if (checker.isPrimeNumber(x)) {
            ret++;
        }
    }
    std::cout << ret << std::endl;
    return 0;
}

Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(I,A,B) for(ll I = (A); I < (B); ++I)
const ll INF=1e15+7;
const ll N = 100001;

int main(){
	ll s,a[4];
	cin>>s;
	FOR(i,0,4){
		a[i]=s%10;
		s/=10;
	}
	if( (a[0]==a[1]&&a[1]==a[2]) || (a[1]==a[2]&&a[2]==a[3]) ){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
template<typename T> using gpp_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T, typename L> using gpp_map = tree<T, L, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template<typename T> using gpp_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;*/
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define Max(a, b) a = max(a, b)
#define Min(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define bit_exist(x, n) ((x >> n) & 1)
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl;
#define mdebug(m) cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;}
#define pb push_back
#define f first
#define s second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void Ans(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using PiP = pair<int, Pii>;
using PPi = pair<Pii, int>;
using bools = vector<bool>;
using pairs = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;
//#define Add(x, y) x = (x + (y)) % mod
//#define Mult(x, y) x = (x * (y)) % mod



signed main(){

    int N; cin >> N;
    vec A(N); cin >> A;

    vec cnt(N, 0);
    REP(i, N) cnt[A[i] - 1]++;
    Sort(cnt);
    vec S(N + 1, 0);
    REP(i, N) S[i + 1] = S[i] + cnt[i];

    vec ans(N + 1, 0);
    FOR(x, 1, N + 1){
        int i = Upper_bound(cnt, x);
        ans[(S[i] + x * (N - i)) / x] = x;
    }

    IFOR(i, 1, N) Max(ans[i], ans[i + 1]);
    FOR(i, 1, N + 1) cout << ans[i] << '\n';

    return 0;
}


Measured memory_bytes: 10240
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
class Simple {
    int N, M;
    int[] a, b;
    int[,] G;
    void Solve() {
        //input
        N = io.Int;
        M = io.Int;
        a = new int[M];
        b = new int[M];
        for (int i = 0; i < M; ++i) {
            a[i] = io.Int;
            b[i] = io.Int;
        }
        //cal
        var ans = 0;
        //i番目の辺を除いてUnionFind
        //処理後、i番目の辺を構成する頂点が同じ親を持てばiを除いても連結グラフ
        for (int i = 0; i < M; ++i) {
            var uf = new UnionFind(N);
            for(int j = 0; j < M; ++j) {
                if (i == j) continue;
                uf.Unite(a[j], b[j]);
            }
            if (!uf.Find(a[i], b[i])) ans++;
        }
        //ret
        Console.WriteLine(ans);
    }
    class UnionFind {
        int[] dat;
        public UnionFind() { }
        public UnionFind(int N) { Init(N); }
		public int count = 0;
        public void Init(int n) { dat = new int[n + 1]; for (int i = 0; i <= n; ++i) dat[i] = -1; count = n;}
        public void Unite(int x, int y) {
            x = Root(x); y = Root(y); if (x == y) return;
            if (dat[y] < dat[x]) swap(ref x, ref y); dat[x] += dat[y]; dat[y] = x;
			count--;
        }
        public bool Find(int x, int y) { return Root(x) == Root(y); }
        public int Root(int x) { return dat[x] < 0 ? x : dat[x] = Root(dat[x]); }
        public int Size(int x) { return -dat[Root(x)]; }
        void swap(ref int a, ref int b) { int tmp = b; b = a; a = tmp; }
    }

    SimpleIO io = new SimpleIO();
    public static void Main(string[] args) { new Simple().Stream(); }
    void Stream() { Solve(); io.writeFlush(); }
}
class SimpleIO {
    SimpleIO(bool isAutoFlush = false) { this.isAutoFlush = isAutoFlush; }
    string[] nextBuffer;
    int BufferCnt;
    char[] cs = new char[] { ' ' };
    public bool isAutoFlush;
    StreamWriter sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
    public SimpleIO() {
        nextBuffer = new string[0];
        BufferCnt = 0;
        if (!isAutoFlush) Console.SetOut(sw);
    }
    public string Next() {
        if (BufferCnt < nextBuffer.Length) return nextBuffer[BufferCnt++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        nextBuffer = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        BufferCnt = 0;
        return nextBuffer[BufferCnt++];
    }
    public string String => Next();
    public char Char => char.Parse(String);
    public int Int => int.Parse(String);
    public long Long => long.Parse(String);
    public double Double => double.Parse(String);
    public void writeFlush() { Console.Out.Flush(); }
}


Measured memory_bytes: 13140