akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main()
{
    long int A[100][100];
    long int B[100][100];
    long int C[100][100];
    long int m,n,l,i,j,k,sum=0;
    scanf("%ld %ld %ld",&n,&m,&l);
    for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
        {
            scanf("%ld", &A[i][j]);
        }
    }
    for(i=0;i<m;i++)
    {
        for(j=0;j<l;j++)
        {
            scanf("%ld", &B[i][j]);
        }
    }
     for (i=0;i<n;i++) {
      for (j=0;j<l;j++) {
            sum = 0;
        for (k=0;k<m;k++) {
          sum = sum+A[i][k]*B[k][j];
        }
        C[i][j] = sum;
      }
    }
    for (i=0;i<n;i++) {
      for (j=0;j<l-1;j++) {
        printf("%ld ",C[i][j]);
      }
      printf("%ld\n",C[i][l-1]);
    }

  return 0;
}



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

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

using namespace std;

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

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

  int result = max({a + b, a - b, a * b});

  cout << result << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void)
{
    int n,m,l,i,j,k;
    int a[100][100],b[100][100];
    long c[100][100]={0};
    scanf("%d %d %d",&n,&m,&l);
    for(i=0;i<n;i++)
    {
        for(j=0;j<m;j++)
        {
            scanf("%d",&a[i][j]);
        }
    }
     
    for(i=0;i<m;i++)
    {
        for(j=0;j<l;j++)
        {
            scanf("%d",&b[i][j]);
        }
    }
 
    for(i=0;i<n;i++)
    {
        for(j=0;j<l;j++)
        {
            for(k=0;k<m;k++)
            {
                c[i][j]+=a[i][k]*b[k][j];
            }
        }
    }
     
    for(i=0;i<n;i++)
    {
        for(j=0;j<l;j++)
        {
            if(j) printf(" ");
            printf("%ld",c[i][j]);
        }
        printf("\n");
    }
 
    return 0;
}


Measured memory_bytes: 2108
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9+7;
main(){
    ll X,Y;
    cin >> X  >> Y;
    int cnt = 0;
    while(X <= Y){
        cnt++;
        X *= 2;
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long i64;
using std::cout;
using std::endl;
using std::cin;

struct SegmentTree {
	std::vector<int> seg;
	int sz = 1;
	
	SegmentTree(int n) {
		while(sz < n) sz *= 2;
		seg.assign(sz * 2 - 1, 0);
	}
	
	void add(int k, int x) {
		k += sz - 1;
		seg[k] += x;
		
		while(k) {
			k = (k - 1) / 2;
			
			seg[k] = seg[2 * k + 1] + seg[2 * k + 2];
		}
	}
	
	void update(int k, int x) {
		k += sz - 1;
		seg[k] = x;
		
		while(k) {
			k = (k - 1) / 2;
			
			seg[k] = seg[2 * k + 1] + seg[2 * k + 2];
		}
	}
	
	int get(int a, int b, int k, int l, int r) {
		if(b<=l||r<=a) return 0;
		if(a<=l&&r<=b) return seg[k];
		
		return get(a, b, 2 * k + 1, l, (l + r) / 2) + get(a, b, 2 * k + 2, (l + r) / 2, r);
	}
	
	int get(int a, int b) {
		return get(a, b, 0, 0, sz);
	}
};

int main(){
	int n, m; cin >> n >> m;
	std::vector<std::pair<int, int>> segment;
	for(int i = 0; i < n; i++) {
		int a, b; cin >> a >> b;
		
		segment.push_back({a, b});
	}
	sort(begin(segment), end(segment));
	
	typedef std::pair<int, int> P;
	
	int counter = 0;
	SegmentTree seg(m + 1);
	std::vector<std::vector<int>> ans(m + 1, std::vector<int>(2, 0));
	std::priority_queue<P, std::vector<P>, std::greater<P>> qu;
	for(int i = 0; i <= m; i++) {
		while(counter < n and segment[counter].first == i) {
			qu.push({segment[counter].second, segment[counter].first});
			
			seg.add(segment[counter++].first, 1);
		}
		
		while(!qu.empty() and qu.top().first + 1 == i) {
			auto p = qu.top(); qu.pop();
			
			seg.add(p.second, -1);
		}
		
		for(int j = 1; j * j <= i; j++) {
			if(i % j) continue;
			if(i / j == j) {
				ans[j][1] += seg.get(ans[j][0] + 1, i + 1);
				ans[j][0] = i;
			} else {
				ans[j][1] += seg.get(ans[j][0] + 1, i + 1);
				ans[j][0] = i;
				ans[i / j][1] += seg.get(ans[i / j][0] + 1, i + 1);
				ans[i / j][0] = i;
			}
		}
	}
	
	for(int i = 1; i <= m; i++) cout << ans[i][1] << endl;	
	return 0;
}


Measured memory_bytes: 17260
#include<iostream>
#include<cmath>
using namespace std;
const double eps = 1.0e-9;
int main()
{
  while(true){
    unsigned long long int n,r,ans=0;
    cin >> n;
    if( n == 0 )break;
    unsigned long long int tmp = n/2LL;
    unsigned long long int rn = (long long int)ceil(sqrt(n/2)-eps);
    //cout << " RN : " << rn << endl;
    for(unsigned long long int i = 2; i <=rn; ++i){
      if(n%(2*(i-1))==0)tmp+=n/(2*(i-1));
      else tmp+=n/(2*(i-1))+1;
    }
    tmp *= 2;
    tmp -= rn*rn;
    ans = 8*(n+tmp);
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 868
def make_alphabet(now_alphabet, alphabet):
    next_alphabet = []
    for n_al in now_alphabet:
        for al in alphabet:
            next_alphabet.append(n_al+al)
    return next_alphabet

a = int(input())
b = []
for a in range(a):
    b.append(input())
alphabet = [chr(ch) for ch in range(97,123)]
now_alphabet = alphabet
count=0
flag=0

while flag==0:
    letter = []
    for word in b:
        for i in range(len(word)-count):
            letter.append(word[i:i+1+count])
    rem = list(set(now_alphabet) - set(letter))
    if rem!=[]:
        print(sorted(rem)[0])
        flag=1
    count+=1
    now_alphabet = make_alphabet(now_alphabet, alphabet)
            


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

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define INF 999999999
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main()
{
	string t,s;
	cin >> t >> s;
	int len = t.length();

	REP(i,len) {
		t = t.substr(len-1) + t.substr(0,len-1);
		if (t == s) {
			cout << "Yes" << endl;
			break;
		}
		if (i == len-1) cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
MAX = int(10e18)


def count(arr1, arr2, target, remove_dup):
    ret = 0
    j = len(arr2)
    for i, val1 in enumerate(arr1):
        while j > 0 and val1 * arr2[j-1] > target:
            j -= 1
        ret += j
        if remove_dup and j >= (i+1):
            ret -= 1
    if remove_dup:
        ret //= 2
    return ret


def search_negative(pos, neg, K):
    neg.sort()
    pos.sort(reverse=True)
    lo = -MAX
    hi = 0
    while lo < hi:
        mid = (lo + hi) // 2
        cnt = count(pos, neg, mid, False)
        if cnt < K:
            lo = mid + 1
        else:
            hi = mid
    return lo


def search_positive(pos, neg, K):
    pos.sort()
    neg.sort(reverse=True)
    lo = 0
    hi = MAX
    while lo < hi:
        mid = (lo + hi) // 2
        cnt = count(pos, pos, mid, True) + count(neg, neg, mid, True)
        if cnt < K:
            lo = mid + 1
        else:
            hi = mid
    return lo


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    negative_nums = []
    positive_nums = []
    zeros = 0
    for a in A:
        if a < 0:
            negative_nums.append(a)
        elif a > 0:
            positive_nums.append(a)
        else:
            zeros += 1
    negative_count = len(negative_nums) * len(positive_nums)
    zero_count = zeros * (N-1) - zeros * (zeros-1) // 2
    ans = 0
    if K <= negative_count:
        ans = search_negative(positive_nums, negative_nums, K)
    elif K <= negative_count + zero_count:
        ans = 0
    else:
        ans = search_positive(positive_nums, negative_nums,
                              K - negative_count - zero_count)
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 96084
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define INF 10000000
#define rep(i,a,b) for(int (i)=a;(i)<(int)(b);(i)++)
using ipair = pair<int,int>;
using itpl = tuple<int,int>;

int main(){
    string S,T;
    bool flag = true;
    cin >> S >> T;
    for(int i=0;i<S.size();i++){
        if(S[i]!=T[i]){flag = false;break;}
    }
    if(flag) cout << "Yes"<<endl;
    else cout << "No" <<endl;
}

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

class Main{
	public static void main(String[] args) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		String[] str = new String[2];
		str = in.readLine().split(" ");
		int a = Integer.parseInt(str[0]);
		int b = Integer.parseInt(str[1]);

		if (a < 1 || b < 1 || Math.pow(10, 9) < a || Math.pow(10, 9) < b) {
			throw new RuntimeException("error: Range over");
		}
		int d = a / b;
		int r = a % b;
		double f = a / (double) b;
		System.out.printf("%d %d %.5f", d, r, f);
	}
}

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

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int a, b;
    cin >> a >> b;
    for (int i = 1; i <= 3; i++) {
        if (a*b*i % 2 == 1) {
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";

    
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef vector<ll> vl;
typedef pair<ll, ll> PP;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
#define all(v) v.begin(), v.end()
#define inputv(v, n)                                                           \
    vl v;                                                                      \
    rep(i, n) {                                                                \
        ll x;                                                                  \
        cin >> x;                                                              \
        v.push_back(x);                                                        \
    }
bool chmin(ll& a, ll& b) { if (b < a) { a = b; return 1; } return 0; }
bool chmax(ll& a, ll& b) { if (b > a) { a = b; return 1; } return 0; }
const ll INF = 999999999999999;
const ll MOD = 1000000007;
const ll MAX_N = 500010;
ll a, b, c, d, e, f, p, t, x, y, z, q, m, n, r, h, k, w, l, ans;
int main(){
    map<ll, ll> M;
    rep(i, 30) {
        M[(1 << i) - 1] = i;
    }
    cin >> n;
    inputv(A, n);
    vl dp(30,0);
    a = 0;
    rep(i, n) {
        a ^= A[i];
        dp[M[A[i] ^ (A[i] - 1)]]++;
        //cout<<M[(A[i] ^ (A[i]-1))]<<endl;
    }

    for (ll i = 30; i > 0;i--) {
        if (((1 << (i - 1)) & a) > 0) {
            dp[i]--;
            if (dp[i] < 0) {
                cout << -1 << endl;
                return 0;
            }
            a = a ^ ((1 << i) - 1);
            ans++;
        }
    }

    cout << ans << endl;

}


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

int main(){
  int l;
  cin >> l;
  string s, t;
  cin >> s >> t;
  if(s > t) swap(s,t);
  int ls = s.length(), lt = t.length();
  string ans = "";
  int res = l;
  vector<bool> can(l+1,false);
  can[0] = true;
  rep(i,l) {
    if(can[i]) {
      if(i + ls <= l) can[i+ls] = true;
      if(i + lt <= l) can[i+lt] = true; 
    }
  }
  if(s == t) {
    int k = l / s.length();
    rep(i,k) ans += s; 
  } else {
    if(ls < lt and s == t.substr(0,ls)) {
      string u = t;
      int lu = u.length();
      while(ls < lu and s == u.substr(0,ls)) {
        u = u.substr(ls,lu-ls);
        lu = u.length();
      }
      bool f = false;
      if(u < s) f = true;
      if(lu < ls and u == s.substr(0,lu) and s.substr(lu,ls-lu) < u) f = false;
      while(res > 0) {
        if((f and res - lt >= 0 and can[res-lt]) or (res - ls < 0 or !can[res-ls])) {
          ans += t;
          res -= lt;
        } else {
          ans += s;
          res -= ls;
        }
      }
    } else {
      while(res > 0) {
        if(res - ls >= 0 and can[res-ls]) {
          ans += s;
          res -= ls;
        } else {
          ans += t;
          res -= lt;
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3956
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
constexpr char ln =  '\n';

const int mx=100010;
const ll mod=1e9+7;


int main(){
  string s,t;
  cin >> s >> t;
  int n = s.size();
  int m = t.size();
  vector<vector<int>> dp(3010, vector<int>(3010,0));
  rep(i,n)rep(j,m){
    dp[i+1][j+1] = dp[i][j];
    if(s[i]==t[j]){
      dp[i+1][j+1]++;
    }
    dp[i+1][j+1] = max(dp[i+1][j+1], max(dp[i][j+1],dp[i+1][j]));
  }
  string ans = "";
  for(int i=n,j=m; i>0 && j>0; ){
    if(dp[i][j]==dp[i-1][j]){
      i--;
    } else if(dp[i][j-1]==dp[i][j]){
      j--;
    } else {
      ans.push_back(s[i-1]);
      i--; j--;
    }
  }
  reverse(ans.begin(),ans.end());
  cout << ans << ln;
  return 0;
}

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

int compareInt(const void* a, const void* b)
{
    int aNum = *(int*)a;
    int bNum = *(int*)b;

    return aNum - bNum;
}

int main(){
  int n=0;
  int k=0;
  int p[2001]={0};
  int sum=0;

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

  qsort(p,sizeof(p)/sizeof(p[0]),sizeof(int),compareInt);

  while(p[i]==0){
    i++;
  }
  for(j=i;j<i+k;j++){
    sum+=p[j];
  }

  printf("%d",sum);
  return 0;
}


Measured memory_bytes: 1756
package main

import (
    "fmt"
    "bufio"
    "os"
    "strings"
    "strconv"
)

func main() {
    var str string
    stdin := bufio.NewScanner(os.Stdin)
    retval := 0

    if stdin.Scan() {
        str = stdin.Text()
        arr := strings.Split(str, " ")
        A, _ := strconv.Atoi(arr[0])
        B, _ := strconv.Atoi(arr[1])
        C, _ := strconv.Atoi(arr[2])
        count := B / A

        if count > C {
            retval = C
        } else {
            retval = count
        }

        fmt.Println(retval)
    }
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int MOD = 1000000009;
const long long INF = 1LL << 60;

struct UnionFind {
    vector<int> d;
    UnionFind(int n = 0): d(n, -1) {};
    int find(int x) {
        if (d[x] < 0) return x;
        return d[x] = find(d[x]);
    }
    bool unite(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return false;
        if (d[x] > d[y]) swap(x, y);
        d[x] += d[y];
        d[y] = x;
        return true;
    }
    bool same(int x, int y) { return find(x) == find(y); }
    int size(int x) { return -d[find(x)]; }
};

int main() {
    int N, M;
    cin >> N >> M;
    UnionFind uf(N);
    for (int i = 0; i < M; ++i) {
        int A, B;
        cin >> A >> B;
        --A, --B;
        uf.unite(A, B);
    }

    int res = 0;
    for (int i = 0; i < N; ++i) res = max(res, uf.size(i));
    cout << res << endl;
}

Measured memory_bytes: 4056
N, M = map(int, input().split())

le = 0
ri = N - 1
for i in range(M):
    L, R = map(int, input().split())
    L -= 1
    R -= 1
    le = max(le, L)
    ri = min(ri, R)

if (le <= ri):
    print(ri - le + 1)
else:
    print(0)


Measured memory_bytes: 3060
#include <algorithm>
#include <cassert>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main(int argc, char* argv[]) {
  int N, Y;
  cin >> N >> Y;

  for (int i = 0; i < Y; i++) {
    for (int j = 0; j < Y - i; j++) {
      int k = N - i - j;
      if (k < 0) {
        break;
      }
      int sum = 10000 * i + 5000 * j + 1000 * k;
      if (sum > Y) {
        if (j == 0)
          goto fail;
        else
          break;
      } else if (sum == Y) {
        cout << i << " " << j << " " << k << endl;
        assert(i + j + k == N);
        return 0;
      }
    }
  }

fail:
  cout << "-1 -1 -1" << endl;

  return 0;
}


Measured memory_bytes: 256
N, M, C = map(int, input().split())
#2行目B
B = [int(i) for i in input().split()]

counter = 0

for i in range(N):
  A = [int(i) for i in input().split()]
  index = 0
  for j in range(M):
    index += A[j]*B[j]
  if index + C > 0:
    counter += 1

print(counter)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int N = stdIn.nextInt();
		switch(N % 10){
		case 2:
		case 4:
		case 5:
		case 7:
		case 9:
			System.out.println("hon");
			break;
		case 0:
		case 1:
		case 6:
		case 8:
			System.out.println("pon");
			break;
		case 3:
			System.out.println("bon");
			break;
		}
		stdIn.close();
	}
}

Measured memory_bytes: 35608
//
// C - たくさんの数式 / Many Formulas
//

#include <iostream>

using namespace std;
using LL = long long;

LL rec(LL, int, int);

string S;
LL num[10][11];

int main() {

    cin >> S;

    for (int i = 0; i < S.length(); i++) {
        for (int j = 1; j <= S.length() - i; j++) {
            num[i][j] = stoll(S.substr(i, j));
        }
    }

    cout << rec(0, 0, 1) << endl;
}

LL rec(LL sum, int p, int len) {

    if (p + len == S.length()) {
        return sum + num[p][len];
    } else {
        return rec(sum + num[p][len], p + len, 1) + rec(sum, p, len + 1);
    }
}

Measured memory_bytes: 760
///答え見ました
#include <bits/stdc++.h>
using namespace std;

vector<int>to[2000005];
vector<int>ans;
void dfs(int v,int p=-1){
  for(int u : to[v]){
    if(u==p) continue;
    ans[u] += ans[v];
    dfs(u,v);
  }
}


int main() {
  int n,q;
  cin >> n >> q;
  
  for(int i=0; i<n-1; i++){
   int a,b;
   cin >> a >> b;
   a--;
   b--;
   to[a].push_back(b);
   to[b].push_back(a);
  }
  
  ans.resize(n);
  
  for(int i=0; i<q; i++){
    int x,y;
    cin >> x >> y; 
    x--;
    ans[x]+=y;
  }
  
  dfs(0);
  for(int i=0; i<n; i++){
   cout << ans[i] << endl; 
  }
  
  return 0;
  
}


Measured memory_bytes: 65664
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(int i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
const ll INF = 1000000000000000;
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl
//DBG("","","","");

signed main(){
	IO_STREAM;
	string S;	cin>>S;
	int size=S.size();
	size=size/2+size%2;
	string T;
	T=S;
	reverse(all(T));
	int ans=0;
	rep(i,0,size){
		if(T[i]!=S[i]){
			ans++;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3584
a = gets.chomp.to_i
b = gets.chomp.to_i
c = gets.chomp.to_i
x = gets.chomp.to_i
ans = 0
(0..a).each do |i|
  (0..b).each do |j|
    (0..c).each do |l|
      ans += 1 if 500 * i + 100 * j + 50 * l == x
    end
  end
end
puts ans


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

int main(){
    using namespace std;
    unsigned long X;
    {
        long x;
        cin >> x;
        X = static_cast<unsigned long>(max(x, -x));
    }
    unsigned long K, D;
    cin >> K >> D;
    if(K * D < X)return 0 & printf("%lu\n", X - K * D);
    K -= X / D;
    X %= D;
    cout << (K & 1 ? D - X : X) << endl;
    return 0;
}

Measured memory_bytes: 3692
#include <stdio.h>
 
int main(void) {
  int n = 0;
  long sum = 0;
  scanf("%d", &n);
  for(int i = 1;i <= n;i++) {
    if(i % 3 == 0 && i % 5 == 0);
    else if(i % 3 == 0);
    else if(i % 5 == 0);
    else sum += i;
  }
  printf("%ld\n", sum);
  return 0;
}

Measured memory_bytes: 2156
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;

int main(){
  int N,K;
  cin>>N>>K;
  string S;
  cin>>S;
  vector<int> v;
  if(S[0]=='0')v.push_back(0);
  REP(i,N){
    int p=0;
    while(S[i+p]==S[i] and i+p<N)p++;
    v.push_back(p);
    i+=p-1;
  }
  if(S[N-1]=='0')v.push_back(0);
  // for(auto e:v)cerr<<e;
  // cerr<<endl;
  int M=v.size();
  int temp=0;
  if(2*K+1>=M){
    cout<<N<<endl;
    return 0;
  }
  int l=0;
  int r=2*K+1;
  REP(i,r){
    temp+=v[i];
  }
  int ans=temp;
  while(1){
    r+=2;
    l+=2;
    if(r>M)break;
    temp+=v[r-2]+v[r-1];
    temp-=v[l-2]+v[l-1];
    ans=max(ans,temp);
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1020
#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>;
#define chmax(x,y) x = max(x,y);
const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};
const int INF = 1001001001;

int main() {
    ll n;
    cin >> n;
    string ans;
    while (n > 0) {
      n--;
      ans += 'a' + n%26;
      n /= 26;
    }
    reverse(ans.begin(), ans.end());
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3512
#include <bits/stdc++.h>
using namespace std;
 
#define fast { ios :: sync_with_stdio(false); cin.tie(0); cout.tie(0); }
#define pb push_back
#define ll long long
 
#define vi vector<int>
#define vl vector<long>
#define vll vector<long long>
 
#define infi INT_MAX
#define infl LONG_LONG_MAX
#define f(i,a,b) for(ll i=a;i<b;i++)
#define fi(i,a,b) for(ll i=(b-1);i>=a;i--)
#define F first
#define S second
#define G(a,b) get<a>(b)
#define MP make_pair
#define MT make_tuple
#define pll pair<ll,ll> 
#define endl "\n"
#define ALL(v) v.begin(),v.end()
#define nl cout<<"\n";
#define pr(x) cout<<x;
#define pr1(x) cout<<x<<" ";
#define pr2(x,y) cout<<x<<" "<<y;


void func()
{
  ll h,w;
  cin>>h>>w;
  char c[h+5][w+5];
  f(i,1,h+1) f(j,1,w+1) cin>>c[i][j];
  ll dp[h+1][w+1];
  dp[h][w]=0;
  fi(i,1,h+1)
  {
    fi(j,1,w+1)
    {
      if(i==h && j==w) continue;
      dp[i][j]=infl;
      if(j!=w)
      {
        if(c[i][j]==c[i][j+1]) dp[i][j]=min(dp[i][j+1],dp[i][j]);
        else  dp[i][j]=min(dp[i][j+1]+1,dp[i][j]);
      }
      if(i!=h)
      {
        if(c[i][j]==c[i+1][j]) dp[i][j]=min(dp[i][j],dp[i+1][j]);
        else  dp[i][j]=min(dp[i][j],dp[i+1][j]+1);
      }
    }
  }
  if(c[1][1]=='.') //cout<<dp[1][1]<<endl;
  {
    ll cnt=dp[1][1]+1;
    pr(cnt/2) nl
  }
  else //cout<<dp[1][1]+1<<endl;
  {
    ll cnt=dp[1][1]+1;
    //cout<<"hi\n";
    if(cnt%2==0)
    {
      pr(cnt/2) nl
    }
    else 
    {
      pr((cnt/2)+1) nl
    }
  }
  //f(i,1,h+1)
  //{
  //  f(j,1,w+1) pr1(dp[i][j])
  //  nl
  //}
}

int main() 
{
    fast
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
    
    ll ntc=1;
    //cin>>ntc;

    while(ntc)
    {
      func();
      ntc--;
    }
 
    return 0;
}

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

int main()
{
    int n;
    string s;
    cin>>n>>s;

    for(int i=0; i<4; ++i) {
        int a[n]={};
        a[0]=i/2;
        a[1]=i%2;

#define F(i) (s[i]%2^a[i]^a[(n+i-1)%n])
        for(int j=1; j+1<n; ++j) a[j+1]=F(j);

        if (a[0]==F(n-1) and a[1]==F(0)) {
            for(int e: a) cout<<"WS"[e];
            cout<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
}


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

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

    if(a < 10 && b < 10){
        cout << a * b <<endl;
    }
    else{
        cout << -1 <<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
	int N, a, b = 0, X;
	cin >> N;
    X = N;
	for (int i = 0; 1; i++){
      a = X % 10;
      X /= 10;
      b += a;
      if (X < 10){
        b += X;
        break;
      }
    }
  if (N % b == 0){
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3628
# @author 

import sys

class CUbiquity:
    def solve(self, tc=0):
        MOD = 10 ** 9 + 7

        n = int(input())
        if n == 1:
            ans = 0
        else:
            ans = (pow(10, n, MOD) - 2 * pow(9, n, MOD) + pow(8, n, MOD)) % MOD
        print(ans)



solver = CUbiquity()
input = sys.stdin.readline

solver.solve()


Measured memory_bytes: 61800
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <cassert>
#include <unordered_map>

#define _(x) { cout << #x << " = " << x << " "; }

const double E = 1e-8;
const double PI = acos(-1);

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, a + 3);
    cout << a[0] + a[1] << '\n';
    return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
                 
                int main(void)
                {
                 int n,m1,m2,m3;
                  scanf("%d",&n);
                  m1=n%10;
                  m2=n%100-m1;
                  m3=n%1000-m2-m1;
                  
                  if(m1==7)
                  {
                    printf("Yes");
                  }
                  else if(m2==70)
                  {
                    printf("Yes");
                  }
                  else if(m3==700)
                  {
                     printf("Yes");
                  }
                  else
                     printf("No");
                  
                  return 0;
                }

Measured memory_bytes: 1728
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define debug2(x, y)                       \
  cerr << "(" << #x << "," << #y << ") = " \
       << "(" << x << "," << y << ")\n"
#define all(x) x.begin(), x.end()
#define each(a, x) for (auto& a : (x))
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define int long long
#define yn(x) puts((x ? "Yes" : "No"))
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
const int MX = 1e5 + 5, INF = 5LL << 57, MOD = 1e9 + 7;

int N, M;
string S;
vi va, vb;

void input() {
  ;
  ;
  cin>>N;
  int ans = 0;
  rep(i,1,N){
    if (i%3 == 0 || i%5 == 0){
      ;
    }
    else {
      ans += i;
    }
  }
  cout<<ans<<endl;
}
void solve() {
  ;
  ;
}
signed main() {
  cout << setprecision(12);
  input();
  solve();
  return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPi(i, a, b) for(int i=int(a); i<int(b); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;

int main(){
    int N;
    cin >> N;
    string S;
    cin >> S;

    int ans = 0;
    char last = 'A';
    REP(i,N){
        char c = S[i];
        if(c == last){
            
        }
        else{
            ans++;
        }
        last = c;
    }

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>

using namespace std;

int main()
{
    double x1,x2,y1,y2;
    cin >> x1 >> y1 >> x2 >> y2;
    cout << fixed << setprecision(8);
    cout << sqrt(pow(x2-x1,2)+pow(y2-y1,2));
    cout << endl;

    return 0;
}


Measured memory_bytes: 3288
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N,M;cin >> N >> M;
  vector<bool> pos(N,false);
  vector<int> num(N,1);
  pos[0] = true;
  rep(i,M){
    int x,y;cin >> x >> y;
    --x;--y;
    if(pos[x]) pos[y]=true;
    --num[x];
    ++num[y];
    if(num[x]==0)pos[x] = false;
  }
  int ans = 0;
  rep(i,N) if(pos[i]) ++ans;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 640
#[test]
fn check_solve() {
    println!("input:\n3\n1 -1 2\noutput:\n{}\n", solve("3\n1 -1 2\n"));
    println!("input:\n3\n1 1 1\noutput:\n{}\n", solve("3\n1 1 1\n"));
    println!(
        "input:\n5\n-2 -1 0 1 2\noutput:\n{}\n",
        solve("5\n-2 -1 0 1 2\n")
    );
    println!(
        "input:\n5\n1 2 3 4 5\noutput:\n{}\n",
        solve("5\n1 2 3 4 5\n")
    );
    println!(
        "input:\n5\n-5 -4 -3 -2 -1\noutput:\n{}\n",
        solve("5\n-5 -4 -3 -2 -1\n")
    );
}
fn solve(src: &str) -> String {
    let mut sc = Scanner::from_str(src);
    let mut ret = String::new();
    use std::fmt::Write;
    let n: usize = sc.read();
    let mut a: Vec<isize> = (0..n).map(|_| sc.read()).collect();
    a.sort();
    let mut k = 1;
    while k < n - 1 && a[k] < 0 {
        k += 1;
    }
    for i in k..n - 1 {
        writeln!(&mut ret, "{} {}", a[0], a[i]).unwrap();
        a[0] -= a[i];
    }
    for i in 0..k {
        writeln!(&mut ret, "{} {}", a[n - 1], a[i]).unwrap();
        a[n - 1] -= a[i];
    }

    format!("{}\n{}", a[n - 1], ret)
}
fn main() {
    let mut buf = String::new();
    use std::io::{Read, Write};
    std::io::stdin().read_to_string(&mut buf).unwrap();
    std::io::stdout().write_all(solve(&buf).as_bytes()).unwrap();
}
struct Scanner<'a>(std::str::SplitWhitespace<'a>);
impl<'a> Scanner<'a> {
    fn from_str(src: &str) -> Scanner {
        Scanner(src.split_whitespace())
    }
    fn get(&mut self) -> &str {
        self.0.next().unwrap()
    }
    fn read<T: std::str::FromStr>(&mut self) -> T {
        self.get().parse().ok().unwrap()
    }
}


Measured memory_bytes: 12148
#include <bits/stdc++.h>
#define INT long long
#define oo (INT)(6e18)
using namespace std;

INT a, b, now = 1;
queue<INT> q;
int main()
{
	ios::sync_with_stdio(false);
	cin>>a>>b;
	for(int i = 0 ; i < a ; i++ )
        now = min( now+b, now*2 );
    cout<<now<<endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
edge = [[] for _ in range(N)]
for _ in range(N-1):
    a,b,c = map(int,input().split())
    a -= 1
    b -= 1
    edge[a].append((b,c))
    edge[b].append((a,c))
Q,K = map(int,input().split())
K -= 1
dist = [-1 for _ in range(N)]
dist[K] = 0
searched = [i == K for i in range(N)]
search = [e for e in edge[K]]
while len(search) > 0:
    e = search.pop()
    n,d = e[0], e[1]
    searched[n] = True
    dist[n] = d
    for c,d2 in edge[n]:
        if searched[c]:
            continue
        search.append((c, d+d2))
for _ in range(Q):
    x,y= map(int, input().split())
    x -= 1
    y -= 1
    print(dist[x]+dist[y])

Measured memory_bytes: 46956
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class CManagement {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int N;
        cin >> N;
        map<int, int> cnt;
        REP(i, N-1) {
            int a;
            cin >> a;
            cnt[a]++;
        }
        FOR(i, 1, N) {
            cout << cnt[i] << endl;
        }
    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    CManagement solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 16164
//
// Created by Hideaki Imamura on 2020-01-02.
//
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

ll n, m, a[100001];

ll n_handshake_geq_x(ll x) {
    ll ret = 0;
    for (int i = 0; i < n; ++i) {
        ret += n - (lower_bound(a, a + n, x - a[i]) - a);
    }
    return ret;
}

int main() {
    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }
    sort(a, a + n);

    ll l = 0, r = 300000, mid;
    while (r - l > 1) {
        mid = (r + l) / 2;
        ll tmp = n_handshake_geq_x(mid);
        if (tmp < m) {
            r = mid;
        } else {
            l = mid;
        }
    }
    // l is the maximum number of x used for >=m number of handshakes.

    ll accumulated_a[100001];
    accumulated_a[n] = 0;
    for (int i = n - 1; i >= 0; --i) {
        accumulated_a[i] = accumulated_a[i + 1] + a[i];
    }

    ll ans = 0, n_used = 0;
    for (int i = 0; i < n; ++i) {
        ll index_for_i = lower_bound(a, a + n, l - a[i]) - a;
        ans += accumulated_a[index_for_i] + a[i] * (n - index_for_i);
        n_used += n - index_for_i;
    }

    cout << ans - (n_used - m) * l << endl;
}

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

int main() {
    int n, l; cin >> n >> l;
    vector<string> s(n);

    rep(i, n) {
        cin >> s.at(i);
    }
    sort(s.begin(), s.end());

    rep(i, n) {
        cout << s.at(i);
    }
    cout << endl;
    return 0;
}

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

const int N = 1e5+5;

int n, MinOP[N];
vector<int> V;

int main() {
    fill(MinOP + 1, MinOP + N, (int)1e9);
    V.emplace_back(1);
    for(int i = 6; i < N; i *= 6) V.emplace_back(i);
    for(int i = 9; i < N; i *= 9) V.emplace_back(i);
    for(auto x : V) for(int i = x; i < N; ++i) MinOP[i] = min(MinOP[i], MinOP[i-x] + 1);
    scanf("%d", &n);
    printf("%d\n", MinOP[n]);
}

Measured memory_bytes: 640
#include<iostream>
using namespace std;
typedef long long ll;

int main()
{
    ll n;
    cin>>n;
    ll ans=0;
    if(n%2==1) cout<<0<<endl;//input//
    else{
    n/=2;
    while(n>=5){
        n/=5;
        ans+=n;
    }
    cout<<ans;
    }
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size)
#define MOD 1000000007
const long long mod = 1e9+7;
typedef vector<long long> Vl;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<Vl> VVl;
typedef pair<int, int> PII;
typedef long long ll;

int main(){
    int a=0,b=0,c=0,d,n=0,x=0;
    VI m(5);
    string s,s1,s2;
    cin >> a >> x;
    cout << (a*3 + x) /2  << endl;
    return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
    string s;cin>>s;
    int res=1<<29;
    for(int i=0;i<=1;i++){
        int val=i;
        int count=0;
        for(int i=0;i<s.size();i++){
            if(s[i]-'0'!=val)count++;
            val=1-val;
        }
        res=min(res,count);
    }
    cout<<res<<endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
using namespace std;
using ll = long long;

int main()
{
    ll q;
    ll c, a, n;

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

        ll ans = 0;
        for (int j = 0; j <= 1000; j++) {
            for (int k = 0; k <= 1000; k++) {
                ll tmpc = c - j * 3 - k * 2;
                ll tmpa = a - k;

                if (tmpc < 0 || tmpa < 0) continue;
                ans = max(ans, j + k + min(tmpc, min(tmpa, n)));
            }
        }

        cout << ans << endl;
    }

    return 0;
}



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

using namespace std;
using ll = long long;

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

  int n, m;
  cin >> n >> m;
  vector<bool> ng(n + 1);
  for (int i = 0; i < m; i++) {
    int a;
    cin >> a;
    ng[a] = true;
  }

  const ll mod = 1e9 + 7;
  vector<ll> memo(n + 1, -1);
  memo[0] = 1;
  function<ll(int)> f = [&](int n) -> ll {
    if (n < 0)
      return 0;
    if (memo[n] != -1)
      return memo[n];
    if (ng[n])
      return 0;
    return memo[n] = (f(n - 1) + f(n - 2)) % mod;
  };
  cout << f(n) << endl;

  // vector<ll> dp(n + 1, 0);
  // dp[0] = 1;
  // for (int i = 1; i <= n; i++) {
  //   if (find(a.begin(), a.end(), i) != a.end())
  //     continue;
  //   dp[i] += dp[i - 1];
  //   dp[i] %= mod;
  //   if (i > 1) {
  //     dp[i] += dp[i - 2];
  //     dp[i] %= mod;
  //   }
  // }
  //
  // cout << dp[n] << endl;

  return 0;
}


Measured memory_bytes: 10120
#include<stdio.h>
     
    int main(){
      int flag[3]={},i;
      char s[3];
      scanf("%s",s);
      for(i=0;i<3;i++){
        if(s[i]=='a') flag[0]=1;
        else if(s[i]=='b') flag[1]=1;
        else if(s[i]=='c') flag[2]=1;
      }
      if(flag[0]==1&&flag[1]==1&&flag[2]==1)
        printf("Yes\n");
      else
        printf("No\n");
    }

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <tuple>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repd(i, a, b) for (ll i = (ll)(a); i < (ll)(b); i++)
#define repdm(i, a, b) for (ll i = (ll)(a); i > (ll)(b); i--)

int main()
{

  int N, K;
  cin >> N >> K;

  double ans = 0;
  repd(i, 1, N + 1)
  {
    int cnt = 0;
    int P = i;
    while (P < K)
    {
      P = P * 2;
      cnt++;
    }
    ans += (double(1.0) / double(N)) * (double(1.0) / double(pow(2, cnt)));
  }
  printf("%.12f\n", ans);
}

Measured memory_bytes: 256
def main():
  n = int(input())
  restrictionArray = list(map(int,input().split()))
  resultArray = [0] * (n+1)
  restrictionArray.append(10000000)
  
  for i in range(n):
    resultArray[i] = min(restrictionArray[i],restrictionArray[i-1])
   
  resultSum = sum(resultArray)
  
  print(resultSum)
  
main()

Measured memory_bytes: 38420
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <tuple>
#include <algorithm>
 
#define rep(i,n) for(int i = 0; i < n; i++)
 
typedef long long ll;
 
using namespace std;
 
const ll INF = ll(1e18)+1;
const double PI=3.14159265358979323846;
 
int main(){
  int n;
  cin >> n;
  cout << (n-1)/2+1 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
string N;
  cin>>N;
  bool nazo=false;
  for(int i=0;i<N.size();i++){
  if(N.at(i)=='9'){
  nazo=true;
    break;
 	 }
  }
  if(nazo){
  cout<<"Yes"<<endl;
  }
  else{
  cout<<"No"<<endl;
  }
}

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

if X <= 599:
    print(8)
elif X <= 799:
    print(7)
elif X <= 999:
    print(6)
elif X <= 1199:
    print(5)
elif X <= 1399:
    print(4)
elif X <= 1599:
    print(3)
elif X <= 1799:
    print(2)
elif X <= 1999:
    print(1)

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

int n, mn, x, v[30], d[200005], ju[200005], u[200005];
string a, ans;
int main()
{
	int i, j, t;
	cin >> a;
	n = a.size();
	a = '.' + a;
	for (i = 0; i < 26; i++) v[i] = n + 1;
	for (i = n; i >= 0; i--) {
		mn = 2e9;
		for (j = 0; j < 26; j++) {
//			if (a[i] - 'a' == j) t = d[v[j]] + 1;
			t = d[v[j]];
			if (t < mn) {
				mn = t;
				x = j;
			}
		}
		ju[i] = v[x];
		d[i] = mn + 1;
		if (i > 0) v[a[i] - 'a'] = i;
		u[i] = x;
	}
	i = 0;
	do {
		ans += (char)(u[i] + 'a');
		i = ju[i];
	} while (i <= n);
	cout << ans;
    return 0;
}

Measured memory_bytes: 3008
import java.util.*;


public class Main {
    public static void main(String[] args) {
        // 自分の得意な言語で
        // Let's チャレンジ！！
        Scanner sc = new Scanner(System.in);
        while(true){
           String line=sc.nextLine();
String line2=sc.nextLine();
            if((line.equals("0")&&line2.equals("0"))){
                break;
            }
            double []j=new double[2];
            j[0]=Double.parseDouble(line);
            j[1]=Double.parseDouble(line2);
            System.out.println(j[0]*j[0]+2*Math.sqrt((j[0]/2)*(j[0]/2)+j[1]*j[1])*j[0]);
        }
    }
}


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

int main(){
	string s;
	int a=0,b=0;
	int ans=0;
	cin>>s;
	rep(i,3){
		if(s[i]=='A')a++;
		if(s[i]=='B')b++;
	}
	if(a!=0&&b!=0)ans=1;
	if(a!=0&&b==0)ans=0;
	if(a==0&&b!=0)ans=0;

	if(ans==1)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;

	return 0;

}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
            int a = sc.nextInt();
            int b = sc.nextInt();
            int c = sc.nextInt();
            
            if((a==b+c)||(b==a+c)||(c==a+b)){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
    }
}


Measured memory_bytes: 35832
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		int N = scn.nextInt();
		int M = scn.nextInt();
		long mt = 1900, at = 100;
		double db = Math.pow(2, M);
		double pre = 1/db;
		double dpre = (db-1)/db;
		long d_time = at * (N-M) + mt * M;
		long time = d_time;
		double ans = 0;
		while(pre > 0.00000000001) {
			pre *= dpre;
			time += d_time;
		}
		while(pre < 1/db + 0.0000001) {
			ans += pre * time;
			time-=d_time;
			pre/=dpre;
		}
		if((long)ans % 100 == 1)ans--;
		if((long)ans % 100 == 99)ans++;
		System.out.println((long)ans);

	}

}


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

int main()
{
	long long int n,k,rem,ans;
	cin>>n>>k;
	rem=n%k;
	if(rem==0)
	{
		cout<<"0";
		return 0;
	}
	else
	{
		if(rem>k/2)
		rem=k-rem;
		cout<<rem;	
	}
}

Measured memory_bytes: 3572
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace practice1
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] input = ReadNumbers(4);
            int a, b, c, d;
            a = input[0];
            b = input[1];
            c = input[2];
            d = input[3];

            if (Math.Abs(a - c) <= d)
            {
                Println("Yes");
                return;
            }

            if (Math.Abs(a - b) <= d && Math.Abs(b - c) <= d)
            {
                Println("Yes");
                return;
            }

            Println("No");

        }

        public static void Println(string str)
        {
            Console.WriteLine(str);
        }

        public static void Print(string str)
        {
            Console.Write(str);
        }

        public static void PrintNumber(long number)
        {
            Console.WriteLine("" + number);
        }

        public static string MyScanf()
        {
            return Console.ReadLine();
        }

        public static string[] MyScanfSplit()
        {
            return MyScanf().Split();
        }

        public static void MyDoubleSort(double[] boo)
        {
            if (boo.Length < 2) return;

            long i, count;
            double a;

            while (true)
            {
                count = 0;

                for (i = 0; i < boo.Length - 1; i++)
                {
                    if (boo[i] > boo[i + 1])
                    {
                        a = boo[i];
                        boo[i] = boo[i + 1];
                        boo[i + 1] = a;
                        count++;
                    }
                }

                if (count == 0) break;
            }
        }

        public static void MyLongSort(int[] boo)
        {
            if (boo.Length < 2) return;

            long i, count;
            int a;

            while (true)
            {
                count = 0;

                for (i = 0; i < boo.Length - 1; i++)
                {
                    if (boo[i] > boo[i + 1])
                    {
                        a = boo[i];
                        boo[i] = boo[i + 1];
                        boo[i + 1] = a;
                        count++;
                    }
                }

                if (count == 0) break;
            }
        }

        public static int[] ReadNumbers(long number)
        {
            int[] a = new int[number];
            string[] buff = MyScanfSplit();
            for(long i = 0; i < number; i++)
            {
                a[i] = int.Parse(buff[i]);
            }

            return a;
        }
    }
}


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

#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define ALL(a) (a).begin(),(a).end()
#define Yes(hoge) cout<<((hoge)?"Yes":"No")<<endl;
#define YES(hoge) cout<<((hoge)?"YES":"NO")<<endl;
using namespace std;
struct Grid{int x,y,t;};
struct Edge{int to,cost;};
struct Graph{vector<vector<Edge>>E;int V;
  const ll Inf = llINF;const int MAX_V=1010;vector<ll>d;
  Graph(int n):E(n){d.resize(MAX_V);E.resize(n);V=n;}
  void init(){for(int i=0;i<MAX_V;i++)d[i]=Inf;}
  void add_edge(int from,int to,int cost){E[from-1].pb({to-1,cost});}
};
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  vector<ll>A(n);
  ll sum=0;
  for(int i=0;i<n;i++){
    cin>>A[i];
    sum+=A[i];
  }

  if(sum%((ll)n*(n+1)/2)==0){
    ll cnt=0;
    bool flag=true;
    ll num=sum/((ll)n*(n+1)/2);
    for(int i=0;i<n;i++){
      ll d=A[(i+1)%n]-A[i]-num;
      if(d>0)flag=false;
      if((-d)%n)flag=false;
      else{
	cnt+=(-d)/n;
      }
    }
    if(cnt!=num)flag=false;
    YES(flag);
  }else{
    cout<<"NO"<<endl;
  }
  return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

class Main{

	static	int[] data;
	static boolean[][] used;
	static boolean[][] kariused;
	static int ans = 1000000000;
	static int sx;
	static int sy;
	static int tx;
	static int ty;






	public static void main(String[] args) {






		Scanner sc = new Scanner(System.in);			//文字の入力
		sx = sc.nextInt();
		sy = sc.nextInt();
		tx = sc.nextInt();
		ty = sc.nextInt();
		
		int dx = tx -sx;
		int dy = ty -sy;
		
		StringBuilder sb = new StringBuilder();
		
		for(int i = 0;i < dx;i++){
			sb.append("R");	
		}
		for(int i = 0;i < dy;i++){
			sb.append("U");
		}
		for(int i = 0;i < dx;i++){
			sb.append("L");	
		}
		for(int i = 0;i < dy;i++){
			sb.append("D");
		}
		sb.append("D");	
		
		for(int i = 0;i < dx+1;i++){
			sb.append("R");	
		}
		for(int i = 0;i < dy+1;i++){
			sb.append("U");
		}
		sb.append("L");
		sb.append("U");

		
		for(int i = 0;i < dx+1;i++){
			sb.append("L");	
		}
		for(int i = 0;i < dy+1;i++){
			sb.append("D");
		}
		sb.append("R");
		
		String ans = new String(sb);
		System.out.println(ans);

		

		
		
		used = new boolean[2001][2001];
		kariused = new boolean[2001][2001];
		//onedfs(sx,sy,0);



	}
}

class Pair implements Comparable{
	int from;
	int end;
	@Override
	public int compareTo(Object other) {
		Pair otherpair = (Pair)other;

		return end - otherpair.end;
	}
}




Measured memory_bytes: 30804