akhauriyash/Code-Regression huggingface dataset:
//#include <bits/stdc++.h>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <numeric>
#include <iomanip>  //setprecision(桁)
using namespace std;
#define pb push_back
#define ll long long int
#define rep(i,n) for(int i = 0;i < n;i++)
#define INF 1e+9
const ll MOD = 1000000007;

struct edge {
    int to;
    double cost;
};

// <最短距離, 頂点の番号>
using P = pair<double, int>;

int V;
const int ci = 2e5+ 5;
vector<edge> G[ci];
double d[ci];

void dijkstra(int s) {
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d+V, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) { //cout << "On" << endl;
        P p = que.top();
        que.pop();
        int v = p.second; //cout << "v=" << v << endl;
        if (d[v] < p.first) continue;
        for (int i=0; i<G[v].size(); i++) {
            edge e = G[v][i]; //cout << "koo" << endl;
            if (d[e.to] > d[v] + e.cost) { //cout << e.cost << endl;
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}
ll modPow(ll a, ll n, ll p) {
    if (n == 0) return 1; // 0乗にも対応する場合
    if (n == 1) return a % p;
    if (n % 2 == 1) return (a * modPow(a, n - 1, p)) % p;
    long long t = modPow(a, n / 2, p);
    return (t * t) % p;
}
//ll dp[200005];

int main(){
    string s; cin >> s;
    ll n = s.size();
    vector<ll> dp(n+1);
    for(ll i = 0; i < n; i++){
        ll c = s[n - 1 - i] - '0';
        ll d = modPow(10,i,2019);
        ll e = (c * d) % 2019;
        dp[i+1] = (dp[i] + e) % 2019;
    }
    sort(dp.begin(),dp.end());
    int cnt = 1;
    ll ans = 0;
    for(ll i = 0; i < n; i++){
        if(dp[i+1] == dp[i]){
            cnt++;
            continue;
        }
        ans += cnt * (cnt - 1) / 2;
        cnt = 1;
    }
    ans += cnt * (cnt - 1) / 2;
    cout << ans << endl;
}


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

template <class Abel>
class UnionFind{
    vector<int> par_, weight_;
public:
    UnionFind(size_t n){
        par_.assign(n, -1);
        weight_.assign(n, 0);
    }

    int root(int x){
        if (par_[x] < 0) {
            return x;
        }else{
            int res = root(par_[x]);
            weight_[x] += weight_[par_[x]];
            return par_[x] = res;
        }
    }

    int weight(int x){
        root(x);
        return weight_[x];
    }

    int weight(int x, int y){
        return weight(y) - weight(x);
    }

    int size(int x){
        return -par_[root(x)];
    }

    bool IsSame(int x, int y){
        return root(x) == root(y);
    }

    void Merge(int x, int y, Abel w){
        w += weight(x);
        w -= weight(y);
        x = root(x);
        y = root(y);
        if (x == y)
            return;
        if (size(x) < size(y)) {
            w = -w;
            swap(x, y);
        }
        par_[x] += par_[y];
        par_[y] = x;
        weight_[y] = w;
    }
};

int main(){
    int n, m, k;
    cin >> n >> m >> k;
    UnionFind<int> UF(n);
    vector<vector<int>> F(n), B(n);
    for (int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        F[a].push_back(b);
        F[b].push_back(a);
        UF.Merge(a, b, 0);
    }

    for (int i = 0; i < k; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        B[a].push_back(b);
        B[b].push_back(a);
    }

    for (int i = 0; i < n; i++){
        int block_cnt = 0;
        for (const auto &b: B[i]){
            if (UF.IsSame(i, b))
                block_cnt++;
        }

        cout << UF.size(i) - 1 - F[i].size() - block_cnt << " ";
    }
    cout << endl;
}

Measured memory_bytes: 12664
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<unordered_set>
#include<unordered_map>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;

using namespace std;
#define N 200010
ll f[N],g[N],h[N],n;
unordered_set<ll> v[N];

unordered_map<ll,ll> q[N];
ll qry(ll x,ll surf){
    if(x>surf)return 0;
    if(q[x].find(surf)!=q[x].end()){
	return q[x][surf];
    }
    ll sum=1;
    for(auto to:v[x]){
	sum+=qry(to,surf);
    }
    q[x][surf]=sum;
    return sum;
}
void G(ll x,ll p,ll maxi){
    g[x]=qry(x,maxi);
    maxi=max(maxi,p);
    for(auto to:v[x]){
	G(to,x,maxi);
    }
}

void H(){
    for(int i=1;i<=n;i++){
	h[i]=-g[i];
	for(auto to:v[i]){
	    h[i]+=g[to];
	}
    }
}

void F(ll x,ll sum){
    sum+=h[x]+1;
    f[x]=sum;
    for(auto to:v[x]){
	F(to,sum);
    }
}

void $(ll x,ll from){
    v[x].erase(from);
    for(auto to:v[x]){
	$(to,x);
    }
}
int main(){
    cin>>n;
    lol(i,n-1){
	ll a,b;cin>>a>>b;
	v[a].insert(b);
	v[b].insert(a);
    }$(1,0);
    G(1,0,0);
    //for(int i=1;i<=n;i++)cout<<g[i]<<" ";cout<<endl;
    H();
    F(1,-1);
    for(int i=2;i<=n;i++){
	if(i>2)cout<<" ";
	cout<<f[i];
    }cout<<endl;
    return 0;
}


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

template <class T>
inline void read(T &res)
{
	char ch; bool flag = false; res = 0;
	while (ch = getchar(), !isdigit(ch) && ch != '-');
	ch == '-' ? flag = true : res = ch ^ 48;
	while (ch = getchar(), isdigit(ch))
		res = res * 10 + ch - 48;
	flag ? res = -res : 0;
}

template <class T>
inline void put(T x)
{
	if (x > 9)
		put(x / 10);
	putchar(x % 10 + 48);
}

template <class T>
inline void CkMax(T &x, T y) {x < y ? x = y : 0;}
template <class T>
inline void CkMin(T &x, T y) {x > y ? x = y : 0;}
template <class T>
inline T Max(T x, T y) {return x > y ? x : y;}
template <class T>
inline T Min(T x, T y) {return x < y ? x : y;}

typedef long long ll;
const int N = 1e5 + 5;
int a[N], n, m, V, P, ans;
ll sum[N];

int main()
{
	read(n); read(m); read(V); read(P);
	for (int i = 1; i <= n; ++i)
		read(a[i]);
	std::sort(a + 1, a + n + 1);
	for (int i = 1; i <= n; ++i)
		sum[i] = sum[i - 1] + a[i];
	for (int i = 1; i <= n; ++i)
	{
		int l = std::upper_bound(a + 1, a + n + 1, a[i]) - a,
			r = std::upper_bound(a + 1, a + n + 1, a[i] + m) - a - 1;
		if (l - 2 + n - r >= V - 1)
		{
			if (n - r + 1 <= P)
				++ans;
		}
		else
		{
			V -= l - 1 + n - r;
			int tl = 0, tr = r - l + 1, res = -1;
			while (tl <= tr)
			{
				int mid = tl + tr >> 1;
				if (V <= mid || 1ll * (r - l + 1 - mid) * (a[i] + m) - (sum[r - mid] - sum[l - 1]) >= 1ll * (V - mid) * m)
					res = mid, tr = mid - 1;
				else
					tl = mid + 1;
			}
			if (~res)
			{
				if (n - r + 1 + res <= P)
					++ans;
			}
			V += l - 1 + n - r;
		}
	}
	put(ans), putchar('\n');
	
	return 0;
}

Measured memory_bytes: 1408
N = int(input())
S = input()
S_set = list(set(S))
mx_ans = 0
for n in range(N):
  X = S[:n]
  Y = S[n:]
  ans = 0
  for i in range(len(S_set)):
    if (X.count(S_set[i])>0) and (Y.count(S_set[i])>0):
      ans += 1
  if mx_ans < ans:
    mx_ans = ans
print(mx_ans)

Measured memory_bytes: 3064
import java.io.*;
public class Main{
    public static void main(String[] args) throws IOException{
        Reader r = new Reader();    
        int[] a = r.ii();
        print(a[0]-a[1]+1);
    }
    static void print(Object o){
        System.out.println(o.toString());
    }
    static class Reader extends BufferedReader{
        Reader(){
            super(new InputStreamReader(System.in));
        }
        String s() throws IOException{
            return readLine();
        }
        String[] ss() throws IOException{
            return s().split(" ");
        }
        int Int(String s){
            return Integer.parseInt(s);
        }
        int i() throws IOException{
            return Int(s());
        }
        int[] ii() throws IOException{
            String[] ss = ss();
            int size = ss.length;
            int[] ii = new int[size];
            for(int j = 0; j < size; j++) ii[j] = Int(ss[j]);
            return ii;
        }
    }
}

Measured memory_bytes: 22484
MOD = 1000000007

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

T = [0 for _ in range(N + 5)]

for a in A:
    T[a] = -1

T[0] = 1
for i in range(0, N):
    if i + 1 <= N and T[i + 1] != -1 and T[i] != -1:
        T[i + 1] = (T[i + 1] + T[i]) % MOD
    if i + 2 <= N and T[i + 2] != -1 and T[i] != -1:
        T[i + 2] = (T[i + 2] + T[i]) % MOD

print(T[N])


Measured memory_bytes: 7856
#include <bits/stdc++.h>
using namespace std;typedef long long ll;typedef vector<ll> vl;typedef vector<vl> vvl;typedef pair<ll,ll> pl;typedef vector<pl> vp;const ll INF=1001001001;const ll LINF=1001001001001001001;const ll D4[]={0,1,0,-1,0};const ll D8[]={0,1,1,0,-1,-1,1,-1,0};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(b<a){a=b;return 1;}return 0;}
#define fore(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()

void solve(long long A, long long B, long long T){
    cout<<(T/A*B)<<endl;
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long T;
    scanf("%lld",&T);
    solve(A, B, T);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define deb(x) cout<<#x<<"="<<x<<endl;
#define endl '\n'
#define M 1000000007
#define int long long
#define max_n 1000000

using namespace std;

void solve()
{
	ll n;
	cin>>n;
	ll a[n];
	map<ll,ll> f;
	for (int i = 0; i < n; ++i)
	{
		cin>>a[i];
		f[a[i]]++;
	}
	ll ans[n];
	ll s=0;
	for(auto i:f)
	{
		ll c=i.second;
		s+=c*(c-1)/2;
	}
	for (int i = 0; i < n; ++i)
	{
		ll c=f[a[i]];
		cout<<s-c*(c-1)/2+max(0LL,(c-1)*(c-2)/2)<<endl;
	}
}

int32_t main() 
{
	IOS	
	ll T=1;
	// cin>>T;
	for(ll i=1;i<=T;++i)
	{		
		// cout<<"Case #"<<i<<": ";
    	solve();
	}
	return 0;
}

Measured memory_bytes: 11136
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
#include<cstring>
#include<stdio.h>
#include<fstream>
#include<stdlib.h>
#include<math.h> 
#include<queue>
#include<string.h>



#define INF 1000000000

using namespace std;

int v,e,r;
vector<pair<int,int> > g[100000];
int olded[100000];



void tanitu(){
	priority_queue<pair<int, int> >pri_qu;
	int a[100000];

	for(int i=0;i<v;i++){
		a[i]=INF;
	}
	a[r]=0;
	pri_qu.push(make_pair(r,0));

	while(1){

		int fir=pri_qu.top().first;
		int sec=pri_qu.top().second;
		pri_qu.pop();

		int g_size=g[fir].size();

		for(int i=0;i<g_size;i++){

			int tmp1=g[fir][i].first;
			int tmp2=g[fir][i].second;

			if(a[tmp1]>tmp2-sec){
				a[tmp1]=tmp2-sec;
				pri_qu.push(make_pair(tmp1, -a[tmp1]));
			}
		}
		if(pri_qu.empty())break;
	}
	for(int i=0;i<v;i++){
		if(a[i]==INF)cout<<"INF"<<endl;
		else cout<<a[i]<<endl;
	}
}


int main(){
	cin>>v>>e>>r;
	int s,t,d;
	for(int i=0;i<e;i++){
		cin>>s>>t>>d;
		g[s].push_back(make_pair(t,d));
	}
	tanitu();
}





Measured memory_bytes: 20412
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int H;
		int W;
		while(true){
			H = sc.nextInt();
			W = sc.nextInt();
			if ((H == 0) && (W == 0)){break;}
			String[] str = new String[]{"#", "."};
			for (int i = 1; i <= H; i++){
				if (i % 2 == 0){
					for(int j = 1; j <= W; j++){
						System.out.print(str[j % 2]);
					}
				} else {
					for (int j = 1; j <= W; j++){
						System.out.print(str[(j + 1) % 2]);
					}
				}
				System.out.println("");
			}
			System.out.println("");
		}
	}
}

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

#define ll long long

#define all(a) (a).begin(),(a).end()
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define Rep(i,n,m) for(int i=(int)(n);i<(int)(m);i++)
#define RepS(i,n,m) for(int i=(int)(n);i<=(int)(m);i++)
#define output_s(a) printf("%s\n",(a).c_str())

//library----------------------------------------------


int main(){
    string s; cin>>s;
    sort(all(s));
    if(s[0]==s[1]&&s[2]==s[3]&&s[1]!=s[2]){
        printf("Yes\n");
    }else{
        printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 256
/*
Author: CNYALI_LK
LANG: C++
PROG: agc020.cpp
Mail: cnyalilk@vip.qq.com
*/
#include<bits/stdc++.h>
#define debug(...) fprintf(stderr,__VA_ARGS__)
#define DEBUG printf("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#define Debug debug("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#define all(x) x.begin(),x.end()
using namespace std;
const double eps=1e-8;
const double pi=acos(-1.0);
typedef long long ll;
typedef pair<int,int> pii;
template<class T>int chkmin(T &a,T b){return a>b?a=b,1:0;}
template<class T>int chkmax(T &a,T b){return a<b?a=b,1:0;}
template<class T>T sqr(T a){return a*a;}
template<class T>T mmin(T a,T b){return a<b?a:b;}
template<class T>T mmax(T a,T b){return a>b?a:b;}
template<class T>T aabs(T a){return a<0?-a:a;}
#define min mmin
#define max mmax
#define abs aabs
int read(){
	int s=0,base=1;
	char c;
	while(!isdigit(c=getchar()))if(c=='-')base=-base;
	while(isdigit(c)){s=s*10+(c^48);c=getchar();}
	return s*base;
}
char WriteIntBuffer[1024];
template<class T>void write(T a,char end){
	int cnt=0,fu=1;
	if(a<0){putchar('-');fu=-1;}
	do{WriteIntBuffer[++cnt]=fu*(a%10)+'0';a/=10;}while(a);
	while(cnt){putchar(WriteIntBuffer[cnt]);--cnt;}
	putchar(end);
}
int main(){
#ifdef cnyali_lk
	freopen("agc020.in","r",stdin);
	freopen("agc020.out","w",stdout);
#endif
	int n,a,b;
	n=read();a=read();b=read();
	if((b-a)&1)printf("Borys\n");
	else printf("Alice\n");
	return 0;
}



Measured memory_bytes: 384
// 単一始点最短経路 ( ダイクストラ法 )
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<vector>

using namespace std;

static const int MAX = 100;
static const int INFTY = (1 <<21);
static const int WHITE = 0;
static const int GRAY = 1;
static const int BLACK = 2;

int n, M[MAX][MAX];

int Dijkstra()
{
    int u, minv;
    int d[MAX], p[MAX], color[MAX];

    for(int i = 0; i < n; i++)
    {
        d[i] = INFTY;
        p[i] = -1;
        color[i] = WHITE;
    }

    // 初期値の設定
    d[0] = 0;
    color[0] = GRAY;

    while(1)
    {
        minv = INFTY;
        // 次に移動するべき頂点
        u = -1;

        for(int i = 0; i < n; i++)
        {
            if( minv > d[i] && color[i] != BLACK )
            {
                // 未訪問の頂点の中で, 最小のコストを持つ頂点を探索する
                u = i;
                minv = d[i];
            }
        }

        if( u == -1 )
        {
            // 最短経路が見つかった
            break;
        }

        // 訪問完了
        color[u] = BLACK;

        for(int v = 0; v < n; v++)
        {
            if( color[v] != BLACK && M[u][v] != INFTY )
            {
                // u → v の経路の中で, vのコストが最小のものが見つかれば更新する
                if( d[v] > d[u] + M[u][v] )
                {
                    // コストの記録
                    d[v] = d[u] + M[u][v];
                    // 頂点 v の親を記録する
                    p[v] = u;
                    // 訪問状態の記録
                    color[v] = GRAY;
                }
            }
        }
    }

    // 結果の表示
    for(int i = 0; i < n; i++)
    {
        cout << i << " " << ( d[i] == INFTY ? -1 : d[i] ) << endl;
    }

    return 0;
}

int main(void)
{

    cin >> n;

    for(int i = 0; i < n; i++)
    {
        for(int j = 0; j < n; j++)
        {
            // 配列の初期化
            M[i][j] = INFTY;
        }
    }

    int k, c, u, v;

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

        for(int j = 0; j < k; j++)
        {
            cin >> v >> c;

            M[u][v] = c;
        }
    }

    Dijkstra();

    return 0;

}



Measured memory_bytes: 3132
from sys import stdin
input = stdin.readline
class SegTree():
    def segfunc(self, x, y):
        return x+y

    def __init__(self, ide, n, init_val):
        self.ide_ele = ide
        self.num = 2**(n-1).bit_length()
        self.seg = [self.ide_ele] * 2 * self.num
        for i in range(n):
            self.seg[i+self.num-1] = init_val[i]    
        for i in range(self.num-2,-1,-1):
            self.seg[i] = self.segfunc(self.seg[2*i+1],self.seg[2*i+2]) 
    def update(self, k, x):
        k += self.num-1
        self.seg[k] = x
        while k:
            k = (k-1)//2
            self.seg[k] = self.segfunc(self.seg[k*2+1], self.seg[k*2+2])
    def query(self, p, q):#p <= x < q
        if q<=p:
            return self.ide_ele
        p += self.num-1
        q += self.num-2
        res = self.ide_ele
        while q-p>1:
            if p&1 == 0:
                res = self.segfunc(res, self.seg[p])
            if q&1 == 1:
                res = self.segfunc(res, self.seg[q])
                q -= 1
            p = p//2
            q = (q-1)//2
        if p == q:
            res = self.segfunc(res, self.seg[p])
        else:
            res = self.segfunc(self.segfunc(res, self.seg[p]), self.seg[q])
        return res

n, q = map(int, input().split())
color = list(map(int, input().split()))
qry = [None]*q
ans = [0]*q
p = 0
for _ in ans:
    l, r = map(int, input().split())
    qry[p] = [l-1, r, p]
    p += 1
qry.sort(key=lambda x: x[1])
dic = {}
last_update_idx = 0
seg = SegTree(0, n, [0]*n)
for l, r, i in qry:
    if last_update_idx < r:
        st = set()
        for j in range(last_update_idx, r):
            if not color[j] in st and color[j] in dic:
                seg.update(dic[color[j]], 0)
            dic[color[j]] = j
            st.add(color[j])
        for v in st:
            seg.update(dic[v], 1)
        last_update_idx = r
    ans[i] = seg.query(l, r)
for v in ans:
    print(v)


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

int main() {
	double d;
	while (cin >> d) {
		for (int i = 1;; i++) {
			double y = sqrt(5.*(i - 1) / 4.9);
			if (9.8*y >= d) { cout << i << endl; break; }
		}
	}
	return 0;
}

Measured memory_bytes: 3200
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String[] words = new String[]{"dream","dreamer","erase","eraser"};
    int n = s.length();
    boolean[] dp = new boolean[n+1];
    dp[n] = true;
    for (int i = n-1; i >= 0; i--){
      for (String word: words){
        if (s.substring(i).startsWith(word)){
          dp[i] = dp[i] || dp[i+word.length()];
        }
      }
    }
    if (dp[0] == true){
      System.out.println("YES");
    }else{
      System.out.println("NO");
    }
  }
}

Measured memory_bytes: 56740
def solve(S):
    l=len(S)
    for i,s in enumerate(S[:-1]):
        if s==S[i+1]:
            return i+1,i+2
    for i,s in enumerate(S[:-2]):
        if s==S[i+2]:
            return i+1,i+3
    return -1,-1

S=input()
print(*solve(S))

Measured memory_bytes: 3188
#include <bits/stdc++.h>
typedef long long ll;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,a) FOR(i,0,a)
	
using namespace std;
const int MAX_N=1e5,MAX_M=1e5;
const ll MOD=1e9+7;
ll n,m;
ll x[MAX_N],y[MAX_M];
int main(){
	cin>>n>>m;
	REP(i,n){
		cin>>x[i];
	}
	REP(i,m){
		cin>>y[i];
	}
	ll xsm=0,ysm=0;
	REP(i,n-1){
		xsm+=(i+1)*(n-i-1)%MOD*(x[i+1]-x[i])%MOD;
		xsm%=MOD;
	}
	REP(i,m-1){
		ysm+=(i+1)*(m-i-1)%MOD*(y[i+1]-y[i])%MOD;
		ysm%=MOD;
	}
	cout<<xsm*ysm%MOD<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>
#include <math.h>

int main(void){
  double x1,y1,x2,y2;
  
  scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
  printf("%0.8lf\n",sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2)));
  
  return(0);
}

Measured memory_bytes: 656
import sys
sys.setrecursionlimit(10 **5)

# sys.stdin = open('input.txt', 'r')
# sys.stdout = open('output.txt', 'w')

readline = sys.stdin.readline

def proc():
    x,n = map(int, readline().rstrip().split())
    a = list(map(int, readline().rstrip().split()))
    hash_map = {}
    for i in a:
        hash_map[i] = True
    
    if not n or x not in hash_map:
        return x
    
    
    p,q = x-1, x+1
    while 1:
        if p not in hash_map and q not in hash_map:
            return p
        elif p not in hash_map:
            return p
        elif q not in hash_map:
            return q
        
        p-=1
        q+=1
    

#for _ in range(int(readline())):
print(proc())

Measured memory_bytes: 9120
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	run()
}

func run() {
	setSpace()
	a, b, k := readN(), readN(), readN()
	n := max(a, b)
	ks := make([]int, 0, n+1)
	for i := 1; i <= n; i++ {
		if a%i == 0 && b%i == 0 {
			ks = append(ks, i)
		}
	}
	fmt.Println(ks[len(ks)-k])
}

func max(a, b int) int {
	var n int
	if a < b {
		n = a
	} else {
		n = b
	}
	return n
}

// ------以下、ユーティリティ------

var sc = bufio.NewScanner(os.Stdin)

func setSpace() {
	sc.Split(bufio.ScanWords)
}

func read() string {
	sc.Scan()
	return sc.Text()
}

func readN() int {
	n, err := strconv.Atoi(read())
	if err != nil {
		panic(err)
	}
	return n
}


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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i, a, b) for(int i = a; i < b; i++)
#define fastio ios::sync_with_stdio(0); cin.tie(0);

int main() {
	//fastio;
	double prob = 0.0;
	int n, k;
	cin >> n >> k;
	for (int i = 1; i <= n; i++) {
		int score = i;
		//cout << score << endl; 
		if (score < k) {
			int rhs = k/score;
			//cout << rhs << endl;
			if (k%score != 0)
				rhs++;
			int x = log2(rhs);
			if(pow(2, x) != rhs)
				x++;
			//cout << x << endl;
			prob += (1/((double)n))*(double)pow(0.5, x);
		}
		else 
			prob += (1/((double)n));
		//cout << prob << endl;
	}
	printf("%0.12f\n", prob);
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <tuple>
#include <utility>
#include <vector>
using namespace std;

constexpr int MOD = 1000000007;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> PLL;

int main() {
    string s;
    cin >> s;
    int state = 0;
    for (int j = 0 ; j < s.size(); ++j) {
        if (state == 0 && s[j] == 'C') {
            ++state;
        }
        if (state == 1 && s[j] == 'F') {
            ++state;
        }
    }
    if (state == 2) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 764
#include <cstdio>
#include <iostream>
#include <cmath>
#include <ctype.h>
#include <string> 
#include <sstream>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
 
using namespace std;

int count(long long int n);

int main()
{
    long long int n;
    cin >> n;
    int cnt = 0;
    cnt = count(n);
    cout << cnt << endl;
    return 0;
}

int count(long long int n)
{
    if(n == 2 || n == 3) return 1;
    else if(n == 4) return 2;
    else if(n % 3 == 0) return count(n / 3) + 1;
    else return count(n / 3 + 1) + 1;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
#define int long long int

signed main(){
    int h, n;
    cin >> h >> n;
    int r = 0;
    int buffer;
    for(int i=0;i<n;i++){
        cin >> buffer;
        r += buffer;
    }
    if(r >= h){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
#define INF (1<<24)
#define MAX_N 50
struct state{
  int pi,pj,cost;
  bool operator < (const state &p)const{
    return cost > p.cost;  
  }
};
 
int n;
int d[MAX_N][4];
int t[MAX_N],u[MAX_N];
 
void solve(){
  for(int i=0;i<MAX_N;i++)
    for(int j=0;j<4;j++)d[i][j]=INF;
  d[0][0]=0;
  priority_queue<state> Q;
  Q.push((state){0,0,0});
 
  while(!Q.empty()){
    state s=Q.top();Q.pop();
    if(s.cost>d[s.pi][s.pj])continue;
    if(s.pi==n+1){cout<<"OK "<<s.cost<<endl;return;}
    
    int k=s.pj+1;
 
    int di=abs(t[s.pi]-t[s.pi+1]);
     
    if(s.pj<3){
      int td=di*k;
      if(d[s.pi+1][s.pj+1]>s.cost+di){
    if(td<=u[s.pi+1]-u[s.pi]){
      d[s.pi+1][s.pj+1]=s.cost+di;
      Q.push((state){s.pi+1,s.pj+1,s.cost+di});
    }
      }
    }
     
 
    int td=t[s.pi]*k;
    for(int i=1;i<=s.pj;i++){
      int nk=k-i;
      int td2=t[s.pi+1]*nk;
      if(td+td2>u[s.pi+1]-u[s.pi])continue;
      if(s.cost+t[s.pi]+t[s.pi+1]<d[s.pi+1][nk]){
    d[s.pi+1][nk]=t[s.pi]+t[s.pi+1]+s.cost;
    Q.push((state){s.pi+1,nk,d[s.pi+1][nk]});
      }
    }
  }
  
  for(int i=0;i<=n;i++){
    bool flg=false;
    for(int j=0;j<4;j++)
      if(d[i][j]!=INF)flg=true;
    if(!flg){
      cout<<"NG "<<i<<endl;return;
    }
  }
  
}
 
int main(){
  while(1){
    cin>>n;
    if(n==0)break;
    for(int i=1;i<=n;i++)cin>>t[i]>>u[i];
    t[n+1]=0;
    u[n+1]=INF;
    solve();
  }
  return 0;
}

Measured memory_bytes: 1220
def ask(n):
    # global test
    l = ["Vacant", "Male", "Female"]
    # if test is not None:
    #     return l.index(test[n])
    # else:
    print(n, flush=True)
    return l.index(input())


def resolve():
    N = int(input())
    sheets = [-1 for _ in range(N)]
    sheets[0] = ask(0)
    if sheets[0] == 0:
        return
    sheets[N - 1] = ask(N - 1)
    if sheets[N - 1] == 0:
        return
    ng = 0
    ok = N - 1
    mid = (ok + ng) // 2
    sheets[mid] = ask(mid)
    # cnt = 3
    while sheets[mid] != 0:  # and cnt < 30:
        mid = (ok + ng) // 2
        sheets[mid] = ask(mid)
        # cnt += 1
        # print(mid, file=sys.stderr)
        if ((mid - ng) % 2 and sheets[ng] == sheets[mid]) \
                or ((mid - ng + 1) % 2 and sheets[ng] != sheets[mid]):
            ok = mid
        else:
            ng = mid
    # if cnt > 20:
    #     raise SystemError("cnt")
    # else:
    #     print("cnt=", cnt, file=sys.stderr)


resolve()


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

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

Node root;

void insert(int);
void inorder(Node);
void preorder(Node);

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

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

  return 0;
}


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

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

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

  if(y==NIL) root=z;
  else if(z->key < y->key) y->left=z;
  else y->right=z;
}

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

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



Measured memory_bytes: 25152
#include <stdio.h>
#include <ctype.h>

int main() {

  char ch[1200];
  int i,n;
  n=0;
  char a[1200];

  while(1) {
    scanf("%c",&a[n]);
    if(a[n] == '\n') {
      break;
    }
    ch[n] = a[n];
    if('A' <= a[n] && a[n] <= 'Z') {
      ch[n] = a[n] + 32;
    } else if(a[n] >= 'a' && a[n] <= 'z') {
      ch[n] = a[n] - 32;

    }
    
    
    n = n +1;
    
  }
  
  for(i=0; i<n ; i++) {
    printf("%c" ,ch[i]);
  }
  printf("\n"); 
  return 0;
  
}


Measured memory_bytes: 2080
s = input()
t = input()
k = len(t)-1

cnt = 9999999

for i in range((len(s)-k)+1):

    if i == 0:
        continue

    Q = s[i-1:i+k]
    x = 0
    for j in range(len(t)):
        x += Q[j] != t[j]
    cnt = min(cnt,x)

print(cnt)
        

Measured memory_bytes: 8948
#include <bits/stdc++.h>
#define NMAX 1000005
#define LOGMAX (int)log2(NMAX)+2
#define MOD 998244353
/*#include <atcoder/convolution>
#include <atcoder/dsu>
#include <atcoder/fenwicktree>
#include <atcoder/lazysegtree>
#include <atcoder/math>
#include <atcoder/maxflow>
#include <atcoder/mincostflow>
#include <atcoder/modint>
#include <atcoder/scc>
#include <atcoder/segtree>
#include <atcoder/string>
#include <atcoder/twosat>
*/
using namespace std;
typedef long long ll;

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    ll n;
    cin>>n;
    while(n--)
        cout<<"ACL";
    return 0;
}


Measured memory_bytes: 3652
import sys
input = lambda: sys.stdin.readline().rstrip("\r\n")

n = int(input())

def num_divisors_table(n):
    table = [0] * (n + 1)
    
    for i in range(1, n + 1):
        for j in range(i, n + 1, i):
            table[j] += 1
    
    return table

table = num_divisors_table(n)
ans = 0
for i in range(1, n + 1, 2):
    if table[i] == 8:
        ans += 1
print(ans)

Measured memory_bytes: 63880
H,W=map(int,input().split())
N=int(input())
A=list(map(int,input().split()))
ans = []
for i in range(N):
  ans+=[i+1]*A[i]
for i in range(H):
  dum=ans[i*W:(i+1)*W]
  if i%2==0:
    print(*dum[:])
  else:
    print(*dum[::-1])


Measured memory_bytes: 3920
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
A,B,C,X,Y = map(int,readline().split())
AB = 2*max(X,Y)
price = float('inf')
for i in range(0,AB+1,2):
  total = A * max(0,X-i//2)+ B * max(0,Y-i//2) + C * i 
  price = min(price,total)
print(price)

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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  cout.tie(NULL);
  //#ifndef ONLINE_JUDGE
  //freopen("date.in", "r", stdin);
  //freopen("date.out", "w", stdout);
  //#endif //ONLINE_JUDGE

  int n;
  cin >> n;

  int a, b, c, d;
  a = n / 1000;
  b = n % 1000 / 100;
  c = n % 100 / 10;
  d = n % 10;

  if(a + b + c + d == 7) {
    cout << a << "+" << b << "+" << c << "+" << d << "=7";
    return 0;
  }
  if(a + b + c - d == 7) {
    cout << a << "+" << b << "+" << c << "-" << d << "=7";
    return 0;
  }
  if(a + b - c + d == 7) {
    cout << a << "+" << b << "-" << c << "+" << d << "=7";
    return 0;
  }
  if(a + b - c - d == 7) {
    cout << a << "+" << b << "-" << c << "-" << d << "=7";
    return 0;
  }
  if(a - b + c + d == 7) {
    cout << a << "-" << b << "+" << c << "+" << d << "=7";
    return 0;
  }
  if(a - b + c - d == 7) {
    cout << a << "-" << b << "+" << c << "-" << d << "=7";
    return 0;
  }
  if(a - b - c + d == 7) {
    cout << a << "-" << b << "-" << c << "+" << d << "=7";
    return 0;
  }
  if(a - b - c - d == 7) {
    cout << a << "-" << b << "-" << c << "-" << d << "=7";
    return 0;
  }
}


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

using namespace std;
typedef long long ll;
//typedef unsigned long long ll;

//#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
//#define sz(x) ll(x.size())
//typedef pair<ll, int> P;
typedef pair<ll, ll> P;
//const double INF = 1e10;
const ll INF = LONG_LONG_MAX / 100;
//const ll INF = 1e15;
const ll MINF = LONG_LONG_MIN;
//const int INF = INT_MAX / 10;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)

bool contain(set<char> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
void print_line(vector<ll> &line) {
    for (int i = 0; i < line.size(); i++) {
        cout << line[i];
        if (i == line.size() - 1) cout << endl;
        else cout << ' ';
    }
}

typedef priority_queue<long long, vector<long long>, greater<long long> > PQ_ASK;
const int mod = 1000000007;

struct D {
    int n, e, w, s, b, t;

    D north() {
        D d{t, e, w, b, n, s};
        return d;
    }

    D south() {
        D d{b, e, w, t, s, n};
        return d;
    }

    D west() {
        D d{n, b, t, s, w, e};
        return d;
    }

    D east() {
        D d{n, t, b, s, e, w};
        return d;
    }

};

int main() {

    D d;
    cin >> d.t >> d.s >> d.e >> d.w >> d.n >> d.b;

    string s;
    cin >> s;

    rep(i, s.size()) {
        char c = s[i];
        if (c == 'S') d = d.south();
        else if (c == 'N') d = d.north();
        else if (c == 'E') d = d.east();
        else if (c == 'W') d = d.west();
    }

    cout << d.t << endl;

}


Measured memory_bytes: 3196
#include<stdio.h>

int main()
{
	int a,b,c,i,count=0;
	scanf("%d %d %d",&a,&b,&c);
	
	for(i=a;i<=b;i++)
	{
		if(c%i==0)count++;
	}
	printf("%d\n",count);
	return 0;
}

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

int main() {
    int tmp, i;
    int sum_a = 0, sum_b = 0;

    for (i=0; i<4; i++) {
        cin >> tmp;
        sum_a += tmp;
    }
    for (i=0; i<4; i++) {
        cin >> tmp;
        sum_b += tmp;
    }

    cout << max(sum_a, sum_b) << endl;
    return 0;
}

Measured memory_bytes: 1160
//#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef pair<int, int> PII;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define IN(a, b, x) (a<=x&&x<b)
#define MP make_pair
#define PB push_back
#ifdef int
const ll INF = (1LL<<60);
#else
const int INF = (1LL<<30);
#endif
const double PI = 3.14159265359;
const double EPS = 1e-12;
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }

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

struct edge{ int to, cost; };

int p[810], d[810], ans1, ans2;
vector<edge> g[810];

int dfs(int num, int prev) {
  // cout << num << " " << prev << endl;
  int res = 0;
  for(edge e: g[num]) {
    if(e.to == prev) continue;
    if(g[e.to].size() == 1) ans2 += e.cost;
    else {
      ans1 += e.cost;
      chmax(res, e.cost + dfs(e.to, num));
    }
  }
  return res;
}

signed main(void)
{
  while(true) {
    int n;
    cin >> n;
    if(!n) break;
    REP(i, n-1) cin >> p[i], p[i]--;
    REP(i, n-1) cin >> d[i];
    REP(i, n) g[i].clear();
    REP(i, n-1) {
      g[i+1].PB({p[i], d[i]});
      g[p[i]].PB({i+1, d[i]});
    }

    int ret = INF;
    REP(i, n) {
      ans1 = 0, ans2 = 0;
      int res = dfs(i, -1);
      chmin(ret, ans1*3 - res + ans2);
      // cout << "i:" << i << " " << ans1 << " " << res << " " << ans2 << endl;
    }
    cout << ret << endl;
  }

  return 0;
}

Measured memory_bytes: 3364
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define call(var) cout<<#var<<"="<<var<<endl;
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

int main(){
    string a,b,c;
    cin >> a >> b >> c;
    char A = (a[0] - 'a' + 'A');
    char B = (b[0] - 'a' + 'A');
    char C = (c[0] - 'a' + 'A');
    cout << A << B << C << endl;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

	public static void main(String[] args) throws IOException {
		new Main().solve();
	}

	private void solve() throws IOException {
		try {
			solveA();
			//			 solveB();
			//			 solveC();
			//			 solveD();
			//			 solveE();
			//			 solveF();
		} finally {
			if (in != null) {
				in.close();
			}
			if (out != null) {
				out.flush();
				out.close();
			}
		}

	}

	private void solveA() {
		int numR = nextInt();
		int numG = nextInt();
		int numB = nextInt();

		int num = (numR * 100 + numG * 10 + numB);

		out.println(num % 4 == 0 ? "YES" : "NO");
	}

	private void solveB() {
		int numN = nextInt();

		out.println("");
	}

	private void solveC() {
		int numN = nextInt();

		out.println("");
	}

	private void solveD() {
		int numN = nextInt();

		out.println("");
	}

	private void solveE() {
		int numN = nextInt();

		out.println("");
	}

	private void solveF() {
		int numN = nextInt();

		out.println("");
	}

	private final PrintWriter out = new PrintWriter(System.out);
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean hasNext() {
		skipUnprintable();
		return hasNextByte();
	}

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

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}
}

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

struct edge { int to, cost; };
typedef pair<int, int> P;
typedef pair<string, int> SP;
#define rep(i, a, b) for(int i = a; i < b; ++i)

const int INF = 1e9 + 7;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;


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

    
    int N, M;
    cin >> N >> M;
    vector<int> H(N+1);
    rep(i, 1, N+1){
        cin >> H[i];
    }

    vector<int> ans(N+1);
    fill(ans.begin(), ans.end(), 1);
    int a, b;
    rep(i, 0, M){
        cin >> a >> b;
        if(H[a] > H[b]){
            ans[b] = 0;
        }
        else if(H[a] < H[b]){
            ans[a] = 0;
        }
        else{
            ans[a] = 0;
            ans[b] = 0;
        }
    }

    int rep = 0;
    rep(i, 1, N+1){
        if(ans[i] != 0){
            // cout << i << " ";
            rep++;
        }
    }
    // cout << endl;

    cout << rep << endl;

    return 0;
}

Measured memory_bytes: 3988
#include<iostream>
#include<string>
using namespace std;
int main() {
	//<<<ここにプログラムを書く>>>
	int x;
	cin >> x;
	cout << x / 3600 << ":" << x % 3600 / 60 << ":" << x % 60 << endl;
	return 0;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
#include <cstdlib>
using namespace std;
#define ll long long
typedef vector<vector<ll> > matrix;
#define pb push_back
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
const double PI  =3.141592653589793238463;
long long MOD = 1000000007;

int stringToInteger(string x){
    int gg=0;
    stringstream geek(x);
    geek >> gg;
    return gg;
}

ll powmod(ll a,ll b,ll m)
{
    ll ans=1;
    while(b>0){ if(b%2)
        {ans*=a; ans%=m;}
         b/=2; a=a*a; a=a%m;
        }
        return ans%m;
}
ll gcd(ll a,ll b)
{

    return __gcd(a,b);
}
ll mulmod(ll a,ll b,ll m)
{  ll ans=0;
    a %=m;
    while (b>0)
    {       if(b&1) ans = (ans + a) % m;
        a = (a * 2)%m;
        b /= 2;
    }
    return ans % m;
}

ll f[2000001];



ll pow(ll a, ll b, ll MOD)
{
 ll x=1,y=a;
 while(b > 0)
 	{
 		if(b%2 == 1)
 	{
 		x=(x*y);
 		if(x>MOD) x%=MOD;
 	}
 	y = (y*y);
 	if(y>MOD) y%=MOD;
 	b /= 2;
 	}
 return x;
}

/* Modular Multiplicative Inverse
 Using Euler's Theorem
 a^(phi(m)) = 1 (mod m)
 a^(-1) = a^(m-2) (mod m) */
ll InverseEuler(ll n, ll MOD)
{
 return pow(n,MOD-2,MOD);
}


bool in(float x1,float y1,float x,float y,float r )
{
    if(abs(x1-x)*abs(x1-x)+abs(y1-y)*abs(y1-y)<=r*r) return true;
    return false;
}
bool cmp(pair<int,int> &a,pair<int,int> &b)
{

        return (a.second<b.second);
}
//
//vector<vector<int> >matrix;
matrix mul(matrix A,matrix B)
{
    matrix C(3, vector<ll>(3));
    for(int i=1;i<=2;i++)
    for(int j=1;j<=2;j++)
     for(int k=1;k<=2;k++)
         C[i][j] = (C[i][j] + A[i][k] * B[k][j]);
    return C;

}
matrix pow(matrix A, int p)
{
    if (p == 1)
        return A;
    if (p % 2)
        return mul(A, pow(A, p-1));
    matrix X = pow(A, p/2);
    return mul(X, X);
}
ll fib(int N)
{
    vector<ll> F1(3);
    F1[1] = 1;
    F1[2] = 1;
    matrix T(3, vector<ll>(3));
    T[1][1] = 0, T[1][2] = 1;
    T[2][1] = 1, T[2][2] = 1;
    if (N == 1)
        return 1;
    T = pow(T, N-1);
    ll res = 0;
    for(int i=1;i<=2;i++)
        res = (res + T[1][i] * F1[i]) ;
    return res;
}
ll bit[10005]={0};
ll sum(ll i)
{
    ll ans=0;
    while(i>0)
    {
        ans+=bit[i];
        i-=(i&(-i));
    }
    return ans;
}
ll update(ll n,ll i)
{
    while(i<=n)
    {
        bit[i]+=1;
        i+=(i&(-i));
    }
}
//int C[10005][1];
int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    int n,h,w;
    cin>>n>>h>>w;
    ll ans=0;
    for(int i=0;i<n;i++)
    {

        int a,b;
        cin>>a>>b;
        if(a>=h&&b>=w) ans++;
    }
    cout<<ans;
}
   //C[10005][10005];


Measured memory_bytes: 256
import math

n = int(input())

sq = int(math.sqrt(55555))

prime = [i for i in range(55556)]
prime[1] = 0
for i in prime:
    if i > sq:
        break
    if i == 0:
        continue
    for j in range(i*2, 55556, i):
        prime[j] = 0

prime_3 = []
count = 0
for i, p in enumerate(prime):
    if count == n:
        break
    if p % 10 == 3:
        prime_3.append(p)
        count += 1

print(*prime_3)

Measured memory_bytes: 41584
#include<cstdio>
#define MAX 105
using namespace std;
int h,w;
char map[MAX][MAX];
int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1}; 
void dfs(int sx,int sy,char ch)
{
//	char ch=map[sx][sy];
	map[sx][sy]='0';
	for(int i=0;i<4;i++)
	{
		int nx=sx+dx[i];
		int ny=sy+dy[i];
		if(nx>=0&&nx<h&&ny>=0&&ny<w&&map[nx][ny]==ch)
		dfs(nx,ny,ch);
	}
	return ;
}
int main(void)
{
	while(scanf("%d%d",&h,&w)==2)
	{
		if(h==0&&w==0)
		break;
		for(int i=0;i<h;i++)
		scanf("%s",&map[i]);
		int res=0;
		for(int i=0;i<h;i++)
		{
			for(int j=0;j<w;j++)
			{
				if(map[i][j]!='0')
				{
//					printf("\n");
					dfs(i,j,map[i][j]);
//					for(int k=0;k<h;k++)
//					printf("%s\n",map[k]); 
					res++;
				}
			}
		}
		printf("%d\n",res);
	}
	return 0;
}

Measured memory_bytes: 1504
#include <iostream>
#include <iomanip>
#include <string>
#include <string.h>
#include <math.h>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
#include <utility>
#include <deque>
#include <queue>
#include <functional>
//#include <boost/multiprecision/cpp_int.hpp>

#define rep(i, n) for(int i = 0; i < n; ++i)
#define REP(i, m, n) for(int i = m; i < n; ++i)
#define rrep(i,n) for(int i = n; i >= 0; --i)
#define RREP(i, m, n) for(int i = n; i >= m; --i)
#define llrep(i, n) for(ll i = 0; i < n; ++i)
#define llREP(i, m, n) for(ll i = m; i < n; ++i)
#define llrrep(i,n) for(ll i = n; i >= 0; --i)
#define llRREP(i, m, n) for(ll i = n; i >= m; --i)

using ll = long long;
using ull = unsigned long long;
using pii = std::pair<int, int>;
using pll = std::pair<long long, long long>;
using pil = std::pair<int, long long>;
using pli = std::pair<long long, int>;
using plpii = std::pair<long long, std::pair<int, int>>;
using pdd = std::pair<double, double>;

const long long INF = 1000000000000000001;
const long long _MOD = 1000000007;
const long long MOD = 998244353;
const int ALPHABET = 27;
const double pi = 3.14159265358979;

using namespace std;
//namespace mp = boost::multiprecision;

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

	int x;
	cin >> x;
	if (x == 7 || x == 5 || x == 3) {
		cout << "YES" << "\n";
	}
	else {
		cout << "NO" << "\n";
	}

	return 0;
}

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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	int prevt = 0;
	int prevx = 0;
	int prevy = 0;
	for (int i = 0; i < n; ++i) {
		int t, x, y;
		cin >> t >> x >> y;
		int path = abs(prevx - x) + abs(prevy - y);
		if (path > t - prevt || (t - prevt - path) & 1) {
			cout << "No" << endl;
			return 0;
		}
		prevt = t;
		prevx = x;
		prevy = y;
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
#define ld long double
#define X first
#define Y second
#define pb push_back
#define max_el(x) max_element(x.begin(),x.end())-x.begin()
#define min_el(x) min_element(x.begin(),x.end())-x.begin()
#define mp make_pair
#define endl '\n'
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
// DONT USE MEMSET, USE VECTORS

ll n;
ll mod = 1e9+7;

// ll f(int u, int fg){
// 	// cout<<u<<endl;

// 	if(u < 0){
// 		return 1;
// 	}
// 	if(!fg){
// 		return (f(u-1,0)*3)%mod;
// 	}
// 	if((1LL<<u)&n){
// 		ll c1 = (f(u-1,1)*2)%mod;
// 		ll c2 = (f(u-1,0))%mod;
// 		cout<<c1<<" "<<c2<<endl;
// 		return (c1+c2)%mod;
// 	}
// 	else{
// 		return (f(u-1,fg))%mod;
// 	}
// }

ll dp[100][3];



ll f(int i, int fg){
	if(i < 0){
		return 1;
	}
	if(dp[i][fg] != -1){
		return dp[i][fg];
	}
	int ni = 0;
	if((1LL<<i)&n){
		ni = 1;
	}
	if(fg == 0){
		if(ni==0){
			dp[i][fg] = f(i-1,0)%mod;
			return dp[i][fg];
		}
		else{
			dp[i][fg] = (f(i-1,1) + f(i-1,0))%mod;
			return dp[i][fg];
		}
	}
	else if(fg == 1){
		if(ni==0){
			dp[i][fg] = (f(i-1,2) + f(i-1,1) + f(i-1,0))%mod;
			return dp[i][fg];
			// return 2*f(i-1,2) + f(i-1,0);
		}
		else{
			dp[i][fg] = (f(i-1,2)*2 +  f(i-1,1))%mod;
			return dp[i][fg];
		}
	}
	else if(fg == 2){
		dp[i][fg] = (f(i-1,2)*3)%mod;
		return dp[i][fg];
	}
}




void solve(){
	cin>>n;
	memset(dp,-1,sizeof(dp));
	cout<<f(63,0)<<endl;
	// cout<<f(0,1)<<endl;
}

int main(){
	fastread;
	int t = 1;
	// cin>>t;
	for(int i=1;i<=t;i++){
		// cout<<"Case #"<<i<<": ";
		solve();
	}
	return 0;
}


Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
int countNum[10];
int main () {
	string s;
	cin >> s;
	bool b = false;
	for (int i = 0; i < 2; ++i)
	{
		if(s[i] == s[i+1] && s[i] == s[i+2]){
			b = true;
		}
	}
	if(b)cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
using namespace std;
int main(){
    string str;
    int c[26];
    fill(c,c+26,1);
    for(int i=7;i<=15;i++)c[i]=-1;
    c['u'-'a']=c['y'-'a']=-1;
    while(cin>>str,str!="#"){
        int cnt=0;
        for(int i=0;i<str.length()-1;i++){
            if(c[str[i]-'a']*c[str[i+1]-'a']<0)cnt++;
        }
        cout<<cnt<<endl;
    }
}

Measured memory_bytes: 1184