akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <bits/stdc++.h>
#include <math.h>

using namespace std;

int main(){
    int n,k;
    cin>>n>>k;
    priority_queue<int> stick;
    
    for(int i=0;i<n;i++){
        int hoge;
        cin>>hoge;
        stick.push(hoge);
    }
    
    int ans=0;
    
    for(int i=0;i<k;i++){
        ans+=stick.top();
        stick.pop();
    }
    
    cout<<ans<<endl;
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<cmath>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<deque>
using namespace std;
#define ll long long
const int mod = 1000000007;
const ll INF = 1000000000000000000;

int A[1010], B[1010];
int dp[10010];
int main()
{
	int H, N;
	cin >> H >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i] >> B[i];
	}
	for (int i = 0; i < 10010; i++) dp[i] = mod;
	dp[0] = 0;
	for (int i = 1; i <= H; i++) {
		for (int j = 0; j < N; j++) {
			dp[i] = min(dp[i], dp[max(0, i - A[j])] + B[j]);
		}
		//cout << dp[i] << endl;
	}
	cout << dp[H] << endl;
}


Measured memory_bytes: 256
from math import sqrt
n = int(input())


def kai(x):
    a = 1
    for i in range(1, x + 1):
        a *= i
    return a


def d(a, b):
    return sqrt((a[0] - b[0]) ** 2 + (a[1] - b[1]) ** 2)


xy = []
for _ in range(n):
    xy.append([int(i) for i in input().split()])

k = 0
for i in range(n):
    for j in range(i + 1, n):
        k += d(xy[i], xy[j])
print(k/n*2)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
using namespace std;
typedef double  dbl;
typedef long long int lld;
#define PI 3.14159265358979323
#define foi(i,n) for(i = 0; i < n; i+=1)
#define fod(i,n) for(i=n-1; i >=0; i-=1)
#define MAX std::numeric_limits<lld>::max()
#define MIN std::numeric_limits<lld>::min()
#define FastIO  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main ()
{
      FastIO
      string s;
      cin >> s;
      if (s == "SAT")
            cout << "1\n";
      if (s == "FRI")
            cout << "2\n";
      if (s == "THU")
            cout << "3\n";
      if (s == "WED")
            cout << "4\n";
      if (s == "TUE")
            cout << "5\n";
      if (s == "MON")
            cout << "6\n";
      if (s == "SUN")
            cout << "7\n";
      return 0;
}

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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	string s,t; cin>>s>>t;
	reverse (s.begin(),s.end());
	cout << (s==t?"YES":"NO")<< endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define REP(i,n) for(int i=(0);i<(n);i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;

inline int read(){
	char ch=getchar();int x=0,op=0;
	while(!isdigit(ch))op|=(ch=='-'),ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return op?-x:x;
}

const int N=100005,M=N*15;
const ll inf=1e18;
namespace G{
	struct edge{
		int u,v,f,c;ll w;int id;
	}e[M];
	ll f[N],d[N];
	int n,m,s,t,flag;
	vi g[N];
	inline void init(int _n,int _s,int _t,int _flag=1){
		n=_n,m=0,s=_s,t=_t,flag=_flag;
		rep(i,1,n)f[i]=0;
	}
	inline void add(int u,int v,int c,ll w){
		g[u].pb(m),w*=flag;
		e[m++]=(edge){u,v,0,c,w,(int)g[v].size()};
		g[v].pb(m);
		e[m++]=(edge){v,u,0,0,-w,(int)g[u].size()-1};
	}
	struct node{
		int u;ll d;
		inline friend bool operator < (node a,node b){
			return a.d>b.d;
		}
	};
	priority_queue<node> Q;
	int dij(){
		rep(i,1,n)d[i]=inf;
		d[s]=0,Q.push((node){s,0});
		while(!Q.empty()){
			node t=Q.top();Q.pop();
			if(d[t.u]!=t.d){
                assert(d[t.u]<t.d);
                continue;
            }
			int u=t.u;
			for(auto k:g[u]){
				int v=e[k].v;
				if(e[k].f<e[k].c&&d[u]+e[k].w+f[u]-f[v]<d[v]){
					d[v]=d[u]+e[k].w+f[u]-f[v];
					Q.push((node){v,d[v]});
				}
			}
		}
		return d[t]<inf;
	}
	int in[N],r[N];
	int dfs(int u,int a){
		if(u==t)return a;
		ll res=0;in[u]=1;
		for(int &p=r[u];p<g[u].size();p++){
			int k=g[u][p],v=e[k].v;
			if(e[k].f<e[k].c&&d[u]+e[k].w+f[u]-f[v]==d[v]&&!in[v]){
				int tmp=dfs(v,min(a,e[k].c-e[k].f));
				res+=tmp,a-=tmp;
				e[k].f+=tmp,
				e[g[e[k].v][e[k].id]].f-=tmp;
			}
			if(!a)break;
		}
		return in[u]=0,res;
	}
	void mcmf(ll &flow,ll &cost){
		while(dij()){
			rep(i,1,n)r[i]=0;
			ll owo=dfs(s,2e9);
			flow+=owo,cost+=owo*(d[t]+f[t]);
			rep(i,1,n)f[i]=min(f[i]+d[i],inf);
		}
	}
}

int n,x,y,c,p0,p1,p2,p3,s,t,bas;

int main(){
	scanf("%d",&n);
	G::init(n*2+6,s=1,t=2,-1);
	p0=3,p1=4,p2=5,p3=6,bas=6;
	rep(i,1,n){
		scanf("%d%d%d",&x,&y,&c);
		G::add(s,bas+i,c,0);
		G::add(bas+i,p0,c,+x+y);
		G::add(bas+i,p1,c,+x-y);
		G::add(bas+i,p2,c,-x+y);
		G::add(bas+i,p3,c,-x-y);
	}
	bas+=n;
	rep(i,1,n){
		scanf("%d%d%d",&x,&y,&c);
		G::add(bas+i,t,c,0);
		G::add(p3,bas+i,c,+x+y);
		G::add(p2,bas+i,c,+x-y);
		G::add(p1,bas+i,c,-x+y);
		G::add(p0,bas+i,c,-x-y);
	}
	ll flow=0,cost=0;
	G::mcmf(flow,cost);
	cout<<-cost<<endl;

	return 0;
}


Measured memory_bytes: 6144
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pull = pair<ull, ll>;
using pis = pair<int, string>;
#define INF 1000000000
#define LLINF 10000000000000000ll
#define MOD 1000000007LL

void bfs(vector<vector<ll>>&edges, vector<ll>&dist, ll place, ll d) {
  dist[place] = d;
  for (ll nx: edges[place]) {
    if (dist[nx] != LLINF) continue;
    bfs(edges, dist, nx, d+1);
  }
  return;
}

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

  ll n, u, v;
  cin >> n >> u >> v;
  u--, v--;
  vector<vector<ll>> edges(n);
  for (int i = 0; i < n-1; i++) {
    ll a, b;
    cin >> a >> b;
    a--, b--;
    edges[a].emplace_back(b);
    edges[b].emplace_back(a);
  }
  
  vector<ll> dist_takahashi(n, LLINF), dist_aoki(n, LLINF);
  bfs(edges, dist_takahashi, u, 0);
  //vector<ll> dist_aoki(n, LLINF);
  bfs(edges, dist_aoki, v, 0);

  //vector<ll> issep(n);
  //for (int i = 0; i < n; i++) if (edges[i].size() > 1) issep[i] = -1;
  //for (int i = 0; i < n; i++) if ((issep[i] == -1) && (dist_takahashi[i] < dist_aoki[i])) issep[i] = 1;
  
  //一番aokiからの距離が近い、到達可能な分岐点からの距離が最も遠いのはどこか
  //この分岐点は唯一に定まる？
  /*
  ll sep, d = LLINF;
  for (int i = 0; i < n; i++) {
    if (issep[i] == 1) {
      if (d > dist_aoki[i]) {
        sep = i;
        d = dist_aoki[i];
      }
    }
  }*/

  ll ans = -1;
  for (int i = 0; i < n; i++) {
    //ans = max(ans, dist_aoki[i]);
    if (dist_takahashi[i] < dist_aoki[i]) ans = max(ans, dist_aoki[i]);
  }
  cout << ans - 1 << endl;

  
}


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

int main()
{
	int N;
	int l, r;
	int sum=0;

	cin >> N;
	
	for (int i = 0; i < N; i++) {
		cin >> l >> r;
		sum += r - l + 1;
	}
	cout << sum << endl;
}


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

int main() {
  int A, B;
  cin >> A >> B;

  int result = 0;
  for (int i = 0; i < 2; i++)
  {
    if (A > B) {
      result += A;
      A--;
    } else {
      result += B;
      B--;
    }
  }

  cout << result << "\n";
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    int A[n];
    for(int i=0;i<n;i++)
    {
        scanf("%d",&A[i]);
    }
    for(int i=n-1;i>0;i--)
    printf("%d ",A[i]);
    
    printf("%d\n",A[0]);
}


Measured memory_bytes: 2720
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <stack>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}

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

    ll N;
    cin >> N ; 
    for(ll i = 0 ; i <= N/4; i++){
        if((N-(4*i))%7 == 0){
            cout << "Yes" << endl ;
            return 0;
        }
    }
    cout << "No" << endl;

    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define io freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define lli long long 
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL);
#define fi(i,a,n) for(int i=a; i<=n; i++)
using namespace std;
// int main(){
//     io
//     fast
// int a,b,c;
//     	int x;
//     	cin>>a>>b>>c;
//     	cin>>x;
// int i=0;
//      if(c>b && b>a) i=1;
//      	else{
//      		while(x--){
//      			if(b>c){c=c*2;}
//      			else if(a>b){b=b*2;}
//      			else continue;

//      if(c>b && b>a) {i=1;break;}
//      		}

//      	}
//      if(i)cout<<"Yes";
//      else cout<<"No";
// }

int main(){
	
	int n,k;
	cin>>n>>k;
	vector<lli> v;
	for(int i=0;i<n;i++){
		lli x;
		cin>>x;
			v.push_back(x);
	}
for(int i=k-1;i<n-1;i++){
	// lli a,b,t=0;
	// a=b=1;
	// int p;
	// p=k;
	// while(p--){a*=v[i-t];
	// 	b*=v[i+1-t];
	// 	t++;}

	if(v[i-k+1]<v[i+1])cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
		}
}

Measured memory_bytes: 5352
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scan = new Scanner(System.in);
        String str = scan.next();
        char st[] = new char[str.length()];
        int ans=0;
        for(int i=0;i<str.length();i++){
        	st[i] = str.charAt(i);
        }
        for(int i=0; i<st.length;i++){
        	if('A'==st[i]){
        		for(int f = i; f<st.length;f++){
        			if('Z'==st[f]){
        				ans = f - i+1;
        			}
        		}break;
        	}
        }
        System.out.println(ans);
	}

}


Measured memory_bytes: 26068
#include<iostream>
using namespace std;
int main()
{
    int n;
    cin>>n;
    n=n%10;
    if(n==2 ||  n==4 || n==5 || n==7 || n==9)
        cout<<"hon"<<endl;
    else if(n==0 || n==1 || n==6 || n==8)
        cout<<"pon"<<endl;
    else
        cout<<"bon"<<endl;

    return 0;
}


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

int main() {
  int t, n, s, f;
  while (cin >> t, t) {
    cin >> n;
    int sum = 0;
    while (n--) {
      cin >> s >> f;
      sum += f - s;
    }
    if (sum >= t) cout << "OK\n";
    else cout << t - sum << "\n";
  }
}


Measured memory_bytes: 3052
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
using llong = long long;
using P = pair<int, int>;
const int inf = 1 << 20;
const int mod = 1e9 + 7;

int index(char ch) {
   if (islower(ch)) return ch - 'a';
   if (isupper(ch)) return ch - 'A';
   return -1;
}
int main() {
   vector<int> alp(26);
   char ch;
   while (cin >> ch) {
      int ind = index(ch);
      if (index(ch) == -1) continue;
      alp[ind]++;
   }
   rep(i, alp.size()) { printf("%c : %d\n", (char)i + 'a', alp[i]); }
   return 0;
}


Measured memory_bytes: 3216
import math

N = int(input())
A = []
B = []
F = []

for i in range(1,int(math.sqrt(N))+1,1):
    if (N%i)== 0:
        A.append(N/i)
        B.append(i)
for i in range(len(A)):
    count_A = int(math.log10(A[i])+1)
    count_B = int(math.log10(B[i])+1)
    if count_A >= count_B:
        F.append(count_A)
    else:
        F.append(count_B)
print(min(F))


Measured memory_bytes: 3064
import java.util.*;
 
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
      
      int x = Math.min(a,b);
      int y = Math.min(c,d);
      
      System.out.print(x+y);

    }
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

int main(){

    LL N,sum=0;cin>>N;
    LL A[N],sub[N];
    REP(i,N){
        cin>>A[i];
        sum+=A[i];
    }
    REP(i,N)sub[i]=-A[(i+1+N)%N]+A[(i+N)%N];
    bool flag = true;


    if(N==1){
        cout<<"YES"<<endl;
    }else{

        if(sum%(N*(N+1)/2)!=0)flag = false;
        LL num = sum/(N*(N+1)/2);
        REP(i,N)sub[i]+=num;
        REP(i,N){
            if(sub[i]%N!=0||sub[i]<0)flag = false;
            num-=(sub[i]/N);
        }

        if(num!=0||!flag)cout<<"NO"<<endl;
        else cout<<"YES"<<endl;
    }



    return 0;
}

Measured memory_bytes: 1792
#include "iostream"
#include "algorithm"
using namespace std;

int main() {
	int a, b, ans[3];
	cin >> a >> b;
	ans[0] = a + b;
	ans[1] = a - b;
	ans[2] = a*b;
	sort(ans, ans + 3);
	cout << ans[2];
	return 0;
}

Measured memory_bytes: 256
import bisect
N,M,K = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
ac = [0]*(N+1)
bc = [0]*(M)
bc[0] = b[0]
for i,val in enumerate(a):
    ac[i+1] = ac[i] + val
for i,val in enumerate(b[1:]):
    bc[i+1] = bc[i] + val
res = 0
for i,val in enumerate(ac):
    if val > K:
        break
    rest = K-val
    idx = bisect.bisect_right(bc, rest)
    if idx+i > res:
        res = idx+i
print(res)


Measured memory_bytes: 110816
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <fstream>
#include <iostream>
#include <map>
#include <queue>
#include <string>
#include <stack>
#include <vector>
#include <set>
#include <tuple>
#include <utility>
#include <functional>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
const int INF = 1000000000;
const int MOD = 1000000009;

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

	map<int,bool> mp;
	int cnt = 0;
	for(int i = 0;i < n;i++){
		int a;
		cin >> a;
		if(1 <= a && a < 400)mp[1] = true;
		if(400 <= a && a < 800)mp[2] = true;
		if(800 <= a && a < 1200)mp[3] = true;
		if(1200 <= a && a < 1600)mp[4] = true;
		if(1600 <= a && a < 2000)mp[5] = true;
		if(2000 <= a && a < 2400)mp[6] = true;
		if(2400 <= a && a < 2800)mp[7] = true;
		if(2800 <= a && a < 3200)mp[8] = true;
		if(3200 <= a)cnt++;
	}

	if(mp.size() == 0)cout << 1 << " " << cnt << endl;
	else cout << mp.size() << " " << (int)mp.size()+cnt << endl;
}


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

#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define FORR(i,m,n) for(int i=m;i>=n;i--)
#define pb(x) push_back(x) 
#define SORT(x) sort((x).begin(),(x).end())
#define INF 999999999

using namespace std;

#define int long long

struct ad{
	int a;
	int d;
};

int32_t main(){
	int n, t, q;
	vector<struct ad> house;
	vector<int> stop;
	cin >> n >> t >> q;
	REP(i, n){
		int a, d;
		cin >> a >> d;
		house.push_back((ad){a, d});
		if(i && house[i-1].d == 1 && house[i].d == 2){
			stop.push_back((house[i].a + house[i-1].a)/2);
		}
	}

	REP(i, q){
		int x;
		cin >> x;
		x--;
		if(house[x].d == 1){
			auto st = lower_bound(stop.begin(), stop.end(), house[x].a);
			if(st == stop.end()) cout << house[x].a + t << endl; 
			else cout << min(*st, house[x].a + t) << endl;
		}
		else{
			auto st = lower_bound(stop.begin(), stop.end(), house[x].a);
			if(st == stop.begin()) cout << house[x].a - t << endl; 
			else cout << max(*(st-1), house[x].a - t) << endl;
		}
	}
}

Measured memory_bytes: 5320
using System;

    class Program
    {
        static void Main(string[] args)
        {
            // 整数の入力
        
        string[] s = Console.ReadLine().Split(' ');
        int M1 = int.Parse(s[0]);
        string[] s2 = Console.ReadLine().Split(' ');
        int M2 = int.Parse(s2[0]);

        int Out = 0;
        if (M1 != M2)
        {
            Out = 1;
        }
            //出力
            Console.WriteLine(Out);
           // Console.ReadKey();

        }
    
}


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

typedef long long LL;

int main() {
    LL N, P;
    cin >> N >> P;
    LL P_aux = P;
    vector<pair<LL, int>> divisors;

    int rep = 0;

    if (N == 1)
    {
        cout << P;
        return 0;
    }

    
    for (LL i = 2; i <= sqrt(P); i ++) {
        rep = 0;
        if (!(P_aux % i)) {
            while (!(P_aux % i)) {
                rep++;
                P_aux /= i;
            }
            divisors.push_back(make_pair(i, rep));
        }
    }
    LL out = 1;
    for (LL i = 0; i < divisors.size(); i++)
    {
        if (divisors[i].second >= N) {
            LL coeff = (LL)floor((double)divisors[i].second / (double)N);
            for (int j = 1; j <= coeff; j++)
                out *= divisors[i].first;
        }
    }

    cout << out;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int main()
{
    int n,t,k,a[3000],i,p;
    float s,w,min;
    while(~scanf("%d",&n))
    {
        min=9999999999;
        scanf("%d %d",&t,&k);
        for(i=1;i<=n;i++)
            scanf("%d",&a[i]);
        for(i=1;i<=n;i++)
        {
            s=t-a[i]*0.006;
            s=fabs(s-k);
            if(s<min)
            {
                min=s;
                p=i;
            }
        }
        printf("%d\n",p);
    }
    return 0;
}



Measured memory_bytes: 128
import math
from math import gcd
INF = float("inf")

import sys
input=sys.stdin.readline
import itertools
from collections import Counter

def main():
    w,h,x,y = map(int, input().split())
    s = (w*h)/2
    if x*2 == w and y*2 == h:
        k = 1
    else:
        k = 0
    print(s,k)



if __name__=="__main__":
    main()


Measured memory_bytes: 65300
#include <stdio.h>

int main(void){
    int i, n, cnt = 1;
    char s[100000 + 1], nc;
    scanf("%d", &n);
    scanf("%s", s);
    nc = s[0];
    for (i = 0; i < n; ++i){
        if (nc != s[i]){
            nc = s[i];
            cnt++;
        }
    }
    printf("%d\n", cnt);
    return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            line.pop();
            line
        }
    )
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let iter = line.split_whitespace();
            iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    )
}

// a+b = xk
// b+c = yk
// c+a = zk
// 2a = (x+z-y)k
// 2b = (y+x-z)k
// 2c = (z+y-x)k

// b = xk - a
// c = zk - a
// b+c = (x+z)k - 2a = yk

// 3 2

fn solve(n: usize, k: usize) -> usize {
    if (k % 2) == 1 {
        let odd = n / k;
        odd * odd * odd
    } else {
        let odd = n / (k/2);
        let odd = if odd % 2 == 1 { odd/2 + 1 } else { odd/2 };
        let ev = n / k;
        odd * odd * odd + ev * ev * ev
    }
}

fn main() {
    let (n, k) = parse_line!(usize, usize);

    println!("{}", solve(n, k));
}

#[test]
fn solve_test() {
    assert_eq!(solve(3,2), 9);
    assert_eq!(solve(5,3), 1);
    assert_eq!(solve(35897, 932), 114191);
}


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

using namespace std;

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

	if(a==b){
    	cout << "a == b" << endl;
    }
  	if(a<b){
    	cout << "a < b" << endl;
      
    }
  	if(a>b){
    	cout << "a > b" << endl;
    }
  
  	return 0;
}


Measured memory_bytes: 3088
/*I MAY NOT GET THE SUCCESS IMMEDIATELY BUT I WILL GET IT FOR SURE*/
#include<bits/stdc++.h>
#define opt std::ios_base::sync_with_stdio(false)
#define I int
#define li		int32_t
#define lli		long long
#define ulli unsigned long long

#define pn			 printf("\n")
#define nl			 cout<<'\n'
#define sf(N)        scanf("%lld",&N)
#define pf(N)        printf("%lld",N)
#define sf1(N1,N2)    scanf("%lld %lld",&N1,&N2)
#define pf1(N1,N2)    printf("%lld %lld",N1,N2)
#define sf2(N1,N2,N3) scanf("%lld %lld %lld",&N1,&N2,&N3)
#define pf2(N1,N2,N3) printf("%lld %lld %lld",N1,N2,N3)

#define sl          cout<<' '
#define ps          printf(" ")

#define rep(i,a,b)	for(i=a;i<b;i++)
#define repr(i,a,b)	for(i=a;i>b;i--)
#define elif		else if
#define mset(a,b)	memset(a,b,sizeof(a))

#define pb		push_back
#define pob		pop_back
#define itr		iterator
#define sz()	size()
#define szof    sizeof
#define lb		lower_bound
#define ub		upper_bound
#define mp		make_pair
#define vlli    vector<lli>
#define plli	pair<lli,lli>
#define vplli	vector<plli >
#define F   	first
#define S		second
#define Dup     erase(unique(V.begin(),V.end()),V.end())

#define bs      binary_search
#define ub      upper_bound
#define lb      lower_bound

#define ALL(V)  V.begin(),V.end()

#define MX1     100000
#define MX2     1000000
#define Inf     1000000000000000
#define mod		1000000007
using namespace std;

lli Power(lli a,lli b)
{
    lli result=1;

    while(b)
    {
        if(b%2)
        {
            result=(result*a)%mod;
        }

        b=b>>1;
        a=(a*a)%mod;
    }

 return result;
}

int main()
{
    opt;

    /*#ifndef ONLINE_JUDGE
    freopen("double_squares.txt","r",stdin);
    freopen("double_squares_out.txt","w",stdout);
    #endif // ONLINE_JUDGE*/

    string s;
    cin>>s;

    lli N=s.length(),i;

    rep(i,0,N-8)
    {
        cout<<s[i];
    }




 return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <cmath>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1001001001;
vector<pair<int64_t,int64_t>>func(int64_t x){
  vector<pair<int64_t,int64_t>>p;
  for(int64_t i=2;i*i<=x;i++){
    int cnt=0;
    if(x%i==0){
    while(x%i==0){cnt++;x/=i;}
    p.push_back(make_pair(i,cnt));
    }
  }
  if(x!=1){p.push_back(make_pair(x,1));}
  return p;
}

int main(){
  int N;
  cin>>N;
  vector<string>s(N);
  set<string>k;
  for(int i=0;i<N;i++){
    cin>>s[i];
    k.insert(s[i]);
  }
  cout<<k.size()<<endl;
  return 0;
}

Measured memory_bytes: 25172
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        for (int i = 1; i <= 9; i++) {
            for (int j = 1; j <= 9; j++) {
                System.out.println(i + "x" + j + "=" + (i*j));
            }
        }
    }
}

Measured memory_bytes: 24160
package main

import (
	"fmt"
	"sort"
)

func getArray(m map[rune]int) (a []int) {
	a = make([]int, len(m))
	index := 0
	for _, v := range m {
		a[index] = v
		index++
	}
	return
}

func main() {
	var s, t string
	fmt.Scan(&s, &t)

	sm := make(map[rune]int, len(s))
	for _, v := range s {
		sm[v]++
	}
	sa := getArray(sm)
	sort.Ints(sa)

	tm := make(map[rune]int, len(s))
	for _, v := range t {
		tm[v]++
	}
	ta := getArray(tm)
	sort.Ints(ta)

	if len(sa) != len(ta) {
		fmt.Println("No")
		return
	}

	for i := range sa {
		if sa[i] != ta[i] {
			fmt.Println("No")
			return
		}
	}
	fmt.Println("Yes")
}


Measured memory_bytes: 6528
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int h, w, a, b;
	
	cin>>h>>w>>a>>b;
	
	cout<<h*w-(h/a)*a*(w/b)*b<<endl;
	
	
	return 0;
}


Measured memory_bytes: 3184
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  cin >> n;
  /* 入力 */
  vector<int> a(n), b(n), c(n-1);
  for(int i=0;i<(n);i++){
    cin >> a.at(i);
  }
  for(int i=0;i<(n);i++){
    cin >> b.at(i);
  }
  for(int i=0;i<(n-1);i++){
  cin >> c.at(i);
  }
  /* 計算 */
  int ans;
  ans += accumulate(b.begin(), b.end(), 0);
  for(int i=0;i<(n-1);i++){
    if(a.at(i) == a.at(i+1)-1){
      ans +=  c.at(a.at(i)-1);
    }
  }
  /* 出力 */
  cout << ans;
}


Measured memory_bytes: 256
A1=list(map(int,input().split()))
A2=list(map(int,input().split()))
A3=list(map(int,input().split()))
N=int(input())
b=[int(input()) for i in range(N)]
if A1[0] in b and A2[0] in b and A3[0] in b:
    print('Yes')
    exit()
elif A1[1] in b and A2[1] in b and A3[1] in b:
    print('Yes')
    exit()
elif A1[2] in b and A2[2] in b and A3[2] in b:
    print('Yes')
    exit()
elif A1[0] in b and A1[1] in b and A1[2] in b:
    print('Yes')
    exit()
elif A2[0] in b and A2[1] in b and A2[2] in b:
    print('Yes')
    exit()
elif A3[0] in b and A3[1] in b and A3[2] in b:
    print('Yes')
    exit()
elif A1[0] in b and A2[1] in b and A3[2] in b:
    print('Yes')
    exit()
elif A1[2] in b and A2[1] in b and A3[0] in b:
    print('Yes')
    exit()
else:
    print('No')

Measured memory_bytes: 3064
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset

#include <math.h>
#include <stdlib.h>


#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true; } return false; }
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true; } return false; }

//INT_MAX	2,147,483,647 = 2*1.0e9

int gcd_euclid(int a, int b){
  if(b == 0) return a;
  else gcd_euclid(b, a%b);
}


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

  vector<int> x(N);
  for(int i = 0; i < N; i++)cin >> x[i];
  x.push_back(X);
  sort(x.begin(), x.end());

  vector<int> dist(N);
  for(int i = 0; i < N; i++){
    dist[i] = x[i+1] - x[i];
  }

  int ans = dist[0];
  for(int i = 0; i < N-1; i++){
    ans = gcd_euclid(ans, dist[i+1]);
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
typedef long long ll;

void solve() {
    int N,M,X;
    cin >> N >> M >> X;
    vector<vector<int>> v(N,vector<int>(M+1));

    REP(i,N) {
        REP(j,M+1) cin >> v[i][j];
    }

    ll ans = INF;
    for (int bit = 0; bit < (1 << N); ++bit) {
        vector<int> rikaido(M,0);
        ll money = 0;
        REP(i,N) {
            if (bit & ( 1 << i)) {
                REP(j,M) rikaido[j] += v[i][j+1];
                money+= v[i][0];
            }
        }
        // rikaido check
        bool ok = true;
        REP(i,M) if (rikaido[i] < X) ok = false;
        if (ok) chmin(ans,money);
    }
    if(ans == INF) cout << -1 << endl;
    else cout << ans << endl;
}

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


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

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<endl

int main(){
    int n;
    cin >> n;
    int sum = 0;
    int a[n];
    REP(i,n){
        cin >> a[i];
    }
    int min1 = INF;
    int ans = 0;
    FOR(i,-100,101){
        REP(j,n){
            ans += (a[j]-i)*(a[j]-i);
        }
        min1 = min(min1,ans);
        ans = 0;
    }
    COUT(min1);
    return 0;
} 

Measured memory_bytes: 256
//
/*
//*/
#include <bits/stdc++.h>
#define LL long long
#define ULL unsigned long long
#define MAX(x,y) (((x)>(y))?(x):(y))
#define MIN(x,y) (((x)<(y))?(x):(y))
#define lowbit(x) ((x)&-(x))
struct IO{
	inline char gc() {static char buf[10000000],*p1=buf,*p2=buf;return p1==p2&&(p2=(p1=buf)+fread(buf,1,10000000,stdin),p1==p2)?EOF:*p1++;}
    #ifdef ONLINE_JUDGE
    #else
    	#define gc getchar
    #endif
	template<typename T>inline IO operator>>(T &n){n=0; bool s=0; char c=gc();while(c<'0'||c>'9') s|=c=='-',c=gc();while(c>='0'&&c<='9') n=(n<<3)+(n<<1)+(c^48),c=gc();if(s) n=-n;return *this;}
	template<typename T>inline IO operator<<(T x){if (x<0) x=-x,putchar('-');static T sta[35];T top = 0;do{sta[top++] = x % 10, x /= 10;}while (x);while (top) putchar(sta[--top] + '0');return *this;}
}cin,cout;
int n;
bool t=false;
int main ()
{
	#ifdef ONLINE_JUDGE
	#else
	//freopen("E:\\testdata.in","r",stdin);
	//freopen("E:\\testdata.out","w",stdout);
	#endif
	cin>>n;
	for(int i=1;i<=9;i++)
		for(int j=1;j<=9;j++)
		{
			if(i*j==n)
				t=true;
		}
	if(t)
		puts("Yes");
	else
		puts("No");
	return 0;
}

Measured memory_bytes: 256
n = int(input())
p = list(map(int, input().split()))
q = list(map(int, input().split()))

def fact(n):
  ans = n
  for i in range(1, n):
    ans *= i
  return ans

def number(lst, n):
  numlst = []
  ans = 1
  for i in range(n):
    numlst.append(i+1)
  for i in range(n):
    for j in range(len(numlst)):
      if lst[i] == numlst[j]:
        ans += j*fact(n-i-1)
        numlst.pop(j)
        break
  return ans

res = number(q, n) - number(p, n)
print(abs(res))

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

int n;
int a[100010];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int index;
		cin>>index;
		a[index]=i;
	}
	for(int i=1;i<=n;i++)
		cout<<a[i]<<" ";
	cout<<endl;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define vv(type, c, m, n, i) vector<vector<type>> c(m, vector<type>(n, i));
#define rep(i,a,n) for(int i=(a), i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,n) for(int i=(a); i>n; --i)
#define len(x) ((int)(x).size())
#define mp make_pair
#define eb emplace_back
typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
inline int f(int n, vi s, int q, vi t) {
	int cnt = 0;
	rep(i, 0, n) {
		rep(j, 0, q) {
			if(s[i] == t[j]) {
				++cnt;
			}
		}
	}
	return cnt;
}
int main() {
	int n; cin >> n;
	set<int> ss; {ll t; rep(i, 0, n) {cin >> t; ss.insert(t);}}
	vi s(all(ss));
	int q; cin >> q;
	vi t(q); rep(i, 0, q) cin >> t[i];
	P(f(len(s), s, q, t));
	return 0;
}

Measured memory_bytes: 3216
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>

#define INF 1000000021
#define MOD 1000000007
#define pb push_back
#define sqr(a) (a)*(a)
#define M(a, b) make_pair(a,b)
#define T(a, b, c) make_pair(a, make_pair(b, c))
#define F first
#define S second
#define all(x) (x.begin(), x.end())
#define deb(x) cerr << #x << " = " << x << '\n'
#define N 222222

using namespace std;
//using namespace __gnu_pbds;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

const ld pi = 2 * acos(0.0);
template<class T> bool umin(T& a, T b){if(a>b){a=b;return 1;}return 0;}
template<class T> bool umax(T& a, T b){if(a<b){a=b;return 1;}return 0;}
template<class T, class TT> bool pal(T a, TT n){int k=0;for(int i=0;i<=n/2;i++){if(a[i]!=a[n-i-1]){k=1;break;}}return k?0:1;}

//int month[] = {0,31,28,31,30,31,30,31,31,30,31,30,31};

ll a[N], b[N];
int main()
{
	int n;
	cin >> n;
	for(int i = 1; i <= n; i ++)
		cin >> a[i];
	ll ans = 0;
	for(int i = 1; i <= n; i ++)
	{
		if(i + a[i] <= n)
			b[i + a[i]] ++;
		if(i - a[i] >= 1)
			ans += b[i - a[i]];
	}
	cout << ans;





	





	getchar();
	getchar();
	return 0;
	//ios::sync_with_stdio(false);
	//cin.tie(0);
}

Measured memory_bytes: 6744
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String S = scan.next();
		String T = scan.next();
		scan.close();
		
		int len = S.length();
		char ch = T.charAt(0);
		
		for (int i = 0 ; i < len ; i++) {
			if (ch == S.charAt(i)) {
				String f = S.substring(i);
				String b = S.substring(0, i);
				if (T.equals(f + b)) {
					System.out.print("Yes");
					return;
				}
			}
		}
		
		System.out.print("No"); 
	}
}


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

using namespace std;

int N;
vector<vector<int>> farr;
vector<vector<int>> parr;

bool isValid(string &state) {
    for (int i = 0; i < state.size(); i++) {
        if (state[i] == '1') {
            return true;
        }
    }
    return false;
}

int64_t calc(int idx, string state) {
    int64_t count = 0;
    for (int i = 0; i < 10; i++) {
        if (state[i] == '1' && farr[idx][i] == 1) {
            count++;
        }
    }
    return count;
}

int64_t dfs(string state) {
    if (state.size() == 10) {
        if (!isValid(state)) {
            return INT64_MIN;
        } 

        int64_t profit = 0;
        for (int i = 0; i < N; i++) {
            int num = calc(i, state);
            profit += parr[i][num];
        }
        return profit;
    }

    return max(
        dfs(state + "0"),
        dfs(state + "1")
    );
}

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

    farr = vector<vector<int>>(N, vector<int>(10));
    vector<vector<int>> farr1(N, vector<int>(10));
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < 10; j++) {
            cin >> farr[i][j];
        }
    }

    parr = vector<vector<int>>(N, vector<int>(11));
    for (int k = 0; k < N; k++) {
        for (int l = 0; l < 11; l++) {
            cin >> parr[k][l];
        }
    }

    int ans = dfs("");
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>

using namespace std;

int main(){
    int X,sen,go;
    cin>>X;
    sen=X/500;
    go=(X-500*sen)/5;
    cout<<1000*sen+5*go<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define REP(i, a, b) for(int i = a; i <= b; i++)
#define all(x) x.begin(), x.end()
#define fi first
#define se second
#define debug(...) cerr<<__LINE__<<" ["<<#__VA_ARGS__<<"]:",debug_out(__VA_ARGS__)
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec)
{ for (auto v : vec) os << v << ' '; os << '\n'; return os; }
template <typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa)
{ os << '(' << pa.first << ',' << pa.second << ')'; return os; }
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T)
{ cerr << " " << H; debug_out(T...); }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = (1<<30) - 1;
const ll LINF = (1LL<<60) - 1;

void solve() {
    string s, t;
    cin >> s >> t;
    int cnt = 0;
    rep(i, 3) {
        cnt += s[i] == t[i];
    }
    cout << cnt << endl;
}

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


Measured memory_bytes: 3580
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>
#include<cmath>
#include<iostream>
using namespace std;
typedef long long ll;
int const maxn=105;
int n;
ll x[maxn],y[maxn],h[maxn];
int judge(ll cx,ll cy){
	int H=-1;
	for(int i=0;i<n;i++)
    if(h[i]>0){
        H=h[i]+abs(cx-x[i])+abs(cy-y[i]);
        if(H>=1) break;
        else H=-1;
    }
	for(int i=0;i<n;i++){
    ll hh=max(H-abs(cx-x[i])-abs(cy-y[i]),(ll)0);
    if(hh!=h[i]){
        return -1;
    }
	}
	return H;
}

int main(){
	scanf("%d",&n);
	for (int i=0;i<n;i++)
    scanf("%lld%lld%lld",&x[i],&y[i],&h[i]);

	int ans=-1;
	for(int i=0;i<=100;i++)
    for(int j=0;j<=100;j++){
        ans=judge(i,j);
        if(ans!=-1){
            printf("%d %d %d\n",i,j,ans);
            return 0;
        }
	}
}

Measured memory_bytes: 256
n, k = [int(i) for i in input().split(" ")]
v = [int(i) for i in input().split(" ")]
mx = 0

def s(l, r):
    global mx
    d = k - l - r
    m = []
    for i in range(l):
        m.append(v[i])
    for i in range(1, r + 1):
        m.append(v[-i])
    m = sorted(m)
    ss = sum(m)
    for i in range(d):
        if i < len(m) and m[i] < 0:
            ss -= m[i]
    if ss > mx:
        mx = ss

for l in range(min(n, k) + 1):
    for r in range(min(n, k) - l + 1):
        s(l, r)

print(mx)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main() {
	ll n;
	scanf("%lld",&n);
	if(n&1) printf("0\n");
	else {
		ll ans=n/10;
		n/=10;
		while(n) {
			ans+=n/5;
			n/=5;
		}
		printf("%lld\n",ans);
	}
	return 0;
}

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")
elif 1800<=X<=1999:
    print("1")

Measured memory_bytes: 61648
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define invrep(i,n) for(int64_t i=n-1;i >= 0;i--)
#define _GLIBCXX_DEBUG
using namespace std;

int main(){
  int64_t n,a,b;
  cin >> n >> a >> b;
  int64_t sho = n / (a+b);
  cout << sho*a + min(a,n%(a+b)) << endl;
}
      
    

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

long n,ans1=0;
vector<long> a(100010);
vector<long> b(100010);
map<vector<long>,long> ans2;
vector<vector<long>> aaa(100010);
vector<bool> homon(100010,true);
queue<vector<long>> q;
int main() {
  cin >> n;
  for(long i=0;i<n-1;i++) {
    cin >> a[i] >> b[i];
    ans2[{a[i],b[i]}]=0;
    aaa[a[i]-1].push_back(b[i]);
    aaa[b[i]-1].push_back(a[i]);
  }
  q.push({1,-1});
  homon[0]=false;
  while(q.size()>0) {
    long c=1;
    long as=q.front()[0];
    long x=q.front()[1];
    for(long i=0;i<aaa[as-1].size();i++) {
      if(c==x) c++;
      if(homon[aaa[as-1][i]-1]) {
        homon[aaa[as-1][i]-1]=false;
        ans2[{min(as,aaa[as-1][i]),max(as,aaa[as-1][i])}]=c;
        q.push({aaa[as-1][i],c});
        ans1=max(ans1,c);
        c++;
      }
    }
    q.pop();
  }
  cout << ans1 << endl;
  for(long i=0;i<n-1;i++) cout << ans2[{a[i],b[i]}] << endl;
}

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

char a[200100];
int l,now;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cin>>a; l=strlen(a);
	for(int i=0;i<l;i++)
		now=(now+a[i]-'0')%9;
	if(now) cout<<"No";
	else cout<<"Yes";
}


Measured memory_bytes: 3708
s = input()
t = input()
x = len(s)
dic = {}
already = set()
for i in range(x):
    if not s[i] in dic.keys():
        if t[i] in already:
            print("No")
            exit()
        dic[s[i]] = t[i]
        already.add(t[i])
    else:
        if dic[s[i]] != t[i]:
            print("No")
            exit()
print("Yes")

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

const int mod = 1000000000 + 7;

bool G[9][9];

int main()
{
   
    
    int a, b, c, N, M;

    scanf("%d %d", &N, &M);

    while(M--)
    {
        scanf("%d %d", &b, &c);
        G[b][c] = G[c][b] = true;
    }

    vector<int>v;

    for(int i = 2; i <= N; i++)
    {
        v.push_back(i);
    }

    int ans = 0;

    do
    {
        int i;
        int j = 1;
        for(i = 0; i < N - 1; i++)
        {
            if(!G[j][ v[i] ])
            {
                break;
            }
            j = v[i];
        }
        if(i == N - 1)
        {
            ans++;
        }
    }while(next_permutation(v.begin(), v.end()));

    cout<<ans<<endl;
    

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
typedef struct{
  string first;
  int score,num;
} team;
int main(){
  int n,a,b,c,k=-1,nn[51];
  team t[51][11];
  cin >> n;
  while(n != 0){
    k++;
    nn[k] = n;
    for(int i=0;i<n;i++){
      cin >> t[k][i].first >> a >> b >> c;
      t[k][i].score = a*3+c;
      t[k][i].num = i;
    }
    for(int i=0;i<n-1;i++){
      for(int j=i+1;j<n;j++){
	if(t[k][i].score < t[k][j].score){
	  team temp = t[k][i];
	  t[k][i] = t[k][j];
	  t[k][j] = temp;
	} else if(t[k][i].score == t[k][j].score && t[k][i].num > t[k][j].num){
	  team temp = t[k][i];
	  t[k][i] = t[k][j];
	  t[k][j] = temp;
	}
      }
    }
    cin >> n;
  }
  for(int j=0;j<=k;j++){
    for(int i=0;i<nn[j];i++){
      cout << t[j][i].first << ',' << t[j][i].score << endl;
    }
    if(j != k) cout << endl;
  }
  return (0);
}

Measured memory_bytes: 3028
//* AuThOr GaRyMr *//
#include<bits/stdc++.h>
#define rb(a,b,c) for(int a=b;a<=c;++a)
#define rl(a,b,c) for(int a=b;a>=c;--a)
#define niv vector<int>
#define LL long long
#define IT iterator
#define PB(a) push_back(a)
#define II(a,b) make_pair(a,b)
#define FIR first
#define SEC second
#define FREO freopen("check.out","w",stdout)
#define rep(a,b) for(int a=0;a<b;++a)
#define KEEP while(1)
#define SRAND mt19937 rng(chrono::steady_clock::now().time_since_epoch().count())
#define random(a) rng()%a
using namespace std;
const int INF=0x3f3f3f3f;
typedef pair<int,int> mp;
typedef pair<mp,mp> superpair;
int  n;
int res[505][505];
void dfs(int start,int to,int index){
	if(to-start+1<=1) return;
	rb(i,start,to)
		rb(j,i+1,to) res[i][j]=index;
	int mid=(start+to)>>1;
	dfs(start,mid,index+1),dfs(mid+1,to,index+1); 
}
int main(){
	cin>>n;
	dfs(1,n,1);
	rb(i,1,n){
		rb(j,i+1,n) cout<<res[i][j]<<" ";cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1536
import numpy as np
n, T = map(int, input().split())
array = np.zeros((0, 2))

for i in range(n):
    #print(np.array(list(map(int, input().split()))))

    array = np.r_[array, np.array(list(map(int, input().split()))).reshape(-1, 2)]

idx = np.argsort(array[:, 0])
array = array[idx]
result = 'TLE'
for c, t in array:
    if t <= T:
        result = int(c)
        break
    

print(result)

Measured memory_bytes: 12424
#include <iostream>

using namespace std;

void solve()
{
	int l[10];
	while(cin >> l[0])
	{
		for(int i = 1; i <= 9; ++i)
		{
			scanf(",%d", &l[i]);
		}
		int v[2];
		scanf(",%d,%d", &v[0], &v[1]);
		int sum = 0;
		for(int i = 0; i < 10; ++i)
		{
			sum += l[i];
		}
		double time = (double)sum / (v[0] + v[1]);
		double dist = time * (double)v[0];
		int pos = 0;
		int d = 0;
		while(true)
		{
			d += l[pos];
			if(d >= dist)
			{
				cout << pos + 1 << endl;
				break;
			}
			++pos;
		}
	}
}

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

Measured memory_bytes: 0
def main():
    N = int(input())
    W = [int(x) for x in input().split()]
    w = sum(W)
    mini = w
    for i in range(N):
        a = sum(W[i+1:])
        b = w - a
        k = abs(a - b)
        if mini > k:
            mini = k
    print(mini)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3188
n=int(input())
xx=input().split()
x=[]
for k in range(len(xx)):
  x.append(int(xx[k]))
x=sorted(x)
ok='YES'
for k in range(len(x)-1):
  if x[k]==x[k+1]:
    ok='NO'
    break
print(ok)    
    
  
  

Measured memory_bytes: 28344
#include<iostream>
#include<string>
using namespace std;
int main(){
    int i,j,a[5],b=100000,c=0,n,cnt=0,z=10,x=0,y;
    for(i=0;i<5;i++){
        cin >> a[i];
        if(a[i]<b){
            b = a[i];
        }
    }
    for(i=0;i<5;i++){
        if(a[i]==b){
            n = i;
            break;
        }
    }
    if(b%10!=0){
        c = (1+b/10)*10;
    }
    else{
        c = b;
    }
    for(i=0;i<5;i++){
        if(n!=i&&a[i]%10==0){
            c = c+a[i];
        }
    }
    for(i=0;i<5;i++){
        if(i!=n&&a[i]%10!=0){
            if(a[i]%10<z){
                z = a[i]%10;
            }
        }
    }
    for(i=0;i<5;i++){
        if(i!=n&&a[i]%10!=0){
            if(a[i]%10==z){
                x = a[i];
                y = i;
                break;
            }
        }
    }
    for(i=0;i<5;i++){
        if(i!=n&&a[i]%10!=0&&i!=y){
            c = c+(1+a[i]/10)*10;
        }
    }

    if(z>b%10){
        c = c-(1+b/10)*10+(1+x/10)*10+b-x;
    }
    cout << c+x;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main() {
    int n, q;
    cin >> n >> q;
    
    string s;
    cin >> s;
    
    vector<char> t(q), d(q);
    for (int i = 0; i < q; i++) {
        cin >> t[i] >> d[i];
    }
    
    auto f = [&](int i) {
        for (int j = 0; j < q; j++) {
            if (t[j] == s[i]) {
                if (d[j] == 'L') {
                    i--;
                    
                    if (i < 0) {
                        return -1;
                    }
                } else {
                    i++;
                    
                    if (i >= n) {
                        return 1;
                    }
                }
            }
        }
        
        return 0;
    };
    
    int ans = n;
    
    if (f(0) == -1) {
        int ok = 0;
        int ng = n;
        
        while(ng - ok > 1) {
            int m = (ok + ng) / 2;
            
            if (f(m) == -1) {
                ok = m;   
            } else {
                ng = m;
            }
        }
        
        ans -= ok + 1;
    }
    
    if (f(n - 1) == 1) {
        int ok = n - 1;
        int ng = -1;
        
        while(ok - ng > 1) {
            int m = (ok + ng) / 2;
            
            if (f(m) == 1) {
                ok = m;   
            } else {
                ng = m;
            }
        }
        
        ans -= n - ok;
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 960