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

#define ll long long
#define ld long double
#define pb push_back
#define pr pair<ll, ll>
#define vct vector<ll>
#define vpt vector<pr>
#define st set<ll>
#define pq priority_queue<ll>
#define mat vector<vector<ll> >
#define all(x) x.begin(),x.end()
#define F(i, n) for (i = 0; i < (1LL*n); i++)
#define Fr(i, n) for (i = n - 1; i >= 0; i--)

struct custom_hash
{
    static uint64_t splitmix64(uint64_t x)
    {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }
    size_t operator()(uint64_t x) const
    {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
#define umap unordered_map<long long, long long, custom_hash>
void prv(vct v)
{
    for (ll i = 0; i < v.size(); i++)
        cout << v[i] << " ";
    cout << "\n";
}
ll poww(ll x, ll y, ll m)
{
    ll res = 1;
    while (y)
    {
        if (y % 2 == 0)
        {
            x = (x * x) % m;
            y = y / 2;
        }
        else
        {
            res = (res * x) % m;
            y--;
        }
    }
    return res;
}
void deb(string s, ll n)
{
    cout << s << " : " << n << "\n";
}
void prn(ll n) { cout << n << "\n"; }
void prs(string n) { cout << n << "\n"; }

mat mt;
void setmtsize(ll m,ll n, ll ini=0){
    mt.resize(m,vector<ll>(n,ini));
}
void prmt(mat m){
    for(ll i=0;i<(1LL*m.size());i++)prv(m[i]);
}
vct divsors(ll n)
{
    vct ans;//ans.push_back(1);
    for(ll i=1;i<=sqrt(n);i++)
    {if(n%i==0){ans.push_back(i);if(i!=(n/i))ans.push_back(n/i);}}
    sort(ans.begin(),ans.end());
    return ans;
}
vct sieve(ll n){
    vct ans(n+1,-1);
    for(ll i=2;i<=n;i++){
        if(ans[i]==-1){
            for(ll j=i;j<=n;j+=i)if(ans[j]==-1)ans[j]=i;
        }
    }
    return ans;
}
ll n, k, m, l, r, x, y, z, ans=0;
ll t, t1, t2;
// ll q;
ll i, j;
ll a, b, c;
ll mod = 1000000007;
ll cas=0;

void solve()
{
    cin>>n;
    vct v(n);
    F(i,n)cin>>v[i];
    ans=0;
    for(i=0;i<n-2;i++){
        for(j=i+1;j<n-1;j++){
            for(k=j+1;k<n;k++){
                ll c1,c2,c3;
                c1=v[i];c2=v[j];c3=v[k];
                if((c1==c2)||(c1==c3)||(c3==c2))continue;
                if((c2+c1>c3) && (c2+c3>c1) && (c3+c1>c2))ans++;
            }
        }
    }
    prn(ans);
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    // freopen("input.txt", "r", stdin); 
    // freopen("output.txt", "w", stdout);
    ll t = 1;
    // cin >> t;
    cas=1;
    // stress();
    while (t--){
        solve();
        cas++;
    }
    return 0;
}

Measured memory_bytes: 3676
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;

#define MAX (ll(1e6)+7)
#define MOD (ll(1e9)+7)
#define INF (ll(1e18)+7)

#define elif else if
#define def inline auto

#define for_in(a,b,c) for(ll a=(b);a<(c);++a)
#define repeat(a,b) for(ll a=0;a<(b);++a)
#define repeat_down(a,b) for(ll a=(b);a>=0;--a)

#define array_size(a) ll(sizeof(a)/sizeof(a[0]))

#define def_input(...) ll __VA_ARGS__;input(__VA_ARGS__)
#define if_print(a,b,c) output(a?#b:#c)
#define print(a) output(#a)
#define fout(a) cout<<fixed<<setprecision(10)<<a
#define fillout(a,b,c) cout<<setfill(a)<<setw(b)<<right<<c
#define ios_boost cin.tie(0);ios::sync_with_stdio(false)

#define digit(a) to_string(a).length()
#define lcm(a,b) a*b/gcd(a,b)

char N='\n',S=' ';
const ll primes[15]={2,3,5,7,11,13,17,19,23,29,31,37,41,43,47};
ll temp_index;

inline void input(){}
template<class T,class...A>inline void input(T&&t,A&&...a){cin>>t;input(move(a)...);}
template<class T>inline void output(T&t){cout<<t<<N;}
template<class T,class...A>inline void output(T t,A...a){cout<<t<<S;output(move(a)...);}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&x:v)i>>x;return i;}
template<class T>ostream&operator<<(ostream&o,vector<T>const&v)
{bool d=0;for(T x:v){if(d)o<<S<<x;else{o<<x,d=1;}}o<<N;return o;}

def get_ll(){ll x;input(x);return x;}
def gcd(ll a,ll b){ll c;while(a){c=a;a=b%a;b=c;}return b;}

inline bool is_prime(ll a){
    if(a<48){for_in(i,0,15)if(primes[i]==a)return 1;}
    elif(a<2809)return gcd(614889782588491410,a)==1;
    else {print(Error:Argument>2808);exit(1);}return 0;
}

template<class T>def sum_array(T&a,T&b){
    b[0]=a[0];
    for_in(i,1,array_size(a))b[i]=a[i]+b[i-1];
}

map<string,ll>LIST;
map<ll,string>VLIST;

def val(string a){
    auto IT=LIST.find(a);
    if(IT!=LIST.end()){
        return LIST[a];
    }
    else{
        ll v=LIST.size();
        LIST[a]=v;
        VLIST[v]=a;
        return v;
    }
}

ll a,b,c,d;ll n,M,Q;ll B[600][600];
int main(){
    ios_boost;
    cin>>n>>M>>Q;
    ll L,R,p,q;
    repeat(i,M){
        cin>>L>>R;
        B[L][R-L]++;
    }
    repeat(i,n+1){
        for_in(j,1,n+1){
            B[i][j]+=B[i][j-1];
        }
    }

    repeat(i,Q){
        cin>>p>>q;
        ll s=0;
        for_in(i,p,q+1){
            s+=B[i][q-i];
        }
        cout<<s<<"\n";
    }

}

//for compilation: g++ -o _ _.cpp -std=c++14 (or 17)
//
//for fastening: g++ -O2 -o _ _.cpp -std=c++14 (or 17)
//for fastening: g++ -O3 -mtune=native -march=native -o _ _.cpp -std=c++14 (or 17)


Measured memory_bytes: 3328
import itertools
import math
import fractions
import functools

n, m, x = map(int, input().split())

c = []
a_do = []
for i in range(n):
    a = list(map(int, input().split()))
    c.append(a[0])
    a_do.append(a[1:])

# minimum = 10**20
# for pat in range(0, (1<<n)): #参考書の選び方の全パターン
#     cost = 0
#     rikaido = [0] * m
#     for i in range(n):
#         if((pat >> i) & 1): #i番目の参考書を読む
#             cost += c[i]
#             for k in range(m):
#                 rikaido[k] += a_do[i][k]
#     ok = True
#     for k in range(m):
#         if(rikaido[k] < x):
#             ok = False
#     if(ok):
#         minimum = min(minimum, cost)

# if(minimum == 10**20):
#     print(-1)
# else:
#     print(minimum)

minimum = 10**20

nums = []
for i in range(n):
    nums.append(i)

temp = []
for i in range(1, n+1):
    for v in itertools.combinations(nums, i):
        cost = 0
        rikaido = [0] * (m)
        for j in range(len(v)):
            cost += c[v[j]]
            for k in range(m):
                rikaido[k] += a_do[v[j]][k]

        ok = True
        for k in range(m):
            if rikaido[k] < x:
                ok = False

        if(ok):
            minimum = min(minimum, cost)


#         temp.append(rikaido)

# minimum = 10**20
# for i in range(len(temp)):
#     for j in range(1, m+1):
#         if temp[i][j] < x:
#             break
#         minimum = min(minimum, temp[i][0])

if(minimum == 10**20):
    print(-1)
else:
    print(minimum)

Measured memory_bytes: 73268
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <utility>
#include <iostream>
#include <algorithm>
#include <functional>

using namespace std;

#define INF (1 << 30)
#define INFL (1LL << 62)
#define MOD7 1000000007
#define MOD9 1000000009
#define EPS 1e-10

#define ll long long
#define ull unsigned long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pul pair<ull, ull>
#define all(a) (a).begin(), (a).end()
#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);--i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)

void YES() { cout << "YES" << endl; }
void NO() { cout << "NO" << endl; }
void Yes() { cout << "Yes" << endl; }
void No() { cout << "No" << endl; }
void yes() { cout << "yes" << endl; }
void no() { cout << "no" << endl; }
void digit(int d) { cout << fixed << setprecision(d); }
void IOup() { cin.tie(0); ios::sync_with_stdio(false); }

class RSQ {
	vector<ll> data;
	int size;
	int suffix;

public:
	RSQ() {}
	RSQ(int n) {
		suffix = -1;
		resize(n);
	}

	void resize(int n) {
		size = 1;
		while (size < n) {
			size <<= 1;
		}
		data.resize(size * 2 - 1, 0);
	}

	ll& operator[](int i) {
		update();
		suffix = i;
		return data[i + size - 1];
	}

	void update() {
		if (suffix < 0)
			return;
		int k = suffix + size - 1;
		suffix = -1;
		while (k > 0) {
			k = (k - 1) / 2;
			data[k] = data[k * 2 + 1] + data[k * 2 + 2];
		}
	}

	ll sum(int a, int b) {
		update();
		suffix = -1;
		return sum(a, b, 0, 0, size);
	}

	ll sum(int a, int b, int k, int l, int r) {
		if (r <= a || b <= l)
			return 0;
		if (a <= l && r <= b)
			return data[k];
		int m = (l + r) / 2;
		return sum(a, b, k * 2 + 1, l, m) + sum(a, b, k * 2 + 2, m, r);
	}
};

int main() {
	int n, q, c, x, y;
	cin >> n >> q;
	RSQ rsq(n + 1);
	while (q--) {
		cin >> c >> x >> y;
		if (c) {
			cout << rsq.sum(x, y + 1) << endl;
		}
		else {
			rsq[x] += y;
		}
	}

	return 0;
}

Measured memory_bytes: 4944
/*==============================================*\
Codeforces ID:    mdshihab
                                                  |
Name:     Md. Shihabul Minhaz                     |
Study:      CSE, JKKNIU                           |
Address:  Trishal, Mymensingh, Bangladesh         |
                                                  |
 mail:   mdshihabul20171@gmail.com                |
 FB  :   fb.com/mdshihabul.minhaz.7               |
 github: Shihabulminhaz                           |
stopstalk :  mdshihab                             |
                                                  |
@uthor   Md. Shihabul Minhaz (shihab)             |
\*===============================================*/


#include<bits/stdc++.h>
using namespace std;
#define fi(a) scanf("%d",&a);
#define fli(a) scanf("%ld",&a);
#define fll(a) scanf("%lld",&a);
#define pi(a) printf("%d\n",a);
#define ppi(i,a) printf("Case %d: %d\n",i,a);
#define ll long long
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
void FI()
{
#ifndef ONLINE_JUDGE
    freopen("C:\\Users\\SHIHAB\\Desktop\\input.in","r",stdin);
#endif // ONLINE_JUDGE
}

int main()
{
    fast
   // FI(); /// skip this line for compile
    int n,k,ans=1,x;
    cin >> n >> k;
    x = n;
    if(k==1){
        cout << 0 << endl;
        return 0;
    }
    while(x<k){
        x+=n-1;
        ans++;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3544
//Zory-2019
#include<cmath>
#include<ctime>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<stack>
#include<bitset>
#include<vector>
#include<algorithm>
#include<iostream>
#include<deque>
using namespace std;
namespace mine
{
	typedef long long ll;
	#define double long double
	const int INF=0x3f3f3f3f;
	ll qread()
	{
		ll ans=0;char c=getchar();int f=1;
		while(c<'0' or c>'9') {if(c=='-') f=-1;c=getchar();}
		while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
		return ans*f;
	}
	void write(ll num)
	{
		if(num<0) {num=-num;putchar('-');}
		if(num>9) write(num/10);
		putchar('0'+num%10);
	}
	void writeln(int num){write(num);puts("");}
	#define FR first
	#define SE second
	#define MP make_pair
	#define pr pair<ll,ll>
	#define PB push_back
	inline void chmax(ll &x,ll y) {x=x>y?x:y;}
	inline void chmin(ll &x,ll y) {x=x<y?x:y;}

	const int MAX_N=2e5+10;
	int c[MAX_N],lst[MAX_N],pos[MAX_N];
	const int MOD=1e9+7;
	ll f[MAX_N],g[MAX_N];
	void main()
	{
		int n;scanf("%d",&n);
		for(int i=1;i<=n;i++)
		{
			c[i]=qread();
			lst[i]=pos[c[i]];
			pos[c[i]]=i;
		}
		f[0]=g[0]=1;
		for(int i=1;i<=n;i++)
		{
			int j=lst[i];
			if(j<i-1 and j!=0)
			{
				f[i]=g[j];
			}
			// printf("f[%d]=%lld\n",i,f[i]);
			g[i]=(g[i-1]+f[i])%MOD;
		}
		printf("%lld",g[n]);
 	}
};
int main()
{
	srand(time(0));
	mine::main();
}


Measured memory_bytes: 5760
n=int(input())
d,x=map(int,input().split())
a=[]
b=[]
for i in range(n):
    c=int(input())
    a.append(c)
for l in range(n):
    k=0
    for j in range(d+1):
        k=j*a[l]+1
        if k>d:
            break
    b.append(j)
print(sum(b)+x)    
        
    



Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
//const int MOD=1e9+7;
//const int MOD=998244353;
const int INF=1e9;
const long long LINF=1e18;
#define int long long
//template
template <typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}
int pw(int n,int k,int MOD){
  int res=1;
  while(k){
    if(k&1)res*=n;res%=MOD;
    n*=n;n%=MOD;
    k>>=1;
  }
  return res;
}
//main
signed main(){
  int N,M;cin>>N>>M;
  typedef pair<int,int> P;
  std::vector<P> e[N];
  while(M--){
    int a,b,x;cin>>a>>b>>x;a--;b--;
    e[a].push_back(P(b,x));
    e[b].push_back(P(a,-x));
  }
  int mod[5]={1000000007,998244353,1000000009,1000000033,2147483647};
  for(int i=0;i<5;i++){
    int MOD=mod[i];
    std::vector<int> d(N,-1);
    for(int i=0;i<N;i++){
      if(~d[i])continue;
      d[i]=1;
      queue<int> que;
      que.push(i);
      while(que.size()){
        int p=que.front();que.pop();
        for(auto q:e[p]){
          int v=q.first,x=q.second;
          if(x<0)x=pw(-x,MOD-2,MOD);
          if(~d[v]){if(d[v]!=(d[p]*x)%MOD)fin("No");}
          else{
            d[v]=d[p]*x%MOD;
            que.push(v);
          }
        }
      }
    }
  }
  fin("Yes");
}



Measured memory_bytes: 11612
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
ll n,m,par[100005],dw[100005];
ll find(ll x){
	if(par[x]==x)return x;
	ll r=find(par[x]);
	dw[x]+=dw[par[x]];
	return par[x]=r;
}
bool same(ll x,ll y){
	return find(x)==find(y);
}
void unit(ll x,ll y,ll w){
	find(x),find(y);
	w+=dw[x],w-=dw[y];
	x=find(x),y=find(y);
	if(x==y)return;
	par[y]=x;
	dw[y]+=w;
}
ll diff(ll x,ll y){
	find(x),find(y);
	return dw[y]-dw[x];
}
int main(void){
	while(1){	
		scanf("%lld%lld",&n,&m);
		if(n==0&&m==0)return 0;
		for(int i=0;i<n;i++)par[i]=i,dw[i]=0;
		while(m--){
			char c;
			scanf(" %c",&c);
			if(c=='!'){
				ll a,b,w;
				scanf("%lld%lld%lld",&a,&b,&w);
				a--,b--;
				unit(a,b,w);
			}else{
				ll a,b;
				scanf("%lld%lld",&a,&b);
				a--,b--;
				if(!same(a,b))printf("UNKNOWN\n");
				else printf("%lld\n",diff(a,b));
			}
		}
	}
}


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

#define REP(i, l, n) for(int i=(l), i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back

ll gcd(ll a,ll b){return b ? gcd(b,a%b) : a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

char alpha[26] = {'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};

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

int main(){
    int n, m; cin >> n >> m;
    ll sum = 0;
    REP(i, 0, m){ll a; cin >> a; sum += a;}
    if(n-sum >= 0){
        cout << n-sum << endl;
    }else{
        cout << -1 << endl;
    }
}

Measured memory_bytes: 3636
import sys
sys.setrecursionlimit(200010)
def main():
    input = sys.stdin.readline
    N, Q = map(int,input().split())
    T = [[] for k in range(N)]
    V = [0]*N
    for _ in range(N-1):
        a, b = map(int,input().split())
        T[a-1].append(b-1)
        T[b-1].append(a-1)
    for q in range(Q):
        p, x = map(int,input().split())
        V[p-1] += x

    def dfs(mae,ima):
        for tsugi in T[ima]:
            if tsugi != mae:
                V[tsugi] += V[ima]
                dfs(ima,tsugi)
    dfs(-1,0)
    print(*V)
if __name__ == '__main__':
    main()


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

int main(){
int n;
cin>>n;
vector<int>a(n),b(n);
for(int i=0;i<n;i++)cin>>a.at(i);
for(int i=0;i<n;i++)cin>>b.at(i);
int sum=0;
for(int i=0;i<n;i++){
	if(a.at(i)-b.at(i)<=0)continue;
    sum+=a.at(i)-b.at(i);
}
cout<<sum<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using pp=pair<int,int>;

int gcd(int a, int b, int c) {
  int m, n;
  for (int i=1; i<=min(a,b); i++) {
    if (a%i==0 && b%i==0) {m=i;}
  }
  for (int i=1; i<=min(m,c); i++) {
    if (m%i==0 && c%i==0) {n=i;}
  }
  return n;
}


int main() {
  int K, S=0;
  cin >> K;
  for (int i=1; i<=K; i++) {
    for (int j=1; j<=K; j++) {
      for (int k=1; k<=K; k++) {
        S+=gcd(i,j,k);
      }
    }
  }
  cout << S << endl;
}

Measured memory_bytes: 3636
import itertools
N,M,Q=map(int,input().split())
L=[]
for q in range(Q):
    L.append(list(map(int,input().split())))

A = itertools.combinations_with_replacement([q for q in range(1,(M+1))], N)
count=[]
for a in A:
    tmp=0
    for l in L:
        
        if a[l[1]-1] - a[l[0]-1] == l[2]:
            tmp+=l[3]
    count.append(tmp)

print(max(count))


Measured memory_bytes: 12532
import sys

a = int(raw_input())
b = int(raw_input())
c = int(raw_input())
x = int(raw_input())
ans = 0

for i in range(a+1):
    for j in range(b+1):
        for k in range(c+1):
            if 500* i + 100 * j + 50 * k == x:
                ans += 1
                
print(str(ans))

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

int main(){
    std::string s;
    std::cin>>s;
    std::string t;
    for(int i=0;i<s.size();++i){
        if(i+1<s.size()&&s[i]=='B'&&s[i+1]=='C'){
            t.push_back('D');
            i++;
        }
        else t.push_back(s[i]);
    }
    long long cnt=0,ans=0;
    for(int i=0;i<t.size();++i){
        if(t[i]=='A') cnt++;
        else if(t[i]=='D') ans+=cnt;
        else cnt=0;
    }
    std::cout<<ans<<'\n';
}


Measured memory_bytes: 776
#include <bits/stdc++.h>
#define ll long long
#define uint unsigned long long
#define ls rt << 1
#define rs rt << 1 | 1
#define pb push_back
#define mp make_pair
#define pii pair<int, int>
#define X first
#define Y second
#define pcc pair<char, char>
#define rep(i, x, y) for(int i = x; i <= y; i ++)
#define rrep(i, x, y) for(int i = x; i >= y; i --)
#define eps 1e-9
using namespace std;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
const ll mod = 1e9 + 7;
int H, W, A, B;
ll jc[200010], ny[200010];

ll qpow(ll x, int y)
{
	ll ret = 1;
	while(y > 0)
	{
		if(y % 2 == 1) ret = (ll)(ret * x) % mod;
		x = (ll)(x * x) % mod;
		y /= 2;
	}
	return ret;
}
ll C(int p, int q)
{
	if (q < 0 || p < q) return 0;
	return jc[p] * ny[q] % mod * ny[p - q] % mod;
}

ll ks(int p, int q)
{
	return C(p + q - 2, q - 1);
}

int main()
{
	cin >> H >> W >> A >> B;
	jc[0] = 1;
	ny[0] = 1;
	rep(i, 1, 200000)
	{
		jc[i] = (jc[i - 1] * i) % mod;
		ny[i] = qpow(jc[i], mod - 2);
//cout << jc[i] << " " <<ny[i] << endl;
	}
	ll ret = 0;
	rep(i, 0, H - A - 1)
		ret = ret + ks(i + 1, B) * ks(H - i, W - B) % mod, ret %= mod;
	printf("%lld\n", ret);
	return 0;
}


Measured memory_bytes: 3328
import java.util.Scanner;

public class Main {
    public static void run(int N, int A) {
        int ac = N % 500;

        System.out.println(ac <= A ? "Yes" : "No");
    }

    public static void runInput() {
        Scanner scanner = new Scanner(System.in);

        int N = scanner.nextInt();
        int A = scanner.nextInt();
        run(N, A);
    }

    public static void main(String args[]) {
        runInput();
    }
}


Measured memory_bytes: 23764
def tempDif(h,T,A):
  temp = T - 0.006*h
  dif = A -temp
  if dif < 0:
    dif = -dif
  return dif
 
N = int(input())
T,A = map(int,input().split())
lis = [int(n) for n in input().split()]
 
lisnew = [tempDif(H,T,A) for H in lis]
print(lisnew.index(min(lisnew))+1)

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

#define FOR(a, b, c) for(int a = b; a <= c; ++a)
#define fi first
#define se second
#define pb push_back
#define int long long

typedef pair<int, int> ii;
typedef pair<int, ii> iii;

const int N = 1e5 + 10;
const int oo = 1e18;

int n, a, b;

signed main()  {
//    freopen("test.inp", "r", stdin);
//    freopen("test.out", "w", stdout);
    ios_base::sync_with_stdio(false); cout.tie(0);
    cin >> n >> a >> b;
    cout << min(a, b) << ' ' << max(0ll, a + b - n);
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<iostream>
using namespace std;
int main ()
{
    int a, b, c, x, i, j, k, cnt=0;
    cin>>a>>b>>c>>x;
    for(i=0;i<= a&&500*i<=x;i++)
    {
        for(j=0;j<=b&&100*j+500*i<=x;j++)
        {
            for(k=0;k<=c&&50*k+100*j+500*i<=x;k++)
            {
                if(500*i+100*j+50*k==x)
                {
                    cnt++;
                }
            }
        }
    }
    cout<<cnt<<endl;;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <math.h>
#include <queue>
#include <string.h>
#include <stdlib.h>
#include <map>
#include <set>
using namespace std;
typedef unsigned long long ull;
typedef  long long ll;

map<ll, ll> prime_factor(ll a) {
	map<ll, ll> ret;
	for (ll i = 2; i * i <= a; i++) {
		while (a %i == 0 && a != 0) {
			ret[i]++;
			a /= i;
		}
	}
	if (a != 1) {
		ret[a]++;
	}
	return ret;
}

int main()
{
	ll n;
	cin >> n;
	map<ll, ll> a = prime_factor(n);

	map<ll, ll>::iterator it;
	cout << n << ":";
	for (it = a.begin(); it != a.end(); it++) {
		for (ll i = 0; i < it->second; i++) {
			cout << " "<< it->first;
		}

	}
	cout << endl;


	return 0;
}



Measured memory_bytes: 3080
import java.util.*;

public class Main{

	public static void main(String[] args){

		Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
      
        int most = X / 500;
        int least = (X-most*500)/5;
      
        int ans = most*1000 + least*5;
        System.out.println(ans);
	}

}

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

int main(void){
  int N;
  cin >> N;
  int d[N], sum = 0;
  for (int i = 0; i < N; i++){
	cin >> d[i];
  }
  for(int i = 0; i < N-1; i++){
	for(int j = i+1; j < N; j++){
		sum +=  d[i]*d[j];
    }
  }
  cout << sum << endl;
  	
	return 0;
  
}

Measured memory_bytes: 256
n=int(input())
ab=[list(map(int,input().split())) for i in range(n)]
ab.sort(key=lambda x: x[1])
t=0
for x in ab:
  if t+x[0] <= x[1]:
    t += x[0]
  else:
    print('No')
    break
else:
  print('Yes')


Measured memory_bytes: 116112
#include <cstdio>
#include <algorithm>
using namespace std;

int n,a[100005],f[100005];

int main(void){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	scanf("%d",&a[i]);
	f[1]=0;
	f[0]=0x3f3f3f3f;
	for(int i=2;i<=n;i++){
		f[i]=min(f[i-1]+abs(a[i]-a[i-1]),f[i-2]+abs(a[i]-a[i-2]));
	}
	printf("%d",f[n]);
}

Measured memory_bytes: 896
#include <iostream>
#include <vector>

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

bool is_same(int a, int b, int c) {
  return (a==b)&&(b==c);
}

bool is_bingo(const std::vector<int>& c) {
  rep(i,3)
  if (is_same(c[3*i+0], c[3*i+1], c[3*i+2])) return true;

  rep(i,3)
  if (is_same(c[i+0], c[i+3], c[i+6])) return true;

  if (is_same(c[0], c[4], c[8])) return true;
  if (is_same(c[6], c[4], c[2])) return true;
  return false;
}

int main(int argc, char** argv) {
  std::vector<int> card(9);
  rep(i,9) std::cin >> card[i];
  int N;
  std::cin >> N;
  std::vector<int> b(N);
  rep(i, N) std::cin >> b[i];
  rep(i,N) {
    rep(j,9) {
      if (card[j] == b[i]) {
        card[j] = 0;
        break;
      }
    }
  }
  if (is_bingo(card)) {
    std::cout << "Yes\n";
  } else {
    std::cout << "No\n";
  }
}


Measured memory_bytes: 888
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <functional>
#include <list>
#include <bitset>
#include <numeric>
#include <utility>
#define INF 1e9
#define MOD 1000000007
#define MAX 210000
#define ll long long
using namespace std;
typedef unsigned long long ull;
typedef pair<int, int> p;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin>>n;
    vector<int> v(n);
    for(int i=0;i<n;i++){
        cin>>v[i];
        v[i]--;
    }
    vector<p> x;
    for(int i=0;i<n;i++){
        x.push_back(make_pair(i,0));
    }
    for(int i=0;i<n;i++){
        if(v[i]==0){
            x[0].second=1;
        }
        else{
            x[v[i]].second=1+x[v[i]-1].second;
        }
    }
    int max=0;
    for(int i=0;i<n;i++){
        if(x[i].second>max){
            max=x[i].second;
        }
    }
    cout<<n-max;
    return 0;
}

Measured memory_bytes: 3316
#include<cstdio>
#include<iostream>
#include<cstring>
#define RG register
using namespace std;
int n,cnt=1;
long long ans;
template<typename I> inline void read(I &ot){
	I ch=getchar(), x=0, f=1;
	while(ch<'0' || ch>'9'){if(ch=='-') f=-1; ch=getchar();	}
	while(ch>='0' && ch<='9'){x=x*10+ch-'0'; ch=getchar();	}
	ot=x*f;}
template<typename I, typename... U> inline void read(I &x,U&... y){read(x); read(y...);}
int main()
{
	//freopen("Greedy Customers.in","r",stdin);
	read(n);
	for(RG int i=1,a;i<=n;i++)
	{
		read(a);
		if(a<cnt) continue;
		if(a==cnt) cnt++;
		else
		{
			if(a%cnt==0) ans+=a/cnt-1;
			else ans+=a/cnt;
		}
		if(cnt==1) cnt++;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 384
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations,product#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal

def input(): 
    x=sys.stdin.readline()
    return x[:-1] if x[-1]=="\n" else x
def printe(*x):print("## ",*x,file=sys.stderr)
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def binr(x): return bin(x)[2:]
def bitcount(x): #xは64bit整数
    x= x - ((x >> 1) & 0x5555555555555555)
    x= (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x= (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f 
    x+= (x >> 8); x+= (x >> 16); x+= (x >> 32) 
    return x & 0x7f

def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    #N = int(input())
    R,C,K = map(int, input().split())
    #A = tuple(map(int, input().split())) #1行ベクトル
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    base=5000
    S=[]
    for i in range(K):
        r,c,v = map(int, input().split())
        r-=1
        c-=1
        S.append((r*base+c,v))

    S.sort(key=itemgetter(0))


    p=0
    dp=[0]*C
    for i in range(R):
        dpi=[[0] * 4 for _ in range(C)]
        for j in range(C):
            cv=0
            
            if p<K and i*base+j==S[p][0]:
                cv=S[p][1]
                p+=1
            if j>0:
                dpi[j]=copy(dpi[j-1])
            if i>0:
                dpi[j][0]=max(dp[j],dpi[j][0])
            if cv!=0:
                for k in range(2,-1,-1):
                    dpi[j][k+1]=max(dpi[j][k]+cv,dpi[j][k+1])
                #printe(dp)
            dp[j]=max(dpi[j])
    print(dp[-1])



if __name__ == "__main__":
    main()


Measured memory_bytes: 177220
#include<bits/stdc++.h>
using namespace std;
#define Maxn 100005
#define inf 0x3f3f3f3f
typedef long long ll;
int n,tot=1,s,t,cnt_zhi;
int hea[Maxn],ds[Maxn],pre[Maxn],pian[Maxn],pr[Maxn],zhi[Maxn];
int ver[Maxn*2],nex[Maxn*2];
bool wh[Maxn]={false};
void add(int u,int v)
{
	 ver[++tot]=v,nex[tot]=hea[u],hea[u]=tot;
	 ver[++tot]=u,nex[tot]=hea[v],hea[v]=tot;
}
queue<int> q;
void dfs(int St)
{
	 memset(ds,inf,sizeof(ds));
	 ds[St]=0;
	 q.push(St);
	 pre[t]=-1;
	 while(!q.empty())
	 {
	 	 int cur=q.front();
	 	 q.pop();
	 	 for(int i=hea[cur];i;i=nex[i])
	 	 {
	 	 	 if(ds[cur]+1<ds[ver[i]])
	 	 	 {
	 	 	 	 ds[ver[i]]=ds[cur]+1;
	 	 	 	 pre[ver[i]]=i;
	 	 	 	 q.push(ver[i]);
			 }
		 }
	 }
	 int MAX=-1,num;
	 for(int i=1;i<=n;i++) if(MAX<ds[i]) MAX=ds[i],num=i;
	 if(t)
	 {
	 	 s=num;
	 	 int x=s;
	 	 while(x!=t)
	 	 {
	 	 	 wh[x]=true;
	 	 	 zhi[++cnt_zhi]=x;
	 	 	 int i=pre[x];
	 	 	 x=ver[i^1];
		 }
		 wh[t]=true;
		 zhi[++cnt_zhi]=t;
	 }
	 else t=num;
}
int cnt;
bool Findpian(int x,int fa,int dis)
{
	 if(dis>=2) return false;
	 pian[x]=dis,cnt+=1;
	 bool pan=true;
	 for(int i=hea[x];i;i=nex[i])
	 {
	 	 if(ver[i]==fa || wh[ver[i]]) continue;
	 	 if(!Findpian(ver[i],x,dis+1)) return false;
	 }
	 return true;
}
bool ok()
{
	 for(int i=1;i<=cnt_zhi;i++)
	 {
	 	 cnt=0;
	 	 if(!Findpian(zhi[i],0,0)) return false;
	 	 pr[i]=cnt-1;
	 }
	 return true;
}
void print()
{
	 bool pan=true;
	 for(int i=1,j=cnt_zhi;i<=cnt_zhi && j>=1;i++,j--)
	 {
	 	 if(pr[j]>pr[i]) break;
	 	 if(pr[i]>pr[j]){ pan=false; break; }
	 }
	 int k=0;
	 if(pan)
	 {
	 	 for(int i=1;i<=cnt_zhi;i++)
	 	 {
	 	 	 int tmp=++k;
	 	 	 for(int j=1;j<=pr[i];j++) printf("%d ",++k);
	 	 	 printf("%d ",tmp);
		 }
	 }
	 else
	 {
	 	 for(int i=cnt_zhi;i>=1;i--)
	 	 {
	 	 	 int tmp=++k;
	 	 	 for(int j=1;j<=pr[i];j++) printf("%d ",++k);
	 	 	 printf("%d ",tmp);
		 }
	 }
}
int main()
{
     //freopen("","r",stdin);
     //freopen("","w",stdout);
	 scanf("%d",&n);
	 int u,v;
	 for(int i=1;i<n;i++)
	 {
	 	 scanf("%d%d",&u,&v);
	 	 add(u,v);
	 }
	 dfs(1);
	 dfs(t);
	 if(!ok()) printf("-1\n");
	 else print();
     //fclose(stdin);
     //fclose(stdout);
     return 0;
}

Measured memory_bytes: 4864
input = input().split()
input_int = [int(n) for n in input]

def bSort(a):
    for i in range(len(a)):
        for j in range(len(a)-1, i, -1):
            if a[j] < a[j-1]:
                a[j], a[j-1] = a[j-1], a[j]

    return a

numbers = bSort(input_int)

max = numbers[-1]
mid = numbers[1]
min = numbers[0]

A = str(max) + str(mid)
B = min

print(int(A)+B)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;

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

int main() {
    string s;
    cin >> s;
    int ans = 0;
    if(s == "RRR") ans = 3;
    else if(s == "SRR" || s == "RRS") ans = 2;
    else if(s == "SSS") ans = 0;
    else ans = 1;

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

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

#define rep(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define rng(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define all(x) (x).begin(),(x).end()
#define cAll(x) (x).cbegin(),(x).cend()
#define COUT(x) cout << x << endl
//#define int long long

template<typename T> constexpr auto square(T x) { return (x) * (x); }

typedef long long LL;
typedef unsigned long long ULL;
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

const int MOD = 1000000007;
const int INF = INT_MAX;

signed main()
{
	int N;
	cin >> N;
	
	VI H(N);
	for (auto& h : H) cin >> h;

	bool flag = false, ans = true;
	rep(i, N - 1) {
		if (H.at(i) - H.at(i + 1) > 1) {
			ans = false;
			break;
		}
		else if (H.at(i) - H.at(i + 1) == 1) {
			if (flag) {
				ans = false;
				break;
			}
			flag = true;
		}
		else if (H.at(i) - H.at(i + 1) == 0) continue;
		else flag = false;
	}

	if (ans) COUT("Yes");
	else COUT("No");

	return 0;
}



Measured memory_bytes: 768
#include <bits/stdc++.h>
#include <vector>
#include <numeric>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    int N;
    cin >> N;
    vector<pii> xy(N);
    REP(i, N){
        cin >> xy[i].fi >> xy[i].se;
        xy[i].fi;
        xy[i].se;
    }
    // 昇順にソート済みの入力
    vector<int> v(N);
    iota(ALL(v), 0);

    auto dist = [](int x0, int y0, int x1, int y1){
        return sqrt((double)(x1 - x0) * (x1 - x0) + (double)(y1 - y0) * (y1 - y0));
    };
    double ans = 0;
    int id = 0;
    do {
        for (int i = 1; i < N; i++) {
            ans += dist(xy[v[i]].fi, xy[v[i]].se, xy[v[i-1]].fi, xy[v[i-1]].se); 
        }
        id++;
    } while (next_permutation(v.begin(), v.end()));
    printf("%.8f\n", (ans / id));
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <set>
#include <stack>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef unsigned long long ll;


int main()
{
	int n;
	cin>>n;
	string str;
	cin>>str;
	int ans = 0;
	int sum = 0;
	rep(i,n){
		if(str[i] == 'I'){
			sum++;
		}else{
			sum--;
		}
		ans = max(ans,sum);
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

/**
 * Built using CHelper plug-in Actual solution is at the top
 */

public class Main {
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();
	}

	static class Task {
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			String N = in.next();
			String ans = "No";
			if(N.charAt(1) == N.charAt(2) && (N.charAt(0) == N.charAt(1) || N.charAt(2) == N.charAt(3))) {
				ans = "Yes";
			}
			out.println(ans);
		}
	}
	
	static class InputReader {
		public BufferedReader reader;
		public StringTokenizer tokenizer;

		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}

		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

	}
}


Measured memory_bytes: 21332
#include <bits/stdc++.h>
#define i64 long long
#define N (int)(1e5)
#define pii pair<int,int>
#define L first 
#define R second
#define all(x) x.begin(),x.end()
using namespace std;
int sumDigit(int n){
	int sum  =0;
	while(n>0){
		sum+=(n%10);
		n/=10;
	}
	return sum;
}
int main(){
	int n,a,b;
	cin>>n>>a>>b;
	int ans =0;
	for(int i=1;i<=n;i++) {
		int s = sumDigit(i);
		if(s>=a and s<=b) ans+=i;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));

VI sum;

int count(int a) {
	int cnt = 0;
	for(i : sum) {
		if ((i&a) == a) {
			cnt++;
		}
	}
	return cnt;
}
signed main(){
cin.tie(0);
ios::sync_with_stdio(false);

	int N, K;
	cin >> N >> K;
	VI A(N);
	REP(i, N) {
		cin >> A[i];
	}
	REP(i, N) {
		int cnt = 0;
		FOR(j, i, N) {
			 cnt += A[j];
			 sum.push_back(cnt);			
		}
	}
	int ans = 0;
	for (int i = 40; i >= 0; i--) {
		if (count(ans|(1LL<<i))>=K)
			ans |= (1LL << i);
	}

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



Measured memory_bytes: 6128
while True:
	n=int(raw_input())
	if n==0:break
	h,w=map(int,raw_input().split())
	fi=[[0 for _ in range(w)] for _ in range(h)]
	for _ in range(n):
		a,b=map(int,raw_input().split())
		fi[a-1][b-1]=1
	s,t=map(int,raw_input().split())
	out=0
	for i in range(h-s+1):
		for j in range(w-t+1):
			co=0
			for k in range(s):
				for l in range(t):
					co+=fi[i+k][j+l]
			out=max(out,co)
	print(out)

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

// typedef
// -----------------------------------------------------------------------------
typedef long long ll;
typedef long double ld;

// container util
// -----------------------------------------------------------------------------
#define ALL(c)  (c).begin(),(c).end()
#define SZ(c) ((ll)(c).size())
#define MAX(c) *max_element(ALL(c))
#define MIN(c) *min_element(ALL(c))
#define SORT(c) sort((c).begin(),(c).end())

// repetition
// -----------------------------------------------------------------------------
#define FOR(i, a, b) for(ll i= (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)

// constant
// -----------------------------------------------------------------------------
const int INF = 1e9;
const int MOD = 1e9 + 7;
const double EPS = 1e-9;
const double PI = acos(-1.0);

// debug
// -----------------------------------------------------------------------------
#define DUMP(x)  cerr << #x << " = " << (x) << endl

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(15);
    ll N; cin >> N;
    vector<ll> A(N);
    vector<ll> dp(N + 1, 0);
    REP(i, N) {
        cin >> A[i];
        dp[A[i]]++;
    }
    ll sum = 0;
    REP(i, N + 1) {
        sum += dp[i] * (dp[i] - 1) / 2;
    }
    REP(i, N) {
        ll ans = sum - (dp[A[i]] - 1);
        cout << ans << "\n";
    }
}

Measured memory_bytes: 5760
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <queue>
#include <stack>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

void OutputError(std::string s) {
  cerr << "\033[93m" << s << "\033[m" << endl;
  return;
}

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  int n;
  cin >> n;
  std::vector<int> a(n, 0);
  for (int i = 0; i < n; i++) {
    cin >> a[i];
  }
  std::vector<int> count(std::pow(10, 5) + 1, 0);
  for (int i = 0; i < n; i++) {
    count[a[i]]++;
  }
  int odd = 0, even = 0;
  for (int i = 1; i <= std::pow(10, 5); i++) {
    if (count[i] != 0) {
      if (count[i] % 2 == 0) {
        even++;
      } else {
        odd++;
      }
    }
  }
  cerr << "\033[93m" << even << " " << odd << "\033[m" << endl;
  int result = 0;
  result += odd;
  if (even % 2 == 0) {
    result += even;
  } else {
    result += even - 1;
  }
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int n;
vector<vi> e;
void rec(int c, int p, int g, vi &path, vi &tmp){
	tmp.pb(c);
	if(c == g){
		path = tmp;
		tmp.pop_back();
		return;
	}
	for(int i : e[c]) if(i != p) rec(i, c, g, path, tmp);
	tmp.pop_back();
}
int col[110000];
int nul(int c, int p, vi &v){
	int ans = -1;
	v.pb(c);
	for(int i : e[c]) if(i != p){
		if(col[i] != -1) ans = col[i];
		else{
			int tmp = nul(i, c, v);
			if(tmp != -1) ans = tmp;
		}
	}
	return ans;
}

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	cin >> n;
	e.resize(n);
	rep(i, n - 1){
		int a, b; cin >> a >> b; a--; b--;
		e[a].pb(b);
		e[b].pb(a);
	}
	vi path, tmp;
	rec(0, 0, n - 1, path, tmp);
	
	dbg(path);
	
	memset(col, -1, sizeof(col));
	rep(i, path.size()) col[path[i]] = i < (1 + path.size()) / 2;
	rep(i, n) if(col[i] < 0){
		vi v;
		int c = nul(i, i, v);
		for(int j : v) col[j] = c;
	}
	//rep(i, n) dbg(i, col[i]);
	
	int cnt[2] = {};
	rep(i, n) cnt[col[i]]++;
	cout << (cnt[0] < cnt[1] ? "Fennec" : "Snuke") << endl;
	
	
	return 0;
}

Measured memory_bytes: 14840
#include <complex>
#include <iostream>
#include <vector>
#include <string>
#include <map>
#include <algorithm>

#define REP(i,n) for(int i=0;i<(int)(n);i++)

using namespace std;

int main() {
  int n;
  cin>>n;
  REP(i,n) {
    int a,b;
    cin>>a>>b;
    complex<int> z(a,b);
    int norm = a*a+b*b;
    bool ok = true;
    REP(j,150) REP(k,j+1) {
      int njk = j*j+k*k;
      if(njk<=1) continue;
      if (njk >= norm) break;
      if ((norm%njk) == 0) {
        int sig[]={1,-1};
        REP(l,2)REP(m,2) {
          int nj=j*sig[l];
          int nk=k*sig[m];
          if (((nj*a+nk*b)%njk) == 0) {
            ok = false;
            break;
          }
        }
      }
    }
    if(ok)
      cout<<'P'<<endl;
    else
      cout<<'C'<<endl;
  }
  return 0;
}

Measured memory_bytes: 1152
/*input

*/

#include <functional>
#include <algorithm>
#include <iostream>
#include <string.h>
#include <utility> 
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <map>
#include <set>

using namespace std;

using ll = long long;
using ld = long double;

const int SINF = 1000000009;
const ll INF =  1000000000000000018;

#define sp          cout << " "
#define nl          cout << "\n"
#define all(c)      (c).begin(),(c).end()
#define prec(n)     cout << fixed << setprecision(n)
#define PI          3.14159265358979323846264338327951
#define ifalse      ios_base::sync_with_stdio(false), cin.tie(NULL)

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

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

template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v) {
  for(auto x: v) {
    os << x << " ";
  }
  return os;
}

template <typename T>
istream &operator>>(istream &is, vector<T> &v) {
  for (auto &x : v) is >> x;
  return is;
}

/******************************** START *********************************/
const int N = 100005;

int main()
{
  ifalse;
  int s, w;
  cin >> s >> w;
  if(w >= s) {
    cout << "unsafe";
  } else {
    cout << "safe";
  }
  return 0;
}

Measured memory_bytes: 3652
import string
 
S = input()
if len(S) < 26:
    for c in string.ascii_lowercase:
        if c not in S:
            break
    print(S + c)
else:
    ret = None
    for i in range(26):
        if max(S[25-i:]) != S[25-i]:
            mc = 'z'
            for c in S[25-i:]:
                if c > S[25-i]:
                    mc = min(c, mc)
            ret = S[:25-i] + mc
            break
            
    if ret is None:
        print(-1)
    else:
        print(ret)

Measured memory_bytes: 3828
import java.util.*;
import java.util.stream.Collectors;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	int H, W;
	char[][] map;
	int[][] counts;

	Main(BufferedReader in) throws IOException {
		String[] tokens = in.readLine().split(" ");
		H = Integer.parseInt(tokens[0]);
		W = Integer.parseInt(tokens[1]);
		map = new char[H][];
		counts = new int[H][W];
		for (int i = 0; i < H; ++i) {
			map[i] = in.readLine().toCharArray();
			Arrays.fill(counts[i], 0);
		}
	}

	void add(int h, int w) {
		// 左上
		if (h > 0 && w > 0) {
			counts[h - 1][w - 1]++;
		}
		if (h > 0) {
			counts[h - 1][w]++;
		}
		if (h > 0 && w + 1 < W) {
			counts[h - 1][w + 1]++;
		}
		if (w > 0) {
			counts[h][w - 1]++;
		}
		if (w + 1 < W) {
			counts[h][w + 1]++;
		}
		if (h + 1 < H && w > 0) {
			counts[h + 1][w - 1]++;
		}
		if (h + 1 < H) {
			counts[h + 1][w]++;
		}
		if (h + 1 < H && w + 1 < W) {
			counts[h + 1][w + 1]++;
		}
	}

	void calc() {
		for (int h = 0; h < H; ++h) {
			for (int w = 0; w < W; ++w) {
				if (map[h][w] == '#') {
					add(h, w);
				}
			}
		}
	}

	void showResult() {
		for (int h = 0; h < H; ++h) {
			for (int w = 0; w < W; ++w) {
				if (map[h][w] == '#') {
					System.out.print('#');
				} else {
					System.out.print(counts[h][w]);
				}
			}
			System.out.println("");
		}
	}
}

Measured memory_bytes: 21204