akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
using namespace std;
int main()
{
    int n, wm; cin >> n >> wm;
    vector<int> v(n);
    vector<int> w(n);
    for (int i = 0; i < n; i++)
    {
        cin >> v[i] >> w[i];
    }
    vector< vector<int> > dp(n+1, vector<int>(wm+1, 0));
    for (int i = 0; i < n; i++)
    {
        for (int wi = 0; wi <= wm; wi++)
        {
            if (wi >= w[i])
                dp[i+1][wi] = max(dp[i][wi - w[i]] + v[i], dp[i][wi]);
            else
                dp[i+1][wi] = dp[i][wi];
        }
    }
    cout << dp[n][wm] << endl;
    return 0;
}


Measured memory_bytes: 6840
import java.util.*;
class Main{
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        double a = scanner.nextDouble();
        double b = scanner.nextDouble();
        double h = scanner.nextDouble(); //* Math.PI / 180; //短針
        double m = scanner.nextDouble(); //* Math.PI / 180; //長針
        double hx = h * 30 + 0.5 * m;
        double mx = m * 6;
        double diff = Math.abs(hx-mx);
        System.out.println(Math.sqrt(Math.pow(a,2)+Math.pow(b,2)-2*a*b*Math.cos(Math.toRadians(diff))));
    }
}



Measured memory_bytes: 37460
X = int(input())
X_0 = int(X**0.5)
X_list = []
for i in range(1, X_0 + 1):
    if X%i == 0:
        X_list.append(i)

flag = False
ans = 0
for x in X_list:
    y = X/x
    y1 = y**0.5
    y2 = int(y**0.5)
    for A in range(x, y2+1):
        if A**5 - (A-x)**5 == X:
            flag = True
            ans = (A, A-x)
            break
if flag:
    print(ans[0], ans[1])
else:
    for x in X_list:
        for B in range(1, x+1):
            if (x-B)**5 + B**5 == X:
                flag = True
                ans = (x-B, -B)
    if flag:
        print(ans[0], ans[1])

Measured memory_bytes: 9428
#include<stdio.h>

int main(){
  int N;
  scanf("%d", &N);
  int V[N];
  int C[N];
  for(int i = 0; i < N; i++){
    scanf("%d", &V[i]);
  }
  
  for(int i = 0; i < N; i++){
    scanf("%d", &C[i]);
  }
  
  int X_Y = 0;
  for(int i = 0; i < N; i++){
    if(V[i] > C[i])
      X_Y += V[i] - C[i];
  }
  
  printf("%d\n", X_Y);
  
  return 0;
}

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

int main() {
	string s;
	cin >> s;
	string ans = "Yes";
	int n = s.size();
	rep(i, (n - 1)/2) {
		if (s[i] != s[n - i - 1] || s[i] != s[(n - 1)/2 - i - 1] || s[i] != s[(n - 1)/2 + i + 1]){
			ans = "No";
			break;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3564
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <map>
#define rep(i,n) Rep(i,0,n)
#define Rep(i,k,n) for(int i=k ; i<n ; i++)
#define rep1(i,n) for(int i=1 ; i<=n ; i++)
#define vi vector<int>
#define vii vector<int,int>
#define Sort(v) sort(v.begin(),v.end())
#define Reverse(v) reverse(v.begin(),v.end())

//const int MOD = 1000000007;
const int INF = 1<<30;
using namespace std;

string yn(bool x){
    return x ? "Yes" : "No";
}

bool check(int x){
    int a[5];
    rep(i,5){
        a[i] = x%10;
        x /=10;
    }
    
    if(a[0] == a[4] and a[1] == a[3]) return 1;
    else return 0;
}

int main(){
    int a,b ; cin >> a >> b;
    
    int ans = 0;
    for(int i=a ; i<=b ; i++){
        ans += check(i);
    }
    
    cout << ans << endl;
    

}







Measured memory_bytes: 256
import sys
#import time
from collections import deque, Counter, defaultdict
#from fractions import gcd
import bisect
import heapq
#import math
import itertools
import numpy as np
input = sys.stdin.readline
sys.setrecursionlimit(10**8)
inf = 10**18
MOD = 1000000007
ri = lambda : int(input())
rs = lambda : input().strip()
rl = lambda : list(map(int, input().split()))

s = ri()
dp = [1]*max(4,(s+1))
for i in range(3):
    dp[i]=0
dp[3]=1
#[0,0,1,1,1,2,3,]
#a[i] = a[i-3]+...+a[0]
#     = a[i-3]+a[i-1]
for i in range(4,s+1):#3-7
    dp[i] = dp[i-3]+dp[i-1]

print(dp[s]%MOD)

Measured memory_bytes: 26812
#include <bits/stdc++.h>
#define endl '\n'
#define fastIO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define trace1(x)                cout<<#x<<": "<<x<<endl
#define trace2(x, y)             cout<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cout<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cout<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define pb push_back
#define ff first
#define ss second
#define all(v) (v).begin(), (v).end()
#define mod (int)(1e9+7)
using namespace std;

int gcd(int a, int b){
    return b == 0 ? a : gcd(b, a%b);
}
int lcm(int a, int b){
    return (a*b)/gcd(a,b);
}
int pow1(int x, unsigned int y) { 
    int temp; 
    if( y == 0) 
        return 1; 
    temp = pow1(x, y/2); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return ((x*temp)%mod*(temp)%mod)%mod; 
} 
int inv_mod(int a){
    int res = 1;
    int mod_temp = mod-2;
    while(mod_temp){
        if(mod_temp&1){
            res = ((res%mod)*(a%mod))%mod;
        }
        a = ((a%mod)*(a%mod))%mod;
        mod_temp >>= 1;
    }
    return res%mod;
}
int ncr(int n, int k){
    int res = 1;
    if ( k > n - k )
        k = n - k;

    for (int i = 0; i < k; ++i){
        res = ((res%mod)*((n - i)%mod))%mod;
        res = ((res%mod)*(inv_mod(i + 1)%mod))%mod;
    }
    return res%mod;
}
int fibonacci(int n){
    double phi = (1LL + sqrt(5))/(double)2;
    int nth_fib = round(pow(phi,n)/sqrt(5));
    return nth_fib;
}

signed main(){

    fastIO

    int n, a, b;
    cin >> n >> a >> b;

    int withab = pow1(2, n) - 1;
    int nca = ncr(n, a), ncb = ncr(n, b);
    int ans = (withab - nca + mod)%mod;
    ans = (ans - ncb + mod)%mod;
    cout << ans << endl; 
    


    return 0;
}

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

int main()
{
  int W, H, x, y, r;
  cin >> W >> H >> x >> y >> r;

  int top, bottom, right, left;
  top = y + r;
  bottom = y - r;
  right = x + r;
  left = x - r;

  if (top > H || bottom < 0 || right > W || left < 0)
  {
    cout << "No" << endl;
  }
  else
  {
    cout << "Yes" << endl;
  }

  return 0;
}



Measured memory_bytes: 3112
#include <algorithm>
#include <iostream>
#define int long long
using namespace std;
const int maxn = 100 + 10;
int n,m,a[maxn][maxn],b[maxn][maxn];
inline int Abs(int x) { return x < 0 ? -x : x; }
bool f[maxn][maxn][80*81];
signed main() {
	cin >> n >> m;
    for (int i = 1;i <= n;i++)
    	for (int j = 1;j <= m;j++) cin >> a[i][j];
    for (int i = 1;i <= n;i++)
    	for (int j = 1;j <= m;j++) cin >> b[i][j];
    f[1][1][Abs(a[1][1]-b[1][1])] = true;
    f[1][1][Abs(b[1][1]-a[1][1])] = true;
    for (int i = 1;i <= n;i++)
    	for (int j = 1;j <= m;j++) {
    		for (int k = 0;k <= 80*80;k++) {
				if (i > 1 && f[i-1][j][k]) {
					f[i][j][abs(k+a[i][j]-b[i][j])] = true;
					f[i][j][abs(k-a[i][j]+b[i][j])] = true;
				}
				if (j > 1 && f[i][j-1][k]) {
					f[i][j][abs(k+a[i][j]-b[i][j])] = true;
					f[i][j][abs(k-a[i][j]+b[i][j])] = true;
				}
			}
		}
	for (int i = 0;i <= 80*80;i++)
		if (f[n][m][i]) {
			printf("%d",i);
			return 0;
		}
    return 0;
}

Measured memory_bytes: 56576
#include <stdio.h>
int main(void)
{
    int N;
    int A;
    int B;
    scanf("%d",&N);
    scanf("%d",&A);
    scanf("%d",&B);
    if(B<N*A) printf("%d\n",B);
    if(B>=N*A) printf("%d\n",N*A);
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int n;
main ()
{
  cin >> n;
  vector<int>a(n);
  for(int i = 0; i < n; i++){ cin >>a[i]; a[i]-= i;}
  sort(a.begin(),a.end());
  long ans = 0;
  for(int i = 0; i < n;i++) ans += abs(a[i] - a[n / 2]);
  cout << ans << endl;
}


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

const int inf = 1e9 + 33;

void chmin (int &x, int y) {
    x = min(x, y);
}

signed main () {
    int n;
    cin >> n;
    vector < int > nines(10), sixes(10);
    nines[0] = sixes[0] = 1;
    for (int i = 1; i < 10; ++i) {
        nines[i] = 9 * nines[i - 1];
        sixes[i] = 6 * sixes[i - 1];
    }
    vector < int > dp(n + 1, inf);
    dp[0] = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < 10; ++j) {
            if (i + nines[j] <= n)
                chmin(dp[i + nines[j]], dp[i] + 1);
        }
        for (int j = 0; j < 10; ++j) {
            if (i + sixes[j] <= n)
                chmin(dp[i + sixes[j]], dp[i] + 1);
        }
    }
    cout << dp[n] << '\n';
}


Measured memory_bytes: 640
package main
import (
   "fmt"
   "os"
   "bufio"
   "strconv"
)
var sc = bufio.NewScanner(os.Stdin)

func main() {
  sc.Split(bufio.ScanWords)
  first := nextInt()
  second := nextInt()
  third := nextInt()
  if first < second && second < third {
    fmt.Println("Yes");
  }else {
    fmt.Println("No");
  }
}


func nextInt() (int) {
    sc.Scan()
    v, e := strconv.Atoi(sc.Text())
    if e != nil { panic(e) }
    return v
}


Measured memory_bytes: 1088
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    int[] d = new int[6];
    int i, q, a, b;
    for(i = 0;i < 6;i++)d[i] = sc.nextInt();
    for(q = sc.nextInt();q-- > 0;out.println(solve(d, a, b))){
      a = sc.nextInt(); b = sc.nextInt();
    }

    sc.close();
  }
  private static int solve(int[] d, int a, int b){
    int i, j;
    for(i = 0;i < 3;i++){
      for(j = 0;j < 4;j++){
        if(d[0] == a && d[1] == b)return d[2];
        rroll(d);
      }
      if(d[0] == a && d[1] == b)return d[2];
      nroll(d);
      for(j = 0;j < 4;j++){
        if(d[0] == a && d[1] == b)return d[2];
        rroll(d);
      }
      if(d[0] == a && d[1] == b)return d[2];
      eroll(d);
    }
    return -1;
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
  private static void nroll(int[] dice){ //(1265)
    int tmp;
    tmp = dice[0]; dice[0] = dice[1]; dice[1] = dice[5];
    dice[5] = dice[4]; dice[4] = tmp;
    return;
  }
  private static void eroll(int[] dice){ //(1463)
    int tmp;
    tmp = dice[0]; dice[0] = dice[3]; dice[3] = dice[5];
    dice[5] = dice[2]; dice[2] = tmp;
    return;
  }
  private static void rroll(int[] dice){ //(2354)
    int tmp;
    tmp = dice[1]; dice[1] = dice[2]; dice[2] = dice[4];
    dice[4] = dice[3]; dice[3] = tmp;
    return;
  }
}

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

int main(){
  int N;
  bool f = 0;
  cin >> N;
  for(int i=0;i<N;i++)
    if((N - 4 * i) % 7 == 0&& 0 <= N - 4 * i  ){
      cout << "Yes" << endl;
      f = 1;
  	  break;
    }
  if(!f)
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <iostream>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

int main() {
    int a[3];
    cin >> a[0] >> a[1] >> a[2];
    sort(a, &a[3]);
    int x = a[0];
    int y = a[1];
    int z = a[2];

    if (x % 2 == y % 2 && y % 2 == z % 2) {
        cout << (z - x + z - y) / 2 << endl;
    } else if (x % 2 == y % 2) {
        cout << (z - 1 - x + z - 1 - y) / 2 + 1 << endl;
    } else if (x % 2 == z % 2) {
        cout << (z - x + z + 1 - y) / 2 + 1 << endl;
    } else {
        cout << (z + 1 - x + z - y) / 2 + 1 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define SORT(a) sort((a).begin(), (a).end())
#define RSORT(a) reverse((a).begin(), (a).end())
#define rep(i, n) for (int i = 0; i < n; i++)
typedef long long ll;
const long long INF = 1LL << 60;
// const int INF=1010101010;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;

const int MAX = 2200;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
  fac[0] = fac[1] = 1;
  finv[0] = finv[1] = 1;
  inv[1] = 1;
  for (int i = 2; i < MAX; 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;
  }
}

// 二項係数計算
long long 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 main() {
  int n, k;
  cin >> n >> k;
  COMinit();
  for (int i = 1; i <= k; i++) {
    cout << (COM(n - k + 1, i) * COM(k - 1, i - 1)) % MOD << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
  int n;
  cin>>n;
  string s[n];
  for(int i=0;i<n;i++) cin>>s[i];
  string t;
  cin>>t;
  int a=0,b=0;
  for(int i=0;i<n;i++){
    string u[2],v[2];
    u[0]=u[1]=s[i];
    v[0]=v[1]=t;
    for(int j=0;j<(int)s[i].size();j++)
      if(s[i][j]=='?') u[0][j]='a';
    for(int j=0;j<(int)t.size();j++)
      if(t[j]=='?') v[0][j]='z';
    for(int j=0;j<(int)s[i].size();j++)
      if(s[i][j]=='?') u[1][j]='z';
    for(int j=0;j<(int)t.size();j++)
      if(t[j]=='?') v[1][j]='a';
    if(u[0].compare(v[0])>0) b++;
    if(v[1].compare(u[1])>0) a++;
    
    /*
    bool f=0;
    for(int j=0;j<(int)min(s[i].size(),t.size());j++){
      if(s[i][j]=='?'||t[j]=='?'){
	f=1;
	break;
      }
      if(s[i][j]==t[j]) continue;
      if(s[i][j]<t[j]) a++;
      if(s[i][j]>t[j]) b++;
      f=1;
      break;
    }
    if(!f){
      if(s[i].size()<t.size()) a++;
      if(s[i].size()>t.size()) b++; 
    }
    */
  }
  //cout<<a<<b<<endl;
  for(int i=a+1;i<=n+1-b;i++) cout<<i<<" \n"[i==n+1-b];
  return 0;
}


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

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

    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        for (int j = i + 1; j < n; j++)
        {
            ans += a[i] * a[j];
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 3636
#                         _
#                        | |
#   ___ _   _ _ __  _   _| | _____
#  / __| | | | '_ \| | | | |/ / _ \
#  \__ \ |_| | | | | |_| |   <  __/
#  |___/\__,_|_| |_|\__,_|_|\_\___|
#
#
a, b = map(int, input().split())
if a < b:
    print(0)
else:
    print(10)










#        _           _              _       _
#       | |         | |            | |     (_)
#    ___| |__   ___ | | ___   _  __| | __ _ _
#   / __| '_ \ / _ \| |/ / | | |/ _` |/ _` | |
#  | (__| | | | (_) |   <| |_| | (_| | (_| | |
#   \___|_| |_|\___/|_|\_\\__,_|\__,_|\__,_|_|
#
#


Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <limits>

using namespace std;


int main(int argc, char** argv){
    int a, b, c, d, e, k;
    cin >> a >> b >> c >> d >> e >> k;
    bool flag = true;
    if (b-a>k) flag = false;
    if (c-a>k) flag = false;
    if (d-a>k) flag = false;
    if (e-a>k) flag = false;
    if (c-b>k) flag = false;
    if (d-b>k) flag = false;
    if (e-b>k) flag = false;
    if (d-c>k) flag = false;
    if (e-c>k) flag = false;
    if (e-d>k) flag = false;

    if (flag == true)  cout << "Yay!\n";
    if (flag == false) cout << ":(\n";

    return 0;
}


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

ll dp[101][100*100+1];
//dp[i][j]:iこ目を使って価値がjのときの最小値
ll v[100],w[100];

int main()
{
	int N,W;
	cin >> N >> W;
	for(int i = 0;i<N;i++)
	{
		cin >> v[i] >> w[i];
	}

	for(int i = 0;i<N+1;i++)
	{
		for(int j = 0;j<N*100+1;j++)
		{
			dp[i][j] = 2*1e9;
		}
	}
	for(int i = 0;i<N+1;i++)
	{
		dp[i][0] = 0;
	}

	for(int i = 0;i<N;i++)
	{
		for(int j = 0;j<=N*100;j++)
		{
			if(j-v[i]>=0)
			dp[i+1][j] = min(dp[i][j],dp[i][j-v[i]]+w[i]);
			else
			{
				dp[i+1][j] = dp[i][j];
			}
		}
	}
	int ans = 0;
	for(int i = 0;i<=N*100;i++)
	{
		if(dp[N][i]<=W)ans = i;
	}
	cout<<ans<<endl;
	
}


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

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, m;
	cin >> n;
	map<string, int> a, b;
	for (int i = 0; i < n; i++)
	{
		string s;
		cin >> s;
		a[s]++;
	}
	cin >> n;

	int ans = 0;
	for (int i = 0; i < n; i++)
	{
		string s;
		cin >> s;
		b[s]++;
	}
	for (map<string, int>::iterator it = a.begin(); it != a.end(); it++)
		ans = max(ans, it->second - b[it->first]);
	cout << ans << endl;
	return 0;
}


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

using namespace std;

char *p;
int a, b, c, d;
string s;

int solve(){
    if(*p == 'a'){
        ++p; return a;
    }
    if(*p == 'b'){
        ++p; return b;
    }
    if(*p == 'c'){
        ++p; return c;
    }
    if(*p == 'd'){
        ++p; return d;
    }
    ++p; // [
    char op = *p; ++p;
    int x = solve();
    int y = solve();
    ++p; //]
    if(op == '+') return x | y;
    if(op == '*') return x & y;
    if(op == '^') return x ^ y;
}



int calc(int v){
    a = v/1000;
    b = v / 100 % 10;
    c = v / 10 % 10;
    d = v%10;
    p = &s[0];
    return solve();
}


int main(){
    while(cin >> s, s != "."){
        int v;
        cin >> v;
        int h = calc(v);
        int c = 0;
        for(int i = 0; i < 10000; ++i){
            if(h == calc(i)) c++;
        }
        cout << h << " " << c << endl;
    }
}




Measured memory_bytes: 3188
using System;
namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            var s = Console.ReadLine().Trim();
            Func<string, bool> func = str =>
            {
                if (str.Length == 1) return true;
                for (var i = 0; i < str.Length / 2; i++)
                    if (str[i] != str[str.Length - 1 - i])
                        return false;
                return true;
            };

            var n = s.Length;
            Console.WriteLine(func(s) && func(s.Substring(0, ((n - 1) / 2))) ? "Yes" : "No");
        }
    }
}


Measured memory_bytes: 13140
function main(input){
  var args = input.split(' ');
  const N = parseInt(args[0],10);
  const A = parseInt(args[1],10);
  const B = parseInt(args[2],10);
  var num = 0;
  for(var i=1; i<=N; i++){
    var sum = 0;
    var str = i.toString().split('').forEach(function(value){
      var x = parseInt(value,10);
      sum += x;
    });
    if((sum >= A) && (sum<=B)){
      num += i;
    }
  }
  console.log(num);
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

bool prime[100005];
int ans[100005];

void find_primes () {
    for (int i = 2; i < 100005; ++i)
        prime[i] = 1;
    for (int i = 2; i < 100005; ++i) {
        if (prime[i]) {
            for (int64_t j = int64_t(i) * int64_t(i); j < 100005; j += i)
                prime[j] = 0;
        }
    }
}

void ansify () {
    for (int i = 1; i < 100005; i += 2) 
        ans[i] = ans[max(i - 2, 0)] + int(prime[i] && prime[(i + 1) / 2]);
}

signed main () {
    find_primes();
    ansify();
    
    int q;
    cin >> q;
    for (int i = 0; i < q; ++i) {
        int l, r;
        cin >> l >> r;
        cout << ans[r] - ans[max(l - 2, 0)] << '\n';
    }
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
#define MOD 1000000007
#define INT long long int
#define REP(i,n) for(int(i)=0;(i)<(n);(i)++) 
using namespace std;
const long long INF = numeric_limits<long long>::max();


int main()
{
    string S;
    cin >> S;
    bool nwse[4];
    REP(i,4)nwse[i] = false;
    REP(i,S.size()){
        if (S[i] == 'N') nwse[0]=true;
        if (S[i] == 'W') nwse[1]=true;
        if (S[i] == 'S') nwse[2]=true;
        if (S[i] == 'E') nwse[3]=true;
    }
    if (nwse[0] == nwse[2] && nwse[1] == nwse[3]){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int64_t INF = 1LL << 60;

int main() {
  int N,K,Q;
  cin>>N>>K>>Q;
  vector<int>A(Q);
  vector<int>k(N+1);
  for(int i=0;i<Q;i++){
    cin>>A[i];
    k[A[i]]++;
  }
  for(int i=1;i<=N;i++){
    if(k[i]+K-Q>0){cout<<"Yes"<<endl;}
    else{cout<<"No"<<endl;}
  }
  
  return 0;}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
const int MOD = (int)1e9 + 7;
using ll = long long;
int N, K;
 
ll dp[2002][2002];	// dp(n, k) = chosing k objects out of n
unsigned long long ans;
 
inline ll add (ll a, ll b) { return ((a%MOD) + (b%MOD))%MOD;}
inline ll mul (ll a, ll b) { return ((a%MOD)*(b%MOD))%MOD;}
void solve () {
	for (int k = 0; k <= K; k++)
		dp[0][k] = 0;
	for (int n = 0; n <= N; n++) 
		dp[n][0] = 1;
	for (int n = 1; n <= N; n++) {
		for (int k = 1; k <= K; k++) {
			dp[n][k] = add(dp[n - 1][k], dp[n - 1][k - 1]);
		}
	}
	return;
}
 
int main () {
	cin >> N >> K;
	solve();
	for (int i = 1; i <= K; i++) {
		ans = mul(dp[K - 1][i - 1], dp[N - K + 1][i]);
		cout << ans << "\n";
	}
	return 0;
}

Measured memory_bytes: 31488
fun main(args: Array<String>) {
    val (k, a, b) = readLongArray()

    if (a + 2 >= b) {
        println(k + 1)
    } else {
        val count = Math.max(0, (k - (a - 1)) / 2)
        val remain = k - (count * 2 + (a - 1))
        val ans = if (k >= (a - 1) + 2) a + count * (b - a) + remain else k + 1
        println(ans)
    }
}

fun readInteger() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerArray() = readStringList().map(String::toInt).toIntArray()
fun readLongArray() = readStringList().map(String::toLong).toLongArray()


Measured memory_bytes: 37988
import java.util.*;
import java.io.*;

public class Main{
	public static void solve(int n){
		int[][] ans = new int[n][n];
		int[] now = new int[2];
		now[0] = (n+1)/2;
		now[1] = (n-1)/2;
		for(int i = 1; i <= n*n; i++){
			if( now[0] > n-1 ){
				now[0] = 0;
			}
			if( now[1] < 0 ){
				now[1] = n-1;
			}
			if( now[1] > n-1 ){
				now[1] = 0;
			}
			if( ans[now[0]][now[1]] != 0 ){
				now[0]++;
				now[1]--;
				i--;
				continue;
			} else {
				ans[now[0]][now[1]] = i;
				now[0]++;
				now[1]++;
			}
		}
		for(int[] x : ans){
			for(int y : x){
				System.out.printf("%4d", y);
			}
			System.out.println();
		}
	}
	
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		while( n != 0 ){
			solve(n);
			n = stdIn.nextInt();
		}
	}
}

Measured memory_bytes: 12000
import java.util.*;
import java.io.*;

/**
 * Made by egor https://github.com/chermehdi/egor.
 * 
 * @author Azuz
 * 
 */
public class Main {

    void solve(Scanner in, PrintWriter out) {
      double d = in.nextDouble();
      double t = in.nextDouble();
      double s = in.nextDouble();

      if (d/s > t) {
        out.println("No");
      } else {
        out.println("Yes");
      }
    }

    public static void main(String[] args) {
        try(Scanner in = new Scanner(System.in);
            PrintWriter out = new PrintWriter(System.out)) {
            new Main().solve(in, out);
        }
    }
}


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

//C++14 (GCC 5.4.1)

#define LLINF (1LL<<60)
typedef long long ll;
#define mod 1000000007

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)

template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); }

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)
#define lower_bound_idx(V,c) distance(V.begin(),lower_bound(V.begin(),V.end(),c))

ll ls(ll x){
    return (x>0) ? x : -x;
}

int main() {
    ios::sync_with_stdio(false);//stdoutとcoutの同期解除
    cin.tie(nullptr);//cinとcoutの同期解除
    
    int N;
    cin >>N;

    vector<ll> A(N);
    rep(i,N) cin >> A[i];
    
    vector<ll> E(N+1,0);
    rep(i,N) E[i+1]=E[i]+A[i];
    //int t=(upper_bound(E.begin(),E.end(),E[N]/2)-E.begin())-1;

    ll ans=LLINF;
    for(int i=0;i<N;i++){
        chmin(ans,ls(E[N]- E[i]*2 ));
    }
    cout << ans <<endl;
    return (0);
}

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

using namespace std;



int main(){

	while(true){
		int n;
		cin>>n;

		if(n==0) break;

		int max=0;
		int min=1000;
		int sum=0;
		for (int i = 0; i < n; ++i)
		{
			int current;
			cin>>current;
			if(current>max){
				max=current;
			}
			if(current<min){
				min=current;
			}
			sum+=current;
		}

		cout<<(sum-min-max)/(n-2)<<endl;
	}
	
return 0;
}

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


int main(){
//	枚数の入力
	int n;
	cin >> n;

//	n件の情報の格納
	int info[n][4],build1[3][10] = {},build2[3][10] = {},build3[3][10] = {},build4[3][10] = {};

	for(int i=0;i<n;i++){
		cin >> info[i][0] >> info[i][1] >> info[i][2] >> info[i][3];
		switch(info[i][0]){
		case 1:
			build1[info[i][1]-1][info[i][2]-1]+=info[i][3];
			break;

		case 2:
			build2[info[i][1]-1][info[i][2]-1]+=info[i][3];
			break;
		case 3:
			build3[info[i][1]-1][info[i][2]-1]+=info[i][3];
			break;
		case 4:
			build4[info[i][1]-1][info[i][2]-1]+=info[i][3];
			break;
		}

	}
	for(int b=1;b<=4;b++)
	{

		for(int f=0;f<3;f++)
		{

			for(int r=0;r<10;r++)
			{
				switch(b){
				case 1:
					cout << " " << build1[f][r];
					break;
				case 2:
					cout << " " << build2[f][r];
					break;
				case 3:
					cout << " " << build3[f][r];
					break;
				case 4:
					cout << " " << build4[f][r];
					break;
				}
			}
			cout << endl; // 改行
		}

//		#での区切り
		if(b != 4){
			for(int k = 0;k<20;k++) cout <<'#';
			cout << endl;
		}
	}

	return 0;
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
bool isValid(char c){
    bool ret = false;
    switch(c){
        case 'A':
        case 'C':
        case 'G':
        case 'T':
            ret = true;
            break;
        default:
            break;
    }
    return ret;
}
int main(){
    string s;
    cin >> s;
    int cnt = 0;
    int ans = 0;
    for(int i = 0; i < s.length(); i++){
        if(isValid(s[i])){
            cnt++;
        }else{
            cnt = 0;
        }
        ans = max(ans,cnt);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3608
#include <iostream>
#include <cmath>

#define INF 1LL<<60

using namespace std;

typedef long long ll;

ll func(ll b, ll n){
	if(n<b){
		return n;
	}else{
		ll nn = floor((double)n/b);
		return func(b,nn) + (n%b);
	}
}

int main(){
	ll N,S;
	cin >> N >> S;
	if(N==S){
		cout << N+1 << endl;
		return 0;
	}

	ll ans = INF;
	for(ll b=2;b<sqrt(N)+1;b++){
		if(func(b,N)==S){
			ans = min(ans,b);
		}
	}

	ll D = N-S;
	for(ll i=1;i<sqrt(D)+1;i++){
		ll b = (N-S)/i+1;
		if(func(b,N)==S){
			ans = min(ans,b);
		}
	}
	if(ans==INF)
		cout << -1 << endl;
	else
		cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String O = sc.next();
        String E = sc.next();
        String[] pass = new String[O.length() + E.length()];
        for (int i = 0; i < O.length(); i++) {
            pass[i * 2] = O.substring(i, i + 1);
        }
        for (int i = 0; i < E.length(); i++) {
            pass[i * 2 + 1] = E.substring(i, i + 1);
        }
        StringBuffer sb = new StringBuffer();
        for (String val : pass) {
            sb.append(val);
        }
        System.out.println(sb);
    }
}


Measured memory_bytes: 22996
def distance(a,b)
  Math.sqrt(((a[0] - b[0]) ** 2) + ((a[1] - b[1]) ** 2))
end

n = gets.chomp.to_i
m = []
n.times {|i| m.push(gets.chomp.split(' ').map{|i| i.to_i}) }

order_list = []
_o = []
n.times{|i| _o.push(i)}
_o.permutation(n){|a| order_list.push(a)}

total_distance = 0.0
order_list.each do |order|
  0.upto(n) do |i|
    break if i+1 >= n
    total_distance += (distance(m[order[i]], m[order[i+1]]))
  end
end
puts total_distance / order_list.length


Measured memory_bytes: 8188
import math
X = int(input())

def IsBekijo(x):
    if x == 1:
        return True
    for i in range(2,math.ceil(math.sqrt(x)) + 1):
        if x % i == 0:
            d = x // i
            while d != 1:
                if d % i == 0:
                    d //=  i
                else:
                    break
            if d == 1:
                return True
    return False

for i in range(X,0, -1):
    if IsBekijo(i):
        print(i)
        break


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define sll(x) scanf("%lld",&x)
#define prll(x) printf("%lld ",x)
#define pri(x) printf("%d ",x)
#define si(x) scanf("%d",&x)
#define el cout << "\n"
#define pb push_back
#define f first
#define s second
#define arrondi(a) (long long)floor(a+0.5);
#define NIL -1
ll N=500005;
ll MAX=9223372036854775807;
ll MOD=1000000007;
long double PI =4*atan(1);

int main()
{
	IOS;
    cout.precision(30);
    ll n,m;
    cin >> n >>m;
    map<ll,ll> mp1,mp2;
    ll nbr=0,s=0;
    for(int i=0;i<m;i++)
    {
        ll x ;
        string y;
        cin >> x >> y;
        if(y=="AC")
            {
                mp1[x]++;
                if(mp1[x]==1)
                {   s++;
                    nbr+=mp2[x];

                }
                }
        else
            {
                if(mp1[x]==0)
                    mp2[x]++;
            }

    }
    cout << s  << " " << nbr;
    return 0;
}


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

struct Card{char suit, value;};

void swapCard(Card c[],int i,int j){
	Card tmp=c[i];
	c[i]=c[j];
	c[j]=tmp;
}

void bubbleSort(Card c[], int N){
	for (int i=1;i<N;i++){
		for (int j=N-1;j>=i;j--){
			if (c[j].value<c[j-1].value){
				swapCard(c,j,j-1);
			}
		}
	}
}

void selectionSort(Card c[], int N){
	for(int i=0;i<N;i++){
		int minv=c[i].value;
		int minj=i;
		for(int j=i+1;j<N;j++){
			if(c[j].value<minv){
				minv=c[j].value;
				minj=j;
			}
		}
		if(minj!=i){
			swapCard(c,i,minj);
		}
	}
}

void printCard(Card c[], int N){
	cout << c[0].suit << c[0].value;
	for (int i=1;i<N;i++){
		cout << " "<< c[i].suit << c[i].value;
	}
	cout << endl;
}

bool isSame(Card c1[],Card c2[],int N){
	for(int i=0;i<N;i++){
		if(c1[i].suit!=c2[i].suit||c1[i].value!=c2[i].value){
			return 0;
		}
	}
	return 1;
}

int main(){
	Card c1[100], c2[100];
	int N;
	char ch;
	
	cin >> N;
	for (int i=0;i<N;i++){
		cin >> c1[i].suit >> c1[i].value;
		c2[i] = c1[i];
	}
	
	bubbleSort(c1,N);
	selectionSort(c2,N);
	
	printCard(c1,N);
	cout << "Stable" << endl;
	printCard(c2,N);
	if(isSame(c1,c2,N)){
		cout << "Stable" << endl;
	}else{
		cout << "Not stable" << endl;
	}
	return 0;
}



Measured memory_bytes: 3140
n=int(input())
ans=""
while n!=0:
    n-=1
    x=n%26
    if x==0:
        ans+="a"
    elif x==1:
        ans+="b"
    elif x==2:
        ans+="c"
    elif x==3:
        ans+="d"
    elif x==4:
        ans+="e"
    elif x==5:
        ans+="f"
    elif x==6:
        ans+="g"
    elif x==7:
        ans+="h"
    elif x==8:
        ans+="i"
    elif x==9:
        ans+="j"
    elif x==10:
        ans+="k"
    elif x==11:
        ans+="l"
    elif x==12:
        ans+="m"
    elif x==13:
        ans+="n"
    elif x==14:
        ans+="o"
    elif x==15:
        ans+="p"
    elif x==16:
        ans+="q"
    elif x==17:
        ans+="r"
    elif x == 18:
        ans += "s"
    elif x==19:
        ans+="t"
    elif x==20:
        ans+="u"
    elif x==21:
        ans+="v"
    elif x==22:
        ans+="w"
    elif x==23:
        ans+="x"
    elif x==24:
        ans+="y"
    elif x==25:
        ans+="z"
    n=(n-x)//26
ansr=ans[::-1]
print(ansr)


Measured memory_bytes: 9260
import java.util.*;
import java.util.Map.Entry;

import javax.swing.text.Segment;
import javax.xml.ws.WebEndpoint;

import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main implements Runnable
{
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};
    static long mod=1000000007;
    
    public static void main(String[] args) {        
        new Thread(null, new Main(), "", 200 * 1024 * 1024).start();        
    }
    
    public void run() {
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

        int n=sc.nextInt();
        int m=sc.nextInt();
        n*=500;

    	out.println(n>=m?"Yes":"No");
     	out.flush();
    }
    
    static void ret(String ans) {
    	System.out.println(ans);
    	System.exit(0);
    }

    static void ret(long ans) {
    	System.out.println(ans);
    	System.exit(0);
    }
    
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

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

//class P {
//	int x,y; double d;
//	P(int  x, int y, double d) {
//	  this.x=x;
//	  this.y=y;
//	  this.d=d;
//	}
//}

//
//class P implements Comparable<P>{
//    int id,ds,p;
//    P(int id, int ds, int p) {
//    	this.id=id;
//    	this.ds=ds;
//    	this.p=p;
//    }
//
//    public int compareTo(P p){
//        return ds-p.ds;
//    }
//}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString()
    {
        while( st==null || !st.hasMoreTokens() )
			try {
				st = new StringTokenizer(x.readLine());
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
        return st.nextToken();
    }
    public int nextInt()
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) {
        int r[] = new int[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextInt(); 
        }
        return r;
    }
    public long[] nextLongArray(int size) {
        long r[] = new long[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextLong(); 
        }
        return r;
    }
    public char[] getCharSet() {
        return this.nextString().toCharArray();
    }    
    public long nextLong()
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 23380
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <sstream>
#include <fstream>

#define all(c) (c).begin(), (c).end()
#define iter(c) __typeof((c).begin())
#define cpresent(c, e) (find(all(c), (e)) != (c).end())
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define tr(c, i) for (iter(c) i = (c).begin(); i != (c).end(); ++i)
#define pb(e) push_back(e)
#define mp(a, b) make_pair(a, b)

using namespace std;
typedef long long unsigned int ll;

int main() {
  int N, K;
  cin >> N >> K;
  int ans = 1;
  for (int i = 0; i < N; ++i) {
    ans = min(ans + ans, ans + K);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i,n) for (int i = 0; i < (n); ++i)
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main(){
    int N;
    cin >> N;
    cout << N*N*N << endl;
    return 0;
}

Measured memory_bytes: 256
/*
　　こんにちは。あたしはｶｳｶﾞｰﾙ。
　　redcoderになるためAtCoderを巡る旅をしてます。

　　　 　 ＿_
　　　 ヽ|＿_|ノ　　　　ﾓｫ
　　　　||‘‐‘||ﾚ　　_)_, ―‐ 、
　　　　/(Ｙ (ヽ＿ /・ ヽ　　 ￣ヽ
　　　　∠ ＿ ゝ　 ｀^ヽ ﾉ.::::_(ノヽ
　　　　 _/ヽ　 　　  /ヽ￣￣/ヽ
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define dump(x)  cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) << endl

#define rep(i, n) REP(i, 0, n)                              // 0, 1, ..., n-1
#define REP(i, x, n) for(int i = x; i < n; i++)             // x, x + 1, ..., n-1
#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(v) (v).begin() , (v).end()
#define RALL(v) (v).rbegin(), (v).rend()

#define COUT(x) cout << (x) << endl

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; }
vector<int> color;

struct Edge
{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w) { }
};

void dfs(const vector<vector<Edge>> &G, int v, int cur, int p) {
    color[v] = cur;
    for(auto next_edge : G[v]) {
        if(next_edge.to == p) continue;
        if(next_edge.weight % 2 == 0) dfs(G, next_edge.to, cur, v);
        else dfs(G, next_edge.to, 1 - cur, v);
    }
}

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

    int n; cin >> n;
    vector<vector<Edge>> G(n);

    for(int i = 0; i < n - 1; i++) {
        int u, v, w; cin >> u >> v >> w;
        u--; v--;
        G[u].push_back(Edge(v, w));
        G[v].push_back(Edge(u, w));
    }

    color.assign(n, -1); //色分け配列初期化
    dfs(G, 0, 1, -1);

    rep(i, n) {
        cout << color[i] << endl;
    }
}


Measured memory_bytes: 9728
#include<iostream>
#include<string>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
#include<functional>
#include<iomanip>
#include<queue>
#include<cassert>
#include<tuple>
#include<set>
#include<map>
#include<list>
#include<bitset>

#define PB push_back
#define ALL(a)  (a).begin(),(a).end()
#define DWN(a)  (a).begin(),(a).end(), greater<int>()
#define rep(i, m) for (int i = 0; i < m; i++)
#define REP(i, n, m) for (int i = n; i < m; i++)

#define mod 1000000007

using namespace std;

typedef long long ll;
typedef pair<int, int> P;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
const int INF = (int)1e9;

int main() {
	int n;
	ll h;
	cin >> n >> h;
	vector<ll> a(n), b(n);
	ll amax = 0LL;
	rep(i, n) {
		cin >> a[i] >> b[i];
		amax = max(amax, a[i]);
	}
	sort(b.begin(), b.end(), greater<ll>());
	ll cnt = 0LL;
	for (int i = 0; i < n; i++) {
		if (amax >= b[i]) break;
		cnt++;
		h -= b[i];
		if (h <= 0) {
			cout << cnt << endl;
			return 0;
		}
	}
	cnt += (h - 1LL) / amax + 1LL;
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 1792
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

N = int(input())
A = list(map(int, input().split()))
A.sort()

start = 0
end = (3 * N) - 1

ans = 0
while True:
    end -= 1
    ans += A[end]
    start += 1
    end -= 1
    if start > end:
        break

print(ans)


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

using namespace std;

using int64 = long long;

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

  int64 w, h, x, y;
  cin >> w >> h >> x >> y;
  double max = w * h * 0.5;
  int bit = (2 * x == w) && (2 * y == h);
  cout << max << " " << bit << endl;
}


Measured memory_bytes: 256
from itertools import product
a=list(input())

for b in product(["+","-"],repeat=3):
  if(eval(a[0]+b[0]+a[1]+b[1]+a[2]+b[2]+a[3])==7):
    print(str(a[0]+b[0]+a[1]+b[1]+a[2]+b[2]+a[3]+"=7"))
    break

Measured memory_bytes: 38384
x,n = map(int,input().split())
v = list(map(int,input().split()))

for i in range(1,100):
  if x not in v:
    print(x)
    break
  if x-i not in v:
    print(x-i)
    break
  elif x+i not in v:
    print(x+i)
    break



Measured memory_bytes: 61776
//vec[i]の範囲外エラー表示
#define _GLIBCXX_DEBUG
//includeとusing
#include <bits/stdc++.h>
using namespace std;
//型名省略
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;
using ll = long long;
using st = string;
using vl = vector<long long>;
using vvl = vector<vector<long long>>;
using vc = vector<char>;
using vvc = vector<vector<char>>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using pll = pair<ll, ll>;
using pcc = pair<char, char>;
//定数
const ll INF = 1e9;
const ll MOD = 1e9+7;
const vl dx = {1,0,-1,0,1,0,-1,0};
const vl dy = {0,1,0,-1,0,1,0,-1};
//マクロ
#define rep(i,n) for(ll i = 0; i < (ll) n; i++)
#define rrep(i,n) for(ll i = (ll) n - 1; i >= 0;i--)
#define REP(i,x,n) for(ll i = (ll) x; i < (ll) n; i++)
#define RREP(i,x,n) for(ll i = (ll) n - 1; i >= x; i--)
#define each(i,A) for(ll i: (vl) A)
#define all(A) A.begin(), A.end()
#define Size(A) ll(A.size())
//入力
template<typename T> T input() {T x; cin >> x; return x;}
//正誤判定
void Yes(bool ans){cout << (ans? "Yes" : "No") << endl;}
void YES(bool ans){cout << (ans? "YES" : "NO") << endl;}
//余り切り上げ
ll ceil(ll a,ll b) {return (a + b - 1) / b;}
//最大値・最小値
template <typename T> bool chmax(T &a, const T& b) {if(a < b) {a = b; return true;} return false;}
template <typename T> bool chmin(T &a, const T& b) {if(a > b) {a = b; return true;} return false;}
//最大公約数
ll gcd(ll a,ll b){if(a<b)swap(a,b); if(a%b==0)return b; return gcd(b,a%b);}
//最小公倍数
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
//n乗の余り
ll modpow(ll x,ll n,ll mod){ll res=1;for(ll i=0;i<n;i++){res=res*x%mod;}return res;}
ll MODpow(ll x,ll n){ll res=1;for(ll i=0;i<n;i++){res=res*x%MOD;}return res;}


/*--------------------------------------------------------------------------*/

//main関数
int main() {
    st s,t,u;
    ll a,b;
    cin >> s >> t >> a >> b >> u;
    if(s == u) cout << a - 1 << " " << b << endl;
    else cout << a << " " << b - 1 << endl;
}



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


int main(){
  
  int n;cin>>n;
  vector<int>v(n);
  rep(i,n)cin>>v[i];
  rep(i,n){
    int k=i;while(true){
    if(v[k]<v[k-1]&&k>0){
      int a=v[k];
      v[k]=v[k-1];
      v[k-1]=a;
      k--;
    }
    else break;
    }
  rep(i,n){
    if(i)cout<<' ';
    cout<<v[i];
  }
  cout<<endl;
  }
}



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

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

typedef long long lint;

using namespace std;

int main(){
  int A,B;
  cin>>A>>B;
  if(A==1)A=14;
  if(B==1)B=14;
  if(A>B)cout<<"Alice"<<endl;
  else if(A<B)cout<<"Bob"<<endl;
  else cout<<"Draw"<<endl;
  return 0;
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0108

"""
import sys
from sys import stdin
input = stdin.readline


def main(args):
    while True:
        # S = [4, 5, 1, 1, 4, 5, 12, 3, 5, 4]
        n = int(input())
        if n == 0:
            break
        S = [int(x) for x in input().split(' ')]

        A = []                  #  After[]
        B = S[:]                #  Before[]
        count = 0
        while True:
            for s in B:
                A.append(B.count(s))
            if A == B:
                break
            B = A[:]
            A = []
            count += 1

        print(count)
        print(*A)


if __name__ == '__main__':
    main(sys.argv[1:])
    

Measured memory_bytes: 8036
# include<bits/stdc++.h>
using namespace std;
# define lowbit(x) ((x)&(-x))
# define pi acos(-1.0)
# define eps 1e-8
# define MOD 1000000007
# define INF 1000000000
# define mem(a,b) memset(a,b,sizeof(a))
# define FOR(i,a,n) for(register int i=a; i<=n; ++i)
# define FDR(i,a,n) for(register int i=a; i>=n; --i)
# define bug puts("H");
# define lch p<<1,l,mid
# define rch p<<1|1,mid+1,r
# define mp make_pair
# define pb push_back
typedef pair<int,int> PII;
typedef vector<int> VI;
# pragma comment(linker, "/STACK:1024000000,1024000000")
typedef long long LL;
inline char nc(){
    static char buf[1000000],*p1=buf,*p2=buf;
    return p1==p2&&(p2=(p1=buf)+fread(buf,1,1000000,stdin),p1==p2)?EOF:*p1++;
}
inline int Scan(){
    char ch=nc();int sum=0, f=1;
    if (ch=='-') f=-1, ch=nc();
    while(!(ch>='0'&&ch<='9'))ch=nc();
    while(ch>='0'&&ch<='9')sum=sum*10+ch-48,ch=nc();
    return sum*f;
}
const int N=55;
//Code beg....

bool vis[N];
VI E[N];
int dep[N], dp[N], ans;

void dfs(int x, int fa){
    dep[x]=dep[fa]+1; dp[x]=INF;
    vis[x]=true;
    for (auto i=E[x].begin(); i!=E[x].end(); ++i) {
        if (*i==fa) continue;
        if (vis[*i]) dp[x]=min(dp[x],dep[*i]);
        else {
            dfs(*i,x);
            dp[x]=min(dp[x],dp[*i]);
        }
    }
    if (dp[x]>=dep[x]&&fa) ++ans;
}
int main ()
{
    int n, m, u, v;
    scanf("%d%d",&n,&m);
    while (m--) scanf("%d%d",&u,&v), E[u].pb(v), E[v].pb(u);
    dfs(1,0);
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include<iostream> 
#include<cstring> 
#include<cstdlib> 
using namespace std; 
  
string X,Y;
void lcs( string X, string Y, int m, int n ) 
{ 
   int L[m+1][n+1]; 
   for (int i=0; i<=m; i++) 
   { 
     for (int j=0; j<=n; j++) 
     { 
       if (i == 0 || j == 0) 
         L[i][j] = 0; 
       else if (X[i-1] == Y[j-1]) 
         L[i][j] = L[i-1][j-1] + 1; 
       else
         L[i][j] = max(L[i-1][j], L[i][j-1]); 
     } 
   } 
   int index = L[m][n]; 
   string str="";
   int i = m, j = n; 
   while (i > 0 && j > 0) 
   { 
      if (X[i-1] == Y[j-1]) 
      { 
          str+= X[i-1]; 
          i--; j--; index--; 
      } 
      else if (L[i-1][j] > L[i][j-1]) 
         i--; 
      else
         j--; 
   } 
  
   for(int i=str.length()-1;i>=0;i--)cout<<str[i]; 
} 
  
int main() 
{ 
cin>>X>>Y;
  int m = X.length(); 
  int n = Y.length(); 
  lcs(X, Y, m, n); 
  return 0; 
} 

Measured memory_bytes: 35456
#include<bits/stdc++.h>
#define lld long long int
#define pb push_back
#define in insert
#define mod 1000000007
#define pi 3.14159265358979

using namespace std;

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

    lld n,k,x,f=0;
    cin>>n>>k;

    cin>>x;
    if(x>k)f=1;
    if(x==k){cout<<"POSSIBLE"<<"\n";return 0;}
    lld g=x;
    for(lld i=0;i<n-1;i++)
    {
        cin>>x;
        if(x>k)f=1;
        if(x==k){cout<<"POSSIBLE"<<"\n";return 0;}
        g=__gcd(g,x);
    }
    if(k%g==0&&g!=1&&f==1)
    {
        cout<<"POSSIBLE"<<"\n";
        return 0;
    }
    if(g==1&&f==1)cout<<"POSSIBLE"<<"\n";
    else cout<<"IMPOSSIBLE"<<"\n";
}


Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
int n, k;
int which(int a){
  if(k-a>=a) return 2*a;
  else return 2*(k-a);
}
int main() {
  cin >> n >> k;
  int x[110];
  for(int i=0; i<n; i++){
    cin >> x[i];
  }
  int sum=0;
  for(int i=0; i<n; i++){
    sum += which(x[i]);
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
K,A,B = (int(i) for i in input().split())
if A+2>=B:
    print(1+K)
else:
    Bis = A
    K-=A-1
    Bis += int(K/2)*(B-A)
    if(K)%2==1:
        Bis+=1
    print(Bis)



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

int calc(int x){
    int val = 0;
    while( x%100 ==0){
        val += 1;
        x = x / 100;
    }
    return val;
}

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

    int cnt = 0;
    int ans = 0;

    while( cnt < N ){
        ans += 1;
        if(calc(ans) == D){
            ++cnt;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256