akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.readline
D = int(input())
C = list(map(int,input().split()))
S = [list(map(int,input().split())) for i in range(D)]
T = [int(input()) for i in range(D)]
M = int(input())
DQ = [tuple(map(int,input().split())) for i in range(M)]

score = 0
lasts = [[0] for i in range(26)]
for i,(s,a) in enumerate(zip(S,T)):
    score += s[a-1]
    lasts[a-1].append(i+1)
for j in range(26):
    lasts[j].append(D+1)

for j,(c,ls) in enumerate(zip(C,lasts)):
    for a,b in zip(ls,ls[1:]):
        score -= c * (b-a)*(b-a-1)//2

from bisect import bisect
for d,q in DQ:
    p = T[d-1]
    T[d-1] = q
    score += (S[d-1][q-1] - S[d-1][p-1])
    for a,b in zip(lasts[p-1],lasts[p-1][1:]):
        score += C[p-1] * (b-a)*(b-a-1)//2
    for a,b in zip(lasts[q-1],lasts[q-1][1:]):
        score += C[q-1] * (b-a)*(b-a-1)//2
    i = lasts[p-1].index(d)
    del lasts[p-1][i]
    i = bisect(lasts[q-1], d)
    lasts[q-1].insert(i,d)
    for a,b in zip(lasts[p-1],lasts[p-1][1:]):
        score -= C[p-1] * (b-a)*(b-a-1)//2
    for a,b in zip(lasts[q-1],lasts[q-1][1:]):
        score -= C[q-1] * (b-a)*(b-a-1)//2
    print(score)

Measured memory_bytes: 17340
#include <iostream>
#include <algorithm>
#include <climits>
#include <vector>
#include <stack>
using namespace std;
int main(int argc, char *argv[])
{
  stack<int> st;
  string input;
  int stack_num = 1;
  int ans_num = 0;
  int right_num = 0;
  int left_num = 0;
  int temp = 0;
  getline(cin, input); 
  // cout << input << "\n";

  for (int i = 0; i < input.size(); i++) {
    stack_num = 1;
    // cout << input[i] << "\n";
    if ('0' <= input[i] && input[i] <='9' || ((input[i] == '-') && ('0' <= input[i] && input[i] <='9'))) {
      if (input[i] == '-') {
	stack_num = 1*-1;
      }else {
	stack_num = stack_num*(input[i] - '0');	
      }

      while (true) {
	i = i+1;
	if (!('0' <= input[i] && input[i] <='9')) {
	  break;
	}
	stack_num = stack_num*10+(input[i]-'0');
      }
      // cout <<"aa" <<stack_num << "\n";
      
      st.push(stack_num);
    }else if(input[i] == ' '){
      
    }else {
      right_num = st.top();
      st.pop();
      left_num = st.top();
      st.pop();
      switch (input[i]) {
      case '+': {
	temp = left_num+right_num;
	break;
      }
      case '-': {
	temp = left_num - right_num;
	break;
      }
      case '*': {
	temp = left_num * right_num;
	break;
      }
      case '/': {
	temp = left_num / right_num;
	break;
      }
default:
	break;
      }
      // cout << ans_num << "\n";
      ans_num = temp;
      st.push(ans_num);
    }


  }
  cout << ans_num << "\n";
  return 0;
}



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

int main() {
  string s;
  cin >> s;
  //a-zにつきsに何回出現するか数える
  //奇数回だった時点で終了 (even = false)
  bool even = true;
  for (char x='a'; x<='z'; x++){
    int count = 0;
    for (int i=0; i<s.size(); i++){
      if (s.at(i)==x)
        count++;
    }
    if (count % 2 == 1){
      even = false;
      break;
    }
  }
  if (even)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int n;
    cin >> n;
    int h[n];
    rep(i, 0, n) cin >> h[i];
    int ans = 0;
    int tmp = 0;
    rep(l, 0, n - 1) {
        if (h[l] >= h[l + 1]) {
            tmp++;
            if (l == n - 2) ans = max(ans, tmp);
        } else {
            ans = max(ans, tmp);
            tmp = 0;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>

int main()
{
  int a,b,c,d;
  scanf("%d %d %d %d",&a,&b,&c,&d);
  
  while(1){
    c=c-b;
    if(c<=0){
      printf("Yes");
      break;
    }
    a=a-d;
    if(a<=0){
      printf("No");
      break;
    }
  }
  return 0;
}

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

#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); i--)
#define ITER(it, a) for(typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))

#define SZ(a) (int) a.size()
#define ALL(a) a.begin(),a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const LL INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int MOD = 1000 * 1000 * 1000 + 7;
const int MAX = 111;

int DP[MAX][MAX][MAX];
int A[MAX];

void ADD(int& x, int val)
{
	x += val;
	if (x >= MOD) x -= MOD;
}

int main()
{
	//freopen("in.txt", "r", stdin);
	//ios::sync_with_stdio(false); cin.tie(0);

	int n;
	scanf("%d", &n);

	FOR (i, 0, n * 2 - 1)
	{
		scanf("%d", &A[i]);
	}

	sort(A, A + n * 2 - 1);

	DP[0][1][0] = 1;

	FOR (i, 0, n)
	{
		FOR (j, 0, n*2)
		{
			FOR (k, 0, j)
			{
				if (DP[i][j][k] == 0) continue;

				int total = j;
				int index = k;

				int pos = n - i - 2;
			//	cout<<"! "<<pos<<endl;
				if (pos >= 0)
				{
					if (A[pos] != A[pos+1]) total++, index++;
				}

				pos += 2 * (i + 1);

			//	cout<<"! "<<pos<<endl;
				if (pos < 2 * n - 1)
				{
					if (A[pos] != A[pos - 1]) total++;
				}

			//	cout<<i<<' '<<j<<' '<<k<<": "<<total<<' '<<index<<' '<<DP[i][j][k]<<endl;

				FOR (s, 0, total)
				{
					int tot = total;
					int ind = index;

					int ts = s;
					if (ts > ind) ts = ind + 1;

					if (abs(s - ind) > 1) tot -= abs(s - ind) - 1;

					ADD(DP[i+1][tot][ts], DP[i][j][k]);
				}
			}
		}
	}

	int res = 0;
	FOR (j, 0, n*2)
	{
		FOR (s, 0, j)
		{
			ADD(res, DP[n-1][j][s]);
		}
	}

	cout<<res<<endl;

}


Measured memory_bytes: 3200
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
int main() {
	int a, b, k;
	cin >> a >> b >> k;
    for (int i = 0; i < k&&a+i<=b; i++) {
		cout << a + i << endl;
    }
	for (int j = k-1; j >= 0; j--) {
		if (b - j <= a + k - 1) {
			goto loop1;
		}
		else {
			cout << b - j << endl;
		}
	loop1:;
	}
	int x;
	cin >> x;
    return 0;
}

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

int top,S[100];

void push(int a){
  S[++top] = a;
}

int pop(){
  int ans;
  top--;
  ans = S[top+1];
  return ans;

}

int main(){

  int s,t,u,i;
  top = 0;
  char array[1000000];

  while(1)
    {

      if( scanf("%s", &array[0]) == EOF ) break;

      if ( array[0] == '+' ){
        s = pop();
        t = pop();
        push(s + t);
      }
      else if ( array[0] == '-' ){
        t = pop();
        s = pop();
        push(s - t);
      }
      else if ( array[0] == '*' ){
        s = pop();
        t = pop();
        push(s * t);
      }
 else {
        u = atoi(array);
        push(u);
      }
    }
  printf("%d\n", pop());

  return 0;
}

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

int main() {
    int N;
    string A;
    string B;
    string C;
    cin >> N;
    cin >> A;
    cin >> B;
    cin >> C;

    int count = 0;
    for (int i = 0; i < N; i++) {
        char a = A[i];
        char b = B[i];
        char c = C[i];
        if (a == b && b == c) {
            count = count;
        } else if (a == b || b == c || c == a) {
            count = count + 1;
        } else {
            count = count + 2;
        }
    }

    cout << count << endl;

	return 0;
}


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)throws IOException{
		int count = 0;
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String inputData = br.readLine();
		String[] inputValue = inputData.split(" ");

		int a = Integer.parseInt(inputValue[0]);
		int b = Integer.parseInt(inputValue[1]);
		int c = Integer.parseInt(inputValue[2]);

		for(int i = a; i <= b; i ++){
			int divisor = c % i;
			if(divisor == 0){
				count ++;
			}
		}

		System.out.println(count);
	}

}

Measured memory_bytes: 24352
function main()
	N,K=map(x->parse(Int,x),split(readline()))
	A=sort(map(x->parse(Int,x),split(readline())))
	fac=ones(Int,N+1)
	M=10^9+7
	for i=1:N
		fac[i+1]=fac[i]*i%M
	end
	ans=0
	for i=K:N
		ans+=(A[i]-A[N-i+1])*fac[i]%M*powermod(fac[i-K+1]*fac[K]%M,M-2,M)%M
		ans%=M
	end
	println(ans)
end
main()


Measured memory_bytes: 216232
var
  s:string;
  k:qword;
  i:longint;
begin
  readln(s);
  read(k);
  for i:=1 to length(s) do
    if (s[i]<>'1') or (i=k) then
      begin
        write(ord(s[i])-48);
        break;
      end;
end.

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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1010;

ll H, W, n;

map<int, set<pair<int,int>>> mp;


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

  cin>>H>>W>>n;
  for (int i=0; i<n; i++) {
    int a, b; cin>>a>>b;
    //g[a-1][b-1]++;
    mp[a].insert({b,1});
  }

  // for (int i=0; i<H; i++) {
  //   for (int j=0; j<W; j++) {
  //     cout<<g[i][j]<<" ";
  //   }
  //   cout<<endl;
  // }


  map<int, set<pair<int,int>>> _mp = mp;

  for (auto& p: mp) {
    int a = p.first;
    for (auto& x: p.second) {
      int b = x.first;
      for (int i=-2; i<=2; i++) {
	for (int j=-2; j<=2; j++) {
	  int da = a+i; int db = b+j;
	  if (da<=0 || da>H || db<=0 || db>W) continue;
	  if (_mp[da].count({db,1})) continue;
	  _mp[da].insert({db,0});
	}
      }
    }
  }

  swap(mp, _mp);
  ll all = (H-2)*(W-2);
  vector<ll> freq(10, 0);

  for (auto& p: mp) {
    int a = p.first;
    if (a+2>H) continue;
    for (auto& q: p.second) {
      int b = q.first;
      if (b+2>W) continue;

      int cnt = 0;
      for (int i=0; i<3; i++) {
	for (int j=0; j<3; j++) {
	  int da = a+i; int db = b+j;
	  if (!mp.count(da)) continue;
	  if (mp[da].count({db,1})) cnt++;
	}
      }
      //cout<<a<<" "<<b<<": "<<cnt<<endl;
      if (cnt) freq[cnt]++;
    }
  }

  // cout<<endl;
  // for (int i=0; i<H; i++) {
  //   for (int j=0; j<W; j++) {
  //     cout<<g[i][j]<<" ";
  //   }
  //   cout<<endl;
  // }


  for (int i=1; i<=9; i++) {
    all -= freq[i];
  }

  freq[0] = all;

  for (ll x: freq) {
    cout<<x<<endl;
  }

  return 0;
}


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

int N, A[100009], S;
bitset<4000009>I, J;

int main() {
	cin >> N;
	for (int i = 1; i <= N; i++) { cin >> A[i]; S += A[i]; }
	I.set(0);
	for (int i = 1; i <= N; i++) {
		J = (I << A[i]);
		I |= J;
	}
	for (int i = (S + 1) / 2; i <= S; i++) {
		if (I[i]) { cout << i << endl; break; }
	}
	return 0;
}

Measured memory_bytes: 2176
#include <iostream>

using namespace std;

int main(){
  int x,y;

  while(1){
    cin >> x >> y;
    if(x == 0 && y == 0) break;
    if(x>y){
      swap(x,y);
    }
    cout << x << ' ' <<  y << endl;
  }
  return 0;
}



Measured memory_bytes: 3068
#include<iostream>
#include<string>
#include<sstream>
#include<cmath>
#include<algorithm>

constexpr int MAX_N = 12;
constexpr double INF = (int)1e9;

int n, w;
int a[MAX_N];
double memo[MAX_N][(1 << MAX_N)];

double func(int x1, int x2) {
	return sqrt(pow(a[x1] + a[x2], 2) - pow(abs(a[x1] - a[x2]), 2));
}

double solve(int m, int S) {
	if (memo[m][S] > 0.0)
		return memo[m][S];
	if (S == (1 << n) - 1)
		return memo[m][S] = a[m];
	double res = INF;
	for (int i = 0; i < n; ++i) {
		if (!((S >> i) & 1))
			res = std::min(res, solve(i, S | (1 << i)) + func(m, i));
	}
	return memo[m][S] = res;
}

void output() {
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < (1 << n); ++j)
			memo[i][j] = 0.0;
	}
	for (int i = 0; i < n; ++i) {
		if (solve(i, (1 << i)) + a[i] <= (double)w) {
			std::cout << "OK" << std::endl;
			return;
		}
	}
	std::cout << "NA" << std::endl;
}

int main() {
	std::string str;
	while (1) {
		std::getline(std::cin, str);
		if (std::cin.eof())
			break;
		std::stringstream ss(str);
		ss >> w;
		n = 0;
		while (!ss.eof()) {
			ss >> a[n];
			++n;
		}
		output();
	}
	return 0;
}

Measured memory_bytes: 3540
#define D(x) cout << #x " = " << x << endl
#define DD(x, y) cout << "(" #x ", " #y ") = (" << x << ", " << y << ")" << endl
#define DDD(x, y, z) cout << "(" #x ", " #y ", " #z ") = (" << x << ", " << y << ", " << z << ")" << endl
#define DV(v) for (auto __macro_vi : v){ cout << __macro_vi << " ";} cout << endl;
#define DA(a, n) for (int __macro_i = 0; __macro_i < n; ++__macro_i) { cout << a[__macro_i] << " "; } cout << endl;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(v) (v).begin(), (v).end()
#include<iostream>
#include<vector>
#include<cassert>
#include<cmath>

using namespace std;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, d;
    cin >> n >> d;
    auto v = vector<vector<int>>(n, vector<int>(d));
    REP(i, n) {
        REP(j, d) { 
            cin >> v[i][j];
        }
    }
    int ans = 0;
    REP(i, n) {
        for (int j = i + 1; j < n; ++j) {
            int tmp = 0;
            for (int k = 0; k < d; ++k) {
                tmp += (v[i][k] - v[j][k]) * (v[i][k] - v[j][k]);
            }
            int r = (int)(sqrt(tmp) + 0.01);
            if (r * r == tmp) ans++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl

int main(){
    string s;
    cin >> s;
    string cmp = "";
    for(int i = 0; i < 5; i++){
        cmp += "hi";
        if(s == cmp){
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;

}


Measured memory_bytes: 256
h, w = map(int, input().split())
hwl = []
for _ in range(h):
    l = list(input())
    hwl.append(l)

for i in range(h):
    for j in range(w):
        if hwl[i][j] == ".":
            cnt = 0
            if i != 0 and j != 0 and hwl[i-1][j-1] == "#":
                cnt += 1
            if i != 0 and hwl[i-1][j] == "#":
                cnt += 1
            if i != 0 and j < w-1 and hwl[i-1][j+1] == "#":
                cnt += 1
            if j != 0 and hwl[i][j-1] == "#":
                cnt += 1
            if j < w-1 and hwl[i][j+1] == "#":
                cnt += 1
            if i < h-1 and j != 0 and hwl[i+1][j-1] == "#":
                cnt += 1
            if i < h-1 and hwl[i+1][j] == "#":
                cnt += 1
            if i < h-1 and j < w-1 and hwl[i+1][j+1] == "#":
                cnt += 1
            hwl[i][j] = str(cnt)
    print("".join(hwl[i]))


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

#pragma warning(disable:4996)
using namespace std;
using ld=long double;

struct Node {
	char var;
	vector<shared_ptr<Node>>chs;
	Node(char ch):var(ch) {

	}
	Node() :var('@') {

	}
};

shared_ptr<Node> term(const vector<int>&ways,map<char,int>mp,string st, int&a,int k) {
	shared_ptr<Node>no;
	if (st[a] == '(') {
		a++;
		auto ans=term(ways,mp,st,a,0);
		assert(st[a]==')');
		a++;
		no=ans;
	}
	else {
		assert(isalpha(st[a]));
		char var = st[a];
		a++;
		no = make_shared<Node>(var);
	}
		
	while (a != st.size() && st[a] != ')') {
		char op = st[a];
			
		if (mp[op] >= k) {
			a++;
			shared_ptr<Node>ans;
			if (ways[mp[op]] == 1) {
				ans = term(ways, mp, st, a, mp[op] + 1);
			}
			else {
				ans = term(ways, mp, st, a, mp[op]);
			}
			shared_ptr<Node>pa(make_shared<Node>(op));
			pa->chs = vector<shared_ptr<Node>>{ no,ans };
			no = pa;
		}
		else {
			break;
		}
	}
	return no;
		
	
}

string get_st(shared_ptr<Node>n) {
	if (isalpha(n->var)) {
		return string(1,n->var);
	}
	else {
		return "("+get_st(n->chs[0])+n->var+get_st(n->chs[1])+")";
	}
}

void solve(string st,map<char,int>ch_mp,const vector<int>&ways) {
	int k=0;
	int a=0;
	shared_ptr<Node>root(term(ways,ch_mp,st,a,0));
	string answer=get_st(root);
	cout<<answer<<endl;
}

struct aa {
	int a_place;
	int b_place;
	int a_turn;
	int cost;
};
int main() {
	int T;cin>>T;
	for (int t = 0; t < T; ++t) {
		int M;cin>>M;
		vector<vector<int>>ad_edges(M,vector<int>(M));
		for (int i = 0; i < M; ++i) {
			for (int j = 0; j < M; ++j) {
				cin>>ad_edges[i][j];
				if(i==j)ad_edges[i][j]=true;
			}
		}
		int start_a,start_b;cin>>start_a>>start_b;
		vector<vector<vector<int>>>costs(M,vector<vector<int>>(M,vector<int>(2,10000000)));
		vector<vector<int>>nums(M,vector<int>(M));
		for (int i = 0; i < M; ++i) {
			for (int j = 0; j < M; ++j) {
				if (ad_edges[i][j]) {
					for (int k = 0; k < M; ++k) {
						nums[j][k]++;
					}
				}
			}
		}
		queue<aa>que;
		for (int i = 0; i < M; ++i) {
			que.push(aa{ i,i,0,0 });
			costs[i][i][0]=0;
			costs[i][i][1]=0;
			que.push(aa{ i,i,1,0 });
		}
		while (!que.empty()) {
			auto af(que.front());
			que.pop();
			if(af.cost>costs[af.a_place][af.b_place][af.a_turn])continue;
			if (af.a_turn == true) {
				for (int b_from = 0; b_from < M; ++b_from) {
					if (ad_edges[b_from][af.b_place]) {
						if (costs[af.a_place][b_from][0] > af.cost + 1) {
							costs[af.a_place][b_from][0]=af.cost+1;
							que.push(aa{ af.a_place,b_from,0,af.cost + 1 });
						}
					}
				}
			}
			else {
				for (int a_from = 0; a_from < M; ++a_from) {
					if (ad_edges[a_from][af.a_place]) {
						nums[a_from][af.b_place]--;
						if (nums[a_from][af.b_place] == 0) {
							costs[a_from][af.b_place][1]=af.cost;
							que.push(aa{a_from,af.b_place,1,af.cost});
						}
						assert(nums[a_from][af.b_place]>=0);
					}
				}
			}
		}
		int ans=costs[start_a][start_b][1];
		if(ans>10000)cout<<"infinity"<<endl;
		else cout<<ans<<endl;
	}
	return 0;
}


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

int main() {
  string s; cin >> s;
  int a_min_idx = s.size();
  int z_max_idx = 0;
  
  for (int i = 0; i < s.size(); ++i) {
    if (s[i] == 'A') a_min_idx = min(a_min_idx, i);
    if (s[i] == 'Z') z_max_idx = max(z_max_idx, i);
  }
  cout << z_max_idx - a_min_idx + 1 << endl;
  
  return 0;
}

Measured memory_bytes: 3736
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
#define all(q) (q).begin(),(q).end()
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int arr[MAX];
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    int x,a,b;
    cin>>x>>a>>b;
    int c=abs(a-x);
    int d=abs(b-x);
    if(c<d)
        cout<<"A"<<endl;
    else

        cout<<"B"<<endl;
    return 0;
}


Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
const long long MOD=1000000007;
int main(){
  #define int long long
  int N,K,ans=MOD;
  cin>>N>>K;
  vector<int> A(N);
  int MA=0;
  for(int i=0;i<N;i++){
    cin>>A.at(i);
    MA=max(MA,A.at(i));
  }
  int left=1,right=MA;
  while(left<=right){
    //cout<<left<<" "<<right<<endl;
    int mid=left+(right-left)/2;
    int count=0;
    for(int i=0;i<N;i++){
      if(mid>=A.at(i)){
        continue;
      }
      //cout<<i<<" "<<mid<<endl;
      int answer_for_i=MOD;
      int L=1,R=A.at(i);
      while(L<=R){
        int M=L+(R-L)/2;
        //cout<<M<<endl;
        if(A.at(i)<=mid*M){
          answer_for_i=min(answer_for_i, M-1);
          R=M-1;
        }
        else{
          L=M+1;
        }
      }
      count+=answer_for_i;
     // cout<<i<<" "<<answer_for_i<<" "<<mid<<endl;
    }
    if(count<=K){
      right=mid-1;
      ans=min(ans,mid);
    }
    else{
      left=mid+1;
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 4832
#
# abc095 a
#
import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """oxo"""
        output = """900"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """ooo"""
        output = """1000"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """xxx"""
        output = """700"""
        self.assertIO(input, output)


def resolve():
    print(700 + input().count("o")*100)


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 16100
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		if((a*b)%2==0) {
			System.out.println("No");
		}
		else {
			System.out.println("Yes");
		}

	}

}

Measured memory_bytes: 35708
import java.math.BigInteger;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		long N = Long.parseLong(sc.next());
		sc.close();

		BigInteger power = new BigInteger("1");
		BigInteger check = new BigInteger("1000000007");
		power.remainder(check);
		for(int i = 1; i <= N; i++) {
			BigInteger tmp = new BigInteger(String.valueOf(i));
			power = power.multiply(tmp);
			power = power.remainder(check);
		}

		System.out.println(power);
	}

}

Measured memory_bytes: 42660
N = int(input())

N_fi = N//3
N_bu = N//5
N_fb = N//15

Sn = N*(1+N)/2
S_fi_n = N_fi/2*(2*3 + (N_fi - 1)*3)
S_bu_n = N_bu/2*(2*5 + (N_bu - 1)*5)
S_fb_n = N_fb/2*(2*15 + (N_fb - 1)*15)

print(int(Sn - S_fi_n - S_bu_n + S_fb_n))

Measured memory_bytes: 9192
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N,K;
    cin >> N >> K;
    vector<P> V(N);
    rep(i,0,N)cin >> V[i].second >> V[i].first;
    sort(V.rbegin(), V.rend());
    map<int,int> mp;
    stack<int> st;
    queue<int> que;
    ll kind = 0, vsum = 0;
    rep(i,0,K){
        vsum += V[i].first;
        mp[V[i].second]++;
        if(mp[V[i].second] == 1)kind++;
        else st.push(V[i].first);
    }
    rep(i,K,N){
        mp[V[i].second]++;
        if(mp[V[i].second] == 1)que.push(V[i].first);
    }
    ll maxi = vsum + kind * kind;
    while(!(st.empty() || que.empty())){
        vsum -= st.top();
        vsum += que.front();
        kind++;
        st.pop();
        que.pop();
        maxi = max(maxi, vsum + kind * kind);
    }
    cout << maxi << endl;
} 

Measured memory_bytes: 5888
#include<bits/stdc++.h>
#define ALL(v) v.begin(), v.end()
typedef long long ll;
ll GCD(ll x, ll y) { return y ? GCD(y, x%y) : x; }
ll LCM(ll x, ll y) { return x * y / GCD(x, y); }

using namespace std;
int main() {
	int n,k;
	cin >> n >> k;

	vector<int> d(k);
	for (int i = 0; i < k; i++)
	{
		cin >> d[i];
	}

	int ans = n;

	bool flag = false;

	for (int i = n;i < 9999990; i++)
	{
		int tmp = i;
		set<int> s;
		
		while (tmp != 0) {
			s.insert(tmp % 10);
			tmp /= 10;
		}

		flag = true;
		for (int dx : d)
		{
			if (s.count(dx)) {
				
				flag = false;
				
			}

		}

		if (flag) {
			cout << i;
			break;
		}

		
	}




}

Measured memory_bytes: 256
def main():
    mod = 998244353
    s, k = input().split()
    k, n, one, cnt, z, zero_list = int(k), len(s), s.count("1")+1, 0, 0, []
    for i in range(n):
        if s[i] == "0":
            zero_list.append(cnt)
            cnt = 0
        else:
            cnt += 1
    mm = min(one-1, k)

    dp = [[0]*(mm+1) for _ in [0]*one]
    dp[0][0] = 1

    for i in zero_list:
        dp2 = [[0]*(mm+1) for _ in [0]*one]
        for jl in range(z+i, one):
            for x in range(i, min(one, jl+1, mm+i+1)):
                dp2[jl][x-i] = (dp2[jl][x-i]+sum([dp[jl-x+p][p]
                                                  for p in range(min(one, x-i+1))])) % mod
            for p in range(min(one, mm+1)):
                dp2[jl][p] = (dp2[jl][p]+sum([dp[jl-l][p]
                                              for l in range(min(one, i, jl-p+1))])) % mod
        z += i
        dp = dp2
    print(sum([sum(i) for i in dp]) % mod)


main()


Measured memory_bytes: 97604
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(),x.end()
#define ln '\n'
const double PI = acos(-1.0);
const long long MOD = 1000000007LL;
//const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
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; }
///////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    set<int> dic;
    int N; cin >> N;
    while (N--) {
        int a; cin >> a;
        dic.emplace(a);
    }
    int M; cin >> M;
    while (M--) {
        int b; cin >> b;
        if (dic.count(b)) dic.erase(b);
        else dic.emplace(b);
    }

    for (auto i : dic) cout << i << ln;
}


Measured memory_bytes: 21852
"""
~~ author : dokueki
~~ created : 10~05~2020
"""

import sys
INT_MAX = sys.maxsize
INT_MIN = -(sys.maxsize)-1
sys.setrecursionlimit(10**7)
mod = 1000000007


def IOE():
    sys.stdin = open("input.txt", "r")
    sys.stdout = open("output.txt", "w")


def main():
    a, b, c, n = map(int, sys.stdin.readline().split())
    s = 0
    if n <= a:
        s += n * 1
    elif n <= a + b:
        s += a * 1 + (n - a) * 0
    else:
        s += a*1+b*0 + (n-a-b)*-1
    print(s)


if __name__ == "__main__":
    try:
        IOE()
    except:
        pass
    main()


Measured memory_bytes: 61892
#include <stdio.h>
int main(void){
     int h, w; 
     int i, j; 
     while(1){ 
         scanf("%d %d ", &h, &w); 
         if(h==0&&w==0)break; 
                  for(i=0;i<h;i++){ 
             for(j=0;j<w;j++){ 
                 if((i%2==0&&j%2==0)||(i%2==1&&j%2==1)){ 
                     printf("#"); 
                 }else{ 
                     printf("."); 
                 } 
             } 
             printf("\n"); 
         } 
         printf("\n"); 
     } 
 
 
     return 0; 
 } 





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

using namespace std;

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

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

    int n;
    cin >> n;
    vector<int> nums(n);
    unordered_map<int, int> hashMap1;
    unordered_map<int, int> hashMap2;
    for (int i = 0; i < n; ++i) {
        cin >> nums[i];
        if (i & 1) {
            if (hashMap2.find(nums[i]) != hashMap2.end()) {
                hashMap2[nums[i]]++;
            } else {
                hashMap2[nums[i]] = 1;
            }
        } else {
            if (hashMap1.find(nums[i]) != hashMap1.end()) {
                hashMap1[nums[i]]++;
            } else {
                hashMap1[nums[i]] = 1;
            }
        }
    }
    if (hashMap1.size() == 1 && hashMap2.size() == 1) {
        if (nums[0] == nums[1]) {
            cout << n / 2 << endl;
        } else {
            cout << 0 << endl;
        }
    } else if (hashMap1.size() == 1) {
        vector<pair<int, int>> vec;
        for (auto it = hashMap2.begin(); it != hashMap2.end(); ++it) {
            pair<int, int> pr;
            pr.first = it->first;
            pr.second = it->second;
            vec.push_back(pr);
        }
        sort(vec.begin(), vec.end(), comp);
        for (auto pr : vec) {
            if (nums[0] != pr.first) {
                cout << n / 2 - pr.second << endl;
                break;
            }
        }
    } else if (hashMap2.size() == 1) {
        vector<pair<int, int>> vec;
        for (auto it = hashMap1.begin(); it != hashMap1.end(); ++it) {
            pair<int, int> pr;
            pr.first = it->first;
            pr.second = it->second;
            vec.push_back(pr);
        }
        sort(vec.begin(), vec.end(), comp);
        for (auto pr : vec) {
            if (nums[1] != pr.first) {
                cout << n / 2 - pr.second << endl;
                break;
            }
        }
    } else {
        vector<pair<int, int>> vec1, vec2;
        for (auto it = hashMap1.begin(); it != hashMap1.end(); ++it) {
            pair<int, int> pr;
            pr.first = it->first;
            pr.second = it->second;
            vec1.push_back(pr);
        }
        sort(vec1.begin(), vec1.end(), comp);
        for (auto it = hashMap2.begin(); it != hashMap2.end(); ++it) {
            pair<int, int> pr;
            pr.first = it->first;
            pr.second = it->second;
            vec2.push_back(pr);
        }
        sort(vec2.begin(), vec2.end(), comp);
        if (vec1[0].first != vec2[0].first) {
            cout << n - vec1[0].second - vec2[0].second << endl;
        } else {
            int sum = max(vec1[0].second + vec2[1].second, vec1[1].second + vec2[0].second);
            cout << n - sum << endl;
        }
    }

    return 0;
}

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

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

int main() {

  ll A, B;
  cin >> A >> B;

  ll ans ;
  ans = (A / __gcd(A, B)) * B;
  
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
constexpr int64_t mod=1e9+7;

int main()
{
  string s;
  cin>>s;
  std::vector<int> num;
  set<char> kind;
  for(auto&& e: s) {
    kind.insert(e);
  }
  
  for (auto&& c:kind)
  {
    int cnt=0;
    string tmp=s;
    set<char> st;
    for(auto&& e: tmp) {
      st.insert(e);
    }
    while(st.size()!=1){
      st.clear();
      for (int i = 0; i < tmp.size()-1; ++i)
      {
        if(tmp[i+1]==c&&tmp[i]!=c) {
          tmp[i]=c;
        }
      }
      cnt++;
      tmp.pop_back();
      for(auto&& e: tmp) {
        st.insert(e);
      }
      if(tmp.empty()) {
        break;
        cnt=mod;
      }
    }
    num.emplace_back(cnt);
  }
  cout<<*min_element(num.begin(), num.end());
  
}

Measured memory_bytes: 256
def main():
    from heapq import heappop, heappush
    import sys
    input = sys.stdin.buffer.readline
    N = int(input())
    edge = [[] for _ in range(N)]
    for i in range(N-1):
        a, b, c = (int(i) for i in input().split())
        edge[a-1].append((c, b-1))
        edge[b-1].append((c, a-1))
    Q, K = (int(i) for i in input().split())

    def dijkstra(s, G):
        d = [10**12]*N
        used = [True] * N  # True:未確定
        d[s] = 0
        used[s] = False
        edges = []
        for e in G[s]:
            heappush(edges, e)
        while len(edges):
            c, v = heappop(edges)
            if not used[v]:
                continue
            d[v] = c
            used[v] = False
            for nexc, nexv in G[v]:
                if used[nexv]:
                    heappush(edges, (nexc+c, nexv))
        return d

    dist = dijkstra(K-1, edge)
    for query in range(Q):
        x, y = (int(i)-1 for i in input().split())
        print(dist[x] + dist[y])


if __name__ == '__main__':
    main()


Measured memory_bytes: 77728
#include <bits/stdc++.h>
using namespace std;
#define LONGLONGMAX 9223372036854775807
#define LONGLONGMIN -9223372036854775807
#define INTMAX 32767
#define INTMIN -32767
#define ROUNDUP(divisor,dividend) (divisor + (dividend - 1)) / dividend
long long int n,i;
int main(){
  cin >> n;
  for (i = 0; i*i <= n; i++) {}
  cout << (i-1)*(i-1) << endl;
}


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

a = list(map(int,input().split()))
a = sorted(a)

aMax = a[-1]
l = len(a)
count = 0
k = 0
kSet = set()

for i in range(n):
    value = a[i]
    if not(value in kSet):
        if i != 0 and a[i-1] == value:
            count -= 1
            kSet.add(value)
            continue
        count += 1
        j = 2
        k = 0
        while k < aMax:
            k = a[i] * j
            kSet.add(k)
            j += 1
    #if value ** 2 > aMax:
    #    break

print(count)

Measured memory_bytes: 216904
#include<bits/stdc++.h>
using namespace std;
/*#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
/*template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
*/typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pl;
typedef pair<int,int> pii;

#define LOCAL 0
#define dbg(x) cout << #x << " is " << x << "\n"
#define gll(x) scanf("%d",&x)
#define gll2(x,y) scanf("%d%d",&x,&y)
#define gll3(x,y,z) scanf("%d%d%d",&x,&y,&z)
#define gllarr(arr,n) f(i,n) gll(arr[i]);
#define sz(x) ((int)x.size())
#define s(x) sort(x.begin(),x.end())
#define all(v) v.begin(),v.end()
#define rs(v) { s(v) ; r(v) ; }
#define r(v) {reverse(all(v));}
#define pb push_back
#define f(i,n) for(int i=0;i<n;i++)
#define fr(i,n) for(int i=n-1;i>=0;i--)
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define repr(i,a,b) for(int i=a;i>=b;i--)

const ll mod = (ll)1e9 + 7;
const ll inf = (ll)1e16;
const ld eps = 1e-12;
const ll N = (int)1e5 + 5;
const ll LOGN = 19;
const ld PI = 3.14159265358979323846;
inline ll mul(ll a, ll b, ll m = mod) { return (ll)(a * b) % m;}
inline ll add(ll a, ll b, ll m = mod) { a += b; if(a >= m) a -= m; if(a < 0) a += m; return a;}
inline ll power(ll a, ll b, ll m = mod) { if(b == 0) return 1; if(b == 1) return (a % m); ll x = power(a, b / 2, m); x = mul(x, x, m); if(b % 2) x = mul(x, a, m); return x;}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    if (LOCAL) {
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\input.txt", "r", stdin);
        freopen("C:\\Users\\Dishant\\Desktop\\Collection-DEV c++\\output.txt", "w", stdout);
    }
    int n;
    cin>>n;
    int a[n];
    f(i, n) cin>>a[i];
    sort(a, a + n);
    int to = 0;
    f(i, n - 1){
        to += a[i];
    }
    if(a[n - 1] < to) {
        cout << "Yes\n";
    }
    else cout<<"No\n";
    return 0;
}

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

int *G, cnt = 0;

void show(int A[], int n)
{
    for (int i = 0; i < n; i++)
        cout << A[i] << endl;
}

void insertionSort(int A[], int n, int g)
{
    for (int i = g; i < n; i++) {
        int v = A[i];
        int j = i - g;
        while (j >= 0 && A[j] > v) {
            A[j + g] = A[j];
            j -= g;
            cnt++;
        }
        A[j + g] = v;
    }
}

void shellSort(int A[], int n)
{
    int m, j = 0;

    while (1) {
        if (G[j] > n) {
            m = j;
            break;
        }
        j++;
    }

    cout << m << endl;
    for (int i = m - 1; i >= 0; i--) {
        if (!i)
            cout << G[i] << endl;
        else
            cout << G[i] << ' ';
        insertionSort(A, n, G[i]);
    }

    cout << cnt << endl;
}

int main()
{
    int n;

    cin >> n;
    int A[n];
    G = new int[n];
    G[0] = 1;

    for (int i = 0; i < n; i++) {
        cin >> A[i];
        if (i)
            G[i] = G[i - 1] * 3 + 1;
    }

    shellSort(A, n);

    show(A, n);

    delete [] G;
}


Measured memory_bytes: 10688
<?php
$n = fgets(STDIN);
$a = fgets(STDIN);
$b = fgets(STDIN);
$c = fgets(STDIN);
$count = 0;

for ($i = 0; $i < $n; $i++ ) {
    $ai = substr($a, $i, 1);
    $bi = substr($b, $i, 1);
    $ci = substr($c, $i, 1);
    if ($ai == $bi && $bi == $ci) {
    } elseif ($ai != $bi && $ai != $ci && $bi != $ci) {
        $count += 2;
    } else {
        $count++;
    }
}

echo $count;

Measured memory_bytes: 4856
S = input()
ymd = "0"
iymd = None

for i in range(4):
    ymd = ymd + S[i]
for i in range(5,7):
    ymd = ymd + S[i]
for i in range(8,10):
    ymd = ymd + S[i]

iymd = int(ymd)

if iymd <= 20190430:
    print("Heisei")
else:
    print("TBD")

Measured memory_bytes: 3064
import java.util.*;
	import java.lang.Math;
    public class Main {
    	public static void main(String[] args) {
    		Scanner scan = new Scanner(System.in);
			String original="";
			original=scan.nextLine();
			int count=0;
			int len=original.length();
			for(int i=0;i<len/2;i++)
			{
				if(original.charAt(i)==original.charAt(len-1-i))
				{}
				else
					count++;
			}
			System.out.println(count);
    	}
    }

Measured memory_bytes: 21972
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class CTravelingSalesmanAroundLake {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int k = Integer.parseInt(in.next());
            int n = Integer.parseInt(in.next());
            int[] a = new int[n];
            int dist = 0;
            int tmpDist;
            for (int i = 0; i < n; i++) {
                a[i] = Integer.parseInt(in.next());
                if (i > 0) {
                    tmpDist = a[i] - a[i - 1];
                    if (tmpDist > dist) {
                        dist = tmpDist;
                    }
                }
            }
            tmpDist = a[0] + k - a[n - 1];
            if (tmpDist > dist) {
                dist = tmpDist;
            }
            out.println(k - dist);
        }

    }
}



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

int main() {
  int N, K, num=1;
  cin >> N >> K;
  
  rep(i, N){
    if(num*2 <= num+K) num *= 2;
    else num += K;
  }
  
  cout << num << endl;
  
  return 0;
}

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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

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

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

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

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

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

int main(){
    bool flag=false;
    ll ans=0,sum=0;

    int h,n;
    cin >>h>>n;

    rep(i,n){
        int ai;
        cin>>ai;
        sum += ai;
    }

    //cout <<fixed<<setprecision(16)<< << endl;
    //cout<<ans<<endl;
    
    if(sum >= h)cout << "Yes" <<endl;
    else cout << "No" <<endl;
    
    return 0;
}


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

int min(i,j){
  if(i >=j) return j;
  else return i;
}

void Matrix(int p[],int a){
  int i,m[1000][1000],l,j,k,q,n;
  n = a - 1;
  for(i = 1; i <= n; i++){
    m[i][i] = 0;
  }
  for(l = 2; l <= n; l++)
    {
    for(i = 1; i <= n-l+1; i++)
      {
      j = i + l - 1;
      m[i][j] = INT_MAX;
      for(k = i; k <= j-1;k ++)
	{
        q = m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j];
        m[i][j] = min(m[i][j], q);
	}
      }
    }
  printf("%d\n",m[i][j]);
}

int main(){
  int A[100],i,trush,n;

  scanf("%d",&n);

  for(i = 1; i < n; i ++){
    scanf("%d%d",&A[i],&trush);
  }
  scanf("%d%d",&A[i],&A[i+1]);

  //for(i = 1; i < n+2; i ++){
  //printf("%d\n",A[i]);
  //}
  Matrix(A,n+2);

  return 0;
}

Measured memory_bytes: 2808
#include<bits/stdc++.h>
#define U [7<<15]={}
#define G )+((c=A[a]+A[P[a]]+C[a])%k?c:0)-M(
typedef long long L;using namespace std;map<L,L>T U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c;char s U;
L M(L f){return f?B[f]+M(f^f&-f):0;}
L S(L a,L i){for(a=M(i++G i);i<2e5;i+=i&-i)B[i]+=a;}
L D(L f){L d;for(map<L,L>::iterator I=T[f].begin();I!=T[f].end();I++)
    d=I->first,d-P[f]?P[d]=f,E[d]=E[f]+1,C[d]=I->second,D(d),Z[f]+=++Z[d],Z[H[f]]<Z[d]?H[f]=d:0:0;}
L K(L f){a=X[f];n=X[b];return a-n?M(O[E[a]<E[n]?a=n,n=b,b=f,n:f]G O[a])+K(P[a]):abs(M(O[f])-M(O[b]));}
main(){for(cin>>n>>k;--*Z+n;T[a][b]=T[b][a]=c)cin>>a>>b>>c;
       for(n=D(0);Z[a=H[P[n]]-n?n:0];n++)for(;!O[a];S(a=H[a],O[a]=++b))X[a]=n;
       for(cin>>a;cin>>s>>a>>b;S(H[a],O[a]),S(a,O[a]-1))*s&2?cout<<K(a)<<endl,0:A[a]+=b;}

Measured memory_bytes: 38084
from sys import stdout
import heapq
printn = lambda x: stdout.write(x)
inn = lambda : int(input())
inl   = lambda: list(map(int, input().split()))
inm   = lambda:      map(int, input().split()) 
DBG = True  and False
BIG = 999999999
R = 10**9 + 7

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

def foo(t):
  #ddprint("foo {}".format(t))
  cnt = 0
  for j in range(n):
    v,i = b[j]
    #ddprint("c {} v {} i {}".format(cnt,v,i))
    if v<=t:
      return (cnt<=k)
    d = (v-t+f[i]-1)//f[i]
    cnt += d
    if cnt>k:
      return False
  return (cnt<=k)

n,k = inm()
a = inl()
f = inl()
a.sort()
f.sort(reverse=True)
b = [(f[i]*a[i], i) for i in range(n)]
b.sort(reverse=True)
c = [z[0] for z in b]
mx = max(c)
mn = -1
mid = mx
while mx>mn+1:
  mid = (mx+mn)//2
  if foo(mid):
    #ddprint("mid {} ok".format(mid))
    mx = mid
  else:
    #ddprint("mid {} ng".format(mid))
    mn = mid
print(mx)


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

int main() {
	int k;
	string s;
	cin >> k;
	cin >> s;
	if (s.size() <= k) {
		cout << s;
	}
	else {
		string ans;
		for (int i = 0; i < k; i++) {
			ans += s[i];
		}
		ans += "...";
		cout << ans;
	}
	return 0;
}

Measured memory_bytes: 3628
n=int(input())
li=[[0 for i in range(2)] for j in range(n)]
ans=0
for i in range(n):
    s,t=map(str,input().split())
    li[i][0]=s
    li[i][1]=t
    ans+=int(t)
x=str(input())
for j in range(n):
    if li[j][0]!=x:
        ans-=int(li[j][1])
    else:
        ans-=int(li[j][1])
        break
print(ans)   

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

int main(){
int N;cin>>N;
  double ans=0;
  for(int i=0;i<N;i++)
  {
   double x;cin>>x;
    string u;cin>>u;
    if(u=="BTC")
      x=x*380000;
    ans+=x;
  }
  cout<<ans<<endl;
}
    


Measured memory_bytes: 256
#include <stdio.h>
int max[7] = {
    0,
    10,
    100,
    1000,
    10000,
    100000,
    1000000
};
 
int main()
{
    int a,b,c;
    int i;
 
    while(scanf("%d%d",&a,&b)==2){
        c=a+b;
        for(i=7;i>=0;i--){
            if(c>= max[i-1])break;
        }
        putchar('0'+i);
        putchar('\n');
    }
    return 0;
}


Measured memory_bytes: 1988
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int main(void) {
	string s;
	cin >> s;
	long long  ans = 0;
	for (int mask = 0; mask < (1 << s.size()-1); mask++) {
		long long result = 0;
		long long add = s[0] - '0';
		for (int i = 0; i < s.size() - 1; i++) {
			if (mask & (1 << i)) {
				result += add;
				add = 0;
			}
			add = add * 10 + s[i + 1] - '0';
		}
		result += add;
		ans += result;
		
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
int main() {
  int a;
  cin>>a;
  vector<int> v(a);
  rep(i,a) cin>>v[i];
  sort(v.begin(),v.end());
  cout<<v[a-1]-v[0]<<endl;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-

numbers = list("1234567890")
querry = [n for n in input().split()]

stack = []

for q in querry:
    if q == "+":
        stack.append(stack.pop() + stack.pop())
    elif q == "-":
        stack.append(-stack.pop() + stack.pop())
    elif q == "*":
        stack.append(stack.pop() * stack.pop())
    else:
        stack.append(int(q))

print(stack.pop())

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

using namespace std;

using int64 = long long;
const int mod = 1000003;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;

template <typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
  os << p.first << " " << p.second;
  return os;
}

template <typename T1, typename T2>
istream &operator>>(istream &is, pair<T1, T2> &p) {
  is >> p.first >> p.second;
  return is;
}

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for (int i = 0; i < (int)v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
  for (T &in : v) is >> in;
  return is;
}

template <typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) {
  return a < b && (a = b, true);
}

template <typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) {
  return a > b && (a = b, true);
}

template <typename T = int64>
vector<T> make_v(size_t a) {
  return vector<T>(a);
}

template <typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
  return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) {
  t = v;
}

template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) {
  for (auto &e : t) fill_v(e, v);
}

template <typename F>
struct FixPoint : F {
  FixPoint(F &&f) : F(forward<F>(f)) {}

  template <typename... Args>
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward<Args>(args)...);
  }
};

template <typename F>
inline decltype(auto) MFP(F &&f) {
  return FixPoint<F>{forward<F>(f)};
}

int main() {
  int a, b, c;
  cin >> a >> b >> c;

  if ((a == b && b != c) || (b == c && a != c) || (a == c && a != b)) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


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

int main(){
	int a;
	cin >> a;
	for(int i=0;i<3;i++){
		if(a%10 == 7){
			//出力
			cout << "Yes" << endl;
			break;
		}
		else{
			a /= 10;
		}
	}
	if(a%10 != 7){

	cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define ll long long
#define INF 0x3f3f3f3f
using namespace std;
const int N=100;

int main(){
    int m[N][N];
    int n,u,k,v;
    cin>>n;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            m[i][j]=0;
        }
    }
    for(int i=0;i<n;i++){
        cin>>u>>k;
        u--;
        for(int j=0;j<k;j++){
            cin>>v;
            v--;
            m[u][v]=1;
        }
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(j)
                cout<<" ";
            cout<<m[i][j];
        }
        cout<<endl;
    }
    return 0;
}



Measured memory_bytes: 3068
a,b = input().split()
a = int(a)
b0 = int(b[0])
b1 = int(b[2])
b2 = int(b[3])


s1 = a*b0
s2 = a*b1
s3 = a*b2

hoge = s1*100+s2*10+s3

if len(str(hoge)) <= 2:
    print(0)
else:
    print(str(hoge)[:-2])

Measured memory_bytes: 61680
#include<stdio.h>
int buttons(int *A, int *B){
    int max = 0;
    if(*A > *B){
        max = *A;
        *A = *A - 1;
    }
    else{
        max = *B;
        *B = *B -1;
    }
    return max;
}


int main(void){
    int A= 0,B = 0;
    scanf("%d %d", &A, &B);
    int max = 0;
    for(int i = 0; i < 2; i++){
        max += buttons(&A, &B); 
    }
    printf("%d", max);
    return 0;
}

Measured memory_bytes: 128