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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define BiSearchRangeNum(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y)

static const int MAX = 2e6+5;

class Heap {
  public:
    vector<int> data; // heap配列
    int last; // 最後尾のindex(要素数 - 1)
    Heap(int N) : data(N, (int)2e9 + 5) {
      last = -1;
    }
    void insert(int x) {
      // 最後尾に要素追加
      last += 1;
      data[last] = x;

      // 上へ辿りながら逆転を解消
      int i = last;
      while (i > 0) {
        if (data[(i - 1) / 2] > data[i]) {
          swap(data[(i - 1) / 2], data[i]);
          i = (i - 1) / 2;
        } else break; // 終了
      }
    }
    int pop() {
      // 根の要素を取り出す
      int root = data[0];

      // 最後尾を根に持ってくる
      data[0] = data[last];
      data[last] = 2e9+5;
      last -= 1;

      // 下へ辿りながら逆転を解消
      int i = 0;
      while (i < ((last + 1 ) / 2)) {
        // 親 > 左の子
        if (data[i] > data[2 * i + 1]) {
          // 右の子 < 左の子 ( < 親)
          if (data[i * 2 + 2] < data[i * 2 + 1]) {
            swap(data[i * 2 + 2], data[i]);
            i = i * 2 + 2; // 右の子に移動
          } else {
            swap(data[i * 2 + 1], data[i]);
            i = i * 2 + 1; // 左の子に移動
          }
        } else if (data[i] > data[i * 2 + 2]) { // (左 >= ) 親 > 右
          swap(data[i * 2 + 2], data[i]);
          i = i * 2 + 2;
        } else {
          break;
        }
      }

      return root;
    }
};

int main() {
  Heap heap(MAX);

  char s[10];
  int a;
  while(1) {
    scanf("%s", s);
    if (s[0] == 'e' && s[1] == 'n') {
      break;
    } else if (s[0] == 'e') {
      printf("%d\n", -heap.pop());
    } else {
      scanf("%d", &a);
      heap.insert(-a);
    }
  }
};



Measured memory_bytes: 10556
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A = 0;
  int N = 0;

  
  cin >> N >> A;

  if (N % 500 != 0){
	int r = 0;
    r = N % 500;
    if (r <= A){
    cout << "Yes" << endl;
    }
    else{
    cout << "No" << endl;
    }
  }
  else{
  cout << "Yes" << endl;
  }
}


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

class Main{
	public static void main(String args[]){
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		try {
			while(true){
				String strs[] = br.readLine().split(" ");
				int n = Integer.parseInt(strs[0]);
				int h = Integer.parseInt(strs[1]);
				if(n == 0) return;
				
				boolean xy[][] = new boolean[n][n];
				boolean xz[][] = new boolean[n][n];
				boolean yz[][] = new boolean[n][n];
				int answer = n * n * n;
				
				for(int i = 0; i < h; i++){
					strs = br.readLine().split(" ");
					int arg1 = Integer.parseInt(strs[1]) - 1;
					int arg2 = Integer.parseInt(strs[2]) - 1;
					if(strs[0].equals("xy")){
						// xy
						xy[arg1][arg2] = true;
						for(int j = 0; j < n; j++){
							if(xz[arg1][j]) continue;
							if(yz[arg2][j]) continue;
							answer--;
						}
					}else if(strs[0].equals("xz")){
						// xz
						xz[arg1][arg2] = true;
						for(int j = 0; j < n; j++){
							if(xy[arg1][j]) continue;
							if(yz[j][arg2]) continue;
							answer--;
						}
					}else{
						// yz
						yz[arg1][arg2] = true;
						for(int j = 0; j < n; j++){
							if(xy[j][arg1]) continue;
							if(xz[j][arg2]) continue;
							answer--;
						}
					}
				}
				
				System.out.println(answer);
			}
		} catch (Exception e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
		}
	}
	
	public static void printArray(int array[]){
		for(int i = 0; i < array.length; i++)
			System.out.print(array[i] + "\t");
		System.out.println();
	}

	public static void printArray(boolean array[]){
		for(int i = 0; i < array.length; i++)
			System.out.print(array[i] + "\t");
		System.out.println();
	}
	
	public static void printMatrix(int matrix[][]){
		for(int i = 0; i < matrix.length; i++){
			printArray(matrix[i]);
		}
	}
	
	public static void printMatrix(boolean matrix[][]){
		for(int i = 0; i < matrix.length; i++){
			printArray(matrix[i]);
		}
	}
}

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

using namespace std;
using ll =long long;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef pair<int,int> PII;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
using P = pair<int,int>;
//Write From this Line

int main()
{
	int n, m;
	cin >> n >> m;
	map<int,int> mp;
	rep(i,m){
		int a, b;
		cin >> a >> b;
		mp[a] ++;
		mp[b] ++;
	}
	for (auto x: mp){
		if(x.second % 2) {
			cout << "NO" << endl;
			return 0;
		}
	}
	cout << "YES" << endl;
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
int main()
{
    char s[1002];
    cin>>s;
    if(s[0]=='Y' and s[1]=='A' and s[2]=='K' and s[3]=='I')
        cout<<"Yes\n";
    else
        cout<<"No\n";
   return 0;
}


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

using namespace std;

typedef long long ll;

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
  
  ll n, m;
  cin >> n >> m;
  
  priority_queue<ll> pq;
  rep(i, n){
    ll x;
    cin >> x;
    pq.push(x);
  }
  
  rep(i, m){
    ll x = pq.top();
    pq.pop();
    pq.push(x / 2);
  }
  
  ll ans = 0;
  while(!pq.empty()){
    ans += pq.top();
    pq.pop();
  }
  
   cout << ans << endl;
}


Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
int main(){
	float n;
	int x1,x2;
  	cin>>n;
  	x1=n/1.08;
  	x2=(n+1)/1.08;
  	if(floor(x1*1.08)==floor(n))cout<<x1<<endl;
  	else if(floor(x2*1.08)==floor(n))cout<<x2<<endl;
  	else cout<<":(";
}

Measured memory_bytes: 384
#Atcoder Beginner Contest 121 B
N,M,C = map(int, input().split())
cnt = 0
b = list(map(int,input().split()))

for i in range(N):
    a = list(map(int,input().split()))
    sum = C
    for j in range(M):
        sum += a[j]*b[j]
    if sum > 0:
        cnt += 1
    else:
        pass

print(cnt)


Measured memory_bytes: 62224
import std.stdio;

void main() {
	int red, green, blue;
	int times;
	
	readf("%s %s %s\n", &red, &green, &blue);
	readf("%s", &times);

	foreach (i;0..times) {
		if (green <= red) {
			green *= 2;
		} else if (blue <= green) {
			blue *= 2;
		}
	}

	if (green > red && blue > green) {
		writeln("Yes");
	} else {
		writeln("No");
	}
}


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

using namespace std;

long long sum(int num)
{
  long long n = num;
  long long s = (n * (n + 1)) / 2;
  return s;
}

int main(void)
{
  string S;
  cin >> S;
  vector<int> bot;
  vector<int> top;
  bool up;
  if (S[0] == '<')
  {
    bot.push_back(0);
    up = true;
  }
  else
  {
    top.push_back(0);
    up = false;
  }
  for (int i = 1; i < S.length(); i++)
  {
    if (S[i] == '<')
    {
      if (up)
      {
        continue;
      }
      else
      {
        bot.push_back(i);
        up = true;
      }
    }
    else
    {
      if (up)
      {
        top.push_back(i);
        up = false;
      }
      else
      {
        continue;
      }
    }
  }
  if (S[S.length() - 1] == '<')
  {
    top.push_back(S.length());
  }
  else
  {
    bot.push_back(S.length());
  }
  long long result = 0;
  if (top[0] < bot[0])
  {
    result += sum(bot[0] - top[0]);
    top.erase(top.begin());
  }
  int last_t = top[top.size() - 1];
  int last_b = bot[bot.size() - 1];
  if (last_t > last_b)
  {
    result += sum(last_t - last_b);
  }
  for (int i = 0; i < bot.size() - 1; i++)
  {
    long long big = max(bot[i + 1] - top[i], top[i] - bot[i]);
    long long small = bot[i + 1] - bot[i] - big-1;
    result += (sum(big) + sum(small));
    //cout << bot[0] << " " << top[0] << " " << bot[1] << " " << big << " " << small << endl;
  }

  cout << result << endl;
}

Measured memory_bytes: 2048
#include <iostream>
#include <string>
#define REP(i,k,n) for(int(i)=(k);(i)<(n);(i)++)
using namespace std;

int gcd(int x, int y)
{
  if (x > y) return gcd(y,x);
  if (x == 0) return y;
  // else
  return gcd(y % x, x);
}

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

  string ans;

  if (C % gcd(A,B) == 0) ans = "YES";
  else ans = "NO";

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
using System;

namespace ConsoleApp16
{
    class Program
    {
        static void Main(string[] args)
        {
            int N;
            int T;
            String[] S = Console.ReadLine().Split(' ');
            N = int.Parse(S[0]);
            T = int.Parse(S[1]);

            var c = new int[N];
            var t = new int[N];

            bool Ans = false;
            int Cost = 1001;

            for(int i = 0;i < N ;i++)
            {
                String[] S1 = Console.ReadLine().Split(' ');
                c[i] = int.Parse(S1[0]);
                t[i] = int.Parse(S1[1]);

                if (t[i] <= T)
                {
                    Ans = true;
                        if (Cost > c[i])
                        {

                        Cost = c[i];

                        }

                }


            }
            if(Ans == true)
            {
                Console.WriteLine(Cost);
            }
            else
            {
                Console.WriteLine("TLE");
            }

        }
    }
}


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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeSearch(Node u, int k){
  while (u != NIL && k!= u->key){
    if(k < u->key) u= u->left;
    else u=u->right;
  }
  return u;

}



void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y



}

 void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!= NIL){
    y = x;
    if(z->key< x->key){
      x = x->left;
    }else{
      x = x->right;
    }
  }
  z->parent = y;
  if(y == NIL){
    root = z;
  }else{
    if(z->key < y->key){
      y->left = z;
    }
    else{
      y->right = z;
    }
  }
}








void inorder(Node u){
  if(u==NIL) return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);

}
void preorder(Node u){
  if(u==NIL) return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);

}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    }
    else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } 
  }

  return 0;
}


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

#define stirng string
#define vvi vector<vector<int>>
#define vi vector<int>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

const int inf = 1e9 + 7;

int main() {
  string s;
  cin >> s;
  int min = inf;
  for(int i=0;i+2<s.size();i++){
    int num = 0;
    num = (s[i]-'0')*100 + (s[i+1]-'0')*10 + (s[i+2]-'0');
    if(abs(num-753) < min){
      min = abs(num-753);
    }
  }
  cout << min << endl;
  return 0;
}


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

n = int(input())

s = [0] * n
for i in range(n):
    s[i] = input().strip()

import collections

counter = collections.Counter(s).most_common()

first = counter.pop(0)
answers = [first[0]]
value = first[1]

for c in counter:
    if c[1] != value:
        break
    answers.append(c[0])

answers = sorted(answers)
for a in answers:
    print(a)


Measured memory_bytes: 117516
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  vector<int>a(n);
  for(int i=0;i<n;i++)cin>>a[i];
  int t=0;
  for(int i=0;i<n;i++)t+=a[i];
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  if(a[m-1]*4*m<t)cout<<"No"<<endl;
  else cout<<"Yes"<<endl;
}


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

int H, W, N, M, p[100], q[100], x, y, dist[109][109][11]; vector<pair<int, int>> X[109][109];
int dy1[6] = { 0,0,-1,-1,1,1 }, dx1[6] = { -1,1,-1,0,-1,0 };
int dy2[6] = { 0,0,-1,-1,1,1 }, dx2[6] = { -1,1,0,1,0,1 };

int solve() {
	for (int i = 1; i <= H; i++) { for (int j = 1; j <= W; j++) { for (int k = 0; k <= N; k++) dist[i][j][k] = (1 << 30); } }
	for (int i = 0; i <= N; i++) {
		queue<pair<int, int>>Q;
		Q.push(make_pair(p[i], q[i])); dist[p[i]][q[i]][i] = 0;
		while (!Q.empty()) {
			int to1 = Q.front().first, to2 = Q.front().second; Q.pop();
			for (int j = 0; j < X[to1][to2].size(); j++) {
				int p1 = X[to1][to2][j].first, p2 = X[to1][to2][j].second;
				if (dist[p1][p2][i] > dist[to1][to2][i] + 1) {
					dist[p1][p2][i] = dist[to1][to2][i] + 1;
					Q.push(make_pair(p1, p2));
				}
			}
		}
	}
	int ans = 0;
	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			bool OK = true;
			for (int k = 1; k <= N; k++) {
				if (dist[i][j][0] >= dist[i][j][k]) OK = false;
			}
			if (OK == true) ans++;
		}
	}
	return ans;
}

int main() {
	while (true) {
		cin >> H >> W; if (H == 0) break;
		for (int i = 0; i < 109; i++) { for (int j = 0; j < 109; j++) X[i][j].clear(); }
		for (int i = 1; i <= H; i++) {
			for (int j = 1; j <= W; j++) {
				for (int k = 0; k < 6; k++) {
					int fx = i, fy = j;
					if (j % 2 == 1) { fx += dx1[k]; fy += dy1[k]; }
					if (j % 2 == 0) { fx += dx2[k]; fy += dy2[k]; }
					if (fx <= 0 || fy <= 0 || fx > H || fy > W) continue;
					X[i][j].push_back(make_pair(fx, fy));
				}
			}
		}
		cin >> N;
		for (int i = 1; i <= N; i++) { cin >> p[i] >> q[i]; }
		int ret = 0;
		cin >> M;
		for (int i = 1; i <= M; i++) {
			cin >> x >> y;
			p[0] = x; q[0] = y;
			ret = max(ret, solve());
		}
		cout << ret << endl;
	}
	return 0;
}


Measured memory_bytes: 3792
import sys
from math import ceil as C, floor as F, sqrt, gcd as G, factorial as FAC
from collections import defaultdict as D, Counter as CNT
from functools import reduce as R
import heapq as HQ

class Heap:
  def __init__(self, data, reverse=False):
    self.reverse = -1 if reverse else 1
    self.data = [self.reverse * d for d in data]
    HQ.heapify(self.data)
  def push(self, x): return HQ.heappush(self.data, self.reverse * x)
  def pop(self): return self.reverse * HQ.heappop(self.data) 

ALP = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
alp = 'abcdefghijklmnopqrstuvwxyz'
def _X(): return sys.stdin.readline().rstrip().split(' ')
def _S(ss): return tuple(ss) if len(ss) > 1 else ss[0]
def S(): return _S(_X())
def Ss(): return list(S())
def _I(ss): return tuple([int(s) for s in ss]) if isinstance(ss, tuple) else int(ss)
def I(): return _I(S())
def _Is(ss): return list(ss) if isinstance(ss, tuple) else [ss]
def Is(): return _Is(I())

def ncr(n, r): return FAC(n) // FAC(r) // FAC(n-r)

s = I()
max_buckets = s // 3
mod = 10 ** 9 + 7

ans = 0
for i in range(1, max_buckets+1):
    n = s - 3 * i
    ans += ncr(n+i-1, i-1)
    ans %= mod

print(ans)
    


Measured memory_bytes: 74792
#include<bits/stdc++.h>
using namespace std;
static const int MAX_N = 50;

int N, d;
int s = 0, square_s = 0, ans;

int main() {
  scanf("%d", &N);
  for (int i = 0; i < N; i++) {
    scanf("%d", &d);
    s += d;
    square_s += d * d;
  }

  ans = (s * s - square_s) / 2;
  printf("%d\n", ans);
  return 0;
}

Measured memory_bytes: 256
#include <iostream>

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

  for (int i = 1; i <= 100/0.08; ++i) {
    if (static_cast<int>(i * 0.08) == a && static_cast<int>(i * 0.1) == b) {
      std::cout << i << std::endl;
      return 0;
    }
  }

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

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define db double
#define pint pair<int,int>
#define mk(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define eb(x,y) emplace_back(x,y)
#define fi first
#define se second
#define Rep(x,y,z) for(int x=y;x<=z;x++)
#define Red(x,y,z) for(int x=y;x>=z;x--)
using namespace std;
const int MAXN=2e5+5;
char buf[1<<12],*pp1=buf,*pp2=buf,nc;int ny;
inline char gc() {return pp1==pp2&&(pp2=(pp1=buf)+fread(buf,1,1<<12,stdin),pp1==pp2)?EOF:*pp1++;}
//inline char gc(){return getchar();}
inline int read(){
	int x=0;for(ny=1;nc=gc(),(nc<48||nc>57)&&nc!=EOF;)if(nc==45)ny=-1;if(nc<0)return nc;
	for(x=nc-48;nc=gc(),47<nc&&nc<58&&nc!=EOF;x=(x<<3)+(x<<1)+(nc^48));return x*ny;
}
int a,b,c,x,y,top;
inline void exgcd(int a,int b,int&x,int&y){
	if(b==0){x=1,y=0;return;}
	exgcd(b,a%b,y,x),y-=a/b*x;
}
inline int inv(int x,int p){int a=0,b=0;exgcd(x,p,a,b);return (a%p+p)%p;}
struct Node{int x,y,c;}q[MAXN];
inline void work(int c,int d){
	q[top=0]=(Node){0,0,0};
	for(int x,a=1,b=0;d;){
		Node tmp=q[top];q[++top]=(Node){tmp.x+c/d*a,tmp.y+c/d*d,c/d};
		for(int t=1;t<=2&&d!=0;t++){if(t==1)b+=c/d*a;else a+=c/d*b;x=c%d,c=d,d=x;}
	}
}
inline ll F(ll x,ll y){return x<0?-1:x/y;}
int main(){
//	freopen("std.in","r",stdin);
//	freopen("std.out","w",stdout);
	for(int t=read();t--;){
		a=read(),x=read(),b=read(),y=read(),c=read();
		int g=__gcd(a,b);a/=g,b/=g,c/=__gcd(c,g);
		g=__gcd(a,c),a/=g,c/=g,y/=g,g=__gcd(b,c),b/=g,c/=g,x/=g;
		a%=c,b%=c;if(c==1){cout<<x+y<<'\n';continue;}int d=1ll*a*inv(b,c)%c;work(c,d);
		if(q[top].x!=c)q[++top]=(Node){c,c,1};int ans=0;
		Rep(i,1,top){
			int lx=q[i-1].x,rx=q[i].x,ly=c-q[i-1].y,ry=c-q[i].y,dx=(rx-lx)/q[i].c,dy=(ly-ry)/q[i].c,l=ans+1,r=x+y;
			while(l<=r){
				int mid=0ll+l+r>>1;ll s=F(x-1ll*mid*lx,dx),t=F(y-1ll*mid*ry,dy);
				if(s>=0&&t>=0&&s+t>=1ll*mid*q[i].c)ans=mid,l=mid+1;else r=mid-1;
			}
		}cout<<ans<<'\n';
	}
	return 0;
}




Measured memory_bytes: 3608
a,v = [int(x) for x in input().split(' ')]
b,w = [int(x) for x in input().split(' ')]
t = int(input())

if v == w:
    if b-a == 0:
        print('YES')
    else:
        print('NO')
elif w > v:
    if a==b:
        print('YES')
    else:
        print('NO')
else:
    if abs(b-a) / (v-w) <= t:
        print('YES')
    else:
        print('NO')

Measured memory_bytes: 9196
def main():
    k, s = map(int, input().split())
    # print(k, s)
    ans = 0
    for z in range(k+1):
        if z <= s:
            for y in range(k+1):
                x = s - z - y
                if 0 <= x and x <= s and x <= k:
                    ans += 1
    print(ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define pb push_back
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define db(x) (cerr << #x << ": " << (x) << '\n')
#define cps CLOCKS_PER_SEC
#define tests(t) int t; cin >> t; while(t--)
#define iceil(n, x) (((n) + (x) - 1) / (x))
#define ll long long
#define ld double
#define eb emplace_back
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define sz size()
#define all(v) (v).begin(), (v).end()
#define uni(v) sort(all(v)), (v).erase(unique(all(v)), (v).end())
#define fi first
#define se second
#define bitcount(x) __builtin_popcount(x)
#define PI acos(-1.0)
#define EPS 1e-9
#define mod 998244353
#define bit(x) (1 << x)
#define par pair<int,int>
#define maxn 400005

using namespace std;
///All indexing is 0-based
using namespace __gnu_pbds;
template<class key, class cmp = std::less<key>>
using ordered_set = tree<key, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
///methods: find_by_order(k); & order_of_key(k);
///To make it an ordered_multiset, use pairs of (value, time_of_insertion)
///to distinguish values which are similar

ll x,y,a,b,c,com,K,sol;
par A[maxn];

int main()
{
    #ifdef acm
    freopen("a.in","r",stdin);
    #endif // acm
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin >> x >> y >> a >> b >> c;

    for(int i=1;i<=a;i++)
        cin >> A[++K].fi  , A[K].se = 1;
    for(int i=1;i<=b;i++)
        cin >> A[++K].fi  , A[K].se = 2;
    for(int i=1;i<=c;i++)
        cin >> A[++K].fi  , A[K].se = 3;

    sort(A+1,A+1+K);

    for(int i=K;i>=1;i--)
    {
        if(com == x+y)
            break;
        if(A[i].se == 3)
            com++ , sol+=A[i].fi;
        if(A[i].se == 1 && x)
            x-- , sol+=A[i].fi;
        if(A[i].se == 2 && y)
            y-- , sol+=A[i].fi;
    }

    cout << sol;


}


Measured memory_bytes: 2688
from collections import deque
k = int(input())
Q = deque()
for i in range(1, 10):
  Q.append(i)

for _ in range(k-1):
  a = Q.popleft()
  d = a % 10
  if d != 0:
    Q.append(10 * a + d - 1)
  Q.append(10 * a + d)
  if d != 9:
    Q.append(10 * a + d + 1)

print(Q.popleft())

Measured memory_bytes: 40688
#include <iostream>
#include <math.h>
#include <numeric>
#include <vector>
#include <map>
#include <algorithm>
#include <queue>
#include <tuple>
#include <functional>

#define PI 3.14159265359
#define INF 1e9
#define LINF 1e18
#define irep(i,n) for(int  i = 0; i < n; i++)
#define irep2(i,a,n) for(int i = a; i < n; i++)
#define lrep(i,n) for(long long  i = 0; i < n; i++)
#define lrep2(i,a,n) for(long long i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl
typedef long long ll;

typedef std::vector<int> v_int;
typedef std::vector<std::vector<int> > v2_int;
typedef std::vector<ll> v_ll;
typedef std::vector<std::vector<ll> > v2_ll;

using namespace std;

int main() 
{
    int n; cin >> n;
    v_ll ans(n+4, 0);
    ans[0] = 2;
    ans[1] = 1;

    irep2(i, 2, n+1) {
        ans[i] = ans[i-1] + ans[i-2];
    }
    cout << ans[n] << endl;
    return 0;
}
    



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define ll long long
#define dd double
#define pb push_back
#define ff first
#define ss second
#define Mp make_pair
const ll Mod=1000000007;
const ll INF=999999999999999999;
const ll NN=(ll)(1e6+5);
int mod(string s,int a) 
{ 
    int ans=0; 
    for (int i=0;i<s.length();i++) 
         ans=(ans*10+(int)s[i]-'0')%a; 
    return ans; 
}
ll min(ll x,ll y){if(x<y) return x;return y;}
ll max(ll x,ll y){if(x>y) return x;return y;}
ll power(ll x,unsigned ll y) 
{ 
    if (y==0) 
        return 1; 
    else if (y%2==0) 
        return power(x,y/2)*power(x,y/2); 
    else
        return x*power(x,y/2)*power(x,y/2); 
}
ll hcf(ll a,ll b) 
{ 
    if(b==0) 
        return a; 
    return hcf(b,a%b);  
}
int main()
{
   fio;
   /*#ifndef ONLINE_JUDGE 
    	freopen("input.txt", "r", stdin); 
    	freopen("output.txt", "w", stdout); 
    	freopen("error.txt", "w", stderr); 
   #endif*/
   ll TT=1;
   //cin>>TT;
   while(TT--)
   { 
     ll n;
     cin>>n;
     cout<<(n/1000+(n%1000?1:0))*1000-n<<"\n";
   }
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#include <sstream>
#include <iomanip>
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define vi vector <ll> 
#define qu queue <ll>
#define min_3(a,b,c) min(a,min(b,c))
#define max_3(a,b,c) max(a,max(b,c))
#define nout(ans) cout << (ans) << "\n"
#define sout(ans) cout << (ans) << " "
using namespace std;

/*
Decimal Places: cout << fixed << setprecision(n) << ans << endl

String to integer:
stringstream dark(s);
int x = 0; dark >> x;
*/

bool compare(const pair<int, int>&i, const pair<int, int>&j)
{
    return i.second < j.second;
}


void solve()
{
    ll a, b, c, k; cin >> a >> b >> c >> k;
    if (a>=k) {
        nout(k);
    }
    else if (a+b>=k) {
        nout(a);
    }
    else {
        nout(a-(k-a-b));
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    int t = 1;
    //cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 3652
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include <iostream>
#include <algorithm>
#include <map>
#include <cmath>
#define INF 100000000000000
using namespace std;
typedef long long llong;

//int isalpha(char ch): ch がアルファベットなら true を返す
//int isdigit(char ch): ch が数字なら true を返す
//int islower(char ch): ch が小文字なら true を返す
//int isupper(char ch): ch が大文字なら true を返す
//int tolower(char ch): ch の小文字を返す
//int toupper(char ch): ch の大文字を返す

//string型
//size()	文字数を返す
//insert()	（指定した場所に）文字・文字列を挿入する
//erase()	（指定した場所の）文字・文字列を削除する
//clear()	すべての文字を削除する
//substr()	文字列の（指定した）部分文字列を返す
//replace()	（指定した）部分文字列を新しい文字列に置換する
//文字列の比較は、<=や==などを使え
//replace関数を使い、簡単に文字列を置換
//リバース関数：reverse(str.begin(), str.end());

//グラフ理論用変数
//vector<vector<llong> > graph(N);

int main(){
    llong a;
    cin >> a;
    cout << a+pow(a, 2)+pow(a, 3) << endl;
    return 0;
}

Measured memory_bytes: 3580
a_price, b_price, c_price, X, Y = list(map(int, input().split()))

a_num = X
b_num = Y

total_price_1 = 0
total_price_2 = 0
max_pizza = 0
diff = 0

if a_price + b_price < c_price * 2:
    total_price_1 = a_price * X + b_price * Y
    print(total_price_1)
else:
    if X > Y:
        total_price_1 = (c_price * 2) * X
    else:
        total_price_1 = (c_price * 2) * Y

    if X > Y:
        total_price_2 += (c_price * 2) * Y
        diff = X - Y
        total_price_2 += a_price * diff
    else:
        total_price_2 += (c_price * 2) * X
        diff = Y - X
        total_price_2 += b_price * diff

    # if a_num >= X and b_num >= Y:
    #     if diff > 0:
    #         total_price += a_price * diff
    #     elif diff < 0:
    #         total_price += b_price * abs(diff)

    # for i in range(diff):
    #     if X - Y > 0:
    #      if total_price_1 > total_price - (c_price * 2) * (i + 1) + a_price:
    #             total_price = total_price - (c_price * 2) + a_price
    #     elif diff < 0:
    #         if total_price > total_price - (c_price * 2) + b_price:
    #             total_price = total_price - (c_price * 2) + b_price
    print(min([total_price_1, total_price_2]))

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

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

  vector<vector<int>> G(N);
  for (int i = 0; i < N - 1; i++)
  {
    int x, y; cin >> x >> y;
    x--; y--;
    G[x].push_back(y);
  }

  vector<int> x(N);
  for (int i = 0; i < Q; i++)
  {
    int p, cost; cin >> p >> cost; p--;
    x[p] += cost;
  }

  vector<int> bfs(N, -1);
  queue<int> q;

  bfs[0] = x[0];
  q.push(0);

  while (!q.empty()) {
    int v = q.front();
    q.pop();

    for (int nv : G[v]) {
      if (bfs[nv] != -1) continue;
      bfs[nv] = bfs[v] + x[nv];
      q.push(nv);
    }
  }

  for (int i = 0; i < N; i++)
  {
    cout << bfs[i] << " ";
  }
}

Measured memory_bytes: 14848
#include<iostream>
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=2;i<=(n);i++)
using namespace std;
const int mod=1000000007;
int main()
{
int N;
long A,B;
cin >> N >> A >> B;
int x[N];
long ans=0;

rep(i,N)
{
	cin >> x[i];
	
}
rep(i,N)
{
	if(i==0){continue;}
   ans+=min(B, (x[i]-x[i-1])*A );
}

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

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

using namespace std;
typedef long long lint;

#define RPT(i, b, e) for (int i = ((int)b); i <= ((int)e); i++)
#define RPT0(i, n) RPT(i, 0, ((int)n) - 1)
#define RPT1(i, n) RPT(i, 1, (n))
#define EACH(it, v) for (const auto& it : v)
#define ALL(v) v.begin(), v.end()

typedef struct _que {
    int a;
    int b;
    int c;
    int d;
} que;

void resolve()
{
    int N, M, Q;
    cin >> N >> M >> Q;
    vector<que> qq(Q);
    RPT0(i, Q) cin >> qq[i].a >> qq[i].b >> qq[i].c >> qq[i].d;

    vector<int> A(N);

    lint max_score = 0;
    RPT(a, 1, M)
    {
        A[0] = a;
        RPT(b, a, M)
        {
            A[1] = b;
            RPT(c, b, M)
            {
                if (N >= 3) A[2] = c;
                RPT(d, c, M)
                {
                    if (N >= 4) A[3] = d;
                    RPT(e, d, M)
                    {
                        if (N >= 5) A[4] = e;
                        RPT(f, e, M)
                        {
                            if (N >= 6) A[5] = f;
                            RPT(g, f, M)
                            {
                                if (N >= 7) A[6] = g;
                                RPT(h, g, M)
                                {
                                    if (N >= 8) A[7] = h;
                                    RPT(i, h, M)
                                    {
                                        if (N >= 9) A[8] = i;
                                        RPT(j, i, M)
                                        {
                                            if (N >= 10) A[9] = j;
                                            lint total = 0;
                                            RPT0(z, Q)
                                            total += (A[qq[z].b - 1] -
                                                          A[qq[z].a - 1] ==
                                                      qq[z].c)
                                                         ? qq[z].d
                                                         : 0;
                                            max_score = max(max_score, total);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }

    cout << max_score << endl;
}

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

/*
#include <chrono>
int main()
{
    chrono::system_clock::time_point start, end;
    start = chrono::system_clock::now();

    resolve();

    end = chrono::system_clock::now();
    double time = static_cast<double>(
        chrono::duration_cast<chrono::microseconds>(end - start).count() /
        1000.0);
    cout << "resolve(): " << time << "[ms]" << endl;

    return 0;
}
*/


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n,i,j,count=0;
cin>>n;
int a[n];
for(i=1;i<=n;i++)
{
cin>>a[i-1];
if(i%2==1&&a[i-1]%2==1)
count++;
}
cout<<count;
}


Measured memory_bytes: 3616
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

int main(void)
{
	string S;
	cin >> S;
	map<char, int>mp;
	for (char c : S) {
		mp[c]++;
	}
	int ans = 0;
	for (auto p : mp) {
		if (p.second % 2)++ans;
	}
	cout << ans / 2 << endl;
	return 0;
}



Measured memory_bytes: 3228
#include <vector>
#include <set>
#include <map>
#include <string>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <ctime>
using namespace std;

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie();
    
    int x;
    cin >> x;
    if(x < 1200) {
        cout << "ABC";
    } else if(x < 2800) {
        cout << "ARC";
    } else cout << "AGC";
}

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

// http://judge.u-aizu.ac.jp/onlinejudge/review.jsp


public class Test
{
	public static void Main()
	{
		  string[] str1 = Console.ReadLine().Split(' ');
		  int n = int.Parse(str1[0]); 

		  int[] a = new int[n];
		  for(int i=0; i<n; i++) {
			string[] str2 = Console.ReadLine().Split(' ');
			a[i] = int.Parse(str2[0]); 
		}
		
		  //Console.WriteLine("改行あり N = {0} P = {1} Ai = {2}", n, p, a);
		  Console.Write(calc(n,a));

	}

  public static string calc(int n,int[] a) {
	  int c0 = 0;
	  int c1 = 0;
	  int c2 = 0;
	  int c3 = 0;
	  int ca = 0;
	  
	  List<int> la = new List<int>();
	  
	  for(int i=0; i<n; i++){
	  	if(a[i]==0) c0++;
	  	if(a[i]==1) c1++;
	  	if(a[i]==2) c2++;
	  	if(a[i]==3) c3++;
	  	if(4<=a[i]) {
			ca++;
			la.Add(a[i]);
		}
	  }
	  la.Sort();
	  
	  List<int> ret = new List<int>();
	  if(c0==0 && c1==0){
		//
	  } else if(c0==0 && 0<c1){
		ret.AddRange(Enumerable.Repeat<int>(1, c1));
	  } else if(0<c0 && c1==0){
		if(c0%2==0) { 
			ret.AddRange(Enumerable.Repeat<int>(0, c0));
		} else { 
			ret.AddRange(Enumerable.Repeat<int>(0, 1));
			if(0<c2) {
				ret.Add(2);
				c2--;
			} else if(0<c3) {
				ret.Add(3);
				c3--;
			} else {
				if(0<la.Count) {
					ret.Add(la[0]);
					la.RemoveAt(0);
				}
			}
			ret.AddRange(Enumerable.Repeat<int>(0, c0-1));
		}
		
	  } else {
		if(c0%2==0) { 
			ret.AddRange(Enumerable.Repeat<int>(1, c1));
			ret.AddRange(Enumerable.Repeat<int>(0, c0));
		} else { 
			ret.AddRange(Enumerable.Repeat<int>(1, c1-1));
			ret.Add(0);
			ret.Add(1);
			ret.AddRange(Enumerable.Repeat<int>(0, c0-1));
		}
	  }

	  if(ca==0 && 0<c2 && c3==1) {
	  	ret.Add(2);
	  	ret.Add(3);
		c2--;
		c3--;
	  }
	  
	  
	  
	  la.Reverse();
	  ret.AddRange(la);
	  ret.AddRange(Enumerable.Repeat<int>(3, c3));
	  ret.AddRange(Enumerable.Repeat<int>(2, c2));
	  string sret = "";
	  foreach(int i in ret) sret = i.ToString() + Environment.NewLine + sret;

	  return sret;
  }
  
  
  
  

}



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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

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

  int a, b;
  cin >> a >> b;
  if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
    cout << "Possible" << endl;
  } else {
    cout << "Impossible" << endl;
  }
}

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

using namespace std;

long long h, w;

int main(void)
{
	scanf("%lld %lld", &h, &w);
	
	if(h == 1 || w == 1)
	{
		printf("1");
		return 0;
	}
	
	if(h % 2 == 1 && w % 2 == 1)
		printf("%lld", (h * w) / 2 + 1);
	else
		printf("%lld", (h * w) / 2);
		
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int n[45000],t[4],i;
	
	for(i=0;i<4;i++){
		scanf("%d%d",&t[i],&n[i]);
		if(t[i]==1){
			t[i]=6000;
		}else if(t[i]==2){
			t[i]=4000;
		}else if(t[i]==3){
			t[i]=3000;
		}else{
			t[i]=2000;
		}
		printf("%d\n",t[i]*n[i]);
	}
	
return 0;
}

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

using namespace std;

#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))
#define OUT(P) cout << (P) << endl
#define OUT2(P1, P2) cout << (P1) << " " << (P2) << endl

int main() {
    int n, i;

    cin >> n >> i;
    cout << n + 1 - i << endl;

    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<set>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define mp make_pair
using namespace std;
set<int>s; int n, k;
signed main() {
	cin >> n; for1(i, n) { cin >> k; s.insert(k); }cout << s.size() << endl;
}


Measured memory_bytes: 7700
from collections import deque
H, W =  map(int, input().split())
S=[]
for _ in range(H):
    S.append(input())
vx = [1, 0, -1, 0]
vy = [0, 1, 0, -1]
ans = 0

def func(si, sj):
    queue = deque([si, sj])  
    seen = [[-1]*W for _ in range(H)]
    seen[si][sj] = 0
    while queue:
        x = queue.popleft()
        y = queue.popleft()
        
        for i in range(4):
            nx = x + vx[i]
            ny = y + vy[i]
            if nx<0 or nx>=H or ny<0 or ny>=W:
                continue
            if S[nx][ny]=="#" or seen[nx][ny]>=0:
                continue
            seen[nx][ny]=seen[x][y]+1
            queue.append(nx)
            queue.append(ny)
    return seen[x][y]
    
ans = 0
for i in range(H):
    for j in range(W):
        if S[i][j]==".":
            ans = max(ans, func(i, j))
print(ans)

Measured memory_bytes: 74632
s = gets.chomp
n = s.length

ans = 0
(1 << (n - 1)).times do |mask|
  expr = []
  (0...n).each do |i|
    if (mask & (1 << i)).zero? then
      expr += [s[i]]
    else
      expr += [s[i], "+"]
    end
  end
  ans += eval(expr.join)
end
puts ans


Measured memory_bytes: 1916
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<string>


using namespace std;
typedef long long ll;
typedef pair<int, int> pr;
const int maxn = 3e5;
const int inf = 0x3f3f3f3f;


int main() {
	ll k, n;
	while (~scanf("%lld %lld", &k, &n)) {
		if (k * 500 >= n) printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
const int mod = 1000000007;

int main() {
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    if (s[0] == 'S') {
        if (s[1] == 'S') {
            if (s[2] == 'S') cout << 0;
            else cout << 1;
        } else {
            if (s[2] == 'S') cout << 1;
            else cout << 2;
        }
    } else {
        if (s[1] == 'S') {
            if (s[2] == 'S') cout << 1;
            else cout << 1;
        } else {
            if (s[2] == 'S') cout << 2;
            else cout << 3;
        }
    }
}


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

int main() {
  int E, Y;
  cin >> E >> Y;

  if (E == 0) {
    if (Y <= 1911) cout << 'M' << Y - 1868 + 1 << endl;
    else if (Y <= 1925) cout << 'T' << Y - 1912 + 1 << endl;
    else if (Y <= 1988) cout << 'S' << Y - 1926 + 1 << endl;
    else cout << 'H' << Y - 1989 + 1 << endl;
  } else {
    if (E == 1) cout << 1868 + Y - 1 << endl;
    else if (E == 2) cout << 1912 + Y - 1 << endl;
    else if (E == 3) cout << 1926 + Y - 1 << endl;
    else cout << 1989 + Y - 1 << endl;
  }

  return 0;
}


Measured memory_bytes: 3108
import java.io.InputStream;
import java.io.PrintStream;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;
import java.util.stream.IntStream;

public class Main {

  public static void main(String[] args) {
    resolve(System.in, System.out);
  }

  static void resolve(InputStream is, PrintStream pw) {
    Scanner sc = new Scanner(is);
    int n = Integer.parseInt(sc.next());
    List<Integer> difficulties = IntStream.range(0, n).mapToObj(i -> Integer.valueOf(sc.next()))
      .sorted().collect(Collectors.toList());
    int ans =
      difficulties.get(difficulties.size() / 2) - difficulties.get(difficulties.size() / 2 - 1);
    pw.println(ans);
  }
}


Measured memory_bytes: 50748
N = int(input())
ans = float('inf')
for i in range(1,int(N**0.5) + 1):
    tmp = N / i
    if tmp.is_integer():
        if tmp == N:
            tmp_ans = N - 1
        else:
            tmp_ans = int(tmp) + i - 2
        if ans > tmp_ans:
            ans = tmp_ans
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

int N;
void input(){
    fast_io();
    cin >> N;
}

vector< ll > prime_table(int n) {
  vector<ll> p_num(n+1,0);
  // vector< bool > prime(n + 1, true);
  // if(n >= 0) prime[0] = false;
  // if(n >= 1) prime[1] = false;
  for(int i = 2; i <= n; i++) {
    // if(!prime[i]) continue;
    for(int j = i + i; j <= n; j += i) {
      // prime[j] = false;
      p_num[j]++;
    }
  }
  return p_num;
}


int solve(){
    ll ans = 1LL;
    auto p_num = prime_table(N);
    for (ll i = 2; i <= N; i++)
    {
      ans += (p_num[i]+2)*i;
    }
    cout << ans << endl;
    
    return 0;
}   

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

Measured memory_bytes: 81304
n = int(input())
l = list(input().split())
l1 = [int(i) for i in l]
ans = 1
mod = 10**9+7
ch = [0]*3
for i in range(n):
  if l1[i] in ch:
    ans = ans * ch.count(l1[i]) % mod
    
    k = ch.index(l1[i])
    ch[k] += 1
    
  else:
    print(0)
    exit()
    
print(ans)

Measured memory_bytes: 13924
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
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;
}

bool is_kaibun(string S) {
    bool flag = true;
    REP(i, S.size()/2) {
        if(S[i] != S[S.size() - 1 - i]) {
            flag = false;
            break;
        }
    }
    return flag;
}

int main() {
    double l;
    cin >> l;
    cout << fixed << l * l * l / 27 << endl;
}


Measured memory_bytes: 256
#define _LIBCPP_DEBUG 0

#include<bits/stdc++.h>

using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;

vector<int> ans(100000+1,0);
vector<int> vec(100000+1,0);

bool isprime(int x){

    if(x<2) return false;
    else if(x==2) return true;
    if(x%2==0) return false;
    for (int i = 3; i*i <= x; i+=2) {
        if(x%i==0) return false;
    }
    return true;
}


int main(void) {

    int Q; cin>>Q;

    vec[1] = 0;
    vec[2] = 1;
    vec[3] = 2;
    for (int i = 4; i <= 100000+1; ++i) {
        if(isprime(i)){
            vec[i] = vec[i-1]+1;
        }else{
            vec[i] = vec[i-1];
        }
    }

    for (int i = 1; i <= 100000+1; ++i) {
        if((vec[i]-vec[i-1]>0) && (vec[(i+1)/2]-vec[(i+1)/2-1]>0)){
            ans[i] = ans[i-1]+1;
        }else{
            ans[i] = ans[i-1];
        }
    }

    for (int i = 1; i <= Q; ++i) {
        int l,r; cin>>l>>r;
        cout<<ans[r]-ans[l-1]<<endl;
    }


}

Measured memory_bytes: 1408
from collections import defaultdict

n, k, q = map(int, input().split())
a = defaultdict(int)

for _ in range(q):
    a_i = int(input())
    a[a_i] += 1

res = ['Yes'] * n


for i in range(1, n+1):
    if i in a:
        if k - q + a[i] <= 0:
            res[i-1] = 'No'
        else:
            res[i-1] = 'Yes'
    else:
        if k - q <= 0:
            res[i-1] = 'No'
        else:
            res[i-1] = 'Yes'

for boo in res:
    print(boo)


Measured memory_bytes: 10016
#include <bits/stdc++.h>
    
        using namespace std;
    
        #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
        #define FOR(i,a,b) for(int i = (a); i < (b); i++)
        #define rep(i,n) FOR(i,0,n)
        #define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)
        #define ITER(it,a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
        #define FILL(a,value) memset(a, value, sizeof(a))
    
        #define SZ(a) (int)a.size()
        #define ALL(a) a.begin(),a.end()
        #define PB push_back
        #define MP make_pair
        #define in insert
        #define er erase
        #define fs first
        #define sc second
    
    
        typedef long long LL;
        typedef vector<int> VI;
    
        typedef vector<bool> VB;
        typedef vector<LL> VL;
        typedef pair<int,int> PII;
        typedef pair<LL,LL> PLL;
        typedef vector<PII> VPI;
        typedef vector<VL>VVL;
        typedef vector<VI>VVI;
        typedef vector<string>VS;
    
        typedef vector<vector<PII>> VVPI;
        typedef vector<vector<PLL>> VVPL;
    
    
    
        const double PI = acos(-1.0);
        const int INF = 1000 * 1000 * 1000 + 7;
        const LL LINF = INF * (LL)INF;
    
        const int MAX = 305;
    
        const int MAS = 1e5 + 10 ;
        const int MOD = 1000 * 1000 * 1000 + 7;
        const double EPS = 1e-8;
        vector<vector<int >> g(MAS);
    
        vector<int>tin(MAS),fup(MAS);
        vector<vector<int >> up ;
        vector<vector<int> > g1(MAS);
    
    
        int main() {
            ios_base::sync_with_stdio(false);
            cin.tie(NULL);
            //  freopen("skateboard.in","r",stdin);
            //  freopen("skateboard.out","w",stdout);
            int n;
            cin >> n;
            vector<vector<int >> can(n, vector<int>(n));
            rep(i, n)
            {
                rep(j,n)
                {
                    cin >> can[i][j] ;
                }
            }
            vector<int> dp(1  << n );
            dp[0] = 1;
            for(int msk = 0 ; msk < (1 << n ) -1 ; msk ++)
            {
                int a = __builtin_popcount(msk);
                rep(b,n)
                {
                    if(can[a][b] && !(msk & (1 << b)))
                    {
                        int newmsk = msk ^(1 << b);
                        dp[newmsk] +=dp[msk];
                        dp[newmsk]%=MOD;
                    }
                }
            }
            cout <<dp[(1 << n ) - 1];
    
        }

Measured memory_bytes: 13952
import math

A,B,H,M = map(int, input().split())

angle_M = M*(360/60)
angle_H = H*(360/12)+angle_M/12

delta = min(abs(angle_H-angle_M),360-abs(angle_H-angle_M))

dist = math.sqrt(A*A + B*B -2*A*B*math.cos(math.radians(delta)))

print(dist)

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

public class Main {

    public static void main(String[] args) {
        // ABC067B - Snake Toy

        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();   // 1 <= k <=n <= 50
        int k = sc.nextInt();
        int[] l = new int[n];

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

        Arrays.sort(l);

        int max = 0;
        for (int i = n - 1; i >= n - k; i--) {
            max += l[i];
        }

        System.out.println(max);
    }

}

Measured memory_bytes: 21844
N = int(input())

H = [list(map(int, input().split())) for _ in range(N)]

for cx in range(101):
    for cy in range(101):
        needH = -1
        for x, y, h in H:
            if h > 0:
                tmp = h+abs(x-cx)+abs(y-cy)
                if needH == -1:
                    needH = tmp
                else:
                    if needH != tmp:
                        needH = -2
                        break
        if needH == -2:
            continue
        f = 1
        for x, y, h in H:
            if h == 0:
                if max(needH-abs(x-cx)-abs(y-cy), 0) != 0:
                    f = 0
                    break
        if f:
            print(cx, cy, needH)
            exit()

Measured memory_bytes: 3064