akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <string.h>
#include <string>
#include <cmath>
#include <complex>
#include <map>
using namespace std;

#define rep(i,n) for(int i=0;i<int(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define PB push_back
#define EPS 1e-8
#define F first
#define S second

static const double PI=6*asin(0.5);
typedef pair<double,double> P;
typedef complex<double> CP;
typedef long long ll;


double dist1,dist2,dist3;
double tx,ty;
vector<CP> p;
CP O(0.0,0.0);
double squ(double a,double b,double c){
	double s=(a+b+c)/2.0;
	return sqrt(s*(s-a)*(s-b)*(s-c));
}

double dis(CP a,CP b){
	CP c((real(a)-real(b)),imag(a)-imag(b));
	return sqrt(real(c)*real(c)+imag(c)*imag(c));
}

char t;
int main(){
	while(cin>>tx>>t>>ty){
		CP tp(tx,ty);
		p.PB(tp);
	}
	double res=0;
	CP tp(p[0].real(),p[0].imag());
	p.PB(tp);
	dist1=dis(p[0],O);
	rep(i,p.size()-1){
		int j=i+1;
		dist2=dis(p[j],O);
		dist3=dis(p[j-1],p[j]);
		res+=squ(dist1,dist2,dist3);
		dist1=dist2;
	}
	printf("%.6f",res);
	return 0;
}

Measured memory_bytes: 1244
# coding: utf-8
 
a = int(input())
b=list(map(int,input().split()))
sum = 0
 
for i in range(a):
    sum += b[i]
  
ans_pre = sum/a
ans = round(ans_pre)

sum = 0 

for i in range(a):
    sum += (b[i]-ans)**2

print(sum)

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

int dp[1002][5000];

const int INF = 1000000000;

int main()
{
    int n, m;
    cin >> n >> m;
    int a[1002], b[1002], c[1002][12];
    int d[1002] {0};
    for(int i = 0; i < m; i++){
        cin >> a[i] >> b[i];
        for(int j = 0; j < b[i]; j++){
            cin >> c[i][j];
            d[i] += (1 << (c[i][j] - 1));
        }
    }
    for(int i = 0; i <= m; i++){
        fill(dp[i], dp[i] + (1 << n), INF);
    }
    dp[0][0] = 0;
    for(int i = 1; i <= m; i++){
        for(int j = 0; j < (1 << n); j++){
            dp[i][j] = min(dp[i - 1][j], dp[i - 1][j & ~d[i - 1]] + a[i - 1]);
        }
    }
    if(dp[m][(1 << n) - 1] >= INF) cout << -1 << endl;
    else cout << dp[m][(1 << n) - 1] << endl;
}

Measured memory_bytes: 19840
n = int(input())
t ,a = map(int, input().split())
height =  list(map(int, input().split()))
diff = []
for i in range(len(height)):
    diff.append(abs(a-(t - height[i]*0.006)))
ans = [i+1 for i in range(len(diff)) if diff[i] == min(diff)]
print(ans[0])

Measured memory_bytes: 3060
using System;

namespace ABC132_b
{
    class Program
    {
        static void Main(string[] args)
        {
            string str1 = Console.ReadLine();
            int x = int.Parse(str1);
            int count = 0;
            int max = 0;
            string[] array = Console.ReadLine().Split(' ');
            int[] intAry = Array.ConvertAll<string, int>(array,delegate (string value)
           {
                 return int.Parse(value);
            });
            
            for(int i = 1; i < x - 1; i++)
            {
                if((intAry[i] < intAry[i + 1]) && (intAry[i] > intAry[i - 1]))
                {
                    count++;
                   
                }
                if ((intAry[i] > intAry[i + 1]) && (intAry[i] < intAry[i - 1]))
                {
                    count++;
                }

            }
            Console.WriteLine(count);
        }
    }
}


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

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

int main(){
    int x,y;
    cin>>x>>y;
    cout<<x+y+1-gcd(x,y)<<endl;
    return 0;
}


Measured memory_bytes: 3104
n = int(input())
h = [int(i) for i in input().split()]

def count(h,m):
    c = 0
    state = 0
    for i in range(n):
        if h[i] >= m and state == 0:
            c += 1
            state = 1
        elif h[i] < m and state == 1:
            state = 0
    return c

ans = 0
m = max(h)
while m > 0:
    ans += count(h,m)
    m -= 1
    
print(ans)

Measured memory_bytes: 39280
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <functional>
#include <complex>
#include <bitset>
#include <numeric>
using namespace std;

typedef long long LL; typedef pair<LL, LL> PLL; typedef vector<LL> VLL;
#define REP(i,n) for(int (i)=0; (i)<(n) ;++(i))
#define REPN(i,a,n) FOR((i),(a),(a)+(n))
#define FOR(i,a,b) for(int (i)=(a); (i)<(b) ;++(i))
#define PB push_back
#define MP make_pair
#define OUT(a) cout<<(a)<<endl;
#define MOD 1000000007



long long modpow(long long a, long long n){
    if(n==0) return 1;
    long long re=modpow((a*a)%MOD,n/2)%MOD;
    if(n%2==1) re= (re*a)%MOD;
    return re;
}
class Modint{
    public:
    long long Mod = MOD;
    long long v;
    Modint():v(0){}
    template<typename T> Modint(T x){
        x %= Mod;
        long long y = (long long)x;
        if(y<0) y+=Mod;
        v=y;
    }
    Modint &operator+=(Modint a){
        v=(v+a.v)%Mod;
        return *this;
    }
    Modint &operator-=(Modint a){
        v=(v-a.v)%Mod;
        return *this;
    }
    Modint &operator*=(Modint a){
        v=(v*a.v)%Mod;
        return *this;
    }
    Modint &operator/=(Modint a){
        v=(v*modpow(a.v,Mod-2))%Mod;
        return *this;
    }
    Modint operator+(Modint a){
        long long t= (v)+(a.v);
        return Modint(t);
    }
    Modint operator-(Modint a){
        long long t= (v)-(a.v);
        return Modint(t);
    }
    Modint operator*(Modint a){
        long long t= (v)*(a.v);
        return Modint(t);
    }
    Modint operator/(Modint a){
        long long t=(v)*modpow(a.v,Mod-2);
        return Modint(t);
    }
};
ostream& operator<< (ostream& os, const Modint m) {
    return os << m.v;
}
Modint dp[404][404],po[404][404];
long long n,c,a[404],b[404];

void solve(int n, int c){
    REPN(i,1,n){
        REPN(j,0,c+1){
            FOR(k,0,j+1){
                dp[i][j]+=dp[i-1][j-k]*(po[b[i]][k]-po[a[i]-1][k]);

            }
            //OUT(dp[i][j])
        }
    }

}

int main(){

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> c;
    dp[0][0]=1;

    REP(i,n){
        cin >> a[i+1];
    }
    REP(i,n){
        cin >> b[i+1];
    }
    REPN(i,1,401){
        REPN(j,0,401){
            po[i][j]=po[i-1][j]+modpow(i,j);
            //OUT(po[i][j])
        }
    }
    solve(n,c);
    cout << dp[n][c] <<endl;



    return 0;
}


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

namespace DDCC2020A
{
    class Program
    {
        static void Main(string[] args)
        {
            var inputArr = Console.ReadLine().Split().Select(int.Parse).ToArray();
            //var inputInt = int.Parse(Console.ReadLine());

            int X = inputArr[0];
            int Y = inputArr[1];



            int ans = 0;

            if (X == 1) ans += 300000;
            else if (X == 2) ans += 200000;
            else if (X == 3) ans += 100000;

            if (Y == 1) ans += 300000;
            else if (Y == 2) ans += 200000;
            else if (Y == 3) ans += 100000;

            if (X == 1 && Y == 1) ans += 400000;
            //string ans = "";

            Console.WriteLine(ans);
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 13396
#include <iostream>
#include <vector>
#include <string>

using namespace std;

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> A(M);
  for(int i =0; i<M; i++) cin >> A[i];
  int HW_Time = 0;
  for(int i=0; i<M; i++) HW_Time += A[i];

  int ans = -1;
  if (N>=HW_Time) ans = N - HW_Time;

  cout << ans << endl;

}

Measured memory_bytes: 3644
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <set>
#include <map>

int main() {
  int k, x;
  scanf("%d %d", &k, &x);

  if (500*k >= x) {
    puts("Yes");
  } else {
    puts("No");
  }
}


Measured memory_bytes: 128
#!/usr/bin/env python3
N = input()

for i in range(8):
    num = [int(i) for i in N]
    for j in range(3):
        if (i >> j) % 2 == 1:
            num[-j - 1] *= -1
    if sum(num) == 7:
        print('{:d}{:+d}{:+d}{:+d}=7'.format(num[0], num[1], num[2], num[3]))
        break


Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <bitset>
#include <cassert>
using namespace std;
typedef long long ll;

double cross(pair<double, double> a, pair<double, double> b, pair<double, double> c) {
	pair<double, double> u = { a.first - c.first, a.second - c.second };
	pair<double, double> v = { a.first - b.first ,a.second - b.second };
	return u.first*v.second - u.second*v.first;
}

double abs(pair<double, double> a) {
	return sqrt(a.first*a.first + a.second*a.second);
}

int main() {
	int n; cin >> n;
	if (n == 2) {
		cout << 0.5 << endl;
		cout << 0.5 << endl;
		return 0;
	}
	vector<pair<pair<double, double>, int>> pi(n);
	for (int i = 0; i < n; i++) cin >> pi[i].first.first >> pi[i].first.second, pi[i].second = i;
	sort(pi.begin(), pi.end());
	double lm = 1e9; int idx = 0;
	vector<pair<pair<double, double>, int>> chi;
	bool used[103] = {};
	chi.push_back(pi[0]);
	used[idx] = true;
	for (int iter = 1; iter < n; iter++) {
		const auto &pr = chi.back().first;
		for (int i = 0; i < n; i++) {
			if (used[i]) continue;
			const auto &p = pi[i].first;
			int sgn = 0;
			bool flag = true;
			for (int j = 0; j < n; j++) {
				if (j == i) continue;
				if (p.first == pr.first && p.second == pr.second) continue;
				int s = cross(pr, p, pi[j].first) > 0 ? 1 : -1;
				flag &= sgn == 0 || s == sgn;
				sgn = s;
			}
			if (flag) {
				if (chi.size() >= 2) {
					const auto &pb = chi[chi.size() - 2].first;
					double s = (pr.first - p.first)*(pb.second - p.second);
					s -= (pb.first - p.first)*(pr.second - p.second);
					s /= 2.;
					s = abs(s);
					if (s < 1e-8) {
						chi.pop_back();
					}
				}
				chi.push_back(pi[i]);
				used[i] = true;
				break;
			}
		}
	}
	if (chi.size() >= 3) {
		const auto &pr = chi.back().first;
		const auto &pb = chi[chi.size() - 2].first;
		const auto &p = chi[0].first;
		double s = (pr.first - p.first)*(pb.second - p.second);
		s -= (pb.first - p.first)*(pr.second - p.second);
		s /= 2.;
		s = abs(s);
		if (s < 1e-8) {
			chi.pop_back();
		}
	}
	vector<double> ans(n);
	int m = chi.size();
	if (m >= 3) {
		for (int i = 0; i < m; i++) {
			const auto &pr = chi[(i - 1 + m) % m].first;
			const auto &pn = chi[(i + 1) % m].first;
			const auto &p = chi[i].first;
			pair<double, double> u = { p.first - pr.first, p.second - pr.second };
			pair<double, double> v = { p.first - pn.first, p.second - pn.second };
			double ang = acos((u.first*v.first + u.second*v.second) / abs(u) / abs(v));
			double r = acos(-1) - ang;
			ans[chi[i].second] = r / (2 * acos(-1));
		}
	}
	else {
		for (int i = 0; i < m; i++) {
			ans[chi[i].second] = 0.5;
		}
	}
	for (int i = 0; i < n; i++) printf("%.15f\n", ans[i]);
	int b = 2 * 0.;
	return 0;
}


Measured memory_bytes: 512
# -*- coding: utf-8 -*-
raw_input()
str = raw_input()
nums = []
for i in range(1,len(str)):
    count = 0
    chars = []
    
    for c in str[0:i]:
        if not c in chars and c in str[i:len(str)]:
            chars.append(c)
            count +=1
    nums.append(count)
print max(nums)


Measured memory_bytes: 2568
#include <iostream>

using namespace std;

int main()
{
string s;
cin>>s;
int j=0;
int res=1,zcount=0;
int zindex=0;
for(int i=0;i<s.size();i++){
         if(s[i]=='Z'){
            zindex=i;}
    }
for(int i=0;i<s.size();i++){
   if(s[i]=='A'){
   j=i;
   while(j<=zindex){
    res++;
    j++;
    }
      break;
   }
   }

   cout<<res-1;
}




Measured memory_bytes: 644
(let ((n (read))
    (a (read))
    (b (read))
    (s (read-line))
    (ninzuu 0)
    (bi 1))
    (loop for i below n do
        (progn
            (case (char-code (char s i))
                (97 (if (< ninzuu (+ a b))
                    (progn
                        (format t "Yes~%")
                        (incf ninzuu)
                    )
                    (format t "No~%")))
                (98 (if (and (< ninzuu (+ a b)) (<= bi b))
                    (progn
                        (format t "Yes~%")
                        (incf ninzuu)
                        (incf bi)
                    )
                    (format t "No~%")))
                (99 (format t "No~%"))
            )
        )
    )
)

Measured memory_bytes: 24964
# include <bits/stdc++.h>
# define ll int64_t
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007

using namespace std;

bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) x *= i;
    return x;
}


int main(){
    ll n;
    cin>>n;
    map<ll,ll> mp;
    rep(i,n){
        ll s;
        cin>>s;
        mp[s]++;
    }
    ll sum=0;
    for(auto p : mp) if(p.second%2!=0) sum++;
    cout<<sum<<endl;
    return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
using namespace std;
#define db(x) cerr << #x << "=" << x << endl
#define db2(x, y) cerr << #x << "=" << x << "," << #y << "=" << y << endl
#define db3(x, y, z) cerr << #x << "=" << x << "," << #y << "=" << y << "," << #z << "=" << z << endl
#define dbv(v) cerr << #v << "="; for (auto _x : v) cerr << _x << ", "; cerr << endl
#define dba(a, n) cerr << #a << "="; for (int _i = 0; _i < (n); ++_i) cerr << a[_i] << ", "; cerr << endl
typedef long long ll;
typedef long double ld;
char str[2005];
const int MOD = 998244353;
int dp[4005], ndp[4005];
int main() {
	scanf("%s", str);
	int n = strlen(str);
	int blues = 0, reds = 0;
	dp[0] = 1;
	for (int i = 0; i < 2 * n; ++i) {
		if (i < n) {
			blues += str[i] - '0';
			reds += 2 - (str[i] - '0');
		}
		memset(ndp, 0, sizeof(ndp));
		for (int j = max(0, i + 1 - reds); j <= min(i + 1, blues); ++j) {
			ndp[j] += dp[j]; // red
			ndp[j] += dp[j - 1]; // blue
			ndp[j] %= MOD;
		}
		swap(dp, ndp);
	}
	printf("%d\n", dp[blues]);
}


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

int m,f,r;

	while(1){
		scanf("%d %d %d",&m,&f,&r);
		if(m==-1 && f==-1 && r==-1)break;
		
		else if(m==-1 || f==-1){
			printf("%c\n",'F');
		}
		else if(m+f>=80){
			printf("%c\n",'A');
		}
		else if(m+f>=65 && m+f<80){
			printf("%c\n",'B');
		}
		else if(m+f>=50 && m+f<65){
			printf("%c\n",'C');
		}
		else if(m+f>=30 && m+f<50){
			if(r>=50){
				printf("%c\n",'C');
			}
			else{
				printf("%c\n",'D');
			}
		}
		else{
			printf("%c\n",'F');
		}
	}
	
return 0;
}


Measured memory_bytes: 2048
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,k;
  cin >>n >>m >>k;
  bool ok=false;
  for(int i=0;i<=n;i++){
    for(int j=0;j<=m;j++){
      if(i*(m-j)+j*(n-i)==k)ok=true;
    }
  }
  if(ok) cout << "Yes"<<endl;
  else cout <<"No"<<endl;
}


Measured memory_bytes: 256
#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;
  
  if(s.at(s.size()-1)=='s') s += "es";
  else s += "s";
  
  cout << s;
  
}

  
  




Measured memory_bytes: 3628
#include <bits/stdtr1c++.h>

using namespace std;
// 我们称一个集合是独特的当对集合的每一个元素a_i, 有gcd(a_i, sum of aexpect a_i)!=1
// 并且gcd(a_i) = 1 元素的大小不超过30000
// N最大不超过20000
// 构造题
// 2 4 6 8 10 ... 20000*2
// 由题设可知，对于最大的N，我们要选择2/3的数
// 注意到为了选择那么多的数，我们应尽量选能被2,3整除的数
// 同时为了gcd all = 1, 不妨2,3交替选择， 比如6k+2, 6k+3, 6k+4, 6k+6
// N<6特殊处理
// 对于N>=6 唯一的问题是sum
// 注意有 gcd(ai, S) = gcd(ai,S-ai)(*) 从S中减去ai效果不变
const int maxn = 1e5 + 7;
vector<int> v;

int main() {
    int add[] = {0, 2, 3, 4, 0};
    int n;
    scanf("%d", &n);
    int tot = 0;
    if (n == 3) return !printf("2 5 63\n");// 70
    else if (n == 4) return !printf("2 5 20 63\n"); //90
    else if (n == 5) return !printf("2 5 20 30 63\n"); //120
    else {
        int cnt = 0, sum = 0;
        int a, b;
        for (int i = 2; i <= 30001; i++) { //从2开始构造
            if (cnt < n && (i % 2 == 0 || i % 3 == 0)) {
                sum += i;
                cnt++;
                v.push_back(i);
            }
            if (i % 6 == 0) a = i;
            if (i % 6 == 4) b = i;
        }
        int X = sum % 6;
        if(X == 2) v[0] = a;
        else if(X == 3) v[1] = a;
        else if(X == 5) v[1] = b;
        for(int i = 0; i < n; i++) printf("%d%c", v[i], i==n-1?'\n':' ');
    }
}


Measured memory_bytes: 512
#include "bits/stdc++.h"
using namespace std;

#ifdef LOCAL
        #include "debug.h"
        #define input freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
        #else
        #define debug(...) 4
        #define input ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#endif

using ll = long long;
const int N = 2e5 + 5;
const int mod = 1e9 + 7;


int32_t main() {
    input;
    int x, y;
    cin >> x >> y;
    // 2 * a + 4 * b = y;
    // a + b = x;

    // 2 * (x - b) + 4 * b = y;
    // 2x - 2b + 4b = y;
    // 2x + 2b = y;
    // b = y-2x/2

    int b = (y - 2 * x) / 2;
    if((y - 2 * x) % 2)
        cout << "No";
    else {
        int a = x - b;
        if(a >= 0 and b >= 0)
            cout << "Yes";
        else    cout << "No";
    }

}

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

class Program
{
    static void Main()
    {
        string[] a = Console.ReadLine().Split(' ');
        long N = long.Parse(a[0]);
        long A = long.Parse(a[1]);
        long B = long.Parse(a[2]);
        long min = long.MaxValue;

        if (Math.Abs(A - B) % 2 == 0)
        {
            min = Math.Abs(A - B) / 2;
        }
        else
        {
            min = Math.Min(min, N - Math.Min(A, B));
            min = Math.Min(min, Math.Max(A, B) - 1);

            if (Math.Max(A, B) - 1 < N - Math.Min(A, B))
            {
                min = Math.Min(min, Math.Min(A, B) - 1 + (Math.Abs(B - A) + 1) / 2);
            }
            else
            {
                min = Math.Min(min, N - Math.Max(A, B) + (Math.Abs(B - A) + 1) / 2);
            }
        }
        Console.WriteLine(min);
    }
}


Measured memory_bytes: 11220
# include <bits/stdc++.h>
# define 	ll 		long long
# define 	N 		100010
using namespace std;
const int inf = 0x3f3f3f3f, INF = 0x7fffffff;
const ll  infll = 0x3f3f3f3f3f3f3f3fll, INFll = 0x7fffffffffffffffll;
int read(){
	int tmp = 0, fh = 1; char ch = getchar();
	while (ch < '0' || ch > '9'){ if (ch == '-') fh = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9'){ tmp = tmp * 10 + ch - '0'; ch = getchar(); }
	return tmp * fh;
}

const int  P = 1e9 + 7;
int cnt[N], a[N], n, len, inv[N], mul[N], ans[N];
int power(int x, int y){
	int i = x; x = 1;
	while (y > 0){
		if (y % 2 == 1) x = 1ll * x * i % P;
		i = 1ll * i * i % P;
		y /= 2;
	}
	return x;
}
int C(int n, int m){
	if (n < m) return 0;
	if (m < 0) return 0;
	return 1ll * mul[n] * inv[m] % P * inv[n - m] % P;
}
int main(){
//	freopen(".in", "r", stdin);
//	freopen(".out", "w", stdout);
	n = read();
	for (int i = 1; i <= n + 1; i++){
		a[i] = read(); 
		if (cnt[a[i]] == 0)
			cnt[a[i]] = i;
			else len = i - cnt[a[i]] + 1;
	}
	mul[0] = 1; for (int i = 1; i <= n + 1; i++) mul[i] = 1ll * mul[i - 1] * i % P;
	inv[n + 1] = power(mul[n + 1], P - 2);
	for (int i = n; i >= 0; i--) inv[i] = 1ll * inv[i + 1] * (i + 1) % P;
	for (int i = 1; i <= n + 1; i++){
		int sum = C(n - 1, i);
		sum = (sum + 2ll * C(n - 1, i - 1)) % P;
		sum = (sum - C(n - len + 1, i - 1) + P) % P;
		sum = (sum + C(n - 1, i - 2)) % P;
		ans[i] = sum;
	}
	for (int i = 1; i <= n + 1; i++)
		printf("%d\n", ans[i]);
	return 0;
}


Measured memory_bytes: 3200
#include <stdio.h>
using namespace std;

int main()
{
	int data[101] = {};
	int rank[101] = {};
	int n, p;
	int r = 1;
	bool flag = false;

	while (true)
	{
		scanf("%d,%d", &n, &p);
		if (n + p == 0) break;
		data[n] = p;
	}
	for (int i = 30; i >= 0; i--)
	{
		flag = false;
		for (int j = 1; j <= 100; j++)
		{
			if (data[j] == i && rank[j] == 0)
			{
				flag = true;
				rank[j] = r;
			}
		}
		if (flag) r++;
	}

	while (true)
	{
		if (scanf("%d", &n) == -1) break;
		printf("%d\n", rank[n]);
	}

	return 0;
}

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

#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define REP2(i, x, n) for (int i = x; i <= n; i++)
#define OP(x) cout << x << endl;
typedef long long ll;

int N;
vector<int> V;
vector<int> C;
int ANS = 0;

void rec(int vs, int cs, int i){
    if(i != N) {
        rec(vs + V[i], cs + C[i], i + 1);
        rec(vs, cs, i + 1);
    }else{
        int ans = vs - cs;
        ANS = max(ANS, ans);
    }
}

int main() {
    cin >> N;
    V.resize(N);
    C.resize(N);
    rep(i, N) cin >> V[i];
    rep(i, N) cin >> C[i];
    rec(0, 0, 0);
    OP(ANS);
}


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

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

  int n; cin >> n;

  vector<int> arr(n);
  for (int i = 0; i < n; ++i) cin >> arr[i];

  sort(begin(arr), end(arr));

  int count = 1;
  for (int i = 1; i < n; ++i) {
    if (arr[i] != arr[i - 1]) count++;
  }
  cout << count << "\n";
}


Measured memory_bytes: 3624
h, n = map(int, input().split())
ab = [list(map(int,input().split())) for _ in range(n)]
#print(ab)
max_a = max(a for a, b in ab)
#print(max_a)
dp = [10**18 for i in range(h+max_a)]
#print(dp)
dp[0] = 0
for i in range(1, h+max_a):
  dp[i] = min(dp[i-a] + b for a, b in ab)
#print(dp)
print(min(dp[h:]))

Measured memory_bytes: 3832
# coding: utf-8
n,k = map(int, input().split())
A = list(map(int, input().split()))
D = dict()
for a in A:
    if a in D:
        D[a] += 1
    else:
        D[a] = 1
D = sorted(D.items(), key=lambda x: x[1])
D = D[:len(D)-k]
total = sum([d[1] for d in D])
print(total)

Measured memory_bytes: 39932
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define For(i,n) for(int i=0;i<n;i++)
#define Fre(i,a,b) for(int i = a; i < b; i++)
#define sf(n) scanf("%d", &n)
#define sff(a,b) scanf("%d %d", &a, &b)
#define sfff(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define pfn(n) printf("%d\n", n)
#define pfs(n) printf("%d ", n)
#define ff first
#define ss second
#define mem(a,b) memset(a,b,sizeof(a))
#define READ freopen("in.txt", "r", stdin)
#define WRITE freopen("out.txt", "w", stdout)
#define sz size()
#define number_of_digit(n) __builtin_ffs(n);
#define ll long long
#define T int
#define ld long double
inline void print(T n)
{
  if (n == 0)
  {
    putchar('0');
    putchar('\n');
  }
  else if (n == -1)
  {
    putchar('-');
    putchar('1');
    putchar('\n');
  }
  else
  {
    char buf[11];
    buf[10] = '\n';
    int i = 9;
    while (n)
    {
      buf[i--] = n % 10 + '0';
      n /= 10;
    }
    while (buf[i] != '\n')
      putchar(buf[++i]);
  }
}
int read()
{
       int cc = getc(stdin);
       for (;cc < '0' || cc > '9';)  cc = getc(stdin);
       int ret = 0;
       for (;cc >= '0' && cc <= '9';)
       {
          ret = ret * 10 + cc - '0';
          cc = getc(stdin);
       }
      return ret;
}
ll power(ll num,ll g)
{
  if(g==0)return 1;

  if(g%2==1)return (num*power((num*num),g/2));
  return power((num*num),g/2);
}
int main()
{
  
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);

  string s;
  cin>>s;
  int l=s.size();
  int a=0,b=0;
  For(i,l)
  {
    if(s[i]=='0')a++;
    else b++;
  }
  cout<<min(a,b)*2<<endl;
  return 0;
}

Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main() {
  int N, M, C;

  int B[20] = {0};

  cin >> N >> M >> C;

  for (int i = 0; i < M; ++i)
    cin >> B[i];

  int ans = 0;
  for (int i = 0; i < N; ++i) {
    long long f = C;
    for (int j = 0; j < M; ++j) {
      int a;
      cin >> a;
      f += a * B[j];
    }
    if (f > 0)
      ++ans;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define fi first
#define se second
#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define rrep(i, n) for (int (i) = 1; (i) <= (n); (i++))
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define pb push_back
#define eb emplace_back
#define yn {puts("Yes");}else {puts("No");}
#define printd(x) printf("%.12f\n", x);
template<class T> bool chmin(T& a, const T& b) {if (a > b) {a = b; return 1;} return 0;}
template<class T> bool chmax(T& a, const T& b) {if (a < b) {a = b; return 1;} return 0;}
using namespace std;
using ll = long long;

int main() {
	int a, b, c, x, y;
	cin >> a >> b >> c >> x >> y;

	ll ans = 100000000000000;
	for (int i = 0; i <= 200000; i++) {
		ll now = 0;
		now = i * c;
		now += max(0, x - i / 2) * a + max(0, y - i / 2) * b;
		chmin(ans, now);
	}

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

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

int main() {
  int x;
  cin >> x;
  cout << x*x*x << endl; 
  return 0;
}


Measured memory_bytes: 3016
#include <stdio.h>

int main(void)
{
	int k,n;
	scanf("%d%d", &k, &n);
	int a[n];
	int i = 0;
	while (i < n)
		scanf("%d", &a[i++]);
	int sum = a[n - 1] - a[0];
	i = 1;
	while (i < n)
	{
		if ((k - a[i] + a[i - 1]) < sum)
			sum = k - a[i] + a[i - 1];
		i++;
	}
	printf("%d", sum);
	return (0);
}


Measured memory_bytes: 896
a, b, c = int(input()), int(input()), int(input())
x = int(input())
value = 0
for i in range(a+1):
        for j in range(b+1):
                for k in range(c+1):
                        sum = 500*i + 100*j + 50*k
                        if sum > x: continue
                        elif sum == x: value+=1
                        else: continue
print(value)

Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using System.Threading.Tasks;

namespace B_Digits
{
    class Program
    {
        static void Main(string[] args)
        {
            string a = ReadLine();
            string[] b = a.Split(' ');
            int N = int.Parse(b[0]);
            int K = int.Parse(b[1]);
            int count = 0;
            int m = 1;
            for (int i = 0; i < N+1; i++) {
                for (int j=0;j<i;j++) {
                    m = m*K;
                }               
                if ((N-m)<0){
                    break;
                }
                m = 1;
                count++;
            }
            int result = count;
        
            WriteLine("{0}",result);
            ReadKey();

        }
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
#define ll long long
#define ld long double
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define REP(i,j) for(int i=0;i<j;i++)
#define FORN(i,j,k) for(int i=j;i<k;i++)
#define vi vector<int>
#define vvi vector<vi >
#define pii pair<int,int>
#define vpii vector<pii >
using namespace std;
int main(void){
	int l,r,d;
	cin>>l>>r>>d;
	int cnt=0;
	for(int i=l;i<=r;i++){
		if(i%d==0)cnt++;
	}
	cout<<cnt;
	return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    ll N,C,K;
    cin >> N >> C >>K;
    vector<ll> T(N);
    rep(i,N){
        cin >> T[i];
    }
    sort(T.begin(),T.end());
    ll ans = 0;
    for(int i = 0;i<N;i++){
        //バスに乗る時間帯に被りがある間
        ll count = 1;
        //同じバスに乗る最初の人の乗車時間の左端と右端
        ll l = T[i];
        
        while(T[i+1]-l <= K && i+1 <N){
          if(count == C) break;
           count++;
           i++;
           
        }
      ans ++;;
    }
    cout << ans << endl;
}

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

using namespace std;

int a[51][51];
int color[51][51];
bool checked[51][51];
int w, h;

int dfs(int y, int x) {
  if (y < 0 || y >= h) {
    return 0b100;
  }
  if (x < 0 || x >= w) {
    return 0b100;
  }
  if (a[y][x] == 1) {
    return 0b001;
  } else if (a[y][x] == 2) {
    return 0b010;
  }
  if (checked[y][x]) {
    return 0;
  }

  int dy[] = { -1, 0, 1, 0 };
  int dx[] = { 0, 1, 0, -1 };

  checked[y][x] = true;
  int ret = 0;
  for (int i = 0; i < 4; i++) {
    ret |= dfs(y + dy[i], x + dx[i]);
  }

  return ret;
}

int main() {
  while (true) {
    for (int i = 0; i < 51; i++) {
      for (int j = 0; j < 51; j++) {
        a[i][j] = 0;
        color[i][j] = 0;
        checked[i][j] = false;
      }
    }

    cin >> w >> h;
    if (w + h == 0) {
      break;
    }
    for (int i = 0; i < h; i++) {
      string str;
      cin >> str;
      for (int j = 0; j < w; j++) {
        if (str[j] == '.') {
          a[i][j] = 0;
        } else if (str[j] == 'B') {
          a[i][j] = 1;
        } else {
          a[i][j] = 2;
        }
      }
    }
    int black = 0, white = 0;
    for (int i = 0; i < h; i++) {
      for (int j = 0; j < w; j++) {
        if (a[i][j] != 0) {
          continue;
        }
        for (int k = 0; k < h; k++) {
          for (int l = 0; l < w; l++) {
            checked[k][l] = false;
          }
        }
        int d = dfs(i, j);
        if (d == 0b001 || d == 0b101) {
          black++;
        }
        if (d == 0b010 || d == 0b110) {
          white++;
        }
      }
    }
    cout << black << " " << white << endl;

  }
  return 0;
}

Measured memory_bytes: 3264
#include <bits/stdc++.h>
 
using namespace std;
 
#define lli long long int
#define REP(i,s,n) for(int i=s;i<n;i++)
#define MOD 1000000007
#define NUM 2520
#define DEBUG 0
#define mp(a,b) make_pair(a,b)
#define SORT(V) sort(V.begin(),V.end())
#define PI (3.141592653589794)
#define INF (1LL<<50)

lli gcd(lli x, lli y)
{
       if(x<y)swap(x,y);
        if (y == 0) {
                return x;
        } else {
                return gcd(y, x % y);
        }
}

lli lcm(lli a,lli b)
{
   return a*b/gcd(a,b);
}

signed main(){

	lli a,b;
	cin>>a>>b;
	lli c,d;
	cin>>c>>d;

	lli diffA = b/c - (a-1)/c;
	lli diffB = b/d - (a-1)/d;
	lli LCM = lcm(c,d);
	lli diffC = b/LCM - (a-1)/LCM;

	cout<<b-a+1-diffA-diffB+diffC<<endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <deque>
#include <list>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
#include <bitset>

using namespace std;


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repr(i,n) for(int (i)=(n); (i)>=(0); (i)--)
#define SIZE(x) ((int)(x).size())
#define GCD(a, b) int gcd(int a,int b){return b?gcd(b,a%b):a;}
#define QP(a, b) int qp(int a,ll b){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
#define all(v) (v).begin(),(v).end()


template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
template<typename A, size_t N, typename T>
void FILL(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

typedef vector<int, int> vint;
typedef pair<int,int> pint;
typedef vector<pint>vpint;
typedef long long ll;

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1LL << 60;
const ll MOD = 1000000007LL;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, a, b; cin >> n >> a >> b;
    cout << (n*a<b ? n*a : b);
    cout << endl;
    return 0;
}



Measured memory_bytes: 256
h, w = map(int, input().split())
s = [list(input()) for _ in range(h)]

for i in range(1, h-1):
    for j in range(1, w-1):
        if s[i][j] == '#' and s[i - 1][j] != '#' and s[i][j - 1] != '#' and s[i + 1][j] != '#' and s[i][j + 1] != '#':
            print('No')
            exit()
print('Yes')

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

ll func(ll x ,ll a, ll b) {
    return (a * x) / b - a * (x / b);
}

int main() {

    ll a, b, n; cin >> a >> b >> n;
    ll ans;
    if (n < b) ans = func(n, a, b);
    else ans = func(b - 1, a, b);
    cout << ans << endl;
    return 0;
}

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

int main() {
    int N;;
    cin >> N;
    int n2 = sqrt(N);
    int sum = 0;
    rep(i,n2){
        for(int j = i;j<N;j++){
            if((i+1)*(j+1) >= N){
                break;
            }
            if((i+1) != (j+1)){
                sum ++;
            }
            sum ++;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3676
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a,b,c,d=0;
    cin>>a;
    map<long long,long long>mp;
    mp[a]++;
    d++;
    while(1)
    {
        if(a%2==0)
        {
            a=a/2;
            if(mp[a]==1)
                break;
            else
            {
                d++;
                mp[a]++;
            }

        }
        else
        {
            a=3*a+1;
            if(mp[a]==1)
                break;
            else
            {
                d++;
                mp[a]++;
            }
        }
    }

    cout<<d+1;
}


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

using ll = long long;
using pii = pair<int, int>;
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i, n) rep2(i, 0, n)
#define rep2(i, m, n) for (int i = m; i < (n); i++)
#define per(i, b) per2(i, 0, b)
#define per2(i, a, b) for (int i = int(b) - 1; i >= int(a); i--)
#define ALL(c) (c).begin(), (c).end()
#define SZ(x) ((int)(x).size())

constexpr ll TEN(int n) { return (n == 0) ? 1 : 10 * TEN(n - 1); }

template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}

template <class T, class U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
    os << "(" << p.first << "," << p.second << ")";
    return os;
}

template <class T>
ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "{";
    rep(i, v.size()) {
        if (i) os << ",";
        os << v[i];
    }
    os << "}";
    return os;
}

#ifdef LOCAL
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
    cerr << " " << H;
    debug_out(T...);
}
#define debug(...) \
    cerr << __LINE__ << " [" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#define dump(x) cerr << __LINE__ << " " << #x << " = " << (x) << endl
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif

int cnt0[4010][4010], cnt1[4010][4010];

int main() {
    int N, K;
    cin >> N >> K;
    int sz = K * 2;

    rep(i, N) {
        int x, y;
        string c;
        cin >> x >> y >> c;
        x %= sz, y %= sz;
        rep(j, 2) {
            rep(k, 2) {
                if (c == "W") {
                    cnt0[x + j * sz][y + k * sz]++;
                } else {
                    cnt1[x + j * sz][y + k * sz]++;
                }
            }
        }
    }

    rep(i, 4010 - 1) {
        rep(j, 4010 - 1) {
            cnt0[i + 1][j + 1] += cnt0[i][j + 1] + cnt0[i + 1][j] - cnt0[i][j];
            cnt1[i + 1][j + 1] += cnt1[i][j + 1] + cnt1[i + 1][j] - cnt1[i][j];
        }
    }

    int ans = 0;

    rep(i, sz) {
        rep(j, sz) {
            int a = cnt0[i + K][j + K] - cnt0[i][j + K] - cnt0[i + K][j] +
                    cnt0[i][j];
            int b = cnt0[i + K * 2][j + K * 2] - cnt0[i + K][j + K * 2] -
                    cnt0[i + K * 2][j + K] + cnt0[i + K][j + K];
            int c = cnt1[i + K * 2][j + K] - cnt1[i + K][j + K] -
                    cnt1[i + K * 2][j] + cnt1[i + K][j];
            int d = cnt1[i + K][j + K * 2] - cnt1[i + K][j + K] -
                    cnt1[i][j + K * 2] + cnt1[i][j + K];
            chmax(ans, a + b + c + d);
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 125824
#include <bits/stdc++.h>
#define rep(i,n) for (int i=0; i<(n); ++i)
#define REP(i,n) for(int i=1;i<=(n);++i)
#define pa(x,n) for(ll i=0;i<n;i++){cout<<(x[i])<<" \n"[i==n-1];};
#define pb push_back

using ll = long long;
using namespace std;
using pint = pair<int,int>;
using pll = pair<ll,ll>;
const int INFint = 2e9+1;
const ll INFll = 2e18+1;
ll MOD=1e9+7;

ll gcd(ll a, ll b) { return __gcd(a,b); } //最大公約数
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; } //最大公倍数

// aのn乗をMODで割りながら計算する
ll modpow(ll a, ll n) {
  long long res = 1;
  while (n > 0) {
    if (n & 1) res = res * a % MOD;
    a = a * a % MOD;
    n >>= 1; // right shift
  }
  return res;
}

// MODを法としたaの逆元を計算する
ll modinv(ll a) {
  return modpow(a, MOD - 2);
}

ll countDivisors(ll n){
  ll cnt = 0;
  for (ll i = 1; i <= sqrt(n); i++) {
    if (n % i == 0) {
      if (n / i == i) cnt++;
      else cnt = cnt + 2;
    }
  }
  return cnt;
}
vector<ll> divisor(ll n){
  vector<ll> res;
  for (ll i(2);i*i<=n;i++){
    if (n%i==0){
      res.push_back(i);
      if (i != n/i) res.push_back(n/i);
    }
  }
  return res;
}

int main(){
  ll N;
  cin>>N;
  ll ans(0);
  ans += countDivisors(N-1);
  vector<ll> di = divisor(N);
  for(int k(0);k<int(di.size());k++){
    //cout << di[k] << endl;
    ll x = N;
    while(x % di[k] == 0){
      x /= di[k];
    }
    if ((x - 1) % di[k] == 0){
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}



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

#define  ll long long
#define  il inline
#define INF 0x3f3f3f3f
#define pii pair<int,int>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define dep(i,a,b) for(int i=(a);i>=(b);--i)

const int mod = 1e9 + 7;
const int maxn = 1e5 + 5;
const int maxm = 2e5 + 10;
const double PI = acos(-1.0);

int n,m;
int a[maxn],dp[maxn];

int main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    cin >> n;
    rep(i,1,n) cin >> a[i];
    rep(i,1,n) {
    	if(a[i] <= a[i - 1]) dp[i] = dp[i - 1] + 1;
    	else dp[i] = 0;
    }
    int ans = 0;
    rep(i,1,n) ans = max(ans,dp[i]);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int main() {
    FAST
    int n;
    cin>>n;
    string s;
    map<string,int>mp;
    for(int i=1;i<=n;i++){
        cin>>s;
        mp[s]++;
    }
    cout<<mp.size();
    return 0;
}

Measured memory_bytes: 19176
#include<stdio.h>

int main()
{
    int a,b;
    char choice;
    scanf("%d %c %d",&a,&choice,&b);
    switch(choice)
   {
    case '+':
    printf("%d\n",a+b);
    break;
    case '-':
    printf("%d\n",a-b);
    break;
    }
    return 0;
}


Measured memory_bytes: 128
def main():
    S = input()
    move = {
        "E": False,
        "W": False,
        "N": False,
        "S": False
    }
    for c in S:
        move[c] = True
    if move["E"] == move["W"] and move["N"] == move["S"]:
        print("Yes")
    else:
        print("No")


if __name__ == "__main__":
    main()


Measured memory_bytes: 38256
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define chmax(a,b) a=max(a,b);
#define chmin(a,b) a=min(a,b);
class Segtree{
	
	private:
	int V;
	typedef struct st{
		ll a,len;
	}st;
	st st0=(st){(ll)0,1};
	typedef struct op{
		ll a;
	}op;
	op op0=(op){0};
	st f(st p,st q){
		return (st){p.a+q.a};
	}
	void g(st &p,op q){
		p.a+=q.a*p.len;
	}
	void h(op &p,op q){
		p.a+=q.a;
	}
	
	st *dat;
	op *laz;
	
	st propagate(ll k){
		if(k<V){
			h(laz[k*2],laz[k]);
			h(laz[k*2+1],laz[k]);
		}
		g(dat[k],laz[k]);
		laz[k]=op0;
		return dat[k];
	}
	void upd(ll l,ll r,op p){
		l+=V,r+=V+1;
		for(ll d=20;d>=0;d--){
			propagate(l>>d);
			propagate(r>>d);
		}
		for(ll a=l,b=r;a<b;a>>=1,b>>=1){
			if(a&1){h(laz[a],p);a++;}
			if(b&1){b--;h(laz[b],p);}
		}
		for(ll a=l,b=r;a+b;a>>=1,b>>=1){
			dat[a/2]=f(propagate(a/2*2),propagate(a/2*2+1));
			dat[b/2]=f(propagate(b/2*2),propagate(b/2*2+1));
		}
	}
	st qry(ll l,ll r){
		l+=V,r+=V+1;
		for(ll d=20;d>=0;d--){
			propagate(l>>d);
			propagate(r>>d);
		}
		st L=st0,R=st0;
		for(ll a=l,b=r;a<b;a>>=1,b>>=1){
			if(a&1){L=f(L,propagate(a));a++;}
			if(b&1){b--;R=f(propagate(b),R);}
		}
		st res=f(L,R);
		return res;
	}
	
	public:
	void init(int ns){
		V=1;
		while(V<=ns)V*=2;
		dat=new st[2*V];
		laz=new op[2*V];
		for(int i=0;i<2*V;i++){
			dat[i]=st0;
			laz[i]=op0;
		}
		
		ll *len=new ll[2*V];
		for(int i=0;i<2*V;i++){
			if(V<=i)len[i]=1;
			else len[i]=len[i*2]*2;
			dat[i]=(st){0,len[i]};
			laz[i]=op0;
		}
	}
	void update(ll l,ll r,ll a){
		upd(l,r,(op){a});
	}
	ll query(ll l,ll r){
		st res=qry(l,r);
		return res.a;
	}
};
Segtree seg;

int main(){
	int n,q;
	cin>>n>>q;
	seg.init(n);
	rep(i,n)seg.update(i,i,0);
	while(q--){
		ll p,s,t,x;
		cin>>p;
		if(p==0){
			cin>>s>>t>>x;
			seg.update(s,t,x);
		}
		if(p==1){
			cin>>s;
			cout<<seg.query(s,s)<<"\n";
		}
	}
}



Measured memory_bytes: 11296
N = int(input())
L = list(map(int, input().split()))
answer = 0
for i in range(N-2):
    for j in range(i, N-1):
        for k in range(j, N):
            if L[i] == L[j] or L[j] == L[k] or L[k] == L[i]:
                continue
            if L[i] < L[j] + L[k] and abs(L[j] - L[k]) < L[i]:
                answer += 1
print(answer)

Measured memory_bytes: 9196
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define rep1(i, n) for (ll i = 1; i <= (ll)n; i++)
#define PI 3.14159265358979323846
#define vll vector<long long>
#define vvll vector<vector<long long>>
#define pll pair<long long, long long>
using namespace std;
using ll = long long;
using ld = long double;

// グローバル変数（入力）
ll n, m, k;
vll a, b;

void input() {
  cin >> n >> m >> k;
  a.resize(n);
  rep(i, n) { cin >> a[i]; }
  b.resize(m);
  rep(i, m) { cin >> b[i]; }
}

void solve() {
  // 累積わ
  vll ra(n + 1);
  vll rb(m + 1);
  ra[0] = 0;
  rb[0] = 0;
  rep1(i, n) { ra[i] = ra[i - 1] + a[i - 1]; }
  rep1(i, m) { rb[i] = rb[i - 1] + b[i - 1]; }
  ll ans = 0, j = m;
  rep(i, n + 1) {
    if (ra[i] > k) { break; }
    while (ra[i] + rb[j] > k) {
      j--;
    }
    ans = max(ans, i + j);
  }
  cout << ans << endl;
}

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


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

void solve()
{
	int n;
	cin >> n;
	
	for(ll a = -120; a<=120; a++)
	{
		for(ll b = -120; b<=120; b++)
		{
			ll A = a * a * a * a * a;
			ll B = b * b * b * b * b;
			if(A-B == n) 
			{
				cout << a << " " << b << "\n";
				return ;
			}
		}
	}
}

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



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

lis_A = []
lis_B = []

for i in range(N):
    a,b = map(str,input().split())
    lis_A.append(a)
    lis_B.append(int(b))
temp = input()
Sum = sum(lis_B)
ans = Sum - sum(lis_B[:lis_A.index(temp)+1])
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define _ ios_base::sync_with_stdio(0);cin.tie(0);
#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;
using P=pair<int,int>;
const int INF=1<<29;
const int MAX_V=100010;
vector<int> children[MAX_V];

int dep[MAX_V];
int par[MAX_V][20];
void dfs(int node,int p,int d){
  dep[node]=d;
  for(int child:children[node]){
    if(child==p)continue;
    par[child][0]=node;
    dfs(child,node,d+1);
  }
}
int lca(int a,int b){
  if(dep[a]<dep[b])swap(a,b);
  REP(i,20) if((dep[a]-dep[b])&(1<<i))a=par[a][i];
  if(a==b)return a;
  for(int i=19;i>=0;i--) if(par[a][i]!=par[b][i]) a=par[a][i],b=par[b][i];
  return par[a][0];
}

int main(){_;
  int n,q,k,u,v;
  cin>>n;
  REP(i,n){
    cin>>k;
    children[i]=vector<int>(k);
    REP(j,k)cin>>children[i][j];
  }
  dfs(0,-1,0);
  REP(i,19) REP(j,n) par[j][i+1]=par[par[j][i]][i];
  cin>>q;
  REP(i,q){
    cin>>u>>v;
    cout<<lca(u,v)<<endl;
  }
}

Measured memory_bytes: 21488
#include<bits/stdc++.h>
using namespace std;
#define ios ios_base::sync_with_stdio(0);cin.tie(0)
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
typedef long long ll;
#define pri(n) printf("%d\n",n)
#define lpri(n) printf("%lld\n",n);
#define rep(i,st,ed) for(int i=st;i<ed;i++)
#define F first
#define S second
#define pb(n) push_back(n)
const int N=100005;
const ll M=1e9+7;
const ll INF=1e18;

ll dp[105][100005];

int main()
{
	int n,sum,x;
	scn(n);scn(sum);

	for(int i=0;i<n;i++)
	{
		scn(x);
		if(i)
		{
			for(int j=0;j<=x;j++)
			{
				dp[i][j]=dp[i-1][j];
			}
			x++;
			for(int j=x;j<N;j++)
			{
				dp[i][j]=(dp[i-1][j]-dp[i-1][j-x]+M)%M;
			}
		}
		else
		{
			for(int j=0;j<=x;j++)
				dp[i][j]=1;
		}
		if(i<n-1)
		{
			for(int j=1;j<N;j++)
			{

				dp[i][j]+=dp[i][j-1];
				dp[i][j]%=M;
			}
		}
	}
	lpri(dp[n-1][sum]);
}

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

const ll MOD = (ll)1e9+7;

ll s2(int a, int b){
    return ((ll)b*(b+1)/2-(ll)a*(a-1)/2)%MOD;
}

template<class T> T powmod(T x, ll n, ll m)
{
    T r = 1;
    T a = x % m;
    while (n>0)
    {
        if (n & 1)
            r = (r*a)%m;
        a = (a*a)%m;
        n = n >> 1;
    }
    return r;
}

ll f(int x, int q){
    if (q==0)
        return x;
    ll aux = powmod(3ll, q-1, MOD);
    return aux*(x*3ll+q)%MOD;
}

int main(int argc, char** argv) {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    if (argc == 2 && atoi(argv[1]) == 123456789)
        freopen("d:\\code\\cpp\\stdin", "r", stdin);

    string s;
    cin >> s;

    ll cntc = 0;
    for(int i=0; i<s.length(); i++)
        cntc += s[i]=='C';
    ll cntqright = 0;
    for(int i=0; i<s.length(); i++)
        cntqright += s[i]=='?';

    ll sol = 0;
    ll cnta = 0;
    ll cntqleft = 0;
    for(int i=0; i<s.length(); i++){
        if (s[i]=='A')
            cnta++;
        else if (s[i]=='B'){
            //sol = (sol + cnta*cntc%MOD)%MOD;
            sol = (sol + f(cntc, cntqright)*f(cnta, cntqleft) %MOD)%MOD;
        }
        else if (s[i]=='C')
            cntc--;
        else if (s[i]=='?'){
            cntqright--;
            //sol = (sol + s2(cntc, cntc+cntqright)*s2(cnta, cnta+cntqleft) %MOD)%MOD;
            sol = (sol + f(cntc, cntqright)*f(cnta, cntqleft) %MOD)%MOD;
            cntqleft++;
        }
    }
    cout << sol;

    return 0;
}

Measured memory_bytes: 512
X=int(input())

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

Measured memory_bytes: 9024
#include <bits/stdc++.h>
#define MODNum 1000000007
#define REP(type, i, a, b) for( type i = a; i < b; i++ )
typedef long long ll;

using namespace std;

int main (void) {
    ll H, ans;
    ll counter=0;
    scanf("%lld", &H);
    ans = 1;
    while ( H > 1 ){
        H /= 2;
        counter++;
        ans += pow(2, counter);
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 256