akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long
#define INF 1e9
#define pb push_back
#define mp  make_pair
#define loop(a,n) for(long long i=a;i<n;i++)
#define vil vector<long long int>
#define vi vector<int>
#define sz(v) v.size()
#define setbits(x)          __builtin_popcountll(x)
#define ff first
#define ss second
using namespace std;


ll gcd(ll a, ll b) {
  if (a == 0)return b;
  return gcd(b % a, a);
}
bool isperfect(ll n) {
  ll y = sqrt(n);
  if (n % y == 0 && y * y == n)return true;
  return false;
}
bool comp(pair<int,int> a, pair<int,int> b) {
    if(a.first == b.first) return a.second>b.second;
  return a.first < b.first;
}
 ll powi(ll a, ll b) {
  ll ans = 1;
  while (b > 0) {
    if (b & 1)ans = (ans * a);
    b = b >> 1;
    a = (a * a);
  }
  return ans;
}
bool isprime(ll n) {
  for (int i = 2; i * i <= n; i++) {
    if (n % i == 0)return false;
  }
  return true;
}
bool prime[10000000];
void seive() {

  prime[1] = true;
  for (int i = 2; i * i < 10000000; i++) {

    if (prime[i])continue;
    for (int j = i * i; j < 10000000; j += i) {
      prime[j] = true;
    }

  }
}

int main()
{
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
  ll n;cin>>n;
  ll x=n+powi(n,2)+powi(n,3);
  cout<<x;
}




  

Measured memory_bytes: 3696
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
		
		char[] c = s.toCharArray();
		
		int res = 0;
		
		for(int i = 1; i < s.length(); i++) {
			char ch = c[i];
			
			if(c[i-1] == ch) {
				c[i] = c[i-1] == '0' ? '1' : '0';
				res++;
			}
		}
		System.out.println(res);
	}
}


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

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

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

long long f(string s) {
     int N = s.size();
     long long sum = 0;
     for (long long i = 0, j = 0; i < N; i = j) {
         while (j < N && s[i] == s[j])j++;
         sum += (j - i) / 2;
     }
     return sum;
 }
 
 int main() {
 
     string S;
     cin >> S;
 
     long long N = S.size();
 
     long long K;
     cin >> K;
 
     bool same = true;
     for (int i = 0; i < N; i++) if (S[0] != S[i]) same = false;
     if (same) {
         cout << (N * K) / 2 << endl;
         return 0;
     }
 
     long long d1 = f(S);
     long long d2 = f(S + S);
 
     long long a = d1;
     long long d = d2 - d1;
 
     cout << a + (K -1) * d << endl;
 
     return 0;
 }

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

#define llt long long int
#define modm 1000000007

int main(){
	int arr[5],ans;
	for(int i=0;i<5;i++){
	cin>>arr[i];
	if(arr[i]==0)
	ans=i+1;
}
	
	cout<<ans<<endl;
	
}


Measured memory_bytes: 3520
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<math.h>
using namespace std;

#define int long long
#define endl "\n"
#define fir first
#define sec second
#define fro front
#define m_p make_pair
#define mod 1000000007
#define all(v)  v.begin(),v.end()
#define rep(i,n)  for(int i=0; i<(int) (n); i++)
#define all(v)  v.begin(),v.end()
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>v[i];
using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}

int modinv(int a, int m) {
	int b = m, u = 1, v = 0;
	while (b) {
		int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res* a% mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}
int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	int a = xx;
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}
int com(int xx, int yy) {
	int zz = 1;
	for (int i = xx; i > xx - yy; i--) {
		zz *= i;
		zz %= mod;
	}
	for (int i = 1; i <= yy; i++) {
		zz *= modinv(i, mod);
		zz %= mod;
	}
	return zz;
}



signed main() {
	int n,a=0;
	cin >> n;
	if (n % 100 <= 12 && n % 100 > 0) {
		a+=2;
	}
	if (n / 100 <= 12 && n / 100 > 0) {
		a++;
	}
	if (a == 0) {
		cout << "NA" << endl;
	}
	if (a == 1) {
		cout << "MMYY" << endl;
	}
	if (a == 2) {
		cout << "YYMM" << endl;
	}
	if (a == 3) {
		cout << "AMBIGUOUS" << endl;
	}
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <complex>
#include <cmath>
using namespace std;

#define EPS 1e-8
#define INF 1e100

typedef complex<double> P;
typedef vector<P> vP;

const P iu(0.0, 1.0);

double dot(P a, P b){
	return real(a) * real(b) + imag(a) * imag(b);
}

double cross(P a, P b){
	return real(a) * imag(b) - imag(a) * real(b);
}

int ccw(P a, P b, P c) {
	b -= a; c -= a;
	if (cross(b, c) > EPS)	return +1;	// counter clockwise
	if (cross(b, c) < -EPS)	return -1;	// clockwise
	if (dot(b, c) < -EPS)	return +2;	// c--a--b on line
	if (norm(b) < norm(c))	return -2;	// a--b--c on line
	return 0;
}

P crosspoint(P a1, P a2, P b1, P b2){
	double t = cross(b1 - a1, b1 - b2) / cross(a2 - a1, b1 - b2);
	return a1 + t * (a2 - a1);
}

P centroid(const vP &pl){
	P s;
	int sz = pl.size() - 1;
	if(sz < 1){ return P(INF, INF); }
	for(int i = 1; i <= sz; ++i){
		s += pl[i];
	}
	return s / (double)sz;
}

vP convex_cut(const vP &pl, P la, P lb) {
	vP Q;
	for (int i = 1; i < pl.size(); ++i) {
		P A = pl[i-1], B = pl[i];
		if (ccw(la, lb, A) != -1){ Q.push_back(A); }
		if (ccw(la, lb, A) * ccw(la, lb, B) < 0){
			Q.push_back(crosspoint(A, B, la, lb));
		}
	}
	if(!Q.empty() && Q.back() != Q[0]){
		Q.push_back(Q[0]);
	}
	return Q;
}

double area(const vP p){
	double s = 0.0;
	for(int i = 1; i < p.size(); ++i){
		s += cross(p[i-1], p[i]);
	}
	return 0.5 * abs(s);
}

int main(){
	const double L = 10000.0;
	int T = 0;
	int x, y;

	while(1){
		P pt[3];
		for(int i = 0; i < 3; ++i){
			scanf("%d%d", &x, &y);
			pt[i] = P(x, y);
			if(x == 0){ return 0; }
		}

		vP plg(5);
		plg[1] = P(0.0, L);
		plg[2] = P(L, L);
		plg[3] = P(L, 0.0);

		for(int k = 1; k < 3; ++k){
			P mid = 0.5 * (pt[0] + pt[k]);
			P dif = iu * (pt[k] - pt[0]);
			
			vP p1 = convex_cut(plg, mid, mid + dif);
			vP p2 = convex_cut(plg, mid, mid - dif);

			if(p1.empty()){ p1.swap(p2); }
				//直線と多角形の交点がないケース。一方は空、他方は元の多角形
			P cn = centroid(p1);
			plg.swap(norm(pt[0] - cn) < norm(pt[k] - cn) ? p1 : p2);
		}

		printf("%d %f\n", ++T, area(plg) / (L * L));
	}
}

Measured memory_bytes: 1244
#include <vector> 
#include <list> 
#include <map> 
#include <set> 
#include <deque> 
#include <queue> 
#include <stack> 
#include <bitset> 
#include <algorithm> 
#include <functional> 
#include <numeric> 
#include <utility> 
#include <sstream> 
#include <iostream> 
#include <iomanip> 
#include <cstdio> 
#include <cmath> 
#include <cstdlib> 
#include <cctype> 
#include <string> 
#include <cstring> 
#include <ctime> 

using namespace std;

#define _int64 long long
#define mo 998244353

int used[210][210];
int x[210];
int y[210];
int pow2[210];

int main()
{
  int i,j,k,n,ans,o,p,b1;
  vector<int> q;
  pow2[0]=1;
  for (i=1;i<210;i++)
  {
    pow2[i]=pow2[i-1]+pow2[i-1];
    pow2[i]%=mo;
  }
  scanf("%d",&n);
  for (i=0;i<n;i++)
    scanf("%d%d",&x[i],&y[i]);
  ans=pow2[n];
  ans--;
  ans-=n;
  ans+=mo;
  ans%=mo;
  memset(used,0,sizeof(used));
  for (i=0;i<n;i++)
    for (j=i+1;j<n;j++)
      if (used[i][j]==0)
      {
        q.clear();
        q.push_back(i);
        q.push_back(j);
        for (k=j+1;k<n;k++)
        {
          b1=0;
          if ((x[i]==x[j])&&(x[k]==x[i])) b1=1;
          else if ((y[i]==y[j])&&(y[k]==y[i])) b1=1;
          else
          {
            if ((y[j]-y[i])*(x[k]-x[i])==(y[k]-y[i])*(x[j]-x[i])) b1=1;
          }
          if (b1==1) q.push_back(k);
        }
        ans-=pow2[q.size()];
        ans+=q.size();
        ans++;
        ans%=mo;
        ans+=mo;
        ans%=mo;
        for (o=0;o<q.size();o++)
          for (p=o+1;p<q.size();p++)
            used[q[o]][q[p]]=1;
      }
  printf("%d\n",ans);
  return 0;
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k; cin >> n >> k;
  vector<long long> h(n + 1);
  for (int i = 1; i < n + 1; i++) cin >> h[i];
  sort(h.begin(), h.end());
  for (int i = 0; i < n; i++) h[i+1] += h[i];
  cout << h[max(0, n - k)] << '\n';
  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MX=1e18;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n,ans=0;cin>>n;
    for(ll i=2;i*i<=n;i++){
        if(n%i)continue;
        ll cnt=0;
        while(n%i==0)n/=i,cnt++;
        ll j;
        for(j=1;(j*(j+1))/2<=cnt;j++);
        ans+=j-1;
    }
    if(n>1)ans++;
    cout<<ans;
}



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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            long result = N * N * N;
            Console.WriteLine(result.ToString());
//            Console.Read();
        }
    }
}

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

if M == 0 or N == 0:
    print("{} {}".format(0, 0))
else:

    p = [0]*M
    S = [0]*M

    for i in range(M):
        tmp = input().split()
        p[i] = int(tmp[0])
        S[i] = tmp[1]

    penalty = 0


    correct_set = set()
    for i in range(M):
        if S[i] == 'AC':
            correct_set.add(p[i])

    correct = len(correct_set)

    for i in range(M):
        if S[i] == 'AC' and p[i] in correct_set:
            correct_set.remove(p[i])
        elif S[i] == 'WA' and p[i] in correct_set:
            penalty += 1


            

    print("{} {}".format(correct, penalty))

Measured memory_bytes: 19436
#include <stdio.h>
#define MAX 100

int main(){
  int i,n,tmp,cnt=0,flag=1,A[MAX];
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }
  while(flag){
    flag = 0;
    for(i = n-1;i > 0;i--){
      if(A[i] < A[i-1]){
	tmp = A[i];
	A[i] = A[i-1];
	A[i-1] = tmp;
	flag = 1;
	cnt++;
      }
    }
  }
  for(i=0;i<n;i++){
    if(i)printf(" ");
    printf("%d",A[i]);
  }
  printf("\n%d\n",cnt);
  
}



Measured memory_bytes: 2128
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define forn(i,n) for(ll i=0;i<(n);i++)
#define maxx ((ll)1e6+5)
#define pb push_back
#define mp make_pair
using namespace std;
int main()
{
	   ld l;
	   cin>>l;
	   ld z=l/3;
	   cout<<fixed<<setprecision(12)<<pow(z,3);
}

Measured memory_bytes: 512
# 0～7で5を作るには
# 0123467 5 7643210 5
# M = 1がxor sum = 0とならず例外

M,K = map(int,input().split())

def solve(M,K):
  if M == 0:
    if K == 0:
      return '0 0'
    else:
      return '-1'
  if M == 1:
    if K == 0:
      return '0 1 1 0'
    else:
      return '-1'
  U = 1<<M
  if K >= U:
    return -1
  other = [str(x) for x in range(U) if x != K]
  result = other + [str(K)] + other[::-1] + [str(K)]
  return ' '.join(result)

answer = solve(M,K)
print(answer)

Measured memory_bytes: 15512
#include <iostream>

int main()
{
    int n;
    int *arr;
    int Max = 0;
    int Min = 0;
    long long All = 0;

    std::cin >> n;
    arr = new int[n];
    
    for (int x = 0; x < n; ++x){
        std::cin >> arr[x];
        if (Max < arr[x] || Max == 0){
            Max = arr[x];
        }
        if (Min > arr[x] || Min == 0){
             Min = arr[x];
        }
        All += arr[x];

    }

    std::cout << Min << " " << Max << " " << All << "\n";

    delete[] arr;
    arr = NULL;

    return 0;
}



Measured memory_bytes: 3156
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <functional>

using namespace std;
 
#define mod 1000000007
#define FOR(x,to) for(int x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define long long long
inline int rei(){int x;cin>>x;return x;}
inline long rel(){long x;cin>>x;return x;}
inline string res(){string x;cin>>x;return x;}
//------------------------------------------------------- 
void Calc(){
	int N = rei();
	int K = rei();
	K = 2*K+1;
	cout << (N+K-1)/K << endl;
}
int main(int argc,char** argv){
	ios::sync_with_stdio(false), cin.tie(0);
	cout.tie(0); Calc(); return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>

using namespace std;

int main(){
    int h, m, s, input;
    cin >> input;

    h = input / 3600;
    m = (input - h * 3600) / 60;
    s = (input - h * 3600) % 60;

    string x = to_string(h) + ":" + to_string(m) + ":" + to_string(s);
    std::cout << x <<std::endl;
    return 0;
}



Measured memory_bytes: 3280
#include <bits/stdc++.h>
using namespace std;
#define ll long long

int a[10005],b[10005];

int main(){
    int n;
    ll sum1=0,sum2=0;
    cin>>n;
    for(int i=1;i<=n;i++) 
		cin>>a[i];
    for(int i=1;i<=n;i++) 
		cin>>b[i];
    for(int i=1;i<=n;i++){
        if(a[i]>b[i]) 
			sum1=sum1+a[i]-b[i];
        else if(a[i]<b[i]){
        	ll sum=b[i]-a[i];
            if(sum%2==0) 
				sum2=sum2+sum/2;
            else {
				sum1++;
				sum2=sum2+(sum+1)/2;
			}
        }
    }
    if(sum2>=sum1) 
		cout<<"Yes"<<endl;
    else 
		cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n,x,y;

int main(){
	cin>>n>>x>>y;
	int t=0;
	for(int i=0;i<n;i++){
		int a,b;
		cin>>a>>b;
		if(x<=a&&y<=b) t++;
	}
	cout<<t<<endl;
}

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

using namespace std;

const double N = 23;
const double PI = acos(-1);

int get(int x) {
    if(x < 2) return 2;
    return get(x - 1) + get(x - 2);
}

int main() {

    int n, m, c;
    cin >> n >> m >> c;
    vector <int> b(m);
    for(int i = 0; i < m; i++) {
        cin >> b[i];
    }

    int res = 0;
    for(int i = 0; i < n; i++) {
        vector <int> a(m);
        int ans = c;
        for(int i = 0; i < m; i++) {
            cin >> a[i];
            ans += a[i] * b[i];
        }
        res += ans > 0;
    }

    cout << res << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
using namespace std;
long long a[100005],n,ans,t,maxx,minn;
int main()
{
    cin>>n>>t;
    for (int i=0; i<n; i++)
        cin>>a[i];
    maxx=0;
    ans=0;
    minn=a[0];
    for(int i=1; i<n; i++)
    {
        if (a[i]-minn==maxx) ans++;
        if (a[i]-minn>maxx)
        {
            maxx=a[i]-minn;
            ans=1;
        }
        if (minn>a[i]) minn=a[i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
 
 
int main(){

    int X,N;
    cin >> X >> N;
    int p[N];
    for(int i = 0; i < N; i ++){
        cin >> p[i];
    }

    vector<int> lost(1);

    lost.at(0) = 10000000;

    for(int i = -1; i <= 101; i ++){
        bool add = true;
        for(int j = 0; j < N; j++){
            if(i == p[j]){
                add = false;
            }
        }
        if(add){
            lost.push_back(i);
        }
    }

    sort(lost.begin(),lost.end(),greater<int>());

    int D = abs(X - lost[0]);
    int ans = lost[0];

    for(int i = 0; i < lost.size() ; i++){
        if(D >= abs(X-lost[i])){
            ans = lost[i];
            D = abs(X-lost[i]);
        }
    }

    cout << ans << endl;


}

Measured memory_bytes: 3636
#include<stdio.h>
int main(){
  int i,j,n,count[100]={0};
  char ch;
  while(scanf("%c",&ch)!=EOF){
    if(ch>='a' && ch<='z'){
      count[ch-'a']++;
    }
    else if(ch>='A'&& ch<='Z'){
      count[ch-'A']++;
    } 
  }
  for(j=0;j<26;j++){
  printf("%c : %d\n",j+'a',count[j]);
  }
  return (0);
}


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

const int N = 1e5 + 10;
int a[N], par[N], h[N];
bool mark[N];
vector<int> adj[N];

void dfs(int root) {
    mark[root] = true;
    par[root] = -1;
    for (auto v: adj[root]) {
        if (!mark[v])
            dfs(v);
        if (h[v] + 1 > h[root]) {
            h[root] = h[v] + 1;
            par[root] = v;
        }
    }
}

int main() {
    ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
    int n, m, u, v;
    cin >> n >> m;
    for (int i = 0; i < n + m - 1; i++) {
        cin >> u >> v;
        adj[--v].push_back(--u);
    }
    for (int i = 0; i < n; i++)
        if (!mark[i])
            dfs(i);
    for (int i = 0; i < n; i++)
        cout << par[i] + 1 << "\n";
    return 0;
}

Measured memory_bytes: 10112
# import numpy as np
# import scipy as sp
# print(a,b,c,sep="") # 半角スペースなしで出力(abc)
# n=int(input())  #数値入力 「N」だけの入力のとき
# a,b=map(int, input().split())  #複数数値入力　「A B」みたいなスペース空いた入力のとき
# c=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき
# s=[list(map(int,list(input()))) for i in range(h)]  # 文字列の二次元配列入力
# s = [list(map(int, input().split())) for i in range(n)] # 数値の二次元配列入力
# import sys ; sys.exit() # プログラム終了
# from copy import deepcopy ; b=deepcopy(a)
# chr(ord('a') + 1)
# s.sort(key=lambda x: x[1], reverse=False) # 2番目の要素で昇順にソート（Trueなら降順）
#

a, b = map(int, input().split())


print(max(a+b, a-b, a*b))


Measured memory_bytes: 38384
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define DEBUGP(val) cerr << #val << "=" << val << "\n"

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  ll h;
  cin >> n >> h;
  VL a(n), b(n);
  vector<PI> pool;
  REP(i, 0, n) {
    cin >> a[i] >> b[i];
    pool.push_back(PI(b[i], a[i]));
  }
  sort(pool.rbegin(), pool.rend());
  ll rem = h;
  ll cnt = 0;
  ll ma = 0;

  REP(i, 0, n) {
    ll b = pool[i].first;
    ll a = pool[i].second;
    if (b <= ma) {
      break;
    }
    rem -= b;
    cnt += 1;
    ma = max(ma, a);
    if (rem <= 0) {
      break;
    }
  }
  if (rem > 0) {
    cnt += (rem + ma - 1) / ma;
  }
  cout << cnt << "\n";
}


Measured memory_bytes: 2936
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define until(x) while(!(x))
#define unless(x) if(!(x))
#define all(x) (x).begin(),(x).end()

int a[100005],b[100005];
int32_t main(){
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i]>>b[i];
	}
	int add = 0;
	for(int i=n;i>=1;i--){
		//cout<<add+a[i]<<" "<<b[i]<<" "<<(add+a[i])%b[i]<<"\n";
		int t = ((add+a[i])%b[i]);
		if(t){
			add += b[i]-((add+a[i])%b[i]);
		}
		//cout<<i<<" "<<add<<"\n";
	}
	cout<<add;
}


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

int main() {
  int a, b = 0, c;
  cin >> a;
  c = a;
  while(true) {
  	b += c % 10;
    c /= 10;
    if(c == 0) {
      break;
    }
  }
  if(a % b == 0) {
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

using namespace std;

#define debug(x,y) cout<<(#x)<<" " <<(#y)<<" is " << (x) <<" "<< (y) << endl
#define watch(x) cout<<(#x)<<" is " << (x) << endl
#define fast ios_base::sync_with_stdio(false)
#define fie(i,a,b) for(i=a;i<b;i++)
#define MOD 1000000007
#define mod 998244353
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define ll long long
#define lld long long int
#define ALL(x) (x).begin(),(x).end()

typedef vector<lld> vi;
typedef vector<vector<lld>> vii;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<pair<lld, lld>> vpi;
typedef long long LL;


int main() {
	fast;
	cin.tie(0);
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/
	string s;
	cin >> s;
	bool flag = false;
	for (lld i = 0; i < s.length(); i++) {
		if (s[i] == '7') {
			cout << "Yes" << endl;
			flag = true;
			break;
		}
	}
	if (!flag) cout << "No" << endl;
}






Measured memory_bytes: 3652
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace std;
#define MuhammedAly ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define all(x) (x).begin(),(x).end()
#define allr(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define popc(x) __builtin_popcount(x)
#define LLMX 1e18
#define NotinRange(n,m) i<0||i>=(n)||j<0||j>=(m)
#define mem(x,y) memset((x),(y),sizeof (x));
#define sz(a) (int)(a).size()
#define inFile(s) freopen((s),"r",stdin)
#define	outFile(s) freopen((s),"w",stdout)
#define biEdge(v, a, b) (v)[(a)].pb((b)), (v)[(b)].pb((a))
#define pi (2 * acos(0))
#define X real()
#define Y imag()
#define cross(a, b) ((conj(a) * (b)).Y)
#define dot(a, b) ((conj(a) * (b)).X)
#define vec(a,b) ((b) - (a))
#define ll long long
typedef long double ld;
typedef complex<double>point;
typedef tuple<int, int, int> line;
typedef pair<point, point>segment;
typedef vector<point>polygon;
const int N = 1e5 + 5, M = 50 + 5, OO = 0x3f3f3f3f, mod = 1e9 + 7, base = 131, mod2 = 1000136437, mod3 = 998244353;
const double EPS = 1e-9;
int n, w[N], v[N], W, mx;
ll memo[100][N];
ll solve(int i, int rem)
{
    if(rem == 0)
        return 0;
    if(i == n)
        return LLMX;
    ll &ret = memo[i][rem];
    if(~ret)
        return ret;
    ret = solve(i + 1, rem);
    if(rem - v[i] >= 0)
        ret = min(ret, solve(i + 1, rem - v[i]) + w[i]);
    return ret;
}
int main()
{
    MuhammedAly
    mem(memo, -1);
    cin >> n >> W;
    for(int i = 0 ; i < n ; i++)
        cin >> w[i] >> v[i], mx += v[i];
    for(int i = mx ; ~i ; i--)
        if(solve(0, i) <= W)
            return cout << i, 0;
    return 0;
}

Measured memory_bytes: 78464
#!python3

# input
N, A, B, C = list(map(int, input().split()))
S = [input() for _ in range(N)]


def main():
    l = [A, B, C]
    d = {"AB": (0, 1, 2), "AC": (0, 2, 1), "BC": (1, 2, 0)}
    dl = ["A", "B", "C"]
    ans = []
    for n in range(N):
        i, j, k = d[S[n]]
        if l[i] < l[j]:
            l[i] += 1
            l[j] -= 1
            ans.append(dl[i])
        elif l[i] > l[j]:
            l[i] -= 1
            l[j] += 1
            ans.append(dl[j])
        elif l[i] == 0:
            print("No")
            return
        else:
            if n < N - 1 and j == d[S[n + 1]][2]:
                i, j = j, i
            l[i] -= 1
            l[j] += 1
            ans.append(dl[j])
        
    print("Yes")
    print("\n".join(ans))


if __name__ == "__main__":
    main()


Measured memory_bytes: 17428
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <iomanip>
using namespace std;
#define INF 1e9
#define PI acos(-1)
typedef long long ll;
typedef pair<int, int> p_ii;



int main() {
	
	ll n, m; cin >> n >> m;
	vector<int>a(n);
	for (int i = 0; i < n; i++)cin >> a[i];

	vector<ll> sum(n + 1);
	sum[0] = 0;
	for (int i = 1; i <= n; i++)sum[i] = (sum[i - 1] + a[i - 1]) % m;

	map<ll, ll> cnt;
	ll ans = 0;
	cnt[0]++;
	for (int i = 1; i <=n; i++) {
		ans += cnt[sum[i]];
		cnt[sum[i]]++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 5376
#include <iostream>
#include <cmath>
#include <string>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <map>
#include <string.h>
#include <cstring>
#include <queue>
 
using namespace std;


int main() {
    int k;
    cin >> k;
    
    queue <long long int> x;
    for(int i=1; i<=9; i++){
        x.push(i);
    }
    long long a;
    
    for(int i=1; i<=k; i++){
        
        a = x.front(); x.pop();
        if(a%10==0){
            x.push(a*10);
            x.push(a*10+1);
        }
        else if(a%10==9){
            x.push(a*10+8);
            x.push(a*10+9);
        }
        else{
            x.push(a*10+a%10-1);
            x.push(a*10+a%10);
            x.push(a*10+a%10+1);
        }
    }
    
    cout << a << endl;
    
    return 0;
 }


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

int main()
{
  	int m,n,s=0;
  cin>>n>>m;
  vector<int> a(m);
  for(int i=0;i<m;i++)
  {
    cin>>a[i];
    s+=a[i];
  }
  if(s<=n)
    cout<<n-s;
  else
    cout<<"-1";
  return 0;
}

Measured memory_bytes: 3616
#include<bits/stdc++.h>
using namespace std;
int main() {
  int n, y;
  cin >> n >> y;
  y /= 1000;
  int h = y % 5;
  y -= h;
  n -= h;
  if (y >= n) {
    for (int i = (y - n) % 4; i * 10 <= y; i += 4) {
      int a = ((y - n) - 9 * i) / 4;
      int b = n - i - a;
      if (a >= 0 && b >= 0) {
        printf("%d %d %d", i, a, b + h);
        return 0;
      }
    }
  }
  printf("%d %d %d", -1, -1, -1);
}

Measured memory_bytes: 256
import java.util.Scanner;
import java.lang.Math;
 
public class Main {
 
    public static void main(String[] args) {
 
        try (Scanner sc = new Scanner(System.in)){
 
            while(true){
                int input = sc.nextInt();
                if(input == 0) break;
 
                int x = 0;
                int y = 0;
                int z = 0;
 
                int z_ = input;
                int min = 999999999;
 
                for (int i=0; i<=(int) Math.sqrt(z_)+1; ++i) { // z
                    int y_ = z_ - i * i * i;
                    if (y_ < 0) break;
 
                    for (int j=0; j<=(int) Math.sqrt(y_)+1; ++j) { // y
                        int x_ = y_ - j * j;
 
                        if (x_ < 0) break;
 
                        int k = x_;
                        int r = i + j + k;
 
                        if (r < min) {
                            min = r;
                        }
 
                    }
                }
 
                System.out.println(min);
            }
        }
 
    }
 
}


Measured memory_bytes: 34740
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
count = 0
for i in range(n):
    ans = 0
    a = list(map(int, input().split()))
    for j in range(m):
        ans += a[j] * b[j]
    if ans + c > 0:
        count += 1
print(count)

Measured memory_bytes: 3060
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
using namespace std;


int main(void) {

  int r,g,b;
  cin >> r >> g >> b;

  cout << ( (100*r + 10*g + b)%4 == 0 ? "YES" : "NO") << endl;

  return 0;
}


Measured memory_bytes: 256
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
//10の1/2乗（ルート）pow(10, 0.5)
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  ll n,m;
  cin >> n >> m;
  vector<ll>a(n);
  vector<ll>b(n);
  rep(i,n) cin >>a.at(i) >>b.at(i);
  vector<ll>c(m);
  vector<ll>d(m);
  rep(i,m) cin >> c.at(i)>>d.at(i);
  for(int i=0;i<n;i++){
    int  mi = abs(a.at(i) - c.at(0) ) + abs(b.at(i) - d.at(0));
    int bangou  = 1;
      for(int k=1;k<m;k++){
       int  num = abs(a.at(i) - c.at(k) ) + abs(b.at(i) - d.at(k));
        if(mi > num){
          mi = num;
          bangou = k + 1;
        }
      }
    cout << bangou << endl;
  }
}

Measured memory_bytes: 3620
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B - Count ABC
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 50;

/* typedef */

/* global variables */

char s[MAX_N + 4];

/* subroutines */

/* main */

int main() {
  int n;
  scanf("%d%s", &n, s);

  int cnt = 0;
  for (int i = 0; i + 2 < n; i++)
    if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C') cnt++;

  printf("%d\n", cnt);
  return 0;
}


Measured memory_bytes: 256
N = int(input())
S = list(input())

def jdg(i,j):
    mm = j+(j-i)
    # print(i,j,mm)
    if mm<N:
        if S[mm]==S[i] or S[mm]==S[j]:
            return True  
        else:
            return False
    else:
        return True

mm1 = S.count("R")
mm2 = S.count("G")
mm3 = S.count("B")

ans = mm1*mm2*mm3

for i in range(N-2):
    for j in range(i+1,N-1):
        if jdg(i,j) or S[i]==S[j]:
            continue
        else:
            ans -= 1

print(ans)

Measured memory_bytes: 68336
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <queue>

using namespace std;

#define inf 99999999999;

double dis[1003][1003]={};
double x[1001],y[1001],r[1001];
double ans[1003]={};
double calc(double x1,double y1,double r1,double x2,double y2,double r2){
	double d = sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
	if(d >r1+r2){
		return d-r1-r2;
	}
	return 0.0;
}
int n;

void dijkstra(int s){
	for(int i=0;i<1003;i++){
		ans[i] = inf;
	}
	ans[s]=0;
	priority_queue< pair<double,int>,vector<pair<double,int > >,greater<pair<double,int > > > q;
	q.push(make_pair(0,s));
	while(!q.empty()){
		pair<double,int> a = q.top();
		q.pop();
		if(ans[a.second]<a.first)continue;
		for(int i=0;i<n+2;i++){
			if(ans[i] > ans[a.second]+ dis[a.second][i]){
				ans[i] = ans[a.second] + dis[a.second][i];
				q.push(make_pair(ans[i],i));
			}
		}
	}
	return ;
}

int main(){
	double xs,ys,xt,yt;
	cin >>xs >> ys >> xt >> yt >> n;
	for(int i=0;i<n;i++){
		cin >> x[i] >> y[i] >> r[i];
	}
	x[n] = xs;
	x[n+1] = xt;
	y[n] = ys;
	y[n+1] = yt;
	for(int i=0;i<n+2;i++){
		for(int j=0;j<n+2;j++){
			dis[i][j] = calc(x[i],y[i],r[i],x[j],y[j],r[j]);
		}
	}
	dijkstra(n);
	cout.precision(10);
	cout << ans[n+1] << endl;
	return 0;
}

Measured memory_bytes: 12400
//ios::sync_with_stdio(false);
#include<bits/stdc++.h>
#define LL long long
#define F(x,y,z) for(int x=y;x<=z;++x)
#define D(x,y,z) for(int x=y;x>=z;--x)
#define ckmax(a,b) (a)=max(a,b)
#define ckmin(a,b) (a)=min(a,b)
#define pb push_back
using namespace std;
const int N=100010;
LL R(){
    LL ans=0,f=1;char c=getchar();
    for(;c<'0'||c>'9';c=getchar()) if (c=='-') f=-1;
    for(;c>='0'&&c<='9';c=getchar()) ans=ans*10+c-'0';
    return ans*f;
}
int n,fa[N],siz[N];
vector<int> v[N];
LL d[N],s,g[N];
map<LL,int> ys,id;
void Err(){
	printf("-1\n");
	exit(0);
}
void dfs(int u,int dep){
	s+=dep;
	for(auto to:v[u])dfs(to,dep+1);
}
int main(){
	//freopen("1.in","r",stdin);freopen("1.out","w",stdout);
	n=R();
	F(i,1,n)d[i]=R(),siz[i]=1,id[d[i]]=i;
	sort(d+1,d+1+n);
	F(i,1,n)ys[d[i]]=i;
	D(i,n,2){
		fa[i]=ys[d[i]+siz[i]*2-n];
		if(fa[i]==0)Err();
		v[fa[i]].pb(i);
		siz[fa[i]]+=siz[i];
	}
	dfs(1,0);
	if(s!=d[1])Err();
	F(i,2,n)printf("%d %d\n",id[d[i]],id[d[fa[i]]]);
    return 0;
}

Measured memory_bytes: 22528
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)   FOR(i,0,n)
#define pb emplace_back
typedef long long ll;
typedef pair<int,int> pint;

double PI=acos(-1.0);
#define eps (1e-7)
struct Point{
    double x,y;
    Point(){}
    Point(double x,double y):x(x),y(y){}
    Point operator+(Point p) {return Point(x+p.x,y+p.y);}
    Point operator-(Point p) {return Point(x-p.x,y-p.y);}
    Point operator*(Point p) {return Point(x*p.x-y*p.y,x*p.y+y*p.x);}
    Point operator*(double k){return Point(x*k,y*k);}
    Point operator/(double k){return Point(x/k,y/k);}
    double norm(){return x*x+y*y;}
    double abs(){return sqrt(norm());}
    bool operator == (const Point &p) const{return fabs(x-p.x)<eps && fabs(y-p.y)<eps;}
    double arg(){return atan2(y,x);}
    double dot(Point p){return x*p.x+y*p.y;}
    double det(Point p){return x*p.y-y*p.x;}
};
struct Circle{
    double r;
    Point p;
    Circle(){}
    Circle(Point p,double r):p(p),r(r){}
};
bool isIntersectCC(Circle c1,Circle c2){
    return (c1.p-c2.p).abs()<=c1.r+c2.r+eps;
}
pair<Point,Point> CrossPointsCC(Circle c1,Circle c2){
    assert(isIntersectCC(c1,c2));
    double d=(c1.p-c2.p).abs();
    double k=acos((d*d+c1.r*c1.r-c2.r*c2.r)/(c1.r*d*2));
    return make_pair(c1.p+(c2.p-c1.p)*Point(cos(k),sin(k))*(c1.r/d),c1.p+(c2.p-c1.p)*Point(cos(-k),sin(-k))*(c1.r/d));
}
double x[11],y[11],r[11];
vector<Point> po;
Circle c[11];
double mx;
int n;
bool test(double d){
    po.clear();
    rep(i,n){
        double dist=r[i]*r[i]-d*d;
        if(dist<0) return false;
        c[i]=Circle(Point(x[i],y[i]),sqrt(dist));
        po.pb(c[i].p);
    }
    rep(i,n)FOR(j,i+1,n){
        if(!isIntersectCC(c[i],c[j])) continue;
        if(abs(c[i].r-c[j].r)+eps>(c[i].p-c[j].p).abs()) continue;
        pair<Point,Point> pp=CrossPointsCC(c[i],c[j]);
        po.pb(pp.first);po.pb(pp.second);
    }
    int sz=po.size();
    rep(i,sz){
        bool flag=true;
        rep(j,n){
            if((po[i]-c[j].p).abs()>c[j].r+eps) flag=false;
        }
        if(flag) return true;
    }
    return false;
}
int main(){
    while(cin>>n,n){
        mx=0;
        rep(i,n){
            cin>>x[i]>>y[i]>>r[i];
            mx=max(mx,r[i]);
        }
        double lb=0,ub=300;
        while(ub-lb>eps){
            double mid=(ub+lb)/2;
            if(test(mid)) lb=mid;
            else ub=mid;
        }
        cout<<fixed<<setprecision(12)<<lb<<endl;
    }
    return 0;
}


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

int d[128];
int f[128];
bool c[128][128];
int n;
int t;
int checked[128];

void dfs(int i) {
  if( checked[i] ) return;
  checked[i] = true;
  t += 1;
  d[i] = t;
  for(int k = 1; k <= n; ++k) {
    if( c[i][k] ) {
      dfs(k);
    }
  }
  t += 1;
  f[i] = t;
  return;
}

int main(void) {

  for(int i = 0; i < 128; ++i) {
    for(int j = 0; j < 128; ++j) {
      c[i][j] = false;
    }
  }

  std::cin >> n;

  int u, k, v;
  for(int i = 0; i < n; ++i) {
    std::cin >> u >> k;
    for(int j = 0; j < k; ++j) {
      std::cin >> v;
      c[u][v] = true;
    }
  }

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

  for(int i = 1; i <= n; ++i) {
    std::cout << i << " " << d[i] << " " << f[i] << std::endl;
  }
  return 0;
}

Measured memory_bytes: 1176
#include <iostream>
#include <vector>
#include <algorithm> // sort
#include <map>       // pair
#include <string>
#include <stdio.h>
using namespace std;

int main(int argc, const char *argv[])
{   
    int N;
    cin >> N;
    vector<int> V(N);
    vector<int> C(N);
    for(int i = 0;i < N ; i ++)
    {
        cin>>V[i];
    }

    for (int i = 0; i < N; i++)
    {
        cin >> C[i];
    }
    int sum = 0;

    for(int i = 0; i < N ; i ++)
    {
        if(V[i]-C[i] > 0)
        {
            sum += V[i] - C[i];
        }
    }

    cout<<sum;
    return 0;
}

Measured memory_bytes: 256
// -----------------------------------
// Author     : MatsuTaku
// Affiliation: Tokushima University
// Country    : Japan
// Date       : 04/04/2020
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int n,k,c; cin>>n>>k>>c;
  string s; cin>>s;

  vector<int> f(k), t(k);
  int cnt = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'o') {
      f[cnt++] = i;
      i+=c;
    }
    if (cnt>=k)
      break;
  }
  cnt = k-1;
  for (int i = n-1; i >= 0; i--) {
    if (s[i] == 'o') {
      t[cnt--] = i;
      i -= c;
    }
    if (cnt < 0)
      break;
  }
  for (int i = 0; i < k; i++) {
    if (f[i] == t[i])
      cout << f[i]+1 << endl;
  }

  return 0;
}


Measured memory_bytes: 3348
# include <iostream>
# include <vector>
# include <deque>
# include <math.h>
# include <set>
# include <iomanip>
# include <time.h>
# include <list>
# include <stdio.h>
# include <queue>
# include <map>
# include <algorithm>
# include <string.h>

# define ll long long
# define mk make_pair
# define sc second
# define fr first
# define pb push_back

using namespace std;

const long long N = (1e6 + 10);
const long long mod = (1e9 + 7);

int n,k,a[N],g;

int f(int sign){
    int k = 0,g = 0;
    for(int i = 1; i <= n; i ++)
        k += (a[i] % 2);

    if((n - k) & 1)
        return sign;

    if(k > 1)
        return sign ^ 1;

    else{
        for(int i = 1; i <= n; i ++){
            if(a[i] == 1)
                return sign ^ 1;

            if(a[i] & 1)
                a[i] --;
            if(g == 0)
                g = a[i];
            else
                g = __gcd(g,a[i]);
        }

        for(int i = 1; i <= n; i ++)
            a[i] /= g;

        return f(sign ^ 1);
    }
}
main () {
    scanf("%d", &n);

    for(int i = 1; i <= n; i ++)
        scanf("%d", &a[i]);

    printf(f(1) == 1 ? "First" : "Second");
}


Measured memory_bytes: 640
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    long long n, k;
    cin >> n >> k;
    long long diff = n / k;
    cout << min(abs(n - diff * k), abs(n - (diff + 1) * k)) << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define MOD (ll)(1e9+7)
#define INF 1e17
#define int ll
#define EPS (1e-6)
using namespace std;
using ll=long long;
using pii=pair<int,int>;

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

int fpow(int b,int p)
{
	if(p==0) return 1;
	int h=fpow(b,p/2);
	if(p%2) return h*b%MOD*h%MOD;
	return h*h%MOD;
}

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int n; cin>>n;
	int ans=0;
	int t;
	For(i,0,n-1){
		cin>>t;
		while(t%2==0){
			t/=2;
			ans++;
		}
	}
	cout<<ans<<"\n";
	return 0;
}





























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

nums = list(map(int, input().split()))
sums = [nums[0]]
for i in range(1, n):
  sums.append(sums[i-1] + nums[i])
  
min_diff = 100
index = 0
for sum in sums:
  if abs(sum - (sums[-1] - sum)) < min_diff:
    min_diff = abs(sum - (sums[-1] - sum))
    
print(min_diff)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <math.h>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <utility>
#include <set>
#include <queue>
using namespace std;
typedef long long int ll;
typedef long double ld;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef pair<ll,ll> pairs;
vector<pairs> p;
bool pairCompare(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.first < secondElof.first;
}
bool pairCompareSecond(const pair<double,ll>& firstElof, const pair<double,ll>& secondElof){
    return firstElof.second < secondElof.second;
}
#define MAX_N 100100
#define MOD 1000000007
bool x[MAX_N];
ll num[MAX_N];
ll fibl[MAX_N]={0};
// 四方向への移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll fib(ll a){
    if (fibl[a]!=0)return fibl[a];
    if (a==0){
        return 0;
    }else if (a==1){
        return 1;
    }
    return fibl[a]=fib(a-1)+fib(a-2);
}
 
ll eratosthenes(ll n) {
    int p = 0;
    for (ll i=0; i<=n; ++i) x[i] = true;
    x[0] = x[1] = false;
    for(int i=2; i<=n; ++i) {
        if(x[i]) {
            p++;
            for(int j=2*i; j<=n; j+=i) x[j] = false;
        }
        
        num[i] = p;
    }
    return p;
}
 
ll gcd(ll a,ll b){
    if (a%b==0)return(b);
    else return(gcd(b,a%b));
}
 
ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

void  base_num(ll data,ll base){
    if(data==0) return;
    ll next=abs(data)%abs(base);
    if(data<0) next=(abs(base)-next)%abs(base);
    base_num((data-next)/base,base);
    cout << next;
}

ll nx[9],n,A,B,C;

ll dfs(ll co,ll a,ll b,ll c){
    ll r0,r1,r2,r3;
    if (co==n){
        ll x=30;
        if (min(min(a,b),c)>0){
            return abs(a-A)+abs(b-B)+abs(c-C) -x;
        }else{
            return INF;
        }
    }
    r0=dfs(co+1,a,b,c);
    r1=dfs(co+1,a+nx[co],b,c)+10;
    r2=dfs(co+1,a,b+nx[co],c)+10;
    r3=dfs(co+1,a,b,c+nx[co])+10;
    return min(min(r0,r1),min(r2,r3));
}

int main(){
    cin >> n >> A >> B >> C;
    for (ll i=0;i<n;i++){
        cin >> nx[i];
    }
    cout << dfs(0,0,0,0) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rep2(i,n) for (int i = 1; i < (n); ++i)
using namespace std;
typedef long long ll;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const long long INF = 1LL << 60;
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int A, B, C;
    cin >> A >> B >> C;
    int ans;
    if(A!=B&&B==C) {
        ans = A;
    }
    else if(B!=C&&C==A){
        ans = B;
    }
    else
    {
        ans = C;

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

Measured memory_bytes: 256
import sys

cin = sys.stdin
N = int(cin.readline())
p = list(map(int, cin.readline().split()))

cnt = 0
for i in range(1,N-1):
    if p[i-1] < p[i] < p[i+1] or p[i-1]>p[i]>p[i+1]:
        cnt += 1
print(cnt)


Measured memory_bytes: 3060
#include<stdio.h>
#include<math.h>

int main()
{
	float x1,y1,x2,y2,x3,y3,xp,yp,r;
	int i,n;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%f %f %f %f %f %f",&x1,&y1,&x2,&y2,&x3,&y3);
		xp=((x2*x2+y2*y2-x1*x1-y1*y1)*(y3-y1)-(x3*x3+y3*y3-x1*x1-y1*y1)*(y2-y1))/(2*((x2-x1)

*(y3-y1)-(x3-x1)*(y2-y1)));
		if(y2-y1){yp=(x2*x2+y2*y2-x1*x1-y1*y1-2*xp*(x2-x1))/(2*(y2-y1));}
		else{yp=(x3*x3+y3*y3-x1*x1-y1*y1-2*xp*(x3-x1))/(2*(y3-y1));}
		r=sqrt((x1-xp)*(x1-xp)+(y1-yp)*(y1-yp));
		printf("%.3f %.3f %.3f\n",xp,yp,r);
	}
	return 0;
}

Measured memory_bytes: 0
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Numerics;
using System.Diagnostics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;

class P
{
    static void Main()
    {
        var nk = Console.ReadLine().Split().Select(int.Parse).ToList();
        List<int>[] neighbours = Enumerable.Repeat(0, nk[0]).Select(_ => new List<int>()).ToArray();
        List<Tuple<int, int>> edges = new List<Tuple<int, int>>();
        for (int i = 0; i < nk[0] - 1; i++)
        {
            var ab = Console.ReadLine().Split().Select(x => int.Parse(x) - 1).ToList();
            neighbours[ab[0]].Add(ab[1]);
            neighbours[ab[1]].Add(ab[0]);
            edges.Add(new Tuple<int, int>(ab[0], ab[1]));
        }

        Dictionary<int, int>[] indexes = neighbours.Select(x => x.Select((y, z) => new Tuple<int, int>(y, z)).ToDictionary(y => y.Item1, y => y.Item2)).ToArray();
        List<int>[][] datas = neighbours.Select(x => new List<int>[x.Count]).ToArray();

        Func<int, int, List<int>> dfs = null;
        dfs = (x, from) =>
        {
            List<int> ret = new List<int>() { 1 };
            for (int i = 0; i < datas[x].Length; i++)
            {
                var dest = neighbours[x][i];
                if (dest == from) continue;
                var v = datas[x][i] != null ? datas[x][i] : (datas[x][i] = dfs(dest, x));
                for (int j = 1; j <= v.Count; j++)
                {
                    if(j >= ret.Count) ret.Add(0);
                    ret[j] += v[j - 1];
                }
            }
            return ret;
        };
        List<int>[] dfsRes = new List<int>[nk[0]];
        for (int i = 0; i < nk[0]; i++) dfsRes[i] = dfs(i, -1);

        int res = int.MaxValue;
        if (nk[1] % 2 == 0)
        {
            res = Enumerable.Range(0, nk[0]).Min(x => dfsRes[x].Skip(nk[1] / 2 + 1).Sum());
        }
        else
        {
            res = edges.Min(x => datas[x.Item1][indexes[x.Item1][x.Item2]].Skip(nk[1] / 2 + 1).Sum() + datas[x.Item2][indexes[x.Item2][x.Item1]].Skip(nk[1] / 2 + 1).Sum());
        }
        Console.WriteLine(res);
    }
}


Measured memory_bytes: 71472