akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

const int MAXN = 2e4;
const int MX = 3e4;
const int MX2 = MX / 2;
const int MX3 = MX / 6;

int n;
int res[MAXN + 10];

int main() {
   scanf("%d", &n);
   if(n == 3) {
      res[1] = 2; res[2] = 3; res[3] = 25;
   } else {
      int ss = 0;
      for(int c2 = 1; c2 <= min(n,MX2); c2++) {
         res[c2] = 2*c2;
         ss += res[c2];
         int c3 = (n - c2);
         if(n % 3 == 0) c3--;
         if((c2+int(n % 3 == 0)) > MX2 || ss % 3 || c3 > MX3 || c3 % 2) continue;
         if(n % 3 == 0) {
            int x = 2*c2 + 2;
            while(x % 3) x += 2;
            res[++c2] = x;
         }
         for(int j = 1; j <= c3; j++) {
            res[c2+j] = 3+6*(j-1);
         }
         cerr << "yay\n";
         break;
      }
   }
   for(int i = 1; i <= n; i++) {
      printf("%d ", res[i]);
   }
   printf("\n");
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int F=1000000007;
main(){
    ll n,m,ans=1,now=0,flag=true,kouho=0,a_kouho=0,b_kouho=0;
    cin>>n>>m;
    ll a[n],b[m],count1[m*n],count2[m*n],a1[m*n+1],a2[m*n+1];
    a1[m*n]=0;
    a2[m*n]=0;
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    for(int j=0;j<m;j++){
        cin>>b[j];
    }

    sort(a,a+n);
    sort(b,b+m);

    a1[0]=n;
    a2[0]=m;
    for(int i=0;i<m*n;i++){
        count1[i]=0;
        count2[i]=0;
    }
    for(int i=0;i<n;i++){
        count1[a[i]-1]++;
    }
    for(int i=0;i<m;i++){
        count2[b[i]-1]++;
    }
    for(int i=1;i<m*n;i++){
        if(count1[i]>1||count2[i]>1)flag=false;
        a1[i]=a1[i-1]-count1[i-1];
        a2[i]=a2[i-1]-count2[i-1];
        //cout<<i<<" "<<a1[i]<<" "<<a2[i]<<endl;
    }

    if(a1[m*n-1]!=1||a2[m*n-1]!=1)flag=false;
    for(int i=m*n-1;i>-1;i--){
        if(count1[i]+count2[i]==2){
            kouho+=(a1[i]*a2[i]-a1[i+1]*a2[i+1]);
            a_kouho++;
            b_kouho++;
        }
        if(count1[i]==1&&count2[i]==0){
            kouho+=(a1[i]*a2[i]-a1[i+1]*a2[i+1]);
            b_kouho++;
            ans=(ans*a_kouho)%F;
        }
        if(count1[i]==0&&count2[i]==1){
            kouho+=(a1[i]*a2[i]-a1[i+1]*a2[i+1]);
            a_kouho++;
            ans=(ans*b_kouho)%F;
        }
        if(count1[i]+count2[i]==0){
            ans=(ans*kouho)%F;
        }
        //cout<<i<<" "<<ans<<endl;
        kouho--;
    }

    if(flag){
        cout<<ans<<endl;
    }
    else{
        cout<<0<<endl;
    }

    
}

Measured memory_bytes: 31488
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
typedef unsigned long long ull;


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

  cout << r*r << endl;
  
  return 0;
}




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

int main(void){
	int i,j=0;	
	string s;
	cin >> s;
	for(i=0,j=s.length()/2;i<s.length();i++){
		if(s[i]=='p') j--;
	}
	cout << j;
	return 0;
}

Measured memory_bytes: 760
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,k,n) for(int i = (k); i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) a.begin(), a.end()
#define MS(m,v) memset(m,v,sizeof(m))
#define D10 fixed<<setprecision(10)
typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
const int INF = 114514810;
const int MOD = 1000000007;
const double EPS = 1e-10;

typedef int weight;
struct edge
{
	int to; weight cost;
	bool operator < (const edge& e) const { return cost < e.cost; }
	bool operator >(const edge& e) const { return cost > e.cost; }
};

typedef vector<edge> Edges;
typedef vector<Edges> Graph;
//int dx[] = { -1, 0, 0, 1 }; int dy[] = { 0, -1, 1, 0 };
template<class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<class T> T &chmax(T &a, const T &b) { return a = max(a, b); }
bool valid(int x, int y, int h, int w) { return (x >= 0 && y >= 0 && x < h&&y < w); }
int place(int x, int y, int w) { return w*x + y; }
///*************************************************************************************///
///*************************************************************************************///
///*************************************************************************************///

int n, m, r;
int dl[201][201], ds[201][201], z[1001];
int dp[1001][201];

int solve(int i, int ship)
{
	if (i == r - 1) return 0;
	if (dp[i][ship] > 0) return dp[i][ship];
	int res = solve(i + 1, ship) + dl[z[i]][z[i + 1]];
	REP(j, n)
	{
		int sum = dl[z[i]][ship] + ds[ship][j] + dl[j][z[i+1]];
		chmin(res, solve(i + 1, j) + sum);
	}
	return dp[i][ship] = res;
}

int main()
{
	while (cin >> n >> m, n)
	{
		MS(dp, -1);
		REP(i, n)REP(j, n)
		{
			dl[i][j] = (i == j ? 0 : INF);
			ds[i][j] = (i == j ? 0 : INF);
		}
		REP(i, m)
		{
			int x, y, t; char c;
			cin >> x >> y >> t >> c;
			x--; y--;
			if (c == 'L') dl[x][y] = dl[y][x] = t;
			else ds[x][y] = ds[y][x] = t;
		}
		REP(k, n)REP(i, n)REP(j, n)
		{
			chmin(dl[i][j], dl[i][k] + dl[k][j]);
			chmin(ds[i][j], ds[i][k] + ds[k][j]);
		}
		cin >> r;
		REP(i, r)
		{
			cin >> z[i];
			z[i]--;
		}
		cout << solve(0, z[0]) << endl;
	}
	return 0;
}

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

struct UnionFind {
  vector<int> par;
  vector<int> rank;

  UnionFind(int N) : par(N), rank(N, 0) {
    for (int i = 0; i < N; i++) par[i] = i;
  }

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

  void unite(int x, int y) {
    int rx = root(x);
    int ry = root(y);

    if (rx == ry) return;
    par[rx] = ry;
    rank[ry] = rank[ry] + rank[rx] + 1;
  }

  bool same(int x, int y) {
    return root(x) == root(y);
  }
};

int main() {
  int n, m, k; cin >> n >> m >> k;
  UnionFind UF(n + 1);

  vector<vector<int>> connect(n + 1, vector<int>(0));
  for (int i = 0; i < m; i++) {
    int a, b; cin >> a >> b;
    if (b > a) swap(a, b);
    UF.unite(a, b);
    connect[a].emplace_back(b);
    connect[b].emplace_back(a);
  }

  vector<vector<int>> not_connect(n + 1, vector<int>(0));
  for (int i = 0; i < k; i++) {
    int c, d; cin >> c >> d;
    not_connect[c].emplace_back(d);
    not_connect[d].emplace_back(c);
  }

  vector<int> count(n + 1, 0);
  for (int i = 1; i < n + 1; i++) {
    int ans = UF.rank[UF.root(i)] - connect[i].size();
    for (auto &item : not_connect[i]) {
      if (UF.same(item, i)) ans--;
    }
    cout << ans << " ";
  }

  cout << endl;
}

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

typedef long long ll;

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

const int maxn = 1e6 + 5;
const int inf = 0x3f3f3f3f;

int n, m;
int x, y;

vector<int> g[maxn];
int dist[maxn];
bool viz[maxn];

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);  cout.tie(0);
  memset(dist, inf, sizeof dist);

  cin>>n>>m;
  for (int i=0; i<m; i++) {
    int u,v; cin>>u>>v;
    g[3*u].push_back(3*v+1);
    g[3*u+1].push_back(3*v+2);
    g[3*u+2].push_back(3*v);
  }

  cin>>x>>y;

  set<pair<int,int>> s;
  s.insert({0, 3*x});

  while (!s.empty()) {
    // for (auto x: s) {
    //   cout<<x.first<<" "<<x.second<<endl;
    // }
    // cout<<endl;

    
    auto cur = *s.begin();
    s.erase(s.begin());
    int d = cur.first;
    int at = cur.second;
    if (viz[at]) continue;
    dist[at] = min(dist[at], d);
    viz[at]=true;
    for (int to: g[at]) {
      if (viz[to]) continue;
      if (d+1 < dist[to]) {
	pair<int,int> tmp = {dist[to],to};
	if (s.count(tmp)) {
	  s.erase(tmp);
	}
	dist[to] = d+1;
	s.insert({d+1,to});
      }
    }
  }

  int ans = dist[3*y];
  if (ans == inf) {
    ans = -1;
  } else {
    ans = ans / 3;
  }
  cout<<ans<<endl;
  

  return 0;
}


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

#define FIO                     ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define mod                     1000000007
#define eps                     1e-9
#define setbits                 __builtin_popcount
#define gcd                     __gcd
#define rep(i,a,b)              for(int i=a;i<=b;i++)
#define repr(i,b,a)             for(int i=b;i>=a;i--)
#define forn(i,n)               for(int i=0;i<n;i++)
#define all(a)                  a.begin(), a.end()
#define in(a,b)                 ( (b).find(a) != (b).end())
#define pb                      push_back
#define fill(a,v)               memset(a, v, sizeof a)
#define endl                    "\n"
#define ff                      first
#define ss                      second
#define mp                      make_pair
#define minin(a)                *min_element (all(a))
#define maxin(a)                *max_element(all(a))
#define asort(c)                sort(all(c))
#define dsort(c)                sort(all(c), greater<int>()) 
#define PI                      3.14159265358979323846
#define int                     long long
typedef  vector<int>                 vi;
typedef  pair<int, int>              ii;
typedef  vector<ii>                 vii;
typedef  set<int>                    si;
typedef  map<int, int>              mii;
typedef  long double                 ld;


clock_t time_p=clock();
void timer()
{
    time_p=clock()-time_p;
    cerr<<"Execution Time: "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
}
int32_t main()
{
  FIO

  
  int n,k,ans=0;
  cin>>n>>k;
  int a[k]={0};
  rep(i,1,n)
  {
    a[i%k]++;
  }
  int m=a[0];
  if(k%2==0)
  {
    n=a[k/2];
    ans+=(n + (n*(n-1)*3)+ (n*(n-1)*(n-2)));
  }
 
  ans+=(m + (m*(m-1)*3) + (m*(m-1)*(m-2)));

  cout<<ans;
  
  timer();
  return 0;
}  

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
const int INF = 10000000;

int main()
{
    int H, W;
    cin >> H >> W;

    int dist[10][10];
    int min_dist[10][10];
    for (int i = 0; i <= 9; i++)
    {

        for (int j = 0; j <= 9; j++)
        {
            cin >> dist[i][j];
            min_dist[i][j] = INF;
            if (i == j)
            {
                min_dist[i][i] = 0;
            }
        }
    }

    for (int k = 0; k < 10; k++)
    {
        for (int i = 0; i < 10; i++)
        {
            for (int j = 0; j < 10; j++)
            {
                dist[i][j] = min(dist[i][k] + dist[k][j], dist[i][j]);
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            int isNumber;
            cin >> isNumber;
            if (isNumber != -1)
            {
                ans += dist[isNumber][1];
            }
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
n,m = map(int, input().split())
bmap = {0: 1}
ret = 0
b = 0
for a in list(map(int, input().split())):
    b += a
    r = b%m
    if r not in bmap:
        bmap[r] = 0
    bmap[r] += 1


for r in bmap.values():
    ret += r*(r-1)//2
print(ret)


Measured memory_bytes: 14480
#include <stdio.h>
int main(){

int i,a,b,j;
while(1){
    scanf("%d%d",&a,&b);
    if(a==0&&b==0){break;}
    for(i=1;i<=a;i++){
        for(j=1;j<=b;j++){
            if((!(i%2==0))&&(j%2==0)||(!(j%2==0))&&(i%2==0))printf(".");
            else printf("#");
        }printf("\n");
    }printf("\n");
}







return 0;}



Measured memory_bytes: 2076
#include<stdio.h>
#define N 100

int main()
{
  int i,j,A[N],minj,n,ch,count=0;

  scanf("%d",&n);

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

  for(i=0; i<n; i++){
    minj = i;
    for(j=i; j<n; j++){
      if(A[j] < A[minj]){
	minj = j;
      }
    }
    if(A[i] > A[minj]){
      count++;
    }
	ch = A[i];
	A[i] = A[minj];
	A[minj] = ch;
  }

  for(i=0; i<n-1; i++){
    printf("%d ",A[i]);
  }
  printf("%d\n",A[n-1]);
  printf("%d\n",count);
  return 0;
}



Measured memory_bytes: 2124
#include<map>
#include<iostream>
#include<deque>
#include<algorithm>
#include<string>
#include<cctype>
#include<iomanip>
#include<vector>
#include<queue>
 
using namespace std;
#define REP(i,b,e) for(ll i=(ll)b;i<(ll)e;i++)
#define rep0(i,n) REP(i,0ll,n)
#define rep1(i,n) REP(i,1ll,n+1)
 
#define shosu setprecision(10)
 
typedef long long ll;
typedef pair<int,int> P;
ll longinf=1ll<<60;
int inf=1<<29;
int dx[4]={1,-1,0,0};
int dy[4]={0,0,1,-1};

int N,Q,K;
ll c[100001];
bool v[100001];
deque<pair<ll,ll>> n[100001];
void dfs(ll node,ll d){
      while(n[node].size()){
            pair<ll,ll> next_p;
            next_p=n[node].front();
            n[node].pop_front();
            ll next_n=next_p.first;
            ll next_d=next_p.second;
            if(!v[next_n]){
                  v[next_n]=true;
                  c[next_n]=d+next_d;
                  dfs(next_n,c[next_n]);
            }
      }
}

int main (){
      cin>>N;
      rep0(i,N-1){
            ll a,b,c;
            cin>>a>>b>>c;
            n[a].push_back({b,c});
            n[b].push_back({a,c});
      }
      fill(v+1,v+N+1,false);
      cin>>Q>>K;
      v[K]=true;
      dfs(K,0);
      rep0(i,Q){
            ll x,y;
            cin>>x>>y;
            cout<<c[x]+c[y]<<endl;
      }
      
      return 0;
}


Measured memory_bytes: 74496
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var N = F;
		var A = GL;
		var B = GL;
		for (var i = 0; i < N; i++) A[i] -= B[i];
		var sum = 0L;
		var ans = 0;
		var pos = new List<int>();
		for (var i = 0; i < N; i++) if (A[i] < 0) { sum += A[i]; ans++; } else pos.Add(i);
		pos.Sort((x, y) => A[y].CompareTo(A[x]));
		if (sum >= 0) { WriteLine(0); return; }
		foreach (var i in pos)
		{
			sum += A[i];
			ans++;
			if (sum >= 0) { WriteLine(ans); return; }
		}
		WriteLine(-1);
	}
}


Measured memory_bytes: 32324
#include <cstdio>
#include <cstring>
#include <string>
#include <queue>
using namespace std;

int main(void)
{
	char str[2500];
	string word;
	queue <string> q;
	
	scanf("%[^\n]", str);
	
	int len = strlen(str);
	
	for (int i = 0; i < len; i++){
		if (str[i] != ' ' && str[i] != '.' && str[i] != ','){
			word += str[i];
//			printf("i %d <--> word %s\n", i, word.c_str());
		}
		else {
			if (3 <= word.size() && word.size() <= 6){
				q.push(word);
//				puts("ã¯ãã£ã");
			}
			word.clear();
		}
	}
	
	string res;
	while (q.size() != 1){
		res = q.front();
		q.pop();
		printf("%s ", res.c_str());
	}
	res = q.front();
	printf("%s\n", res.c_str());
	
	return (0);
}

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

int main(){
  string S;
  cin >> S;
  bool a = false;
  for(int i=0; i<S.size()-1; i++){
    if(S.at(i) == S.at(i+1)){
      a = true;
    }
  }
  if(a){
    cout << "Bad" << endl;
  }else{
    cout << "Good" << endl;
  } 
}

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

int N;

int dk(int i) {
	int ret;

	for (ret=0; i>0; ret++) {
		i/=10;
	}
	return ret;
}
		
int main(int argc, char *argv[]) {
	int sr;
	int ret=0;

	sr=scanf("%d", &N);

//printf("%d\n", dk(N));

// 1桁:9個
// 3桁:100～999: 900個
// 5桁:10000～99999: 90000個
	switch(dk(N)) {
	case 1: ret=N; break;
	case 2: ret=9; break;
	case 3: ret=909-999+N; break;
	case 4: ret=909; break;
	case 5: ret=90909-99999+N; break;
	case 6: ret=90909; break;
	}

	printf("%d\n", ret);
	fflush(stdout);

	return 0;

}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <iomanip>
#include <numeric>
#include <queue>
#include <cmath>
using namespace std;

int g(int start, int d) {
	vector<int> v1(10, 0), v2(10, 0);
	v1[start]++;
	for (int i = 2; i <= d; i++) {
		v2 = vector<int>(10, 0);
		for (int j = 0; j < 10; j++) {
			if (j > 0) v2[j] += v1[j - 1];
			v2[j] += v1[j];
			if (j < 9) v2[j] += v1[j + 1];
		}
		v1 = v2;
	}
	return accumulate(v1.begin(), v1.end(), 0);
}

string f(int n) {
	if (n < 10) {
		return string(1, '0' + n);
	}
	int c = 9;
	int start = 0;
	int digit = 0;
	for (int i = 2; ; i++) {
		bool flag = false;
		for (int j = 1; j < 10; j++) {
			int ret = g(j, i);
			if (c + ret >= n) {
				flag = true;
				start = j;
				break;
			}
			c += ret;
		}
		if (flag) {
			digit = i;
			break;
		}
	}
	string res(1, '0' + start);
	n -= c;
	while ((int)res.size() < digit) {
		if (res.back() > '0') {
			int ret = g(res.back() - '0' - 1, digit - res.size());
			if (ret >= n) {
				res.push_back(res.back() - 1);
				continue;
			} else {
				n -= ret;
				
			}
		}
		int ret = g(res.back() - '0', digit - res.size());
			if (ret >= n) {
				res.push_back(res.back());
				continue;
			} else {
				n -= ret;
				
			}
		ret = g(res.back() - '0' + 1, digit - res.size());
			if (ret >= n) {
				res.push_back(res.back() + 1);
				continue;
			} 
	}
	return res;
}

int main() {
	int k;
	cin >> k;
	cout << f(k) << endl;
}


Measured memory_bytes: 3456
import java.io.PrintWriter;
import java.util.*;

public class Main {
    int n;
    Edges[] g;
    long[] counter;

    void run() {
        Scanner sc = new Scanner(System.in);

        n = sc.nextInt();
        int q = sc.nextInt();
        g = new Edges[n];
        counter = new long[n];

        for (int i = 0; i < n; i++) {
            g[i] = new Edges();
        }

        for (int i = 0; i < n - 1; i++) {
            int a = sc.nextInt() - 1, b = sc.nextInt() - 1;
            g[a].add(b);
            g[b].add(a);
        }

        for (int i = 0; i < q; i++) {
            int p = sc.nextInt() - 1, x = sc.nextInt();
            counter[p] += x;
        }

        dfs(0, 0, new boolean[n]);

        PrintWriter out = new PrintWriter(System.out);
        out.print(counter[0]);
        for (int i = 1; i < n; i++) {
            out.print(" " + counter[i]);
        }
        out.println();
        out.flush();


    }

    void dfs(int idx, long cnt, boolean[] visited) {
        counter[idx] += cnt;
        visited[idx] = true;

        for (int next: g[idx]) if (!visited[next]) {
            dfs(next, counter[idx], visited);
        }
    }

    class Edges extends ArrayList<Integer> {}

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

    public static void main(String[] args) {
        new Main().run();
    }

}


Measured memory_bytes: 232016
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;

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

    static class TaskC {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
        /*
        Rating 1-399 : gray
        Rating 400-799 : brown
        Rating 800-1199 : green
        Rating 1200-1599 : cyan
        Rating 1600-1999 : blue
        Rating 2000-2399 : yellow
        Rating 2400-2799 : orange
        Rating 2800-3199 : red
         */
            Set<Integer> colors = new HashSet<>();
            int n = in.nextInt();
            int choosers = 0;
            for (int i = 0; i < n; i++) {
                int current = getColor(in.nextInt());
                if (current < 0) {
                    ++choosers;
                }
                else {
                    colors.add(current);
                }
            }
            out.printf("%d %d\n",
                       Math.max(colors.size(), 1),
                       colors.size() + choosers);
        }

        private int getColor(int score) {
            if (score < 400) {
                return 0;
            }
            else if (score < 800) {
                return 1;
            }
            else if (score < 1200) {
                return 2;
            }
            else if (score < 1600) {
                return 3;
            }
            else if (score < 2000) {
                return 4;
            }
            else if (score < 2400) {
                return 5;
            }
            else if (score < 2800) {
                return 6;
            }
            else if (score < 3200) {
                return 7;
            }
            else {
                return -1;
            }

        }

    }
}



Measured memory_bytes: 22996
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		String T = sc.next();
		char[] s = S.toCharArray();
		char[] t = T.toCharArray();
		int a = 0;
		sc.close();

		for (int i = 0; i < 3; i++) {
			if (s[i] == t[i]) {
				a++;
			}
		}
		System.out.println(a);
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int S,S1,S2;
  cin >> S;
  S1 = S/100;
  S2 = S - S1*100;
  
  if((S1 >= 1 && S1 <= 12) && (S2 >= 1 && S2 <= 12)){
    cout << "AMBIGUOUS" << endl;
  }else if(S1 >= 1 && S1 <= 12){
    cout << "MMYY" << endl;
  }else if(S2 >= 1 && S2 <= 12){
    cout << "YYMM" << endl;
  }else{
    cout << "NA" << endl;
  }  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define nl "\n"
#define pb push_back
#define pll pair<ll,ll>
#define ppll pair<ll,pll>
#define vll vector<ll>
#define vs vector<string>
#define vpll vector<pll>
#define vvll vector<vector<ll>>
#define vvpll vector<vpll>
#define mp make_pair
#define f first
#define s second
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define Test ll T;cin>>T; while(T--)
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL);
#define init(x,n,v) for(ll i=0;i<=n;i++) x[i]=v;
#define all(x) x.begin(),x.end()
#define pi 3.14159265358979323846
#define MOD 1000000007
#define MAX 2000000000000000000
#define MAXN 1000005
const ll infinity =1e18;
 
  ll dp[1002][1002];
   //ll ch[100][100005];      // initial declaration of array outside the main.
 string s[1002];

  



 int main(){

	//fast_io
	//Test{

	//}
	int h,w;
	cin>>h>>w;
     for(int i=0;i<h;i++){
     	cin>>s[i];
     }
    //base case
      dp[0][0]=1;



     //transition state
     for(int i=0;i<h;i++){
     	for(int j=0;j<w;j++)
     	{
     		if(s[i][j]=='#')
     			{dp[i][j]=0;
     		    continue;}

     			if(i>0)dp[i][j]+=dp[i-1][j];
     			 dp[i][j]%=MOD;
     			if(j>0)dp[i][j]+=dp[i][j-1];
     			 dp[i][j]%=MOD;
     		
     	}

      }
     //ans
     	cout<<dp[h-1][w-1];
       
       return 0;
}

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


int main() {
    int d;
    cin >> d;
    if(d == 22)cout << "Christmas Eve Eve Eve\n";
    else if(d == 23)cout << "Christmas Eve Eve\n";
    else if(d == 24)cout << "Christmas Eve\n";
    else cout << "Christmas\n";
    return 0;
}

/*
やっほい！
　　　　　　　やほほい！
　　　　+　　 　*
　　　 ∧∧　　. ∧∞∧　*
*　ヽ(=´ω｀)人(´ω｀*)ﾉ
　.～（ O x.） （ 　 O)～　+
。*　 　∪　　　　∪
*/

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;
using ll = long long;

#define REP(i, a) for (int i = 0; i < (a); ++i)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a)-1; i >= (b); --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define SIZE(obj) (int)(obj).sizeT()
#define YESNO(cond, yes, no) \
    { cout << ((cond) ? (yes) : (no)) << endl; }
#define SORT(list) sort(ALL((list)));
#define RSORT(list) sort((list).rbegin(), (list).rend())
#define ASSERT(cond, mes) assert(cond&& mes)

constexpr int MOD = 1'000'000'007;
constexpr int INF = 1'050'000'000;

template <typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

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

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

template <typename T>
istream& operator>>(istream& is, vector<T>& v) {
    REP(i, (int)v.size())
    is >> v[i];
    return is;
}

template <typename T>
T clamp(T& n, T a, T b) {
    if (n < a) n = a;
    if (n > b) n = b;
    return n;
}

template <typename T>
static T GCD(T u, T v) {
    T r;
    while (v != 0) {
        r = u % v;
        u = v;
        v = r;
    }
    return u;
}

template <typename T>
static T LCM(T u, T v) {
    return u / GCD(u, v) * v;
}

std::vector<int> enum_div(int n) {
    std::vector<int> ret;
    for (int i = 1; i * i <= n; ++i) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i != 1 && i * i != n) { ret.push_back(n / i); }
        }
    }
    return ret;
}

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

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

struct ToUpper {
    char operator()(char c) {
        return toupper(c);
    }
};

struct ToLower {
    char operator()(char c) {
        return tolower(c);
    }
};

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    int N;
    cin >> N;
    string S;
    cin >> S;
    int red = count(ALL(S), 'R');
    int blue = count(ALL(S), 'B');
    YESNO(red > blue, "Yes", "No");
    return 0;
}

Measured memory_bytes: 256
#include <stdlib.h>
#include<iostream>
#include<bits/stdc++.h>
#include<cmath>
#define ll long long
const int INF=0x3f3f3f3f;
#define mod 1000000007
using namespace std;
//priority_queue
int s[300];
int main()
{
int n;
cin>>n;
for(int i=1;i<=n;i++)
    s[i]=i;
int m;
cin>>m;
m--;for(int i=1;i<=n;i++)
s[i]+=m;
sort(s+1,s+1+n);
int sum=0;
int ma=s[1];
for(int i=1;i<=n;i++)
    { sum+=s[i];
        if(s[i]<=0)
            ma=max(ma,s[i]);}
cout<<sum-ma<<endl;

}



Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <set>
#include <cmath>
#include <cstdint>
#include <deque>
#include <algorithm>
#include <utility>
#include <unordered_map>

using namespace std;
int main() {
  int n;
  cin >> n;
  vector<uint64_t> from(n + 1);
  vector<uint64_t> to(n + 1);
  vector<uint64_t> weight(n + 1);
  for (int i = 1; i < n; i++) {
    cin >> from[i];
    cin >> to[i];
    cin >> weight[i];
  }
  int q, k;
  cin >> q >> k;
  vector<int> x(q);
  vector<int> y(q);
  for (int i = 0; i < q; i++) {
    cin >> x[i];
    cin >> y[i];
  }

  unordered_map<int, vector<pair<int, uint64_t>>> edges;
  for (int i = 0; i < n; ++i) {
    edges[from[i]].emplace_back(make_pair(to[i], weight[i]));
    edges[to[i]].emplace_back(make_pair(from[i], weight[i]));
  }

  vector<uint64_t> dist(n + 1);
  deque<pair<int, uint64_t>> queue;  // vertex, dist
  queue.push_back(make_pair(k, 0));  // starting point
  while (!queue.empty()) {
    auto start = queue.front();
    queue.pop_front();
    uint64_t current_dist = start.second;
    dist[start.first] = current_dist;

    auto edge = edges.find(start.first);
    for (auto& entry : edge->second) {
      if (dist[entry.first] == 0 && entry.first != k) {
        queue.push_back(make_pair(entry.first, current_dist + entry.second));
      }
    }
  }

  for (int i = 0; i < q; ++i) {
    cout << dist[x[i]] + dist[y[i]] << "\n";
  }
}


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

#include<boost/multi_array.hpp>
#include<boost/optional.hpp>
#include<boost/range/irange.hpp>
#include<boost/range/algorithm.hpp>
#include<boost/range/adaptors.hpp>
namespace adaptor = boost::adaptors;

// 多倍長テンプレ
/* ---------------------- ここから ---------------------- */
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;
/* ---------------------- ここまで ---------------------- */

using ll = long long;
using ull = unsigned long long;

const ll INF = 1LL << 60;

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; }

/*
	int N;
	std::cin >> N;
	std::vector<int> vec(N);
	for (auto& v : vec)
	{
		std::cin >> v;
	}
*/

ll a[100010];
ll b[100010];
ll c[100010];
ll dp[100010][3];

void Main()
{
	int N;
	cin >> N;

	for (int i = 0; i < N; ++i) {
		std::cin >> a[i] >> b[i] >> c[i];
	}

	for (int i = 0; i < 100010; ++i) {
		for (int j = 0; j < 3; ++j) {
			dp[i][j] = -1;
		}
	}

	dp[0][0] = a[0];
	dp[0][1] = b[0];
	dp[0][2] = c[0];
	for (int i = 0; i < N; ++i) {
		chmax(dp[i + 1][0], dp[i][1] + a[i + 1]);
		chmax(dp[i + 1][0], dp[i][2] + a[i + 1]);
		chmax(dp[i + 1][1], dp[i][0] + b[i + 1]);
		chmax(dp[i + 1][1], dp[i][2] + b[i + 1]);
		chmax(dp[i + 1][2], dp[i][0] + c[i + 1]);
		chmax(dp[i + 1][2], dp[i][1] + c[i + 1]);
	}

	cout << max(dp[N - 1][0], max(dp[N - 1][1], dp[N - 1][2]));
	return;
}

int main()
{
	std::cin.tie(nullptr);
	std::ios_base::sync_with_stdio(false);
	std::cout << std::fixed << std::setprecision(15);
	Main();
}

Measured memory_bytes: 8288
var output;
var input = require("fs").readFileSync("/dev/stdin", "utf8").trim().split("\n");
var obj = {
  "list" : input,
  "index" : 0,
  "max" : input.length,
  "next" : function(){
    if(!this.hasNext()){throw "NoSuchElementException:次に要素は無いよ";}
    var returnObj = this.list[this.index];
    this.index++;
    return returnObj;
  },
  "hasNext" : function(){return (this.index < this.max);}
}
Main();
function next(){return obj.next();}
function hasNext(){return obj.hasNext();}
function myout(t){console.log(t);}//standard output
function myerr(t){console.error(t);}//standard error
//[no]要素の扱い。数値型
//不明値、異常時:引数そのまま返す
//1:数値へ変換 2:半角SPで分割 4:半角SPで分割し、数値配列へ
//6:1文字に分割 7:1文字に分割し、数値配列へ
//8:半角SPで結合 9:改行で結合 0:文字なしで結合
function myconv(i,no){try{switch(no){case 1:return parseInt(i);case 2:return i.split(" ");case 4:return i.split(" ").map((a)=>Number(a));case 6:return i.split("");case 7:return i.split("").map((a)=>Number(a));case 8:return i.join(" ");case 9:return i.join("\n");case 0:return i.join("");default:return i;}}catch(e){return i;}}
function Main() {
  var s = myconv(next(),6);
  var list = {};
  for(var i = 0; i < s.length; i++){
    if(list[s[i]] == null){
       list[s[i]] = 1;
    }else{
       list[s[i]]++;
    }
  }
  var maxKeys = [];
  var max = 0;
  var keys = Array.from(Object.keys(list));
  if(keys.length == 1){
     myout(0);
    return;
  }
  
  var output = 107;
  for(var j = 0; j < keys.length; j++){
    var tmpKey = keys[j];
    var tmpS = Object.assign([],s);
    var count = 0;
  while(!check(tmpS,tmpKey)){
    for(var i = 0; i < tmpS.length; i++){
      if(tmpS[i+1] == tmpKey){
         tmpS[i] = tmpKey;
      }
    }
    tmpS.pop();
    count++;
  }
    output = Math.min(output,count);
  }
  myout(output);
}
function check(str,chr){
    var ret = true;
    for(var i = 0; i < str.length; i++){
      if(str[i] != chr){
         ret = false;
      }
    }
    return ret;
}


Measured memory_bytes: 32172
N = int(input())
A = list(map(int, input().split()))

X = [0]*N

for i in range(N//2):
    X[N-1] += -A[i*2] + A[i*2+1]
    if i==N//2-1:
        X[N-1] += A[N-1]

for i in range(N-2,-1,-1):
    X[i]=2*A[i]-X[i+1]
    
sX=["a"]*N
for i in range(N):
    sX[i]=str(X[i])

print(" ".join(sX))

Measured memory_bytes: 21272
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()
#define all(arr) arr.begin(), arr.end()

using namespace std;

void _cin() {}
template <class Head, class... Tail>
void _cin(Head&& head, Tail&&... tail) {
  cin >> head;
  _cin(forward<Tail>(tail)...);
}

#define Cin(T, ...) \
  T __VA_ARGS__;    \
  _cin(__VA_ARGS__)

int main() {
  Cin(string, s);

  bool ok = false;

  int c;
  for (; c < sz(s); ++c) {
    if (s.at(c) == 'C') {
      ok = true;
      break;
    }
  }
  if (!ok) {
    puts("No");
    return 0;
  }

  ok = false;
  int f;
  for (f = sz(s) - 1; f >= 0; --f) {
    if (s.at(f) == 'F') {
      ok = true;
      break;
    }
  }
  if (!ok) {
    puts("No");
    return 0;
  }

  if (!(c < f)) {
    puts("No");
    return 0;
  }

  puts("Yes");

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> a(N + 1);
  int c = 1, d = 0;
  for (int i = 0; i < N; i++) cin >> a.at(i);
  a.at(N) = 101;
  for (int i = 0; i < N; i++) {
    if (a.at(i) == a.at(i + 1)) {
      c++;
    }
    else {
      d += c / 2;
      c = 1;
    }
  }
  cout << d << endl;
}

Measured memory_bytes: 256
//dlang template---{{{
import std.stdio;
import std.conv;
import std.string;
import std.array;
import std.algorithm;
import std.typecons;
import std.math;
import std.range;

// MIT-License https://github.com/kurokoji/nephele
class Scanner
{
  import std.stdio : File, stdin;
  import std.conv : to;
  import std.array : split;
  import std.string;
  import std.traits : isSomeString;

  private File file;
  private char[][] str;
  private size_t idx;

  this(File file = stdin)
  {
    this.file = file;
    this.idx = 0;
  }

  this(StrType)(StrType s, File file = stdin) if (isSomeString!(StrType))
  {
    this.file = file;
    this.idx = 0;
    fromString(s);
  }

  private char[] next()
  {
    if (idx < str.length)
    {
      return str[idx++];
    }

    char[] s;
    while (s.length == 0)
    {
      s = file.readln.strip.to!(char[]);
    }

    str = s.split;
    idx = 0;

    return str[idx++];
  }

  T next(T)()
  {
    return next.to!(T);
  }

  T[] nextArray(T)(size_t len)
  {
    T[] ret = new T[len];

    foreach (ref c; ret)
    {
      c = next!(T);
    }

    return ret;
  }

  void scan()()
  {
  }

  void scan(T, S...)(ref T x, ref S args)
  {
    x = next!(T);
    scan(args);
  }

  void fromString(StrType)(StrType s) if (isSomeString!(StrType))
  {
    str ~= s.to!(char[]).strip.split;
  }
}

//Digit count---{{{
int DigitNum(int num) {
  int digit = 0;

  while (num != 0) {
    num /= 10;
    digit++;
  }

  return digit;
}
//}}}
//}}}

void main() {
  Scanner sc = new Scanner;

  int N;
  int A, B;

  sc.scan(N);
  sc.scan(A, B);

  int[] P = new int[N];
  int canA = 0;
  int canB = 0;
  int canC = 0;

  foreach (i; 0 .. N)
    sc.scan(P[i]);

  sort(P);

  foreach (i; 0 .. N) {
    if (P[i] <= A) {
      canA++;
    } else if (P[i] > A && P[i] <= B) {
      canB++;
    } else if (P[i] > B) {
      canC++;
    }
  }

  writeln(min(canA, canB, canC));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int INF = 1001001001;
const ll LINF = 1001001001001001001;
#define fori(i,a,b) for(int i=(a);i<(int)(b);i++)
#define repi(i,n) fori(i,0,n)
#define forr(i,a,b) for(int i=int(b-1);i>=int(a);i--)
#define repr(i,n) forr(i,0,n)
#define all(x) (x).begin(),(x).end()
#define fill(a,x) memset(a,x,sizeof(a))
#define pb push_back
#define mp make_pair
#define pcnt __builtin_popcount
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}

#define MAX 10010
vector<int> g[MAX];
int s[MAX],c[MAX];
int idx=0;
void dfs(int i,int p){
    s[i]=c[idx++];
    for(int x:g[i]){
        if(x==p)continue;
        dfs(x,i);
    }
}
void solve(){
    int n;
    cin>>n;
    repi(i,n-1){
        int a,b;
        cin>>a>>b;
        a--,b--;
        g[a].pb(b);
        g[b].pb(a);
    }
    repi(i,n)cin>>c[i];
    
    sort(c,c+n,greater<int>());
    dfs(0,-1);

    ll sum=0;
    fori(i,1,n)sum+=c[i];
    cout<<sum<<endl;
    repi(i,n){
        if(i>0)cout<<" ";
        cout<<s[i];
    }
    cout<<endl;
}

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


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
  string s;
  cin >> s;
  if (s.size() == 2) cout << s << endl;
  else {
    reverse(s.begin(), s.end());
    cout << s << endl;
  }
}

Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

def main():
    n = int(input())
    l = [int(i) for i in input().split()]
    sorted_l = sorted(l)

    counter = 0
    for i in range(n):
        counter += sorted_l[i * 2]
    print(counter)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
inf=10**9+1

n=int(input())
array_a=sorted([a for a in map(int, input().split())])+[inf]
array_b=sorted([a for a in map(int, input().split())])+[inf]
array_c=sorted([a for a in map(int, input().split())])

nums_b=[0 for _ in range(n)]
cur=0
for (idx,b) in enumerate(array_b[:-1]):
    while(array_a[cur]<b):
        cur+=1
    nums_b[idx]=cur


cur=0
res=0
for (idx,c) in enumerate(array_c):
    while(array_b[cur]<c):
        res+=nums_b[cur]*(n-idx)
        cur+=1
print(res)

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

int main() {
  int a, b, c, x, count , p, q, r;
  count = p = q = r = 0;
  
  while(1){
    cin >> a >> b >> c;
    if (a < b) {
      x = a;
      a = b;
      b = x;
    }
    if (b < c) {
      x = b;
      b = c;
      c = x;
    }
    if (a < b) {
      x = a;
      a = b;
      b = x;
    }
    
    if (b + c > a){
      if (b*b + c*c == a*a) {
        p++;
      } else if (b*b + c*c > a*a) {
        q++;
      } else {
        r++;
      }
      count++;
    } else {
      break;
    }
  }
  cout << count << " " << p << " " << q << " " << r << endl;
  
  return 0;
  
}


Measured memory_bytes: 3100
#!/usr/bin/env python
from __future__ import division, print_function

import os
import sys
from io import BytesIO, IOBase

if sys.version_info[0] < 3:
    from __builtin__ import xrange as range
    from future_builtins import ascii, filter, hex, map, oct, zip


def main():
    a, b, c = map(int, input().split())
    print(max(0, c - a + b))


# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


def print(*args, **kwargs):
    """Prints the values to a stream, or to sys.stdout by default."""
    sep, file = kwargs.pop("sep", " "), kwargs.pop("file", sys.stdout)
    at_start = True
    for x in args:
        if not at_start:
            file.write(sep)
        file.write(str(x))
        at_start = False
    file.write(kwargs.pop("end", "\n"))
    if kwargs.pop("flush", False):
        file.flush()


if sys.version_info[0] < 3:
    sys.stdin, sys.stdout = FastIO(sys.stdin), FastIO(sys.stdout)
else:
    sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)

input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()


Measured memory_bytes: 29292
#include <stdio.h>

int main(){
	int a, b;

	do{
		scanf("%d %d", &a, &b);
	}while(!(-1000 <= a || b <= 1000));

	if(a < b)
		puts("a < b");
	else if(a > b)
		puts("a > b");
	else
		puts("a == b");
	return 0;
}
	

Measured memory_bytes: 580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;


int main()
{	
	int n,k,sum=0;
	cin>>n>>k;
	vector<int>v(n);
	for(int i=0;i<n;i++)cin>>v[i];
	sort(v.begin(),v.end(),greater<int>());
	for(int i=0;i<k;i++)sum+=v[i];
	cout<<sum<<endl;
}

Measured memory_bytes: 256
//gauravsinghh
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long int
#define ld long double
#define db double
#define pii pair<int,int>
#define pll pair<long long,long long>
#define sii set<int>
#define sll set<long long>
#define vii vector<int> 
#define vll vector<long long>
#define mii map<int,int>
#define mll map<long long, long long>
#define lob lower_bound
#define upb upper_bound
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define pf pop_front
#define ins insert
#define mp make_pair
#define w(t) cin >> t;while(t--)
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define os cout<<" "
#define bitcount __builtin_popcount
#define gcd __gcd
#define endl "\n"
#define present(s,x) (s.find(x) != s.end()) 
#define cpresent(s,x) (find(all(s),x) != s.end()) 
#define ford(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++) 
#define fors(container, it, a, b) for(__typeof(container.begin()) it = a; it != b; it++) 
#define MOD 1000000007
#define EPSILON 1e-9
#define PI 3.14159265358979323846
#define inf 999999999999999999
#define siz 100005
#define fbo find_by_order
#define ook order_of_key
#define sz(s) (int)s.size()
#define mem(n,m) memset(n,m,sizeof(n))
#define rep(i,n) for(ll i = 0; i < n; i++)
#define ren(i,n) for(ll i = n-1; i >= 0; i--)
#define all(x) x.begin(),x.end()
#define fo(i, a, b) for(int i = a; i <= b; i++)
#define ffo(i, a, b) for(int i = a; i >= b; i--)
#define MAX 100005
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")

void io_set() {
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

bool comp(const pair < ll, ll >&a, const pair < ll, ll >&b){
    return ((a.ss < b.ss) || (a.ss == b.ss && a.ff < b.ff));
}

ll power(ll a, ll b){
    if(!b){
        return 1;
    }
    if(b&1){
        return (a * power(a*a , b/2));
    }
    return power(a*a , b/2);
}

signed main(){ 
    IOS
    //io_set();
    ll n, k;
    cin >> n >> k;
    ll x = power(k-1, n-1);
    cout << k*x << endl;
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e18+7;
int mod = 998244353;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
struct UnionFind {
    vector<int> par, size;
    UnionFind(int x) {
        par.resize(x);
        size.resize(x, 1);
        for(int i = 0; i < x; i++) {
            par[i] = i;
        }
    }
    int find(int x) {
        if (par[x] == x)
            return x;
        return par[x] = find(par[x]);
    }
    bool same(int x, int y) {
        return find(x) == find(y);
    }
    int consize(int x) {
        return size[find(x)];
    }
    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y)
            return;
        if (size[x] < size[y]) {
            par[x] = y;
            size[y] += size[x];
        }
         else {
            par[y] = x;
            size[x] += size[y];
        }
    }
};
int mod_pow(int x,int y) {
    int res = 1;
    while(y > 0) {
        if(y%2) {
            res = res*x%mod;
        }
        x = x*x%mod;
        y/=2;
    }
    return res;
}
int fac[2500], finv[2500], inv[2500];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < 2500; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}
int COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
int gcd(int X,int Y) {
    if(X%Y == 0) {
        return Y;
    }
    else {
        return gcd(Y,X%Y);
    }
}
signed main() {
    int N,K;
    cin >> N >> K;
    int mx = 0;
    int GCD = 0;
    for(int i = 0; i < N; i++) {
        int A;
        cin >> A;
        if(i == 0) {
            GCD = A;
        }
        mx = max(mx,A);
        GCD = gcd(GCD,A);
    }
    cout << ((mx >= K && (mx-K)%GCD == 0)?"POSSIBLE":"IMPOSSIBLE") << endl;
}


Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)


void solve(long long A, long long B){
    lint res = 0;
    lint a = min(A,B);
    lint b = max(A,B);
    if (a==b) res = b * 2;
    else res = b + (b-1);
    cout << res << endl;
}

int main(){

    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}



Measured memory_bytes: 256
// ref. https://tiramistercp.hatenablog.com/entry/abc145-f

import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;
import java.util.stream.LongStream;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = sc.nextInt();
    int[] H = new int[N + 2];
    for (int i = 1; i <= N; i++) {
      H[i] = sc.nextInt();
    }
    // [idx-lastSelected][0<=numDel<=K]
    long[][] dp = new long[N + 2][K + 1];
    IntStream.range(1, dp.length).forEach(i -> Arrays.fill(dp[i], Long.MAX_VALUE >> 1));

    for (int r = 1; r <= N + 1; r++) {
      for (int l = 0; l < r; l++) {
        int numSkip = r - l - 1; // Skip between (l, r)
        for (int k = 0; k + numSkip <= K && r > k + numSkip; k++) {
          dp[r][k + numSkip] = Math.min(dp[r][k + numSkip], dp[l][k] + cost(H[l], H[r]));
        }
      }
    }
    System.out.println(LongStream.of(dp[N + 1]).min().orElse(-1));
  }

  static long cost(long l, long r) {
    return Math.max(0, r - l);
  }
}


Measured memory_bytes: 28884