akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <ctime>
#include <cstring>
#include <cassert>
#include <bitset>
#include <sstream>
#include <queue>
            
#define pb push_back
#define mp make_pair
#define fs first
#define sc second
#define sz(a) ((int) (a).size())
#define eprintf(...) fprintf(stderr, __VA_ARGS__)

using namespace std;

typedef long long int64;
typedef long double ldb;

const long double eps = 1e-9;
const int inf = (1 << 30) - 1;
const long long inf64 = ((long long)1 << 62) - 1;
const long double pi = acos(-1);

template <class T> T sqr (T x) {return x * x;}
template <class T> T abs (T x) {return x < 0 ? -x : x;}

bool Clear(vector<bool>& used_x, vector<bool>& used_y, int n, int m) {
	for (int i = 0; i < n; ++i) {
		used_x[i] = false;
	}
	for (int j = 0; j < m; ++j) {
		used_y[j] = false;
	}
	return true;			
}

bool Go(vector<vector<int>>& a,
		vector<vector<int>>& b,
		vector<bool>& used_x,
		vector<bool>& used_y,
		int n, int m,
		int cur_dim, int cur,
		int t_x, int t_y) {
	if (cur_dim == 0) {
		if (cur == t_x) {
			return true;
		}

		used_x[cur] = true;
		for (int i = 0; i < m; ++i) {
			if (!used_y[i] && a[cur][i] > 0) {
				--a[cur][i];
				++b[i][cur];
				if (Go(a, b, used_x, used_y, n, m, 1, i, t_x, t_y)) {
					return true;
				}
				++a[cur][i];
				--b[i][cur];
			}
		}
	} else {
		if (cur == t_y) {
			return true;
		}

		used_y[cur] = true;
		for (int i = 0; i < n; ++i) {
			if (!used_x[i] && b[cur][i] > 0) {
				--b[cur][i];
				++a[i][cur];
				if (Go(a, b, used_x, used_y, n, m, 0, i, t_x, t_y)) {
					return true;
				}
				++b[cur][i];
				--a[i][cur];
			}
		}	
	}

	return false;
}

int main () {
    ios_base::sync_with_stdio(0);
//	freopen("input.txt", "rt", stdin);
//	freopen("output.txt", "wt", stdout);

	int n, m;
	cin >> n >> m;

	vector<vector<int>> a(n, vector<int>(m, 0));
	vector<vector<int>> b(m, vector<int>(n, 0));
	int s_x = -1, s_y = -1;
	int t_x = -1, t_y = -1;
	for (int i = 0; i < n; ++i) {
		string s;
		cin >> s;
		for (int j = 0; j < m; ++j) {
			if (s[j] == 'o') {
				a[i][j] = 1;
				b[j][i] = 1;
			} else if (s[j] == 'S') {
				s_x = i;
				s_y = j;
			} else if (s[j] == 'T') {
				t_x = i;
				t_y = j;
			}
		}
	}

	if (s_x == t_x || s_y == t_y) {
		cout << -1 << endl;
		return 0;
	}


	int res = 0;
	vector<bool> used_x(n, false);
	vector<bool> used_y(m, false);
	while ((Clear(used_x, used_y, n, m) && Go(a, b, used_x, used_y, n, m, 0, s_x, t_x, t_y)) || 
			(Clear(used_x, used_y, n, m) && Go(a, b, used_x, used_y, n, m, 1, s_y, t_x, t_y))) {
		++res;
	}

	cout << res << endl;

	return 0;
}


Measured memory_bytes: 384
s=input()

if s[0] == s[1]:
    if s[2]==s[3] and s[0]!=s[2] and s[0]!=s[3]:
        print('Yes')
    else:
        print('No')
elif s[0] == s[2] and s[0]!=s[1] and s[0]!=s[3]:
    if s[1] == s[3]:
        print('Yes')
    else:
        print('No')
elif s[0] == s[3] and s[0]!=s[1] and s[0]!=s[2]:
    if s[1] == s[2]:
        print('Yes')
    else:
        print('No')
else:
    print('No')

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

int main(){
    
    int X;
    cin >> X;
    
    if (X >= 30){
        cout << "Yes" << "\n";
    } else {
        cout << "No" << "\n";
    }
    
    return 0;
}



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

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    map<int, int> mp;
    for (int i = 0; i < n; i++) mp[a[i]]++;
    long long ans = 0;
    auto ptr = mp.begin();
    while (ptr != mp.end())
    {
        long long x = (*(ptr++)).second;
        if (x >= 2) ans += x * (x - 1) / 2;
    }
    for (int i = 0; i < n; i++)
    {
        long long x = mp[a[i]];
        if (x < 2) cout << ans << endl;
        else cout << ans - x * (x - 1)  / 2 + (x - 1) * (x - 2) / 2 << endl;
    }
}

Measured memory_bytes: 8320
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<n; i++)
#define PI 3.14159265359
#define INF 1000100100
#define MOD 1000000007
#define all(x) (x).begin(),(x).end()
typedef long long ll;
#define P pair<int, int>
#define PP pair<P,int>
#define T tuple<int,int,int> 
using namespace std;

int main(){
    string s; cin >> s;
    int sl=s.length();
    int ans=INF;
    rep(i,sl-2){
        int a=(s[i]-'0')*100;
        int b=(s[i+1]-'0')*10;
        int c=(s[i+2]-'0');
        ans=min(ans,abs(a+b+c-753));
    }
    cout << ans << endl;
    return 0;
}


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

typedef long long ll;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define MP make_pair
#define F first
#define S second
#define PB push_back
#define dump(x)  cout << #x << " = " << (x) << endl;	// debug
#define SZ(x) ((ll)(x).size())
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define RFOR(i, a, b) for (ll i = (a); i >= (b); i--)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define pvd(v) cout << setprecision(16) << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, left, right)  (a).begin()+(left),(a).begin()+(right)	// left to (right-1)

int main() {
	ll n, d;
	ll res = 0;
	double x, y;
	cin >> n >> d;
	FOR(i, 1, n) {
		cin >> x >> y;
		double dis = sqrt(x*x + y * y);
		if (dis <= d)res++;
	}
	pv(res)
	return 0;
}

Measured memory_bytes: 3756
#include <bits/stdc++.h>
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb       push_back
#define conv(a)  bitset<30>(a).to_string() ;
#define mxpq     priority_queue <int>
#define mnpq     priority_queue<int,vector<int>,greater<int>>
#define S(v)     sort(v.begin(),v.end())
#define RS(v)    sort(v.rbegin(),v.rend())
#define print    printf("%.16f\n", ans)
#define inf      LLONG_MAX
#define mini     LLONG_MIN
#define T        int tc;cin>>tc;while(tc--)
#define int      long long 
#define MAXN     10000001
#define M        1000000007
#define fio      cin.sync_with_stdio(false) ; cin.tie(0);cout.tie(0) ;
#define endl     "\n"
using namespace std;
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> Set;


void Xarr(){
     
      int x ; int m ; cin>>x>>m ;
      for(int i=0;i<m;i++){
          int a; cin>>a ;
          x-=a ;
      } 
      if(x<0) x=-1 ;
      cout<<x<<endl ;
} 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
int32_t main(){
 
    cout<<fixed<<setprecision(16);
    cin.sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
 
    #ifndef ONLINE_JUDGE
     freopen("input.txt",  "r",  stdin);
     freopen("output.txt", "w", stdout);
    #endif
    
    cout << setprecision(9) << fixed;
     clock_t z = clock();
     
     Xarr();
     cerr << "Run Time : " << ((double)(clock() - z) / CLOCKS_PER_SEC);
 
     return 0;

}

Measured memory_bytes: 3808
#include<iostream>

using namespace std;

int main()
{
    string S, T;
    cin >> S >> T;
    int N = S.size(), ans = 0;
    for(int i = 0; i < N; ++i)
    {
        if (S[i] != T[i]) ++ans;
    }
    cout << ans << endl;
}



Measured memory_bytes: 3912
#include<bits/stdc++.h>
using namespace std;
int ans;
long long a[87];
int main()
{
    cin>>ans;
    a[0]=2;
    a[1]=1;
    for(int i=2;i<=ans;i++)
        a[i]=a[i-1]+a[i-2];
    cout<<a[ans]<<endl;
    return 0;
}

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;
typedef pair<int, int> P;
const int INF = 1e9;

int main()
{
    string s, t;
    cin >> s >> t;
    if (s.size() < t.size()) {
        cout << "UNRESTORABLE" << endl;
        return 0;
    }
    for (int i = s.size() - t.size(); i >= 0; i--) {
        bool flag = true;
        for (int j = 0; j < t.size(); j++) {
            if (s[i + j] != t[j] && s[i+j] != '?') {
                flag = false;
                break;
            }
        }
        if (flag) {
            for (int j = 0; j < t.size(); j++) s[i+j] = t[j];
            break;
        }
        if (i == 0) {
            cout << "UNRESTORABLE" << endl;
            return 0;
        }
    }
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == '?') s[i] = 'a';
    }
    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
<?php
$data = trim(fgets(STDIN));

$result = array( "diff"=>999, "num"=>999 );
$max = strlen($data);
for( $i=$max-3; $i>=0; $i-- )
{
  $num = substr( $data, $i, 3 );
  $diff = abs(753-$num);
  if( $diff < $result["diff"] )
  {
    $result["num"] = $num;
    $result["diff"] = $diff;
  }
}

echo $result["diff"];

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

long long d,e[18],ans;

long long solve(int l,int r,long long d){
	if (l>=r&&d) return 0;
	if (l==r) return 10-(l==0);
	if (l==r+1) return 1;
	int t=(10-d%10)%10;
	return (10-(l==0)-t)*solve(l+1,r-1,abs(d-t*(e[r-l]-1))/10);
}

int read(){
	int x=0,f=1;char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-')  f=-f;
	for (;isdigit(ch);ch=getchar()) x=x*10+ch-'0';
	return x*f;
}

int main(){
	d=read();
	for (int i=e[0]=1;i<18;i++) e[i]=e[i-1]*10;
	for (int i=0;i<18;i++) ans+=solve(0,i,d);
	printf("%lld\n",ans);
	return 0;
}

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


int main() {
    int n,m;
    cin >> n >> m;
    vector< vector<int>> a(n,vector<int>(m,0));
    rep(i,n)rep(j,m)cin >> a.at(i).at(j);
    vector<int> b(m,0);
    rep(i,m)cin >> b.at(i);
    
    vector<int> c(n,0);
    rep(i,n){
        rep(j,m){
            c[i] += a.at(i).at(j)*b.at(j);
        }
        cout << c[i] << endl;
    }
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/


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

typedef struct{
  double x;
  double y;
} Point;

void koch(int n,Point a,Point b){
  if(n==0) return;
  Point s,t,u;
  double th=M_PI*60.0/180.0;

  s.x=(2.0*a.x+1.0*b.x)/3.0;
  s.y=(2.0*a.y+1.0*b.y)/3.0;
  t.x=(1.0*a.x+2.0*b.x)/3.0;
  t.y=(1.0*a.y+2.0*b.y)/3.0;
  u.x=(t.x-s.x)*cos(th)-(t.y-s.y)*sin(th)+s.x;
  u.y=(t.x-s.x)*sin(th)+(t.y-s.y)*cos(th)+s.y;

  koch(n-1,a,s);
  printf("%.8f %.8f\n",s.x,s.y);
  koch(n-1,s,u);
  printf("%.8f %.8f\n",u.x,u.y);
  koch(n-1,u,t);
  printf("%.8f %.8f\n",t.x,t.y);  
  koch(n-1,t,b);  
}

int main(){
  Point a,b;
  int n;
  scanf("%d",&n);
  a.x=0;
  a.y=0;
  b.x=100;
  b.y=0;
  printf("%.8f %.8f\n",a.x,a.y);  
  koch(n,a,b);
  printf("%.8f %.8f\n",b.x,b.y);

  return 0;
}

Measured memory_bytes: 640
import java.util.ArrayDeque;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		// long cur = System.currentTimeMillis();
		solver();
		// System.out.println(System.currentTimeMillis() - cur + "ms");
	}

	int N;

	@SuppressWarnings("rawtypes")
	void solver() {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		ans = N - 1;
		int[] A = new int[N];
		for (int i = 0; i < N; i++) {
			A[i] = sc.nextInt() - 1;
		}
		pow10[0] = 1;
		for (int i = 1; i <= 10; i++) {
			pow10[i] = 10L * pow10[i - 1];
		}
		factorial[0] = 1;
		for (int i = 1; i <= 10; i++) {
			factorial[i] = factorial[i - 1] * (long) i;
		}
		memo = new int[(int) factorial[N]];
		Arrays.fill(memo, -1);
		enumerate(A);
		Arrays.sort(A);
		second = true;
		enumerate(A);
		System.out.println(ans);
	}

	int ans;
	boolean second = false;

	long[] pow10 = new long[11];
	int[] memo;
	long[] factorial = new long[11];

	ArrayList<Long> enumerate(int[] A) {
		long a = to_long(A);
		ArrayDeque<Long> cur_que = new ArrayDeque<>();
		cur_que.add(a);
		ArrayDeque<Long> next_que = new ArrayDeque<>();
		ArrayList<Long> ret = new ArrayList<>();
		ret.add(a);
		int index = numbering(to_array(a));
		if (memo[index] != -1) {
			ans = Math.min(memo[index], ans);
		}

		memo[index] = 0 + (second ? 10 : 0);
		for (int i = 1; i <= N / 2 - ((N % 2 == 0) ? 1 : 0); i++) {
			while (!cur_que.isEmpty()) {
				long cur = cur_que.poll();
				for (int j = 0; j < N; j++) {
					for (int k = j + 1; k < N; k++) {
						int[] tmp = to_array(cur);
						int s = j, t = k;
						while (s < t) {
							int dummy = tmp[s];
							tmp[s] = tmp[t];
							tmp[t] = dummy;
							s++;
							t--;
						}
						long dummy = to_long(tmp);
						int idx = numbering(tmp);
						if (memo[idx] == -1) {
							next_que.add(dummy);
							memo[idx] = i + (second ? 100 : 0);
						} else if (memo[idx] < 100 && second) {
							ans = Math.min(memo[idx] + i, ans);
						}
					}
				}
			}
			ret.addAll(next_que);
			cur_que.addAll(next_que);
			next_que.clear();
		}
		return ret;
	}

	int numbering(int[] permutation) {
		int ret = 0;
		for (int i = 0; i < permutation.length; i++) {
			int count = 0;
			for (int j = i - 1; j >= 0; j--) {
				if (permutation[i] > permutation[j])
					count++;
			}
			ret += factorial[i] * count;
		}
		return ret;
	}

	long to_long(int[] array) {
		long ret = 0;
		for (int i = 0; i < array.length; i++) {
			ret += pow10[array.length - 1 - i] * array[i];
		}
		return ret;
	}

	int[] to_array(long a) {
		int[] ret = new int[N];
		int pos = N - 1;
		while (a > 0) {
			ret[pos--] = (int) (a % 10);
			a /= 10;
		}
		return ret;
	}

	void tr(Object... o) {
		System.out.println(Arrays.deepToString(o));
	}
}

Measured memory_bytes: 119752
# coding: utf-8

dish = [int(input().rstrip()) for i in range(5)]


def get_ans(flag: int, current: int):
    if (1 << 5) - 1 == flag:
        return current

    tmp = current
    if current % 10 != 0:
        tmp += 10 - (current % 10)

    ans = 2000
    for i in range(5):
        key = 1 << i
        if (flag & key) != 0:
            continue
        ret = get_ans(flag + key, tmp + dish[i])
        ans = min(ans, ret)
    return ans


print(get_ans(0, 0))


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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

using namespace std;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i <= b; i++)
#define revrep(i, s) for (int i = s-1; i > 0; i--)
#define revrrep(i, s) for (int i = s-1; i >= 0; i--)
#define all(a)  begin((a)),end((a))
#define uniq(c) (c).erase(unique(all((c))), end((c)))

bool check(vector<int> arr_a, vector<int> arr_b)
{
    rep (i, 0, arr_a.size()) {
        if (arr_a[i] != arr_b[i]) return false;
    }
    return true;
}

int main()
{
    int N; cin >> N;
    vector<int> P(N), Q(N);
    rep (i, 0, N) cin >> P[i];
    rep (i, 0, N) cin >> Q[i];

    vector<int> nums(N);
    iota(nums.begin(), nums.end(), 1);
    int cnt = 0, a = 0 , b = 0;
    do {
        ++cnt;
        if (check(P, nums)) a = cnt;
        if (check(Q, nums)) b = cnt;
        if (a != 0 and b != 0) break;
    } while (next_permutation(nums.begin(), nums.end()));

    cout << abs(a - b) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    Scanner sc = new Scanner(System.in);

    public static void main(String[] arg){
        Main m = new Main();
        m.run();
    }

    void run(){
        long n = sc.nextLong();
        long a = sc.nextLong();
        long b = sc.nextLong();

        long div = n/(a+b);
        long mod = n%(a+b);

        System.out.println( (div * a) + Math.min(mod,a));
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <utility>
#include <map>
#include <vector>
using namespace std;
typedef long long ll;
pair<ll,ll> p[60];
map<pair<ll,ll>,int> mp;
vector<pair<ll,ll>> v;
bool used[50];
int n;
int solve(ll a, ll b){
	int i,j,num = 0;
	bool used[60];
	for(i=0;i<n;i++) used[i] = false;
	for(i=0;i<n;i++){
		if(used[i]) continue;
		for(j=0;j<n;j++){
			if(j==i) continue;
			if(p[i].first - p[j].first==a && p[i].second - p[j].second==b){
				num++;
				used[i] = true;
			}
		}
	}
	return num;
}
int main(){
	int i,j,mx = 60;
	cin >> n;
	if(n==1){
		cout << 1 << endl;
		return 0;
	}
	for(i=0;i<n;i++){
		ll a,b; cin >> a >> b;
		p[i] = {a,b};
	}
	for(i=0;i<n;i++){
		for(j=0;j<n;j++){
			if(j==i) continue;
			ll a = p[i].first - p[j].first,c = p[i].second - p[j].second;
			v.push_back({a,c});
		}
	}
	for(i=0;i<v.size();i++){
		mx = min(mx,n - solve(v[i].first,v[i].second));
	}
	cout << mx << endl;
}

Measured memory_bytes: 384
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
double j,a,b,h,m,sz,fz,ans,s;
main()
{
	cin>>a>>b>>h>>m;
	sz=(h*60+m)*0.5;
	fz=m*6;
	if(sz>fz)j=sz-fz;
	else j=fz-sz;
	if(j>180)j=360-j;
	ans=sqrt(a*a+b*b-2*cos(j*M_PI/180)*a*b);
	printf("%0.20f",ans);
	return 0;
}

Measured memory_bytes: 4292
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> PLL;
typedef vector<int> VI;
typedef vector<char> VC;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<ll> VLL;
typedef vector<PLL> VP;
const static int INF = 1000000000;
const static int MOD = 1000000007;
const int dx[4]={1, 0, -1, 0};
const int dy[4]={0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define rept(i,m,n) for(ll i=m; i<n; i++)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back
#define SORT(V) sort((V).begin(), (V).end())
#define RVERSE(V) reverse((V).begin(), (V).end())
#define paired make_pair
#define PRINT(V) for(auto v : (V)) cout << v << " "
//charを整数に
int ctoi(char c) { if (c >= '0' && c <= '9') { return c - '0'; } return 0; }
// 累積和 for (int i = 0; i < N; ++i) s[i+1] = s[i] + a[i]; 
void cum_sum(int N,vector<double> a, vector<double> &s){ for(int i=0; i<N; i++){ s[i+1]=s[i]+a[i];}}
//ユークリッドの控除法
ll gcd(ll a,ll b){
    if(b == 0) return a;
    return gcd(b,a%b);
}
//最小公倍数
ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}
//素数判定
bool is_prime(long long n) {
    if (n <= 1) return false;
    for (long long p = 2; p * p <= n; ++p) {
        if (n % p == 0) return false;
    }
    return true;
}
int getdigit(ll num){
    unsigned digit=0;
    while(num!=0){
        num /= 10;
        digit++;
    }
    return digit;
}
//空白文字も入力 getline(cin, S);
//桁数指定 setprecision
void rec(int d, ll val, VLL &all){
    all.PB(val);
    if(d==10) return;
    for(int j=-1; j<=1; j++){
        int add=(val%10)+j;
        if(add>=0 && add<=9) rec(d+1, val*10+add, all);
    }
}
int main()
{
    ios::sync_with_stdio(0); 
    cin.tie(0); 
    cout.tie(0);
    int K;
    cin >> K;
    VLL all;
    for(int i=1; i<10; i++) rec(1,i,all);
    sort(all.begin(), all.end());
    cout << all[K-1] << endl;
}

Measured memory_bytes: 5312
import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }

void main() {
  auto st = readln.split.to!(string[]);

  void solve() {
    writeln(st[1] ~ st[0]);
  }

  solve();
}


Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d", $n);
for($i = 1; $i <= $n; $i++){
    $p[$i] = [];
    $c[$i] = 0;
    $answer[$i] = false;
}
for($i = 0; $i < $n-1; $i++){
    fscanf(STDIN, "%d%d", $a, $b);
    //接続先の配列を作る
    $p[$a][] = $b;
    $p[$b][] = $a;
    //接続数の配列を作る
    $c[$a]++;
    $c[$b]++;
}
$numArray = explode(" ", trim(fgets(STDIN)));
sort($numArray);
$maxC = max($c);
for($i = 1; $i <= $n; $i++){
    if($maxC == $c[$i]){
        $maxCpos = $i;
    }
}
$max = max($numArray);
echo (dfs($maxCpos)-$max)."\n";
echo implode(" ", $answer);

function dfs($current){
    global $p, $c, $answer, $numArray;
    $sum = 0;
    if($answer[$current] === false){
        $answer[$current] = array_pop($numArray);
        $sum+=$answer[$current];
        foreach($p[$current] as $to){
            $sum+=dfs($to);
        }
    }
    return $sum;
}


Measured memory_bytes: 12792
#include<bits/stdc++.h>
using namespace std;
long long n,k,t,u,v,l,d[210],a,p;

int main(){
  cin>>n>>k>>t>>u>>v>>l;
  for(int i=1;i<=n;i++)cin>>d[i];
  d[n+1]=l;
  for(int i=1;i<=n+1;i++){
    if(a>d[i]-d[i-1]){
      a-=d[i]-d[i-1];
      a=min(a+v*t,v*t*(k+1));
    }
    else p+=d[i]-d[i-1]-a,a=v*t;
  }
  printf("%.10f\n",1.0*p/u+1.0*(l-p)/v);
  return 0;
}

Measured memory_bytes: 1196
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
What do you think? What do you think?
1st on Billboard, what do you think of it
Next is a Grammy, what do you think of it
However you think, I’m sorry, but shit, I have no fucking interest
*******************************
Higher, higher, even higher, to the point you won’t even be able to see me
https://www.a2oj.com/Ladder16.html
*******************************
NEVER DO 300IQ CONTESTS EVER
300IQ AS WRITER = EXTRA NONO
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class Main
   {
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         StringTokenizer st = new StringTokenizer(infile.readLine());
         int A = Integer.parseInt(st.nextToken());
         int B = Integer.parseInt(st.nextToken());
         int C = Integer.parseInt(st.nextToken());
         int D = Integer.parseInt(st.nextToken());
         int K = Integer.parseInt(st.nextToken());
         int res = 60*(C-A);
         if(B > D)
            res -= (B-D);
         else
            res += (D-B);
         System.out.println(res-K);
      }
   }

Measured memory_bytes: 32504
(defun main ()
  (let ((s (read-line))
	(t1 (read-line))
	(ans 0))
    (loop
       :for char1 :across s
       :for char2 :across t1
       :unless (equal char1 char2)
       :do (incf ans))
    ans))

(format t "~a~%" (main))


Measured memory_bytes: 29652
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int r,g,b,n,ans=0;
    cin>>r>>g>>b>>n;
    for(int i=0;i<=n/r+1;i++){
        for(int j=0;j<=n/g+1;j++){
            int x=i*r,y=j*g;
            if(n-x-y<0) break;
            if((n-x-y)%b==0)    ans++;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define MOD 1000000007
#define M 1000005
using namespace std;

ll n, x, y, ans, dp[M][5];
vector<ll> adj[M];

void dfs(ll u, ll p, ll c){
    if (adj[u].size() == 1 && u != 1){
        dp[u][c] = 1;
        return;
    }
    if (dp[u][c] > 0) return;
    else {
        ll res = 1;
        for (ll v : adj[u]){
            if (v == p) continue;
            ll cnt = 0;
            dfs(v, u, 0);
            (cnt += dp[v][0]) %= MOD;
            if (c == 0){
                dfs(v, u, 1);
                (cnt += dp[v][1]) %= MOD;
            }
            (res *= cnt) %= MOD;
        }
        dp[u][c] = res;
        return;
    }
}

int main(){
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n;
    if (n == 1){
        cout << 2;
        return 0;
    }
    for (int i = 0; i < n - 1; i++){
        cin >> x >> y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    dfs(1, 0, 0);
    dfs(1, 0, 1);
    cout << (dp[1][0] + dp[1][1]) % MOD;
    return 0;
}

Measured memory_bytes: 40448
n,k=map(int,input().split())
h=list(map(int,input().split()))

dp=[float('inf')]*n

dp[0]=0

for i in range(1,n):
	for j in range(1,k+1):
		if j>i:break
		dp[i]=min(dp[i-j]+abs(h[i]-h[i-j]),dp[i])
print(dp[-1])

Measured memory_bytes: 55136
import sys
import fractions

input = sys.stdin.readline


def main():
    N = int(input())
    s = [int(input()) for i in range(5)]

    m = fractions.math.ceil(N/min(s))
    if m == 1:
        print(5)
    else:
        print(m+4)


if __name__ == "__main__":
    main()


Measured memory_bytes: 64492
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;
ll MOD = 1000000007;

// a^p
// 2^3 = 2 * 2^2
// 2^2 = 2 * (2^1)
// 2^1 = 2
ll modpow(ll a, ll p, ll mod) {
  if (p == 0) return 1;

  if (p % 2 == 0) {
    ll half = modpow(a, p / 2, mod) % mod;
    return half * half % mod;
  } else {
    return a * modpow(a, p - 1, mod) % mod;
  }
}

// nCa を求める
ll modCombination(ll n, ll a, ll mod) {
  if (n - a < a) {
    return modCombination(n, n - a, mod);
  }

  ll denominator = 1;  // 分母
  ll numerator = 1;    // 分子

  for (ll i = 0; i < a; i++) {
    denominator *= a - i;
    numerator *= n - i;
    denominator %= mod;
    numerator %= mod;
  }

  return numerator * modpow(denominator, mod - 2, mod) % mod;
}

void dfs(vector<vector<ll>> &edges, vector<ll> &counter, vector<bool> &visited, ll parentCounter, ll current) {
  visited[current] = true;
  counter[current] += parentCounter;

  for (auto v : edges[current]) {
    if (v == false) continue;
    if (visited[v] == true) continue;

    dfs(edges, counter, visited, counter[current], v);
  }
}

int main() {
  ll N, Q;
  cin >> N >> Q;
  vector<vector<ll>> edges(N);

  for (ll i = 0; i < N - 1; i++) {
    ll a, b;
    cin >> a >> b;
    edges[a-1].push_back(b-1);
    edges[b-1].push_back(a-1);
  }

  vector<ll> counter(N, 0);
  for (ll i = 0; i < Q; i++) {
    ll p, x;
    cin >> p >> x;
    counter[p-1] += x;
  }

  vector<bool> visited(N, false);
  dfs(edges, counter, visited, 0, 0);

  for (auto p : counter) {
    cout << p << " ";
  }
  cout << endl;

  return 0;
}


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

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int n = Integer.parseInt(str[0]);
    int k = Integer.parseInt(str[1]);
    int cnt = 1;
    for(; n/k>0 ;){
      n = n/k;
      cnt += 1;
    }
    System.out.println(cnt);
  }
}

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


Measured memory_bytes: 2108
#include<stdio.h>
#define N 500000

int A[N],n;
void maxHeapify(i) {
  
  int left,right,largest,tmp;
  
  left = 2*i;
  right = 2*i+1;
  
 
    
    if(left <= n && (A[left] > A[i]))
      largest = left;
    else largest = i;
    
    if(right <= n && (A[right] > A[largest]))
      largest = right;
    
    if(largest != i) {
      
      tmp = A[i];
      A[i] = A[largest];
      A[largest] = tmp;
      
      maxHeapify(largest);
    
  }
}

void buildMaxHeap(int A[]) {

  int i;

  for(i=n/2;i>=1;i--)
    maxHeapify(i);

}

int main(void) {
  
  int i;
  scanf("%d",&n);
  
  for(i=1;i<=n;i++) 
    scanf("%d",&A[i]);
  
  for(i=n/2;i>=1;i--) 
    maxHeapify(i);
  
  for(i=1;i<=n;i++)
    printf(" %d",A[i]);
  printf("\n");
  return 0;
}
 

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

int main() {
    int i,j,k,l,M,N,H,W,a,b,c,d,x,temp ;
  	long long lng;
    string str,ans;
    cin >> N >> M;
	lng = M*pow(M-1,N-1);
 
  	cout << lng << endl;
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main(void){
  char s[50],sc[50];
  int sa,n,k;
  scanf("%d %d",&n,&k);
  scanf("%s",s);
  sa='A'-'a';
  for(int i=0;i<n;i++){
    if(i==k-1){
      sc[i]=s[i]-sa;
    }
    else{
      sc[i]=s[i];
    }
  }
  sc[n]='\0';
  printf("%s",sc);
}

Measured memory_bytes: 128
from functools import reduce
import math

n = int(input())

def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

numlis = [int(a) for a in input().split()]
print(lcm_list(numlis))


Measured memory_bytes: 6336
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> PII;


// chmax, chmin
template <class T>
inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T>
inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}

template <typename T>
function<T(T, T)> op_max = [](T a, T b) -> T { return max(a, b); };
template <typename T>
function<T(T, T)> op_min = [](T a, T b) -> T { return min(a, b); };

template <typename T>
function<T(T, T)> op_sum = [](T a, T b) -> T { return a + b; };

namespace detail {
template <typename T, std::size_t NDIMS>
struct vector_builder {
  using type = std::vector<typename vector_builder<T, NDIMS - 1>::type>;

  static type make(std::vector<std::size_t> dims, const T& v = {}) {
    const auto vec = std::vector<T>(dims.empty() ? 0 : dims.back(), v);
    if (!dims.empty()) dims.pop_back();
    return vector_builder<std::vector<T>, NDIMS - 1>::make(dims, vec);
  }
};

template <typename T>
struct vector_builder<T, 1> {
  using type = std::vector<T>;

  static type make(std::vector<std::size_t> dims, const T& v = {}) {
    return type(dims.empty() ? 0 : dims.back(), v);
  }
};
}  // namespace detail

template <typename T, typename... SIZE_T>
auto exvector(const T& v, SIZE_T... dims) {
  static_assert(sizeof...(dims) != 0, "invalid dimension");
  std::vector<std::size_t> vec_dims{dims...};
  return detail::vector_builder<T, sizeof...(dims)>::make(vec_dims, v);
}

using namespace std;
//********************  dumps ************************//

template <typename T>
void dump(const T& data, vector<int>& iter) {
  cout << data << " ";
}
template <typename T>
void dump(const vector<T>& data, vector<int>& iter) {
  for (auto elem : data) dump(elem, iter);
  cout << endl;
}

template <typename T>
void dump(const vector<vector<T>>& data, vector<int>& iter) {
  for (auto elem : iter) {
    cout << "[" << elem << "]";
  }
  cout << endl;
  for (int i = 0; i < data.size(); i++) {
    iter.push_back(i);
    dump(data[i], iter);
    iter.pop_back();
  }
  cout << endl;
}

template <typename T>
void dump(const vector<T>& data, int dummy) {
  for (int i = 0; i < data.size(); i++) {
    cout << "[" << i << "] " << data[i] << endl;
  }
}
template <typename T>
void dump(const T& data) {  // T : data, U = base type val.
  vector<int> iter;
  dump(data, iter);
}
///////////////////////////////////////////////


void solve(long long A, long long B, long long C, long long D, long long E){
  vector<LL> vals = {A,B,C,D,E};
  int ret = 0;
  int nega = 0;
  for(auto val: vals) {
    ret += val;
    if(val%10 > 0) {
      ret += 10  - (val % 10);
      chmax(nega, 10 - (int)(val % 10));
    }
  }
  cout << ret - nega <<endl;
}

int main(){ 
    cout << setprecision(10);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    long long D;
    scanf("%lld",&D);
    long long E;
    scanf("%lld",&E);
    solve(A, B, C, D, E);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <algorithm>

using namespace std;

int h [2000000], d[2000000];
int main() {
	int n; cin>>n;
	for(int i=0; i<n; i++) cin>>h[i];

	d[0]=0;
	d[1]=abs(h[1]-h[0]);
	
	for(int i=2; i<n; i++) {
		d[i]=min(abs(h[i-1]-h[i])+d[i-1], abs(h[i-2]-h[i])+d[i-2]);
		
	}
	printf("%i\n", d[n-1]);
}


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

int main()
{
	int n, l;
	cin >> n >> l;
	vector<string> s(n);
	for (int i = 0; i <= n - 1; i++)
	{
		cin >> s[i];
	}

	sort(s.begin(), s.end());

	for (int i = 0; i <= n - 1; i++)
		cout << s[i];

	//system("pause");
}

Measured memory_bytes: 256
//              _      _                 
//             (_)    | |                
//    _ __ ___  _  ___| |__   __ _  ___  
//   | '_ ` _ \| |/ __| '_ \ / _` |/ _ \ 
//   | | | | | | | (__| | | | (_| | (_) |
//   |_| |_| |_|_|\___|_| |_|\__,_|\___/ 
//                                       
// 
#include <bits/stdc++.h>
#define int long long
#define mp make_pair
#define pb push_back
#define ld long double
#define pii pair<int,int>
#define sz(x) (int)x.size()
#define piii pair<pii,pii>
#define precise cout<<fixed<<setprecision(10)
#define st first
#define nd second
#define ins insert
#define vi vector<int>
#define BOOST ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
/*#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
using namespace std;
map<int,int>cnt;
const int MAX=1e5+5;
int ans=0;
int32_t main()
{
  BOOST;
 	int n;
 	cin>>n;
 	for (int i=1;i<=n;i++)
 	{
 		int a;
 		cin>>a;
 		cnt[a]++;
 		ans+=a;
 	}
 	
 	int q;
 	cin>>q;
 	for (int z=0;z<q;z++)
 	{
 		int a,b;
 		cin>>a>>b;
 		cnt[b]+=cnt[a];
 		ans+=(b-a)*cnt[a];
 		cnt.erase(a);
 		cout<<ans<<"\n";
 	}
  return 0;
}


Measured memory_bytes: 7572
const Debug = function () {
    const stdin = function (text) {

    };

    return stdin;
};


const Release = function () {
    const fs = require('fs');
    const stdin = function (text) {
        if (text) console.log(text);
        return fs.readFileSync('/dev/stdin', 'utf8');
    }
    return stdin;
};


const debug = false;

const stdin = debug ? Debug() : Release();
const input = stdin().split('\n').map(x => parseInt(x));

const A = input[0];
const B = input[1];
const C = input[2];
const X = input[3];

var z = [];
for (var i = 0; i <= Math.floor(X / 500); i++) {
    var _a = X - i * 500;

    for (var j = 0; j <= Math.floor(_a / 100); j++) {
        var _b = _a - j * 100;
        var _c = _b / 50;
        z.push({ a: i, b: j, c: _c });

    }
}

console.log(z.filter(x => x.a <= A && x.b <= B && x.c <= C).length);


Measured memory_bytes: 7628
import sys

S = input()
S1 = ''
S2 = ''
if S == S[::-1]:
    S1 = S[0:(len(S) - 1) // 2]
    if S1 == S1[::-1]:
        S2 = S[(len(S) + 3) // 2 - 1:]
        if S2 == S2[::-1]:
            print('Yes')
            sys.exit()
print('No')

Measured memory_bytes: 3060
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.OutputStream;
import java.util.StringTokenizer;
import java.io.Writer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class TaskD {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int H = in.nextInt(), W = in.nextInt(), D = in.nextInt();
            int[][] a = in.nextInt2dArray(H, W);
            int[][] b = new int[H * W + 1][];
            for (int i = 0; i < H; i++) {
                for (int j = 0; j < W; j++) {
                    b[a[i][j]] = new int[]{i, j};
                }
            }
            long[] d = new long[H * W + 1];
            for (int i = D + 1; i <= H * W; i++) {
                d[i] = d[i - D] + Math.abs(b[i][0] - b[i - D][0]) + Math.abs(b[i][1] - b[i - D][1]);
            }
            int Q = in.nextInt();
            while (Q-- > 0) {
                int L = in.nextInt(), R = in.nextInt();
                out.println(d[R] - d[L]);
            }
        }

    }

    static class OutputWriter extends PrintWriter {
        public OutputWriter(OutputStream out) {
            super(out);
        }

        public OutputWriter(Writer out) {
            super(out);
        }

        public void close() {
            super.close();
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public int[][] nextInt2dArray(int n, int m) {
            int[][] a = new int[n][m];
            for (int i = 0; i < n; i++) {
                for (int j = 0; j < m; j++) {
                    a[i][j] = nextInt();
                }
            }
            return a;
        }

    }
}



Measured memory_bytes: 51348
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;

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

void YN(bool ans){
    if(ans)cout<<"Yes"<<endl;
    else cout <<"No"<<endl;
    return;
}

int main(){
    double R;
    cin>>R;
    cout<<fixed<<setprecision(10)<<3.141592*R*2;
    return 0;
}

Measured memory_bytes: 3788
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

s64 update_score(const set<int>& last, int day, int prev, int c, int max_d)
{
    s64 ret = 0;
    auto itr = last.upper_bound(day);
    int l, r;
    if (itr == last.end())
    {
        r = max_d + 1;
        l = *--itr;
    }
    else
    {
        r = *itr;
        l = *--itr;
    }
    ret += (s64)(prev - l) * (r - day);

    return c * ret;
}

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

    const int DAY = 365;
    const int NUM = 26;
    int d;
    cin >> d;
    int c[NUM];
    rep (i, NUM)
    {
        cin >> c[i];
        c[i] = -c[i];
    }

    int s[DAY][NUM];
    rep (i, d) rep (j, NUM) cin >> s[i][j];

    set<int> last[NUM];
    rep (i, NUM) last[i].insert(0);

    int t[DAY];
    rep (i, d)
    {
        cin >> t[i];
        --t[i];
    }

    s64 v = 0;
    rep (i, d)
    {
        v += s[i][t[i]];
        last[t[i]].insert(i + 1);
        rep (j, NUM)
        {
            v += c[j] * ((i + 1) - *last[j].rbegin());
        }
    }

    int m;
    cin >> m;

    s64 ans[m];
    rep (ii, m)
    {
        int dd, q;
        cin >> dd >> q;
        --q;
        int p = t[dd - 1];
        t[dd - 1] = q;
        v += s[dd - 1][q] - s[dd - 1][p];

        last[p].erase(dd);
        last[q].insert(dd);
        auto itr = last[q].lower_bound(dd);
        int prevq = *--itr;

        v += update_score(last[p], dd, dd, c[p], d);
        v += update_score(last[q], dd, prevq, c[q], d);
        ans[ii] = v;
    }

    rep (i, m)
    {
        cout << ans[i] << "\n";
    }

    return 0;
}



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


int main(int argc, char *argv[]) {
    int n, k;
    int l[50];

    scanf("%d%d", &n, &k);
    for (int i = 0; i < n; i++) {
        scanf("%d", &l[i]);
    }

    for (int j = 0; j < n - 1; j++) {
        for (int i = 0; i < n - 1; i++) {
            int tmp;
            if (l[i] < l[i + 1]) {
                tmp = l[i];
                l[i] = l[i + 1];
                l[i + 1] = tmp;
            }
        }
    }

    for (int i = 0; i < n; i++) {
//        printf("%d\n", l[i]);
    }


    int sum = 0;
    for (int i = 0; i < k; i++) {
        sum += l[i];
    }

    printf("%d\n", sum);

    return 0;
}


Measured memory_bytes: 128
#include <stdio.h>

int binarysearch(int);
int array[100000],num1;
int main(){
  int i,num2,key,count=0;
  scanf("%d",&num1);
  for(i=0;i<num1;i++) scanf("%d",&array[i]);

  scanf("%d",&num2);
  for(i=0;i<num2;i++){
    scanf("%d",&key);
    if(binarysearch(key)==1) count++;
  }
  printf("%d\n",count);
  return 0;
}

int binarysearch(int key){
  int left=0,right=num1,mid;

  while(left<right){
    mid=(left+right)/2;
    if(key==array[mid]) return 1; /* found key */
    if(key>array[mid]) left=mid+1;
    else if(key<array[mid]) right=mid;
  }
  return 0;
}



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

using ll =  long long;
using pint =  pair<int,int>;

#define INF 99999999
#define rep(i,n) for(int (i)=0,temp=(int)(n);(i)<temp;++(i)) 
#define repi(i,start,end) for(int (i)=(start),temp=(int)(end);i<(end);++(i))
#define rfor(v,x) for(const auto& (x) : (v)) //xは値を表す
#define all(x) (x).begin(),(x).end()
#define SORT(v, n) sort((v), (v)+(n))
#define vsort(v) sort((v).begin(), (v).end())
#define vfsort(v,lambda) sort(all((v)),(lambda))
#define vint vector<int>
#define vvint vector<vector<int>> //vvint v(n,vint(n))のように宣言できる
#define vin(v) rep(i,(v).size()) {cin >> (v)[i];}
//最終奥義(使うときはINFも書き換えろ!!)
#define int long long
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int ctoi(char c) {return c-'0';}
//lambda式 -> [&](int x, int y){return x<y;}
//vector内の重複を削除-> v.erase(unique(all(v)),v.end());

int pairs[200005];



int calc(int n){
  string num=to_string(n);
  int digit=num.length();
  int d = num[0]-num.back();

  if(num.back()=='0')return 0;
  if(digit==2){
    if(d==0)return 3;
    else if(d>0)return 2;
    return 0;
  }

  
  int res=0;
  if(d<0){
      rep(i,digit-2)res+=2*(pow(10,i));
  }else if(d>0){
    rep(i,digit-1)res+=2*(pow(10,i));
  }else{
    res+=2;
    rep(i,digit-2)res+=2*(pow(10,i));
    string mid=num.substr(1,digit-2);
    int m=stoi(mid);
    res+=2*m+1;
  }
  return res;
}

void solve(int n){
  if(n<10) pairs[n-1]=n;
  else pairs[n-1]=pairs[n-2]+calc(n);
}

signed main(void){
  int n;cin >> n;
  rep(i,n)solve(i+1);
  cout << pairs[n-1] << endl;
  //rep(i,n)cerr << i+1 << ": " << pairs[i] << endl;
  //repi(i,1,n)cerr << i+1 << ":" << pairs[i]-pairs[i-1]<<endl;
  //cerr << calc(2012) << endl;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    scanf("%d",&n);
    int a,ans=1<<28;
    for(int i=0;i<n;++i){
        scanf("%d",&a);
        int cnt=0;
        while(a%2==0){
            cnt++;
            a/=2;
        }
        ans=min(ans,cnt);
    }
    printf("%d\n",ans);
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
#define m_p make_pair
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    ll a,b;
    cin >> a >> b;
    cout << (a+b)%24 << endl;
    return 0;
}

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

int main() {
  while (true) {
    int n, x;
    cin >> n >> x;
    if (n == 0 && x == 0) break;
    int cnt = 0;
    for (int i = 1; i <= n - 2; i++) {
      for (int j = i + 1; j <= n - 1; j++) {
        if (x - i - j <= n && x - i - j >= 1 && i < j && j < x - i - j) {
          cnt++;
        }
      }
    }
    cout << cnt << endl;
  }
  return 0;
}



Measured memory_bytes: 3072
a,b,c,d = 4.times.map { gets.to_i }
cnt = 0
(0..a).each do |i|
  (0..b).each do |j|
    (0..c).each do |k|
      cnt += 1 if i * 500 + j * 100 + k * 50 == d
    end
  end
end

puts cnt

Measured memory_bytes: 1788
n,q = (int(x) for x in input().split())
s = input()
prefix = [0]
for i in range(n-1):
    if s[i] == 'A' and s[i+1] == 'C':
	    prefix.append(prefix[-1]+1)
    else:
        prefix.append(prefix[-1])
for _ in range(q):
    l, r = (int(x) for x in input().split())
    print(prefix[r-1] - prefix[l-1])


Measured memory_bytes: 6100
#include<bits/stdc++.h>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<stack>
#include<queue>
#define endl  "\n"
#define ll long long
#define int long long
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cin.exceptions(cin.failbit);cout.tie(NULL);
using namespace std;
bool isPrime(int n)
{
    if (n <= 1)
        return false;
    if (n <= 3)
        return true;
    if (n % 2 == 0 || n % 3 == 0)
        return false;
    for (int i = 5; i * i <= n; i += 6)
    {
        if ((n % i == 0) || (n % (i + 2) == 0))
            return false;
    }
    return true;
}

int32_t main()
{
	int t=1;
	while(t--)
	{
		int n;
		cin >> n;
		int a[n];
		for(int i=0;i<n;i++)
		{
			cin >> a[i];
		}
		sort(a,a+n);
		int cnt=0;
		
		for(int i=0;i<n;i++)
		{
			for(int j=i+1;j<n;j++)
			{
				for(int k=j+1;k<n;k++)
				{
					int x=a[i];
					int y=a[j];
					int z=a[k];
					
					if(x!=y && x!=z && y!=z)
					{
						if(x+y>z && y+z>x && x+z>y)
						cnt++;
					}
				}
			}
		}
		cout << cnt;
	}
}




Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
using namespace std;
typedef signed long long int ll;

int main(){
  ll a,b,c;
  cin>>a>>b>>c;
  //    cout<<a<<b<<c<<endl;
  /*if(c-a-b<0){
    cout<<"No"<<endl;
  }*/
 //     cout<<4*a*b<<endl;
 //     cout<<(c-a-b)*(c-a-b)<<endl;
  ll d=4;
  d*=a;
  d*=b;
  ll e=c-a-b;
  if(e<0){
    cout<<"No"<<endl;
    return 0;
  }
  e*=e;
  
  if(d<e){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}


Measured memory_bytes: 256