akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include<algorithm>//next_permutation
using namespace std;
 
#define rep(i,n) for(int i=0;i<(n);i++)
#define repa(i,a,n) for(int i=(a);i<(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rrepa(i,a,n) for(int i=n-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()
#define MOD 1000000007
#define cmax(a,b) a=max(a,b)
#define cmin(a,b) a=min(a,b)
#define vc vector
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;


int main (){
    int n;
    cin >> n;
    vector<string>s(n);
    rep(i,n) cin >> s[i];
    sort(s.begin(),s.end());
    map<string,int>mp;
    rep(i,n){
        mp[s[i]]++;
    }
    int ma;
    int i = 0;
    for(auto p:mp){
        if(p.second>i){
            i=p.second;
        }        
    }
    for(auto p:mp){
        int a = p.second;
        if(a==i) cout << p.first<<endl;;
    }
}

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

int main(void)
{
	int e[1000], n[1000];
	int sum, sumn, i;
	double ave;
	i = 0;
	sum = 0;
	sumn = 0;
	
	while (scanf("%d%*c%d", &e[i], &n[i]) != EOF){
		sum += e[i] * n[i];
		sumn += n[i];
		i++;
	}
	
	ave = (double)sumn / (double)i;
	
	
	
	printf("%d\n%.0lf\n", sum, floor(ave + 0.5));
	
	return 0;
	
}

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

using namespace std;

int main(void)
{
	int x, n;
	cin >> x >> n;
	if (n == 0) {
		cout << x << endl;
		return 0;
	}
	int p[n];
	bool used[102];
	for (int i = 0; i < 102; i++)
		used[i] = false;
	for (int i = 0; i < n; i++) {
		cin >> p[i];
		used[p[i]] = true;
	}

	set<int> ans;
	for (int i = 0; ; i++) {
		if (x+i <= 101)
			if (used[x+i] == false)
				ans.insert(x+i);
		if (x-i >= 0)
			if (used[x-i] == false)
				ans.insert(x-i);
		if (x+i >= 102 && x-i < 0)
			break;
			
		if (ans.size() == 1) {
			cout << *ans.begin() << endl;
			return 0;
		} else if (ans.size() == 2) {
			auto it = ans.begin();
			auto it2 = ans.begin();
			it2++;
			cout << min(*it, *it2) << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
 
using namespace std;
 
int main(){
  	ios::sync_with_stdio(0);
	cin.tie(0);
	int X, res = 0;
  	cin >> X;
  	if(X>=500){
    	res += 1000*(X/500);
      	X = X%500;
    }
  	if(X>=5){
      	res += 5*(X/5);
      	X = X%5;
    }
  	cout << res;
  	return 0;	
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
vector<int> a;
int main()
{
	int p,q,opt,x;
	cin >> q;
	while (q--)
	{
		cin >> opt;
		if (opt == 0){ cin >> x; a.push_back(x); }
		if (opt == 1){ cin >> p; cout << a[p] << endl; }
		if (opt == 2) a.pop_back();
	}
	return 0;
}


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

using namespace std;
typedef long long ll;

int main(){
    ll a, b, q;
    cin >> a >> b >> q;
    vector<ll> ss(a, 0), ts(b, 0);
    for(int i = 0; i < a; ++i){
        cin >> ss.at(i);
    }
    for(int i = 0; i < b; ++i){
        cin >> ts.at(i);
    }
    sort(ss.begin(), ss.end());
    sort(ts.begin(), ts.end());

    for(int i = 0; i < q; ++i){
        ll x;
        cin >> x;
        auto its = lower_bound(ss.begin(), ss.end(), x);
        auto itt = lower_bound(ts.begin(), ts.end(), x);

        ll ans = 20000000000LL;

        // right, right
        if(its != ss.end() && itt != ts.end()){
            ans = min(ans, max(*its - x, *itt - x));
        }

        // left, left
        if(its != ss.begin() && itt != ts.begin()){
            ans = min(ans, max(x - *(its-1), x - *(itt-1)));
        }

        // left, right
        if(its != ss.begin() && itt != ts.end()){
            ans = min(
                ans,
                min(
                    x - *(its-1) + *itt - *(its-1),
                    *itt - x + *itt - *(its-1)
                )
            );
        }

        // right, left
        if(its != ss.end() && itt != ts.begin()){
            ans = min(
                ans,
                min(
                    x - *(itt-1) + *its - *(itt-1),
                    *its - x + *its - *(itt-1)
                )
            );
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 2944
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Dhanin Gupta
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ACoffee solver = new ACoffee();
        solver.solve(1, in, out);
        out.close();
    }

    static class ACoffee {
        public void solve(int testNumber, InputReader in, PrintWriter w) {
            char[] a = in.next().toCharArray();

            if (a[2] == a[3] && a[4] == a[5])
                w.println("Yes");
            else
                w.println("No");
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private InputReader.SpaceCharFilter filter;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public String readString() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuilder res = new StringBuilder();
            do {
                res.appendCodePoint(c);
                c = read();
            }
            while (!isSpaceChar(c));

            return res.toString();
        }

        public boolean isSpaceChar(int c) {
            if (filter != null)
                return filter.isSpaceChar(c);
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public String next() {
            return readString();
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 22228
#include <iostream>
#include <fstream>
#include <sstream>
#include <random>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <queue>
#include <iostream>
#include <functional>
#include <stdio.h>
#include <string.h>
#include <unordered_map>
#include <set>
#include <iomanip>

#define ll long long
#define mod 1000000007
using namespace std;


int health_compute(int h_val) {
    if(h_val == 1) {
        return 1;
    }
    else {
        int res = health_compute(h_val/2);
        return 2*res + 1;
    }
}

int main() {

    ll h;
    cin>>h;
    ll sum = 0;
    ll two_pow = 1;
    while(h > 0) {
        sum += two_pow;
        two_pow *= 2;
        h /= 2;
    }

    cout<<sum<<'\n';
    return 0;
}


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

ans = []
def solve(num):
    if num[0] != "0":
        ans.append(int(num))
    if len(num) == 10:
        return
    top = int(num[0])
    for i in range(max(top - 1, 0), min(top + 2, 10)):
        solve(str(i) + num)

for i in range(10):
    solve(str(i))
ans = sorted(ans)

print(ans[k - 1])
        
    

Measured memory_bytes: 84396
#include<iostream>
#include<vector>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<queue>
#include<deque>
#include<map>
#include<bitset>
using namespace std;

typedef long long ll;
#define rep(i, n) for(int i = 0;i < (n);i++)
#define repr(i, n) for(int i = (n);i >= 0;i--)
#define repf(i, m, n) for(int i = (m);i < (n);i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1;} return 0;}
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1;} return 0;}
int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0};
//////////////////////////////////////////////////


int main() {
    int n; cin >> n;
    int ans = 0;
    rep(i,n) {
        int a; cin >> a;
        if(i%2==0 && a%2==1) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  int A,B;
  
  cin>>A>>B;
  
  if(A==2){
    if(B==2){
		cout<<"Yes"<<endl;
    }else{
      cout<<"No"<<endl;
    }
    
  }
  else if(A==4||A==6||A==9||A==11){
    if(B==4||B==6||B==9||B==11){
      cout<<"Yes"<<endl;
    }
    else{
          cout<<"No"<<endl;
    }
  }else{
      if(B==1||B==3||B==5||B==7||B==8||B==10||B==12){
      	cout<<"Yes"<<endl;
      }else{
      	cout<<"No"<<endl;
      }

  }
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define INF 0x6fffffff
#define INFL 0x6fffffffffffffffLL
ll	n;
ll	ans;
vector<ll>	aa(100);
vector<ll>	maxk(100);

int main() {
	ll		a,b,c,d,h,i,j,k,l,m,x,y;
	ans = 1000;
	cin >> n;
	for(i=1;i<=n;i++) cin >> aa[i];
	maxk[0] = 1000;
	for(i=1;i<=n;i++) {
		maxk[i] = maxk[i-1];
		for(j=1;j<i;j++) {
			a = (maxk[j] / aa[j]) * aa[i] + (maxk[j] % aa[j]);
			maxk[i] = max(maxk[i] , a);
		}
	}
	cout << maxk[n] << endl;
	return 0;
}


Measured memory_bytes: 3644
import math

n = int(input())
A, B = [], []
for _ in range(n):
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)
A.reverse()
B.reverse()

cnt = 0
for a, b in zip(A, B):
    a += cnt
    cnt += math.ceil(a/b) * b - a
print(cnt)

Measured memory_bytes: 16940
#include<iostream>
#include<string>
#include<cstring>
using namespace std;
int main(){
  char S[11],OUT[11];
  int A[13],i,j=1,max=0;
  A[0]=-1;
  cin >> S;
  for(i=0;i<11;i++) {
    if(S[i] != 'A' && S[i] != 'C' && S[i] != 'G' && S[i] != 'T') {
      A[j]=i;
      j++;
    }
    if(S[i] == '\0')i=11;
  }
  for(i=1;i<j;i++) {
    if(A[i]-A[i-1]-1 > max) {
      max = A[i]-A[i-1]-1;
    }
  }
  cout << max << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
using namespace std;
#define MAX 300000
typedef long long ll;

int main(){
  ll ans=100000000000;
  ll H[3];
  cin>>H[0]>>H[1];
  H[2]=H[0];
  if(H[0]%3==0 || H[1]%3==0) ans=0;
  else ans=min(H[0],H[1]);
  ll sum[3],maxs,mins;

  for(ll i=0;i<2;i++){
    for(ll j=0;j<H[i];j++){
      sum[0]=j*H[i+1];
      sum[1]=(H[i]-j)*(H[i+1]/2);
      sum[2]=(H[i]-j)*((H[i+1]+1)/2);
      maxs=max(sum[0],sum[2]);
      mins=min(sum[0],sum[1]);
      ans=min(ans,maxs-mins);

      
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;

#define pll pair<ll,ll>
#define ff first
#define snd second
#define pb push_back
#define vll vector<ll>
#define vpll vector<pll>
#define endl "\n"
#define MOD 1000000007
using namespace std;

ll const N = 1e5+1;


void solve()
{
   ll n,k;
   cin>>n>>k;
   vll v(n+1,0);
   for(int i=0;i<k;i++)
   {
           ll d;
           cin>>d;
           for(int i=0;i<d;i++)
           {
                   ll a;
                   cin>>a;
                   v[a]++;
           }
   }
   ll ans = 0;
   for(int i =1;i<=n;i++)
   {
           if(v[i]==0)
           ans++;
   }
   cout<<ans;
}
 
int main() {
            ios_base::sync_with_stdio(false);
            cin.tie(NULL);
	    int t=1;
	    //cin>>t;
	    while(t--)
	    {
	            solve();
	    }
	    return 0;
}

Measured memory_bytes: 3660
import math
A, B, H, M = map(int, input().split())

H_angle = H*30 + M*0.5
M_angle = M*6

angle = abs(H_angle - M_angle)

if angle > 180:
    angle = 360 - angle

cos = math.cos(math.radians(angle))

C_pow = A**2 + B**2 - 2*A*B*cos


C = math.sqrt(C_pow)
C = float('{:.20f}'.format(C))
print(C)


Measured memory_bytes: 9504
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO ?????????????????????????????????????????????
		
		Scanner scan = new Scanner(System.in);
		// ?????°??????????????°???
		int n = scan.nextInt();
		// ???????????????????´????????????°
		int taro = 0;
		int hanako = 0;
		// ?????????????????????????????§??°?????????
		for(int i = 0; i<n; i++) {
			// ??????????????????
			String taroCard = scan.next();
			String hanakoCard = scan.next();
			// ?????????????????????????????????
			int tl = taroCard.length();
			int hl = hanakoCard.length();
			int l = 0;
			if(tl < hl) l = tl;
			else l = hl;
			// ??????????????????1????????\???char??????????´?
			char[] tcC = taroCard.toCharArray();
			char[] hcC = hanakoCard.toCharArray();
			// 1????????\????????????
				int count = 0;
				for(int i2 = 0; i2 < l; i2++){
					if (tcC[i2] > hcC[i2]) {
						taro = taro + 3;
						count = 1;
						break;
					}
					else if (tcC[i2] < hcC[i2]) {
						hanako = hanako + 3;
						count = 1;
						break;
					}
				}
				if(count == 0) {
					if (tl > hl) taro = taro +3;
					else if (tl < hl) hanako = hanako +3;
					else{
						taro = taro + 1;
						hanako = hanako +1;
					}
				}
		}
		// ??????
		System.out.println(taro + " " + hanako);

	}

}

Measured memory_bytes: 30088
#include <iostream>
#include <vector>

using namespace std;


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

	int l = 0;
	int r = 1;
	int x = A[0];
	int s = A[0];
	long ans = 0;
	while (l < r) {
		while (r < N && x == s) {
			x ^= A[r];
			s += A[r];
			r ++;
		}

		ans += r - l - 1;
		if (x == s) ans += 1;

		x ^= A[l];
		s -= A[l];
		l++;
		if (l == r && r < N) r++;
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
#!/usr/bin/env python
n, x, m = map(int, input().split())

tmp = x 
cnt = 0 
dup = 0 
a = [x] 
while True:
    tmp = (tmp*tmp)%m
    if tmp in a:
        dup = tmp 
        break
    cnt += 1
    a.append(tmp)

di = 0 
for i in range(len(a)):
    if a[i] == dup:
        di = i 

# block sum
b = []
bs = 0 
for i in range(di, len(a)):
    bs += a[i]
    b.append(a[i])

# block length
bl = len(a)-di
sumbl = 0 

ans = 0 
for i in range(di):
    ans += a[i]
ans += (n-di)//bl * bs
for i in range((n-di)%bl):
    ans += b[i]

print(ans)


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

int main(void)
{
	int N, K; cin >> N >> K;
	int R, S, P; cin >> R >> S >> P;
	string T; cin >> T;
	vector<char> rec;
	int ans = 0;

	for (int i = 0; i < K; i++) {
		if (T[i] == 's') {
			ans += R;
			rec.push_back('r');
		}
		else if (T[i] == 'p') {
			ans += S;
			rec.push_back('s');
		}
		else {
			ans += P;
			rec.push_back('p');
		}
	}

	for (int i = K; i < N; i++) {
		if (T[i] == 's') {
			if (rec[i - K] != 'r') {
				ans += R;
				rec.push_back('r');
			}
			else if (i < N - K) {
				if(T[i+K]=='p')rec.push_back('p');
				else rec.push_back('s');
			}
			
		}
		else if (T[i] == 'p') {
			if (rec[i - K] != 's') {
				ans += S;
				rec.push_back('s');
			}else if (i < N - K) {
				if (T[i + K] == 'r')rec.push_back('r');
				else rec.push_back('p');
			}
		}
		else {
			if (rec[i - K] != 'p') {
				ans += P;
				rec.push_back('p');
			}
			else if (i < N - K) {
				if (T[i + K] == 's')rec.push_back('s');
				else rec.push_back('r');
			}
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define loop(x,n) for(int x = 0; x < n; ++x)
#define vector_loop(x,n) for(int i = 0; x < n; i++)
#define vii(n) vector<int> a(n)
typedef pair<int, int> pii;
#define endl "\n"
#define sd(val) scanf("%d", &val)
#define ss(val) scanf("%s", &val)
#define sl(val) scanf("%lld", &val)
#define debug(val) printf("check%d\n", val)
#define all(v) v.begin(), v.end()
#define MP make_pair
#define FF first
#define SS second
#define ll long long
#define MOD 1000000007
#define clr(val) memset(val, 0, sizeof(val))
#define what_is(x) cerr << #x << " is " << x << endl;
#define OJ                            \
    freopen("input.txt", "r", stdin); \
    freopen("output.txt", "w", stdout);
#define FIO                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);

int main()
{
    vector<int> a(5);
	int index = 0;
	for (int i = 0; i < 5; ++i)
	{
		cin >> a[i];
	}
	for (int i = 0; i < 5; ++i)
	{
		if (a[i] == 0)
		{
			index = i;
			break;
		}
	}
	cout << index + 1;


}

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

int main()
{
  int d,g;
  int p[11],c[11];
  int i,j;
  int a,b,e;
  int ans=10000;
  scanf("%d%d",&d,&g);
  for(i=0;i<d;i++){
    scanf("%d%d",&p[i],&c[i]);
  }
  for(i=0;i<(1<<d);++i){
    a=0;
    b=0;
    e=0;
    for(j=0;j<d;j++){
      if(i&(1<<j)){
        a+=100*(j+1)*p[j]+c[j];
        b+=p[j];
      }
      else{
        e=j;
      }
    }
    for(j=0;j<p[e];j++){
      if(a>=g){
        if(ans>b) ans=b;
        break;
      }
      a+=100*(e+1);
      b++;
    }
  }
  printf("%d",ans);
  return 0;
}


Measured memory_bytes: 1712
#include <cstdio>
#include <iostream>
#include <string>
#define MAX 1000000
using namespace std;

int main(){
  int i,j,n1,n2,a1,a2;
  bool a[MAX],f1,f2;
  for(i=2;i<MAX;i++) a[i] = true;
  for(i=2;i<MAX;i++){
    if(a[i] == true){
      for(j=i*2;j<MAX;j+=i) a[j] = false;
    }
  }

  while(1){
    cin >> n1 >> n2;
    if(n1 == 0 && n2 == 0) break;

    a1 = a2 = 0;
    f1 = f2 = true;
    for(i=n1;i>=2;i--){
      if(a[i] && n1 % i == 0){
	if(f1){
	  a1 = i;
	  f1 = false;
	}
	else a1 -= i;
      }
    }

    for(i=n2;i>=2;i--){
      if(a[i] && n2 % i == 0){
	if(f2){
	  a2 = i;
	  f2 = false;
	}
	else a2 -= i;
      }
    }


    if(a1 > a2) cout << "a" << endl;
    else cout << "b" << endl;

  }
  return 0;
}

Measured memory_bytes: 1828
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int a = scn.nextInt();
		int b = scn.nextInt();
		int c = scn.nextInt();
		if(b/a<c) {
			System.out.println(b/a);
		}else {
			System.out.println(c);
		}
		scn.close();
	}
}

Measured memory_bytes: 21716
#include <stdio.h>
#include <stdlib.h>

int main()
{
	long long N, M;
	scanf("%lld %lld", &N, &M);
	
	if (N > 1 && M > 1) printf("%lld\n", (N - 2) * (M - 2));
	else if (N * M > 1) printf("%lld\n", N * M - 2);
	else printf("1\n");
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 128
from math import factorial


def c(n):
    if n < 2:
        return 0
    return factorial(n) // (factorial(n-2) * factorial(2))


def main():
    N = int(input())  # 文字列または整数(一変数)
    a = list(map(int, input().split()))  # 整数のリスト
    for i in range(N):
        a[i] -= 1

    nums = [0 for _ in range(N)]

    for i in a:
        nums[i] += 1

    b = [c(nums[i]) for i in range(N)]
    sum_b = sum(b)

    b_alt = [c(nums[i]-1) for i in range(N)]

    for i in range(N):
        print(sum_b - b[a[i]] + b_alt[a[i]])


if __name__ == '__main__':
    main()


Measured memory_bytes: 121476
#ifndef ONLINE_JUDGE
  #include "Debug.h"
#else
  #define debug(...) 42
#endif
#include <bits/stdc++.h>
using namespace std;
#define int long long 
#define f(i,x,n) for(int i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
const int MOD = 1e9 + 7, N = 5e5 + 10;
const int LINF = LLONG_MAX;

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int h,w,m;
    cin >> h >> w >> m;
    map<pair<int,int>,int>maps;
    f(i,1,m+1){
        int x,y;
        cin >> x >> y;
        maps[{x,y}] = 1;
    }
    vector<int>row(h+1,0),col(w+1,0);
    for(auto s : maps){
        row[s.first.first]++;
        col[s.first.second]++;
    }
    vector<int>x,y;
    int ans = 0;
    for(auto s : maps){
        x.push_back(s.first.first);
        y.push_back(s.first.second);
    }
    int a = x.size();
    int b = y.size();
    int ind_x,ind_y;
    int ma_x = 0,ma_y = 0;
    f(i,1,h+1){
        if(row[i] > ma_x){
            ma_x = row[i];
            ind_x = i;
        }
    }
    f(i,1,w+1){
        ans = max(ans,col[i] + ma_x - maps[{ind_x,i}]);
    }
    f(i,1,w+1){
        if(col[i] > ma_y){
            ma_y = col[i];
            ind_y = i;
        }
    }
    debug(ans,ma_y,ind_y);
    f(i,1,h+1){
        ans = max(ans,row[i] + ma_y - maps[{i,ind_y}]);
    }
    cout << ans << "\n";

    return 0;
}
 

Measured memory_bytes: 68876
# coding:utf-8

import sys
# from collections import Counter, defaultdict

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

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def ceil(n, m):
    return -(-n//m)


n, h = LI()
A, B = [], []
for _ in range(n):
    a, b = LI()
    A.append(a)
    B.append(b)

# 2種類以上の刀を振ることはありえない
attack = max(A)
B.sort()
B.reverse()

damage = 0
ans = 0
# 攻撃力の高い順に投げる
for i in range(n):
    if damage >= h:
        break
    # 振った時の最大ダメージ >= 投げた時のダメージの場合
    # 投げるのをやめる
    if B[i] <= attack:
        break
    damage += B[i]
    ans += 1

# 消滅するまで一番攻撃力の高い刀で殴る
if damage < h:
    ans += ceil(h - damage, attack)

print(ans)


Measured memory_bytes: 11316
import java.text.DecimalFormat;
import java.util.stream.LongStream;
import java.util.stream.IntStream;
import java.io.*;
import java.util.*;

public class Main {

    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        PrintWriter out = new PrintWriter(System.out);

        AtCoder problem = new AtCoder(sc);
        problem.solve(out);

        out.flush();
    }

}

class AtCoder {

    int W, a, b;

    AtCoder(FastScanner sc) {
        W = sc.nextInt();
        a = sc.nextInt();
        b = sc.nextInt();
    }

    void solve(PrintWriter out) {
        int max = Math.max(a, b);
        int min = Math.min(a, b);
        out.println(max - (min + W) < 0 ? 0 : max - (min + W));
    }

}

class FastScanner {

    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;

    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }

    private int readByte() {
        if (hasNextByte()) {
            return buffer[ptr++];
        } else {
            return -1;
        }
    }

    private static boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }

    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
            ptr++;
        }
        return hasNextByte();
    }

    public String next() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }

    public long nextLong() {
        if (!hasNext()) {
            throw new NoSuchElementException();
        }
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }

    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
            throw new NumberFormatException();
        }
        return (int) nl;
    }

    public double nextDouble() {
        return Double.parseDouble(next());
    }
}


Measured memory_bytes: 19540
X, Y, A, B, C = gets.chomp.split(" ").map(&:to_i)
pp = gets.chomp.split(" ").map(&:to_i).sort.reverse[0...X]
qq = gets.chomp.split(" ").map(&:to_i).sort.reverse[0...Y]
R = gets.chomp.split(" ").map(&:to_i).sort.reverse

mp = X-1
mq = Y-1

nr = 0
loop do
  m = [pp[-1], qq[-1]].compact.min
  break if nr >= C || m >= R[nr] || (pp.empty? && qq.empty?)
  nr += 1
  if qq.empty? || pp[-1] <= qq[-1]
    pp.pop
  elsif pp.empty? || pp[-1] > qq[-1]
    qq.pop
  end
end

puts (pp.inject(&:+) || 0) + (qq.inject(&:+) || 0) + (R[0...nr].inject(&:+) || 0)


Measured memory_bytes: 35204
#include<iostream>
#include<vector>
#include<bitset>
#define MAX 1000000
using namespace std;

typedef struct {
    int x, y, w, h;
} Rect;

int main(void)
{
    int h, w, k;
    vector<vector<int>> s;
    vector<vector<int>> acum;
    
    cin >> h >> w >> k;
    
    acum.push_back(vector<int>(w+1,0)); // 1オリジンにするため
    for (int i = 0; i < h; i++) {
        vector<int> tmp_s_v;
        vector<int> tmp_acum_v;
        tmp_acum_v.push_back(0); // 1オリジンにするため
        for (int j = 0; j < w; j++) {
            int tmp_s, tmp_acum;
            char c;
            cin >> c; tmp_s = c - '0';
            tmp_s_v.push_back(tmp_s);
            tmp_acum = acum.at(i).at(j+1) + tmp_acum_v.at(j) - acum.at(i).at(j) + tmp_s;
            tmp_acum_v.push_back(tmp_acum);
        }
        s.push_back(tmp_s_v);
        acum.push_back(tmp_acum_v);
    }
    
    int ans = MAX;
    bitset<10> b(0);
    for (int i = 0; !b[h-1]; b = bitset<10>(++i)) { // タテのすべての分け方を走査する
        vector<int> y1_v, y2_v;
        int y1 = 1;
        int y2 = 1;
        while (y2 <= h) {
            while ( b[y2-1] != 1 && y2 < h) y2++;
            y1_v.push_back(y1);
            y2_v.push_back(y2);
            y1 = y2 + 1;
            y2 = y1;
        }
        int h_count = y1_v.size()-1;

        int x1 = 1;
        int x2 = 1;
        int v_count = 0;
        while (x2 <= w) { // ヨコの分け方を調べる
            vector<int>::iterator y1, y2;
            int sum = 0;
            for (y1 = y1_v.begin(), y2 = y2_v.begin(); y1 != y1_v.end(); y1++, y2++) {
                int tmp_sum = acum.at(*y2).at(x2) - acum.at(*y1-1).at(x2) - acum.at(*y2).at(x1-1) + acum.at(*y1-1).at(x1-1);
                if (sum < tmp_sum) sum = tmp_sum;
            }
            if (sum > k) {
                if (x1 == x2) { // このときは分割できない
                    v_count = MAX;
                    break;
                }
                v_count++;
                x1 = x2;
            } else {
                x2++;
            }
        }
        int count = h_count + v_count;
        if (count < ans) ans = count;
    }
    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 384
#include<stdio.h>

int main(){
    char s[4];
    scanf("%s",s);
    for(int i=0;i<3;i++){
        if(s[i]==s[i+1]){
            printf("Bad\n");
            return 0;
        }
    }
    printf("Good\n");
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <climits>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <string.h>
#include <iomanip>
#include <stdlib.h>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;
typedef pair<int, int> P;
const int INF = 100000000;
int dx[4] = { 1,0,-1,0 };
int dy[4] = { 0,1,0,-1 };

int main()
{
	int i, j, k, l, m, sum0,sumn, N, M,X,Y,C;
	cin >> N;
	j = 0;
	sum0 = sumn = 0;
	vector<int>A(N);
	for (i = 0; i<N; i++) {
		cin >> A[i];
	}
	sort(A.begin(), A.end());
	for (i = 0; i < N; i++) {
		if (A[N - 1] % 2 == 0) {
			if (A[i] < A[N - 1] / 2) {
				j++;
			}
		}

			else if (A[N - 1] % 2 == 1) {
				if (A[i] < A[N - 1] / 2) {
					j++;
				}

			}
		
	}
	if (j == N - 1) {
		cout << A[N - 1] << " " << A[N-2] << endl;
	}
	else if(A[N-1]%2==0){
		if (abs(A[j - 1] - A[N - 1] / 2) >= abs(A[j] - A[N - 1] / 2)) {
			cout << A[N - 1] << " " << A[j] << endl;
		}
		else
			cout << A[N - 1] << " " << A[j - 1] << endl;
	}

		else if(A[N-1]%2==1){
			if (abs(A[j - 1] - A[N - 1] / 2) >= abs(A[j] - A[N - 1] / 2)) {
			cout << A[N - 1] << " " << A[j] << endl;
		}
		else
			cout << A[N - 1] << " " << A[j - 1] << endl;
		}
		
	
	
	
	return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const int INF = 1000000005;
const long double EPS = 1e-10;

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> a(n);
  int sum = 0;
  rep(i, n) {
    cin >> a[i];
    sum += a[i];
  }

  vector<int> d;
  for (int i = 1; i * i <= sum; i++) {
    if (sum % i == 0) {
      d.push_back(i);
      d.push_back(sum / i);
    }
  }
  sort(d.begin(), d.end(), greater<int>());

  int n2 = d.size();
  rep(i, n2) {
    vector<int> r(n);
    int sumr = 0;
    rep(j, n) {
      r[j] = a[j] % d[i];
      sumr += r[j];
    }
    sort(r.begin(), r.end(), greater<int>());

    int cnt = 0;
    rep(j, sumr / d[i]) {
      cnt += d[i] - r[j];
    }
    if (cnt <= k) {
      cout << d[i] << endl;
      return 0;
    }
  }

  
  return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int X[100005];
int Y[100005];
int N,A,B,C,m,n,a,b,c,x,y,z,i,j,k,h;
int main ()
{
	cin>>a>>b;
	if(a<b)
	cout<<0;
	else
	cout<<10;
	
	return 0;
}

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

using namespace std;

long long p[200005];
map<long long, long long> m;

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	long long n;
	cin >> n;
	for(long long i = 0; i < n; ++i) cin >> p[i];
	for(long long i = 0; i < n; ++i){
		++m[p[i]];
		if(m[p[i]] > 1){
			cout << "NO";
			return 0;
		}
	}
	cout << "YES";

	return 0;
}



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

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef pair<ll, int> li;
typedef pair<int, ll> il;
typedef vector<ii> vii;
typedef vector<il> vil;
typedef vector<li> vli;

#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define MOD 100000007
#define sz size()
const double pi=acos(-1.0);
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};

int main()
{
    ll a, b, gun, gcd, lcm;
    cin>>a>>b;
    gun=a*b;
    gcd=__gcd(a, b);
    lcm=gun/gcd;
    cout<<lcm<<endl;
    return 0;
}


Measured memory_bytes: 256
#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 <functional>
#include <ctime>
#include <fstream>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
#include <iomanip>
#include <float.h>
#include <math.h>
#include <cassert>
#pragma warning (disable: 4996)
using namespace std;

using ll = long long;
unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

ll ll_gcd(ll a, ll b) {
    if (a < b) return ll_gcd(b, a);
    ll r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

struct UnionFind {
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    if (n < 0)return 0;
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

ll merge_cnt(vector<ll>& a) {
    int n = a.size();
    if (n <= 1) { return 0; }

    ll cnt = 0;
    vector<ll> b(a.begin(), a.begin() + n / 2);
    vector<ll> c(a.begin() + n / 2, a.end());

    cnt += merge_cnt(b);
    cnt += merge_cnt(c);

    int ai = 0, bi = 0, ci = 0;
    while (ai < n) {
        if (bi < b.size() && (ci == c.size() || b[bi] <= c[ci])) {
            a[ai++] = b[bi++];
        }
        else {
            cnt += n / 2 - bi;
            a[ai++] = c[ci++];
        }
    }
    return cnt;
}

int main() {
    ll n;
    cin >> n;
    cout << (modpow(10, n, 1000000007) - modpow(9, n, 1000000007) - modpow(9, n, 1000000007) + modpow(8, n, 1000000007) + 10000000070) % 1000000007 << endl;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define Rep(i,n) for(int i = 0; i < (n); i++)
#define For(i,start,end) for(i64 i = start, i <= end, i++)
using namespace std;
typedef long long ll;
typedef unsigned long ul;

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
using f32 = float;
using f64 = double;

//----------------library in this time--------------------------------



//------------------------main function-------------------------------
void Main(){
    int a;
    char s[11];
    cin >> a;
    cin >> s;
    if(a>=3200){
        cout << s << endl;
    }else{
        cout << "red" << endl;
    }
    
}
//--------------------------------------------------------------------
int main(){
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    
    Main();
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

type Count struct {
	key, val int
}

type Counts []*Count

func (c Counts) Len() int           { return len(c) }
func (c Counts) Swap(i, j int)      { c[i], c[j] = c[j], c[i] }
func (c Counts) Less(i, j int) bool { return c[i].val > c[j].val }

func main() {
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, initialBufSize), maxBufSize)
	defer wt.Flush()

	n := nextInt()
	m := make([]map[int]int, 2)
	for i := range m {
		m[i] = make(map[int]int, 0)
	}
	for i := 0; i < n; i++ {
		v := nextInt()
		m[i%2][v]++
	}

	cnts := make([]Counts, 2)
	for i := range cnts {
		cnts[i] = mapToCounts(m[i])
		sort.Sort(cnts[i])
	}

	var ans int
	if len(cnts[0])*len(cnts[1]) == 0 {
		ans = n / 2
	} else if cnts[0][0].key != cnts[1][0].key {
		ans = n - cnts[0][0].val - cnts[1][0].val
	} else {
		if len(cnts[0]) == 1 && len(cnts[1]) == 1 {
			ans = n / 2
		} else if len(cnts[0]) == 1 {
			ans = n/2 - cnts[1][1].val
		} else if len(cnts[1]) == 1 {
			ans = n/2 - cnts[0][1].val
		} else {
			ans = n - max(cnts[0][0].val+cnts[1][1].val, cnts[1][0].val+cnts[0][1].val)
		}
	}

	puts(ans)
}

const (
	initialBufSize = 100000
	maxBufSize     = 10000000
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wt = bufio.NewWriter(os.Stdout)
)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func puts(a ...interface{}) {
	fmt.Fprintln(wt, a...)
}

func mapToCounts(m map[int]int) Counts {
	c := make(Counts, 0)
	for k, v := range m {
		c = append(c, &Count{k, v})
	}
	return c
}

func max(nums ...int) int {
	ret := nums[0]
	for _, v := range nums {
		if v > ret {
			ret = v
		}
	}
	return ret
}


Measured memory_bytes: 8320
import java.util.*;
import java.lang.*;

public class Main {

    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int x = sc.nextInt();
        int y = sc.nextInt();
        int gcd = 1;
        int mod = Math.max(x, y) % Math.min(x, y);
        
        if (mod == 0){
            gcd = Math.min(x, y);
        } else {
            for (int i = 1; i <= mod; i++) {
                if (x % i == 0 && y % i == 0) {
                    if (gcd < i) {
                        gcd = i;
                    }
                }
            }
        }
        System.out.println(gcd);
    }
}


Measured memory_bytes: 26716
let () = Scanf.scanf "%d %d\n" @@ fun k q ->
  let ds = Array.init k @@ fun _ -> Scanf.scanf "%d " @@ fun d -> d in
  for i = 0 to q - 1 do
    Scanf.scanf "%d %d %d\n" @@ fun n x m ->
      let acc = Array.make (k + 1) 0 in
      for i = 0 to k - 1 do
        acc.(i + 1) <- (if ds.(i) mod m = 0 then m else ds.(i) mod m) + acc.(i)
      done;
      Printf.printf "%d\n" @@
      n - 1 - (x + acc.(k) * ((n - 1) / k) + acc.((n - 1) mod k)) / m + x / m
  done

Measured memory_bytes: 8576
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
typedef unsigned long long int ulli;
#define vec(s) vector

#define vvec(s) vector<vector
>
typedef vector<lli> vi;
typedef vector<vi> vvi;
typedef pair<lli,lli> pii;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define YN(x) cout<<(x?"Yes":"No")<<endl;
#define out(s) cout<<s<<endl;
#define pb(s) push_back(s);
#define sp " ";
#define INF 10000000000
#define LINF 9000000000000000000
#define all(s) s.begin(),s.end()
void vout(vi v){
    for(int i=0;i<v.size();i++)
    cout<<v.at(i)<<endl;
}
int main(){
    lli m, n;
    cin >> m >> n;
    YN(m == n);
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
#include<iostream>
#include<math.h>

using namespace std;

typedef long long int ll; 
const long long mod=1e9+7;

ll power(ll b,ll a) // a^b
{
	if(b==0)
		return 1LL;
	if(b==1)
		return a*1LL;
	if(b%2==0)
	{
		ll temp = power(b/2,a);
		temp = (temp*temp)%mod;
		return temp;
	}
	else
	{
		ll temp = power((b-1)/2,a);
		temp = (temp*temp)%mod;
		return (temp*a)%mod;		
	}

}

int main(void)
{
	ll n,k;
	cin >> n >> k;

	ll cnt[100005];

	ll ans=0;
	for(ll i=k;i>=1;i--)
	{
		cnt[i] = power(n,k/i);
		for(ll j=2*i;j<=k;j+=i)
			cnt[i] = (cnt[i]-cnt[j]+mod)%mod;
		

		ans = (ans + (cnt[i]*i)%mod)%mod;
		// ans = ans%mod;
		// cout << ans << endl;
	}

	cout << ans << endl;


	return 0;
}

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

int main()
{
	string a;
	char i, b, n;

	cin >> a;

	i = a[0];
	b = a[1];
	n = a[2];

	
	if (i==b&&b==n){
		cout << "No";
	}
	else {
		cout << "Yes";
	}
	
	return 0;
}

Measured memory_bytes: 3016
#include<bits/stdc++.h>
clock_t t=clock();
namespace my_std{
	using namespace std;
	#define pii pair<int,int>
	#define fir first
	#define sec second
	#define MP make_pair
	#define rep(i,x,y) for (int i=(x);i<=(y);i++)
	#define drep(i,x,y) for (int i=(x);i>=(y);i--)
	#define go(x) for (int i=head[x];i;i=edge[i].nxt)
	#define templ template<typename T>
	#define sz 66
	#define mod 1000000007ll
	typedef long long ll;
	typedef double db;
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	templ inline T rnd(T l,T r) {return uniform_int_distribution<T>(l,r)(rng);}
	templ inline bool chkmax(T &x,T y){return x<y?x=y,1:0;}
	templ inline bool chkmin(T &x,T y){return x>y?x=y,1:0;}
	templ inline void read(T& t)
	{
		t=0;char f=0,ch=getchar();double d=0.1;
		while(ch>'9'||ch<'0') f|=(ch=='-'),ch=getchar();
		while(ch<='9'&&ch>='0') t=t*10+ch-48,ch=getchar();
		if(ch=='.'){ch=getchar();while(ch<='9'&&ch>='0') t+=d*(ch^48),d*=0.1,ch=getchar();}
		t=(f?-t:t);
	}
	template<typename T,typename... Args>inline void read(T& t,Args&... args){read(t); read(args...);}
	char __sr[1<<21],__z[20];int __C=-1,__zz=0;
	inline void Ot(){fwrite(__sr,1,__C+1,stdout),__C=-1;}
	inline void print(register int x)
	{
		if(__C>1<<20)Ot();if(x<0)__sr[++__C]='-',x=-x;
		while(__z[++__zz]=x%10+48,x/=10);
		while(__sr[++__C]=__z[__zz],--__zz);__sr[++__C]='\n';
	}
	void file()
	{
		#ifdef NTFOrz
		freopen("a.in","r",stdin);
		#endif
	}
	inline void chktime()
	{
		#ifdef NTFOrz
		cout<<(clock()-t)/1000.0<<'\n';
		#endif
	}
	ll ksm(ll x,int y){ll ret=1;for (;y;y>>=1,x=x*x%mod) if (y&1) ret=ret*x%mod;return ret;}
	ll inv(ll x){return ksm(x,mod-2);}
//	inline ll mul(ll a,ll b){ll d=(ll)(a*(double)b/mod+0.5);ll ret=a*b-d*mod;if (ret<0) ret+=mod;return ret;}
}
using namespace my_std;

int n;
ll fac[sz],_fac[sz];

ll dp[sz][sz][sz][sz];

int main()
{
	file();
	read(n);
	fac[0]=_fac[0]=1;rep(i,1,sz-1) _fac[i]=inv(fac[i]=fac[i-1]*i%mod);
	dp[1][1][1][0]=1;
	rep(i,1,n-1) rep(j,1,n) rep(x,0,j) rep(y,0,j-x) if (dp[i][j][x][y]) rep(p,0,x+y) rep(s,0,n-j)
	{
		// (p,x+y-p) \to (x,y), next_sum=s
		int k=p-x;
		if ((s-k+100000)&1) continue;
		ll w=dp[i][j][x][y]*_fac[p]%mod*_fac[x+y-p]%mod;
		if (k<=0)
		{
			k=-k;
			int a=k+(s-k)/2,b=(s-k)/2;
			if ((!a&&!b)||x||y) (dp[i+1][j+s][a][b]+=w)%=mod;
		}
		else
		{
			int a=(s-k)/2,b=k+(s-k)/2;
			if ((!a&&!b)||x||y) (dp[i+1][j+s][a][b]+=w)%=mod;
		}
	}
	ll ans=0;
	rep(x,0,n) rep(y,0,n-x) (ans+=dp[n][n][x][y]*fac[n]%mod*_fac[x]%mod*_fac[y]%mod)%=mod;
	cout<<ans;
	return 0;
}

Measured memory_bytes: 114944
#include <bits/stdc++.h>
using namespace std;
long long n, m, q;
long long a[105], b[105], c[105], d[105];
long long ans;
vector<long long> v;
 
void dfs(int x) {
    if(x==n+1) {
        long long now=0;
        for(int i=1;i<=q;i++) {
            if(v[b[i]]-v[a[i]]==c[i]){
            	now += d[i];
			} 
        }
        ans = max(ans, now);
        return;
    }
    for(int i=v[x-1];i<=m;i++) {
        v.push_back(i);
        dfs(x+1);
        v.pop_back();
    }
}
int main() {
    cin>>n>>m>>q;
    for(int i=1;i<=q;i++) {
        cin>>a[i]>>b[i]>>c[i]>>d[i];
    }
    ans = 0;
    v.clear();
    v.push_back(1);
    dfs(1);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <vector>

#define MOD 1000000007

using namespace std;

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

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

    vector<long long int> s(n + 1);
    s[0] = 0;
    for (int i = 0; i < n; i++) {
        s[i + 1] = s[i] + a[i];
    }

    long long int result = 0;
    long long int temp = 0;

    for (int i = 0; i < n; i++) {
        temp = (s[n] - s[i + 1]) % MOD;
        temp = (a[i] * temp) % MOD;
        result = (temp + result) % MOD;
    }

    cout << result << endl;

    return 0;
}

Measured memory_bytes: 6320
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
#include<cmath>
#define ll long long
using namespace std;
ll a[100010];
ll ansmx,ansmi;
int n;
int main(){
	scanf("%d",&n);
	int i,j;
	for(i=1;i<=n;++i){
		scanf("%lld",&a[i]);
	}
	ansmx=ansmi=2;
	for(i=n;i>=1;--i){
		ansmx=(ansmx/a[i]+1)*a[i]-1;
		if(ansmi%a[i]!=0){
			ansmi=ansmi/a[i];
			ansmi=ansmi*a[i]+a[i];
		}
	}
	if(ansmx>=ansmi){
		printf("%lld %lld\n",ansmi,ansmx);
	}
	else  printf("-1\n");
	return 0;
}

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

int main() {
  int N,K,sum=0;
  cin >> N >> K;
  
  for(int i=0; i<N; i++){
    int x;
    cin >> x;
    
    sum += min(2*x , 2*abs(K-x));
    
  }
  cout << sum << endl;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define sc(x) scanf("%d",&x);
int main(){
    int n, cnt = 0; sc(n)
    vector<int> a(n);
    for (int i = 0; i < n; i++) sc(a[i])
    for (auto &x : a){
        if (x % 2 == 0){
            while (x % 2 == 0){
                cnt++;
                x = x / 2;
            }
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define rrep(i, a, b) for(int i = a; i >= (b); --i)
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define sz(x) (int)(x).size()
#define int long long
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vi> vvi;
#define INF (ll)1e18

void min_self(ll& a, ll b){
  a = min(a,b);
}
signed main() {
  cin.tie(0)->sync_with_stdio(0);
  cin.exceptions(cin.failbit);
  int N, W; cin >> N >> W;
  int V = 0;
  vector<ii> v(N);
  for(ii& i: v){
    cin >> i.first >> i.second;
    V += i.second;
  }
  vector<ll> dp(V+1,INF); // dp[i] - minimum weight of items with value i
  dp[0] = 0;
  rep(i,0,N){
    rrep(w,V-v[i].second,0){
      min_self(dp[w+v[i].second], dp[w]+v[i].first);
    }
  }
  ll res = 0;
  rep(i,1,V+1){
    if(dp[i] <= W) res = i;
  }
  cout << res << "\n";
  return 0;
}


Measured memory_bytes: 3968
#include <bits/stdc++.h>
using namespace std;
int main(){
  long long h,n;
  cin>>h>>n;
  vector<int> x(n);
  for(int i=0;i<n;i++){
    cin>>x[i];
  }
  int attack=0;
  for(int i=0;i<n;i++){
    attack+=x[i];
  }
  if(h<=attack){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

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

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<PII> VP;


//REPEAT
//------------------------------------------
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define RFOR(i, m, n) for(int i = m;i > n;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,m)  RFOR(i,m,0)

//container util
//------------------------------------------
#define pb(a) push_back(a)
#define fst first
#define snd second
#define SORT(V) sort((V).begin(),(V).end())
#define REV(V) reverse((V).begin(),(V).end())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//grobal variable
//------------------------------------------


//def function
//------------------------------------------

//main
//------------------------------------------

signed main(){
  int a, b, c, d, e, k;
  cin >> a >> b >> c >> d >> e >> k;

  if(e-a<=k){
    cout << "Yay!" << endl;
  }else{
    cout << ":(" << endl;
  }
  return 0;
}


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

int main(){
  int a,b[100010];
  cin >> a;
  int c=0;
  int d=0;
  for(int i=0;i<a;i++)
    
   cin >> b[i];
  
  for(int i=0; i<a; i++){
    
    if(b[i]%4==0) c++;
    else if(b[i]%2==0) d++;
    
  }
  
  if(c>=a/2) {
    cout << "Yes" << endl;
    
    return 0;
  }
  else if(c*2+d>=a) {
  cout << "Yes" << endl;
    
    return 0;
}
  
  cout << "No" << endl;
}


Measured memory_bytes: 640