akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#define INF 10000
#define BalMax 3
#define debug 0

int DP[3][41];
int n,p[40],t[40];
char JDG[3]="aa";


void initDP(void){
  int i,j;
  for(i=0;i<3;i++){
    for(j=0;j<41;j++){
      DP[i][j]= INF;
    }
  }
}

int minimum(int a, int b){
  if(a<b)return a;
  else   return b;
}


int calc1(int num){
  int min;
  int dt,dx;
  int A,B,C;
  dt = t[num] - t[num-1];
  dx = p[num] + p[num-1];

  if(p[num]+4*p[num-1] > dt){
    A = INF;
  }
  else{
    A = DP[2][num-1] + dx;
  }

  if(p[num]+p[num-1]*3 > dt){
    B = INF;
  }  
  else{
    B = DP[1][num-1] + dx;
  }

  if(p[num]+p[num-1]*2 > dt){
    C = INF;
  }
  else{
    C = DP[0][num-1] + dx;
  }

  return minimum(A ,minimum(B ,C) );

}

int calc2(int bal, int num){
  int dt,dx; 
  
  dt = t[num] - t[num-1];//Ô·
  dx = abs(p[num] - p[num-1]);//£

  if(dx*(bal+1) > dt){//æêÈ¢
    return INF;
  }
  else{
    return DP[bal-1][num-1]+dx;
  }
}


int val(int bal, int num){
  int k;
  switch(bal){
  case 0://¨¢Ä©çÆèÉ¢­
    k = calc1(num);
    break;
  case 1://1±ÁÄéóÔ©ç»ÌÜÜæèÉ¢­
    k = calc2(bal,num);
    break; 
  case 2://2±ÁÄéóÔ©ç»ÌÜÜæèÉ¢­
    k = calc2(bal,num);
    break;
  }
  return k;
}

int solve(void){
  int i,j,min;
  if(p[0]>t[0]){//1ÂÚªÆêÈ¢ê
    strcpy(JDG,"NG");
    return 0+1;
  }
  else{         //êÂÚÍæêéê
    //úð
    DP[0][0]=p[0];
    min = p[0];

    for(j=1;j<n;j++){
      min = INF;
      for(i=0;i<BalMax;i++){
	DP[i][j] = val(i,j);//æéOÌÂi,ÉæéDÌjÔ
	if(DP[i][j]<min){
	  min = DP[i][j];
	}
      }
      if(min >= INF){//ÆêÈ©Á½
	strcpy(JDG,"NG");
	break;
      }
    }
    
    if(j==n){//Sæê½êifor[vðbreakÅ²¯È¢j
      strcpy(JDG,"OK");
      return min+p[n-1];
    }else{
      return j+1;
    }
  }
}

int main(void)
{
  int i,j,x;

  while(1){
    //t@CÇÝÝ
    scanf(" %d ", &n);
    if(n == 0)break;
    for(i=0;i<n;i++){
      scanf("%d %d",&p[i],&t[i]);
    }    
    //ú»
    initDP();

    if(debug){//fobOpoÍ
      printf("n=%d\n",n);
      for(i=0;i<n;i++){
	printf("p[%d]=%d,t[%d]=%d\n",i,p[i],i,t[i]);
      }
      putchar('\n');
      
    }
    
    x=solve();
    
    if(debug){ //fobOpoÍ
      printf("DP\n");
      for(j=0;j<3;j++){
	for(i=0;i<n;i++){
	  printf("%d ",DP[j][i]);
	}
	putchar('\n');
      }	
    }
    //¦ÌoÍ
    printf("%s %d\n",JDG ,x);
  }
    
  
  //fclose(fp);
  return 0;
}

Measured memory_bytes: 0
num500 = int(input())
num100 = int(input())
num50 = int(input())
numSum = int(input())

patternCounter = 0

for count500 in range(num500 +1):
    if numSum < count500 * 500:
        break
    for count100 in range(num100 + 1 ):
        if numSum < ((count500 * 500) + (count100 * 100)):
            break
        for count50 in range(num50 + 1):
            if numSum < ((count500 * 500) + (count100 * 100) + (count50 * 50)):
                break
            elif numSum == ((count500 * 500) + (count100 * 100) + (count50 * 50)):
                patternCounter +=1

print(patternCounter)


Measured memory_bytes: 3064
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

int main(void)
{
    int H, W;
    cin >> H >> W;
    char A[101][101];
    rep(y, H) {
        rep(x, W) {
            cin >> A[y][x];
        }
    }

    string str((W + 2), '#');
    cout << str << endl;
    rep(y, H)
    {
        cout << "#";
        rep(x, W) {
            cout << A[y][x];
        }
        cout << "#" << endl;
    }
    cout << str << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
const ll MOD = 1e9 + 7;
const long long INF = 1LL << 60;

bool is_prime(const unsigned n){
    switch(n) {
        case 0: // fall-through
        case 1: return false;
        case 2: return true;
    } // n > 2 が保証された

    if(n % 2 == 0) return false;

    // 上で i=2 相当は調べたので、i=3から奇数のみ調べる
    for(unsigned i = 3; i * i <= n; i += 2) {
        if(n % i == 0) return false;
    }

    return true;
}


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

    int i = x;
    while (true){
        if(is_prime(i)){
            cout << i << endl;
            break;
        }
        else
        {
            i++;
        }
    }
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cstdio>
#include <string>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>



int main()
{
	int N, M, S;

	scanf("%d%d%d", &N, &M, &S);

	if (N == M) printf("%d\n", S);
	else if (N == S) printf("%d\n", M);
	else if (M == S) printf("%d\n", N);


	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long int
#define pb push_back
#define MAX INT_MAX
#define MIN INT_MIN
#define MOD 1000000007
#define FO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
void solve() {
	int a, b;
	cin >> a >> b;
	int c = 0;
	while(a > 0) {
		a -= b;
		c++;
	}
	cout << c;
    return;
}
int32_t main() {
    FO;
    solve();
    return 0;
}


Measured memory_bytes: 256
// 2013/11/25 Tazoe

#include <iostream>
#include <algorithm>
using namespace std;

const int INF = 1000000000;

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

		if(n==0)
			break;

		int T[10][10];
		for(int i=0; i<10; i++){
			for(int j=0; j<10; j++){
				if(i==j){
					T[i][j] = 0;
				}
				else{
					T[i][j] = INF;
				}
			}
		}

		int m = 0;		// 町の総数

		for(int i=0; i<n; i++){
			int a, b, c;
			cin >> a >> b >> c;

			T[a][b] = T[b][a] = c;

			if(a+1>m){
				m = a+1;
			}
			if(b+1>m){
				m = b+1;
			}
		}

		for(int k=0; k<m; k++){
			for(int i=0; i<m; i++){
				for(int j=0; j<m; j++){
					T[i][j] = min(T[i][j], T[i][k]+T[k][j]);
				}
			}
		}

		int m_min = -1;
		int s_min = INF;

		for(int i=0; i<m; i++){
			int s = 0;

			for(int j=0; j<m; j++){
				s += T[i][j];
			}

			if(s<s_min){
				m_min = i;
				s_min = s;
			}
		}

		cout << m_min << ' ' << s_min << endl;
	}

	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+5;
int H,W,n,x,y,i,mn[N];
int main(){
	scanf("%d%d%d",&H,&W,&n);
	for(i=1;i<=H;++i)mn[i]=1<<30;
	for(i=1;i<=n;++i)scanf("%d%d",&x,&y),mn[x]=min(mn[x],y);
	for(i=2,y=1;i<=H;++i){
		if(y>=mn[i])break;
		y+=y+1<mn[i];
	}
	printf("%d\n",i-1);
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception{
		
		Scanner sc = new Scanner(System.in);
		
		String s = sc.nextLine();
		int len = s.length();

		for(int i=0; i<len; i++){
			String a = s.substring(i, i+1);
			int n = 1;
			int an = 1;
			for(int j=i+1; j<len; j++){
				if((s.substring(j, j+1)).equals(a)){
					an++;
					n++;
					if(an > n/2){
						System.out.println(i+1 + " " + (j+1));
						return ;
					}
				}else{
					n++;
					if(n % 2 == 0){
						if(an < n/2) break;
					}else{
						if(an <= n/2) break;
					}
				}
			}
			
		}
		System.out.println("-1 -1");
		return;
	}
}


Measured memory_bytes: 28264
#include <iostream>

using namespace std;

int main()
{
    long long n,res;
    cin>>n;
        res = ((1 + n) * n) / 2;
    res -= 3 * (((n / 3) + 1) * (n / 3)) / 2;
    res -= 5 * (((n / 5) + 1) * (n / 5)) / 2;
    res += 15 * (((n / 15) + 1) * (n / 15)) / 2;
    cout<<res;
    return 0;
}


Measured memory_bytes: 3608
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int n;
char s[100005];
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	if(s[1]==s[n])
	{
		if(n%2==0)
			puts("First");
		else
			puts("Second");
	}
	else
	{
		if(n%2==0)
			puts("Second");
		else
			puts("First");
	}
	return 0;
}


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

int main(){
  int n;
  cin >> n;
  int four = 0, two = 0, odd = 0;
  for(int i = 0; i < n; i++){
    int a;
    cin >> a;
    if(a % 4 == 0){
      four++;
      continue;
    }
    if(a % 2) odd++;
    else two++;
  }
  
  bool ok = true;
  if(odd == four + 1 && two > 0) ok = false;
  if(odd > four + 1) ok = false;
  
  if(ok) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

public class Main {
	public static void main(String[] args) {
		try {
			BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
			String[] line = in.readLine().split(" ");
			int a = Integer.parseInt(line[0]);
			int b = Integer.parseInt(line[1]);
			int c = Integer.parseInt(line[2]);
			
			int count = 0;
			for (int i = a; i <= b; i++) {
				if (c % i == 0) {
					count++;
				}
			}
			System.out.println(String.valueOf(count));
		} catch (IOException e) {
			// TODO 自動生成された catch ブロック
			e.printStackTrace();
		}
	}
}

Measured memory_bytes: 17056
pos = 0

def reconstruction(pre_order, in_order, post_order, left, right):
    if left >= right:
        return
    global pos
    root = pre_order[pos]
    pos += 1
    mid = in_order.index(root)
    reconstruction(pre_order, in_order, post_order, left, mid)
    reconstruction(pre_order, in_order, post_order, mid + 1, right)
    post_order.append(root)


def solve(pre_order, in_order):
    post_order = []
    reconstruction(pre_order, in_order, post_order, 0, len(pre_order))
    print(' '.join([str(v) for v in post_order]))


n = int(input())
pre_order = [int(v) for v in input().split()]
in_order = [int(v) for v in input().split()]

solve(pre_order, in_order)


Measured memory_bytes: 5608
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
using namespace std;
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; }
using Graph = vector<vector<int> >;
// MOD
const int MOD = 1000000007;

long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

int H, W;
int field[100][100];

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const double PI=3.14159265358979323846;
bool seen[100][100];


string N[100];

bool memo[110];
bool flag;
Graph G;

int dist[100][100];

bool compare_f(pair<int, int> &x, pair<int, int> &y) {
  return x.second< y.second;
}

int dp[100000];

struct Unionfind{
    vector<int> par;

    Unionfind(int n) : par(n, -1){}

    int root(int x){
        if(par[x] < 0) return x;
        else return par[x] = root(par[x]);
    } 

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

    bool merge(int x, int y){
        x = root(x); y = root(y);
        if(x == y) return false;
        if(par[x]>par[y]) swap(x, y);
        par[x] += par[y];
        par[y] = x;
        return true;
    }

    int size(int x){
        return -par[root(x)];
    }
};

int main() {
    long long X; cin >> X;
    long long sum = 100;
    int res = 0;
    while(sum < X){
        res++;
        sum += 0.01*sum;
    }
    cout << res <<endl;
}

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

using namespace std;

#define sqr(x) ((x) * (x))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()

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

void solve() {
  ll N, A, B;
  cin >> N >> A >> B;
  ll d = B - A;
  if (d % 2 == 0) {
    cout << d / 2 << endl;
  } else {
    ll cand1 = min(N - A, B - 1);
    ll cand2 = min((B - A + 1) / 2 + (A - 1), (B - A + 1) / 2 + (N - B));
    cout << min(cand1, cand2) << endl;
  }
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
s = list(input())
t = list(input())
sa = float('inf')

for i in range(len(s)-len(t)+1):
    s_part = s[i:(i+len(t))]
    huitti = len(t)
    for j in range(len(t)):
        if s_part[j] == t[j]:
            huitti -= 1
    sa = min(sa, huitti)

print(sa)

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

using namespace std;

using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using vvvll = vector<vector<vector<ll>>>;
using vvvvll = vector<vector<vector<vector<ll>>>>;
using pl4 = pair<ll,ll>;
using str = string;
using vpl4 = vector<pair<ll,ll>>;

#define sz size()
#define be begin()
#define en end()
#define fi first
#define se second
#define pb push_back
#define mp make_pair

#define llin(x) ll(x);cin >> (x);
#define stin(x) str(x);cin >> (x);
#define vllin(x,n) vll(x)(n);FOR(i,0,n-1){cin >> (x)[i];}
#define vllin2(a,b,n) vll(a)(n);vll(b)(n);FOR(i,0,n-1){cin >> (a)[i] >> (b)[i];}
#define vllin3(a,b,c,n) vll(a)(n);vll(b)(n);vll(c)(n);FOR(i,0,n-1){cin >> (a)[i] >> (b)[i] >> (c)[i];}
#define vlling(x,n) (x).assign(n,0);FOR(i,0,n-1){cin >> (x)[i];}
#define vlling2(a,b,n) (a).assign(n,0);(b).assign(n,0);FOR(i,0,n-1){cin >> (a)[i] >> (b)[i];}
#define vlling3(a,b,c,n) (a).assign(n,0);(b).assign(n,0);(c).assign(n,0);FOR(i,0,n-1){cin >> (a)[i] >> (b)[i] >> (c)[i];}
#define vpl4in(x,n) vpl4(x)((n),mp(0,0));FOR(i,0,n-1){cin >> x[i].fi >> x[i].se;}
#define FOR(i,a,b) for(ll i=a;i<=b;i++)
#define rFOR(i,b,a) for(ll i=a;i>=b;i--)
#define SORT(x) sort(x.be,x.en)
#define rSORT(x) sort(x.rbegin(),x.rend())
#define say(x) cout << (x);
#define sal(x) cout << (x) << endl;
#define says(x) cout << (x) << (' ');
#define sas cout << (' ');
#define sayR(x) cout << fixed << setprecision(10) << (x);
#define salR(x) cout << fixed << setprecision(10) << (x) << endl;
#define yn(a) cout << ((a) ? "yes" : "no") << endl;
#define Yn(a) cout << ((a) ? "Yes" : "No") << endl;
#define YN(a) cout << ((a) ? "YES" : "NO") << endl;
#define Imp(a) cout << ((a) ? "Possible" : "Impossible") << endl;
#define IMP(a) cout << ((a) ? "POSSIBLE" : "IMPOSSIBLE") << endl;

ll MOD = 1000000007;

signed main()
{
    llin(n);
    ll k=0;
    FOR(i,0,n-1){
        k=k+i;
    }
    sal(k)
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    long long n,k;
    cin>>n>>k;
    long long ans=0;
    for(long long i=0;i<n;i++){
        long long x,y;
        cin>>x>>y;
        long long xx,yy;
        xx=x*x+y*y;
        yy=k*k;
        if(xx<=yy) ans++;
        
    }
    cout<<ans<<endl;

}

Measured memory_bytes: 3164
cond = [int(n) for n in input().split(" ")]
while True:
    answer = [101,0]
    case = []
    sets = set()
    for c in range(cond[0]):
        case.append([int(n) for n in input().split(" ")[1:]])
        sets = sets | {n for n in case[-1]} 
        #print(sets,case)
    else:
        for num in sets:
            disp = [num,0]
            for c in case:
                if num in c:
                    disp[1] += 1
            else:
                #print(disp,answer,cond)
                if (disp[1] >= cond[1] and disp[1] > answer[1] ) or (disp[1] == answer[1] and disp[0] < answer[0]):
                    answer = disp
        else:
            if answer[0] == 101:
                print(0)
            else:
                print(answer[0])
            cond = [int(n) for n in input().split(" ")]
            if cond == [0,0]:
                break

Measured memory_bytes: 7716
#include<iostream>
#include<algorithm>
#include<iomanip>
using lint=int64_t;
using namespace std;

int main()
{
	int N;
	int v[100]={};

	cin >> N;
	for(int i=0;i<N;i++)
		cin >> v[i];
	
	sort(v,v+N);

	double ans=0;
	ans=(v[0]+v[1])/2.0;
	for(int i=2;i<N;i++)
		ans=(ans+v[i])/2.0;

	cout << fixed << setprecision(7);
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxn = 200000 + 10;
double prob[maxn];
double pre[maxn];

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  double p;
  pre[0] = 0;
  for (int i = 0; i < n; i++) {
    cin >> p;
    prob[i] = (1.0*p*(p+1)/2)/p;
    pre[i + 1] = pre[i] + prob[i];
    // cout << prob[i] << endl;
  }
  double res = -1;
  for (int i = 0; i + k <= n; i++) {
    res = max(res, (pre[i+k] - pre[i]));
  }
  cout << setprecision(6) << fixed << res << endl;
}


Measured memory_bytes: 3328
($n,$m)=glob<>;@a=<>;for(0..$n-1){($a,$b)=glob$a[$_];$d=1e9;$a[$n+$_-1]=~$",$d>($k=abs($a-$`)+abs($b-$'))&&($d=$k,$p=$_)for(1..$m);print$p,$/}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF 1e18L
#define MININF -1e18L
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define SORT(v) sort(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define pb push_back
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
typedef long long ll;
typedef pair<int, int> intint;

int main(void)
{
    int n;
    cin >> n;
    int t,a;
    cin >> t >> a;
    double min_v = 100000000;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        int tmp;
        cin >> tmp;
        // min_v = min(min_v, abs((t - tmp * 0.006) - a);
        if(min_v > abs(a - (t - tmp * 0.006))){
            ans = i + 1;
            min_v = abs(a - (t - tmp * 0.006));
        }
    }

    pr(ans);
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void)
{
	string s;
	cin>>s;
	
	string v[3]={"Sunny","Cloudy","Rainy"};
	for(int i=0;i<=2;i++)
	{
		if(v[i]==s)
		cout<<v[(i+1)%3]<<endl;
	}
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long

int main(void){
    int N; cin >> N;
    vector<int> A(N);
    for (auto& ai : A){
        cin >> ai;
    } 
    sort(A.begin(), A.end());
    reverse(A.begin(), A.end());
    ll res = 0;
    for (int i = 1; i < N; ++i)
        res += A[i / 2];
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 4028
#include<iostream>
using namespace std;
#include<vector>
#include<functional>
template<typename T>
struct dualsegtree{
	using F=function<T(T,T)>;
	const F lazycalcfn,updatefn;
	int n;
	T lazydefvalue;
	vector<T>dat,lazy;
	vector<bool>lazyflag;
	dualsegtree(int n_=0,T defvalue=0,
		const F lazycalcfn_=[](T a,T b){return a+b;},
		const F updatefn_=[](T a,T b){return a+b;},
		T lazydefvalue_=0
	):lazydefvalue(lazydefvalue_),
		lazycalcfn(lazycalcfn_),updatefn(updatefn_)
	{
		n=1;
		while(n<n_)n<<=1;
		dat.assign(n,defvalue);
		lazy.assign(n-1,lazydefvalue);
		lazyflag.assign(n-1,false);
	}
	void copy(const vector<T>&v)
	{
		for(int i=0;i<v.size();i++)dat[i]=v[i];
		lazy.assign(n-1,lazydefvalue);
		lazyflag.assign(n-1,false);
	}
	void update(int a,int b,T x,int k=0,int l=0,int r=-1)//[a,b)
	{
		if(r<0)r=n;
		if(b<=l||r<=a)return;
		else if(a<=l&&r<=b)
		{
			if(k<n-1)
			{
				lazy[k]=lazycalcfn(lazy[k],x);
				lazyflag[k]=true;
			}
			else dat[k-n+1]=updatefn(dat[k-n+1],x);
		}
		else
		{
			if(lazyflag[k])
			{
				update(0,n,lazy[k],k*2+1,l,(l+r)/2);
				update(0,n,lazy[k],k*2+2,(l+r)/2,r);
				lazy[k]=lazydefvalue;
				lazyflag[k]=false;
			}
			update(a,b,x,k*2+1,l,(l+r)/2);
			update(a,b,x,k*2+2,(l+r)/2,r);
		}
	}
	T query(int i)
	{
		T ret=dat[i];
		i+=n-1;
		while(i>0)
		{
			i=(i-1)/2;
			if(lazyflag[i])ret=updatefn(ret,lazy[i]);
		}
		return ret;
	}
};
int N,Q;
main()
{
	cin>>N>>Q;
	long ans=(long)(N-2)*(N-2);
	dualsegtree<bool>fX(N,false,[](bool a,bool b){return b;},[](bool a,bool b){return a||b;});
	dualsegtree<bool>fY(N,false,[](bool a,bool b){return b;},[](bool a,bool b){return a||b;});
	dualsegtree<int>cX(N,N-2,[](int a,int b){return b;},[](int a,int b){return b;});
	dualsegtree<int>cY(N,N-2,[](int a,int b){return b;},[](int a,int b){return b;});
	int mX=N,mY=N;
	for(;Q--;)
	{
		int t,x;cin>>t>>x;
		if(t==1)
		{
			ans-=cX.query(x);
			if(!fX.query(x))
			{
				mX=x;
				fX.update(x,N,true);
				cY.update(0,mY,x-2);
			}
		}
		else
		{
			ans-=cY.query(x);
			if(!fY.query(x))
			{
				mY=x;
				fY.update(x,N,true);
				cX.update(0,mX,x-2);
			}
		}
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 7756
#if 0

#endif

#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<int(n);++i)
using namespace std;
template<class A>void p(A a){cout << (a) << endl;}
template<class A,class B>void p(A a,B b){cout << a << " "  ;p(b);}
template<class A,class B,class C>void p(A a,B b,C c){cout << a << " " ;p(b,c);}
template<class A,class B,class C,class D>void p(A a,B b,C c,D d){cout << a << " " ;p(b,c,d);}
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int INF=numeric_limits<int>::max();
// for copy
// for(int i=0;i<N;++i) {

int main(void) {
  int X,Y,A,B,C;
  cin>>X>>Y>>A>>B>>C;
  int p[A+10];
  int q[B+10];
  int r[C+10];
  vector<int> all;
  REP(i,A) {
    cin>>p[i];
  }
  REP(i,B) {
    cin>>q[i];
  }
  REP(i,C) {
    cin>>r[i];
  }
  sort(p,p+A,greater<int>());
  sort(q,q+B,greater<int>());
  sort(r,r+C,greater<int>());
  REP(i,X) {
    all.push_back(p[i]);
  }
  REP(i,Y) {
    all.push_back(q[i]);
  }
  REP(i,C) {
    all.push_back(r[i]);
  }
  sort(all.begin(),all.end(),greater<int>());
  ll res=0;
  REP(i,X+Y) {
    res+=all[i];
  }
  cout << res << endl;
  return 0;
}



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

#define pb push_back
#define mp make_pair

typedef pair<int, int> pii;
typedef long long ll;

const int MAXM = 100005;
const int MAXN = 200005;

int n, k, l;
pii e1[MAXM], e2[MAXM];
int p1[MAXN], p2[MAXN];
vector<int> c1[MAXN], c2[MAXN];
map<pii, int> cache;

inline int root(int *p, int x) {
  return x == p[x] ? x : p[x] = root(p, p[x]);
}

bool merge(int *p, int a, int b) {
  a = root(p, a);
  b = root(p, b);
  p[a] = b;
  return a != b;  
}

int main() {
#ifdef LOCAL                       
  freopen("input.txt", "r", stdin);
  freopen("output.txt", "w", stdout);
#endif
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  cin >> n >> k >> l;
  for (int i = 1; i <= n; ++i) {
    p1[i] = i;
    p2[i] = i;
  }
  for (int i = 0, a, b; i < k; ++i) {
    cin >> a >> b;
    merge(p1, a, b);
  }
  for (int i = 0, a, b; i < l; ++i) {
    cin >> a >> b;
    merge(p2, a, b);
  }
  for (int i = 1; i <= n; ++i) {
    c1[root(p1, i)].pb(i);
    c2[root(p2, i)].pb(i);
  }
  for (int i = 1; i <= n; ++i) {     
    sort(c1[i].begin(), c1[i].end());
    sort(c2[i].begin(), c2[i].end());
  }
  for (int i = 1; i <= n; ++i) {
    int r1 = root(p1, i);
    int r2 = root(p2, i);
    pii leaders = mp(r1, r2);
    int &res = cache[leaders];
    if (!res) {
      if (c1[r1].size() > c2[r2].size()) {
        for (auto it : c2[r2]) {
          int pos = lower_bound(c1[r1].begin(), c1[r1].end(), it) - c1[r1].begin();
          if (pos < (int)c1[r1].size() && c1[r1][pos] == it) ++res;
        }
      } else {
        for (auto it : c1[r1]) {
          int pos = lower_bound(c2[r2].begin(), c2[r2].end(), it) - c2[r2].begin();
          if (pos < (int)c2[r2].size() && c2[r2][pos] == it) ++res;
        }
      }
    }
    cout << res << ' ';
  }
  return 0;
}

Measured memory_bytes: 34432
#include<bits/stdc++.h>
#define rep(i,a) for(int (i)=0; (i)<(a); (i)++)
#define rrep(i,a) for(int (i)=a-1; (i)>=(0); (i)--)
#define rep2(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define MOD 1000000007
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
typedef long long ll;

using namespace std;

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int n; cin >> n;
  string s,t; cin >> s >> t;
  rep(i,n) cout << s[i] << t[i];
  return 0;
}

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

int N, L;
vector<string> S;

int main() {
    cin >> N >> L;
    rep(i, N) {
        string tmp; cin >> tmp;
        S.push_back(tmp);
    }
    sort(S.begin(), S.end());

    rep(i, N) {
        cout << S[i];
    }

    cout << endl;
}

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

int main() {
  int n, u, v, m;
  cin >> n >> u >> v >> m;
  map<int, P> mpu, mpv;
  REP(i, n) REP(j, n) {
    int k;
    cin >> k;
    mpu[k] = {i, j};
  }
  REP(i, n) REP(j, n) {
    int k;
    cin >> k;
    mpv[k] = {i, j};
  }
  int ans = 0;
  vector<int> cu(2 * n + 2, 0), cv(2 * n + 2, 0);
  REP(i, m) {
    int q;
    cin >> q;
    if (n == 1) {
      if (mpu.find(q) != end(mpu)) {
        P p = mpu[q];
        cu[0]++;
      }
      if (mpv.find(q) != end(mpv)) {
        P p = mpv[q];
        cv[0]++;
      }
    } else {
      if (mpu.find(q) != end(mpu)) {
        P p = mpu[q];
        cu[p.first]++;
        cu[n + p.second]++;
        if (p.first == p.second) cu[2 * n]++;
        if (p.first == n - 1 - p.second) cu[2 * n + 1]++;
      }
      if (mpv.find(q) != end(mpv)) {
        P p = mpv[q];
        cv[p.first]++;
        cv[n + p.second]++;
        if (p.first == p.second) cv[2 * n]++;
        if (p.first == n - 1 - p.second) cv[2 * n + 1]++;
      }
    }
    int nu = 0, nv = 0;
    REP(j, 2 * n + 2) {
      if (cu[j] == n) nu++;
      if (cv[j] == n) nv++;
    }
    if (nu >= u) ans += 1;
    if (nv >= v) ans += 2;
    if (ans == 0) continue;
    if (ans == 1) {
      cout << "USAGI" << endl;
      return 0;
    }
    if (ans == 2) {
      cout << "NEKO" << endl;
      return 0;
    }
    if (ans == 3) {
      cout << "DRAW" << endl;
      return 0;
    }
  }
  cout << "DRAW" << endl;
  return 0;
}



Measured memory_bytes: 20968
N, M = map(int, input().split())
min_gate = 0
max_gate = N

for _ in range(M):
    l, r = map(int, input().split())
    min_gate = max(min_gate, l)
    max_gate = min(max_gate, r)

print(max(max_gate - min_gate + 1, 0))

Measured memory_bytes: 3060
#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];
  }
  
  sort(A.begin(), A.end());
  
  cout<< A[N-1] - A[0] << endl;
}

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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for (int i = a; i < (int)b; ++i)
#define rrep(i, n) for (int i = ((int)n - 1); i >= 0; --i)

using ll = long long;
using ld = long double;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const ll MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    int n;
    ll k;
    cin >> n >> k;
    vector<int> a(n + 1);
    rep (i, n) {
        cin >> a[i];
        a[i]--;
    }
    int pos = 0;
    map<int, int> used;
    vector<int> city;
    while (used[pos] == 0) {
        used[pos]++;
        city.push_back(pos);
        pos = a[pos];
    }
    int index;
    rep (i, city.size()) {
        if (pos == city[i]) {
            index = i;
            break;
        }
    }
    int len = city.size() - index;
    if (k <= city.size() - 1) {
        cout << city[k] + 1 << endl;
    } else {
        ll t = (k - index) % len;
        cout << city[index + t] + 1 << endl;
    }

    return 0;
}



Measured memory_bytes: 13880
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
typedef pair<int, int> pii;
int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
    int n, r; cin >> n >> r;
    if (n >= 10)
        cout << r << '\n';
    else
        cout << r + 100 * (10 - n) << '\n';
}


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

int main(void){

    int n, leftPoint = 0, rightPoint = 0;
    string leftStr, rightStr;
    cin >> n;

    for (int i = 0; i < n; i++) {
        cin >> leftStr >> rightStr;
        if (leftStr == rightStr) {
            leftPoint++;
            rightPoint++;
        } else if (leftStr > rightStr) {
            leftPoint += 3;
        } else {
            rightPoint += 3;
        }
    }
    cout << leftPoint << " " << rightPoint << endl;
    return 0;
}

Measured memory_bytes: 3124
#include <iostream>
#include <cstdio>
#include <climits>
#include <cmath>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;

template <typename T>
class BinarySearchTree
{
private:
  struct Node
  {
    T key;
    Node *right, *left, *parent;
  };
  void inorder(Node *u)
  {
    if(u == NIL) return;
    inorder(u->left);
    cout << " " << u->key;
    inorder(u->right);
  }
  void preorder(Node *u)
  {
    if(u == NIL) return;
    cout << " " << u->key;
    preorder(u->left);
    preorder(u->right);
  }
public:
  Node *root, *NIL;
  BinarySearchTree()
  {
    root = new Node;
    NIL = new Node;
    NIL->parent = NIL;
    NIL->left = NIL;
    NIL->right = NIL;
    root = NIL;
  }
  ~BinarySearchTree(){}
  void insert(int k)
  {
    Node *x = root;
    Node *y = NIL;
    Node *z;
    z = new Node;
    z->key = k;
    z->left = NIL;
    z->right = NIL;
    while(x != NIL)
    {
      y = x;
      if(z->key < x->key)
        x = x->left;
      else
        x = x->right;
    }
    z->parent = y;
    if(y == NIL)
      root = z;
    else
    {
      if(z->key < y->key)
        y->left = z;
      else
        y->right = z;
    }
  }
  void dispPre(){preorder(root);cout << endl;}
  void dispIn(){inorder(root);cout << endl;}
};

int main()
{
  int n, x;
  string com;
  cin >> n;
  BinarySearchTree<int> T;
  for(int i = 0; i < n; i++)
  {
    cin >> com;
    if(com == "insert")
    {
      cin >> x;
      //cerr << "insert" <<endl;
      T.insert(x);
    }
    else if(com == "print")
    {
      T.dispIn();
      T.dispPre();
    }
  }
  return 0;
}

Measured memory_bytes: 24648
a,b,m=map(int,input().split())
alist=list(map(int,input().split()))
blist=list(map(int,input().split()))
x=[]
y=[]
c=[]
for _ in range(m):
    x1,y1,c1=map(int,input().split())
    x.append(x1)
    y.append(y1)
    c.append(c1)
#print(alist,blist,x,y,c)
ans=300000
amin=min(alist)
bmin=min(blist)
if(ans>(amin+bmin)):
    ans=amin+bmin
else:
    pass

for i in range(m):
    cost=alist[x[i]-1]+blist[y[i]-1]-c[i]
    if(ans>cost):
        ans=cost
    else:
        continue
print(ans)

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

#define int long long

int get(int l, int r, int s = 0, int e = (1ll << 60)) {
	if (r <= s || e <= l)
		return 0;
	if (l <= s && e <= r)
		return e - s;
	int mid = (s + e) / 2;
	int x = get(l, r, s, mid);
	int y = get(l, r, mid, e);
	return (y? x + min(x + y, e - mid): x);
}

int32_t main() {
	int a, b;
	cin >> a >> b;
	cout << get(a, b + 1);
}

Measured memory_bytes: 3636
#include<stdio.h>

void keybord(char s[]){
    char k[11] = {'\0'};
    int i;
    int j = 0;

    for(i = 0; s[i]; i++){
        if(s[i] == '0'){
            k[j] = s[i];
            j++;
        }

        if(s[i] == '1'){
            k[j] = s[i];
            j++;
        }

        if(s[i] == 'B' && j > 0){
            j--;
        }
    }
    k[j] = '\0';

    printf("%s", k);
}

int main(void){
    char s[11];

    scanf("%s", s);

    keybord(s);

    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
vector<string> split(string &s, char delimiter){
  vector<string> res;
  int prev_split_point = 0;
  for (int i = 0; i < s.length(); i++) {
    while(s[i] != delimiter && i < s.length())i++;
    string add = s.substr(prev_split_point, i - prev_split_point);
    if(!add.empty())res.push_back(add);
    prev_split_point = i + 1;
  }
  return res;
}

int main(int argc, char *argv[]){
  char c[26];
  for (int i = 0; i < 26; i++) {
    c[i] = 'a' + i;
  }
  vector<string> vs;
  string s;
  string ans[] = {"this", "that", "the"};
  vector<string> tmp;
  while(getline(cin, s)){
    vs = split(s, ' ');
    int n = vs.size();
    for (int k = 0; k < 26; k++) {
      tmp = vs;
      for (int i = 0; i < vs.size(); i++) {
        for (int j = 0; j < vs[i].length(); j++) {
          if('a' <= tmp[i][j] && tmp[i][j] <= 'z')
            tmp[i][j] = c[(vs[i][j] - 'a' + k) % 26];
        }
      }
      for (int i = 0; i < 3; i++) {
        for (int j = 0; j < tmp.size(); j++) {
          if(tmp[j] == ans[i]){k = 50, i = 10, j = 1000;}
        }
      }
    }
    for (int i = 0; i < tmp.size(); i++) {
      std::cout << tmp[i];
      if(i == tmp.size() - 1)std::cout << std::endl;
      else std::cout << " ";
    }
  }
  return 0;
}

Measured memory_bytes: 1188
#include <bits/stdc++.h>
using namespace std;
const double PI = acos(-1);

int main(){
  string S, T;
  cin >> S >> T;

  long long int cnt = 0;
  for (int i = 0; i < S.size(); i++) {
    if (S[i] != T[i]) {
      cnt++;
    }
  }
  cout << cnt << endl;
  return 0;
}

Measured memory_bytes: 3840
n,k=gets.split;a=[*0..9]-gets.split.map(&:to_i)
i1=(0...n.size).find{|i|!a.find{|e|e==n[i].to_i}}
(puts n;exit)if !i1
i2=i1.downto(0).find{|i|a.find{|e|e>n[i].to_i}}||-1
puts "#{i2<0?a[0]>0?a[0]:a[1]:n[0...i2]+a.find{|e|e>n[i2].to_i}.to_s}"+a[0].to_s*(n.size-i2-1)

Measured memory_bytes: 1788
def main():
    n = int(input())
    s = input()
    ma = 0
    for i in range(1, n):
        x = s[:i]
        y = s[i:]
        ma = max(ma, count_same(x, y))
    print(ma)


def count_same(x, y):
    return len(set(x) & set(y))


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <stdio.h>

int main()
{
	int n;
	int a;
	long long s = 0;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
	{
		scanf("%d", &a);
		s += a;
	}
	printf("%lld\n", s - n);
	
	return 0;
}

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

#define MAX_N 100000
#define MAX_M 100000

typedef struct EDGE {
	int to;
	struct EDGE *next;
} edge;

int buff_size;
edge buff[MAX_M + MAX_M];
edge *adj[MAX_N];

void init(int n, int m) {
	int i;
	for(i = 0; i < n; ++i) {
		adj[i] = NULL;
	}
	for(i = 0; i < m; ++i) {
		buff[i].next = NULL;
	}
	buff_size = 0;
}

edge *new_edge() {
	return buff + buff_size++;
}

void add_edge(int u, int v) {
	edge *e = new_edge();
	e->to = v;
	e->next = adj[u];
	adj[u] = e;
}

int head, tail;
int queue[MAX_N];

void enqueue(int data) {
	queue[tail++] = data;
}

int dequeue() {
	return queue[head++];
}

int empty() {
	return head == tail;
}

void clear() {
	head = tail = 0;
}

int next_label;
int label[MAX_N];

void bfs(int v) {
	edge *e;

	clear();
	enqueue(v);

	label[v] = next_label;
	while(!empty()) {
		const int v = dequeue();
		for(e = adj[v]; e != NULL; e = e->next) {
			if(label[e->to] == -1) {
				label[e->to] = next_label;
				enqueue(e->to);
			}
		}
	}
	++next_label;
}

int main() {
	int n, m, q;
	int u, v;
	int s, t;
	int i;

	scanf("%d %d", &n, &m);
	init(n, m);

	for(i = 0; i < m; ++i) {
		scanf("%d %d", &u, &v);
		add_edge(u, v);
		add_edge(v, u);
	}

	memset(label, -1, sizeof(label));
	for(i = 0; i < n; ++i) {
		if(label[i] == -1) bfs(i);
	}

	scanf("%d", &q);
	while(q--) {
		scanf("%d %d", &s, &t);
		puts(label[s] == label[t] ? "yes" : "no");
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 5280
'use strict'

function main(input){
    const N = Number(input[0]);
    const A = input[1].split(' ').map(Number);
    let B = [];
    for(let i=0;i<N;i++){
        B.push(A[i]-i-1);
    }
    B.sort((a,b)=>a-b);
    //console.log(B);
    const n = N/2 |0;
    let b;
    if(N%2){
        b=B[n];
    }else{
        b=(B[n]+B[n-1])/2|0;
    }
    let ans = 0;
    for(let k of B){
        ans+=Math.abs(k-b);
    }
    console.log(ans);
}

main(require('fs').readFileSync('/dev/stdin', 'utf8').split('\n'))


Measured memory_bytes: 58632
while True:
	n, x = map(int, raw_input().split())
	if (n == 0) and (n == x):
		break
	cnt = 0
	for i in range(1, n+1):
		for j in range(i+1, n+1):
			for k in range(j+1, n+1):
				if (i + j + k) == x:
					cnt += 1
				elif (i + j + k) > x:
					break
	print cnt

Measured memory_bytes: 4212
#include<bits/stdc++.h>
//ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
//clock_t start=clock();clock_t end=clock();cout<<(double)(end-start)/CLOCKS_PER_SEC<<endl;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef unsigned int ui;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
typedef pair<pii,pii> P;
typedef tuple<ll,ll,ll> tl;
typedef pair<double,double> pdd;
typedef vector<vector<ll>> mat;
ll mod=1000000007;
ll mod2=998244353;
ll mod3=1000003;
ll mod4=998244853;
ll mod5=1000000009;
ll inf=1LL<<60;
double pi=3.141592653589793238462643383279L;
double eps=1e-14;
#define rep(i,m,n) for(ll i=m;i<n;i++)
#define rrep(i,n,m) for(ll i=n;i>=m;i--)
#define srep(itr,st) for(auto itr=st.begin();itr!=st.end();itr++)
#define mrep(itr,mp) for(auto itr=mp.begin();itr!=mp.end();itr++)
#define Max(a,b) a=max(a,b)
#define Min(a,b) a=min(a,b)
int dh[4]={1,-1,0,0};
int dw[4]={0,0,1,-1};
int ddh[8]={-1,-1,-1,0,0,1,1,1};
int ddw[8]={-1,0,1,-1,1,-1,0,1};
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umh unordered_map<ll,ll,custom_hash>
ll gcd(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    if(a%b==0)return b;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll c=gcd(a,b);
    return a*b/c;
}
ll Pow(ll n,ll k){
    ll ret=1;
    ll now=n;
    while(k>0){
        if(k&1)ret*=now;
        now*=now;
        k/=2;
    }
    return ret;
}
ll beki(ll n,ll k,ll md){
  ll ret=1;
  ll now=n;
    now%=md;
  while(k>0){
    if(k%2==1){
      ret*=now;
      ret%=md;
    }
    now*=now;
    now%=md;
    k/=2;
  }
  return ret;
}
ll gyaku(ll n,ll md){
  return beki(n,md-2,md);
}
ll popcount(ll n){
    ll ret=0;
    ll u=n;
    while(u>0){
        ret+=u%2;
        u/=2;
        
    }
    return ret;
}
int main(){
    ios::sync_with_stdio(false);cin.tie(0);
    int n;cin>>n;
    ll ans=0;
    rep(i,1,n+1){
        if(i%3!=0&&i%5!=0)ans+=i;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 3612
#include<iostream>
using namespace std;
long long int gcd(long long int a,long long int b){
    if(a%b==0)return b;
    return gcd(b,a%b);
}
int main()
{
    long long int a,b;
    cin >> a >> b;
    cout << a*b/gcd(a,b);
    return 0;
}

Measured memory_bytes: 384
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
using E = System.Linq.Enumerable;
 
class Program
 {
        static int R;

        static void Main(string[] args)
        {
          //入力を受け取る
          var NM = Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToArray();
          var N = NM[0];
          var M = NM[1];
          //一回の提出でかかる時間
          var OT = (N-M)*100+1900*M;
          

          Console.WriteLine(OT*Math.Pow(2,M));
        }
}







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

long long A[200005];

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

    long long sum1 = 0;
    for(int i = 0; i < N; i ++){
        scanf("%d", &A[i]);
        sum1 += A[i];
    }

    long long temp1 = 0;
    long long ans = sum1;
    for(int i = 0; i < N; i ++){
        temp1 += A[i];
        ans = min(ans, abs(temp1+temp1-sum1));
    }

    printf("%lld", ans);

    return 0;
}


Measured memory_bytes: 1792
from sys import stdin
input = stdin.readline

N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

sumA = [0]
sumB = [0]


for i in range(N):
    sumA.append(sumA[i] + A[i])

for i in range(M):
    sumB.append(sumB[i] + B[i])

ans = 0
t = M

for i in range(N + 1):
    for j in range(t, -1, -1):
        if K < sumA[i] + sumB[j]:
            t -= 1
            continue
        else:
            ans = max(ans, i + j)
            break

print(ans)


Measured memory_bytes: 49412
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define N 1000
#define max(a,b) (a<b?b:a)

int lcs(char *a,char *b){
  int c[N+1][N+1];
  int m,n,i,j,maxl=0;
  char s1[N],s2[N];
  m = strlen(a);
  n = strlen(b);
  s1[0] = ' ';
  s2[0] = ' ';
  strcpy(&s1[1],a);
  strcpy(&s2[1],b);
  for(i=0;i<=m;i++) c[i][0] = 0;
  for(j=1;j<=n;j++) c[0][j] = 0;
  for(i=1;i<=m;i++){
    for(j=1;j<=n;j++){
      if(s1[i] == s2[j]) c[i][j] = c[i-1][j-1]+1;
      else c[i][j] = max(c[i-1][j],c[i][j-1]);
      maxl = max(maxl,c[i][j]);
    }
  }
  return maxl;
}

int main(){
  char s1[N],s2[N];
  int n,i,j;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%s",s1);
    scanf("%s",s2);
    printf("%d\n",lcs(s1,s2));
  }
  return 0;
}



Measured memory_bytes: 5608
#include <iostream>

int main()
{
  char x, y;

  std::cin >> x >> y;

  if (x > y) {
  std::cout << ">" << std::endl;
  } else if (x < y) {
  std::cout << "<" << std::endl;
  } else {
  std::cout << "=" << std::endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define il inline
#define re register
#define debug printf("Now is Line : %d\n",__LINE__)
#define file(a) freopen(#a".in","r",stdin);freopen(#a".out","w",stdout)
#define int long long
#define D double
#define inf 123456789
#define mod 1000000007
il int read() {
    re int x = 0, f = 1; re char c = getchar();
    while(c < '0' || c > '9') { if(c == '-') f = -1; c = getchar();}
    while(c >= '0' && c <= '9') x = x * 10 + c - 48, c = getchar();
    return x * f;
}
#define rep(i , a , b) for(int i = (a) , i##Limit = (b) ; i <= i##Limit ; ++ i)
#define drep(i , b , a) for(int i = (a) , i##Limit = (b) ; i >= i##Limit ; -- i)
#define Next(i, u) for(re int i = head[u]; i; i = e[i].next)
#define mem(k, p) memset(k, p, sizeof(k))
#define lb(x) (x)&(-(x))
#define ls k * 2
#define rs k * 2 + 1
#define maxn 2333
il int Mul(int a, int b) { return 1ll * a * b % mod; }
il int Inc(int a, int b) { return (a += b) >= mod ? a - mod : a; }
il int Dec(int a, int b) { return (a -= b) < 0 ? a + mod : a; }
il int qpow(int a, int b) { int r = 1; while(b) { if(b & 1) r = Mul(r, a); a = Mul(a, a), b >>= 1; } return r; }
int n, m, dp[maxn][4][2];
char c[maxn];
il int dfs(int u, int use, int li) {
	if(use > m) return 0;
	if(u > n) return use == m;
	if(dp[u][use][li] != -1) return dp[u][use][li];
	int p = li == 1 ? c[u] - '0' : 9, ans = 0;
	rep(i, 0, p) ans += dfs(u + 1, use + (i != 0), li && i == p);
	return dp[u][use][li] = ans;
} 
signed main() {
	scanf("%s", c + 1), n = strlen(c + 1), m = read(), mem(dp, -1);
	cout << dfs(1, 0, 1);
	return 0;
}

Measured memory_bytes: 384
import sys

N, K = map(int, input().split())
X = list(map(int, sys.stdin.readline().rsplit()))

res = 10 ** 10
for i in range(N):
    if i + K - 1 < N:
        a, b = X[i], X[i + K - 1]
        if b <= 0:
            res = min(res, abs(a))
        elif 0 <= a:
            res = min(res, b)
        else:
            res = min(res, 2 * abs(a) + abs(b), abs(a) + abs(b) * 2)

print(res)


Measured memory_bytes: 20248
import sys
from heapq import *
input = sys.stdin.readline

def main():
    n, q = map(int, input().split())
    
    key = []
    for i in range(n):
        s, t, x = map(int, input().split())
        l, r = max(0, s-x), max(0, t-x)
        key.append((l, 1, x))
        key.append((r, -1, x))
    
    for i in range(q):
        d = int(input())
        key.append((d, 2))

    key.sort()
    judge = []
    already = dict()
    
    for i in range(2*n+q):
        k = key[i]
        if k[1] == -1:
            if k[2] in already:
                already[k[2]] += 1
            else:
                already[k[2]] = 1
        elif k[1] == 1:
            heappush(judge, k[2])
        else:
            while judge:
                if judge[0] in already and already[judge[0]] > 0:
                    already[judge[0]] -= 1
                    heappop(judge)
                else:
                    break
            if judge:
                print(judge[0])
            else:
                print(-1)
    

    
if __name__ == "__main__":
    main()



Measured memory_bytes: 180244
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=105,INF=1<<20;
const double eps=1e-9;
double ti[MAX][MAX],p[MAX][MAX],pre[MAX][MAX];

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int N,M,L;cin>>N>>M>>L;
    
    for(int i=0;i<N;i++){
        memset(pre,0,sizeof(pre));
        double a,b,c;cin>>a>>b>>c;
        pre[0][0]=1.0;
        
        for(int j=0;j<M;j++){
            for(int k=0;k<=j;k++){
                pre[j+1][k]+=pre[j][k]*(100.0-a)/100.0;
                pre[j+1][k+1]+=pre[j][k]*a/100.0;
            }
        }
        
        for(int k=0;k<=M;k++){
            p[i][k]=pre[M][k];
            if(c==0) ti[i][k]=INF;
            else ti[i][k]=L/c+b*k;
        }
    }
    
    for(int i=0;i<N;i++){
        double ans=0.0;
        for(int j=0;j<=M;j++){
            double can=p[i][j];
            for(int k=0;k<N;k++){
                if(i==k) continue;
                double sum=0.0;
                for(int l=0;l<=M;l++){
                    if(ti[i][j]<ti[k][l]-eps) sum+=p[k][l];
                }
                can*=sum;
            }
            ans+=can;
        }
        
        cout<<fixed<<setprecision(25)<<ans<<endl;
    }
}





Measured memory_bytes: 3572
#include <iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep(i,a,n) for(int i=a;i<n;i++)
signed main()
{
	int a;
	cin >> a;
	if (a % 11 > 6)cout << (a / 11) * 2 + 2 << endl;
	else if(a%11==0) cout << (a / 11)*2 << endl;
	else cout << a / 11 * 2 + 1 << endl;
}

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

#define abs(N) ((N>0)?N:-1*N)
#define min(A,B) ((A>B)?B:A)
#define max(A,B) ((A<B)?B:A)
#define print(S) (cout << S)
#define println(S) (cout << S << endl)

int main(){
	int m,f,r;
	while(true){
		cin >> m >> f >> r;
		if(m==-1 && f == -1 && r == -1){
			break;
		}
		if(m==-1 || f == -1 || m+f < 30){
			println("F");
		}else if(m+f >= 80){
			println("A");
		}else if(m+f >= 65){
			println("B");
		}else if(m+f >= 50){
			println("C");
		}else if(r >= 50){
			println("C");
		}else{
			println("D");
		}
	}

	return 0;
}



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

typedef long double ld;
typedef long long ll;
typedef pair<ll,ll> pi;
typedef vector <ll> vi;
typedef vector <pi> vpi;
#define f first
#define s second
#define FOR(i,s,e) for(ll i=s;i<=ll(e);++i)
#define DEC(i,s,e) for(ll i=s;i>=ll(e);--i)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lbd(x, y) lower_bound(all(x), y)
#define ubd(x, y) upper_bound(all(x), y)
#define aFOR(i,x) for (auto i: x)
#define mem(x,i) memset(x,i,sizeof x)
#define fast ios_base::sync_with_stdio(false),cin.tie(0)
#define maxn 200001
ll A[maxn];
int N,K;

int main(){
	fast;
	
	cin>>N>>K;
	
	FOR(i,1,N){
		cin>>A[i];
	}
	
	ll l = 0, r = 1e10;
	
	
	while (l + 1 < r){
		ll mid = (l + r) / 2;
		
		ll res = 0;
		FOR(i,1,N) res += ceil((ld)A[i] / (ld)mid) - 1;
		
		if (res > K) l = mid;
		else r = mid;
	}
	
	//~ ll res = 0;
	//~ FOR(i,1,N) res += ceil((ld)A[i] / (ld)l) - 1;
	//~ //cout<<res<<' ';
	//~ if (res > K) cout<<r;
	//~ else cout<<l;
	cout<<r;
	
	
	
}



Measured memory_bytes: 5196