akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
typedef long long int lli;
#define vi vector<int>
#define vs vector<string>
#define pb push_back
#define endl "\n"
#define sortin sort(arr.begin(),arr.end())
#define inputArray for(int i{};i<n;i++){cin>>arr[i];}
#define inputArray1 for(int i{};i<m;i++){cin>>arr1[i];}
#define intloop for(int i{};i<n;i++)
#define intloopminus for(int i{};i<n-1;i++)
#define strloop for(int i{};i<str.length();i++)
#define N int n;cin>>n
#define strlen str.length()
#define InputStr string str;cin>>str
#define twoinputs int n,k;cin>>n>>k
#define T int t;cin>>t;while(t--)
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    InputStr;
    string str1="";
    for(int i{};i<str.length();i++)
    {
        if(str[i]=='B'&& str1.empty())
        {
            continue;
        }
        else if(str[i]=='1'|| str[i]=='0')
        {
            str1.pb(str[i]);
        }
        else if(str[i]=='B')
        {
            str1.pop_back();
        }
    }
    cout<<str1<<endl;
}

Measured memory_bytes: 3640
import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int K = sc.nextInt();
        int result = 0;
        while(N > 0){
        	N /= K;
        	result++;
        }
        System.out.println(result);
    }
}

Measured memory_bytes: 21716
package main
 
import (
  "fmt"
  "math"
)
 
const inf = math.MaxInt32
 
type edge struct {
  from int
  to   int
  cost int
}
 
func main() {
  var n,m int
  fmt.Scan(&n,&m)
  
  edges := make([]edge ,m)
  for i := range edges {
    fmt.Scan(&edges[i].from)
    fmt.Scan(&edges[i].to)
    fmt.Scan(&edges[i].cost)
  }
  
  //ノードi,j間の最短経路を定義
  dist := make([][]int, n)
  for i := 0; i < n; i++ {
    dist[i] = make([]int, n)
    for j := 0; j < n; j++ {
      if i == j {
        dist[i][j] = 0
      } else {
        dist[i][j] = inf
      }
    }
  }
  
  //既知の経路
  for i := 0; i < m; i++ {
    dist[edges[i].from-1][edges[i].to-1] = edges[i].cost
    dist[edges[i].to-1][edges[i].from-1] = edges[i].cost
  }
  
  //最短経路を更新
  for k := 0; k < n; k++ {
    for i := 0; i < n; i++ {
      for j := 0; j < n; j++ {

        //経由した方が低コストの場合、最短経路を更新
        if dist[i][k]+dist[k][j] < dist[i][j] {
          dist[i][j] = dist[i][k] + dist[k][j]
          //逆向きは更新不要？
          //dist[j][i] = dist[i][k] + dist[k][j]
        }
      }
    }
  }
  
  //最短経路に含まれていない辺をカウント
  ans := 0
  for i := 0; i < m; i++ {
    if dist[edges[i].from-1][edges[i].to-1] < edges[i].cost {
      ans++
    }
  }
  fmt.Println(ans)
}

Measured memory_bytes: 768
#include<stdio.h>
#include<string.h>

const int N =259;

int main(void)
{
   char a[N],b[N];
   int k =0 ,go=0;
   
   while(fgets(a,259,stdin))
   {
   	int c = strlen(a)-1;
   	
   	for(int i=c ,j =0 ;j<c ;i++,j++)
   	{
   		a[i]=a[j];
	}
	
   	fgets(b ,259 ,stdin);
   	for(int i =0 ;i<strlen(a) ; i++)
   	{
   		k =0;
   	   for(int j =0 ;j<strlen(b)-1 ; j ++)
   	   {
   		if(a[i+j]==b[j])
   		{
   			k++;
		}
		else
		{
			break;
		}   
      	}
     
		if(k==strlen(b)-1)
		{
			go =1;
			break;
	    }
    }
	if(go==1)
	{
		printf("Yes\n");
	}
    else
    {
    	printf("No\n");
	}
   	
   }
   
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);

using namespace std;

int find(vector<vector<int > > &m, vector<vector<int > > &d, int x, int y, int n) {
    if (x >= 2 || y >= n) return 0;
    if (d[x][y]) return d[x][y];
    int max = std::max(find(m, d, x+1, y, n), find(m, d, x, y+1, n)) + m[x][y];
    d[x][y] = max;
    return max;
}

int main() { _
    int n;
    cin >> n;
    vector<vector<int > >  m(2, vector<int>(n, 0));
    for (int i = 0; i < 2; i++) {
        for (int j = 0; j < n; j++) {
            int x;
            cin >> x;
            m[i][j] = x;
        }
    }
    vector<vector<int > >  d(2, vector<int>(n, 0));
    cout << find(m, d, 0, 0, n) << endl;
    return 0;
}


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

typedef long long ll;

int main() {
    int N, f = 0, X;
    cin >> N;
    X = N;
    while (X > 0) {
        f += X % 10;
        X /= 10;
    }
    if (N % f) cout << "No\n";
    else cout << "Yes\n";
}

Measured memory_bytes: 3560
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;
int ans=0;
int main(void){
	int a,b;
	cin>>a>>b;
	if(a<=8&&b<=8)cout<<"Yay!\n";
	else cout<<":(\n";
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
 
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
 
#include <complex>
 
#include <functional>
#include <cassert>
 
typedef long long ll;
using namespace std;
 
#define debug(x) cerr << #x << " = " << (x) << endl;
 
 
#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100010
 
 
int main(){
  char s[SIZE];
  int counter[500] = {};
  
  scanf("%s",s);
 
  int n = strlen(s);
  
  for(int i=0;i<n;i++){
    counter[s[i]-'a']++;
  }
 
  bool flag = true;
 
  for(int i=0;i<3;i++)
    flag &= counter[i] - n/3 == 0 || counter[i] - n/3 == 1; 
 
  if(flag)
    puts("YES");
  else
    puts("NO");
  
  return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef vector<int>vi;
int main()
{
    int n;
    cin>>n;
    vi v(n);
    int s=0;
    for(int i=0;i<n;i++){
        cin>>v[i];
        s+=v[i];
    }
    int m=round(double(s)/double(n));
    s=0;
    for(int i=0;i<n;i++){
        int d=v[i]-m;
        s+=d*d;
    }
    cout<<s<<'\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long
const int INF = 1LL << 60;

signed main(){

  string s, t; cin >> s >> t;
  if(s == t.substr(0, (int)s.size())){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}

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

int main(){
  int seq[32]={1, 1, 1,2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  int K;
  cin >> K;
  cout << seq[K-1] << endl;

}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void) {
	long long int X, Y;
	long long int tail;
	int count(0);

	cin >> X >> Y;
	tail = Y;
	while (tail >= X) {
		count++;
		tail /= 2;
	}
	cout << count;


	return 0;
}

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

/*int par[100000];

void init(int n){
    for(int i=0; i<n; i++) par[i] = i;
}

int find(int x){
    if(par[x] == x) return x;
    else{
        par[x] = find(par[x]);
        return par[x];
    }
}

int min(int a, int b){
    if(a > b) return b;
    else return a;
}

void unite(int x, int y){
    x = find(x);
    y = find(y);
    if(x == y) return;

    par[x] = y;
}*/
long long c[1000][1000];//その文字へのたどり方の総数
int main(){
	string t,b;
	cin>>t>>b;
	for(int i=0;i<t.size();i++){
	for(int j=0;j<b.size();j++){
		c[i][j]=0;
	}
	}
	if(t[0]==b[0]){
		c[0][0]=1;
	}
	for(int i=1;i<t.size();i++){
		for(int j=0;j<b.size();j++){
			if(t[i]==b[j]){
				if(j==0){
					c[i][j]=c[i-1][j]+1;
				}
				else{
				c[i][j]=(c[i-1][j]+c[i-1][j-1])%1000000007;
				}
			}
			else{
				c[i][j]=c[i-1][j];
			}
			}
	}
	int B=b.size()-1;
	int T=t.size()-1;
	cout<<c[T][B]<<endl;
	/*int N;
	cin>>N;
	int p[1000][3];
	for(int i=0;i<N;i++){
		cin>>p[i][0]>>p[i][1]>>p[i][2];
		sort(p[i],p[i]+3);
	}
	int q[1000];
	for(int i=0;i<N;i++){
		q[i]=0;
	}
	int answer=0;
	for(int i=0;i<N;i++){
		for(int j=i+1;j<N;j++){
			if(q[i]==0){
				if(p[i][0]==p[j][0]&&p[i][1]==p[j][1]&&p[i][2]==p[j][2]){
					answer=answer+1;
					q[i]=1;
				}
			}
		}
	}
	cout<<answer<<endl;*/


	/*int W,H,C;
	cin>>W>>H>>C;
	int gcd=0;
	for(int i=1;i<min(W,H)+1;i++){
		if(W%i==0 && H%i==0){
		gcd=max(gcd,i);
	}
	}
	cout<<(W/gcd)*(H/gcd)*C<<endl;*/
	/*int E,Y;
	cin>>E>>Y;
	if(E==0){
		int y=Y-1867;
		if(y<=44){
			cout<<'M'<<y<<endl;
		}
		if(y-44>0 && y-44<=14){
			cout<<'T'<<y-44<<endl;
		}
		if(y-58>0 && y-58<=63){
			cout<<'S'<<y-58<<endl;
		}
		if(y-121>0){
			cout<<'H'<<y-121<<endl;
		}
	}
		if(E==1){
			cout<<Y+1867<<endl;
		}
		if(E==2){
			cout<<Y+1911<<endl;
		}
		if(E==3){
			cout<<Y+1925<<endl;
		}
		if(E==4){
			cout<<Y+1988<<endl;
		}*/
	/*int H,R;
	cin>>H>>R;
	if(H>-R){
		cout<<1<<endl;
	}
	if(H==-R){
		cout<<0<<endl;
	}
	if(H<-R){
		cout<<-1<<endl;
	}*/

	/*
int W;
cin>>W;
cout<<W*32<<endl;*/

    return 0;
}


Measured memory_bytes: 10992
//00
#include<iostream>
#include<queue>
#include<utility>

using namespace std;

int main(){
  for(int W,H;cin>>W>>H,W|H;){
    bool g[20][20];
    queue<pair<int,int> > que;
    for(int y=0;y<H;y++){
      for(int x=0;x<W;x++){
	char c;
	cin>>c;
	g[y][x]=c=='.';
	if(c=='@'){
	  que.push(make_pair(y,x));
	}
      }
    }
    int ans=0;
    while(!que.empty()){
      ans++;
      int y=que.front().first;
      int x=que.front().second;
      que.pop();
      int dy[]={0,1,0,-1};
      int dx[]={1,0,-1,0};
      for(int i=0;i<4;i++){
	int ny=y+dy[i];
	int nx=x+dx[i];
	if(0<=ny&&ny<H&&0<=nx&&nx<W&&g[ny][nx]){
	  que.push(make_pair(ny,nx));
	  g[ny][nx]=false;
	}
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 0
def combinationListRecursive(data, r):
  result = []
  _combinationListRecursive(data, r, 0, [], result)
  return result

def _combinationListRecursive(data, r, start, progress, result):
  if r == 0:
    result.append(progress)
    return

  for i in range(start, len(data)):
    _combinationListRecursive(data, r - 1, i + 1, progress + [data[i]], result)

n, m, x = map(int, input().split())
t = []
for i in range(n):
    l = list(map(int, input().split()))
    t.append(l)

tmp = []
for i in range(1, n+1):
    c = combinationListRecursive(t, i)
    for j in c:
        cnt = [0] * (m + 1)
        for k in j:
            for l in range(m+1):
                cnt[l] += k[l]
        tmp.append(cnt)

ans = float("INF")
for i in tmp:
    ignore = False
    for j in i[1:]:
        if x > j:
            ignore = True
    if ignore:
        continue

    ans = min(ans, i[0])

if ans == float("INF"):
    ans = -1

print(ans)


Measured memory_bytes: 11376
from collections import deque
import numpy as np
import bisect

n, m, k = map(int, input().split())
A = [0] + list(map(int,input().split()))
B = [0] + list(map(int,input().split()))

a = np.cumsum(A)
b = np.cumsum(B)

ans = 0
for i in range(n+1):
    time = k - a[i]
    if time < 0:
        break
    ans = max(ans, bisect.bisect_right(b, time) - 1 + i)

print(ans)

Measured memory_bytes: 59924
def II(): return int(input())
N=II()
tbl=[0]*101
for i in range(1,N+1):
  i=str(i)
  tbl[int(str(i[0]+i[-1]))]+=1
ans=0
for i in range(1,N+1):
  i=str(i)
  ans+=tbl[int(str(i[-1]+i[0]))]
print(ans)
      

Measured memory_bytes: 9172
#include <bits/stdc++.h>
using namespace std;
//#include <boost/multiprecision/cpp_int.hpp>
//using multiInt = boost::multiprecision::cpp_int;

using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
template<typename Q_temp>
using smaller_queue = priority_queue <Q_temp, vector<Q_temp>, greater<Q_temp> >;

const int INF = (int) 1e9;
const ll LINF = (ll) 4e18;
const ll MOD = (ll) (1e9 + 7);
const double PI = acos(-1.0);
const int limit = 100010;

#define REP(i,m,n) for(ll i = m; i < (ll)(n); ++i)
#define rep(i,n) REP(i, 0, n)
#define MP make_pair
#define MT make_tuple
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible") << endl
#define all(v) v.begin(), v.end()
#define NP(v) next_permutation(all(v))
#define dbg(x_) cerr << #x_ << ":" << x_ << endl;
#define dbg2(x_) for(auto a_ : x_) cerr << a_ << " "; cerr << endl;
#define dbg3(x_ , sx_) rep(i, sx_) cerr << x_[i] << " "; cerr << endl;
vector<int> Dx = {0, 0, -1, 1, -1, 1, -1, 1, 0};
vector<int> Dy = {1, -1, 0, 0, -1, -1, 1, 1, 0};

inline ll CEIL(ll a, ll b) {
    return (a + b - 1) / b;
}

//------------------------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a[5];
    rep(i, 5) cin >> a[i];
    int k;
    cin >> k;
    bool exist = false;
    rep(i, 5) for (int j = i + 1; j < 5; ++j) {
        if (a[j] - a[i] > k) exist = true;
    }
    cout << (exist ? ":(" : "Yay!") << endl;
    return 0;
}



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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
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; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

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

    ll N;
    cin >> N;
    vector<ll> X(N);
    REP(i, N) cin >> X[i];

    ll S = 0;
    REP(i, N) S += X[i];
    S /= N;
    ll res = (1ll<<60);
    for(int i=-10;i<=10;i++){
    	ll P = S + i;
    	ll tmp = 0;
    	REP(i, N){
    		tmp += (X[i]-P)*(X[i]-P);
    	}
    	chmin(res, tmp);
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int mod = 1e9 + 7;
const int MAX = 510000;
const int V = 100005;
ll dy[8] = {1,0,-1,0,1,-1,1,-1};
ll dx[8] = {0,1,0,-1,1,-1,-1,1};
const double pi = acos(-1);
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}

struct lr{
    ll l;
    ll r;
    bool operator < (const lr &t) const {
        return l==t.l ? r < t.r : l > t.l;
    }
};

int main(){
    ll n; cin >> n;
    vector<struct lr> v(n);
    ll ans = 0;
    rep(i,n){
        cin >> v[i].l >> v[i].r;
        ans = max(v[i].r - v[i].l + 1, ans);
    }
    sort(all(v));
    multiset<ll> fil,fir,sel,ser;
    rep(i,n){
        sel.insert(v[i].l); ser.insert(v[i].r);
    }
    rep(i,n-1){
        auto itrl = sel.find(v[i].l);
        auto itrr = ser.find(v[i].r);
        fil.insert(v[i].l); fir.insert(v[i].r);
        sel.erase(itrl); ser.erase(itrr);
        auto itr = --fil.end();
        auto itr2 = --sel.end();
        ans = max(ans, *fir.begin()-*itr+1+*ser.begin()-*itr2+1);
        //cout << *fir.begin() << " " << *ser.begin() << endl;
    }
    for(ll i=n-2; i>=1; i--){
        auto itrl = fil.find(v[i].l);
        auto itrr = fir.find(v[i].r);
        fil.insert(v[i+1].l); fir.insert(v[i+1].r);
        fil.erase(itrl); fir.erase(itrr);
        auto itr = --fil.end();
        ans = max(ans, *fir.begin()-*itr+1 + v[i].r-v[i].l+1);
    }
    cout << ans << endl;
}

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

int main() {
	int N;
	cin >> N;
	vector<int> X(N);
	rep(i,N) cin >> X[i];
	int ans = 1e9+7;
  for(int p=1;p<=100;p++){
		int sm = 0;
		rep(i,N){
			sm += (X[i]-p)*(X[i]-p);
		}
		ans = min(ans,sm);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool b[105][105];
int main()
{
	int i,j,k=1,h,w;
	char x;
	cin>>h>>w;
	for(i=1;i<=h;i++)
	  for(j=1;j<=w;j++)
	  {
	  	cin>>x;
	  	if(x=='#') b[i][j]=1;
	  }
	for(i=1;i<=h;i++)
	  for(j=1;j<=w;j++)
	    if(b[i][j])
		if(b[i-1][j]||b[i+1][j]||b[i][j-1]||b[i][j+1]);
	    else 
		{
			k=0;
			break;
	    }
	if(k) cout<<"Yes";
	else cout<<"No";
	return 0;
}

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

int main() {
  // aの定義
  double a = 0;
  double b = 0;
  double c = 0;
  // mの入力
  cin >> a >> b;
  // a+bの計算
  c = 2 * b - a;
  cout << c << endl;
}


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

int dp[100][101];	//??¨?????????,?????????????¨???°(100??§????????????)

int n;
int a[100],e[100],r[100];	//??????????¨??????¶???

int solve(int dNow,int eNow){
	if(dNow<0) return 0;	//?????????????????????
	if(dp[dNow][eNow]!=-1) return dp[dNow][eNow];

	int ans=114514;
	bool able=false;
	for(int i=0;i<n;i++){
		if(eNow<r[i]) continue;
		if(a[i]==0 && (100<=eNow || e[i]==0)) continue;
		able=true;
		ans=min(ans,1+solve(dNow-a[i],min(eNow+e[i],100)));
	}

	if(!able){
		return -1;
	}

	dp[dNow][eNow]=ans;
	return ans;
}

int main(){
	int d;	//??¨????????????
	int i,j;
	while(cin>>d,d>0){
		cin>>n;
		for(i=0;i<n;i++){
			cin>>a[i]>>e[i]>>r[i];
		}

		for(i=0;i<100;i++){
			for(j=0;j<101;j++){
				dp[i][j]=-1;
			}
		}
		int ans=solve(d-1,0);
		if(ans==-1){
			cout<<"NA"<<endl;
		}else{
			cout<<ans<<endl;
		}
	}
	return 0;
}

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

ll k, ans, a, b;

int main(){
    cin >> k >> a >> b;
    if (a + 1 >= b || a > k - 1) ans = k + 1;
    else k -= a + 1, ans = b + (b - a) * (k / 2) + k % 2;
    cout << ans << endl;
}

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

if 400 <= x <= 599:
  print(8)
elif 600 <= x <= 799:
  print(7)
elif 800 <= x <= 999:
  print(6)
elif 1000 <= x <= 1199:
  print(5)
elif 1200 <= x <= 1399:
  print(4)
elif 1400 <= x <= 1599:
  print(3)
elif 1600 <= x <= 1799:
  print(2)
else:
  print(1)

Measured memory_bytes: 61616
using System;
using System.Linq;
using System.Collections.Generic;

namespace Algorithm
{
    class Program
    {
        const int Mod = 1000000007;
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            var dict = new Dictionary<int, int>();

            for (var i = 2; i <= n; i++)
            {
                var tmp = i;
                var t = 0;
                var count = 2;
                
                while (count <= i)
                {
                    if (tmp % count == 0)
                    {
                        t++;
                        tmp /= count;
                    }
                    else
                    {
                        if (t != 0)
                        {
                            if (dict.ContainsKey(count))
                                dict[count] += t;
                            else
                                dict[count] = t;
                        }
                        count++;
                        t = 0;
                    }
                }
            }

            var total = 1L;
            foreach (var d in dict)
            {
                // 約数求める時は次数＋１しないとだから＋１する
                total *= d.Value + 1;
                total %= Mod;
            }

            Console.WriteLine(total);
        }
    }
}


Measured memory_bytes: 13140
from math import ceil, log
n, k = map(int, input().split())
if n > k:
    ans = (n-k)/n
    o = k
else:
    ans = 0
    o = n

for i in range(1, o+1):
    ans += 1 / (n * 2 ** ceil(log(k/i, 2)))
print(ans)

Measured memory_bytes: 3060
#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 N;
  cin >> N;
  int a = N % 1000;
  if(N % 1000 == 0)cout << 0 << endl;
  else cout << 1000 - a << endl;
  
}

Measured memory_bytes: 3628
/*#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
#include <array>
#include <vector>
#include <deque>
#include <set>
#include <map>
#include <string>
#include <stack>
#include <queue>
#include <unordered_map>
#include <unordered_set>
*/

#include <bits/stdc++.h>
using namespace std;

#define int long long
#define pb push_back
#define mp make_pair
#define F first
#define S second
#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()
#define RALL(a) (a).rbegin(),(a).rend()
#define SORT(c) sort((c).begin(),(c).end())

typedef long long ll;
const ll inf = 2e9 + 7;
const int MAX_N = 5e5 + 5;
int dx[] = { -1,0,1,0 }, dy[] = { 0,1,0,-1 };
vector<ll> prime;

ll inv[MAX_N], fac[MAX_N];

template <class T = int> T in() { T x; cin >> x; return (x); }
inline ll GCD(ll a, ll b) { ll c; while (b != 0) { c = a % b; a = b; b = c; }return a; }
inline ll LCM(ll a, ll b) { return a * b / GCD(a, b); }
inline ll POW(ll a, ll b) { ll c = 1; while (b > 0) { if (b & 1) { c = a * c%inf; }a = a * a%inf; b >>= 1; }return c; }
inline void _nCr() { fac[0] = 1; for (int i = 1; i < MAX_N; i++) { fac[i] = fac[i - 1] * i%inf; }for (int i = 0; i < MAX_N; i++) { inv[i] = POW(fac[i], inf - 2); } }
inline ll nCr(ll n, ll r) { return (fac[n] * inv[r] % inf)*inv[n - r] % inf; }
inline void PRI(ll n) { bool a[n + 1]; for (int i = 0; i < n + 1; i++) { a[i] = 1; }for (int i = 2; i < n + 1; i++) { if (a[i]) { prime.pb(i); ll b = i; while (b <= n) { a[b] = 0; b += i; } } } }

typedef pair<int, pair<int, int>> edge;

class UnionFind {
private:
	vector<int> par;
public:
	UnionFind(int N) { par = vector<int>(N, -1); }
	int find(int x);
	ll size(int x);
	void unite(int x, int y);
	bool same(int x, int y);
};



class Kruskal {
private:
	UnionFind *uf;
	vector<edge> e;
public:
	vector<edge> mst;
	Kruskal(int N) { uf = new UnionFind(N); }
	void add(int x, int y, ll z);
	void run();
};



//----UnionFind-------------------------------
int UnionFind::find(int x) {
	if (par[x] < 0) return x;
	else return par[x] = find(par[x]);
}

ll UnionFind::size(int x) {
	return -par[find(x)];
}

void UnionFind::unite(int x, int y) {
	x = find(x);
	y = find(y);

	//大きい方に小さい方をくっ付ける
	if (size(x) < size(y)) swap(x, y);
	par[x] += par[y];
	par[y] = x;
}

bool UnionFind::same(int x, int y) {
	x = find(x);
	y = find(y);
	return x == y;
}



//----Kruskal-------------------------------
void Kruskal::add(int x, int y, ll z) {
	//x < y
	if (x > y) swap(x, y);
	e.push_back({ z,{x,y} });
}

void Kruskal::run() {
	sort(e.begin(), e.end());
	e.erase(unique(e.begin(), e.end()), e.end());
	for (auto x : e) {
		if (uf->same(x.second.first, x.second.second)) {
			continue;
		}
		else {
			mst.push_back(x);
			uf->unite(x.second.first, x.second.second);
		}
	}
}

signed main() {
	int n = in(),m = in(),c = in();
	int b[m];
	REP (i,m) cin >> b[i];
	int ans = 0;
	REP (i,n) {
		int sum = 0;
		REP (i,m) {
			sum += in() * b[i];
		}
		sum += c;
		if (sum > 0) ans++;
	}
	cout << ans << endl;
}

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

int num[110];
int n;
unsigned long long int dp[110][110];
unsigned long long int solve(int i, int tar, unsigned long long int sum);
int main(){
  memset(dp, 0, sizeof(dp));
  cin >> n;
  for(int i = 0; i < n; i++){
    cin >> num[i];
  }
  cout << solve(1, num[n - 1], num[0]) << endl;
  
}

unsigned long long int solve(int i, int tar, unsigned long long int sum){
  if(i >= n) return 0;
  if(sum < 0 || sum > 20) return 0;
  if(dp[i][sum] > 0) return dp[i][sum];
  if(sum == tar && i == n - 1) return 1;
  else if(sum != tar && i == n - 1) return 0;
  return dp[i][sum] = solve(i + 1, tar, sum + num[i]) + solve(i + 1, tar, sum - num[i]);
}

Measured memory_bytes: 1260
import math
A,B,H,M = map(int,input().split())
kA = (60*H+M)/2
kB = M*6

kAB = min(abs(kA-kB), 360-abs(kA-kB))

if kAB == 0:
    print(abs(A-B))
    exit()
elif kAB == 180:
    print(A+B)
    exit()

C = (A**2) + (B**2) - (2*A*B*math.cos(math.radians(kAB)))
print(C**(1/2))

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

using namespace std;

const int INF = 1 << 30;

int main()
{
  string S;
  cin >> S;
  int a = INF, b = 0;
  for(int i = 0; i < S.size(); i++) {
    if(S[i] == 'A') a = min(a, i);
    if(S[i] == 'Z') b = max(b, i);
  }
  cout << b - a + 1 << endl;
}

Measured memory_bytes: 640
#import sys
MOD = 10 ** 9 + 7
INFI = 10**10
#input = sys.stdin.readline
import math
 
import itertools
 
#import bisect
 
import copy
from functools import lru_cache
 
def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n
 
    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]
 
    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot
 
    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])
 
    return result
 
def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta
 
def my_index(l, x, default=False):
    if x in l:
        return l.index(x)
    else:
        return default
 
#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]
 
 
 
def main():
    h,n=map(int,input().split()) #n yen, m types
    ab=[list(map(int,input().split())) for i in range(n)]
    maxa = max(a for a, b in ab)
    dp=[INFI for i in range(h+maxa)]
    dp[0]=0
 
 
    def f(h):
 
        for a,b in ab:
            for j in range(h+maxa):
                dp[j]=min(dp[j],dp[j-a]+b)
        return min(dp[h:])
 
    print(f(h))
 
 
if __name__ == "__main__":
    main()

Measured memory_bytes: 41328
using System;

namespace AOJ.intro
{
    namespace ITP_1_4_C
    {
        static public class Calclator
        {
            static public void Main()
            {
                while(true){
                    string[] inputData = Console.ReadLine().Split();
                    int a, b;
                    string op;
                    a  = int.Parse(inputData[0]);
                    b  = int.Parse(inputData[2]);
                    op = inputData[1];
                    int calcResult = 0;
                    string errMsg;

                    if (op == "+")
                    {
                        calcResult = a + b;
                    }
                    else if (op == "-")
                    {
                        calcResult = a - b;
                    }
                    else if (op == "*")
                    {
                        calcResult = a * b;
                    }
                    else if (op == "/")
                    {
                        if (b == 0)
                        {
                            errMsg = "0割り算です.";
                            Console.WriteLine(errMsg);
                            return;
                        }
                        calcResult = a / b;
                    }
                    else if (op == "?")
                    {
                        break;
                    }
                    Console.WriteLine(calcResult);
                }
            }
        }
    }
}


Measured memory_bytes: 9240
#include<bits/stdc++.h>
#define int long long

using namespace std;

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

    int n, arr[100000];
    cin >> n;
    for (int i = 0; i < n; i++)
        cin >> arr[i];
    sort(arr, arr + n, greater<int>());

    int s = -1;
    for (int i = 0; i + 1 < n; i++)
        if (arr[i] == arr[i + 1])
            if (s == -1)
                s = arr[i], i++;
            else
                return cout << s * arr[i] << '\n', 0;
    cout << "0\n";

    return 0;
}


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

int main() {
    int n;
    cin >> n;
    int x[n];
    for (int i = 0; i < n; i++) {
        cin >> x[i];
    }
    int m;
    cin >> m;
    while (m--) {
        int a;
        cin >> a;
        a--;
        if (x[a] != 2019 && (a == n-1 || x[a]+1 < x[a+1]))
            x[a]++;
    }
    for (int xx : x) cout << xx << endl;
    return 0;
}


Measured memory_bytes: 3112
#include<stdio.h>

long long int count=0;
void merge(long long int a[], int left, int mid, int right) 
{ 
    int p,o,k; 
    int n1 = mid - left+1; 
    int n2 =  right-mid; 
    int L[n1], R[n2]; 
  
    for (p = 0; p < n1; p++) //左半分の数列を登録
        L[p] = a[left + p]; 
       
    for (o = 0; o < n2; o++) //右半分の数列を登録
        R[o] = a[mid + 1+ o];
        
    p = 0; 
    o = 0;  
    k = left; 
    while (p < n1 && o < n2) //一つの数列に合併していく
    { 
        if (L[p] <= R[o]) 
        { 
            a[k] = L[p];  count++;
            p++; 
        }
        else
        { 
            a[k] = R[o]; 
            o++;
			count++; 
        } 
        k++; 
     } 
  
    while (p < n1) 
    { 
        a[k] = L[p];  count++;
        p++; 
        k++; 
    } 
  
    while (o < n2) 
    { 
        a[k] = R[o];  count++;
        o++; 
        k++; 
    } 
    
} 
  
void mergesort(long long int a[], int l, int r) 
{ 
    if (l < r) 
    {    
        int m = l+(r-l)/2; 
        mergesort(a, l, m); //左半分に分解したものをさらに二等分に分解させる関数mergesortに入れる
        mergesort(a, m+1, r); //右半分に分解したものをさらに二等分に分解させる関数mergesortに入れる
		merge(a, l, m, r); //ソートした左半分と右半分を一つの配列にする
    } 
} 

long long int num[100000005];
int main()
{
	int a;
	
	scanf("%d",&a); 
	for(int i=0;i<a;i++)
	{
		scanf("%lld",&num[i]);
	}
	
	mergesort(num,0,a-1);
	
	for(int i=0;i<a;i++)
	{
		if (i==0)
		{
			printf("%lld",num[i]);
		}else
		{
			printf("% lld",num[i]);
		}
			
	}	
	printf("\n");
	printf("%lld\n",count);
	
	return 0;
}



Measured memory_bytes: 7596
import sys

a, b = map(int, sys.stdin.readline().split())
if a < b: a, b = b, a

def main():
    r, c = 16 - b * 2, a - b
    ans = 'Yay!' if c <= r // 2 else ':('
    print(ans)

if __name__ ==  '__main__':
    main()

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

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		int x = sc.nextInt();

		int a[] = new int[n];
		for(int i = 0; i < n; i++){
			a[i] = sc.nextInt();
		}

		Arrays.sort(a);

		int count = 0;

		for(int i = 0; i < n; i++){
			if(x >= a[i] && i != n - 1){
				count++;
				x -= a[i];
			}
			else if(i == n - 1 && a[i] == x){
				count++;
			}
			else {
				break;
			}
		}

		System.out.println(count);
	}
}


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

int main()
{
    int N, K;
    cin >> N >> K;
    vector<bool> a(N, false);
    for (int i = 0; i < K; i++)
    {
        int d;
        cin >> d;
        for (int j = 0; j < d; j++)
        {
            int t;
            cin >> t;
            a[t - 1] = true;
        }
    }

    int count = 0;
    for (int i = 0; i < N; i++)
    {
        if (a[i] == false)
        {
            count++;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
vector<int> v[25];
int n,m,a,b,cnt=0,data[20];
void dfs(int st,int lv){
	//printf("%d %d\n",st,lv);
	if(lv==n-1){
		++cnt;
		return;
	}
	for(int i=0;i<v[st].size();i++){
		if(data[v[st][i]]==0){
			data[v[st][i]]=1;
			dfs(v[st][i],lv+1);
			data[v[st][i]]=0;
		}
	}
}
int main(){
	memset(data,0,sizeof data);
	data[1]=1;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=m;i++){
		scanf("%d%d",&a,&b);
		v[a].push_back(b);
		v[b].push_back(a);
	}
	dfs(1,0);
	printf("%d",cnt);
}

Measured memory_bytes: 764
#include<stdio.h>
#define rep(i,a,b) for(int i = a;i <= b;i++)

int main(void){
  int s,w; scanf("%d%d",&s,&w);
  if(s<=w){
    printf("unsafe");
  }
  else{
    printf("safe");
  }
  return 0;
}


Measured memory_bytes: 1676
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        boolean black = false;
        if ('B' == s.charAt(0)) {
            black = true;
        }
        int cnt = 1;
        for (int i = 1; i < s.length(); i++) {
            char c = s.charAt(i);
            if (black && 'B' == c || !black && 'W' == c) {
                continue;
            }
            black = Boolean.logicalXor(black, true);
            cnt++;
        }
        System.out.println(cnt - 1);
    }

}


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

#define rep(i,n) for(int i=0,i##_cond=(n);i<i##_cond;++i)
using vi = vector<int>;
using vs  = vector<string>;

int main(){
  string s;
  while(cin >> s, s != "#"){
    vi a(4); rep(i,4){
      cin >> a[i];
      a[i]--;
    }
    int h = 1, w = 0;
    rep(i,s.size()) if(s[i] == '/') h++;
    rep(i,s.size()){
      if(s[i] == '/') break;
      else if(s[i] == 'b') w++;
      else w += s[i]-'0';
    }
    vs b(h);
    {
      int i = 0;
      rep(j,s.size()){
	if(s[j] == '/') i++;
	if(s[j] == 'b') b[i] += "b";
	else{
	  rep(k,s[j]-'0') b[i] += ".";
	}
      }
    }
    b[a[0]][a[1]] = '.';
    b[a[2]][a[3]] = 'b';
    string ans;
    int c = 0;
    rep(i,h){
      rep(j,w){
	if(b[i][j] == '.') c++;
	else{
	  if(c != 0){
	    ans += to_string(c);
	    c = 0;
	  }
	  ans += "b";
	}
      }
      if(c != 0){
	ans += to_string(c);
	c = 0;
      }
      if(i != h-1) ans += "/";
    }
    cout << ans << endl;
  }
}


Measured memory_bytes: 3208
from sys import stdin
input = stdin.readline
 
A,V = input().rstrip().split()
B,W = input().rstrip().split()
T = int(input().rstrip())
A,V,B,W = int(A),int(V),int(B),int(W)
s=0
L1=A-B
L2=B-A
S=V-W
if V<=W:
  print('NO')
  s=1
else:
    if B<A:
      if L1/S<=T:
        print('YES')
      else:print('NO')
    else:
      if L2/S<=T:
        print('YES')
      else:print('NO')

Measured memory_bytes: 61764
N, M = list(map(int, input().split()))
A = []
for i in range(N):
    A.append(list(map(int, input().split()))[1:])
ans = 0
for a in A[0]:
    flag = True
    for i in range(1, N):
        if not a in A[i]:
            flag = False
            break
    if flag==True:
        ans += 1
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <stack>
#include <queue>
#include <bitset>
#include <numeric>
#include <cassert>
#include <random>
#ifdef DEBUG
#include "./Lib/debug.hpp"
#include "./Lib/Timer.hpp"
#include "./Lib/sample.hpp"
#else
#define dump(...)
template<class T>inline auto d_val(T a, T b) { return a; }
#endif

/* (=＾o＾=) */
#define int ll

/* macro */
#define FOR(i, b, e) for(ll i = (ll)(b); i < (ll)(e); ++i)
#define RFOR(i, b, e) for(ll i = (ll)(e-1); i >= (ll)(b); --i)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define REPC(x,c) for(const auto& x:(c))
#define REPI2(it,b,e) for(auto it = (b); it != (e); ++it)
#define REPI(it,c) REPI2(it, (c).begin(), (c).end())
#define RREPI(it,c) REPI2(it, (c).rbegin(), (c).rend())
#define REPI_ERACE2(it, b, e) for(auto it = (b); it != (e);)
#define REPI_ERACE(it, c) REPI_ERACE2(it, (c).begin(), (c).end())
#define ALL(x) (x).begin(),(x).end()
#define cauto const auto&
/* macro func */
#define SORT(x) do{sort(ALL(x));}while(false)
#define RSORT(x) do{sort((x).rbegin(),(x).rend());}while(false)
#define UNIQUE(v) do{v.erase( unique(v.begin(), v.end()), v.end() );}while(false)
#define MAX(x,y) do{x = std::max(x,y);}while(false)
#define MIN(x,y) do{x = std::min(x,y);}while(false)
#define BR do{cout<<"\n";}while(false)

/* type define */
using ll = long long;
using PAIR = std::pair<ll, ll>;
using VS = std::vector<std::string>;
using VL = std::vector<long long>;
using VVL = std::vector<VL>;
using VVVL = std::vector<VVL>;
using VD = std::vector<double>;
template<class T>
using V = std::vector<T>;

/* using std */
using std::cout;
constexpr char endl = '\n';
using std::cin;
using std::sort;
using std::pair;
using std::string;
using std::stack;
using std::queue;
using std::vector;
using std::list;
using std::map;
using std::unordered_map;
using std::multimap;
using std::unordered_multimap;
using std::set;
using std::unordered_set;
using std::unordered_multiset;
using std::multiset;
using std::bitset;
using std::priority_queue;

/* constant value */
constexpr ll MOD = 1000000007;
//constexpr ll MOD = 998244353;

/* Initial processing  */
struct Preprocessing { Preprocessing() { std::cin.tie(0); std::ios::sync_with_stdio(0); }; }_Preprocessing;

/* Remove the source of the bug */
signed pow(signed, signed) { assert(false); return -1; }

/* define hash */
namespace std { template <>	class hash<std::pair<ll, ll>> { public:	size_t operator()(const std::pair<ll, ll>& x) const { return hash<ll>()(1000000000 * x.first + x.second); } }; }

/* input */
template<class T> std::istream& operator >> (std::istream& is, vector<T>& vec) { for (T& x : vec) is >> x; return is; }

//=============================================================================================

signed main() {

	ll n;
	cin >> n;
	string str;
	cin >> str;
	
	REPC(c, str) {
		ll p = c - 'A';
		p += n;
		p %= 26;
		char a = p + 'A';
		cout << a;
	}BR;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n, c = [int(x) for x in input().split()]
xv = [[0, 0]]
for _ in range(n):
    xv.append([int(x) for x in input().split()])
xv.sort()

from copy import deepcopy

xv_2 = [[0, 0]] + deepcopy(xv)[::-1]
for i in range(1, n + 1):
    xv_2[i][0] = c - xv_2[i][0]

xv_cumsum = [0]
xv_2_cumsum = [0]

for i in range(1, n + 1):
    xv_cumsum.append(xv_cumsum[-1] + xv[i][1])
    xv_2_cumsum.append(xv_2_cumsum[-1] + xv_2[i][1])

clock = [0]
anti_clock = [0]

for i in range(1, n + 1):
    clock.append(clock[-1] + xv[i][1] - (xv[i][0] - xv[i - 1][0]))

for i in range(1, n + 1):
    anti_clock.append(anti_clock[-1] + xv_2[i][1] - (xv_2[i][0] - xv_2[i - 1][0]))

for i in range(1, n + 1):
    clock[i] = max(clock[i], clock[i - 1])
    anti_clock[i] = max(anti_clock[i], anti_clock[i - 1])

ans = 0

for i in range(n):
    ans = max(ans, xv_2_cumsum[i] - 2*xv_2[i][0] + clock[n - i], xv_cumsum[i] -2*xv[i][0] + anti_clock[n - i])

print(ans)


Measured memory_bytes: 125660
n,m = map(int, input().split())
l_lst, r_lst = [], []
for i in range(m):
  l,r = map(int, input().split())
  l_lst.append(l)
  r_lst.append(r)
res = min(r_lst)-max(l_lst)+1
if res > 0:
  print(res)
else:
  print(0)

Measured memory_bytes: 11052
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N, D;cin >> N >> D;
  vector<vector<int>> X(N, vector<int>(D));
  for(int i=0;i<N;i++){
    for(int j=0;j<D;j++){
      cin >> X.at(i).at(j);
    }
  }
  
  int ans =0;
  for(int i=0;i<N;i++){
    for(int j=i+1;j<N;j++){
      long long L=0;
      for(int k=0;k<D;k++){
        L += (X.at(i).at(k) - X.at(j).at(k))*(X.at(i).at(k) - X.at(j).at(k));
      }
      for(int l=0;l<=400;l++){
        int m=l*l;
        if(L == m){
          ans++;
          break;
        }
      }
    }
  }
  cout << ans <<endl;
}

Measured memory_bytes: 256
#include <iostream>

#define ll long long
#define NIL 2100000000

using namespace std;

int main(){
    int h, i, currentNode = 1;
    ll tmp;
    ll heap[510];
    for(i = 0; i < 510; i++){
        heap[i] = NIL;
    }
    cin >> h;
    for(i = 0; i < h; i++){
        cin >> tmp;
        while(1){
            if(heap[currentNode] == NIL){
                heap[currentNode] = tmp;
                currentNode = 1;
                break;
            }else{
                currentNode++;
            }
        }
    }
    for(i = 1; i < h + 1; i++){
        if(heap[i] == NIL){
            i--;
            continue;
        }
        cout << "node " << i << ": key = " << heap[i] << ", ";
        if(i > 1){
            cout << "parent key = " << heap[i / 2] << ", ";
        }
        if(heap[i * 2] != NIL){
            cout << "left key = " << heap[i * 2] << ", ";
        }
        if(heap[i * 2 + 1] != NIL){
            cout << "right key = " << heap[i * 2 + 1] << ", ";
        }
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3088
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int 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: 256
#include <bits/stdc++.h>
using namespace std;

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

    int sum=0;
    if(N%10){
        for(char c :to_string(N)){
            sum += c - '0';
        }
    }else{
        sum = 10;
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
n,k=map(int,input().split())
while True:
    w = int(n/k)
    c = n
    n = abs(n-(w*k))
    if n==c:
        while True:
            c = n
            n = min(n,abs(n-k)) 
            if n == c:
                break
        break
print(n)

Measured memory_bytes: 2940
MAX = 2*10**6+100
fact = [0]*MAX
inv = [0]*MAX
finv = [0]*MAX
 
def C_init():
    fact[0] = 1
    fact[1] = 1
    finv[0] = 1
    finv[1] = 1
    inv[1] = 1
    
    for i in range(2, MAX):
        fact[i] = fact[i-1]*i%MOD
        inv[i] = MOD-inv[MOD%i]*(MOD//i)%MOD
        finv[i] = finv[i-1]*inv[i]%MOD

def C(n, r):
    if n<r:
        return 0
    if n<0 or r<0:
        return 0
    return fact[n]*(finv[r]*finv[n-r]%MOD)%MOD

n, k = map(int, input().split())
MOD = 10**9+7
C_init()

if k>=n-1:
    print(C(2*n-1, n))
else:
    ans = 0
    
    for i in range(k+1):
        ans += C(n, i)*C(n-1, i)
        ans %= MOD
    
    print(ans)

Measured memory_bytes: 87664
#![allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}
fn read_vec2<T: std::str::FromStr>(n: usize) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main() {
    let n = read::<i32>() % 1000;
    println!("{}", if n == 0 {0} else {1000 - n});
}

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

int main(){
	string s;cin>>s;
	int w;cin>>w;
	for(int i=0;i<s.size();++i){
		if(i%w==0){
			cout<<s[i];
		}
	}
	cout<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll n;
  cin >> n;
  ll ans = 0;
  ll flor = sqrt(n); // 商と余りが一致する可能性があるのはここから
  for(ll i=n/flor;i>=1;i--){
    ll d = (n-i)/i;
    if(d == 0) continue;
    if((n-i)%i == 0 && n/d == i){ // i余らせて割り切れる && 割り切れた数で割るとiになる
      ans += ((n-i)/i);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	static long MOD = 1000000007;

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int N = in.nextInt();
		char[] S = in.next().toCharArray();
		int[] alph = new int[26];
		for (int i = 0; i < S.length; i++) {
			alph[S[i] - 'a']++;
		}
		long ans = 1;
		for (int i = 0; i < alph.length; i++) {
			if (alph[i] > 0) {
				int num = alph[i] + 1;
				ans = ans * num % MOD;
			}
		}
		System.out.println(ans - 1);
		in.close();
	}
}

Measured memory_bytes: 25684
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N;
string S;

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

  cin >> N >> S;
  int cnt=0;
  rep(i, N-2) {
    if (S[i]=='A' && S[i+1]=='B' && S[i+2]=='C') cnt++;
  }
  cout << cnt << "\n";
  return 0;
}

Measured memory_bytes: 256
#import<bits/stdc++.h>
#define endl '\n'
using namespace std;
typedef long long LL;
LL i,j,k,m,n,a[200040];
string s;
main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	for(;i++<n;)
	{
		cin>>k;
		m+=k%2*i%2;
	}
	cout<<m;
}

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

#define rep(i, s, n) for (Int i = s; i < (Int)(n); i++)
#define rrep(i, n, s) for (Int i = n - 1; i >= s; i--)
#define dump(x) cout << (x) << '\n'
#define Int int64_t
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).end()
 
double EPS = 1e-10;
Int INF = 1e18;
int inf = 1e9;
Int mod = 1e9+7;

int main() {
    Int n;
    cin >> n;
    vector<Int> a(n);
    rep(i, 0, n) cin >> a[i];
    vector<Int> b(1e5 + 1, 0);
    rep(i, 0, n) {
        if (a[i] > 0) {
            b[a[i] - 1]++;
        }
        b[a[i]]++;
        b[a[i] + 1]++;
    }
    Int res = 0;
    rep(i, 0, 1e5 + 1) res = max(res, b[i]);
    dump(res);
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;


int main()
{
    ll ab, bc, ca;
    cin >> ab >> bc >> ca;
    cout << ab * bc / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
<?php
  
class out {
    public static function println($str = "") {
        echo ($str) . PHP_EOL;
    }
}


$gets = trim(fgets(STDIN));
$gets = explode(' ',$gets);

$num1 = intval($gets[0]);
$num2 = intval($gets[1]);

$ans = F_even_or_odd($num1, $num2);

out::println($ans);

function F_even_or_odd($num1, $num2){
    
    $seki = $num1*$num2;
    if($seki%2==0){
        $res = 'Even';
    }else{
        $res = 'Odd';
    }
    
    return $res;
}

?>

Measured memory_bytes: 4084
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 10000000



int main(){
	
	long long a,b,c,d;
	cin>>a>>b>>c>>d;
	
	cout<<max({a*c,a*d,b*c,b*d})<<endl;
	
	
    return 0;
}


Measured memory_bytes: 3620
s = input()
t = input()

sl = len(s)
tl = len(t)
ans = tl
for i in range(sl-tl+1):
  cnt = 0
  for j in range(tl):
    if s[i+j] != t[j]:
      cnt += 1
  ans = min(ans, cnt)
print(ans)

Measured memory_bytes: 9060