akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <iomanip>
using namespace std;
typedef long long ll;
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

#define EPS (1e-7)
#define INF (1e15)
#define PI (acos(-1))
#define MOD 1000000007

#define REP(i,n) for(int i=0;i<n;i++)
#define REPS(i,f,n) for(int i=(f);i<(n);i++)
#define EACH(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)

#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define arrdump(n,a) for(int i=0;i<n;i++) {cout<<((i>0)? " ":"")<<a[i];}cout<<"\n";


typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

int dy4[]={0, 0, 1, -1};
int dx4[]={1, -1, 0, 0};
int dx8[]={0, 0, 1, -1, 1, 1, -1, -1};
int dy8[]={1, -1, 0, 0, 1, -1, -1, 1};

// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_3_C&lang=jp


struct Node {
    int key;
    Node *next;
    Node *prev;
};

Node *NIL;

static void init() {
    NIL = (Node*)malloc(sizeof(Node));
    NIL->next = NIL;
    NIL->prev = NIL;
}

static void insert(int key) {
    Node *x = (Node*)malloc(sizeof(Node));
    x->key = key;
    x->prev = NIL;
    x->next = NIL->next;

    NIL->next->prev = x;
    NIL->next = x;
}

static Node* searchNode(int key) {
    Node *cur = NIL->next;
    while(cur != NIL && key != cur->key) {
        cur = cur->next;
    }
    return cur;
}

static void deleteNode(Node *n) {
    if (n==NIL) return;
    n->next->prev = n->prev;
    n->prev->next = n->next;
    free(n);
}

static void del(int key) {
    deleteNode(searchNode(key));
}

static void deleteFirst() {
    deleteNode(NIL->next);
}

static void deleteLast() {
    deleteNode(NIL->prev);
}

static void print() {
    int i = 0;
    Node *cur = NIL->next;
    while(cur != NIL) {
        if (i) cout << " ";
        cout << cur->key;
        cur = cur->next;
        i++;
    }
    cout << "\n";
}

int main() {
    init();
    int n; cin >> n;
    char str[50];
    int key;
    REP(i, n) {
        scanf("%s%d", str, &key);
        string com = string(str);
        if (com == "insert") insert(key);
        if (com == "delete") del(key);
        if (com == "deleteFirst") deleteFirst();
        if (com == "deleteLast") deleteLast();
    }
    print();
    return 0;
}


Measured memory_bytes: 34372
#include <iostream>

 

using namespace std;

 

int main()
{
   int i, h, m, s;
   cin >> i;
   h = i / 3600;
   m = (i%3600)/60;
   s = i % 60;
   cout << h << ":" << m << ":"<< s << endl;

 

   
   return 0;
}


Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  ll N;
  ll D;
  cin >> N >> D;
  ll X[N];
  ll Y[N];
  int Sum=0;
  ll k;
  rep(i,N){cin >> X[i] >> Y[i];}
  int i=0;
  while(i<N){
    k=(X[i])*(X[i])+(Y[i])*(Y[i]);
    if(k<=D*D){Sum++;}
    i++;
  }
  cout << Sum << endl;
  return 0;
}


Measured memory_bytes: 6748
import java.util.*;

public class Main {
  
  public static void main (String[] args){
  
  	Scanner scanner = new Scanner (System.in);
  
  	int N = scanner.nextInt();
    int A = scanner.nextInt();
    
    int blackColor = N*N-A;
  
  	System.out.println(blackColor);
  }
}

Measured memory_bytes: 23380
n,m = map(int,input().split())
dp = [-1]*(n+1) 
dp[0] = 1
mod = 10**9 + 7
for i in range(m):
    a = int(input())
    dp[a-1] = 0
#print(dp)
for i in range(1,n+1):
    if dp[i] == 0:
        continue
    else:
        if i == 1:
            dp[i] = dp[i-1] +1
        else:
            dp[i] = (dp[i-1] + dp[i-2])%mod
        #print(dp)
print(dp[n-1])

Measured memory_bytes: 12796
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    vector<ll>a(n);
    ll xx = 0;
    REP(i,n){
        cin >> a[i];
        xx ^= a[i];
    }

    REP(i,n)cout << (xx^a[i]) << " ";
    cout << endl;
    
    return 0;
}

Measured memory_bytes: 4844
#include <bits/stdc++.h>
#include <time.h>
#include <assert.h>


using namespace std;



#define For(i,x,n)  for(long long i=x;i<n;i++)
#define rFor(i,x,n) for(long long i=x;i>=n;i--)
#define itFor(it,st)   for(auto it=st.begin() ; it!=st.end() ; it++)
#define MOD 1000000007
#define PI 3.141592653589793
#define INF 999999999999999999
#define N 1000005
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sp " "
#define cont continue
#define brk break

#define deb1(x)                cout<<#x<<": "<<x<<endl
#define deb2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define deb3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define deb4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define deb5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define deb6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl

using namespace std;

int main()
{
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed;
    cout<<setprecision(3);
    srand(time(NULL));

	ll a,b;
	cin>>a>>b;

	For(i,1,1001){
		ll p8 = i*0.08;
		ll p10 = i*0.1;
		if(p8==a and p10==b){
			cout<<i;
			return 0;
		} 
	}    
	cout<<"-1";
    
    //cout<<"\nTime used = "<<static_cast<double>(clock())/(CLOCKS_PER_SEC)<<"s"<<endl;  // - for checking time used for a test case
    return 0;
}

//s1.substr(1,3) - return 3 characters starting from position 1 as substring of string sz1. eg sz1="shreynumh" sz1.substr(2,5)="reyan"
//num = atoi(s.c_str()); //convert string s to integer num
//n.erase(i,std::string::npos); //erase i th position in string n , decreasing string size
//s.find(b)!= std::string::npos - finds string b in string a - true if found
//cout<<"Time used = "<<static_cast<double>(clock())/(CLOCKS_PER_SEC)<<"s"<<endl;  // - for checking time used for a test case                


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <utility>
#include <vector>
using namespace std;
typedef pair<string, int> PSI;

vector<PSI> read_str() {
    string s; int val;
    vector<PSI> ret;
    while(1) {
        cin >> s;
        if(s == "$") break;
        cin >> val;
        ret.push_back(make_pair(s, val));
    }
    return ret;
}

int main() {
    vector<PSI> A = read_str(), B = read_str(), C = read_str();
    int L = B.size(), N = A.size();

    for(int l=0; l<N-L+1; l++) {
        int r = l + L;
        bool ok = true;
        for(int k=l; k<r; k++) {
            int i = k-l;
            if(A[k].first != B[i].first) ok = false;

            // 端の要素
            if(k == l || k == r-1) {
                if(A[k].second < B[i].second) ok = false;
            }
            else {
                if(A[k].second != B[i].second) ok = false;
            }
        }

        if(ok) {
            // replace
            vector<PSI> tmp, ans;
            for(int i=0; i<N; i++) {
                // l == i のときにまとめてやってるから無視
                if(l < i && i < r) continue;
                if(r <= i || i < l) {
                    // 被ってないので普通に入れる
                    tmp.push_back(A[i]);
                }
                else {
                    if(L != 1) {
                        int diff = A[l].second - B[0].second;
                        if(diff > 0) {
                            PSI nxt1 = make_pair(A[l].first, diff);
                            tmp.push_back(nxt1);
                        }
                    }

                    int M = C.size();
                    for(int k=0; k<M; k++) {
                        tmp.push_back(C[k]);
                    }

                    
                    int diff = A[l+L-1].second - B[L-1].second;
                    if(diff > 0) {
                        PSI nxt2 = make_pair(A[l+L-1].first, diff);
                        tmp.push_back(nxt2);
                    }
                }
            }

            // 重複してるやつをどうにかする
            int S = tmp.size();
            ans.push_back(tmp[0]);
            for(int i=1; i<S; i++) {
                if(ans.back().first == tmp[i].first) {
                    ans.back().second += tmp[i].second;
                }
                else {
                    ans.push_back(tmp[i]);
                }
            }

            // こたえ
            for(auto e : ans) {
                printf("%s %d ", e.first.c_str(), e.second);
            }
            printf("$\n");
            return 0;
        }
    }
    // マッチしないのでそのまま出す
    for(auto e : A) {
        printf("%s %d ", e.first.c_str(), e.second);
    }
    printf("$\n");
    return 0;
}


Measured memory_bytes: 3440
from sys import stdin
from itertools import repeat
def main():
    n, m = map(int, stdin.readline().split())
    dat = map(int, stdin.read().split(), repeat(10, 2 * m))
    a = [0] + [2] * n
    a[1] = 1
    for i in xrange(m):
        x, y = dat[i*2], dat[i*2+1]
	if a[x] == 0:
            continue
        a[y] += 2
        if a[x] & 1 and a[y] & 1 ^ 1:
            a[y] -= 1
        a[x] -= 2
	if a[x] < 0:
            a[x] = 0
    print sum(x & 1 for x in a)
main()


Measured memory_bytes: 20080
#include <bits/stdc++.h>
using namespace std;
#define N 101
int n,m,p,t[N],x;
int main()
{
	scanf("%d",&n);
	int sum=0;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&t[i]);
		sum+=t[i];
	}
	scanf("%d",&m);
	for(int i=1;i<=m;i++)
	{
		scanf("%d%d",&p,&x);
		int tmp=sum;
		sum-=t[p];
		sum+=x;
		printf("%d\n",sum);
		sum=tmp;
	}
	return 0;	
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, l, r) for(register int i = l; i < r; i++)
#define hrp(i, l, r) for(register int i = l; i <= r; i++)
#define rev(i, r, l) for(register int i = r; i >= l; i--)
#define ms(n, t) memset(n, t, sizeof(n))
#define U 10050
#define pb push_back
#define int ll
#ifndef JOEON
#define D(...)
#define R(x, l)
#define sp
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
template<typename tn> inline tn next(void);
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v);
signed main(void)
{
	#ifdef JOEON
//		freopen("C:\\Users\\Joeon\\Desktop\\IN.txt", "r", stdin);
//		freopen("C:\\Users\\Joeon\\Desktop\\OUT.txt", "w", stdout);
	#endif
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout<<next<int>()*next<int>()<<endl;
	return 0;
}
template<typename tn> inline tn next(void)
{
	tn k;
	cin>>k;
	return k;
}
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v)
{
	rep(i, 0, v.size()) os<<v[i]<<' ';
	return os;
}


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

int solve(vector<int> D, int i){       //i := 現在の位置
    int n = D.size();
    if(i == n) return 0;

    int ret = 1e9;
    if(D[i]){
        int d = D[i];
        for(int j = i; j < n; j++){
            D[j] = (D[j] - d + 10) % 10;
            ret = min(ret, 1 + solve(D, i + 1));
        }

    }else{
        ret = min(ret, solve(D, i + 1));
    }

    return ret;
}

int main(){

    while(1){
        int n; cin >> n;
        if(!n) break;
        string s, t; cin >> s >> t;
        vector<int> D(n);
        for(int i = 0; i < n; i++){
            D[i] = (t[i] - s[i] + 10) % 10;
        }
        cout << solve(D, 0) << endl;
    }
   
}


Measured memory_bytes: 3016
#include <bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
using namespace std;
struct Dinic{
  const int INF=1<<28;
  
  struct edge {
    int to,cap,rev;
    edge(){}
    edge(int to,int cap,int rev):to(to),cap(cap),rev(rev){}
  };

  int n;
  vector<vector<edge> > G;
  vector<map<int,int> > M;
  vector<int> level,iter;

  Dinic(){}
  Dinic(int sz):n(sz),G(n),M(n),level(n),iter(n){}
  
  void add_edge(int from,int to,int cap){
    M[from][to]=G[from].size();
    M[to][from]=G[to].size();
    G[from].push_back(edge(to,cap,G[to].size()));
    // undirected
    //G[to].push_back(edge(from,cap,G[from].size()-1));
    // directed
    G[to].push_back(edge(from,0,G[from].size()-1));
  }
  
  void bfs(int s){
    fill(level.begin(),level.end(),-1);
    queue<int> que;
    level[s]=0;
    que.push(s);
    while(!que.empty()){
      int v=que.front();que.pop();
      for(int i=0;i<(int)G[v].size();i++){
        edge &e = G[v][i];
        if(e.cap>0&&level[e.to]<0){
          level[e.to]=level[v]+1;
          que.push(e.to);
        }
      }
    }
  }
  
  int dfs(int v,int t,int f){
    if(v==t) return f;
    for(int &i=iter[v];i<(int)G[v].size();i++){
      edge &e=G[v][i];
      if(e.cap>0&&level[v]<level[e.to]){
        int d = dfs(e.to,t,min(f,e.cap));
       if(d>0){
         e.cap-=d;
         G[e.to][e.rev].cap+=d;
         return d;
       }
      }
    }
    return 0;
  }
  
  int flow(int s,int t,int lim){
    int fl=0;
    for(;;){
      bfs(s);
      if(level[t]<0||lim==0) return fl;
      fill(iter.begin(),iter.end(),0);
      int f;
      while((f=dfs(s,t,lim))>0){
       fl+=f;
       lim-=f;
      }
    }
  }

  int flow(int s,int t){
    return flow(s,t,INF);
  }

  //cap==1 only
  bool back_edge(int s,int t,int from, int to){
    for(int i=0;i<(int)G[from].size();i++) {
      edge& e=G[from][i];
      if(e.to==to) {
        if(e.cap==0&&flow(from,to,1)==0) {
          flow(from,s,1);
          flow(t,to,1);
          return 1;
        }
      }
    }
    return 0;
  }
};
int main(){
  int n,m,x,N;
  while(cin>>n,n){
    map<int,int>M;
    cin>>N;
    r(i,N){
      cin>>x;
      M[x]=i;
    }
    Dinic d(N+n+2);
    r(i,N)d.add_edge(N+n,i,1);
    r(i,n)d.add_edge(N+i,N+n+1,1);
    r(i,n){
      cin>>m;
      r(j,m){
        cin>>x;
        if(M.count(x))d.add_edge(M[x],N+i,1);
      }
    }
    cout<<d.flow(N+n,N+n+1,1e8)<<endl;
  }
}


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

typedef pair<int,int> P;
#define ll long long
#define ld long double
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define sz(x) ((int)(x).size())
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
int main()
{
    ll x;
    cin >> x;
    ll shou = x/11;
    if(x%11==0)
    {
        cout << shou*2 << endl;
    }else
    {
        if(x%11>6)
        {
            cout << (shou+1)*2<< endl;
        }else
        {
            cout << 2*shou+1 << endl;
        }
        
    }
    

}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <math.h>
#include <vector>
#include <algorithm>
using namespace std;
 
long long lucas(int n){
	if(n == 0) return 2;
	else if(n == 1) return 1;
	else{
		long long tmp1 = 2, tmp2 = 1, ans = 0;
		for(int i = 2; i <= n; i++){
			ans = tmp1 + tmp2;
			tmp1 = tmp2;
			tmp2 = ans;
		}
		return ans;
	}
}
 
int main(){
	int n;
	cin >> n;
	cout << lucas(n) << endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static String Y = "Yes";
	public static String N = "No";
	public static String I = "IMPOSSIBLE";
	public static String B = "Bad";
	public static String G = "Good";
	public static long MOD = (long) (Math.pow(10, 9) + 7);
	public static Scanner sc = new Scanner(System.in);

	public static void main(String[] args) {

		long x = nl();
		long a = 0l;
		long b = 0l;

		for (int i = 0; i <= 1000; i++) {
			boolean flg = false;
			for (int j = 0; j <= 1000; j++) {
				a = (long) Math.pow(i, 5);
				b = (long) Math.pow(j, 5);

				if (a + b == x) {
					flg = true;
					a = i;
					b = j * (-1);
					break;
				}
				if (a - b == x) {
					flg = true;
					a = i;
					b = j;
					break;
				}
			}
			if (flg) {
				break;
			}
		}

		out(a + " " + b);

	}

	public static int count(String search, String text) {
		int nsearch = search.length();
		int ntext = text.length();
		int count = 0;

		for (int i = 0; i <= ntext - nsearch + 1; i++) {
			for (int j = i + nsearch - 1; j < ntext; j++) {
				if (search.equals(text.substring(i, j + 1))) {
					count++;
				}
			}
		}

		return count;
	}

	/*
	 * 以下メソッド集
	 */
	static int ni() {
		return sc.nextInt();
	}

	static long nl() {
		return sc.nextLong();
	}

	static String n() {
		return sc.next();
	}

	static char[] nc() {
		return sc.next().toCharArray();
	}

	static int kaijo(int n) {
		if (n == 0 || n == 1) {
			return 1;
		} else {
			return n * kaijo(n - 1);
		}
	}

	static int fib(int n) {
		return (n == 1 || n == 0) ? n : fib(n - 2) + fib(n - 1);
	}

	static long lcm(long m, long n) {

		return m * n / gcd(m, n);
	}

	static int lcm(int m, int n) {

		return m * n / gcd(m, n);
	}

	static long gcd(long a, long b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static int gcd(int a, int b) {
		return (b == 0) ? a : gcd(b, a % b);
	}

	static void out(String info) {
		System.out.println(info);
	}

	static void out(int info) {
		System.out.println(info);
	}

	static void out(double info) {
		System.out.println(info);
	}

	static void out(long info) {
		System.out.println(info);
	}

	static void out(char info) {
		System.out.println(info);
	}

	static void outn(String info) {
		System.out.print(info);
	}

	static void outn(int info) {
		System.out.print(info);
	}

	static void outn(double info) {
		System.out.print(info);
	}

	static void outn(long info) {
		System.out.print(info);
	}

	static void outn(char info) {
		System.out.print(info);
	}

	static int max(int a, int b) {
		return Math.max(a, b);
	}

	static long max(long a, long b) {
		return Math.max(a, b);
	}

	static int min(int a, int b) {
		return Math.min(a, b);
	}

	static long min(long a, long b) {
		return Math.min(a, b);
	}
}


Measured memory_bytes: 38784
#include <iostream>

using namespace std;



int main()
{
    int a,b,k,d,i=0;
    cin>>a>>b>>k;
    if(a>b)
        d=b;
    else
        d=a;
    while(d!=0)
    {
        if((a%d==0)&&(b%d==0))
        {
         //   cout<<d<<endl;;
            i++;
            if(k==i)
                break;
        }

            d--;
    }
    cout<<d;

    return 0;
}


Measured memory_bytes: 384
import java.util.*;

public class Main {

	public static void main(String[] args) {
		
		Scanner sc = new Scanner(System.in);
		String input;
		char a;
		while(true) {
			input = sc.nextLine();
			if (input.equals("0")) {
				break;
			}
			int sum=0;
			for (int i=0 ; i<input.length() ; i++) {
				a = input.charAt(i);
				sum += a-'0';
			}
			System.out.println(sum + "");
		}
	}

}


Measured memory_bytes: 26440
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		int M = in.nextInt();
		long[] A = new long[N];
		for (int i = 0; i < N; i++) {
			A[i] = in.nextLong();
		}
		Arrays.sort(A);
		long[][] BC = new long[M][2];
		for (int i = 0; i < M; i++) {
			BC[i][0] = in.nextLong();
			BC[i][1] = in.nextLong();
		}
		Arrays.sort(BC, (a, b) -> Long.compare(b[1], a[1]));

		long sum = 0;
		int index = 0;
		for (int i = 0; i < M; i++) {
			for (long j = 0; index < A.length && j < BC[i][0]; j++) {
				sum += Math.max(A[index], BC[i][1]);
				index++;
			}
		}

		for (int i = index; i < A.length; i++) {
			sum += A[i];
		}
		System.out.println(sum);
		in.close();
	}
}

Measured memory_bytes: 100520
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#define MAX(X, Y) (((X) > (Y))? (X) : (Y))
#define MIN(X, Y) (((X) < (Y))? (X) : (Y))
int compare_int(const void *a, const void *b){
  return *(long int*)b - *(long int*)a; // 大きい順
}
int compare_int_small(const void *a, const void *b){
  return *(long int*)a - *(long int*)b; // 小さい順
}
// 公約数
long long int gcd(long long int a, long long int b){
  if(b == 0){
    return a;
  }else{
    return gcd(b, a % b);
  }
}
// 最小公倍数 = a * b / 最大公約数
// 公倍数
long long int lcm(long long int a, long long int b){
  return a * b / gcd(a, b);
}

// 5min
int main(void){
  char s[11];
  int min = 100000000;

  scanf("%s", s);

  if(strlen(s) < 3){
    min = 753 - atoi(s);
  }else{
    for(int i = 0; i < strlen(s) - 2; i++){
      int ans = 0;
      int tmp = 0;
      char t;
      t = s[i];
      tmp = (t - '0') * 100;
      t = s[i + 1];
      tmp += (t - '0') * 10;
      t = s[i + 2];
      tmp += (t - '0');
      //      printf("tmp = %d s[0] = %c\n", tmp, s[i]);

      ans = 753 - tmp;

      if(ans < 0){
	ans *= (-1);
      }

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

  printf("%d\n", min);
  return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;

int main(void) {
    int K, ans=0;
    string S;

    cin >> K;
    cin >> S;

    string tmp;
    if(S.size()<=K){
      cout << S <<endl;
      return 0;
    }
    else{
      for(int i=0; i<K; i++){
        tmp += S[i];
     }
     tmp+="...";
    }


    cout << tmp << endl;

    return 0;
}


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

vector<ll> fct, invfct;

ll mod_pow(ll n, ll p, ll mod){
	if(p==0) return 1;
	
	ll ret = mod_pow(n*n%mod, p/2, mod);
	if(p%2==1) ret = ret * n % mod;
	return ret;
}

ll calc(ll x, ll n, ll mod){
	if(n>=mod || x==0){
		return 0;
	}else{
		return fct[x+n-1]*invfct[x-1] % mod;
	}
}

int main(){
	int Q;  cin >> Q;
	ll mod = 1000003;
	fct = vector<ll>(2*mod,1);
	invfct = vector<ll>(mod,1);
	for(int i=1; i<2*mod; i++){
		fct[i] = fct[i-1] * i % mod;
	}
	invfct[mod-1] = mod_pow(mod-1, mod-2, mod);
	for(int i=mod-2; i>=1; i--){
		invfct[i] = invfct[i+1]*(i+1) % mod;
	}
	
	while(Q--){
		ll x, d, n;  cin >> x >> d >> n;
		if(d==0){
			cout << mod_pow(x, n, mod) << endl;
		}else if(d==1){
			cout << calc(x, n, mod) << endl;
		}else{
			x = x * mod_pow(d, mod-2, mod) % mod;
			cout << mod_pow(d, n, mod)*calc(x, n, mod) % mod << endl;
		}
	}
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

signed main(){
    string s;cin>>s;
    for(char c='a';c<='z';c++){
        if(find(all(s),c)==s.end()){
            cout<<c<<endl;
            return 0;
        }
    }
    cout<<"None"<<endl;
    return 0;
}


Measured memory_bytes: 512
fn main() {
    proconio::input! {
        s: proconio::marker::Chars,
        t: proconio::marker::Chars,
    }
    let mut min = std::usize::MAX;
    for w in s.windows(t.len()) {
        let mut count = 0;
        for z in w.iter().zip(t.iter()) {
            if *z.0 != *z.1 {
                count += 1;
            }
        }
        if min > count {
            min = count;
        }
    }
    println!("{}", min);
}


Measured memory_bytes: 2132
N,M,X = map(int,input().split())
C = []
A = []
ans = 12*(10**5)+1
for _ in range(N):
    tmp = list(map(int,input().split()))
    C.append(tmp[0])
    A.append(tmp[1:])
#print(C)
#print(A)

for i in range(2**N):
    knowledge = [0]*M
    cost = 0
    for j in range(N):
        if (i>>j) & 1: # bit全探索
            cost += C[j]
            for k in range(M):
                knowledge[k] += A[j][k]
    if min(knowledge) >= X:
        ans = min(ans,cost)
if ans == 12*(10**5)+1:
    ans = -1
print(ans)

Measured memory_bytes: 9240
#include<stdio.h>

#define NIL -1

static const int MAX = 500;
static const int INFTY = (1<<21);

main(){
  int n, i, j,length,k,c,min,u,v;
  int M[MAX][MAX],pi[MAX],key[MAX],pass[MAX];

  scanf("%d", &n);
  for ( i = 0; i< n; i++ ){
    for ( j = 0; j < n; j++ ){
      M[i][j] = INFTY;
    }
  }

  for ( i = 0; i < n; i++ ){
    scanf("%d %d", &u, &k);
    for ( j = 0; j < k; j++ ){
      scanf("%d %d", &v, &c);
      M[u][v] = c;
    }
  }

  for(i=0;i<n;i++){
    key[i]=INFTY;
    pi[i]=NIL;
    pass[i]=0;
  }
  key[0]=0;
  
  while(length!=NIL){
    min=INFTY;
    length=NIL;
    for(i=0;i<n;i++){
      if (key[i]<min && pass[i]!=1){
	length=i;
	min=key[i];
      }
    }
    pass[length]=1;   
    for(i=0;i<n;i++){
      if(M[length][i]+key[length]<key[i] && pass[i]!=1){
	key[i]=M[length][i]+key[length];
	pi[i]=length;
      }
    }
  }
  
  for ( i = 0; i < n; i++ ){
    printf("%d %d\n", i, (key[i]==INFTY?-1:key[i]));
  }

  return 0;
}

Measured memory_bytes: 804
#include <bits/stdc++.h>
#define pb push_back
typedef long long ll;
using namespace std;
int ans=0;
int main()
{
	ios::sync_with_stdio(false);
	string a;
	cin>>a;
	for (int i=0;i<a.size()/2;i++)
	{
		if (a[i]!=a[a.size()-1-i])
		{
			ans++;
		}
	}
	cout<<ans;
	return 0;
}


Measured memory_bytes: 256
N,A,B,C= map(int,input().split())
l = []
for i in range(N):
    l.append(int(input()))

def solve(w,x,y,z):
    if w == N:
        if min(x,y,z)>0:
            return abs(x-A) + abs(y-B) + abs(z-C) -30
        else: 
            return 10e4
    can0 = solve(w + 1,x,y,z)
    can1 = solve(w + 1,x + l[w],y,z) + 10
    can2 = solve(w + 1,x,y + l[w],z) + 10
    can3 = solve(w + 1,x,y,z + l[w]) + 10
    return min(can0,can1,can2,can3)

print(solve(0,0,0,0))




Measured memory_bytes: 3064
{-
n+m=o
余事象使って
全ての組み合わせ o(o-1)/2
奇数になるのは偶数と奇数 n*m
-}

main = do
  li <- getLine
  let [n,m] = map read $ words li
  let ans = compute n m
  print ans

compute :: Int -> Int -> Int
compute n m = o * pred o `div` 2 - n * m
  where
    o = n + m


Measured memory_bytes: 508
#!/usr/bin/env python

import sys

n,x = [ int(x) for x in sys.stdin.readline().split() ]
lall= [ int(x) for x in sys.stdin.readline().split() ]

now  = 0
bound= 1
for li in lall:
    now+= li
    if now<=x: bound+=1
    else: break
#
print( bound )


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int n,x,t; cin >> n >> x >> t;
  int sum = 0;
  if(n % x == 0)
    sum = t * (n / x);
  else
    sum = t * (n / x + 1);
  cout << sum << endl;
}

Measured memory_bytes: 3600
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include <numeric>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999

using namespace std;


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





ll gcd(ll x, ll y) {
	ll m = max(x, y), n = min(x, y);
	if (m%n == 0)return n;
	else return gcd(m%n, n);
}

int main() {
	string S;
	cin >> S;
	ll l = S.length();
	int h = l / 2;
	bool ok = true;
	int cnt = 1;
	while (ok) {
		if (l % 2 == 1){
			char a = S[h];
			int k = 1;
			while(k<=h){
				if (S[h - k] != a || S[h + k] != a) {
					cout << h + k << endl;
					return 0;
				}
				k++;
			}
			cout << l << endl;
			return 0;
		}
		if (l % 2 == 0) {
			char a = S[h];
			char b = S[h - 1];
			if (a != b) {
				cout << h << endl;
				return 0;
			}
			int k = 1;
			while (k <= h) {
				if (S[h - 1] != S[h - 1 - k] || S[h] != S[h + k]) {
					cout << h + k << endl;
					return 0;
				}
				k++;
			}
			cout << l << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 512
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>
#include<cmath> 
using namespace std;
char a[10001],b[10001]; 
int main()
{
	scanf("%s",a+1);
	scanf("%s",b+1);
	for(int i=1;i<=strlen(a+1)+strlen(b+1);i++)
	{
		if(i%2==0)printf("%c",b[i/2]);
		else printf("%c",a[(i+1)/2]);
	}
	printf("\n"); 
}

Measured memory_bytes: 128
def n0():return int(input())
def n1():return [int(x) for x in input().split()]
def n2(n):return [int(input()) for _ in range(n)]
def n3(n):return [[int(x) for x in input().split()] for _ in range(n)]
 
import itertools
n,m,q=n1()
s=n3(q)

Alist=list(itertools.combinations_with_replacement(range(1,m+1), n))
ans=0
for A in Alist:
    tmp=0
    for r in s:
        if A[r[1]-1]-A[r[0]-1]==r[2]:
            tmp+=r[3]
    ans=max(ans,tmp)
print(ans)

Measured memory_bytes: 21548
'use strict'

const main = (input) => {
    input = input.split('\n')
    const N = parseInt(input[0])
    const lr = input.slice(1, N + 1)
    let arr = []
    for(let i = 0; i <= 9999; i++){
        arr[i] = false
    }
    lr.forEach((v, i) => {
        let l = parseInt(v.split(' ')[0] - 1)
        let r = parseInt(v.split(' ')[1] - 1)
        for(let i = l; i <= r; i++){
            arr[i] = true
        }
    })

    console.log(arr.filter(v => v === true).length)
}

main(require('fs').readFileSync('/dev/stdin', 'utf-8'))

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

#define PI acos(-1)
#define _fastIO ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MOD 1000000007
#define mxx 1000000
#define all(v) v.begin(),v.end()

using namespace std;
typedef long long ll;

int tc;


void solve(){

   map<int,int>mp;
   ll n,q,x,y,sum=0;
   cin>>n;
   for(int i=1; i<=n; i++){
        cin>>x;
        mp[x]++;
        sum+=x;
   }
   cin>>q;
   while(q--){
        cin>>x>>y;
        sum-=mp[x]*x;
        sum+=mp[x]*y;
        mp[y]+=mp[x];
        mp[x]=0;
        cout<<sum<<endl;
   }

}

int main()
{

    _fastIO;

    //cin>>tc; while(tc--)
    solve();

    return 0;
}


Measured memory_bytes: 8076
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

int main(){
  int N,K;
  cin >> N >> K;
  vector<pair<ll,int>> vec(N);
  for(int i=0;i<N;i++) cin >> vec[i].second >> vec[i].first;

  sort(vec.begin(),vec.end());
  reverse(vec.begin(),vec.end());

  ll sum=0;
  map<int,int> mp;
  vector<ll> opt;
  for(int i=0;i<K;i++){
    if(mp[vec[i].second] == 0){
      mp[vec[i].second] = 1;
    }else{
      opt.push_back(vec[i].first);
    }
    sum+=vec[i].first;
  }

  int pos = opt.size()-1;
  ll sz = mp.size();
  ll ans = sum + sz*sz;
  for(int i=K;i<N;i++){
    if(sz == K) break;
    if(mp[vec[i].second]==1) continue;

    mp[vec[i].second] = 1;
    sz++;
    sum-=opt[pos];
    sum+=vec[i].first;
    pos--;

    ans=max(ans,sum+sz*sz);
  }
  cout << ans <<endl;
  return 0;
}


Measured memory_bytes: 5116
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<queue>
using namespace std;

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    int ans=0;
    int abc=max({a,b,c});
    a=abc-a;
    b=abc-b;
    c=abc-c;
    
    ans+=a/2;a=a%2;
    ans+=b/2;b=b%2;
    ans+=c/2;c=c%2;
    if(a+b+c==2){
        ans++;
    }else if(a+b+c==1){
        ans+=2;
    }else{
        
    }
    cout<<ans<<endl;
    
    
    
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
   
using namespace std;
#define ll long long
#define ld long double
#define pll pair<long long,long long>
#define vll vector<long long>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define deb(x) cout << #x << "=" << x << endl
#define F(i,a,b) for(ll i=a;i<=b;i++)
#define RF(i,a,b) for(ll i=a;i>=b;i--)
#define in(a,n) F(i,0,n-1)cin>>a[i]
#define vi vector<int>
#define out(a,n) F(i,0,n-1)cout<<a[i]<<" ";cout<<endl
#define mod 1000000007
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define int long long




void solve()
{
    string s;
    cin>>s;
    int ans=0,c=0;
    for(auto x:s)
    {
        if(x=='R')c++;
        else 
        {
            ans=max(ans,c);
            c=0;
        }
    }
    ans=max(ans,c);
    cout<<ans;
    
    
}

int32_t main()
{
	ios::sync_with_stdio(false);
    cin.tie(NULL);
    
	int t=1;
//	cin>>t;
	while(t--)solve();
	    
   
}

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

int main() {
 int n,sum=0;cin >> n;
 vector<int> x(n);

 rep(i,n){
   cin >> x[i];
   sum+=x[i];
 }
 double mean =(double)sum/(double)n;
 double meanint=sum/n;
 double meanfloat=mean-(double)meanint;
 double mean1;
 if(meanfloat >=0.5)mean1=ceil(mean);
 else mean1=floor(mean);

long long ans=0;
rep(i,n){
  ans+=pow((x[i]-mean1),2);
}



 cout << ans << endl;


}

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

const ll mod = 1e9 + 7;
const ll INF = -1 * ((1LL << 63) + 1);
const int inf = -1 * ((1 << 31) + 1);

using namespace std;

vector<ll> a,b;
set<pair<ll,ll>>st;
set<pair<ll,ll>>used;
ll H,W,N;

int f(int x,int y){
    // 左上がx,yの3*3の正方形の中に含まれる黒い点のかずをかえす
    if(used.count({x,y}))return 0;
    used.insert({x,y});

    int ret = 0;
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            if(st.count({x+i,y+j}))ret++;
        }
    }
    return ret;
}

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    cin >> H >> W >> N;
    
    a.resize(N);
    b.resize(N);
    rep(i,N){
        cin >> a[i] >> b[i];
        a[i]--;b[i]--;
        st.insert({a[i],b[i]});
    }
    vector<ll> cnt(10,0); // cnt[i] := 3*3の中に黒い点がi個ある正方形の個数
    rep(i,N){
        // ある点(a[i],b[i])について、{a[i],b[i]}を含むような正方形は左上の座標が
        // a[i]-2,b[i]-2 から始まって a[i],b[i]にくるんで
        int sx = a[i] - 2;
        int sy = b[i] - 2;
        for(int x = 0 ; x < 3 ; x ++ ){
            for(int y = 0 ; y < 3 ; y ++ ){
                int nx  = sx + x;
                int ny  = sy + y;
                if( nx < 0 || ny < 0 || nx + 2 >= H || ny + 2 >= W) continue;
                cnt[f(nx,ny)] ++ ;
            }
        }
    }
    ll ans = (H-2)*(W-2);
    rep(i,9)ans -= cnt[i+1];
    cnt[0] = ans;
    rep(i,10)cout << cnt[i] << endl;
}

Measured memory_bytes: 64384
#include <stdio.h>

int main(void)
{
   int N;
   int A[210];
   int counter[210];

   scanf("%d", &N);

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

   for(int i = 0; i < N; i++)
   {
   	counter[i] = 0;
   	while(A[i] % 2 == 0)
   	{
   		A[i] = A[i] / 2;
   		counter[i]++;
  	}
   }
   
   int min = counter[0];

   for(int i = 1; i < N; i++)
   {
   	if(min > counter[i])
		min = counter[i];
   }

   printf("%d", min);

   return 0;
}


Measured memory_bytes: 2084
#include<iostream>
#include<vector>
#include<algorithm>
#include<tuple>
#include<utility>
#include<string>
#define ll long long
using namespace std;

int main(){
    int N,M,Q;
    int ans = 0;
    cin >> N >> M >> Q;
    vector<int> A(N+5);
    vector<int> v(4+5,0);
    vector< vector<int> > S(Q+5,v);
    for (int i = 0; i < Q; i++){
        cin >> S[i][0] >> S[i][1] >> S[i][2] >> S[i][3];
    }    
    for(A[0]=1; A[0]<=M; A[0]++){
        for(A[1]=A[0]; A[1]<=M; A[1]++){
            for(A[2]=A[1]; A[2]<=M; A[2]++){
                for(A[3]=A[2]; A[3]<=M; A[3]++){
                    for(A[4]=A[3]; A[4]<=M; A[4]++){
                        for(A[5]=A[4]; A[5]<=M; A[5]++){
                            for(A[6]=A[5]; A[6]<=M; A[6]++){
                                for(A[7]=A[6]; A[7]<=M; A[7]++){
                                    for(A[8]=A[7]; A[8]<=M; A[8]++){
                                        for(A[9]=A[8]; A[9]<=M; A[9]++){
                                            int tmp = 0;
                                            for (int i = 0; i < Q; i++){
                                                int e = S[i][0];
                                                int f = S[i][1];
                                                int g = S[i][2];
                                                int h = S[i][3];
                                                if(A[f-1] - A[e-1] == g){
                                                    tmp += h;
                                                }
                                            }                                            
                                            ans = max(ans, tmp);
                                        }
                                    }
                                }   
                            }
                        }
                    }
                }   
            }
        }
    }
    cout << ans << endl;
}

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

int lr(char a){
	//l = 0, r = 1
	if(a == 'q') return 0;
	else if(a == 'w') return 0;
	else if(a == 'e') return 0;
	else if(a == 'r') return 0;
	else if(a == 't') return 0;
	
	else if(a == 'a') return 0;
	else if(a == 's') return 0;
	else if(a == 'd') return 0;
	else if(a == 'f') return 0;
	else if(a == 'g') return 0;
	
	else if(a == 'z') return 0;
	else if(a == 'x') return 0;
	else if(a == 'c') return 0;
	else if(a == 'v') return 0;
	else if(a == 'b') return 0;
	else return 1;
}

int main(){
while(1){	
	
	string s;
	int cnt = 0;
	cin >> s;
	if(s == "#") break;
	int len = s.size();
	int past = lr(s[0]);
	for(int i = 1; i < len; i++){
		if(past != lr(s[i])) cnt += 1;
		past = lr(s[i]);
	}
	
	cout << cnt << endl;
	
}//end
	return 0;
}


Measured memory_bytes: 3144
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP2D(a, n, m) REP(i, n) REP(j, m) printf("%lld%c", a[i][j], j + 1 == m ? '\n' : ' '); puts("")

typedef long long ll;

//------------------------------------------------------------------------------
ll mod_pow(ll x, ll n, ll mod) {
  ll res = 1;
  while (n > 0) {
    if (n & 1) {
      res = res * x % mod;
    }
    x = x * x % mod;
    n >>= 1;
  }
  return res;
}

ll mod_inverse(ll x, ll mod) {
  return mod_pow(x, mod - 2, mod);
}

//------------------------------------------------------------------------------
const int N_MAX = 5000;
const int MOD = 1e9+7;

int N;
char s[N_MAX + 1];

int M;
ll dp[N_MAX + 1][N_MAX + 1];

void solve() {
  dp[0][0] = 1;
  REP(i, N) FOR(j, 0, N) {
    // printf("i: %d, j: %d, k: %d\n", i, j, k);
    int j1 = max(j - 1, 0);
    dp[i + 1][j1] = (dp[i + 1][j1] + dp[i][j]) % MOD;         // BS
    dp[i + 1][j + 1] = (dp[i + 1][j + 1] + dp[i][j]) % MOD;   // 0
    dp[i + 1][j + 1] = (dp[i + 1][j + 1] + dp[i][j]) % MOD;   // 1
  }

  // DUMP2D(dp, N + 1, N + 1);

  ll b = mod_pow(2, M, MOD);
  ll ans = dp[N][M] * mod_inverse(b, MOD) % MOD;
  printf("%lld\n", ans);
}


void input() {
  scanf("%d", &N);
  scanf("%s", s);
  M = strlen(s);
}

int main() {
  input();
  solve();
  return 0;
}


Measured memory_bytes: 195584
N, L=map(int,input().split())
tar=0
for i in range(N):
    tar += L + i
ANS = []
for i in range(N):
    ANS.append(tar - (L + i))
ans = 1000000
tmp2 = 1000000
for a in ANS:
    tmp = abs(tar - a)
    if tmp < tmp2:
        ans = a
        tmp2 = tmp
print(ans)


Measured memory_bytes: 3060
#!usr/bin/env python3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.buffer.readline().split()]
def I(): return int(sys.stdin.buffer.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n,k = LI()
    g = LIR(n)
    l = list(set(([i for (i,j) in g])))
    g.sort(key=lambda x:-x[1])
    l.sort()
    q = []
    q2 = []
    f = [0]*len(l)
    ans = 0
    res = k
    for i in range(n):
        t,d = g[i]
        g[i][0] = t = bisect.bisect_left(l,t)
        if res:
            f[t] += 1
            ans += d
            res -= 1
            if f[t] > 1:
                heappush(q,(d,t))
        else:
            heappush(q2,(-d,t))
    x = sum([i >= 1 for i in f])
    ans += x**2
    s = ans
    while q2 and q:
        d,t = heappop(q2)
        d *= -1
        if f[t]:
            continue
        else:
            nd,nt = heappop(q)
            s -= nd
            s += 2*x+1
            s += d
            x += 1
            f[t] = 1
            f[nt] -= 1
            if ans < s:
                ans = s
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()


Measured memory_bytes: 82780
#include <iostream>
#include <stack>
#include <vector>

using namespace std;

const int maxn = 100000;
const int NIL = -1;

vector <int> G[maxn];
int n;
int color[maxn];

void DFS(int r,int c)
{
    stack <int> S;
    S.push(r);
    color[r] = c;
    while(!S.empty())
    {
        int u = S.top();S.pop();
        for(int i=0;i<G[u].size();i++)
        {
            int v = G[u][i];
            if(color[v]==NIL)
            {
                color[v] = c;
                S.push(v);
            }
        }
    }
}

void assignColor()
{
    int id = 1;
    for(int i=0;i<n;i++)
        color[i] = NIL;
    for(int u=0;u<n;u++)
    {
        if(color[u]==NIL)
            DFS(u,id++);
    }
}

int main()
{
    int s,t,m,q;
    cin >> n >> m;
    for(int i=0;i<m;i++)
    {
        cin >> s >> t;
        G[s].push_back(t);
        G[t].push_back(s);
    }//邻接表

    assignColor();

    cin >> q;
    for(int i=0;i<q;i++)
    {
        cin >> s >> t;
        if(color[s]==color[t])
        {
            cout << "yes" << endl;
        }else{
            cout << "no" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 8952
import bisect
 
a, b, q = map(int, input().split())
s = [float('-inf')] + [int(input()) for _ in range(a)] + [float('inf')]
t = [float('-inf')] + [int(input()) for _ in range(b)] + [float('inf')]
 
 
for _ in range(q):
    
    x = int(input())
    
    s_index = bisect.bisect_right(s, x)
    s_right = s[s_index]
    s_left = s[s_index - 1]
    t_index = bisect.bisect_right(t, x)
    t_right = t[t_index]
    t_left = t[t_index - 1]
    
    ans = float('inf')
    
    # 最初に寺を訪れる場合
    ans = min(
        ans, 
        abs(x - s_right) + min(abs(s_right - t_right), abs(s_right - t_left)), 
        abs(x - s_left) + min(abs(s_left - t_right), abs(s_left - t_left)), 
    )
    # 最初に神社を訪れる場合
    ans = min(
        ans, 
        abs(x - t_right) + min(abs(t_right - s_right), abs(t_right - s_left)), 
        abs(x - t_left) + min(abs(t_left - s_right), abs(t_left - s_left)), 
    )
        
    print(ans)

Measured memory_bytes: 14608
#include<iostream>
#include<cstdio>
#include<vector>
#include<stack>
#include<algorithm>
#include<functional>
#include<string>
#include<cstring>
#include<cmath>
#include<utility>
#include<cstdlib>
#include<map>
#include<set>
#include<sstream>
#include<bitset>
#include<queue>
using namespace std;
typedef long long int ll;
const int INF=1000000000;
ll n,T;
ll ans;
string f;

int main()
{
  ans=0;
  cin>>n>>T;
  cin>>f;
  for(int i=0;i<f.size();i++)
    {
      ll temp=0;
      if('0'<=f[i]&&f[i]<='9')
        {
          temp=1;
          for(int j=0;j<f[i]-'0';j++)
            {
              temp*=n;
              if(temp>INF)
                {
                  cout<<"TLE"<<endl;
                  return 0;
                }
            }
          ans+=temp*T;
 
          if(ans>INF)
            {
              cout<<"TLE"<<endl;
              return 0;
            }
        }
    }
  if(ans<=INF)
    {
      cout<<ans<<endl;
    }
  else cout<<"TLE"<<endl;
  return 0;
}

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

int x;

int main()
{
    int res = 0;
    while(cin >> x)
    {
        res = 0;
        while(x)
        {
            if(x % 10 == 2)
                res++;
            x /= 10;
        }

        cout << res << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<string.h>
#define ll long long 
#include<vector>
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
using namespace std;
const int mod=1e9+7;
int main(){
	IOS;
	int n;
	double d;
	cin>>n>>d;
	d*=d;
	
	int ans=0;
	double x,y;
	for(int i=0;i<n;i++)
	{
		cin>>x>>y;
		if(x*x+y*y<=d)
		ans++;
	}
	cout<<ans;
}

Measured memory_bytes: 3728
# 幅優先探索（行きがけ）
import collections
import sys
import math


def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())


def main():
    X, N = LI()
    PArry = LI()
    ans = float("inf")
    sa = float("inf")
    for i in range(-N, N+1):
        a = X+i
        if a in PArry:
            continue
        s = abs(X-a)
        if sa == s:
            ans = min(ans, a)
        if s < sa:
            ans = a
            sa = s

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 9472
import java.util.Scanner;

public class Main {

	void main() {
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt();
		int c = sc.nextInt();
		int[][] table = new int[r+1][c+1];
		for(int i=0;i<r;i++) {
			for(int j=0;j<c;j++) {
				table[i][j] = sc.nextInt();
				}
		}
		for(int i=0;i<r;i++) {
			for(int j=0;j<=c;j++) {
				if(j!=c) {
					table[i][c] += table[i][j];
				}
				table[r][j] += table[i][j];
			}
		}
		for(int i=0;i<=r;i++) {
			for(int j=0;j<=c;j++) {
				if(j==0) {
					System.out.print(table[i][j]);
				}else {
					System.out.print(" "+table[i][j]);
				}
			}
			System.out.println();
		}
		
	}
	
	public static void main(String[] args) {
		new Main().main();
	}

}





Measured memory_bytes: 41312