akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main(void){
    int i;
    int src;
    int data;
    
    while(1){
        scanf("%d",&src);
        if(src==0)break;
        
        for(i=0;i<9;i++){
            scanf("%d",&data);
            src-=data;
        }
        printf("%d\n",src);
    }
    return(0);
}

Measured memory_bytes: 600
import sys

#+++++
		
def main():
	a=int((input()))
	l = list(map(int, input().split()))
	pp=1
	for i in l:
		pp=pp*i
		
	kk=0
	for i in l:
		kk+=pp/i

	print(pp/kk)
	
	
#+++++

if __name__ == "__main__":
	if sys.platform =='ios':
		sys.stdin=open('inputFile.txt')
	else:
		pass
		#input = sys.stdin.readline
			
	ret = main()
	if ret is not None:
		print(ret)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
#include <queue>
#include <cmath>

#define	MOD 1000000007;
#define PI 3.14159265358979323846;
using namespace std;
typedef long long ll;
ll mod = 1000000007;

int main()
{
	ll N;
	cin >> N;

	ll A[100000];
	map<ll, ll> mp;
	ll max1 = 0;
	ll max2 = 0;;
	for (ll i = 0; i < N; i++)
	{
		cin >> A[i];

		mp[A[i]]++;

		if (mp[A[i]] >= 2)
		{
			ll value = A[i];
			if (max1 != value && max2 != value)
			{
				if (max1 < value)
				{
					max2 = max1;
					max1 = value;
				}
				else
				{
					if (max2 < value)
					{
						max2 = value;
					}
				}
			}

			if (max1 == value && mp[A[i]] >= 4)
			{
				max2 = value;
			}
		}
	}
	cout << (max1 * max2) << endl;

	return 0;
}

Measured memory_bytes: 7296
import numpy as np
N, M = map(int, input().split())

frag = True
A = np.zeros(N)
for i in range(N):
    A[i] = -1
for i in range(M):
    si,ci = map(int, input().split())
    if A[si-1] != -1 and A[si-1] != ci:
        frag = False
    elif si == 1 and ci == 0 and N != 1:
        frag = False
    else:
        A[si-1] = ci

ans = 0
for i in range(N):
    if A[N-i-1] == -1:
        A[N-i-1] = 0
    ans += A[N-i-1]*(10**i)
    
if ans == 0 and N == 1:
    pass
elif ans < 10**(N-1):
    ans += 10**(N-1)
    
if frag:
    print(int(ans))
else:
    print(-1)

Measured memory_bytes: 21264
from collections import defaultdict
import sys
input = sys.stdin.readline
nmax = 10**5+10
eratos = [0 for i in range(nmax+1)]
prime = []
cnt = 2
while True:
  while cnt <= nmax and eratos[cnt]:
    cnt += 1
  if cnt > nmax:
    break
  eratos[cnt] = 1
  prime.append(cnt)
  for i in range(cnt**2,nmax+1,cnt):
    eratos[i] = 1
cbls = []
sqst = set()
for i in prime:
  if i**3 <= 10**10:
    cbls.append(i**3)
  else:
    sqst.add(i**2)
n = int(input())
a = [int(input()) for i in range(n)]
dc = defaultdict(int)
for i in a:
  for p in cbls:
    while i%p == 0:
      i //= p
  dc[i] += 1
ans = n
for i,v in dc.items():
  if i == 1:
    ans -= v-1
    continue
  if v == 0:
    continue
  x = 1
  for p in prime:
    if p**3 > 10**10:
      break
    if i%(p*p) == 0:
      x *= p
      i //= p*p
    elif i%p == 0:
      x *= p**2
      i //= p
  if i in sqst:
    x *= int(i**0.5+0.5)
    i //= i
  if i != 1:
    continue
  if x in dc:
    ans -= min(dc[x],v)
    dc[x] = 0
print(ans)

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

int main()
{
    int n;

    cin >> n;

    string s[n];
    int p[n];

    for( int i = 0; i < n; i++ )
        cin >> s[i] >> p[i];

    for( int i = 0; i < n - 1; i++ )                //同じ製品をまとめる
        for( int j = i + 1; j < n; j++ )
            if( s[i] == s[j] )
            {
                s[j] = "";
                p[i] += p[j];
                p[j] = 0;
            }

    for( int i = 0; i < n - 1; i++ )                //文字数順に並べる。
        for( int j = i + 1; j < n; j++ )
            if( s[i].size() > s[j].size() )
            {
                string t1 = s[i];
                s[i] = s[j];
                s[j] = t1;
                
                int t2 = p[i];
                p[i] = p[j];
                p[j] = t2;
            }

    for( int i = 0; i < n - 1; i++ )                //辞書順に並べる。
        for( int j = i + 1; j < n; j++ )
            if( s[i].size() == s[j].size() && s[i] > s[j] )
            {
                string t1 = s[i];
                s[i] = s[j];
                s[j] = t1;
                
                int t2 = p[i];
                p[i] = p[j];
                p[j] = t2;
            }

    for( int i = 0; i < n; i++ )
        if( s[i] != "" )
            cout << s[i] << " " << p[i] << endl;

    return 0;
}


Measured memory_bytes: 3732
=begin
1, n*m と m*l の2次元配列を作る
2, n*l のループの中に m のループ
=end

n, m, l = gets.split.map(&:to_i)

a = Array.new(n){
  gets.split.map(&:to_i)
}

b = Array.new(m){
  gets.split.map(&:to_i)
}

n.times do |i|
  arr = []
  l.times do |j|
    sum = 0
    m.times do |k|
      sum += a[i][k] * b[k][j]
    end
    arr << sum
  end
  puts arr.join(' ')
end


Measured memory_bytes: 7352
n,m=map(int,input().split())
h=list(map(int, input().split()))
ans=[0]*n
for i in range(m):
  a,b=map(int,input().split())
  if h[a-1]>h[b-1]:
        ans[b-1]+=1
  elif h[a-1]<h[b-1]:
        ans[a-1]+=1
  else:
        ans[b-1]+=1
        ans[a-1]+=1
print(ans.count(0))

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

int main(){
  string str;
  int LR[9] = {0,1,2,0,1,2,0,1,2};
  int UD[9] = {0,0,0,1,1,1,2,2,2};
  while(cin >> str && str[0] != '#'){
    int ans = 0, ans2 = 0, a = str[0] - '0' - 1, b = a;
    bool turn = false, turn2 = false;
    for(int i=1;i<str.size();i++){
      int n = str[i] - '0' - 1;
      if(!turn && (i % 2 == 1 && LR[n] < LR[a] || i % 2 == 0 && LR[n] > LR[a])){
	ans++;
	/*if(UD[n] != UD[a] || UD[n] != UD[b])*/ turn = true;
      }
      if(!turn2 && (i % 2 == 1 && LR[n] > LR[a] || i % 2 == 0 && LR[n] < LR[a])){
	ans2++;
	/*if(UD[n] != UD[a] || UD[n] != UD[b])*/ turn2 = true;
      }
      if(turn && (i % 2 == 1 && LR[n] > LR[a] || i % 2 == 0 && LR[n] < LR[a])){
	ans++;
	/*if(UD[n] != UD[a] || UD[n] != UD[b])*/ turn = false;
      }
      if(turn2 && (i % 2 == 1 && LR[n] < LR[a] || i % 2 == 0 && LR[n] > LR[a])){
	ans2++;
	/*if(UD[n] != UD[a] || UD[n] != UD[b])*/ turn2 = false;
      }
      b = a;
      a = n;
    }
    cout << min(ans,ans2) << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<iomanip>
#include<map>
using namespace std;
typedef long long ll;

int main() {
    int n; cin >> n;
    map<string, ll> vec;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        vec[s] += 1 ;
    }

    ll ans = 0;
    for (auto v : vec) ans += v.second * (v.second - 1) / 2;
    cout << ans << endl;
}


Measured memory_bytes: 11136
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;

struct Eratosthenes {
    ll n;
    vector<ll> f;  // f[i] : iを割りきる最小の素因数
    vector<ll> primes;  // primes[i] : i番目(iは0-index)の素数
    Eratosthenes(ll n = 1): n(n), f(n+1) {
        f[0] = f[1] = -1;
        for(ll i = 2; i <= n; ++i) {
            if(f[i]) {
                continue;
            } 
            primes.pb(i);
            f[i] = i;
            for(ll j = i*i; j <= n; j += i) {
                if(!f[j]) {
                    f[j] = i;
                } 
            }
        }
    }
    bool isPrime(ll x) {  // xが素数ならtrueを返す
         return f[x] == x;
    }
    vector<ll> factorList(ll x) {  // xの素因数を重複も許して昇順に列挙したvectorを返す(x = 720 = (2^4)*(3^2)*(5^1)なら{2,2,2,2,3,3,5}のように)
        vector<ll> res;
        while(x != 1) {
            res.pb(f[x]);
            x /= f[x];
        }
        return res;
    }
    vector<P> factor(ll x) {  // (xのi番目の素因数, その素因数の個数)のvectorを返す(x = 720 = (2^4)*(3^2)*(5^1)なら{(2, 4), (3, 2), (5, 1)}のように)
        vector<ll> fL = factorList(x);
        if(fL.size() == 0) {
            return {};
        } 
        vector<P> res(1, make_pair(fL[0], 0));
        for(auto p : fL) {
            if(res.back().first == p) {
                res.back().second++;
            } 
            else {
                res.emplace_back(p, 1);
            }
        }
        return res;
    }
};

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

    Eratosthenes era(MAX_N);
    map<ll, ll> mp;
    exrep(x, 1, n) {
        auto f = era.factor(x);
        for(auto p : f) {
            mp[p.first] += p.second;
        }
    }
    
    ll ans = 1;
    for(auto p : mp) {
        ans *= (p.second + 1);
        ans %= mod;
    }

    out(ans);
    re0;
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define INF 1e18
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
#define MAX 1000
#define ll long long
#define P pair<int,int>
using namespace std;
const int mod = 1000000007;
//char c[MAX][MAX];
int step[MAX][MAX];
int H,W,N; 
int vy[4] ={1,-1,0,0}, vx[4] = {0,0,-1,1}; //up,down,left,right 

signed main(){
    ll n,m; cin >> n >> m;
    vector<pair<ll,ll>> v;
    rep(i,m){
        pair<ll,ll> p; cin >> p.second >> p.first;
        v.push_back(p);
    }
    sort(v.begin(),v.end());

    ll cnt=-100,ans=0;    
    rep(i,v.size()){
        if(cnt <= v[i].second){
            cnt = v[i].first;
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    list<string> list1;
    for(int i=0;i<n;i++){
        string name;
        cin >> name;
        list1.push_front(name);
    }
    list1.sort();
    list1.unique();

    // string *various = new string[n];
    // int count = 0;
    // for(int i=0;i<n;i++){
    //     string name;
    //     int flag = 0;
    //     cin >> name;
    //     for(int j=0;j<i;j++){
    //         if(various[j] == name){
    //             flag = 1;
    //             break;
    //         }
    //     }
    //     if(flag == 0){
    //         various[i] = name;
    //         count++;
    //     }
    // }
    cout << list1.size()<< endl;
	return 0;
}

Measured memory_bytes: 12596
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <cmath>
#define INF 100000000
#define MOD 1000000007
using namespace std;


int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    cout<< min(a,b)+min(c,d) << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s=sc.next();
		int count=0;
		for(int i=0;i<3;i++) {
			if(s.charAt(i)=='o') {
				count++;
			}
		}
		System.out.println(700+(100*count));
	}
}

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

int main(){
    int x,y,z; cin >> x >> y >> z;
    int p = 0;
    int ans;
    while(y*p +z*(p+1) <= x){
        ans = p;
        p++;
    }
    cout << p-1 << endl;
}




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

int main() {
    char c11, c12, c13, c21, c22, c23;
    cin >> c11 >> c12 >> c13 >> c21 >> c22 >> c23;
    
    cout << (c11==c23 and c12==c22 and c13==c21 ? "YES" : "NO") << endl;
}


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

vector<long long> fibo(long long N){
    long long i;
    vector<long long> A(N);

    for(i=0;i<N;i++){
        if(i==0){
            A[0]=1;
        }else if(i==1){
            A[1]=2;
        }else{
            A[i]=(A[i-1]+A[i-2])%1000000007;
        }
    }

    return A;
}
 
int main(){
    long long i;
    long long N,M;
    long long one_count=0;
    long long result=1;
    cin>>N>>M;
    vector<long long>A(M);
    vector<long long>B(M+1);
    vector<long long> fibo_B;

    if(M==0){
        fibo_B=fibo(N);
        cout<<fibo_B[N-1]<<endl;
    }else{
        for(i=0;i<M;i++){
            cin>>A[i];
            if(i==0){
                B[0]=A[i]-1;
            }else{
                if(A[i]-A[i-1]==1){
                    one_count+=1;
                }
                B[i]=A[i]-A[i-1]-2;
            }
        }

        if(one_count>0){
            cout<<0<<endl;
        }else{
            B[i]=N-A[i-1]-1;

            sort(B.begin(),B.end());
            fibo_B=fibo(B[M]);
            for(i=0;i<M+1;i++){
                if(B[i]!=0){
                    result*=fibo_B[B[i]-1];
                }
                result=result%1000000007;
            }

            cout<<result<<endl;
        }
    }
}

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

bool p[1300000];

void prime() {
  fill(p, p+1300000, true);
  p[0] = false;
  p[1] = false;
  for(int i = 2; i < 1300000; i++) {
    if(p[i]) {
      for(int j = 2; i*j < 1300000; j++) {
	p[i*j] = false;
      }
    }
  }
}

int main() {
  int n;
  prime();
  while(cin >> n, n) {
    int ans = 0;
    for(int i = n; !p[i]; i--) ans++;
    for(int i = n; !p[i]; i++) ans++;
    cout << ans << endl;
  }
}

Measured memory_bytes: 2428
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		String[] datasetstr = new String[2];
		int[] datasetint = new int[2];
		while (str != null) {
			datasetstr = str.split(" ", 2);
			datasetint[0] = Integer.parseInt(datasetstr[0]);
			datasetint[1] = Integer.parseInt(datasetstr[1]);
			System.out.println(Math.round(Math.ceil(Math.log10(datasetint[0]
					+ datasetint[1] + 1))));
			str = br.readLine();
		}
	}
}

Measured memory_bytes: 24488
#include<algorithm>
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<map>
using namespace std;
int main()
{
	double n,k,m,p=0,q;
	cin>>n>>k;
	for(int i=1;i<=n;i++)
	{
		q=1/n;
		for(m=i;m<k;m*=2,q/=2);
		p+=q;
	}
	cout<<setprecision(12)<<p<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)

int n;
int main()
{
	cin >> n;
	if (n <= 2) cout << 0 << endl;
	else cout << n / 3 << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<string>
using namespace std;
typedef long long ll;
typedef long double lb;
typedef vector<int,vector<int>> vec;
typedef pair<int,int> P;
#define REP(i,j,n) for (int i=j;i<(n);i++)
#define RREP(i,n) for (int i = n; 0<i;i--)
#define print(out) cout<< out  << "\n";
#define all(vec) vec.begin(),vec.end()
#define mod 1000000007
const int INF = 1e9;

int main(){
  int N,a,b;cin>>N;
  map<int, int>mp0,mp1;
  REP(i,0,N/2){
    cin>>a>>b;
    mp0[a]++;mp1[b]++;
  }
  vector<P> vec0,vec1;
  for(auto mp : mp0)(vec0.push_back({mp.second,mp.first}));
  for(auto mp : mp1)(vec1.push_back({mp.second,mp.first}));
  sort(all(vec0),greater<>());sort(all(vec1),greater<>());
  //print(vec0[0].first<<vec1[0].first)
  if(vec0[0].second!=vec1[0].second){
    print(N-vec0[0].first-vec1[0].first)
  }
  else {
    int v0,v1,v2=0,v3=0;
    v0=vec0[0].first;
    v1=vec1[0].first;
    if(vec0.size()>1)v2 = vec0[1].first;
    if(vec1.size()>1)v3 = vec1[1].first;
    print(N-max(v0+v3,v1+v2))

  }

}


Measured memory_bytes: 6136
package main

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

func main() {
	n, k := readI(), readI()
	a := k
	for i := 1; ; i++ {
		if n < a {
			fmt.Println(i)
			return
		}
		a *= k
	}
}

/*-----------Input utils-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	if len(os.Args) >= 2 {
		if os.Args[1] == "debug" {
			debug()
		}
	}
	const buf = 200100
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, buf), buf)
}

func debug() {
	testFile, err := os.Open("./test/sample-1.in")
	if err != nil {
		fmt.Fprintln(os.Stderr, "There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

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

func readR() []rune {
	return []rune(readS())
}

func readI() int {
	i, _ := strconv.Atoi(readS())
	return i
}

func readF() float64 {
	f, _ := strconv.ParseFloat(readS(), 64)
	return f
}


Measured memory_bytes: 1780
#include <bits/stdc++.h>
#define eps 1e-3
#define pi acos(-1.0)
#define inf 0x3f
#define INF 0x3f3f3f3f3f3f3f3f
#define pb push_back
#define debug1 cout<<"&&";
#define debug2 cout<<"**";
#define ms(a, x) memset(a, x, sizeof(a))
#define for0(i, n) for(int i = 0; i < n; ++i)
#define for1(i, n) for(int i = 1; i <= n; ++i)
using namespace std;
typedef double db;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, int> pli;
typedef pair<long long, long long> pll;
const int mod = 1e9 + 7;
const int N = 21;
const int M = 3e6 + 10;
/*=================================================================================*/

int n, mp[N][N];
ll dp[M];

int main() {
   cin>>n;
   for0(i, n) for0(j, n) {
      scanf("%d", &mp[i][j]);
   }
   dp[0] = 1;
   for0(i, (1<<n)) {
      ll cnt = 0;
      for0(j, n) {
         if((i >> j) & 1) {
            cnt++; // 记录已经匹配完成的人数
         }
      }
      for0(j, n) {
         if(mp[cnt][j] && ((1<<j)^i) != i) {
            dp[(1<<j)^i] = (dp[(1<<j)^i] + dp[i]) % mod;
         }
      }
   }
   cout<<dp[(1<<n)-1]<<endl;
}

Measured memory_bytes: 20044
#include<stdio.h>
#include<limits.h>

int main(){
  int i,buy,value,sell=0,profit=INT_MIN,num,flag=0;
  scanf("%d",&num);
  scanf("%d",&buy);
  for(i=0;i<num-1;i++){
    scanf("%d",&value);
    if(buy > value && i < num-2){
      sell=value;
      if(profit < (sell - buy))profit = sell - buy;
      buy=value;
      sell = 0;
    }
    else if(sell <= value){
      sell=value;
    }
    if(profit < (sell - buy))profit = sell - buy;
  }
  printf("%d\n",profit);
  return 0;
}


Measured memory_bytes: 2144
N=int(input())
D={}
from decimal import Decimal
A=[Decimal(input()) for _ in range(N)]
A=[int(i*10**9) for i in A]
for i in range(N):
  x=A[i]
  y=x
  tcnt,fcnt=0,0
  while x%2==0 and tcnt<18:
    tcnt+=1
    x//=2
  while y%5==0 and fcnt<18:
    fcnt+=1
    y//=5
  if (tcnt,fcnt) not in D:
    D[((tcnt,fcnt))]=1
  else:
    D[((tcnt,fcnt))]+=1

ans=0
for t1,f1 in D:
  for t2,f2 in D:
    if t1+t2>=18 and f1+f2>=18:
      if t1==t2 and f1==f2:
        ans+=D[(t1,f1)]*(D[(t1,f1)]-1)
      else:
        ans+=D[(t1,f1)]*D[(t2,f2)]
print(ans//2)

Measured memory_bytes: 41632
h, w, k = map(int, input().split())
c = []
for i in range(h):
    c.append(list(input())[:])

sqr = [32, 16, 8, 4, 2, 1]

def bin_num(n):
    paint_num = []
    for i in range(6):
        if n > sqr[i]:
            paint_num.append(5-i)
            n -= sqr[i]
    return paint_num 

ans = 0
h_count = 2**h
w_count = 2**w
for i in range(h_count):
    h_ng = bin_num(i+1)
    for j in range(w_count):
        w_ng = bin_num(j+1)
        count = 0
        for m in range(h):
            for l in range(w):
                if (c[m][l] == '#') and (not m in h_ng) and (not l in w_ng):
                    count += 1
        if count == k:
            ans += 1
print(ans)




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

#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)
#define all(c) (c).begin(), (c).end()
 
typedef vector<int> vi;
typedef vector<vi> vvi;

int main() {
  int n; cin >> n;
  vvi dp(n+1, vi(n+1));

  rep(i, n+1) {
    rep(j, n+1) {
      if(i == 0 || j == 0) {
        dp[i][j] = 0;
        continue;
      }
      int x; cin >> x;
      dp[i][j] =  dp[i-1][j] + dp[i][j-1] - dp[i-1][j-1]+ x;
    }
  }

  int ans = -1<<30;
  loop(i, 1, n+1) {
    loop(j, 1, n+1) {
      loop(k, 1, i+1) {
        loop(l, 1, j+1) {
          ans = max(ans, dp[i][j] - dp[k-1][j] - dp[i][l-1] + dp[k-1][l-1]);
        }
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1256
n,h=map(int,input().split())
A=[]
B=[]
for i in range(n):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)

maxa=max(A)
C=[]
B.sort(reverse=True)
ans=0
for ele in B:
    if ele<maxa:
        break
    ans+=1
    h-=ele
    if h<=0:
        break
if h>0:
    ans+=(h+maxa-1)//maxa
print(ans)

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


int main() {
  int a,b,c,k;
  cin >> a >> b >> c >> k;
  int ans = 0;
  ans += min(a,k);
  k -= min(a,k);
  if(k == 0){ cout << ans; return 0;}
  k -= min(b,k);
  if(k == 0){ cout << ans; return 0;}
  ans -= min(k,c);
  cout << ans;

  return 0;
}

Measured memory_bytes: 3632
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
using namespace  std;
template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.first << "," << P.second << ")";
}
#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) 42
#endif

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define rep(n) for (int i = 0; i < n; ++i)

const int md = 1e9 + 7; //998244353 ;
void addto(int &x, int y) { x = x + y; if (x >= md) x -= md; }
int add(int x, int y) { int z = x + y; return z >= md? z -= md : z;}
void updmin(auto&x, auto y ) { if (y < x) x = y;}
void updmax(auto&x, auto y ) { if (y > x) x = y;}
long long pw(auto x, auto y) {	
	long long s = 1;
	while(y) {
		if (y & 1) s = s * x % md;
		x= 1LL * x * x % md; y /= 2;
	}
	return s;
}


const int maxn = 1e6 + 10;

int T, n, m;

void task() {
	cin >> n;
	cout << 8 - (n - 400) / 200 << endl;
	
	// you should actually read the stuff at the bottom
}
int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout<<fixed<<setprecision(20);
  T = 1;
  for (int ti = 1; ti <= T; ++ti) {
    task();
  }
  return 0;
}

/* stuff you should look for
	* int overflow, array bounds
	* special cases (n=1?)
	* do smth instead of nothing and stay organized
	* write down
*/


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

int main(){
  long t,a,k;
  cin>>t>>a>>k;
  if (t>=k){
    t=t-k;
    cout<<t<<' '<<a;}
  else if (k>(t+a)){
    cout<<"0 0";}
  else {
    k=k-t;
    a=a-k;
    cout<<"0 "<<a;}
  return 0;
}


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

int linearsearch(int s[], int n, int key) {
	int i=0;
	s[n] = key;
	while (s[i] != key) {
		i++;
	}
	return i;
}

int main()
{
	int n, q, c = 0;
	int s[10000];

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> s[i];
	}
	cin >> q;
	int num1 = 0;

	for (int i = 0; i < q; i++) {
		cin >> num1;
		int num = linearsearch(s, n, num1);
		if (num != n)
			c++;
	}
	cout << c << endl;
	return 0; 
}


Measured memory_bytes: 3104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 200005;
const int mod = 1000000007;
int n,x,y;
int c[N], w[N];
int mn[N], mnid[N];
int sz[N];
int min1 = -1, min2 = -1;
ll f[N], inv[N];
ll exp(int a, int x){
    if (x == 0) return 1;
    ll p = exp(a,x/2);
    p *= p; p %= mod;
    if (x & 1){
        p *= a; p %= mod;
    }
    return p;
}
int main(){
    scanf("%d%d%d",&n,&x,&y);
    memset(mn,-1,sizeof(mn));
    f[0] = inv[0] = 1;
    for (int i = 1; i < N; i++) {
        f[i] = (f[i-1]*i)%mod;
        inv[i] = (inv[i-1] * exp(i,mod-2))%mod;
    }
    for (int i = 1; i <= n; i++){
        scanf("%d%d",&c[i],&w[i]);
        if (mn[c[i]] == -1 || mn[c[i]] > w[i]){
            mn[c[i]] = w[i];
            mnid[c[i]] = i;
        }
        if (min1 == -1 || w[min1] > w[i]){
            min1 = i;
        }
    }
    for (int i = 1; i <= n; i++){
        if (c[i] != c[min1]){
            if (min2 == -1 || w[min2] > w[i]){
                min2 = i;
            }
        }
    }
    for (int i = 1; i <= n; i++){
        if (w[i] + mn[c[i]] <= x) w[i] = mn[c[i]];
    }
    for (int i = 1; i <= n; i++){
        if ( (w[min2] + w[i] <= y) || (c[i] != c[min1] && w[i] + w[min1] <= y)){
            sz[c[i]]++;
        }
    }
    ll ans = 1;
    int sum = 0;
    for (int i = 1; i <= n; i++){
        if (sz[i]) {ans *= inv[sz[i]]; ans %= mod;}
        sum += sz[i];
    }
    ans *= f[sum];
    ans %= mod;
    printf("%lld",ans);

}


Measured memory_bytes: 7296
#include <iostream>
#include <vector>
#include <numeric>

int gcd(unsigned a, unsigned b) {
  while(1) {
    if(a < b) std::swap(a, b);
    if(!b) break;
    a %= b;
  }
  return a;
}

int main() {
  int N, X;

  std::cin >> N >> X;

  std::vector<int> x(N);

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

  int answer = std::abs(x[0] - X);

  for (int i = 1; i < N; i++) {
    answer = gcd(answer, std::abs(x[i] - X));
  }

  std::cout << answer << std::endl;
}


Measured memory_bytes: 640
#include<stdio.h>

int main(void){
  int W , H;
  int x , y , r;

  -100 <= x && x <= 100;
  -100 <= y && y <= 100;
  
  scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

  if(0 <= x - r && x + r <= W
     && 0 <= y - r && y + r <= H){
    printf("Yes\n");
  } else {
    printf("No\n");
  }
  
  return 0;
}


/* 円をはじっこによせてる */



Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD 1000000007
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
ll findlcm(ll arr[], ll n)
{
    // Initialize result
    ll ans = arr[0];

    // ans contains LCM of arr[0], ..arr[i]
    // after i'th iteration,
    for (int i = 1; i < n; i++)
        ans = (((arr[i] * ans)) /
                (gcd(arr[i], ans)));

    return ans;
}
int main()
{
     ll n,i,j,cnt=1,k,w=-100,b,h,m,hcf,prod,t;
   /* freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);*/
    cin>>n;
    for(i=1;i<n;i++)
    {
        if(pow(2,i)<=n){
            cnt+=pow(2,i);
        }
        else{
            break;
        }
    }
    cout<<cnt;
    
   
   
    

	    return 0;
}


Measured memory_bytes: 256
Program Frog1;
uses math;
var F,H:Array[0..1000005] of longint;
    i,n :longint;
    minn:int64;
    fi,fo:text;
//--------------------------------
begin
//assign(fi,'Frog1.inp');reset(Fi);
readln(n);
for i:=1 to n do begin
                 Read(H[i]);
                 end;
F[1]:=0;
F[0]:=0;
H[0]:=1000000000;
for i:=2 to n do begin
                 F[i]:=min(F[i-1]+abs(H[i]-H[i-1]),F[i-2]+abs(H[i]-H[i-2]));
                 end;
Writeln(F[n]);
//readln;
end.


Measured memory_bytes: 4608
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
 
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; }
 
#include <bits/stdc++.h>
using namespace std;
 
int main(){
    string s;
    cin>>s;
  
    cout<<s[0]<<s[1]<<s[2]<<endl;

    
  return 0;
}

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

int main()
{
    int n, x, cnt = 0;
    do
    {
        scanf("%d %d", &n, &x);
        cnt = 0;
        if (n != 0 || x != 0)
        {
            for (int a = 1; a <= n; a++)
            {
                for (int b = 1; b <= n; b++)
                {
                    for (int c = 1; c <= n; c++)
                    {
                        if (a < b && b < c && a + b + c == x)

                        {
                            cnt = cnt + 1;
                        }
                    }
                }
            }
            printf("%d\n", cnt);
        }

    } while (n != 0 || x != 0);
}



Measured memory_bytes: 2032
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define pb emplace_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define F first
#define S second
#define vll vector<ll>
#define fast ios:: sync_with_stdio(false),cin.tie(0);
#define COUT cout<<fixed<<setprecision(9)
#define SET set<ll,greater<ll>>gquiz
#define ITERATOR set<ll,greater<ll>> :: iterator itr
#define V vector<ll>vector
#define sz size()
#define A vector<pair<ll,ll>>vect
ll N=100000,M=100000;
#define B vect.push_back(make_pair(N,M));
 
bool sortbysec(const pair<int,int> &a,const pair<int,int> &b) 
{ 
    return (a.second < b.second); 
} 
ll pow1(ll n,ll k,ll mm){
    if(k==0)return 1;
    if(k%2==0)return (pow1((n%mm)*(n%mm),k/2,mm))%mm;
    return ((n%mm)*(pow1((n%mm)*(n%mm),k/2,mm)%mm))%mm;
}
ll pow2(ll n,ll k){ll ans=1;
	while(k>0){
        if(k%2==1)ans=ans*n;n=n*n;k/=2;
    }return ans;
}
ll ncr(ll n,ll r){if(n==1 || r==0)return 1;if(r>n/2)r=n-r;
	ll ans=1;for(ll i=1;i<=r;i++){ans=((ans * n )/i);n--;}return ans;
}
ll ncrsum(ll n,ll r, ll mod){
	if(n==1 || r==0)return 1;
	ll ans=1,sum=1;for(ll i=1;i<=r;i++){ans=(((ans * n )/i)%mod);n--;sum+=ans;sum%=mod;}return sum;
}
bool isprime(ll n){if(n==1 || (n!=2 && n%2==0))return false; if(n==2)return true; 
		for(ll i=3;i<=sqrt(n);i+=2)if(n%i==0)return false; return true; }
		
vll factor(ll n){
	vll ans;
	if(n>0)ans.pb(1);if(n==2)ans.pb(2);
	for(ll i=2;i*i<=n;i++){if(n%i==0){ans.pb(i);if(n/i!=i)ans.pb(n/i);}}if(n>2)ans.pb(n);
	return ans;
}
ll numoffactor(ll n){ return factor(n).sz;}
ll gcd(ll a,ll b) 
{ 
	if (a == 0) 
		return b; 
	return gcd(b%a, a); 
} 
 
int main()
{
	ll n,m,k;
	cin>>n>>m>>k;
	if(k%2==0)
	{
		ll b[n+1];
		if(m>0)
		{
		   b[0]=k;
		   m--;
		}
		else
		{
			if(k<1e6)
			{
				b[0]=k+1;
				b[1]=k+1;
			}
			else
			{
				b[0]=1;
				b[1]=1;
			}
		}
		ll x=1;
		while(m>0)
		{
			b[x]=k;
			x++;
			m--;
		}
		for(ll i=x;i<n;i++)
		{
		   if(k<1e6)	
		   b[i]=k+1;
		   else
		   b[i]=1;
		}
		
		for(ll i=0;i<n;i++)
		cout<<b[i]<<" ";
	}
	else
	{
		ll b[n+1];
		if(m>0)
		{
			b[0]=k;
			m--;
		}
		else
		{
			b[0]=k+1;
			b[1]=k+1;
		}
		ll x=1;
		while(m>0)
		{
			b[x]=k;
			x++;
			m--;
		}
		for(ll i=x;i<n;i++)
		b[i]=k+1;
		
		for(ll i=0;i<n;i++)
		cout<<b[i]<<" ";
	}
}

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

int main() {
  string s;
  cin >> s;
  int n = s.size();
  vector<char> c(n);
  for (int i=0; i<n; i++) {
    c.at(i) = s.at(i);
  }
  sort(c.begin(), c.end());
  string ans = "yes";
  for (int i=1; i<n; i++) {
    if(c.at(i) == c.at(i-1)) {
      ans = "no";
      break;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let n = read::<i64>();
    let k = read::<i64>();

    println!("{}",  (n/k)*(n/k)*(n/k) + if k % 2 == 0 { ((n+k/2)/k) * ((n+k/2)/k) * ((n+k/2)/k) } else { 0i64 });
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) { cout << H << " "; debug_out(T...); }
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

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

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int n;
  string s;
  cin >> n >> s;
  int ans = 0;
  for (int r = 1; r < n; ++r) {
    vector<int> left(50,0), right(50,0); //アルファベットのカウント
    for (int i = 0; i < r; ++i) {
      left[s[i] - 'a']++;
    }
    for (int i = r; i < n; ++i) {
      right[s[i] - 'a']++;
    }
    int res = 0;
    rep(i,50) {
      if (left[i] > 0 && right[i] > 0) {
        res++; //どちらにも含まれる
      }
    }
    chmax(ans,res);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <array>
#include <deque>
#include <stack>
#include <queue>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <utility>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <complex>
#include <bitset>
#include <functional>

using namespace std;
using ll=long long int;

int main() {
    int n;
    cin >> n;
    vector<int> b(n);
    for (auto &e: b) cin >> e;

    int ans = b[0] + b[n-2];
    for (int i = 0; i < n-2; ++i) {
        ans += min(b[i], b[i+1]);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
n,a,b = list(map(int, input().split()))

if (b-a)%2==0:
    print(int((b-a)//2))
else:
    #print(min(a-1,n-b)+1+(b-a-1)//2)
    if b-a==1:
        if a-1 < n-b:
            print(a)
        else:
            print(n-a)
    else:
       # if a==1 or b==n:
        #    print(int((b-a-1)/2+1))
        if a-1 < n-b:
            #print(b-1-1)
            print(int(a+(b-a-1)//2))
        else:
            print(int(n-b+1+(n-(a+n-b+1))//2))



Measured memory_bytes: 3060
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <array>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional> // greater など
#include <cmath>      // abs など
#include <numeric>    // accumulate, gcd など
#include <cassert>    // assert
#include <stdexcept>
#include <bitset>
using namespace std;

// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
// typedef int128_t ll;
// typedef cpp_int ll;

// GCC, 配列のアクセスなど
#define _GLIBCXX_DEBUG
// Clang, 配列のアクセスなど
#define _LIBCPP_DEBUG 0

// #define NDEBUG 1
// debug用出力 https://trap.jp/post/998/
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << H << " ";
    debug_out(T...);
}
#ifdef NDEBUG
#define debug(...)
#else
#define debug(...) debug_out(__VA_ARGS__)
#endif

//////////////// //////////////// //////////////// //////////////// ////////////////
//////////////// //////////////// //////////////// //////////////// ////////////////

// constexpr inline ll mod = 1'000'000'007;
// constexpr int max_n = 200'000 + 5;

int n;
vector<ll> as;
queue<ll> nxt;
ll res;

int main()
{
    // 高速な入出力
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << setprecision(15); // 浮動小数の表示の精度

    cin>>n;
    rep(i,n) {
        int a; cin>>a; as.push_back(a);
    }
    sort(as.begin(), as.end(), [](ll a, ll b){return a > b;});
    nxt.push(as[0]);
    rep(i,n-1) {
        res += nxt.front(); nxt.pop();
        nxt.push(as[i + 1]);
        nxt.push(as[i + 1]);
    }
    cout<<res<<endl;

    return 0;
}


Measured memory_bytes: 6348
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 
#define dump(x)  cout << #x << " = " << (x) << endl;
typedef long long lint;
using namespace std;
int main(){
	lint n,a,b,ans=0;
	cin>>n>>a>>b;
	ans+=a*(n/(a+b));
	ans+=(a<n%(a+b)?n%(a+b)-(n%(a+b)-a):n%(a+b));
	cout<<ans<<endl;
}

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

    sum = 0
    for j in range(n):
        j += 1
        # for i in range(n):
        #     if i % j == 0:
        #         sum += i
        k = n // j
        sum += (k * (1 + k) // 2) * j 

    print(sum)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9168
#include <bits/stdc++.h>
using namespace std;
int H,W;
char board[50][50];
int white;
struct P {int h,w,d;};
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
 
 
int bfs(){
	queue<P> Q;
  	Q.push(P{0,0,0});
    board[0][0]='#';  
  
    while(Q.size()){  
  	P p=Q.front();Q.pop();
    if (p.h==H-1 && p.w==W-1)return p.d;
 	int nh,nw;
  	for(int i=0;i<4;i++){
      nh=p.h+dh[i];nw=p.w+dw[i];
  	  if(0<=nh && nh<H && 0<=nw && nw<W &&  board[nh][nw]=='.'){
        Q.push(P{nh,nw,p.d+1});
 	    board[nh][nw]='#';
      }
    }
    }
    return -1;
}
		
int main(){
	cin >>H >>W;
  for (int i=0;i<H;i++){
    for (int j=0;j<W;j++){
      cin >>board[i][j];  
      if(board[i][j]=='.')white++;
    }}
    int dist=bfs();
    int ans;
    ans=(dist==-1)?-1:(white-dist-1); 
    
    
    cout << ans <<endl;
    return 0;
    }

Measured memory_bytes: 256
// include
// ------------------------------------------------
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
int getDigit(long long n);      // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(int(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(int(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      ((a)/GCD((a),(b))*(b))
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;

// code
// ------------------------------------------------
int main() {

  ll n;
  cin >> n;
  vector<ll> a(n);
  rep(i,n) cin >> a[i];

  vsort(a);

  ll p = a[0];
  bool flg = false;

  while(1)
  {
    bool flg = true;
    for(int i=0; i < n; i++)
    {
      if(a[i] % p != 0)
      {
        p = a[i] % p;
        flg = false;
        break;
      }
    }
    if(flg)
    {
      break;
    }
  }

  cout << p << endl;

  return 0;
}
// funcの実体
// ------------------------------------------------
int getDigit(ll n)
{
  int i = 1;
  while(1)
  {
    n = n / 10;
    if(n == 0)
      break;
    i++;
  }
  return i;
}
int CalcSumOfDigit(int n)
{
  int s = 0;
  while(n)
  {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(97 <= *itr && *itr <= 122)
    {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str)
{
  for(auto itr = str.begin();itr != str.end() ; itr++)
  {
    if(65 <= *itr && *itr <= 90)
    {
      *itr = *itr + 32;
    }
  }
  return str;
}


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

int main() {
  int N;
  int L;
  int A;
  cin >> N >> L;

  for (int i = 0; i < N; i++) {
    int x;
    cin >> x;
    
    if(L / 2 >= x){
    A += 2 * x;
    }
    
    else{
    A += 2 * (L - x);
    }
  }
  cout << A << endl;

}


Measured memory_bytes: 256
#include <stdio.h>

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

    int i, a, min = 1000001, max = -1000001;
    long long sum = 0;

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

        if(min > a)
        {
            min = a;
        }

        if(max < a)
        {
            max = a;
        }

        sum += a;
    }

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

    return 0;
}

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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end());
#define vdelete(v) (v).erase(unique(all(v)), (v).end());
#define pb(n) push_back(n);
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807
#define MAX_N 100000

struct ans {
    int xy[4];
};

int h,w,a[500][500];
vector<ans> v;


signed main() {
    cin >> h >> w;
    rep(i,h) rep(j,w) cin >> a[i][j];
    rep(i,h) {
        rep(j,w-1) if (a[i][j]%2) {
            ans tmp;
            tmp.xy[0] = i+1;
            tmp.xy[1] = j+1;
            tmp.xy[2] = i+1;
            tmp.xy[3] = j+2;
            v.pb(tmp)
            a[i][j+1]++;
        }
    }
    rep(i,h-1) {
        int X = w-1;
        if (a[i][X]%2) {
            ans tmp;
            tmp.xy[0] = i+1;
            tmp.xy[1] = X+1;
            tmp.xy[2] = i+2;
            tmp.xy[3] = X+1;
            v.pb(tmp)
            a[i+1][X]++;
        }
    }
    cout << v.size() << endl;
    for(auto i : v) {
        rep(j,3) cout << i.xy[j] << " ";
        cout << i.xy[3] << endl;
    }
}




Measured memory_bytes: 8304
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>


using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

int main(void)
{
    cin.sync_with_stdio(false);
    ll N;
    cin >> N;

    // right, left, center
    vector<tuple<ll, ll, ll>> arms;
    REP(n, N) {
        ll x, l;
        cin >> x >> l;
        ll left = x - l;
        ll right = x + l;
        arms.pb(mt(right, left, x));
    }
    sort(ALL(arms));

    ll prev = -1e9;
    ll ans = 0;
    for(auto arm: arms) {
        auto right = get<0>(arm);
        auto left = get<1>(arm);
        if (left >= prev) {
            prev = right;
            ++ans;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 4980
// aising2020_c
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF (ll)(1e9)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    int N;
    cin >> N;

    REPN(n, 1, N+1){

        int sup = sqrt(n);
        int ans = 0;
//        print(n);
        REPN(x, 1, sup+1) REPN(y, 1, sup+1){

            int c = x*x + y*y + x*y - n;
            int b = x + y;
            double s = (-b + sqrt(b*b - 4*c)) / 2;
//            print(x, y, s);
            if (int(s) == s){
                int t = int(s);
                if (t >= 1) ans++;
            }
        }
        print(ans);

    }


    return 0;
}


Measured memory_bytes: 3592
import sys
INF = 1 << 60
MOD = 10**9 + 7 # 998244353
sys.setrecursionlimit(2147483647)
input = lambda:sys.stdin.readline().rstrip()
def resolve():
    a0 = a1 = a2 = a3 = INF

    ans = 0
    for _ in range(int(input())):
        x, y = map(int, input().split())
        ans = max(ans, x + y - a0, x - y - a1, -x + y - a2, -x - y - a3)
        a0 = min(a0, x + y)
        a1 = min(a1, x - y)
        a2 = min(a2, -x + y)
        a3 = min(a3, -x - y)

    print(ans)
resolve()

Measured memory_bytes: 68176
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include<algorithm>
#include <iomanip>
#include <math.h>

using namespace std;
typedef long long ll;
///定義場所///
int i, j, k, l, m, n;
int N, M, K, H, W, T, P;
ll MOD = 1000000007;
//ll ans = 0;
//関数リスト//
int ctoi(char c) {
	switch (c) {
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return 0;
	}
}
//(注)pairの型・比較する場所(first/second)は毎回変えて使用する
bool pairCompare(const pair<int ,int> firstElof, pair<int,int> secondElof)
{
	return firstElof.second < secondElof.second;
}
int Keta(ll F) {
	int keta = 1;
	while (F/10 > 0) {
		keta++;
		F /= 10;
	}
	return keta;
}
//////////////
int main() {
	cin >> N;
	vector<pair<ll, ll>>task(N);
	for (i = 0; i < N; i++) {
		cin >> task[i].first >> task[i].second;
	}
	sort(task.begin(), task.end(), pairCompare);
	int ans = 1;
	ll time = 0;
	for (i = 0; i < N; i++) {
		time += task[i].first;
		if (time > task[i].second) {
			ans = 0;
			break;
		}
	}
	if (ans == 1) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
}

Measured memory_bytes: 3456
n = int(input())
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)
total = 0
for i in range(n):
    for j in range(n):
        for k in range(n):
            total += gcd(i+1,gcd(j+1,k+1))
print(total)

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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)


int main() {
	cin.sync_with_stdio(false);
	int r, g, b;
	cin >> r >> g >> b;
	if ((r * 100 + g * 10 + b) % 4 == 0) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}

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

#define int ll
#define FOR(i,n,k) for(int i=n;i<k;i++)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int32_t main()
{
    IOS;
    string s,w;
    cin>>s;
    w = s[0];
    FOR(i,1,s.size()) if(s[i]!=w[w.size()-1]) w+=s[i];
    cout<<w.size()-1<<"\n";
    return 0;
}

Measured memory_bytes: 592