akhauriyash/Code-Regression huggingface dataset:
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [tuple(map(int, l.split())) for l in sys.stdin]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)

def main():
    n = I()
    a = LI()
    r = 1
    m = a[0]
    for i in range(1,n):
        if m <= a[i]:
            r += 1
            m = a[i]

    return r


print(main())



Measured memory_bytes: 6740
#include <stdio.h>

int main() {
  int n, q, C = 0;
  int S[100000], T[50000];
  int i, j;

  scanf("%d", &n);
  for(i = 0; i < n; i++) scanf("%d", S+i);

  scanf("%d", &q);
  for(i = 0; i < q; i++) scanf("%d", T+i);

  for(i = 0; i < q; i++) {
    int lb = 0, ub = n;
    while(lb + 1 < ub) {
      int mb = (lb + ub) / 2;
      if(T[i] < S[mb]) ub = mb;
      else lb = mb;
    }
    if(T[i] == S[lb]) C++;
  }

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

  return 0;
}

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

int main(){
    string s;
    int num,num1;
    cin>>s;
    num=0;
    num1=0;
    if(s[0]=='A'){
        num=1;
    }else if(s[0]=='B'){
        num1=1;
    }

    if(s[1]=='A'){
        num=1;
    }else if(s[1]=='B'){
        num1=1;
    }

    if(s[2]=='A'){
        num=1;
    }else if(s[2]=='B'){
        num1=1;
    }
    
    if(num==1 && num1==1){
        cout<<"Yes";
    }else {
        cout<<"No";
    }

    return 0;

}

Measured memory_bytes: 256
n = int(input())
p_list = [int(input()) for i in range(n)]
max_p = max(p_list)
max_p_index = p_list.index(max_p)
ans = 0

for i in range(n):
    if i == max_p_index:
        ans += p_list[i] // 2
    else:
        ans += p_list[i]

print(ans)

Measured memory_bytes: 3060
class Integer
  def square
    return self ** 2
  end
end

judge = ->(ary) {
  if ary.last.square == ary[0].square + ary[1].square
    puts "YES"
    break
  else
    puts "NO"
  end
}

n = gets.to_i

n.times do |i|
  ary = gets.split(" ").map(&:to_i).sort
  judge.call(ary)
end

Measured memory_bytes: 6108
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<cctype>
#include<queue>
#include<set>
#include<iomanip>
#include<cstdlib>
using namespace std;
int a[3][101],n,i,j;
int main()
{
	cin>>n;
	for(i=1;i<=2;i++)
	{
		for(j=1;j<=n;j++)
		{
			cin>>a[i][j];
		}
	}
	for(i=1;i<=2;i++)
	{
		for(j=1;j<=n;j++)
		{
			a[i][j]=max(a[i-1][j],a[i][j-1])+a[i][j];
		}
	}
	cout<<a[2][n]<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;

int n, all[100], cnt[100];
string s;

int main()
{
	ios_base::sync_with_stdio( 0 );
	cin.tie( 0 );
	cin>>n;
	for( int a = 0; a <= 30; a++ )all[a] = 1e9; 
	for( int a = 1; a <= n; a++ )
	{
		cin>>s;
		for( int b = 0; b < s.size(); b++ )cnt[s[b]-'a']++;
		for( int b = 0; b <= 30; b++ )all[b] = min( all[b], cnt[b] ), cnt[b] = 0;
	}
	for( int a = 0; a < 26; a++ )
	{
		while(all[a])
		{
			cout<<char('a'+a);
			all[a]--;
		}
	}
	return 0;
}
 



Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

bool visited[111111];
int p[100001];
int q[100001];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n,x;
	cin>>n>>x;
	vi perm(n);
	for(int i = 0; i < n; i++) perm[i] = i;
	for(int i = 0; i < x; i++)
	{
		cin>>p[i]>>q[i];
		p[i]--; q[i]--;
	}
	vi P = perm;
	vi inv = perm;
	for(int i = 0; i < x; i++)
	{
		swap(inv[P[p[i]]], inv[P[q[i]]]);
		swap(P[p[i]],P[q[i]]);
	}
	visited[inv[0]]=1;
	visited[inv[1]]=1;
	visited[inv[0]+1]=1;
	if(inv[0]>0) visited[inv[0]-1]=1;
	vi P2 = perm;
	vi inv2 = perm;
	for(int i = 0; i < x; i++)
	{
		swap(inv2[P2[p[i]]], inv2[P2[q[i]]]);
		swap(P2[p[i]],P2[q[i]]);
		swap(inv[p[i]], inv[q[i]]);
		swap(P[p[i]],P[q[i]]);
		int pos = inv2[0];
		visited[inv[pos+1]] = 1;
		if(pos>0) visited[inv[pos-1]] = 1;
	}
	//cerr<<inv[0]<<'\n';
	int ans = 0;
	for(int i=0;i<n;i++)
	{
		if(visited[i]) ans++;
	}
	cout<<ans<<'\n';
}


Measured memory_bytes: 3072
#include <iostream>
using namespace std;
int main(void){
    int H, W;
    cin >> H >> W;
    int i;
    int j;
    int map[1000][1000] = {};
    int x[1000000] = {};
    int y[1000000] = {};
    string str;
    int p = 0;
    for(i = 0; i < H; i++){
        cin >> str;
        for(j = 0; j < W; j++){
            map[i][j] = (str[j] == '#') ? 1 : 0;
            if(str[j] == '#'){
                y[p] = i;
                x[p] = j;
                ++p;
            }
        }
    }
    int flag = true;
    int count = 0;
    int bp = 0, bbp = 0;
    while(flag){
        bbp = bp;
        bp = p;
        flag = false;
        for(i = bbp; i < bp; i++){
            int xi = x[i];
            int yi = y[i];
            if(xi - 1 >= 0 && map[yi][xi - 1] == 0){
                map[yi][xi - 1] = count+2;
                x[p] = xi - 1;
                y[p] = yi;
                p++;
                flag = true;
            }
            if(xi + 1 < W && map[yi][xi + 1] == 0){
                map[yi][xi + 1] = count+2;
                x[p] = xi + 1;
                y[p] = yi;
                flag = true;
                p++;
            }
            if(yi - 1 >= 0 && map[yi - 1][xi] == 0){
                map[yi - 1][xi] = count+2;
                x[p] = xi;
                y[p] = yi-1;
                flag = true;
                p++;
            }
            if(yi + 1 < H && map[yi + 1][xi] == 0){
                map[yi + 1][xi] = count+2;
                x[p] = xi;
                y[p] = yi+1;
                flag = true;
                p++;
            }    
        }
        if(flag)count++;
    }
    /*
    for(i = 0; i < H; i++){
        for(j = 0; j < W; j++){
            cout << map[i][j];
        }
        cout << endl;
    }
    */
    cout << count;
}


Measured memory_bytes: 11904
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;

int main(){
	int a,n=0;
	char s[15],s1[15];
	scanf("%s",s);
	for(int i=0;i<strlen(s);i++){
		if(s[i]=='0'){
			s1[n++]='0';
		}
		else if(s[i]=='1'){
			s1[n++]='1';
		}
		else if(s[i]=='B'){
			if(n>0){
				s1[--n]='\0';
			}
		}
		
	}
	for(int i=0;i<n;i++){
			printf("%c",s1[i]);
		}
	
	printf("\n");
	return 0;
}

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

// @@ !! LIM()

int main(int argc, char *argv[]) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll N; cin >> N;
  vector<ll> A(N+2);
  for (ll i = 0; i < N; i++) cin >> A.at(i+1);
  ll sum = 0;
  for (ll i = 0; i <= N; i++) {
    sum += abs(A.at(i+1) - A.at(i));
  }
  for (ll i = 1; i <= N; i++) {
    cout << sum - abs(A.at(i+1) - A.at(i)) - abs(A.at(i) - A.at(i-1))
      + abs(A.at(i+1) - A.at(i-1)) << "\n";
  }

  return 0;
}



Measured memory_bytes: 4000
#include<iostream>
#include<algorithm>
#define int long long
using namespace std;
const int N=1e5+5;
const long long inf=2e12+7;
long long dp[N],dp1[4*N],lazy[4*N],pos[N];
void upd(int idx,int l,int r,int lef,int rig,int val){
	if(l>rig||r<lef){
		return;
	}
	if(l>=lef&&r<=rig){
		if(dp1[idx]<=val){
			return;
		}
		else{
			if(dp1[idx]>val){
				lazy[idx]=val;
				dp1[idx]=val;
			}
			return;
		}
	}
	if(lazy[idx]!=inf){
		dp1[2*idx]=min(lazy[idx],dp1[2*idx]);
		dp1[2*idx+1]=min(dp1[2*idx+1],lazy[idx]);
		lazy[2*idx]=min(lazy[2*idx],lazy[idx]);
		lazy[2*idx+1]=min(lazy[2*idx+1],lazy[idx]);
		lazy[idx]=inf;
	}
	upd(2*idx,l,(l+r)/2,lef,rig,val);
	upd(2*idx+1,(l+r)/2+1,r,lef,rig,val);
	dp1[idx]=max(dp1[2*idx],dp1[2*idx+1]);
}
long long getans(int idx,int l,int r,int pos1){
	if(l>pos1||r<pos1){
		return inf;
	}
	if(l==r){
		return dp1[idx];
	}
	if(lazy[idx]!=inf){
		dp1[2*idx]=min(lazy[idx],dp1[2*idx]);
		dp1[2*idx+1]=min(dp1[2*idx+1],lazy[idx]);
		lazy[2*idx]=min(lazy[2*idx],lazy[idx]);
		lazy[2*idx+1]=min(lazy[2*idx+1],lazy[idx]);
		lazy[idx]=inf;
	}
	return min(getans(2*idx,l,(l+r)/2,pos1),getans(2*idx+1,(l+r)/2+1,r,pos1));
}
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,end,time,i,j,k;
	cin>>n>>end>>time;
	for(i=1;i<=n;i++){
		cin>>pos[i];
	}
	for(i=1;i<N;i++){
		dp[i]=inf;
	}
	for(i=1;i<4*N;i++){
		dp1[i]=inf;
	}
	for(i=1;i<4*N;i++){
		lazy[i]=inf;
	}
	for(i=0;i<n;i++){
		if(i!=0){
			dp[i]=min(dp[i],getans(1,1,n,i)+3*pos[i]);
		}
		k=upper_bound(pos+1,pos+1+n,(time+2*pos[i+1])/2)-pos-1;
		dp[k]=min(dp[k],dp[i]+time+pos[k]-pos[i]);
		if(k!=n){
			upd(1,1,n,k+1,n,dp[i]-2*pos[i+1]-pos[i]);
		}
	}
	dp[n]=min(dp[n],getans(1,1,n,n)+3*pos[n]);
	cout<<dp[n]+end-pos[n];
}

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

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

const long long inf = 1e18;
 
int N;
vector<long long> a;
vector< vector<long long> > dp;
vector<long long> c_sum;

//dp[l][r]:[l, r]の範囲に置いて、1つになるまで操作をした時のコストの総和の最小値

long long rec(int l, int r) {
    if (dp[l][r] != inf) return dp[l][r];
    if (r-l == 1) return dp[l][r] = 0;
    
    for (int i = l+1; i < r; i++) {
        chmin(dp[l][r], rec(l, i)+rec(i, r)+c_sum[r]-c_sum[l]);
    }
    return dp[l][r];
}

int main() {
    cin >> N;
    a.resize(N);
    dp.resize(N+2, vector<long long> (N+2, inf));
    for (int i = 0; i < N; i++) {
        cin >> a[i];
    }
    c_sum.resize(N+2, 0);
    for (int i = 0; i < N; i++) {
        c_sum[i+1] = c_sum[i] + a[i];
    }

    long long ret = rec(0, N);
    cout << ret << endl;
}

Measured memory_bytes: 1664
// comment
// #input #output

#include <iostream>
#include <vector>

using namespace std;

int sum_all(vector<int> v){
  int n = v.size();
  int calc = 0;
  int before = 5000;
  for(int j = 0 ; j < n ; j ++) {
    int now = 5000+v[j];
    // cout<<before<<" "<<now<<endl;
    int diff = before - now;
    calc += diff > 0 ? diff : -diff;
    before = now;
  }
  int now = 5000;
  // cout<<before<<" "<<now<<endl;
  int diff = before - now;
  calc += diff > 0 ? diff : -diff;
  before = now;

  return calc;
}

int abs(int n) {
  return n > 0 ? n : -n;
}

int main(void) {
  int n;
  cin>>n;
  vector<int> v(n);
  for(int i = 0 ; i < n ; i ++)cin>>v[i];

  // cout<<sum_all(v)<<endl;
  int sum = sum_all(v);
  for (int i = 0; i < v.size(); ++i) {
    int before = i == 0 ? 0 : v[i-1];
    int after = i != v.size() - 1 ? v[i+1] : 0;
    int now = v[i];
    int diff = abs(now - before) + abs(now - after) - abs(before - after);
    // cout<<before<<" " <<v[i]<<" " <<after<<" "<<diff<<endl;
    // cout<<now - before <<" "<< now - after<<" "<< before - after<<endl;
    // cout<<"sum"<<" " <<sum - diff<<endl;
    cout<<sum - diff<<endl;
  }
}


Measured memory_bytes: 1656
#include <iostream>
#include <vector>
#include <queue>
#include <utility>
using namespace std;

int main(){
  int h, w;
  cin >> h >> w;
  vector<string> table;
  vector<vector<int>> d(h, vector<int>(w, -1));
  for(int i=0; i<h; i++){
    string str;
    cin >> str;
    table.push_back(str);
  }
  queue<pair<int, int>> que;
  int count = h * w;
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      if(table[i][j] == '#'){
        d[i][j] = 0;
        que.push(make_pair(i, j));
        count--;
      }
    }
  }
  int max = 0;
  while(!que.empty()){
    int y = que.front().first;
    int x = que.front().second;
    que.pop();
    for (int dx = -1, dy = 0, i = 0; i < 4; dx += dy, dy = dx - dy, dx = dy - dx, ++i) {
      if(x+dx<0 || x+dx>=w || y+dy<0 || y+dy>=h || d[y+dy][x+dx] != -1){
        continue;
      }else{
        que.push(make_pair(y+dy, x+dx));
        d[y+dy][x+dx] = d[y][x] + 1;
        if(d[y+dy][x+dx] > max) max = d[y+dy][x+dx];
      }
    }
  }
  cout << max << endl;
  return 0;
}


Measured memory_bytes: 13456
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;
import java.io.IOException;
import java.util.InputMismatchException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * 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;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskB solver = new TaskB();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskB {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            int[] a = in.nextIntArray(n);

            Arrays.sort(a);

            long sum = 0;
            for (int i = 0; i < k; i++) {
                sum += a[n - 1 - i];
            }

            out.println(sum);
        }

    }

    static class InputReader {
        BufferedReader in;
        StringTokenizer tok;

        public String nextString() {
            while (!tok.hasMoreTokens()) {
                try {
                    tok = new StringTokenizer(in.readLine(), " ");
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
            }
            return tok.nextToken();
        }

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

        public int[] nextIntArray(int n) {
            int[] res = new int[n];
            for (int i = 0; i < n; i++) {
                res[i] = nextInt();
            }
            return res;
        }

        public InputReader(InputStream inputStream) {
            in = new BufferedReader(new InputStreamReader(inputStream));
            tok = new StringTokenizer("");
        }

    }
}



Measured memory_bytes: 21588
#include <stdio.h>

int main(void)
{
	int a, b, sum;
	int data;
	
	while (scanf("%d %d", &a, &b) != EOF) {
		sum = a + b;
		data = 0;
		while (sum > 0) {
			data++;
			sum /= 10;
		}
		printf("%d\n", data);
	}
	
	return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <iomanip>
#include <climits>
#include <algorithm>
#include <vector>
#include <deque>
#include <queue>
#include <list>
#include <stack>
#include <string>
#include <functional>
#include <numeric>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <unordered_map>
#include <random>
#define _USE_MATH_DEFINES
#include <math.h>
#include <complex>

using namespace std;

#define INF (int)1e8
#define _INF (int)-1e8  
#define INFLL (long long)1e15
#define _INFLL (long long)-1e15
#define Loop(i, n) for(int i = 0; i < (int)n; i++)
#define Loop1(i, n) for(int i = 1; i <= (int)n; i++)
#define Loopr(i, n) for(int i = (int)n - 1; i >= 0; i--)
#define Loopr1(i, n) for(int i = (int)n; i >= 1; i--)
#define bitmanip(m,val) static_cast<bitset<(int)m>>(val)
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef pair<int, int> P;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;

/*******************************************************/

int main() {
  int n; cin >> n;
  vvi a(2, vi(n, 0));
  Loop(i, 2) {
    Loop(j, n) {
      cin >> a[i][j];
    }
  }
  vvi dp(2, vi(n, 0));
  Loop(i, 2) {
    Loop(j, n) {
      int val1 = (j - 1 >= 0) ? dp[i][j - 1] : 0;
      int val2 = (i - 1 >= 0) ? dp[i - 1][j] : 0;
      dp[i][j] = max(val1, val2) + a[i][j];
    }
  }
  cout << dp[1][n - 1] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <utility>
using namespace std;


int main(){
  int x, y, z;
  cin >> x >> y >> z;
  int cnt = 0;
  int res = z;
  while(true){
    res += y + z;
    if(res > x){
      cout << cnt << endl;
      break;
    }
    cnt++;
  }
}

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

int main()
{
	long long int n;
	long long int b,min,c;
	long long int x,y;
	cin>>n;
	min=n;
	for(long long int i=1;i<=sqrt(n);i++)
	{
		if(n%i==0)
		{
			b=n/i;
			c=abs(b-i);
			if(c<min)
			{
				min=c;
				x=i,y=b;
			}
		}
	}
	printf("%lld\n",x+y-2);
}

Measured memory_bytes: 256
#include <map>
#include <string>
#include <iostream>
#include<vector>
#include <set>
#include<math.h>
#include<algorithm>

using namespace std;

int main()
{
	int c;
	double a, b;
	
	while (cin >> a >> b)
	{
		c = log10(a+b) + 1;
		cout << c << endl;
	}
}

Measured memory_bytes: 1264
#include <bits/stdc++.h>
using namespace std;
 
#define MOD (1000000007)
#define f first
#define s second
#define pb(x) push_back(x)
#define mp(x,y) make_pair(x,y)
#define all(x) x.begin(), x.end()
#define print(vec,l,r) for(int i = l; i <= r; i++) cout << vec[i] <<" "; cout << endl;
#define forf(i,a,b) for(int i = (a); i < (b); i++)
#define forr(i,a,b) for(int i = (a); i > (b); i--)
#define input(vec,N) for(int i = 0; i < (N); i++) cin >> vec[i];
typedef long long int ll;
#define ld long double
const int N = 2e5+30;
//https://codeforces.com/problemset/page/2?tags=1700-1700
 
 
void solve(){
   int H,W;
   cin>>H>>W;
   int dp[H+3][W+3];
   char c[H+1][W+1];
   for(int i=1;i<=H;i++){
     for(int j=1;j<=W;j++){
       cin>>c[i][j];
     }
   }
   memset(dp,0,sizeof(dp));
   dp[1][1]=1;
   for(int i=1;i<=H;i++){
     for(int j=1;j<=W;j++){
       if(c[i][j]=='.'){
        if(i-1>=1){
          dp[i][j] = (dp[i][j] + dp[i-1][j])%MOD;
        }
        if(j-1>=1){
          dp[i][j] = (dp[i][j] + dp[i][j-1])%MOD;
        }
       }
     }
   }
   cout<<dp[H][W]<<'\n';
}
 
 
int main(){
 	ios_base::sync_with_stdio(false);
  cin.tie(NULL);
	int T;
  //cin >> T;
  //cout<<prs.size()<<'\n';
	 T = 1;
  //visited[1]=1;
	while(T--){
		solve();
	}
}

Measured memory_bytes: 8564
from pprint import pprint
import heapq

def solve(n, a, b):
    b_pq = []
    b_rev = {}
    delete = []
    for i, b_i in enumerate(b):
        if b_i == a[i]:
            continue
        heapq.heappush(b_pq, (-1 * b_i, i))

    count = 0
    while b_pq:
        tmp = heapq.heappop(b_pq)
        # pprint(tmp)
        b_i = tmp[0] * -1
        i_b = tmp[1]
        # print(i_b, b_i)
        i_a = (i_b - 1 + n) % n
        i_c = (i_b + 1) % n
        b_cand = b_i
        if b_cand - b[i_a] - b[i_c] < a[i_b]:
            continue

        #while b_cand - b[i_a] - b[i_c] >= a[i_b]:
        #    b_cand = b_cand - b[i_a] - b[i_c]
        #    count += 1
        tmp_count =  (b_cand - a[i_b]) // (b[i_a] + b[i_c])
        b_cand -= (b[i_a] + b[i_c]) * tmp_count
        count += tmp_count

        b[i_b] = b_cand
        if b_cand != a[i_b]:
            heapq.heappush(b_pq, (-1 * b_cand, i_b))
        # print("count: ", count)
        # pprint(b)
         

        if b_cand == a[i_b] and b == a:
            return count
    
    return -1


if __name__ == '__main__':

    n = int(input().strip())
    a = list(map(int, input().strip().split(" ")))
    b = list(map(int, input().strip().split(" ")))
    print(solve(n, a, b))

Measured memory_bytes: 121344
#include<cstdio>
#include<iostream>
#include<cmath>

using namespace std;

int main(void){

	double x1,y1,x2,y2;
	double ans;

	cin>>x1>>y1>>x2>>y2;
	printf("%.8f\n",hypot(x1-x2,y1-y2));

	return 0;
}

Measured memory_bytes: 1248
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let s: String = read(&mut stdin_lock, &mut buf, b'\n');
    let cv: Vec<char> = s.chars().collect();
    let l = cv.len();

    let mut dp = vec![vec![0u32; 13]; l + 1];
    dp[0][0] = 1;
    for i in 0..l {
        let c = cv[i];
        if c == '?' {
            for d in 0..10 {
                for j in 0..13 {
                    dp[i + 1][(j * 10 + d) % 13] += dp[i][j];
                    dp[i + 1][(j * 10 + d) % 13] %= 1_000_000_007;
                }
            }
        } else {
            let d = c.to_digit(10).unwrap() as usize;
            for j in 0..13 {
                dp[i + 1][(j * 10 + d) % 13] += dp[i][j];
                dp[i + 1][(j * 10 + d) % 13] %= 1_000_000_007;
            }
        }
    }
    let ans = dp[l][5];
    println!("{}", ans);
}


Measured memory_bytes: 14588
import sys

sys.setrecursionlimit(10000000)
import os
import math
import bisect
import collections
import itertools
import heapq
import re
import queue

# import fractions

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N, K, Q = il()
    P = [K]*N
    ret = [0]*N
    A = iln(Q)
    
    for a in A:
        ret[a-1] += 1

    for n in range(N):
        point = P[n] - Q + ret[n]
        if point <= 0:
            print('No')
        else:
            print('Yes')


if __name__ == '__main__':
    main()


Measured memory_bytes: 10308
from itertools import permutations
import math
n = int(input())
x,y = [],[]
for _ in range(n):
    x_, y_ =map(int,input().split())
    x.append(x_)
    y.append(y_)

c = list(permutations([i for i in range(1,n+1)],n))

g = [[-1]*(n+1) for _ in range(n+1)]
sum = 0
for ci in (c):
    tmp = 0
    for i in range(len(ci)-1):
        if g[ci[i]][ci[i+1]] == -1:
            tmp += math.sqrt((x[ci[i]-1]-x[ci[i+1]-1])**2 
                             + (y[ci[i]-1]-y[ci[i+1]-1])**2)
        else:
            tmp += g[ci[i]][ci[i+1]]
    sum += tmp
print(sum/len(c))

Measured memory_bytes: 13860
#include <iostream>
#include <string>
#include <cmath>

#include <list>
#include <queue>
#include <algorithm>

#define INF 1000000000

using namespace std;

int main(void)
{
    int n, m;

    int connection[9][9];
    for (int i = 0; i < 9; i++) {
        for (int j = 0; j < 9; j++) {
            connection[i][j] = 0;
        }
    }

    int array[] = {2,3,4,5,6,7,8};

    cin >> n >> m;
    for (int i = 1; i <= m; i++) {
        int a, b;
        cin >> a >> b;
        connection[a][b] = 1;
        connection[b][a] = 1;
    }

    int count = 0;

    do {
        bool flag = true;
        if (connection[1][array[0]] == 1) {
            for (int i = 0; i < n - 2; i++) {
                int current = array[i];
                // cout << current << " ";
                // auto itr = find(connection[current].begin(), connection[current].end(), array[i + 1]);
                
                if (connection[current][array[i + 1]] == 0) {
                    flag = false;
                    break;
                }
            }
            if (flag) count++;
        }
        // cout << endl;
    } while (next_permutation(array, array + n - 1));

    cout << count;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

#define MAX_N 1
#define INF 1000000000 //1e9
#define PI 3.14159265359
#define mod 1000000007

int main(){
    long long H;
    cin >> H;
    long long count = 0;
    long long pow = 1;
    for(long long ll = H; ll >= 1; ll /=2){
        count += pow;
        pow *= 2;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
import java.io.*;

public class Main{
	public static void main (String[] args) {
	    //long x;
	    long x1 = 1;
	    try{
		//System.out.println("input number 1<x<100");
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);
		long x = Long.parseLong(br.readLine());
		if(x <= 100 && 1 <= x){
		for(int i=0; i<3; i++){
		x1 = (long)x1 * x;
		}
		System.out.println(x1);
		}else{
		//System.out.println("Input Error");
		}
	    }catch(IOException e){
	    //System.out.println("KUSO key bord");
	    }

	}
}

Measured memory_bytes: 24248
#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; 
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long int ll;
#define ull unsigned long long int
#define all(a) a.begin(),a.end()s
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define hell 1000000007
#define vi vector<int>
#define vll vector<long long>
#define vvi vector<vi>
#define mp make_pair
#define pb push_back
#define MAX 10000001
int main()
{
    ll k,n;
    cin>>k>>n;
    ll a[n];
    ll sum=0;
    for(ll i=0;i<n;i++)
        cin>>a[i];
    vector<ll>v;
    for(ll i=1;i<n;i++)
    {
        v.pb(a[i]-a[i-1]);
        sum+=(a[i]-a[i-1]);
    }
    v.pb(k-sum);
    sort(v.begin(),v.end());
    cout<<k-v[v.size()-1]<<endl;
}

Measured memory_bytes: 3956
#include<iostream>
#include<algorithm>
#include<cmath>
#include<map>
#include<stdio.h>
#include<vector>
using namespace std;
#define int long long
#define double long double
#define rep(s,i,n) for(int i=s;i<n;i++)
#define c(n) cout<<n<<endl;
#define ic(n) int n;cin>>n;
#define sc(s) string s;cin>>s;
#define mod 1000000007
#define inf 1000000000000000007
#define f first
#define s second
#define mini(c,a,b) *min_element(c+a,c+b)
#define maxi(c,a,b) *max_element(c+a,c+b)
#define P pair<int,int>
//printf("%.12Lf\n",);
int keta(int x){
	rep(0,i,30){
		if(x<10){
			return i+1;
		}
		x=x/10;
	}
}
int gcd(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return bb;
		}	
		bb=bb%aa;
		if(bb==0){
			return aa;
		}
	}
}	
int lcm(int x,int y){
	int aa=x,bb=y;
	rep(0,i,1000){
		aa=aa%bb;
		if(aa==0){
			return x/bb*y;
		}	
		bb=bb%aa;
		if(bb==0){
			return x/aa*y;
		}
	}
}
bool p(int x){
	if(x==1)return false;
	rep(2,i,sqrt(x)+1){
		if(x%i==0&&x!=i){
			return false;
		}
	}	
	return true;
}
int max(int a,int b){
	if(a>=b)return a;
	else return b;
}
int min(int a,int b){
	if(a>=b)return b;
	else return a;
}	
int n2[41];		
int nis[41]; 
int nia[41];
int mody[41];
int nn;
int com(int n,int y){
	int ni=1;
	for(int i=0;i<41;i++){
		n2[i]=ni;
		ni*=2;
	}
	int bunsi=1,bunbo=1;
	rep(0,i,y)bunsi=(bunsi*(n-i))%mod;
	rep(0,i,y)bunbo=(bunbo*(i+1))%mod;
	mody[0]=bunbo;
	rep(1,i,41){
		bunbo=(bunbo*bunbo)%mod;
		mody[i]=bunbo;
	}
	rep(0,i,41)nis[i]=0;
	nn=mod-2;
	for(int i=40;i>=0;i-=1){
		if(nn>n2[i]){
			nis[i]++;
			nn-=n2[i];
		}
	}
	nis[0]++;
	rep(0,i,41){
		if(nis[i]==1){
			bunsi=(bunsi*mody[i])%mod;
		}
	}
	return bunsi;
}
int yakuwa(int n){
	int sum=0;
	rep(1,i,sqrt(n+1)){
		if(n%i==0)sum+=i+n/i;
		if(i*i==n)sum-=i;
	}
	return sum;
}	
bool integer(double n){
	if(n==long(n))return true;
	else return false;	
}
int pow(int b,int a){	
	int aa=1;
	rep(0,i,a)aa*=b;	
	return aa;
}
int sankaku(int a){
	return a*(a+1)/2;
} 
bool search(int x){
	int n;
	int a[n];
	int l=0,r=n;
	while(r-l>=1){
		int i=(l+r)/2;
		if(a[i]==x)return true;
		else if(a[i]<x)l=i+1;
		else r=i;
	}
	return false;
}
signed main(){
	ic(n)
	if(n==2){
		c(1)
		return 0;
	}
	if(n==3){
		c(2)
		return 0;
	}		 
	n=n-1;	
	int ans=2;
	rep(2,i,sqrt(n)+1){
		if(n%i==0)ans+=2;
		if(i*i==n)ans-=1;
	}
	n=n+1;
	rep(2,i,sqrt(n)+1){
		if(n%i==0){
			int nn=n;
			while(nn%i==0)nn/=i;
			if(nn%i==1)ans++;
		}
	}
	c(ans)
}	

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define lf double
#define ll long long
#define ii pair<int,int>
#define li pair<ll,int>
#define iii pair<ii,int>
#define heap priority_queue
#define mp make_pair
#define st first
#define nd second
#define pb push_back
#define pp pop_back
#define all(x) x.begin(),x.end()
#define len(x) strlen(x)
#define sz(x) (int) x.size()
#define orta ((bas+son)/2)
#define min3(x,y,z) min(min(x,y),z)
#define max3(x,y,z) max(max(x,y),z)
#define dbgs(x) cerr<<(#x)<<" --> "<<(x)<<" "
#define dbg(x) cerr<<(#x)<<" --> "<<(x)<<endl;getchar()
#define MOD 1000000007
#define inf 2000000000
#define N 3500
#define LOG 26
using namespace std;

int n;

int main() {

	scanf("%d",&n);
	for(int i=1;i<=N;i++) {
		for(int j=1;j<=N;j++) {
			ll left=1ll*i*j*4;
			ll rightval=1ll*n*i*j;
			ll right=1ll*n*(i+j);
			if((left-right)<1) continue ;
			if(rightval%(left-right)==0) {
				printf("%lld %lld %lld",i,j,rightval/(left-right));
				return 0;
			}
		}
	}
	
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <sstream>
#include <cmath>

int main(int argc, const char * argv[]) {

    std::string S;
    std::cin >> S;

    unsigned long size = S.size();
    if(size == 1) {
        std::cout << S;
        return 0;
    }

    long long count = std::pow(2, size - 1);
    long long sum = 0;
    for(unsigned long i=0; i<count; i++) {
        std::string formula;
        formula.push_back(S[0]);
        for(unsigned long j=0; j<=size-2; j++) {
            if(i&(1<<j)) {
                formula.push_back('+');
            }
//            std::cout << j <<std::endl;
            formula.push_back(S[j+1]);
        }

        std::istringstream strm(formula);
        std::string tmp;
        unsigned long ans = 0;
        while(getline(strm, tmp, '+')) {
            ans += std::stoll(tmp);
        }
        sum += ans;

//        std::cout << formula << "=" << ans << std::endl;
    }

    std::cout << sum;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <cmath>
#include <map>
#include <climits>
#include <cassert>
#include <algorithm>
#include <utility>

using namespace std;
using Int = long long int;
using UInt = unsigned long long int;
using VI = vector<long long int>;
using VVI = vector<vector<long long int> >;

// 二つの値の最小値を求める関数
Int Min(const Int a, const Int b) {
    if (a <= b) {
        return a;
    } else {
        return b;
    }
}
// 二つの値の最大値を求める関数
Int Max(const Int a, const Int b) {
    if (a >= b) {
        return a;
    } else {
        return b;
    }
}

int main(void) {
    Int n, a, b;
    cin >> n >> a >> b;
    Int max, min;
    max = Min(a, b);
    min = Max(0, a + b - n);
    cout << max << " " << min << endl;
    return 0;
}


Measured memory_bytes: 3544
<?php
fscanf(STDIN, "%d", $n);
$w = explode(' ', trim(fgets(STDIN)));
$s1 = 0;
$s2 = array_sum($w);
$x = PHP_INT_MAX;
for ($i = 0; $i < $n - 1; $i++) {
	$s1 += $w[$i];
	$s2 -= $w[$i];
	$s = abs($s2 - $s1);
	if ($s < $x) { $x = $s; } else { break; }
}
echo $x;

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

using namespace std;
typedef unsigned long long int ll;
typedef pair<ll, ll > pi;  
typedef pair<pair<ll, ll >, ll > pii;  
vector<ll > vec;
vector<vector<ll > > vec2;
ll MOD = 1000000007;
ll INF = 1145141919454519;

int main() {

    ll A, B, C, D;
    cin >> A >> B >> C >> D;

    if(A+B > C+D){
        cout << "Left" << endl;
    }else if(A+B < C+D){
        cout << "Right" << endl;
    }else{
        cout << "Balanced" << endl;
    }

}

Measured memory_bytes: 384
num = gets.to_i ; line = [0,0,0,0,0,0]
list = Array.new(num)
num.times do |i|
	list[i] = gets.to_i
	if list[i]<165.0
		line[0]+=1
	elsif list[i]<170.0
		line[1] += 1
	elsif list [i]<175.0
		line[2] += 1
	elsif list [i]<180.0
		line[3] += 1
	elsif list [i]<185.0
		line[4] += 1
	else 
		line[5] +=1
	end
end
6.times do |i|
	print i+1 , ":"
	line[i].times do 
		print "*"
	end
	print "\n"
end

Measured memory_bytes: 6128
#include <queue>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <map>
#include <stdio.h>
using namespace std;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for(int i = (a); i < (int)(b); i++)
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vint;
typedef vector<string> vstr;
typedef pair<ll, ll> pint;
unsigned long long inf = (1LL << 62);
ll MOD = (ll)pow(10.0, 9.0) + 7;
pint dx[4] = { {1, 0}, {-1, 0}, {0, 1}, {0, -1} };

ll min(ll a, ll b)
{

	return (a < b) ? a : b;
}
ll max(ll a, ll b) { return (a > b) ? a : b; }


ll N, C, K;
vector<ll> T;
int main() {

	cin >> N >> C >> K;
	T.resize(N);
	rep(i, N)
		cin >> T[i];


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

	ll numbus = 0;
	ll ninzuu = 0;
	ll nowtime = T[0];
	ll lcus = T[0];
	stack<ll> s;
	for (int i = 0; i < T.size(); i++) {

		
		if (s.size() >= C || T[i] > lcus + K) {
			while (!s.empty()) { s.pop(); }

		}


		if (s.empty()) { numbus += 1; lcus = T[i]; }

		s.push(T[i]);

	}

	cout << numbus << endl;
	
	return 0;
}

Measured memory_bytes: 1024
'use strict'

class Main {
  solve() {
    const size = input.nextIntArr();
    const nodes = input.nextIntRange(size[1]);
    const edges = [];
    for (const n of nodes) {
      edges[n[0]] = edges[n[0]] ? edges[n[0]] : [];
      edges[n[1]] = edges[n[1]] ? edges[n[1]] : [];
      edges[n[0]].push(n[1]);
      edges[n[1]].push(n[0]);
    }

    let cnt = 0;
    for (let i = 0; i < size[1]; ++i) {
      const n = nodes[i];
      const stack = [n[0]];
      const visited = [];
      while (stack.length > 0) {
        const e = stack.pop();
        visited[e] = true;
        for (let _e of edges[e]) {
          if (e == n[0] && _e == n[1]) { continue; }
          if (visited[_e]) {continue;}
          stack.push(_e);
        }
      }
      if (!visited[n[1]]) { ++cnt; }
    }
    console.log(cnt);
  }
}

class Input {
  constructor() {
    this.cursor = 0;
    this.inputAll();
  }

  inputAll() {
    this.data = (require("fs").readFileSync("/dev/stdin", "utf8")).split('\n');
    return this.data;
  }

  /* 1行 or 複数行文字列 */
  nextLine(n) {
    if (n) {
      const ret = this.data.slice(this.cursor, this.cursor + n);
      this.cursor += n;
      return ret;
    }
    return this.data[this.cursor++];
  }
  /* 一行文字配列 */
  nextStrArr() { return this.nextLine().split(' '); } 
  /* 一行整数配列 */
  nextIntArr() { return this.nextStrArr().map((e) => parseInt(e)); }
  /* 一行浮動小数点配列 */
  nextFloatArr() { return this.nextStrArr().map((e) => parseFloat(e)); }
  /* 複数行整数配列 */
  nextIntLine(n) { return this.nextLine(n).map((e) => parseInt(e)) }
  /* 複数行浮動小数点配列 */
  nextFloatLine(n) { return this.nextLine(n).map((e) => parseFloat(e)) }
  /* 複数行文字列二次元配列 */
  nextStrRange(n) { return this.nextLine(n).map((line) => line.split(' ')); }
  /* 複数行整数二次元配列 */
  nextIntRange(n) { return this.nextLine(n).map((line) => line.split(' ').map((e) => parseInt(e))); }
  /* 複数行浮動小数点数二次元配列 */
  nextFloatRange(n) {
    return this.nextLine(n).map((line) => line.split(' ').map((e) => parseFloat(e)));
  }
} 
const input = new Input();
(new Main()).solve();


Measured memory_bytes: 11824
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,int> P;
ll N,X;
ll A[4002];
ll R[4002];
int main(){
  cin >>N >> X;
  int mid=0;
  for(int i=0;i<N;i++){
    cin >> A[i];
    if( A[mid] > A[i] ) mid = i;
  }
  for(int i=N;i<2*N;i++) A[i] = A[i-N];
  ll res = LLONG_MAX; 
  for(int i=0;i<N;i++){
    ll at = 0;
    priority_queue<P,vector<P>,greater<P> > q;
    for(int j=0;j<2*N;j++){
      q.push( P(A[j],j) );
      while( !q.empty() ){
        P p = q.top();
        if( j - i <= p.second ) break;
        q.pop();
      }
      //      cout << j << " "<< q.top().first << " " << q.top().second<< endl;
      if( j >= N )
        at += q.top().first;
    }
    res = min( at + X * (ll)i, res );
  }
  cout << res << endl;
}


Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib> 
#include <algorithm>
#define rep(i, n) for(int i = 0; i < n; i++)
#define For(i, m, n) for(int i = m;i < n;i++)

using namespace std;


int main(){
    int n,m;
    cin >> n >> m;
    int tmp;
    int count;

    if(n > m){
        count = n;
        n--;
    } else {
        count = m;
        m--;
    }

    if(n > m){
        count = count + n;
    } else {
        count = count + m;
    }

    cout << count << endl;
    return 0;
}

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

int main(){
  
  int a,b;
  cin >> a >> b;
  vector<int> c={ 0,1,3,1,2,1,2,1,1,2,1,2,1 };
  
  if( c.at(a) == c.at(b) ){
    
    cout << "Yes" << endl;
    
  }
  
  else{
    
    cout << "No" << endl;
    
  }
  
}
  


Measured memory_bytes: 3564
#include<cstdio>
#include<cstdlib>
#include<vector>
#include<string>
#include<algorithm>
#include<set>
#include<sstream>
#include<iostream>

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define pb push_back
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
using namespace std;

int main(){
	string s;
	cin>>s;
	s[3] = '8';
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <map>
#include <vector>
#include <set>
#include <algorithm>
#include <sstream>
#include <queue>
#include <cctype>
#include <cmath>
#include <fstream>

using namespace std;

typedef long long ll;
#define REP(i,k) for(int (i)=0;(i)<(k);(i)++)
#define INF ~(1<<31)
#define CLR(a) memset((a),0,sizeof((a)))
#define EPS 1e-9
#define DBG 1
#define D(s,v) if(DBG) cout<<(s)<<": "<<(v)<<endl;
#define DVEC(s,v) if(DBG) {cout<<(s)<<": "; for(int i=0;i<(v).size();i++) cout<<(v)[i]<<" "; cout<<endl;}
#define DARR(s,v,n) if(DBG) {cout<<(s)<<": "; for(int i=0;i<n;i++) cout<<(v)[i]<<" "; cout<<endl;}

int main(){
    ios_base::sync_with_stdio(0);
    int N;
    while(cin>>N){
        set<int> d;
        for(int i=0;i<N;i++){
            int x; cin>>x;
            d.insert(x);
        }
        cout<<d.size()<<endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
// __builtin_ctz : no of trailing zeros
#define int long long
#define ll long long
#define pp pair<int,int>
#define mod 1000000007
#define trace(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 sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;
int max(int x, int y)
{
    return x>y ? x : y;
}
int min(int x, int y)
{
    return x<y ? x : y;
}
void _(int&a , int b)
{
    a=(a%mod+b%mod)%mod;
    a=(a+mod)%mod;
}
ll cl(ll a,ll b)
{
    return (a/b)+(!(!(a%b)));
}
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;cin >> n;
    cout << (n-1)/2;
    }

Measured memory_bytes: 256
def fibonacchi(n: int) -> int:
    global computed_result
    if computed_result.get(n):
        return computed_result[n]
    else:
        computed_result[n] = fibonacchi(n - 2) + fibonacchi(n - 1)
        return computed_result[n]


if __name__ == "__main__":
    n = int(input())
    computed_result = {0 : 1, 1: 1}
    print(f"{fibonacchi(n)}")



Measured memory_bytes: 5604
#TIME : 
#python에서 소수점연산을 할때 Decimal library를 사용해야한다. float는 바이너리로 표현을 해서 오차가 발생한다.
import sys
from math import sqrt
from decimal import Decimal

input = sys.stdin.readline

def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    s = input()
    return(list(s[:len(s) - 1]))
def invr():
    return(map(int,input().split()))

AB = input().split()
a = Decimal(AB[0])
b = Decimal(AB[1])
res = (a*b).__trunc__()
print(res)

Measured memory_bytes: 71512
import java.util.*
import kotlin.math.*

fun main() {
    val n = readLine()!!.toInt()
    val s = List(n) { readLine()!! }

    val ans = StringBuilder()
    for (i in 'a'..'z') {
        var cnt = Int.MAX_VALUE
        s.forEach { str ->
            cnt = min(cnt, str.count { it == i })
        }
        ans.append(i.toString().repeat(cnt))
    }
    println(ans.toString())
}

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

int main(int argc, char *argv[]) {
  int N, a, b, c;
  scanf("%d", &N);
  a = N % 10;
  N /= 10;
  b = N % 10;
  N /= 10;
  c = N;
  printf("%d\n", (a == 1 ? 9 : 1) + 10 * (b == 1 ? 9 : 1) + 100 * (c == 1 ? 9 : 1));
  
  return 0;
}


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

int main(void)
{
    double n;
    while(cin >> n) {
        for (int i = 1; i < 1000; ++i) {
            double h = 5 * i - 5;
            double t = sqrt(h / 4.9);
            double v = 9.8 * t;
            if (v >= n) {
                cout << i << endl;
                break;
            }
        }
    }
    return 0;
}



Measured memory_bytes: 3124
/*
  GOOD is not Enough
  You've got to be GREAT.
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
// #include<boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;
using namespace __gnu_pbds;
using namespace std;
#define int long long
#define mod 1000000007
#define FAST ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define f(i,n) for(int i=0;i<n;i++)
#define fp(i,k,n) for(int i=k;i<=n;i++)
#define fr(i,k,n) for(int i=k;i>=n;i--)
#define pb push_back
#define pii pair<int,int>
#define dbg(x) cout << (#x) << " is " << (x) << '\n' 
#define F first
#define S second
#define all(a) a.begin(),a.end()
typedef tree<int,null_type,less_equal<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set;

int get(int x)
{
   x=x/100;
    return x;
}

void solve()
{ 
  int n;
  cin >> n;
  int y=0,val=100;
  while(val<n)
  {
      val+=get(val);
      y++;
  }
  cout << y << '\n';
  return;
}

signed main()
{
  FAST
  int T=1;
  // cin >> T;
  while(T--)
  {
    solve();
  }
  return 0;
}

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

#define INF 1e9
using namespace std;
using ll = long long;

int main() {

    string S; cin >> S;
    ll n = S.size();
    vector<ll> ans(n);

    for (int i = 0; i < 2; ++i) {
        ll cnt = 0;
        for (int j = 0; j < n; ++j) {
            if (S[j] == 'R') {
                ++cnt;
            } else {
                ans[j] += cnt / 2;
                ans[j-1] += (cnt + 1) / 2;
                cnt = 0;
            }
        }

        reverse(ans.begin(), ans.end());
        reverse(S.begin(), S.end());

        for (int j = 0; j < n; ++j) {
            if (S[j] == 'R') {
                S[j] = 'L';
            } else {
                S[j] = 'R';
            }
        }
    }

    for (int i = 0; i < n; ++i) {
        cout << ans[i] << ' ';
    }

    cout << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
int cnt[100005];
string s;
int main (){
	int n,m;scanf ("%d%d",&n,&m);
	int ac=0,wa=0;
	for (int i=1,id;i<=m;i++){
		cin>>id>>s;
		if (cnt[id]==-1) continue;
		if (s=="AC") ac++,wa+=cnt[id],cnt[id]=-1;
		else cnt[id]++;
	}
	printf ("%d %d",ac,wa);
	return 0;
}


Measured memory_bytes: 640
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
	Scanner scan = new Scanner(System.in);
	int A = scan.nextInt();
	String op = scan.next();
	int B = scan.nextInt();
	
	int res;
	if(op.equals("+")){
		res = A+B;
	}else{
		res = A-B;
	}
	
	System.out.println(res);
	}
}

Measured memory_bytes: 9812
#include <bits/stdc++.h>
using namespace std;
const int N = 100010;
int rmq[18][N];
int n, L, Q;
int a[N];
void init(){
	int cur = 1;
	for(int i = 1; i <= n; i++){
		if(cur < i) cur = i;
		for(; cur <= n && a[cur] <= L + a[i]; cur++);
		rmq[0][i] = cur - 1;
	}
	for(int i = 1; i < 18; i++)
		for(int j = 1; j <= n; j++)
			rmq[i][j] = rmq[i - 1][rmq[i - 1][j]];
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> a[i];
	cin >> L >> Q;
	init();
	while(Q--){
		int a, b;
		cin >> a >> b;
		if(a > b) swap(a, b);
		int ans = 0;
		for(int i = 17; i >= 0; i--){
			int na = rmq[i][a];
			if(na < b){
				a = na;
				ans += (1 << i);
			}
		}
		cout << ans + 1 << "\n";
	}
	return 0;
}


Measured memory_bytes: 8320
/*
    Washief Hossain Mugdho
    17 September 2020
    Educational DP Knapsack1
*/

#ifndef DEBUG
#pragma GCC optimize("O3")
#endif

#include <bits/stdc++.h>
#define ull unsigned long long
#define ll long long
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define fastio ios_base::sync_with_stdio(0)
#define untie cin.tie(0)
#define ms(a, b) memset(a, b, sizeof a)
using namespace std;
int N, W, w[105], v[105];
ull memo[100005][105];

ull dp(int remaining, int curObj)
{
    if (remaining <= 0 || curObj >= N)
        return 0;
    if (memo[remaining][curObj])
        return memo[remaining][curObj];
    ull res = 0;
    if (w[curObj] <= remaining)
        res = v[curObj] + dp(remaining - w[curObj], curObj + 1);
    return memo[remaining][curObj] = max(dp(remaining, curObj + 1), res);
}

int main()
{
#ifdef LOCAL_OUTPUT
    freopen(LOCAL_OUTPUT, "w", stdout);
#endif
#ifdef LOCAL_INPUT
    freopen(LOCAL_INPUT, "r", stdin);
#endif
    cin >> N >> W;
    for (int i = 0; i < N; i++)
        cin >> w[i] >> v[i];
    cout << dp(W, 0) << endl;
}


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

int main(){
  int r,g,b;
  cin>>r>>g>>b;
  
  int p =100*r+10*g+b;
  if(p%4==0){
    cout<<"YES"<<endl;
  }
  else{
    cout<<"NO"<<endl;
  }
}

  

Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr=input.trim().split("\n");
var NL=arr.shift().split(" ").map(Number);
var N=NL[0];
var L=NL[1];
arr.length=N;
arr=arr.map(Number);
var s=arr.map(function(v,i){return [v,i];});
s.sort(function(a,b){return b[0]-a[0];});
var life=[];
s.forEach(function(v){
   var i=v[1];
   if(i==0){
      if(arr[i]>arr[i+1])life[i]=L-arr[i];
      else life[i]=life[i+1]+L-arr[i];
   }else if(i==arr.length-1){
      if(arr[i]>arr[i-1])life[i]=L-arr[i];
      else life[i]=life[i-1]+L-arr[i];
   }else{
      if(arr[i]>arr[i-1] && arr[i]>arr[i+1])life[i]=L-arr[i];
      else if(arr[i]>arr[i-1] && arr[i]<arr[i+1])life[i]=life[i+1]+L-arr[i];
      else if(arr[i]<arr[i-1] && arr[i]>arr[i+1])life[i]=life[i-1]+L-arr[i];
      else if(arr[i]<arr[i-1] && arr[i]<arr[i+1])life[i]=Math.max(life[i-1],life[i+1])+L-arr[i];
   }
});
var ans=0;
life.forEach(function(v){
   ans=Math.max(ans,v);
});
console.log(ans);

Measured memory_bytes: 40108
#include <iostream>
#include <algorithm>
#include <vector>



//------------------------3-------------------------
#define rep(i,l,r) for(ll i=l;i<r;i++)
using namespace std;
typedef long long ll;


int main()
{
    ll  n,m,k; std::cin >> n >> m >> k;
    ll  a[200001], b[200001];
    // std::vector<long long>  a(n+1), b(m+1);
    a[0]=0; b[0]=0;
    rep(i,1,n+1) cin >> a[i];
    rep(i,1,m+1) cin >> b[i];
    
    rep(i,1,n+1) a[i]+=a[i-1];
    rep(i,1,m+1) b[i]+=b[i-1];
    ll ans=0, r=m;

    rep(i,0,n+1)
    {
        if(a[i]>k) break;
        while (a[i]+b[r]>k)
            r--;
        ans = max(ans, i+r);
    }
    
    cout << ans;

    return 0;
}

Measured memory_bytes: 6748