akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {
	static class Pos {
		int x, y;

		Pos(int x, int y) {
			this.x = x;
			this.y = y;
		}
	}

	public static boolean f(Pos start, Pos s[], int n, int m) {
		if (m - 1 < n) {
			return true;
		}

		Pos next[] = nextArea(jump(start), sprinkler(s[n]));
		for (int i = 0; i < next.length; i++) {
			if (f(next[i], s, n + 1, m)) {
				return true;
			}
		}

		return false;
	}

	public static Pos[] jump(Pos s) {
		Pos next[] = new Pos[12];
		next[0]  = new Pos(s.x + 2, s.y + 1);
		next[1]  = new Pos(s.x + 2, s.y    );
		next[2]  = new Pos(s.x + 2, s.y - 1);
		next[3]  = new Pos(s.x - 2, s.y + 1);
		next[4]  = new Pos(s.x - 2, s.y    );
		next[5]  = new Pos(s.x - 2, s.y - 1);
		next[6]  = new Pos(s.x + 1, s.y + 2);
		next[7]  = new Pos(s.x    , s.y + 2);
		next[8]  = new Pos(s.x - 1, s.y + 2);
		next[9]  = new Pos(s.x + 1, s.y - 2);
		next[10] = new Pos(s.x    , s.y - 2);
		next[11] = new Pos(s.x - 1, s.y - 2);

		return remake(next);
	}

	public static Pos[] sprinkler(Pos s) {
		Pos next[] =  new Pos[9];
		for (int i = -1; i <= 1; i++) {
			for (int j = -1; j <= 1; j++) {
				next[(i + 1) * 3 + (j + 1)] = new Pos(s.x + i, s.y + j);
			}
		}

		return remake(next);
	}

	public static Pos[] nextArea(Pos f[], Pos s[]) {
		Pos next[] = new Pos[Math.max(f.length, s.length)];

		int index = 0;
		for (int i = 0; i < f.length; i++) {
			for (int j = 0; j < s.length; j++) {
				if (f[i].x == s[j].x && f[i].y == s[j].y) {
					next[index++] = new Pos(f[i].x, f[i].y);
				}
			}
		}

		return remake(next);
	}

	public static Pos[] remake(Pos s[]) {
		int index = 0;
		for (int i = 0; i < s.length; i++) {
			if (s[i] != null && 0 <= s[i].x && s[i].x < 10 && 0 <= s[i].y && s[i].y < 10) {
				s[index++] = s[i];
			}
		}
		Pos s2[] = new Pos[index];
		for (int i = 0; i < index; i++) {
			s2[i] = s[i];
		}
		return s2;
	}

	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n;
		Pos start;
		Pos s[];

		while (true) {
			start = new Pos(sc.nextInt(), sc.nextInt());
			if ((start.x | start.y) == 0) {
				break;
			}

			n = sc.nextInt();
			s = new Pos[n];
			for (int i = 0; i < n; i++) {
				int x = sc.nextInt();
				int y = sc.nextInt();
				s[i] = new Pos(x, y);
			}

			if (f(start, s, 0, n)) {
				System.out.println("OK");
			} else {
				System.out.println("NA");
			}
		}
	}
}

Measured memory_bytes: 18200
#include <stdio.h>
#include <string.h>
int main(void){
	int i,n;
	char a[20] = {'\0'};
	scanf("%s",a);
	for(i = strlen(a)-1; i >= 0 ; i-- )
	putchar(a[i]);
	printf("\n");
	return 0;
}

Measured memory_bytes: 520
#define _USE_MATH_DEFINES
#include  <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include<math.h>
#include<iomanip>
#include<stdio.h>
#include <stdlib.h>
#include<stdio.h>
#include <queue>
#include<map>
#include <sstream>
#include<set>
#include<stack>

//#include<bits/stdc++.h>


using namespace std;



int main()
{
    
    string a, b;
    cin >> a >> b;
    int x, y;
    cin >> x >> y;
    string d;
    cin >> d;
    if (d == a)x--;
    else y--;
    cout << x << " " << y << endl;
   
    return 0;

}

Measured memory_bytes: 256
N=input()
X=len(N)
A=[]
for i in range(X):
  A.append(N[i])



rock=0
paper=0
win=0
lose=0
for i in range (X):
  if A[i]=="g":
    if rock>=paper+1:
      win+=1
      paper+=1
    else:
      rock+=1
  else:
    if rock>=paper+1:
      paper+=1
    else:
      rock+=1
      lose+=1


print(win-lose)


Measured memory_bytes: 4084
def main():
    N = int(input())
    *a, = map(int, input().split())

    ma = max(a)
    s = sum(a)
    cond = ma - (s - ma) < 0
    print('Yes' if cond else 'No')


if __name__ == '__main__':
    main()

# import sys
#
# sys.setrecursionlimit(10 ** 7)
#
# input = sys.stdin.readline
# rstrip()
# int(input())
# map(int, input().split())


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
const int N=1001;
long long n,x[N],y[N],q[N],t;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
		cin>>x[i]>>y[i];
	for(int i=1;i<=n;i++)
		if((x[i]+y[i]+x[1]+y[1])&1)
		{
			cout<<-1;
			return 0;
		}
	for(int i=30;i>=0;i--)
		q[++t]=1<<i;
	if((x[1]+y[1]+1)&1)
		q[++t]=1;
	cout<<t<<'\n';
	for(int i=1;i<=t;i++)
		cout<<q[i]<<" ";
	cout<<'\n';
	for(int i=1;i<=n;i++)
	{
		if(t==32)
			x[i]++;
		for(int j=1;j<=31;j++)
			if(abs(x[i])>=abs(y[i])&&x[i]>=0)
				cout<<'R',x[i]-=q[j];
			else if(abs(x[i])>=abs(y[i])&&x[i]<0)
				cout<<'L',x[i]+=q[j];
			else if(y[i]>=0)
				cout<<'U',y[i]-=q[j];
			else
				cout<<'D',y[i]+=q[j];
		if(t==32)
			cout<<'L';
		cout<<'\n';
	}
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include<string>
#include<cstring>
#include <cstdio>
#include<utility>
#include<algorithm>
#include<vector>
#include<cmath>
#include<map>
#include<bitset>
#include<queue>
#include<stack>
#include<set>
#include <limits>
#include <climits>
#include <numeric>
#include<cassert>
#include<cctype>
#include<iterator>
using namespace std;
typedef long long ll;
typedef vector<ll>VI;
typedef vector<bool>VB;
typedef pair<ll,ll>P;
typedef pair<double,double>P_D;
#define VV(T) vector<vector<T>>
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define bitrep(bit,A) for(int bit=A; ;bit=(bit-1)&A)
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) (ll)((a).size())
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=c_max(x,a)
#define chmin(x,a) x=c_min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define SORT(c) stable_sort(ALL(c))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX_6 1001001//6
#define MAX_7 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
#define MOD 1000000007
#define INF 1<<30
#define INFTY 1000000000000000001LL
#define MAX_INT INT_MAX
#define Endl '\n'
#define greater greater<int>()

int main(){
    int n;cin>>n;
    vector<int>l(n);rep(i,n)cin>>l[i];
    sort(ALL(l));
    ll ans=0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            int s=l[i]+l[j];
            auto iter_lower=lower_bound(l.begin()+j+1,l.end(),s);
            ll idx_lower=distance(l.begin()+j+1,iter_lower);
            ans+=idx_lower;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <queue>
#include <cstdlib>

using namespace std;
typedef long long int ll;

bool debug = false;
#define show(x) if (debug) {cout << "" # x << " = " << x << endl;}
#define rep(x, a, b) for (int x = a; x < b; x++)

int main() {
  string s;
  cin >> s;

  int a = 0;
  int n = 0;
  for (auto c : s) {
    show(c);
    show(a);
    show(n);
    switch (c) {
    case 'S':
      n++;
      break;
    case 'T':
      if (n > 0)
        n--;
      else
        a++;
      break;
    }
  }

  cout << a + n << endl;
  
  return 0;
}


Measured memory_bytes: 640
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#include <bits/stdc++.h>
#define int long long
#define endl '\n'
#define null nullptr
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mp make_pair
#define test int t; cin>>t; while(t--)
#define FAST                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL)

using namespace std;

typedef vector<int> vi;
typedef vector<pair<int,int>> vii;
typedef pair<int,int> pii;
typedef unordered_map<int,int> mp;

const int mod = 1e9+7;



int32_t main(){
    FAST;

    int n;  cin >> n;
        int ans = 0;
    for(int x=0;x<n;x++){
        int t;  cin >> t;
        ans += t;

    }

    cout << (ans - n);

    return 0;
}


Measured memory_bytes: 256
x, n = gets.split(" ").map(&:to_i)
ary = gets.split(" ").map(&:to_i)

if n == 0
  puts x
  exit
end

sa = ary.sort_by{|y| (y-x).abs}
i = 0
200.times do |j|
  if !ary.include?(j) && (i-x).abs > (j-x).abs
    i = j
  end
end

puts i


Measured memory_bytes: 14364
#include<bits/stdc++.h>
using namespace std;
int main(){
  vector<int> a(3),b(3),c(4);
  for(int i=0;i<3;i++){
    cin >> a[i] >> b[i];
    c[a[i]-1]++;
    c[b[i]-1]++;
  }
  bool t=true;
  for(int i=0;i<4;i++){
    if(c[i]==3){
      t=false;
    }
  }
  if(t){
    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;
typedef long long ll;
typedef pair<ll,ll> P;
 
const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

int n, m;
ll a[1000], b[1000];
ll c[1000000];

int main() {
    cin >> n >> m;
    rep(i,n) cin >> a[i];
    rep(i,m) cin >> b[i];
    rep(i,n) a[i]--;
    rep(i,m) b[i]--;
    rep(i,n) c[a[i]] ^= 1;
    rep(i,m) c[b[i]] ^= 2;
    ll c1 = 0, c2 = 0;
    ll e = 0;
    ll ans = 1;
    for (int i = n*m-1; i >= 0; i--) {
        if (c[i] == 3) {
            e += c1 + c2;
            c1++;
            c2++;
        } else if (c[i] == 2) {
            if (c1 == 0) {
                cout << 0 << endl;
                return 0;
            }
            ans = ans * c1 % MOD;
            e += c1-1;
            c2++;
        } else if (c[i] == 1) {
            if (c2 == 0) {
                cout << 0 << endl;
                return 0;
            }
            ans = ans * c2 % MOD;
            e += c2-1;
            c1++;
        } else {
            if (e == 0) {
                cout << 0 << endl;
                return 0;
            }
            ans = ans * e % MOD;
            e--;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 384
# AOJ 1077: The Great Summer Contest
# Python3 2018.7.10 bal4u

while True:
	n, k, f = [0]*3, [0]*3, [0]*3
	a = list(map(int, input().split()))
	if sum(a) == 0: break
	for i in range(3): n[i] += a[i]+a[3+i]
	ans = 0
	for i in range(3):
		if n[i] >= 3: f[i] = 1
		ans += n[i]//3
		n[i] %= 3
		k[n[i]] += 1
	if k[0] > 0:
		if k[2] == 2:
			i = 0
			while n[i]: i += 1
			if f[i]: ans += 1
	elif k[1] > 0: ans += 1
	elif k[2] > 0: ans += 2
	print(ans)


Measured memory_bytes: 5616
#include <stdio.h>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <iostream>
#include<math.h>
#include<bitset>
#include<iomanip>
#include<queue>
using namespace std;

int main() {
	int N, M, ans = 0; cin >> N >> M;
	vector<pair<int, int>> a(M);
	for (int i = 0; i < M; i++) {
		int k,l;cin >> k>>l;
		a[i] = { l,k };
	}
	sort(a.begin(),a.end());
	int x = 0;
	for (int i = 0; i < M; i++) {
		if (x <= a[i].second) { ans++; x = a[i].first; }
	}
	cout << ans << endl;
}



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

vector<pair<lld,lld>> arr;
vector<pair<lld,lld>> v1, v2;
lld dp[33];
bool cmp(pair<lld,lld> x, pair<lld,lld> y){
	return x.first * (y.second + 1) > y.first * (x.second + 1);
}
bool cmp2(pair<lld,lld> x, pair<lld,lld> y){
	return x.second < y.second;
}
int main(void){
	ios::sync_with_stdio(false);
	lld N,T; cin >> N >> T;
    for(int i = 0; i < N; i++){
		lld a,b; cin >> a >> b;
		arr.push_back(make_pair(a,b));
	}
	sort(arr.begin(),arr.end(),cmp);
	for(int i = 0; i < N; i++){
		pair<lld,lld> k = make_pair(arr[i].first,arr[i].second);
		arr[i].first == 0 ? v2.push_back(k) : v1.push_back(k);
	}
	sort(v2.begin(),v2.end(),cmp2);
	for(int i = 0; i < 33; i++) dp[i] = 1e9; dp[0] = 0;
	for(int i = 0; i < v1.size(); i++){
		lld dp2[33];
		for(int j = 0; j < 33; j++) dp2[j] = dp[j];
		for(int j = 1; j < 33; j++){
			lld t = (dp[j-1] + 1)*v1[i].first + v1[i].second + dp[j-1] + 1;
			//cout << "t " <<j <<' ' <<  t << endl;
			if(t <= 1e9 && t < dp2[j]) dp2[j] = t;
			if(dp2[j] == 1e9) break;
		}
		for(int j = 0; j < 33; j++) dp[j] = dp2[j];
	}
	/*for(int i = 0; i < 33; i++) cout << dp[i] << ' ';
	cout << endl;*/
	
	int mm = 0;
	for(int i = 0; i < 33; i++){
		if(dp[i] > T || dp[i] == 1e9) break;
		int c = i;
		for(int j = 0; j < v2.size(); j++){
			dp[i] = v2[j].second + dp[i] + 1;
			if(dp[i] > T) break;
			else c++;
		}
		mm = max(c,mm);
	}
	cout << mm;  
	return 0;
} 


Measured memory_bytes: 12524
N = int(input())
K = int(input())
DP = [[1 for _ in range(2)]for _ in range(N+1)]
for i in range(1,N+1):
    DP[i][0] = min(DP[i-1])*2
    DP[i][1] = min(DP[i-1])+K
print(min(DP[-1]))


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <math.h>
#include <algorithm>
#include <queue>
#include <deque>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <set>
#include <map>
#include <bitset>
#include <stdlib.h>
#include <cassert>
#include <time.h>
#include <numeric>
#include <iomanip> 
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef tree<int,null_type,less<int>,rb_tree_tag, tree_order_statistics_node_update> indexed_set;
typedef vector<int> vi;
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(v) (int)v.size()
#define ll long long int
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define fill(a,v) memset(a,v,sizeof(a));
#define all(v) v.begin(),v.end()
#define forn(i, a, b) for(int i = a; i < b; i++)


#define trarr(a,n) forn(i,0,n) cerr<<a[i]<<" \n"[i==n-1];
#define trmat(g,n,m) forn(i,0,n)forn(j,0,m) cerr<<g[i][j]<<" \n"[i==m-1];
#define tr(...) cerr<<__FUNCTION__<<' '<<__LINE__<<" = ";trace(#__VA_ARGS__, __VA_ARGS__)
template<typename S, typename T> 
ostream& operator<<(ostream& out,pair<S,T> const& p){out<<'('<<p.ff<<", "<<p.ss<<')';return out;}
template<typename T>
ostream& operator<<(ostream& out,vector<T> const& v){
int l=v.size();for(int i=0;i<l-1;i++)out<<v[i]<<' ';if(l>0)out<<v[l-1];return out;}
template<typename T>
void trace(const char* name, T&& arg1){cout<<name<<" : "<<arg1<<endl;}
template<typename T, typename... Args>
void trace(const char* names, T&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');cout.write(names, comma-names)<<" : "<<arg1<<" | ";trace(comma+1,args...);}

const ld PI = acos(-1);
const ld EPS = 1e-9;
const int inf = 1e9+10;
const ll INF = 1e18+10;
const int P = 1e9+7;
const int N = 2e2+10;
const int V = 1e5+10;

void solve(int _t){
	int n, c;
	cin >> n >> c;
	ll w[n], v[n];
	forn(i, 0, n){
		cin >> w[i] >> v[i];
	}
	ll dp[N][V] = {0};
	forn(i, 0, n) forn(j, 0, V) dp[i][j] = INF;
	forn(i, 0, n)
		dp[i][v[i]] = w[i];
	forn(i, 1, n){
		forn(j, 0, V){
			dp[i][j] = min({dp[i][j], dp[i-1][j]});
			if(j < v[i]) continue;
			dp[i][j] = min({dp[i][j],dp[i-1][j-v[i]]+w[i]});
		}
	}
	forn(i, 1, n){
		forn(j, 0, V){
			dp[i][j] = min({dp[i][j], dp[i-1][j]});
			if(j < v[i]) continue;
			dp[i][j] = min({dp[i][j],dp[i-1][j-v[i]]+w[i]});
		}
	}
	int ans = 0;
	forn(i, 0, V){
		if(dp[n-1][i] <= c) ans = i;
	}
	cout<< ans << endl;
}	
int main(){
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int t = 1;
	// cin >> t;
	forn(test, 1, t+1){
		solve(test);
	}
	return 0;
}

Measured memory_bytes: 167724
#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 drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define print(x)cout<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  string s,t;
  cin>>s>>t;
  if(s==t){
    cout<<"No"<<endl;
    return 0;
  }
  vi S,T;
  rep(i,sz(s)){
    S.push_back(s[i]-'a');
  }
  rep(i,sz(t)){
    T.push_back(t[i]-'a');
  }
  sort(rng(S));
  sort(rng(T),greater<int>());
  string A="",B="";
  rep(i,sz(S)){
    A+='a'+S[i];
  }
  rep(i,sz(T)){
    B+='a'+T[i];
  }
  vector<string> ans;
  ans.push_back(A);
  ans.push_back(B);
  sort(rng(ans));
  if(ans[0] == A){
    cout<<"Yes"<<endl;
  }
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int n;

    while (scanf("%d", &n), n){
        int point[128] = {0};
        int i, j;

        for (i = 0; i < n; i++) scanf("%d", point + i);
        for (i = 0; i < n - 1; i++){
            for (j = 0; j < n - i - 1; j++){
                if (point[j] > point[j + 1]){
                    int tmp = point[j];
                    point[j] = point[j + 1];
                    point[j + 1] = tmp;
                }
            }
        }
        point[0] = 0;
        for (i = 1; i < n - 1; i++){
            point[0] += point[i];
        }
        printf("%d\n", point[0] / (n - 2));
    }

    return 0;
}

Measured memory_bytes: 600
N = int(input())
Hlist = list(map(int,input().split()))
sign = 1
Answer = 'Yes'
for i in range(len(Hlist)-1):
    H1 = Hlist[i]
    H2 = Hlist[i+1]
    if H1 > H2:
        if H1 - H2 == 1 and sign == 1:
            Hlist[i] -= 1
            sign =0
        else:
            Answer = 'No'
            break
    if H1 < H2:
        sign = 1
print(Answer)

Measured memory_bytes: 20580
S = [int(x) for x in input()]
for i in range(2**3):
    s = S[0]
    ans = str(S[0])
    for j in range(3):
        if ((i >> j) & 1):
            s += S[j+1]
            ans += "+" + str(S[j+1])
        else:
            s -= S[j+1]
            ans += "-" + str(S[j+1])
    if s == 7:
        print(ans + "=7")
        break


Measured memory_bytes: 38256
#include<bits/stdc++.h>
using namespace std;
double solve(int x)
{
    double sol = sqrt(1+8*x);
    sol += 1;
    sol = (1.0*sol)/2;
    return sol;
}
int main()
{
    int a,b;
    cin>>a>>b;
    int ans = ((b-a)*(b-a+1))/2 - b;
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<list>
#include<map>
#include<stack>
#include<queue>
#include<math.h>
#include<vector>
#include<algorithm>
#include<string.h>
#include<iomanip>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) range(i,0,b)
#define debug(x) cout << "debug" << x << endl;
using namespace std;

int main(){
    int n;
    map<string, int> dic;
    cin >> n;
        char inp[8];
        string name;
    while(n--){
        scanf("%s", inp);
        cin >> name;
        if(inp[0] == 'i'){
            dic[name] = 1;
        }else if(inp[0] == 'f'){
            if(dic.find(name) != dic.end()){
                cout << "yes" << endl;
            }else{
                cout << "no" << endl;
            }
        }
    }
}

Measured memory_bytes: 34960
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>

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

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; }
typedef pair <ll,ll> P;
ll MOD = 1000000007;

int main()
{
    ll N;
    cin >> N;
    vector<ll> T(N);
    ll sum = 0;
    rep(i, N) {
        cin >> T[i];
        sum += T[i];
    }
    ll M;
    cin >> M;
    rep(i, M) {
        ll P, X;
        cin >> P >> X;
        cout << sum + (X - T[P-1]) << endl; 
    }


    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    long k, a, b, ans;
    cin >> k >> a >> b;
    if(k < a || b < a + 2){
        ans = k + 1;
    } else{
        int c = b - a;
        k = k - (a - 1);
        ans = a + (k / 2) * c;
        if(k % 2 == 1) ++ans;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
#define mp make_pair
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1<<30;
const ll LINF = 1LL<<58;
const ll mod = 1000000007;

int main(){
    int n, ans = 0;
    cin >> n;
    vector<int> H(n+1);
    rep(i,n) cin >> H[i];
    H[n] = INF;
    rep(i,n){
        int cnt = 0;
        while(H[i] >= H[i+1]){
            cnt++; i++;
        }
        chmax(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#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;

vi reachable(const vector<vi> &e, int s){
	int n = e.size();
	vi v(n); v[s] = 1;
	queue<int> q; q.push(s);
	while(!q.empty()){
		int c = q.front(); q.pop();
		for(int i : e[c]) if(!v[i]){
			q.push(i); v[i] = 1;
		}
	}
	return v;
}

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	int n, m, p; cin >> n >> m >> p;
	vector<tuple<int,int,int>> e;
	vector<vi> es(n), re(n);
	vi dist(n, inf);
	dist[0] = 0;
	
	rep(i, m){
		int a, b, c; cin >> a >> b >> c; a--; b--;
		e.emplace_back(a, b, p - c);
		es[a].pb(b);
		re[b].pb(a);
	}
	vi reach1 = reachable(es, 0);
	vi reach2 = reachable(re, n - 1);
	
	rep(it, n){
		bool u = 0;
		for(auto i : e){
			int a, b, c; tie(a, b, c) = i;
			if(!reach1[a] || !reach2[a]) continue;
			if(!reach1[b] || !reach2[b]) continue;
			if(dist[b] > dist[a] + c){
				u = 1;
				dist[b] = dist[a] + c;
			}
		}
		if(!u) break;
		if(it == n - 1){
			cout << -1 << endl;
			return 0;
		}
	}
	cout << max(0, -dist[n - 1]) << endl;
	
	return 0;
}

Measured memory_bytes: 768
package main

import (
	"fmt"
	"strconv"
)

func harshad(N int) int {
	A := strconv.Itoa(N)
	var X int
	for i := 0; i < len(A); i++ {
		X += int(A[i] - '0')
	}
	return X
}

func main() {
	// Code for B - Harshad Number
	var N int
	fmt.Scanf("%d", &N)

	if N%harshad(N) == 0 {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}

}


Measured memory_bytes: 1836
#include <iostream>
#include <cstring>
#include <cstdio>
using namespace std;

char letter[27] = {"abcdefghijklmnopqrstuvwxyz"};
int flag[27] = {0};

int main()
{
    int n, sum, maxn = -1;
    char a[110];
    scanf("%d", &n);
    getchar();
    scanf("%s", a);

    for(int i = 0; i < n; i++)
    {
        sum = 0;
        memset(flag, 0, sizeof(flag));
        for(int j = 0; j <= i; j++)
        {
            for(int m = 0; m < 27; m++)
            {
                if(a[j] == letter[m])
                    flag[m] = 1;
            }
        }
        for(int k = i + 1; k < n; k++)
        {
            for(int m = 0; m < 27; m++)
            {
                if(a[k] == letter[m] && flag[m] == 1)
                {
                    sum++;
                    flag[m] = 2;
                    continue;
                }
            }
        }
        if(sum > maxn)
            maxn = sum;
    }
    printf("%d\n", maxn);
    return 0;
}

Measured memory_bytes: 256
from bisect import*
n,*l=map(int,open(0).read().split())
l.sort()
A=0
for i in range(n):
    a=l[i]
    for j in range(i+1,n):
        b=l[j]
        k1=max(j+1,bisect(l,b-a))
        k2=bisect_left(l,a+b)
        A+=max(0,k2-k1)
print(A)

Measured memory_bytes: 48888
(function (input) {
    var inputs = input.replace(/\r/g, '').split("\n"), str, joi, ioi;
    while(true) {
        joi = 0;
        ioi = 0;
        str = inputs.shift();
        if(str === '') {
            break;
        }
        for(var i = 0, len = str.length; i < len - 2; i++) {
            var tmp = str[i] + str[i + 1] + str[i + 2];
            if(tmp == 'JOI') {
                joi++;
            }
            if(tmp == 'IOI') {
                ioi++;
            }
        }
        console.log(joi + "\n" + ioi);
    }
})(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 8772
#include <iostream>
#include <algorithm>
#include <vector>

int main(){
    int n;
    std::cin >> n;
    int p[n],q[n];
    bool flag=false;
    for(int i=0;i<n;++i){
        std::cin >> p[i];
        q[i]=p[i];
    }
    
    std::sort(q,q+n);  //ソート後
    
    for(int i=0;i<n-1;++i){
        for(int j=i;j<n;++j){
            int temp=p[i];
            p[i]=p[j];
            p[j]=temp;
            for(int l=0;l<n;++l){
                if(p[l]!=q[l]){
                    break;
                }
                if(l==n-1&&p[l]==q[l]){
                    flag=true;
                }
            }
            if(flag==false){
                int temp=p[j];
                p[j]=p[i];
                p[i]=temp;
            } else {
                flag=true;
                break;
            }
        }
        if(flag){
            break;
        }
    }
    
    if(flag){
        std::cout << "YES" << std::endl;
    } else {
        std::cout << "NO" << std::endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{  
  long int n,i,k,l;
  n=5;
  long int a[n+1];
  for(i=1;i<=n;i++)
  {
    cin>>a[i];
  }
  for(i=1;i<=n;i++)
  {
    if(a[i]==0)
      l=i;
  }
  cout<<l<<endl;

}

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

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define ROF(i,b,a) for (int i=(b);i>(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,n-1,-1)

typedef int i32;
typedef long long int i64;
typedef unsigned long long int ui64;
typedef float f32;
typedef double f64;
typedef long double f128;
typedef pair<int,int> Pi;

constexpr int INF = 1e9 + 7;
constexpr int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main() {
    int N; cin>>N;
    int A;
    map<int,int> m;
    REP(i,N) {
        cin>>A;
        m[A]++;
    }
    vector<int> avail;
    for (auto x: m) REP(i,x.second/2) avail.push_back(x.first);
    i64 ans = 0;
    sort(avail.begin(),avail.end());
    if (avail.size()>=2) ans = (i64)avail[avail.size()-1]*avail[avail.size()-2];
    cout<<ans<<endl;
}



Measured memory_bytes: 4992
n,m = gets.chomp.split.map(&:to_i)
count = 0
ans = Array.new(n,-1)
num_list = []
flag = false
while(true)
    if count == m
        break
    end
    s,c = gets.chomp.split.map(&:to_i)
    if ans[s-1] == -1
        ans[s-1] = c
        num_list.push(s)
    elsif ans[s-1] != c 
        flag = true
    end
    count += 1
end
num = 0
while(true)
    if num == 0
        if ans.size == 1 && ans[num] == -1
            ans[num] = 0
        elsif ans.size > 1 && ans[num] == -1
            ans[num] = 1
        end
    else
        if ans[num] == -1
            ans[num] = 0
        end
    end
    num += 1
    if num == n
        break
    end
end
if flag || (ans.size >= 2 && ans[0] == 0) 
    print '-1'
else
    ans.each do |a|
        print a.to_i
    end
end

Measured memory_bytes: 14408
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>
#define rep(i, f, n) for (int i = (f); i < (int)(n); i++)
#define repe(i, f, n) for (int i = (f); i <= (int)(n); i++)
using namespace std;
using ll = long long;
using pint = pair<int, int>;

const int INF = 1001001001;

int main() {
  int N;
  cin >> N;
  vector<int> v = {64, 32, 16, 8, 4, 2, 1};
  for (auto x : v) {
    if (x <= N) {
      cout << x << endl;
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 3600
mod=1000000007
n=int(input())
x=list(map(int,input().split()))
cl=[1]
for i in range(1,n):
    cl.append(cl[i-1]+x[i])
sum=0
for i in range(n-1):
    sum+= x[i]*(cl[n-1]-cl[i])
    sum%=mod

print(sum)


Measured memory_bytes: 109660
#include <bits/stdc++.h>
using namespace std;
long long n, k;
int main() {
    cin >> n >> k;
    vector<long long> h(n, 0);
    long long sum = 0;
    for(int i = 0; i < n; ++i) {
        cin >> h.at(i);
    }
    sort(h.begin(), h.end(), greater<int>());

    for(int i = 0; i < n; ++i) {
        if(i < k) {

        }else {
            sum += h.at(i);
        }
    }

    cout << sum << endl;
}

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

using namespace std;

#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

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#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 rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(ll)(n);i>0;i--)
#define REP(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = 1e18;
const ll MOD = 1000000007;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0, -1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
#define mp make_pair


int main () {
  fio();
  int n, m, qu;
  cin >> n >> m >> qu;
  vector<pair<int, int> > lr(m);
  vector<vector<int> > hyou(n, vector<int>(n));
  for (int i = 0; i < m; i++) {
    cin >> lr[i].first >> lr[i].second;
    lr[i].first--; lr[i].second--;
    hyou[lr[i].first][lr[i].second]++;
  }
  sort(all(lr));
  vector<vector<int> > sum(n, vector<int>(n + 1));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      sum[i][j + 1] = sum[i][j] + hyou[i][j];
    }
  }
  while (qu--) {
    int p, q;
    cin >> p >> q;
    p--; q--;
    int cnt = 0;
    for (int i = p; i <= q; i++) {
      cnt += sum[i][q + 1];
    }
    cout << cnt << endl;
  }
        
}


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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  string res = "NO";
  for (int i = 1; i <= b; ++i) {
    if (a * i % b == c) {
      res = "YES";
    }
  }
  cout << res << endl;
}


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

using namespace std;

int main(void){
	int n;

	string s;

	long long int alp[5] = {};

	cin >> n;


	for (int i = 0; i < n; i++){
		cin >> s;

		if (s[0] == 'M')
			alp[0]++;
		if (s[0] == 'A')
			alp[1]++;
		if (s[0] == 'R')
			alp[2]++;
		if (s[0] == 'C')
			alp[3]++;
		if (s[0] == 'H')
			alp[4]++;
	}


	long long int sum = 0;
	for (int i = 0; i < 5; i++){
		for (int j = i + 1; j < 5; j++){
			for (int k = j + 1; k < 5; k++){
				sum += alp[i] * alp[j] * alp[k];
			}
		}
	}



	cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a,b,c,d,e,k;
  cin>>a>>b>>c>>d>>e>>k;
  if(e-a<=k){
    cout<<"Yay!"<<endl;
  }
  else{
    cout<<":("<<endl;
  }
  return 0;
}


Measured memory_bytes: 256
x,y,z,k,*L=map(int,open(0).read().split())
a=L[:x];b=L[x:x+y];c=sorted(L[x+y:])[::-1]
ab=sorted(i+j for i in a for j in b)[::-1][:min(x*y,k)]
print(*sorted(i+j for i in ab for j in c)[::-1][:k],sep="\n")

Measured memory_bytes: 137880
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
  ll n,a,b,c,i,q,ans=0;
  cin>>n;
  map<ll,ll> mp;
  for(i=0;i<n;i++){
    cin>>a;
    mp[a]++;
    ans+=a;

  }
  cin>>q;
  while(q--){
    cin>>b>>c;
    if(mp[b]){
      ans+=mp[b]*(c-b);
      mp[c]+=mp[b];
      mp[b]=0;
    }
    cout<<ans<<endl;
  }
}


Measured memory_bytes: 9364
n,m = gets.split.map(&:to_i)
l = n-m
N = n.times.map{gets.chomp}
M = m.times.map{gets.chomp}
puts (0..l).any?{|offsety| (0..l).any?{|offsetx| m.times.all?{|y| N[offsety + y][offsetx, m] == M[y]}}} ? 'Yes' : 'No'


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

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

const int inf = 1'000'000'000;

#include<bits/stdc++.h>

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

int main(){
  int a,b;
  cin >> a >> b;
  for (int i = 1; i <10001; i++) {
    if ((int)(i*8/100) == a && (int)(i*10/100) == b) {
      cout << i << endl;
      return 0;
    }
  }
  cout << -1 << endl;
}


Measured memory_bytes: 3648
l = list(map(int, input().split()))

w = l[0]
h = l[1]
n = l[2]

minx = 0
maxx = w
miny = 0
maxy = h

for i in range(n):
    l = list(map(int, input().split()))
    x = l[0]
    y = l[1]
    a = l[2]
    if a == 1:
        if minx < x:
            minx = x
    elif a == 2:
        if maxx > x:
            maxx = x
    elif a == 3:
        if miny < y:
            miny = y
    elif a == 4:
        if maxy > y:
            maxy = y
    if maxx - minx <= 0 or maxy - miny <= 0:
        maxx = 0
        minx = 0
        maxy = 0
        miny = 0

cnt = w * h
#print(minx, maxx, miny, maxy)
ans = (maxx-minx) * (maxy-miny)
if ans < 0:
    ans = 0
print(ans)


Measured memory_bytes: 3064
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int q = sc.nextInt();
        PriorityQueue<Event> queue = new PriorityQueue<>();
        for (int i = 0; i < n; i++) {
            queue.add(new Event(sc.nextInt(), sc.nextInt(), sc.nextInt()));
        }
        TreeMap<Integer, Integer> map = new TreeMap<>();
        for (int i = 0; i < q; i++) {
            map.put(sc.nextInt(), i);
        }
        int[] ans = new int[q];
        Arrays.fill(ans, -1);
        while (queue.size() > 0) {
            Event e = queue.poll();
            Map.Entry<Integer, Integer> x = map.ceilingEntry(e.start - e.point);
            while (x != null && x.getKey() < e.end - e.point) {
                ans[x.getValue()] = e.point;
                map.remove(x.getKey());
                x = map.ceilingEntry(e.start - e.point);
            }
        }
        StringBuilder sb = new StringBuilder();
        for (int x : ans) {
            sb.append(x).append("\n");
        }
        System.out.print(sb);
    }
    
    static class Event implements Comparable<Event> {
        int start;
        int end;
        int point;
        
        public Event(int start, int end, int point) {
            this.start = start;
            this.end = end;
            this.point = point;
        }
        
        public int compareTo(Event another) {
            return point - another.point;
        }
    }
}

Measured memory_bytes: 83148
#include<bits/stdc++.h>
    using namespace std;
    
    //                                 (POLICY BASED DS)
    // #include <ext/pb_ds/assoc_container.hpp>
    // #include <ext/pb_ds/tree_policy.hpp>
    // using namespace __gnu_pbds;
    // template<typename T>
    // using ordered_set=tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
    // template<typename T>
    // using ordered_multiset=tree<T,null_type,less_equal<T>,rb_tree_tag,tree_order_statistics_node_update>;
    //                      ( find_by_order( )  ,  order_of_key( ) )
    
    typedef long long ll;
    typedef long double ld;
    typedef unsigned long long ull;
    typedef vector<int> vi;
    typedef vector<long long> vll;
    typedef pair<ll,ll> pll;
     
    const ll mod = 1e9 + 7;
    const ld PI = 3.1415926535897932384626;
    const ld eps = 1e-9;                            
     
    #define boost ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
    #define sidha(i,a,b) for(ll i=(ll)(a);i<(ll)(b);++i)
    #define ulta(i,a,b) for(ll i=(ll)(a);i>=(ll)(b);--i)
    #define stl(container,itr) \
        for(auto itr = container.begin(); itr != container.end(); itr++)
    #define sab(v) v.begin(), v.end()
    #define rall(v) v.rbegin(), v.rend()            
    #define test ll t;cin>>t;while(t--)
    #define sz size()
    #define pb push_back
    #define mp make_pair
    #define fi first
    #define se second
    #define LOG2(X) (63ll - __builtin_clzll(X))
    #define endl '\n'
    #define modinv(x) power(x, mod-2)
    #define ncr(n,r) ( n >= r ? ((((fact[n]*modinv(fact[r]))%mod)*modinv(fact[n-r]))%mod) : (ll)0)
    #define MAX 100005
     
    ll power(ll x, ll y) { 
        ll ans=1;
        x=x%mod;
        while(y>0) { 
            if (y&1) 
                ans=(ans*x)%mod; 
            y=y>>1;
            x=(x*x)%mod; 
        } 
        return ans; 
    }
    
    // vector<ll> adj[MAX];
    // ll visit[MAX];
    // void dfs(ll node){
    //     visit[node]=1;
    //     for(auto i : adj[node]){
    //         if(!visit[i]) dfs(i);
    //     }
    // }
    
    // ll spf[MAX];
    // void sieve(){
    //     sidha(i,1,MAX)  spf[i]=i;
    //     for(ll i=4;i<MAX;i+=2)  spf[i]=2;
    //     for(ll i=3;i*i<=MAX;i++){
    //         if(spf[i]==i){
    //             for(ll j=i*i;j<MAX;j+=i){
    //                 if(spf[j]==j)   spf[j]=i;
    //             }
    //         }
    //     }
    // }

    int main()
    {
        boost;
        ll n,ans=0,b;
        cin>>n;
        sidha(i,1,n){
            b=n/i;
            if(n%i) ans+=b;
            else    ans+=(b-1);
        }
        cout<<ans;
        return 0;
    }
    

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

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

int main()
{
	int d,n,ans;
	cin >> d >> n;
	ans=1;
	REP(i,d) ans *= 100;
	if(n==100) n+=1;
	ans = ans * n;
	cout << ans << endl;
}

Measured memory_bytes: 256
class Bridge:
    def __init__(self, nodeA, nodeB):
        self.edges = [Edge(nodeA, self), Edge(nodeB, self)]
        nodeA.addEdge(self.edges[1])
        nodeB.addEdge(self.edges[0])
        self.dir = True
        self.vec = None
    def __repr__(self):
        return str((self.vec, self.dir))

class Edge:
    def __init__(self, node, bridge):
        self.bridge = bridge
        self.node = node
    def another(self):
        return self.bridge.edges[1 if self.bridge.edges[0] == self else 0]

class Node:
    def __init__(self, id):
        self.id = id
        self.edges = []
        self.parent = None
        self.judge = True
    def addEdge(self, edge):
        self.edges.append(edge)
    def __repr__(self):
        return str((self.id, None if self.parent is None else self.parent.node.id, self.judge))

N, M = map(int, input().split())

nodes = [Node(i) for i in range(N+1)]
bridges = []
for A, B in (map(int, input().split()) for _ in range(M)):
    bridges.append(Bridge(nodes[A], nodes[B]))

s = [(0, nodes[1])]
idx = 0
while len(s) > 0:
    level, cur = s.pop()

    nxtlevel = level + 1
    for nxt in cur.edges:
        if nxt.bridge.vec is None:
            cur.judge ^= True
            nxt.bridge.vec = (cur.id, nxt.node.id)
            if nxt.node.parent is None:
                nxt.node.parent = nxt.another()
                s.append((nxtlevel, nxt.node))

    if len(s) > 0:
        nl = s[-1][0]
    else:
        nl = 1
    while level >= nl:
        if not cur.judge:
            cur.judge ^= True
            cur.parent.node.judge ^= True
            cur.parent.bridge.dir ^= True
        level -= 1
        cur = cur.parent.node
  
if nodes[1].judge:
    for br in bridges:
        if br.dir:
            print("{} {}".format(br.vec[0], br.vec[1]))
        else:
            print("{} {}".format(br.vec[1], br.vec[0]))
else:
    print("-1")


Measured memory_bytes: 113824
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

#ifndef U_L_LONG
typedef unsigned long long U_L_LONG;
#endif
#ifndef L_LONG
typedef long long L_LONG;
#endif

typedef std::pair<int, int> IntPair;

#ifndef LL_ABS
#define LL_ABS(x) (((((L_LONG)(x) < 0) ? ((L_LONG)(x) * (-1)) : ((L_LONG)(x)))))
#endif

//static void ABC120D_DecayedBridges();
static void ABC119C_MonstersBattleRoyale();
static void ABC118A_BpmA();

#if 1
int main()
{
	//ABC120D_DecayedBridges();
	ABC118A_BpmA();

	fflush(stdout);
	return 0;
}
#endif

static void ABC118A_BpmA()
{
	int A, B;

	scanf(" %d %d", &A, &B);

	printf("%d\n", ((B % A) ? (B - A) : (A + B)));
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define _printV(vec) for(int i = 0; i < SZ(vec); i++){cout << vec[i];if (i==SZ(vec)-1){cout<<endl;}else{cout << " ";}}
#define printV(vec) cout<<#vec<<":";_printV(vec)
#define _printA(arr,n) for(int i = 0; i < n; i++){cout << arr[i];if (i==n-1){cout<<endl;}else{cout << " ";}}
#define printA(arr) cout<<#arr<<":";_printA(arr,sizeof(arr)/sizeof(arr[0]))
#define LLINF = (1LL<<62)
#define puts(var) cout<<#var<<":"<<var<<" "
typedef long long ll;

int main()
{
  int X,Y;
  cin >> X >> Y;
  ll sum = X+Y/2;
  printf("%lld\n",sum);
  return 0;
}


Measured memory_bytes: 256
import sys

def input(): return sys.stdin.readline()[:-1]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def MATINT(h): return [list(map(int, input().split())) for _ in range(h)]
def MATSTR(h): return [input() for _ in range(h)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
inf = float('inf')
mod = 10 ** 9 + 7

def main():
    S = input() + 'R'
    R = 0
    L = 0
    Ri = 0
    Li = 0
    flag = 0
    ans = [0] * (len(S)-1)
    for i in range(len(S)-1):
        if S[i] == 'R':
            R += 1
        elif S[i] == 'L':
            if flag == 0:
                Ri = i - 1
                Li = i
                flag = 1
            L += 1
            if S[i + 1] == 'R':
                tmp = R + L
                if tmp % 2 == 0:
                    ans[Ri] = tmp // 2
                    ans[Li] = tmp // 2
                else:
                    if R > L:
                        if R % 2 == 0:
                            ans[Ri] = tmp // 2
                            ans[Li] = ceil(tmp, 2)
                        else:
                            ans[Ri] = ceil(tmp, 2)
                            ans[Li] = tmp // 2
                    else:
                        if L % 2 == 0:
                            ans[Ri] = ceil(tmp, 2)
                            ans[Li] = tmp // 2
                        else:
                            ans[Ri] = tmp // 2
                            ans[Li] = ceil(tmp, 2)
                flag = 0
                L = 0
                R = 0
    print(*ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 50108
#include <stdio.h>

int main(void) {
	int n, k;
	int ans = 1;

	scanf("%d %d", &n, &k);

	for (int i = 0; i < n; i++) {
		if (ans >= k) ans += k;
		else ans *= 2;
	}

	printf("%d\n", ans);

	return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<pair<int, int>> pairs(N);

    int ai;
    rep(i, N) {
        cin >> ai;
        pairs[i] = make_pair(ai, i);
    }
    sort(pairs.begin(), pairs.end());

    rep(i, N) cout << pairs[i].second + 1 << " ";
    cout << endl;

    return 0;
}



Measured memory_bytes: 1664
#pragma GCC optimize("Ofast")
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>
#include<queue>

const long long INF_L = 1e17+7;
const long long INF_I = 1e9+7;
const long long MOD = 1e9+7;
const double EPS = 1e-8;
const double PI=acos(-1);

using namespace std;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	string s,t;
	cin >> s >> t;
	
	if(s.size()<t.size()){
		cout << "UNRESTORABLE" << endl;
		return 0;
	}
		
	for(int i=s.size()-t.size();i>=0;i--){
		for(int j=0;j<t.size();j++){
			if(s[i+j]!='?' && s[i+j]!=t[j]){
				break;
			}else if(s[i+j]==t[j] || s[i+j]=='?'){
				bool ok=true;
				for(int k=0;k<t.size();k++){
					if(s[i+k]=='?' || s[i+k]==t[k]){
						continue;
					}else if(s[i+k]!=t[k]){
						ok=false;
					   break;
					}
				}
				if(ok){
					for(int k=0;k<t.size();k++){
						s[i+k]=t[k];
					}
					for(int i=0;i<s.size();i++){
						if(s[i]=='?'){
							s[i]='a';
						}
					}
					cout << s << endl;
					return 0;
				}
			}
		}
	}
	
	/*
	if(s_base==s){
		cout << "UNRESTORABLE" << endl;
		return 0;
	}
	*/
	
	cout << "UNRESTORABLE" << endl;
	return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v)   (v).begin(),(v).end()
#define debug(x) cerr<<#x<<": "<<(x)<<endl
#define INF      (int)1e9
#define EPS      (double)1e-9
#define MOD      ((int)1e9+7)
using namespace std;
typedef long long     llong;
typedef vector<int>   vi;
typedef vector<vi >   vvi;
typedef vector<vvi >  vvvi;
typedef pair<int,int> pii;
template<class Type> void line(const Type &a){int cnt=0;for(const auto &elem:a){if(cnt++)cout<<' ';cout<<elem;}cout<<endl;}

int main(){
	int n,m;
	cin>>n>>m;
	
	vi h(n);
	REP(i,n) cin>>h[i];
	
	vector<bool> jud(n,true);
	REP(i,m){
		int a,b;
		cin>>a>>b;
		a--, b--;
		if(h[a]==h[b]) jud[a]=jud[b]=false;
		else if(h[a]>h[b]) jud[b]=false;
		else jud[a]=false;
	}
	
	int ans=0;
	REP(i,n){
		if(jud[i]) ans++;
	}
	
	cout<<ans<<endl;
}

Measured memory_bytes: 3736