akhauriyash/Code-Regression huggingface dataset:
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	var res float64
	for i := 0; i < 2*n; i += 2 {
		var x float64
		var u string
		fmt.Scan(&x, &u)
		if u == "BTC" {
			res += x * 380000
		} else {
			res += x
		}
	}
	fmt.Println(res)
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
 
using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int,int> pii;
typedef pair <db,db> pdd;
typedef vector<int> vi;
//typedef vector<vector<int> > matrix;
 
#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))
 
#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>
 
inline int gcd(int a,int b){if(a==0) return b;return gcd(b%a,a);}
inline int power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const double EPS = 1e-9;
const ll MOD=998244353;
const ll hell=1000000007;
const int INF = 1e16;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
template<typename T>
using ordered_set=tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;
 
auto seed = chrono::high_resolution_clock::now().time_since_epoch().count();
std::mt19937 rng(seed);
 
double startTime;
double getCurrentTime() {
    return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}
const int dx[] = { -1, 0, 1, 0 };
const int dy[] = { 0, 1, 0, -1 };
 
const int N=200005;

int cost[1<<16],dp[1<<16];


void solve()
{

int n;
cin>>n;
int a[n][n];
for(int i=0;i<n;i++)
for(int j=0;j<n;j++)
cin>>a[i][j];
for(int mask=1;mask<(1<<n);mask++)
{
    for(int i=0;i<n;i++)
    if(mask&(1<<i))
    {
        cost[mask]=cost[mask^(1<<i)];
        for(int j=0;j<n;j++)
        if(mask&(1<<j))
        cost[mask]+=a[i][j];
        break;
    }
}
for(int mask=1;mask<(1<<n);mask++)
{
    dp[mask]=cost[mask];
    for(int j=mask;j>0;j=(j-1)&mask)
    dp[mask]=max(dp[mask],dp[mask^j]+dp[j]);
}
cout<<dp[(1<<n)-1]<<endl;



}

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


Measured memory_bytes: 4644
#include <iostream>

using namespace std;
int main() {
	int N,s[108];
	int has_non10=0;
	int min_non10;
	int sum=0;
	cin >> N;
	for(int i=0;i<N;i++) {
		cin >> s[i];
		sum+=s[i];
		if(s[i]%10) {
			if(has_non10==0) {
				has_non10=1;
				min_non10=s[i];
			}
			if(min_non10>s[i]) min_non10=s[i];
		}
	}
	if(sum%10) {
		cout << sum << endl;
	} else {
		if(has_non10) {
			cout << sum - min_non10 << endl;
		} else {
			cout << "0" << endl;
		}
	}
	return 0;
}


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

int main() {
	int n;
	cin >> n;
	int a[n], b[n];
	for(int i = 0; i < n; i++) { cin >> a[i]; if(i > 0) a[i] += a[i - 1]; }
	for(int i = 0; i < n; i++) cin >> b[i];
	
	for(int i = n - 2; i >= 0; i--) b[i] += b[i + 1];
	
	int ans = 0;
	for(int i = 0; i < n; i++) ans = max(ans, a[i] + b[i]);
	cout << ans;
}

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

using namespace std;

typedef long long ll;

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

	int a, b;
	cin >> a >> b;
	cout << 6 - (a + b) << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main (){
  int D,G;
  cin >>D>>G;
  int p[D],c[D];
  for(int i=0; i<D; i++) cin >>p[i]>>c[i];
  int ans=100000;
  
  for(int mask=0;mask<(1<<D); mask++){
  	int s=0,num=0,rest_max=-1;
    for(int i=0; i<D; i++){
    	if(mask>>i&1){
        	s+=100*(i+1)*p[i]+c[i];
            num+=p[i];
        }
      else{rest_max=i;}
    }
    
    if(s<G){
    	if(G-s<100*(rest_max+1)*p[rest_max]) num+=(G-s+(100*rest_max+1)-1)/(100*(rest_max+1));
      else continue;
    }
    ans=min(ans,num);
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc = new Scanner(System.in);

		//入力表示
		int K = sc.nextInt();
		int X = sc.nextInt();

		for (int i = X - K + 1; i < X + K; i++) {
			if (i < X + K - 1) {
				System.out.print(i + " ");
			} else {
				System.out.println(i);
			}
		}

	}
}

Measured memory_bytes: 23764
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
  Scanner in = new Scanner(System.in);
  while (in.hasNext()) {
	int d = in.nextInt();
	int val = 0;
	int x;
	for (int i = 1; (x = i * d) < 600; i++) {
	  val += d * x * x;
	}
	System.out.println(val);
  }
}
}

Measured memory_bytes: 12000
N=int(input())
W=[]
for _ in range(N):
    W.append(input())

for i in range(N-1):
    if W[i][-1]==W[i+1][0]:
        pass
    else:
        print('No')
        break
else:
    if len(set(W)) == N:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 38256
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt() + sc.nextInt();
		int b = sc.nextInt() + sc.nextInt();
		System.out.println(a > b ? "Left" : a == b ? "Balanced" : "Right");
	}
}

Measured memory_bytes: 23124
printn = lambda x: print(x,end='')
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split())
ins = lambda : input().strip()
DBG = True # and False
BIG = 10**18
R = 10**9 + 7

def ddprint(x):
  if DBG:
    print(x)

a,b = inm()
s = [1 if (a%4,b%4) in \
   [(0,1),(0,2),(1,1),(1,2),(2,3),(2,0),(3,3),(3,0)] else 0]
for i in range(1,44):
    bit = 1<<i
    aa = 0 if a&bit==0 else a%2
    bb = 0 if b&bit==0 else (b+1)%2
    s.append((aa+bb)%2)
    #if i<8:
    #    ddprint(f"i {i} aa {aa} bb {bb} si {(aa+bb)%2}")
print(sum([s[i]*2**i for i in range(len(s))]))


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  bool bl = false;
  while(!bl){
    if(n < 0) break;
    if(n % 4 == 0) bl = true;
    n -= 7;
  }
  (bl) ? cout << "Yes" << endl : cout << "No" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#define PI 3.14159265359
typedef long long ll;
const int MOD = 1e9+7;
const ll LLINF = 7e18;
using namespace std;


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

	ll tmp = 0, ans1 = 0;
	for (int i = 0; i < n; i++){
		tmp += a[i];
		if (i%2 == 0){
			if (tmp >= 0){
				ans1 += tmp + 1;
				tmp = -1;
			}
		}else{
			if (tmp <= 0){
				ans1 += -tmp + 1;
				tmp = 1;
			}
		}
	}
	tmp = 0;
	ll ans2 = 0;
	for (int i = 0; i < n; i++){
		tmp += a[i];
		if (i%2 == 0){
			if (tmp <= 0){
				ans2 += -tmp + 1;
				tmp = 1;
			}
		}else{
			if (tmp >= 0){
				ans2 += tmp + 1;
				tmp = -1;
			}
		}
	}
	cout << min(ans1, ans2) << endl;
	return 0;
}



Measured memory_bytes: 4048
#include<bits/stdc++.h>
using namespace std;
int main(){
  int s;
  cin >> s;
  bool ym = false, my = false;
  int tl = s%100, hd = s/100;
  if(tl >= 1 && tl <= 12) ym = true;
  if(hd >= 1 && hd <= 12) my = true;
  if(ym && my) cout << "AMBIGUOUS" << endl;
  else if(ym) cout << "YYMM" << endl;
  else if(my) cout << "MMYY" << endl;
  else cout << "NA" << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
main(){
    int N;
    char S[1025];
    scanf("%d",&N);
    char str[][6] = {".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
    for(int i = 0;i < N;i++){
        scanf("%s",S);
        int num = 0;//?????¨??\??????????????????
        int count = 0;
        for(int j = 0;j < strlen(S);j++){
            if(S[j] != '0'){num = S[j] - '0';}
            if(S[j] == '0' && num == 0){continue;}
            if(S[j] == S[j+1]){
                count++;
                continue;
            }
            printf("%c",str[num-1][count%(strlen(str[num-1]))]);
            count = 0;
            num = 0;
        }
        printf("\n");
    }
}

Measured memory_bytes: 2580
#include <stdio.h>
int main(void)
{
    int a=0,b=0,c=0;
    scanf("%d %d %d",&a,&b,&c);
    if(a<b&&b<c)
    {
        printf("Yes\n");
    }
    else
    {
        printf("No\n");
    }
    return 0;
}



Measured memory_bytes: 2100
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<long long,int> P;

int main(){
    int n, a, b;
    cin >> n >> a >> b;
    string s;
    cin >> s;
    int p = 0, q = 0;
    rep(i, n){
        if (s[i] == 'a'){
            if (p + q < a + b) {
                cout << "Yes" << endl;
                p++;
            }
            else cout << "No" << endl;
        }
        else if (s[i] == 'b'){
            if (p + q < a + b && q < b) {
                q++;
                cout << "Yes" << endl;
            }
            else cout << "No" << endl;
        }
        else cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
template <class T> ll size(const T& x) { return x.size(); }
#define rep(i,a,b) for(ll i = (a); i < (b); ++i)
#define iter(it,c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define pb push_back
#define fs first
#define sc second
#define MOD 1000000007
#define MOD2 998244353
#define INF 1000000000000000000ll
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
template <class T> T smod(T a, T b) {
  return (a % b + b) % b; }

struct union_find {
    vi par;
    vi sz;
    union_find(ll n) {
        par = vi(n);
        sz = vi(n);
        rep(i,0,n) par[i] = i, sz[i] = 1;
    }

    ll uf_find(int a) {return par[a] = par[a] == a ? a : uf_find(par[a]); }
    void uf_union(int a, int b) {
        int pa = uf_find(a);
        int pb = uf_find(b);
        if(pa == pb) return;
        par[pb] = uf_find(pa);
        sz[pa] += sz[pb];
    }
    ll uf_size(int a) { return sz[uf_find(a)]; }
};


void solve()
{
    int n, m;
    cin >> n >> m;
    union_find uf = union_find(n);
    rep(i,0,m)
    {
        int a, b;
        cin >> a >> b;
        a--;b--;
        uf.uf_union(a,b);
    }
    ll mx = 0;
    rep(i,0,n)
    {
        mx = max(mx, uf.uf_size(i));
    }
    cout << mx << endl;
}

int main()
{
    cin.sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
	/*ll t;
	cin >> t;
	while(t--)*/
		solve();
}


Measured memory_bytes: 6472
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int main(void){
  int N,X;
  int *m;
  int cnt = 0;
  scanf("%d%d",&N,&X);
  m = (int*)malloc(sizeof(int) * N);
  int i;
  int min = 0;
  for(i = 0; i < N; i++){
    scanf("%d",&m[i]);
  }
  min = m[0];
  for(i = 0; i < N; i++){
    if(min > m[i]){
      min = m[i];
    }
    X -= m[i];
  }
  while(X >= min){
    X -= min;
    cnt++;
  }

  printf("%d", N + cnt);
  
  free(m);
  return 0;
}

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

int main(){

  int D,G;cin>>D>>G;
  vector<int> p(D),c(D);
  for(int i=0;i<D;i++)cin>>p[i]>>c[i];
  int count=1<<30;
  // D桁のビット列 000~111 を繰り返す
  for(int bit=0;bit<1<<D;bit++){
      int tmp=0,num=0;  // tmp は総合スコア, num は回数
      for(int i=0;i<D;i++){
          if(bit&(1<<i)){  // 1 のとき, 全て加算
              tmp+=p[i]*(i+1)*100+c[i];  // 総合スコアに代入
              num+=p[i];  // 計算回数を代入
          }
      }
      if(G<=tmp&&count>num)  count=num;  // 総合スコアが目標を超えてかつ計算回数が小さかったらカウントに代入
      else {  // 総合スコアが目標以下かつ, 計算回数が大きかったら
          for(int i=D-1;i>=0;i--){
              if(!(bit&(1<<i))){  // もしビット列が0だったら
                  if((G-tmp)<p[i]*(i+1)*100){  // 目標-総合スコアよりも全て加算したスコア(ボーナスを抜いたスコア)が大きい時
                      while(tmp<G){  // 総合スコアが目標より小さい間
                          tmp+=(i+1)*100;  // 総合スコアに一回分のスコアを加算
                          num++;  // 計算回数をインクリメント
                      }
                    if(count>num)count=num;  // 計算回数が小さかったらカウントに代入
                  }
              }
          }
      }
  }
  cout<<count<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll         long long
#define fl(i,n)    for(i=0;i<n;i++)
#define fld(i,a,b) for(i=a;i>b;i--)
#define fli(i,a,n) for(i=a;i<n;i++)
#define inp(i,a,n) for(i=0;i<n;i++) {cin>>a[i];}
#define op(i,a,n)  for(i=0;i<n;i++) {cout<<a[i]<<" ";}
#define pb         push_back
#define mp         make_pair
#define F          first 
#define S          second
#define mod        998244353
#define all(x)     x.begin(),x.end()    
#define speedup    ios_base::sync_with_stdio(false),cin.tie(0)
using namespace std;
void comp() {
	ll i,j,k,l,r,n,m;
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	while(1) {
		c-=b;
		if(c<=0) {
			cout<<"Yes\n";
			return;
		}
		a-=d;
		if(a<=0) {
			cout<<"No\n";
			return;
		}
	}
}

int main() {
    speedup;
    ll i=0,t;
    //cin>>t;
    t=1;
    while(t--) {
        comp();
    }
    return 0;
}

Measured memory_bytes: 3640
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main() {
#if _DEBUG
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n;
	cin >> n;
	double sum = 0;
	for (int i = 0; i < n; ++i) {
		int a;
		cin >> a;
		sum += 1. / a;
	}
	printf("%.6f", 1. / sum);
	return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
//#include <stdio.h>
//#include <stack>
//#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
//#include <fstream>
//#include <list>
//#include <iomanip>
#include <stdlib.h>
#include <cctype>

using namespace std;

#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define ssort(z) sort(z.begin(),z.end())
#define rsort(z) sort(z.rbegin(),z.rend())
#define eerase(z) z.erase(unique(z.begin(),z.end()),z.end())
#define ccnt(z,w) count(z.begin(),z.end(),w)


void printVec(std::vector<int> & vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec1(std::vector<string>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}
void printVec2(std::vector<Int>& vec) {
	std::cout << "";
	for (auto it = vec.begin(); it != vec.end(); ++it) {
		std::cout << *it << " ";
	}
	std::cout << std::endl;
}

Int gcd(Int a, Int b) {
	return b != 0 ? gcd(b, a % b) : a;
}
Int lcm(Int a, Int b) {
	return a / gcd(a, b) *b;
	//a*bは64bit integer overflow
}

bool comp(const string a, const string b) {
	return a.length() < b.length();
}

bool integer(double num) {
	return floor(num) == num;
}

string gen(int num) {
	string str = "";
	for (int i = 0; i < num; i++) str += ".";
	return str;
}
Int fact(int num) {
	if (num == 0) return 1;
	else return num * fact(num - 1);
}


int main() {
	int a, b; cin >> a >> b;
	cout << a - b + 1;

	cout << endl;
	return 0;
}

Measured memory_bytes: 256
import numpy as np
N, M = map(int, input().split(" "))
H = [int(x) for x in input().split(" ")]
assert len(H) == N

good = np.ones(N, dtype=bool)

for _ in range(M):
    A, B = [int(x)-1 for x in input().split(" ")]
    if H[A] > H[B]:
        good[B] = False
    elif H[A] < H[B]:
        good[A] = False
    else:
        good[A] = False
        good[B] = False
print(np.sum(good))

Measured memory_bytes: 38476
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define rep(i,m,n) for(int i = (m); i <= (n); i++)
#define zep(i,m,n) for(int i = (m); i < (n); i++)
#define rrep(i,m,n) for(int i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,m,n) for(int i = (m); i <= n; i++){cout << (x[i]) << " ";} cout<<endl;

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    
    map<string, ll> mp;

    ll n; cin >> n;
    zep(i, 0, n){
        string s; cin >> s;
        if(mp.find(s) == mp.end()){
            mp[s] = 0;
        }
        mp[s]++;
    }
    
    ll m; cin >> m;
    zep(i, 0, m){
        string t; cin >> t;
        if(mp.find(t) == mp.end()){
            mp[t] = 0;
        }
        mp[t]--;
    }

    ll mx = 0;
    for(auto it = mp.begin(); it != mp.end(); it++){
        mx = max((*it).second, mx);
    }
    print(mx)
    return 0;
}

Measured memory_bytes: 256
function main(s) {
	s = s.split("\n").map(x => Number(x));
	p = 0;
	for (i = 0; i <= Math.min(s[0], s[3]/500); i++) {
		for (j = 0; j <= Math.min(s[1], (s[3]-500*i)/100); j++) {
			if ((s[3]-500*i-100*j)%50 === 0 && (s[3]-500*i-100*j)/50 <= s[2]) {p++;};
		}
	}
	console.log(p);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8'));



Measured memory_bytes: 9420
fun comp_two_num(a: Int, b: Int): Unit {
    when {
        a < b -> {println("a < b")}
        a > b -> {println("a > b")}
        else -> {println("a == b")}
    }
}

fun main(args : Array<String>) {
    val (a,b) = readLine()!!.split(" ").map(String::toInt)
    comp_two_num(a, b)
}



Measured memory_bytes: 31768
import java.util.Scanner;
	class Main{

		public static void main(String[] args){
	Scanner sc=new Scanner(System.in);
	int MOUNTAIN[]=new int[10];
	for(int i=0;i<10;i++){
		MOUNTAIN[i]=sc.nextInt();
	}
	for(int i=1;i<10;i++){
		for(int j=0;j<10-i;j++){
			if(MOUNTAIN[j]>MOUNTAIN[j+1]){
				int taihi;
				taihi = MOUNTAIN[j];
				MOUNTAIN[j]=MOUNTAIN[j+1];
				MOUNTAIN[j+1]=taihi;
			}
			
		}
	}
	for(int i=9;i!=6;i--){
		System.out.println(MOUNTAIN[i]);
	}
		}
	}

Measured memory_bytes: 26104
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include<bits/stdc++.h>
#define endl "\n"
using namespace __gnu_pbds;
using namespace std;
typedef tree<int, null_type, less<int>, rb_tree_tag, 
             tree_order_statistics_node_update> 
    PBDS;
typedef long long int ll;
const int N=1e5;
void solve(){
	int n;
	cin>>n;
	int arr[n];
	int dp[n];
	for(int i=0;i<n;i++)cin>>arr[i];
	dp[0]=0;
dp[1]=abs(arr[1]-arr[0]);
		for(int i=2;i<n;i++){
			dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
		}
		cout<<dp[n-1]<<endl;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output (2).txt","w",stdout);
#endif
	int t;
	t=1;
	while(t--){
	solve();
	}
	return 0;
}


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

const long double PI = acos(-1);
 
ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}

ll lcm(ll a,ll b){return a / gcd(a,b) * b;}

int main(){
    int h, w, n;
    cin >> h >> w >> n;

    int a = max(h, w);
    cout << ceil((double)n / a) << endl;
    return 0;
}

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

int main() {
  int S;
  cin >> S;
  int a = S/1000, b = (S%1000)/100, c = (S%100)/10, d = S%10;
  if (a == b || b == c || c == d) cout << "Bad" << endl;
  else cout << "Good" << endl;
}


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

typedef long long lint;
typedef pair<int, int> P;
#define REP(i, x, n) for(int i = x ; i < n ; ++i)
#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for(int i = n - 1 ; i >= 0 ; --i)
#define SORT(c) sort((c).begin(), (c).end())

const int IINF = 1e9 + 10;
const lint LLINF = (lint)1e18 + 10;
const lint MOD = (lint)1e9 + 7;
const int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

lint solve(int k, vector<lint> v, int maxbit){
    vector<lint> t;
    repr(j, maxbit){
        t.resize(0);
        rep(i, v.size()){
            if(v[i] >> j & 1){
                t.push_back(v[i]);
            }
        }
        if(t.size() >= k){
            break;
        }
    }
    if(t.size() < k){
        return 0;
    }else if(t.size() == k){
        lint res = t[0];
        rep(i, k){
            res &= t[i];
        }
        return res;
    }else{
        lint tmp = t[0];
        int cnt = 0;
        while(tmp > 0){
            tmp /= 2;
            ++cnt;
        }
        --cnt;
        lint res = 1LL << cnt;
        rep(i, t.size()){
            t[i] %= res;
        }
        res += solve(k, t, cnt);
        return res;
    }
}

int main(){
    int n, k;
    cin >> n >> k;
    vector<lint> a(n);
    rep(i, n){
        cin >> a[i];
    }
    vector<lint> sum(n+1);
    sum[0] = 0;
    REP(i, 1, n+1){
        sum[i] = sum[i-1] + a[i-1];
    }
    vector<lint> v;
    rep(i, n){
        REP(j, i+1, n+1){
            v.push_back(sum[j] - sum[i]);
        }
    }
    lint ans = solve(k, v, 41);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 10736
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <climits>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <set>
#include <complex>
#include <functional>
#include <utility>
#include <iterator>

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define INF 2000000000

#ifdef LOCAL
  #define dprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define dprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

//const double PI = 3.1415926535897932384626433832795;

int main() {
  int n, m;
  cin >> n >> m;
  int t;
  REP(i, m) {
    cin >> t;
    n -= t;
    if(n < 0) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << n << endl;
  return 0;
}


Measured memory_bytes: 3556
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <functional>
#include <string>
#include <array>
#include <vector>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <queue>
#include <complex>
#define full(c) c.begin(), c.end()
#define vector2d(name,type,h,w,init) vector<vector<type>> name(h,vector<type>(w,init)) 
const int PRIME = 1000000007;
const int INT_INF = 2147483647;
const long long int LL_INF = 9223372036854775807;
const double PI = acos(-1);
const double EPS = 0.000000001;
typedef unsigned long long int ull;
typedef long long int ll;
using namespace std;

set<string> ret;
set<string> member;
map <string, set<string> > other;
map<string, bool> flag;
void find(string gr) {
	if (flag[gr]) return;
	flag[gr] = true;
	if (other.find(gr) != other.end()) {
		for (string st : other[gr]) {
			if (other.find(st) != other.end()) {
				find(st);
			}
			else {
				ret.insert(st);
			}
		}
	}
	else {
		ret.insert(gr);
	}
}
int main() {
	while (1) {
		int k, i, n;
		string str;
		cin >> n;
		if (n == 0) break;
		ret.clear();
		flag.clear();
		member.clear();
		other.clear();
		cin >> str;
		k = 0;
		while (str[k] != ':') k++;
		while (str[k] != '.') {
			k++;
			i = 1;
			while ('a' <= str[k + i] && str[k + i] <= 'z') i++;
			member.insert(str.substr(k, i));
			k += i;
		}
		n--;
		while (n--) {
			string gr;
			cin >> str;
			k = 0;
			while (str[k] != ':') k++;
			gr = str.substr(0, k);
			while (str[k] != '.') {
				k++;
				i = 0;
				while ('a' <= str[k + i] && str[k + i] <= 'z') i++;
				other[gr].insert(str.substr(k, i));
				k += i;
			}
		}
		/*for(string st : member) cout<<st<<endl;
		for(auto p : other){
		  cout<<p.first<<":";
		  for(string s : p.second) cout<<s<<" ";
		  cout<<endl;
		}*/
		for (string st : member) {
			find(st);
		}
		/*for(string st : member) cout<<st<<endl;
		for(auto p : other){
		  cout<<p.first<<":";
		  for(string s : p.second) cout<<s<<" ";
		  cout<<endl;
		}
		for(string s : ret) cout<<s<<endl;
		*/
		cout << ret.size() << endl;
	}
	return 0;
}



Measured memory_bytes: 3392
#include <iostream>
#include <stdio.h>
#include <cmath>
using namespace std;
int main(void){
    double x1,x2,y1,y2,A;
    scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2);
    A=(x1-x2)*(x1-x2)+(y1-y2)*(y1-y2);
    
  printf("%.6lf\n",sqrt(A));  
}



Measured memory_bytes: 3200
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=mod*mod*3LL;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

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

ll fac[200007],finv[200007],inv[200007];
void cominit(){
    fac[0]=fac[1]=1;
    finv[0]=finv[1]=1;
    inv[1]=1;
    for(int i=2;i<200007;i++){
        fac[i]=fac[i-1]*i%mod;
        inv[i]=mod-inv[mod%i]*(mod/i)%mod;
        finv[i]=finv[i-1]*inv[i]%mod;
    }
}
ll com(ll n,ll k){
    if(n<k)return 0;
    if(n<0 || k<0)return 0;
    return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}


///////modint
struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    cominit();
    ll n, k;
    cin >> n >> k;
    mint ans = 0;
    for(ll i=0;i<=k;i++){
    	ans += (((com(k, i) * modpow(i, n))%mod) * ((k-i)&1? -1: 1)) % mod;
    }
    ans *= mint(finv[k]);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 7908
def solve(n):
    ans = 0
    mp = {}
    while (n >= 10):
        s = str(n)
        next = -1
        for i in range(1, len(s)):
            next = max(next, int(s[0:i])*int(s[i:]))
        if next in mp:
            ans = -1
            break
        mp[next] = True
        n = next
        ans += 1
    return ans


def main():
    q = int(input())
    for i in range(q):
        n = int(input())
        print(solve(n))


main()



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

int main(){
long long n;
  int c=0;
  int d=0;
  cin>>n;
  vector<long long> a(17);
  if(n>3){
  for(long long i=2;i*i<=n;i++){
 int b=0;
    while(n%i==0){
b++;
      n/=i;
    }
    if(b!=0){
      a.at(d)=b;
      d++;
  }
  }
 if(n!=1){
c++;
 }
  for(long long i=0;a.at(i)!=0;i++){
for(long long j=1;a.at(i)>=j;j++){
  a.at(i)-=j;
  c++;
}
  }
  cout<<c<<endl;
}
  else if(n==1){
cout<<0<<endl;
  }else {
cout<<1<<endl;
  }
}
  


Measured memory_bytes: 3644
#include <cstdio>
#include <cmath>
#include <iostream>
#include <set>
#include <algorithm>
#include <vector>
#include <map>
#include <cassert>
#include <string>
#include <cstring>
#include <queue>

using namespace std;

#define rep(i,a,b) for(int i = a; i < b; i++)
#define S(x) scanf("%d",&x)
#define S2(x,y) scanf("%d%d",&x,&y)
#define P(x) printf("%d\n",x)
#define all(v) v.begin(),v.end()
#define mp make_pair
#define pb push_back
#define FF first
#define SS second

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

int main() {
  int a,b;
  S2(a,b);
  a += b;
  a %= 24;
  P(a);
  return 0;  
}


Measured memory_bytes: 256
// 2011/10/07 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int X, Y;
		cin >> X >> Y;
		if(X==0&&Y==0)
			break;

		int C[18][17];
		for(int i=0; i<=Y+2; i++)
			for(int j=0; j<=X+1; j++)
				C[i][j] = 1;

		for(int i=1; i<=Y; i++)
			for(int j=1; j<=X; j++)
				cin >> C[i][j];

		for(int i=Y+1; i<=Y+2; i++)
			for(int j=1; j<=X; j++)
				C[i][j] = 0;

		int DP[18][17];
		for(int i=0; i<=Y+2; i++)
			for(int j=0; j<=X+1; j++)
				DP[i][j] = 0;

			for(int j=1; j<=X; j++)
				if(C[1][j]==0)
					DP[1][j] = 1;

		for(int i=2; i<=Y; i++)
			for(int j=1; j<=X; j++)
				if(C[i][j]==0){
					DP[i][j] += (DP[i-1][j-1]+DP[i-1][j]+DP[i-1][j+1]);
				}
				else if(C[i][j]==1){
					DP[i][j] = 0;
				}
				else if(C[i][j]==2){
					DP[i+2][j] += (DP[i-1][j]+DP[i][j]);
					DP[i][j] = 0;
				}

		int sum = 0;
		for(int i=Y; i<=Y+2; i++)
			for(int j=1; j<=X; j++)
				sum += DP[i][j];

		cout << sum <<endl;
	}

	return 0;
}

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

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

	switch(n % 10){
	case 2:
	case 4:
	case 5:
	case 7:
	case 9:
		cout << "hon" << endl;
		break;

	case 0:
	case 1:
	case 6:
	case 8:
		cout << "pon" << endl;
		break;

	case 3:
		cout << "bon" << endl;
		break;
	}
	
}

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

using namespace std;

void rwFile() {
    freopen("INP.inp", "r", stdin);
    freopen("OUT.out", "w", stdout);
}

typedef pair<int, int> i2;

const int maxN = 1e5 + 1;
const int maxM = 1e6 + 1;
vector<i2> adj[maxN];
int number[maxN], low[maxN], nC[maxN], order = 0;
int n, m;
stack<int> stk;
int SLTPLTM = 0, TP[maxN];

/// Strongly connected components (SSC)
void DFS_SCC(int u) {
    number[u] = ++order;
    low[u] = number[u];
    stk.push(u);
    for (i2 x : adj[u]) {
        int v = x.first;
        //int id = x.second;
        if (TP[v] != 0) continue;
        if (number[v] == 0) {
            DFS_SCC(v);
            low[u] = min(low[u], low[v]);
        }
        else low[u] = min(low[u], number[v]);
    }
    if (number[u] == low[u]) {
        int v;
        SLTPLTM++;
        do {
            v =  stk.top();
            stk.pop();
            TP[v] = SLTPLTM;
        } while (v != u);
    }
}

void TJALG() { /// https://vn.spoj.com/problems/TJALG/
    cin >> n >> m;
    for (int i = 1; i <= m; i++) {
        int u, v; cin >> u >> v;
        adj[u].push_back({v, i});
    }
    for (int i = 1; i <= n; i++) {
        if (number[i] == 0) DFS_SCC(i);
    }
    cout << SLTPLTM;
}

int parent[maxN], L[maxN], R[maxN], child[maxN], D[maxN];
int cost[maxM];
long long res = 0;

void DFS_tree(int u) {
    L[u] = ++order;
    child[u] = 1;
    for (i2 x : adj[u]) {
        int id = x.second;
        int v = x.first;
        if (v == parent[u]) continue;
        parent[v] = u;
        D[v] = D[u] + cost[id];
        DFS_tree(v);
        child[u] += child[v];
        res += 1LL * cost[id] * child[v] * (n - child[v]);
        //cout << child[v] << " " << v << " ";
    }
    R[u] = order;
}

void NTTREE() { /// https://vn.spoj.com/problems/NTTREE/
    cin >> n;
    for (int i = 1; i < n; i++) {
        int u, v; cin >> u >> v >> cost[i];
        u++; v++;
        adj[u].push_back({v, i});
        adj[v].push_back({u, i});
    }
    DFS_tree(1);
    cout << res;
}

vector<int> Adj[2 * maxN];
int val[2 * maxN];

void DFS_counter(int u) {
    for (int v : Adj[u]) {
        if (v == parent[u]) continue;
        parent[v] = u;
        val[v] += val[u];
        DFS_counter(v);
    }
}

void solveD_Ki() { /// https://atcoder.jp/contests/abc138/tasks/abc138_d
    int q; cin >> n >> q;
    for (int i = 1; i < n; i++) {
        int u, v; cin >> u >> v;
        Adj[u].push_back(v);
        Adj[v].push_back(u);
    }
    while (q--) {
        int p, x; cin >> p >> x;
        val[p] += x;
    }
    DFS_counter(1);
    for (int i = 1; i <= n; i++) cout << val[i] << " ";
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(nullptr); cout.tie(nullptr);
    //rwFile();
    ///TJALG();
    ///NTTREE();
    solveD_Ki();
}


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

signed main(){
  int A,B;
  cin>>A>>B;
  int ans=0;
  if((A+B)%2==0)ans=(A+B)/2;
  else ans=(A+B)/2+1;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3580
#include<stdio.h>
#include<stdlib.h>
#define N 2000001

int main()
{
  int n,i,j,k=0;
  scanf("%d",&n);
  int A[n+1],B[n+1];
  for(i=0;i<n;i++){
    scanf("%d",&A[i+1]);
    if(k<A[i+1])k=A[i+1];
                  }
  int C[k+1];
  for(i=0;i<=k;i++)/*countingsort*/
    C[i]=0;

  for(i=0;i<n;i++)
    C[A[i+1]]++;

  for(i=1;i<=k;i++)
    C[i]=C[i]+C[i-1];

  for(j=1;j<=n;j++){
    B[C[A[j]]]=A[j];
    C[A[j]]--;    } 
                  
  for(i=1;i<=n;i++){
    if(i>1)printf(" ");
     printf("%d",B[i]);
    }
  printf("\n");
  return 0;
}


Measured memory_bytes: 17432
from itertools import chain

n, m = map(int, input().split())
data = [ list(map(int, input().split())) for _ in range(n) ]


for low in data:
	del low[0]

data = list(chain.from_iterable(data))

counter = 0

for i in range(1, m+1):
	if data.count(i) == n:
		counter += 1

print(counter)

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

int main() {
	int a,b,c,d,p,xsya = 0,ysya = 0;
	cin >> a;
	cin >> b;
	cin >> c;
	cin >> d;
	cin >> p;
	xsya = a * p;
	if(p > c){
	ysya = b + (p - c) * d;
	}
	else{
		ysya = b;
	}
	if(xsya > ysya){
		cout << ysya << endl;
	}
	else{
		cout << xsya << endl;
	}


	return 0;
}

Measured memory_bytes: 1160
/**
 *  author: Behradm
 *  Created: 2020.08.02 16:24:10
 *  In The Name Of God
**/
#include <bits/stdc++.h>

using namespace std;

int main() {   
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  string s;
  cin >> s;
  int r =0 ;
  for (int i = 0; i < n; i++)
    r += (s[i] == 'R');
  int res = 0;
  for (int i = 0; i < r; i++)
    res += s[i] != 'R';
  cout <<res << '\n';
  return 0;
}


Measured memory_bytes: 3728
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<tuple>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int N, M, Q;
vector<vector<int>>sum;
int buildSumTable(vector<int> L, vector<int> R) {
	sum = vector<vector<int>>(N + 1, vector<int>(N + 1, 0));
	rep(i, M)sum[L[i]][R[i]] ++;
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= N; j++) {
			sum[i][j] += sum[i - 1][j];
			sum[i][j] += sum[i][j - 1];
			sum[i][j] -= sum[i - 1][j - 1];
		}
	}
}
int getSumRange(int L, int R) {
	int ans = sum[R][R] - sum[R][L - 1] - sum[L - 1][R] + sum[L - 1][L - 1];
	return ans;
}

int main() {
	cin >> N >> M >> Q;
	vector<int>L(M), R(M);
	rep(i, M)cin >> L[i] >> R[i];
	vector<int>p(Q), q(Q);
	rep(i, Q) cin >> p[i] >> q[i];
	buildSumTable(L, R);
	rep(i, Q) {
		int ans = getSumRange(p[i], q[i]);
		cout << ans << endl;
	}
	return 0;
}


Measured memory_bytes: 5120
//#include <bits/stdc++.h>
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <queue>

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<n;++i)
#define mod (ll)(1e9+7)
#define FIX(a) ((a)%mod+mod)%mod
#define ALL(obj) (obj).begin(), (obj).end()
#define rALL(obj) (obj).rbegin(), (obj).rend()
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define fi first
#define se second
#define pb push_back
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<string> s(n);
    REP(i,n) cin >> s[i];
    int a = 0;
    int ans = 0;
    REP(b,n){
        bool f = true;
        REP(i,n){
            REP(j,n){
                int t1i = (i-a+n)%n;
                int t2i = (j-a+n)%n;
                int t1j = (j-b+n)%n;
                int t2j = (i-b+n)%n;
                if(s[t1i][t1j]!=s[t2i][t2j]){
                    f=false;
                    break;
                }
            }
            if(!f) break;
        }
        if(f) ans++;
    }
    cout << ans*n << endl;

    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main(){
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  if((a==b && b!=c) || (a==c && a!=b) || (b==c &&a!=b))
    printf("Yes\n");
  else
    printf("No\n");
  return 0;
}


Measured memory_bytes: 128
n=int(input())
a,b=[],[]
for i in range(n):
  inp=list(map(int,input().split()))
  a.append(inp[0])
  b.append(inp[1])
a.sort()
b.sort()
am=sum(a[(n-1)//2:n//2+1])
bm=sum(b[(n-1)//2:n//2+1])
print(bm-am+1)

Measured memory_bytes: 25420
#include<bits/stdc++.h>
using namespace std;
/*	 0   1	    2      3   	  4       5    	6      7    	     8   
 *  0kg  0   0      0      0      0       0     0      0             0
 *  3kg	 0   0	    0	 3*30   3*30   3*30    3*30   3*30          3*30
 *  4kg	 0   0	    0    3*30   4*50   4*50    4*50   4*50+3*50    4*50+3*30
 *  5kg  0   0      0    3*30   4*50   5*60    5*60   4*50+3*50    5*60+3*30
 *
 *
 * */
int main()
{
    int n,w;
    cin>>n>>w;
    int weights[n+1];
    int values[n+1];
    for(int i=1;i<=n;i++)
    {
	cin>>weights[i]>>values[i];
    }
    long long dp_mat[n+1][w+1]={};
    for(int i=0;i<=n;i++)
    {
	for(int j=0;j<=w;j++)
	{
	    
	    if(i==0||j==0)
		dp_mat[i][j]=0;
	    else if(weights[i]<=j)
		    dp_mat[i][j] =  max(dp_mat[i-1][j], dp_mat[i-1][j-weights[i]] + values[i]);
	    else
		dp_mat[i][j]=dp_mat[i-1][j];
	}
    }

/*
    for(int i =0;i<=n;i++)
    {
	for(int j=0;j<=w;j++)
	{
	    cout<<dp_mat[i][j]<<" ";
	}
	cout<<endl;
    }*/
    cout<<dp_mat[n][w];
    return 0;
}


Measured memory_bytes: 79104
#include<cstdio>
#include<cmath>
using namespace std;
long long n,ans;
int s;
int main(){
    scanf("%lld",&n);
    for(int i=sqrt(n);i>0;--i)
        if(n%i==0){
        	ans=n/i;
        	break;
		}
	while(ans>0){
		++s;
		ans/=10;
	}
	printf("%d\n",s);
    return 0;
}

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

int main(void)
{
 unsigned int N;
 unsigned int l;
 unsigned int r;

 int i,sum=0; 

 scanf("%d",&N);
 
for(i=0;i<N;i++){ 
 scanf("%d %d",&l,&r);
 sum=sum+(r-l)+1;
 }
 
   printf("%d\n",sum);

return 0;
}

Measured memory_bytes: 128
#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 INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
long long dp[110][100010] = {0};
  
int main()
{
  int N, W;
  cin >> N >> W;

  vector<vector<int>> A(N,vector<int>(2));
  REP(i, N){
    REP(j, 2){
      cin >> A.at(i).at(j);
    }
  }
  
  REP(i,N){
    REP(j,W+1){
      if(j-A.at(i).at(0) >= 0){
        chmax(dp[i+1][j],dp[i][j-A.at(i).at(0)]+A.at(i).at(1));
      }
      chmax(dp[i+1][j],dp[i][j]);
    }
  }
  
  cout << dp[N][W] << endl;
}

Measured memory_bytes: 79360
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef std::int_fast64_t i64;
typedef std::uint_fast64_t u64;
typedef std::int_fast32_t i32;
typedef std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(std::vector<T>& vector, const typename std::vector<T>::size_type size) {
    vector.reserve(size);
    std::copy_n(std::istream_iterator<T>(std::cin), size, std::back_inserter(vector));
  }

  template <typename T, std::size_t N>
  void read(std::array<T, N>& array) {
    std::copy_n(std::istream_iterator<T>(std::cin), N, array.begin());
  }
}

#endif

// main.cpp

int main() {
  i64 N, K;
  std::cin >> N >> K;
  std::vector<i64> h;
  tools::read(h, N);

  std::vector<i64> dp(N, std::numeric_limits<i64>::max());
  dp[0] = 0;
  for (i64 i = 0; i < N; ++i) {
    for (i64 j = 1; j <= K; ++j) {
      if (i + j < N) dp[i + j] = std::min(dp[i + j], dp[i] + std::abs(h[i] - h[i + j]));
    }
  }

  std::cout << dp.back() << std::endl;
  return 0;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
inline ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
inline ll lcm(ll a, ll b) { return a / gcd(a, b)*b; }
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T>& V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> >& Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T>& mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }
template<typename T>vector<T> make_v(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>auto make_v(size_t a,Ts... ts){return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type fill_v(T &t,const V &v){t=v;}
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type fill_v(T &t,const V &v){for(auto &e:t) fill_v(e,v);}
/*
 <url:https://atcoder.jp/contests/abc157/tasks/abc157_e>
 問題文============================================================
 E - Simple String Queries
 =================================================================
 解説=============================================================
 ================================================================
 */

template<class Type>
Type solve(Type res = Type()){
    int N; cin >> N;
    string S; cin >> S;
    vector<set<int>> alpha(26);
    for(int i = 0; i < N;i++){
        int c = S[i] - 'a';
        alpha[c].insert(i);
    }
    int Q; cin >> Q;
    while(Q--){
        int com; cin >> com;
        if(com == 1){
            int i; char c; cin >> i >> c;
            i--;
            
            int ic = c - 'a';
            int jc = S[i] - 'a';
            
            alpha[jc].erase(i);
            alpha[ic].insert(i);
            S[i] = c;
        }else{
            int l,r; cin >> l >> r;
            l--; r--;
            int num = 0;
            for(int c = 0; c < 26; c++){
                auto it = alpha[c].lower_bound(l);
                if(it == alpha[c].end()) continue;
                if(l <= *it && *it <= r) num++;
            }
            cout << num << endl;
        }
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    solve(0);
    // cout << fixed << setprecision(15) << solve<ll>() << endl;
    return 0;
}


Measured memory_bytes: 24220
#from fractions import gcd
#mod = 10 ** 9 + 7
#N = int(input())
#a = list(map(int,input().split()))
#a,b,c = map(int,input().split())
#ans = [0] * N
#math.ceilで切り上げ
import math
import string

def intinput():
    return int(input())

def listintinput():
    return list(map(int,input().split()))

def splitintinput():
    return map(int,input().split())

S = input()
a = len(S)
print('x'*a)


Measured memory_bytes: 3828
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 5000;
int n, a, b, p[maxn + 10];
int suf[maxn + 10][maxn + 10], sum[maxn + 10][maxn + 10];
ll f[maxn + 10][maxn + 10];
int cmp(int x, int y) {
	return !x ? y : !y ? x : p[x] < p[y] ? x : y;
}

int main() {
	scanf("%d%d%d", &n, &a, &b);
	for (int i = 1; i <= n; ++i) {
		scanf("%d", &p[i]);
	}
	for (int i = 1; i <= n; ++i) {
		for (int j = n; j >= 1; --j)
			suf[j][i] = cmp(suf[j + 1][i], p[j] >= i ? j : 0);
		for (int j = 1; j <= n; ++j)
			sum[j][i] = sum[j - 1][i] + (p[j] >= i);
	}
	for (int i = n; i >= 1; --i) {
		for (int j = n; j >= 1; --j) {
			f[i][j] = 1e18;
			int pos = suf[i][j];
			if (!pos) f[i][j] = 0;
			else {
				f[i][j] = min(f[i][j], f[i][p[pos] + 1] + b);
				f[i][j] = min(f[i][j], 1ll * (sum[pos - 1][j] - sum[i - 1][j]) * a + f[pos + 1][p[pos] + 1]);
			}
		}
	}
	printf("%lld", f[1][1]);
}


Measured memory_bytes: 392192
/* 
chirag11032000
Chirag Thakur
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

using ll = long long;
using db = double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;

template < typename T > using OrderedSet = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template < typename Arg1 >
void __f(const char* name, Arg1&& arg1) {
	cerr << name << " : " << arg1 << std::endl;
}
template < typename Arg1, typename... Args >
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma = strchr(names + 1, ',');
	cerr.write(names, comma - names) << " : " << arg1 << " | ";
	__f(comma + 1, args...);
}
#else
#define trace(...)
#endif

#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define unique_sort(x) sort(all(x)), x.resize(distance(x.begin(), unique(all(x))))

const db PI = acos(-1);
const ll LINF = LLONG_MAX;
const int INF = INT_MAX, MOD = 1e9 + 7, N = 1e5 + 10;

void test_case();

int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	test_case();
	cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
	return 0;
}

void test_case() {
	int n, l;
	cin >> n >> l;
	int tot = 0;
	for (int i = 1; i <= n; ++i) {
		tot += l + i - 1;
	}
	int best = -INF;
	for (int i = 1; i <= n; ++i) {
		int curr = tot - (l + i - 1);
		if (best == -INF || abs(curr - tot) < abs(best - tot)) {
			best = curr;
		}
	}
	cout << best << "\n";
}

Measured memory_bytes: 256
K, N = tuple(int(v) for v in input().split())

A_list = list(int(a) for a in input().split())

# # 各点の距離
# x_iter = iter(A_list)
# y_iter = iter(A_list)
# next(y_iter)
# 
# d_list = [y - x for x, y in zip(x_iter, y_iter)]
# d_list.append(K - A_list[-1] + A_list[0])
# d_list += d_list
# 
# l = len(d_list) // 2
# # sum_d = [sum(d_list[i:i+l-1]) for i in range(l)]
# min_d = min(sum(d_list[i:i+l-1]) for i in range(l))
# 
# print(min_d)

A_list += [a + K for a in A_list[:-1]]
print(min(A_list[i+N-1] - A_list[i] for i in range(N)))


Measured memory_bytes: 26420