akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define MEM(a, b) memset(a, (b), sizeof(a))
#define FOR(i, j, k, in) for (int i=j ; i<k ; i+=in)
#define RFOR(i, j, k, in) for (int i=j ; i>=k ; i-=in)
#define REP(i, j) FOR(i, 0, j, 1)
#define RREP(i, j) RFOR(i, j, 0, 1)
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.rbegin(), cont.rend()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define MP make_pair
#define PB push_back
#define PI 3.1415926535897932384626433832795
typedef long long ll;
#define MOD 998244353
ll gcd(ll a,ll b){if (b == 0)return a;return gcd(b, a % b);} 
#define cases int t;cin>>t;while(t--) 
ll power(ll x,ll y,ll p){ll res=1;x=x%p;if(x==0)return 0;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res%MOD;}  

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

    for(int i=1;i<=n;i++)
    cout<<f[i]<<endl;


}


Measured memory_bytes: 5128
#include<bits/stdc++.h>
using namespace std;
#define FOR(i,n)             for(ll i=1;i<=n;i++)
#define LOOP(i,n)            for(ll i=0;i<n;i++)
#define loop(a,b)            for(ll i=a;i<=b;i++)
#define sci(n)               scanf("%d",&n)
#define scl(n)               scanf("%lld",&n)
#define scl3(a,b,c)          scanf("%lld%lld%lld",&a,&b,&c);
#define scl2(a,b)            scanf("%lld%lld",&a,&b)
#define scd(n)               scanf("%lf",&n)
#define srt(g)               sort(g.begin(),g.end())
#define rvs(g)               reverse(g.begin(),g.end())
#define pl                   pair<long long,long long>
#define pll                  pair<long long,pair<long long,long long>>
#define ll long long
#define pb push_back
#define mp make_pair
#define pi acos(-1.0)
#define f first
#define s second
int main()
{
    ll n;
    scl(n);
    ll a[n+5],cnt=0;
    FOR(i,n)
    {
        scl(a[i]);
        if(i%2==1 && a[i]%2==1)cnt++;
    }
    cout << cnt << "\n";
}



Measured memory_bytes: 3756
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

const int INF = 1e9 + 5;
const int MAX_N = 16;

vector<pair<int, int>> adj [MAX_N]; // <oth, cost>
int dp [1 << MAX_N][MAX_N];
int within [1 << MAX_N];

int main () {
  ios::sync_with_stdio(false);

  int n, m;
  cin >> n >> m;

  int add = 0;
  for (int i = 0; i < m; i++) {
    int u, v, w;
    cin >> u >> v >> w;
    u--;
    v--;
    
    add += w;

    adj[u].push_back({v, w});
    adj[v].push_back({u, w});
  }

  for (int mask = 1; mask < 1 << n; mask++) {
    int id = -1;
    for (int i = 0; i < n; i++) {
      if (mask & 1 << i) {
        id = i;
      }
    }

    within[mask] = within[mask - (1 << id)];
    for (auto pr : adj[id]) {
      if (mask & 1 << pr.first) {
        within[mask] -= pr.second;
      }
    }
  }

  for (int i = 0; i < 1 << n; i++) {
    for (int j = 0; j < n; j++) {
      dp[i][j] = INF;
    }
  }

  for (int i = 1; i < 1 << (n - 1); i++) {
    dp[i][0] = within[i];
  }

  for (int mask = 1; mask < 1 << n; mask++) {
    for (int last = 1; last < n; last++) {
      if (mask & 1 << last) {
        for (auto pr : adj[last]) {
          int prev = pr.first;
          if (mask & 1 << prev) {
            int overm = mask - (1 << last) - (1 << prev);
            for (int sub = overm; sub > 0; sub = (sub - 1) & overm) {
              dp[mask][last] = min(dp[mask][last],
                                   within[sub + (1 << last)] + dp[mask - sub - (1 << last)][prev] - pr.second);
            }
            dp[mask][last] = min(dp[mask][last], dp[mask - (1 << last)][prev] - pr.second);
          }
        }
      }
    }
  }

  cout << dp[(1 << n) - 1][n - 1] + add << endl;
}


Measured memory_bytes: 4224
import sys

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

a_list = [[l for l in input()] for _ in range(n)]
b_list = [[l for l in input()] for _ in range(m)]

if n == m:
    if a_list == b_list:
        print('Yes')
        sys.exit()

for i in range(n-m):
    for j in range(n-m):
        a_list_sub = a_list.copy()
        a_list_sub = a_list[i:i+m]
        a_list2 = [row[j:j+m] for row in a_list_sub]
        if a_list2 == b_list:
            print('Yes')
            sys.exit()

print('No')    

Measured memory_bytes: 3064
N = int(input())
d = {}
for i in range(N):
    s = input()
    if s in d.keys():
        d[s] += 1
    else:
        d[s] = 1
Max = max(d.values())
keys = [k for k, v in d.items() if v == Max]
keys.sort()
for k in keys:
    print(k)

Measured memory_bytes: 32224
function main(input) {
const x1 = parseInt(input.split(/\s|\n/g)[0],10),
	  y1 = parseInt(input.split(/\s|\n/g)[1],10),
	  x2 = parseInt(input.split(/\s|\n/g)[2],10),
	  y2 = parseInt(input.split(/\s|\n/g)[3],10),
      x3 = x2-(y2-y1),
      y3 = y2+(x2-x1);
console.log(`${x3} ${y3} ${x3-(y3-y2)} ${y3+(x3-x2)}`.split(/\n/g)[0])
  
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

using namespace std;
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define sz size
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORN(i,a,b) for(int i=a;i<=b;i++)
#define FORRN(i,a,b) for (int i=(a);i>=(b);i--)
#define FORR(i,a,b) for (int i=(a);i>(b);i--)
typedef unsigned long long ull;
typedef long long ll;

vector<int> G[100005];
bool vis[100005];
int cnt[100005],mx;

int dfs(int x){
    if(vis[x])
        return cnt[x];
    vis[x]=true;
    for(auto i: G[x])
        cnt[x]=max(cnt[x],dfs(i)+1);

    return cnt[x];
}

int main(){
    ios_base::sync_with_stdio(false); //Fast I/O
    cin.tie(0);
    cout.tie(0);
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);

    int n,m;
    cin >> n >> m;

    FOR(i,0,m){
        int a,b;
        cin >> a >> b;
        G[a].pb(b);
    }
    mx=0;
    FORN(i,1,n)
        mx=max(mx,dfs(i));

    cout << mx << endl;

    return 0;
}


Measured memory_bytes: 7552
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=5e7+5;
int N;
int main(){
	cin>>N;
	double t=1.0;
	while(1){
	//	cout<<(int)(t*1.08)<<endl;
		if((int)(t*1.08)==N){
			cout<<(int)t<<endl;
			return 0;
		}
		if(t*1.08>N)break;
		t+=1.0;
	}
	cout<<":("<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;
#define int long long int
#define mod 1000000007
int fact[1000001];
void function2()
{
	fact[0]=1;
	int j;
	for(j=1;j<=1000000;j++)
	{
		fact[j]=(j*fact[j-1])%mod;
	}
}
int power(int a,int b)
{
	if(b==0)
	  return 1;
	else
	{
		int r=power(a,b/2);
		if(b%2==0)
		   return (r*r)%mod;
		else
		{
			int x=(r*r)%mod;
			return (a*x)%mod;
		}
	}
}
int ncr(int n,int r)
{
	int val=fact[n];
	val*=power(fact[r],mod-2);
	val%=mod;
	val*=power(fact[n-r],mod-2);
	val%=mod;
	return val;
}
int32_t main()
{
	function2();
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int s;
	cin>>s;
	int j;
	int answer=0;
	for(j=1;3*j<=s;j++)
	{
		int r=j;
		int n=s-3*j;
		int here=ncr(n+r-1,r-1);
		answer+=here;
		answer%=mod;
	}
	cout<<answer<<endl;
}


Measured memory_bytes: 11472
#include <bits/stdc++.h>
using namespace std;
int main(){
  int K;
  cin >> K;
  vector<int> panasonic = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  cout << panasonic.at(K-1) << endl; 
}

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

ll f(ll x){
  if(x == 1){
    return 1;
  }
  ll a = f(x/2);
  return 2*a+1;
}

int main(){
  ll h;
  cin >> h;
  cout << f(h) << endl;
  return 0;
}


Measured memory_bytes: 256
from math import factorial
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def MI(): return map(int, input().split())


def S(): return input()


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


def MS(): return map(str, input().split())

YN = ['No', 'Yes']
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']


# show_flg = False
show_flg = True

p = None
XY = None
N = None


def main():
    N = I()
    P = LI()
    MP = [0] * N
    ans = 0

    for i in range(N):
        if i == 0:
            MP[i] = P[i]
        else:
            MP[i] = min(MP[i-1], P[i])

    for i in range(N):
        if MP[i] >= P[i]:
            # print(i, P[i])
            ans += 1

    print(ans)
    # print(MP)
    # print(P)



if __name__ == '__main__':
    main()


Measured memory_bytes: 71500
#include <stdio.h>
#include <list>
#include <algorithm>

#define MAX_CARD (100000)

using namespace std;

typedef struct {
	int start;
	int length;
} OFSET;

bool operator< (const OFSET& a, const OFSET& b)
{
	return (a.length < b.length);
}

OFSET oflst[MAX_CARD];

int main(void)
{
	OFSET of;
	int ofcnt;
	int card[MAX_CARD + 1];
	int n, k;
	int i;
	
	while (1){
		ofcnt = 0;
		
		scanf("%d%d", &n, &k);
		if (n == 0 && k == 0){
			break;
		}
		
		for (int i = 0; i < k; i++){
			scanf("%d", &card[i]);
		}
		sort(card, card + k);
		
		if (card[0] == 0){
			of.start = card[1];
			i = 2;
		}
		else {
			of.start = card[0];
			i = 1;
		}
		of.length = 1;
		
		for (; i < k; i++){
			if (card[i] - 1 == card[i - 1]){
				of.length++;
			}
			else {
				oflst[ofcnt++] = of;
				of.start = card[i];
				of.length = 1;
			}
		}
		oflst[ofcnt++] = of;
		
	/*	for (int i = 0; i < ofcnt; i++){
			printf("%d %d\n", oflst[i].start, oflst[i].length);
		}
	*/	
		if (card[0] != 0){
			printf("%d\n", max_element(oflst, oflst + ofcnt)->length);
		}
		else {
			int catmax;
			
			catmax = 0;
			for (int i = 0; i < ofcnt - 1; i++){
				if (oflst[i].start + oflst[i].length + 1 == oflst[i + 1].start && (oflst[i].length + oflst[i + 1].length + 1) > catmax){
					catmax = (oflst[i].length + oflst[i + 1].length + 1);
				}
			}
			printf("%d\n", max(max_element(oflst, oflst + ofcnt)->length + 1, catmax));
		}
	}
	
	return (0);
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main (){
  int a,b;
  cin >> a >> b;
  if (a == b) {cout<<"Draw"; return 0;}
  if (a == 1) {cout<<"Alice"; return 0;}
  if (b == 1) {cout<<"Bob"; return 0;}
  if (a > b) cout<<"Alice";
  if (a < b) cout<<"Bob";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
const ll mod = 1000000007;
const int INF = 1001001001;
const ll LINF = 1001001001001001001;

int main(){
    ll n; cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a.at(i);
    rep(i,n) a.at(i) -= i + 1;
    sort(a.begin(),a.end());
    ll b = a.at(n/2);
    ll ans = 0;
    rep(i,n) ans += abs(a.at(i) - b);
    cout << ans << endl;
}

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

int main(){
    int H,W;
    int i,j;
           
    for (;;){
        cin >> H >> W;
        if (H==0 && W==0)break;
        for (i=0;i<H;i++){
            for (j=0;j<W;j++){
                if (i==0 || i==H-1){
                    if (j==W-1){
                        cout << "#"<< endl;
                    }else{
                        cout << "#"; 
                    }
                } else {
                    if (j==0){
                        cout << "#";
                    }else if(j ==W-1){
                        cout << "#" << endl; 
                    }else {
                        cout << ".";
                    }
                }
            }
        }
        cout << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3072
#include <cstdio>
#include <algorithm>
#include <vector>

using namespace std;

int N,M;

int Par[100100];
int Size[100100];

vector<int> Group[100100];

void Connect(int x,int y);
int rootOf(int x);

int main() {
    
    scanf("%d %d",&N,&M);

    int i,j;

    for(i = 1;i <= N;i++){
        int k;

        scanf("%d",&k);
        for(j = 1;j <= k;j++){
            int l;
            scanf("%d",&l);

            Group[l].push_back(i);
        }
    }

    for(i = 1;i <= N;i++) {
        Par[i] = i;
        Size[i] = 1;
    }

    for(i = 1;i <= M;i++){
        for(j = 0;j + 1 < Group[i].size();j++){
            Connect(Group[i][j],Group[i][j + 1]);
        }
    }

    if(Size[rootOf(1)] == N) puts("YES");
    else puts("NO");

    return 0;
}
void Connect(int x,int y){
    int p1,p2;
    
    p1 = rootOf(x);
    p2 = rootOf(y);

    if (p1 == p2) return;

    if(Size[p1] > Size[p2]) {
        Par[p2] = p1;
        Size[p1] += Size[p2];
    }
    else {
        Par[p1] = p2;
        Size[p2] += Size[p1];
    }
}
int rootOf(int x){
    int p = x;
    vector<int> t;

    while(Par[p] != p){
        t.push_back(p);
        p = Par[p];
    }

    for(auto s : t){
        Par[s] = p;
    }

    return p;
}

Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define pb push_back
#define mp make_pair
#define deb(x) cout<< #x << " " << x << "\n";
#define INF 9223372036854775807
const ll mod=998244353;

ll a,b,c,d;
vector<ll> v={2,3,5};
map<ll,ll> m;

ll solve(ll n){
    if(n==0)
        return 0;
    if(n==1)
        return d;
    ll mn=INF;
    if(n<INF/d)
        mn=n*d;
    if(m.find(n)!=m.end())
        return m[n];
    ll cost;
    for(ll i=0;i<3;i++){
        if(i==0) cost=a;
        if(i==1) cost=b;
        if(i==2) cost=c;
        if(n%v[i]==0)
            mn=min(mn,cost+solve(n/v[i]));
        else{
            ll down=n/v[i]*v[i];
            mn=min(mn,d*(n-down)+cost+solve(n/v[i]));
            ll up=down+v[i];
            mn=min(mn,d*(up-n)+cost+solve(n/v[i]+1));
        }
    }
    return m[n]=mn;
}
 
int main() {
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 
    ll t,n;
    cin>>t;
    while(t--){
        cin>>n>>a>>b>>c>>d;
        m.clear();
        cout<<solve(n)<<"\n";
    }

    return 0;
}

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

#define ONLINE_JUDGE
#define pb(a) push_back(a)
#define all(a) (a.begin(), a.end())

using ll = long long;

const int E5 = 1e5;

//////////// Solution /////////////////////////////////

ll get(ll a[E5], int i) {
	return (i > 0 ? a[i-1] : 0);
}

void solve() {
	ll l[E5],r[E5];
	int N,K;
	cin >> N >> K;
	int llen=0,rlen=0;
	for (int i = 0; i < N; ++i) {
		int x;
		cin >> x;
		if (x >= 0) {
			r[rlen++] = x;
		} else {
			l[llen++] = -x;
		}
	}
	reverse(l,l+llen);
	
	ll ans = 1e18;
	for (int i = max(0,K-llen); i <= min(K,rlen); ++i) {
		ans = min(ans, 2 * min(get(r,i),get(l,K-i)) + max(get(r,i),get(l,K-i)));
	}

	cout << ans << '\n';
}	

/////////// End Solution ///////////////////////////////////////

//////// Initialization ////////////////////////////////////

int main() {

	#ifndef ONLINE_JUDGE
	FILE *FIN = freopen("/home/danil/prog/input.txt", "r", stdin);
	clock_t time_start = clock();
	#endif

	ios::sync_with_stdio(false);
	cin.tie(NULL);

	solve();

	#ifndef ONLINE_JUDGE
	fclose(FIN);
	cerr << "\x1b[031m\n-----------------\nTime=" << (ll)((double)(clock()-time_start) / CLOCKS_PER_SEC * 1000) << "ms\n\x1b[0m";
	#endif

	return 0;
}

//////// End Initialization ///////////////////////////////////////

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
int main(void){
    int n,m,i,k;
    cin>>n>>m;
    i=n;
    int A[i];
   for(i=0;i<n;i++){
       cin>>A[i];
   }
   
   for(k=1;k<=m;k++){
   for(i=1;i<n;i++){
   if(A[i-1]%k>A[i]%k){
         int temp;
         temp=A[i-1];
         A[i-1]=A[i];
         A[i]=temp;
       }
   }
   }
  for(i=0;i<n;i++){
      cout<<A[i]<<endl;
  }  
}


Measured memory_bytes: 3104
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
using namespace std;

long long int INF = 1000000007;

long long int pow10_9_5(long long int num){
	long long int pow_num = 1000000005;
	long long int mod_num = 1000000007;
	long long int pow_cur = num;
	long long int ret = 1;
	while(pow_num > 0){
		if(pow_num % 2 == 1){
			ret *= pow_cur;
			ret %= mod_num;
		}
		pow_cur *= pow_cur;
		pow_cur %= mod_num;
		pow_num /= 2;
	}
	return ret;
}

int main() {
	
	long long int N;
	cin >> N;
	
	long long int ans = 0;
	long long int pp = 1;
	long long int pp2 = 1;
	
	for(long long int n = 1; n <= (N + 1) / 2; n++){
		pp *= n;
		pp %= INF;
	}
	
	long long int num = (N - 1) / 2;
	long long int den = N / 2 - 1;
	
	for(long long int n = 1; n <= N - 2 - num; n++){
		pp2 *= n;
		pp2 %= INF;
	}
	
	long long int conv;
	
	if(num != den){
		conv = num;
	}else{
		conv = 1;
	}
	
	long long int diff = 0;
	
	for(long long int n = num; n <= N - 3; n++){
		long long int ppp = (pp * pp2) % INF;
		diff += conv * ppp;
		diff %= INF;
		//cout << n << endl;
		//cout << conv << " " << pp << " " << pp2 << endl;
		long long int n1 = n;
		long long int n2 = N - 2 - n;
		conv *= n1 + 1;
		conv %= INF;
		conv *= n2;
		conv %= INF;
		conv *= pow10_9_5(n1 - n2 + 1);
		conv %= INF;
		conv *= pow10_9_5(n1 - n2 + 2);
		conv %= INF;
		pp *= n + 2;
		pp %= INF;
		pp2 *= pow10_9_5(n2);
		pp2 %= INF;
	}
	
	ans = (N - 1) * pp;
	ans = (ans - diff + INF) % INF;
	
	cout << ans << endl;
	/*
	int DATA_SIZE = 10;
	int a[DATA_SIZE];
	
	for(int i = 0; i < DATA_SIZE; i++){
		a[i] = i;
	}
	int ans_true = 0;
	do{
		
		for(int i = 0; i < DATA_SIZE; i++){
			cout << a[i] << " ";
		}
		cout << endl;
		
		bool p[DATA_SIZE + 1] = {};
		for(int i = 0; i < DATA_SIZE; i++){
			p[a[i]] = true;
			p[a[i] + 1] = true;
			bool flag = true;
			for(int j = 0; j < DATA_SIZE + 1; j++){
				if(!p[j]){
					flag = false;
				}
			}
			if(flag){
				ans_true += i + 1;
				//cout << i + 1 << endl;
				break;
			}
		}
	}while(next_permutation(a, a + DATA_SIZE));
	
	cout << ans_true << endl;
	*/
	return 0;
}



Measured memory_bytes: 256
import javax.swing.plaf.basic.BasicInternalFrameTitlePane;
import  java.io.*;
import  java.math.*;
import java.nio.Buffer;
import java.sql.SQLSyntaxErrorException;
import  java.util.*;
import  java.text.*;
import java.util.regex.Pattern;
import java.util.stream.Collectors;


public class Main {
    public static boolean gcd(int a,int b){
        if(a==1||b==1){
            return false;
        }
        while(1>0){
            int t = a%b;
            if(t == 0){
                break;
            }
            else{
                a=b;
                b=t;
            }

        }
        if(b>1)	return true;
        else{
            return  false;
        }
    }
    static class kNight implements Comparable<kNight>{
        int p;
        int c;
        kNight(int p,int c){
            this.p=p;
            this.c=c;
        }
        @Override
        public int compareTo(kNight k) {
            if(p==k.p){
                return c-k.c;
            }
            else{
                return p-k.p;
            }
        }


    }
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;

        public FastReader()
        {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

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

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
    public static void main(String[] args) {
        FastReader cin=new FastReader();
        int n=cin.nextInt();
        boolean flag=true;
        while(n>0){
            int x=n%10;
            if(x==7){
                System.out.println("Yes");
                return;
            }
            n=n/10;
        }
        System.out.println("No");

    }
}


Measured memory_bytes: 32668
from collections import Counter,defaultdict,deque
import sys
import bisect
import math
import itertools
import string
import queue
import copy
# import numpy as np
# import scipy
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7
 
def inp(): # n=1
    return int(input())
def inpm(): # x=1,y=2
    return map(int,input().split())
def inpl(): # a=[1,2,3,4,5,...,n]
    return list(map(int, input().split()))
def inpls(): # a=['1','2','3',...,'n']
    return list(input().split())
def inplm(n): # x=[] 複数行
    return list(int(input()) for _ in range(n))
def inpll(n): # [[1,1,1,1],[2,2,2,2],[3,3,3,3]]
    return [list(map(int, input().split())) for _ in range(n)]

def main():
    n = inp()
    s = []
    for _ in range(n):
        t = inpls()
        t[1] = int(t[1])
        s.append(t)
    x = input()
    key = 0
    ans = 0
    for i in range(n):
        if key:
            ans += s[i][1]
        if s[i][0]==x:
            key = 1
    print(ans)          

if __name__ == "__main__":
    main()

Measured memory_bytes: 39148
#line 2 "header.hpp"

//%snippet.set('header')%
//%snippet.fold()%
#ifndef HEADER_H
#define HEADER_H

// template version 2.0
using namespace std;
#include <bits/stdc++.h>

// varibable settings
const long long INF = 1e18;
template <class T> constexpr T inf = numeric_limits<T>::max() / 2.1;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define _rrep(i, n) rrepi(i, 0, n)
#define rrepi(i, a, b) for (ll i = (ll)((b)-1); i >= (ll)(a); --i)
#define r_rep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(i, a) for (auto &&i : a)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(...) make_tuple(__VA_ARGS__)
#define ub upper_bound
#define lb lower_bound
#define lpos(A, x) (lower_bound(all(A), x) - A.begin())
#define upos(A, x) (upper_bound(all(A), x) - A.begin())
template <class T> inline void chmax(T &a, const T &b) { if ((a) < (b)) (a) = (b); }
template <class T> inline void chmin(T &a, const T &b) { if ((a) > (b)) (a) = (b); }
template <typename X, typename T> auto make_table(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto make_table(X x, Y y, Z z, Zs... zs) { auto cont = make_table(y, z, zs...); return vector<decltype(cont)>(x, cont); }

#define cdiv(a, b) (((a) + (b)-1) / (b))
#define is_in(x, a, b) ((a) <= (x) && (x) < (b))
#define uni(x) sort(all(x)); x.erase(unique(all(x)), x.end())
#define slice(l, r) substr(l, r - l)

typedef long long ll;
typedef long double ld;
using vl = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;

template <typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;
void check_input() { assert(cin.eof() == 0); int tmp; cin >> tmp; assert(cin.eof() == 1); }

#if defined(PCM) || defined(LOCAL)
#else
#define dump(...) ;
#define dump_1d(...) ;
#define dump_2d(...) ;
#define cerrendl ;
#endif

#endif /* HEADER_H */
//%snippet.end()%
#line 2 "solve.cpp"
template<class T=ll> using vec = vector<T>;
struct Fast { Fast() { std::cin.tie(0); ios::sync_with_stdio(false); } } fast;


int solve() {
    rep(i, 5){
        int x;cin>>x;
        if (x==0) {
            cout << i+1 << endl;
            return 0;
        }
    }
    return 0; 
}


int main(){/*{{{*/
    solve();
    return 0;
}/*}}}*/


Measured memory_bytes: 3640
//#include "pch.h"
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <bitset>
#include <limits.h>
#include <string>
#include <deque>
#include <cmath>
#include <bitset>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

#define rip(i, n, s) for (int i = (s);i < (int)( n ); i++)
#define mpa make_pair
#define all(a) (a).begin(), (a).end()

const ll mod = 1000000007;

int main(){
    int n;
    cin >> n;
    vector<ll> a(n);
    rip(i,n,0) cin >> a[i];
    vector<bitset<64>> da(n);
    rip(i,n,0) da[i] = bitset<64>(a[i]);
    ll ans = 0;
    rip(i,64,0){
        ll co = 0;
        rip(j,n,0){
            if(da[j][63- i]){
                co++;
            }
        }
        ans *= 2;
        ans += co * (n - co);
        ans %= mod;
    }
    cout << ans << endl;
}

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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}


// 約数の列挙
vector<ll> divisor(ll n) {
    vector<ll> res;
    for (ll i=1;i*i<=n;++i) {
        if (n%i == 0) {
            res.push_back(i);
            if (i != n/i) res.push_back(n/i);
        }
    }
    return res;
}
int main() {
    ll N;
    cin >> N;
    vector<ll> tmp = divisor(N);
    ll ans = 0;
    rep(i, tmp.size()) {
        //cout << tmp[i] << endl;
        ll m = tmp[i] - 1;
        if (m > 0 and N/m == N%m) ans += m;
        //ans += (tmp[i]-1);
    }
    cout << ans << endl;
}
//
// int main() {
//     ll N;
//     cin >> N;
//     vector<ll> tmp = divisor(N);
//     sort(tmp.begin(), tmp.end());
//     rep(i, tmp.size()) {
//         cout << tmp[i] << endl;
//     }
//
//     for (int m=1; m<N; ++m) {
//         if (N%m == N/m) {
//             cout << "m = " << m << "| " << N%m << ", " << N/m << endl;
//         }
//     }
// }


Measured memory_bytes: 384
n, k = map(int, input().split())
x = list(map(int, input().split()))
p = n
for i in range(n):
  if x[i] > 0:
    p = i
    break
result = float('inf')
for i in range(k + 1):
  if p - i < 0 or p + k - i > n:
    continue
  if i == 0:
    t = min(result, x[p + k - 1])
  elif i == k:
    t = min(result, abs(x[p - k]))
  else:
    t = min(result, abs(x[p - i]) * 2 + x[p + (k - i) - 1], abs(x[p - i]) + x[p + (k - i) - 1] * 2)
  result = min(result, t)
print(result)


Measured memory_bytes: 14660
//=================================
// Created on: 2018/09/21 23:10:48
//=================================
#include <iostream>
#include <bitset>
int main()
{
    int N;
    std::cin >> N;
    constexpr int MAX = 10000;
    std::bitset<MAX> bs{0};
    bs[0] = 1;
    for (int i = 0; i < N; i++) {
        int s;
        std::cin >> s;
        bs |= bs << s;
    }
    for (int i = MAX; i >= 0; i--) {
        if (i % 10 == 0) { continue; }
        if (bs[i]) { return std::cout << i << std::endl, 0; }
    }
    std::cout << 0 << std::endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;

int32_t main(){
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        int a,b,c;
         cin >> a >> b >> c;
         int s=a+b+c;
         if(s>=22)cout <<  "bust";
         else cout << "win";

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define MOD (unsigned long long)(1e9+7)
typedef long long int ll;

ll dp[1007][1007];

int main(){
	ll h, w;
	cin>>h>>w;
 	string mat[h];
	memset(dp, 0, sizeof(dp));
	for(int i=0;i<h;i++){
		cin>>mat[i];
	}
	for(int i=0;i<h;i++){
		if(mat[i][0]=='#') break;
		dp[i][0]=1;
	}
	for(int i=0;i<w;i++){
		if(mat[0][i]=='#') break;
		dp[0][i]=1;
	}

	for(int i=1;i<h;i++){
		for(int j=1;j<w;j++){
			if(mat[i][j]=='.'){
				if(mat[i-1][j]=='#') dp[i][j]=dp[i][j-1];
				else if(mat[i][j-1]=='#') dp[i][j]=dp[i-1][j];
				else dp[i][j]=(dp[i-1][j]+dp[i][j-1])%MOD;
			}
		}
	}
	
	cout<<dp[h-1][w-1];
}


Measured memory_bytes: 9216
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define pint pair<int,int>
#define pll pair<ll,ll>
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

ll d[400][400],d2[400][400];
ll V;
int n,m,l;
void warshall_floyd(){
  rep(k,V){
    rep(i,V){
      rep(j,V)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
    }
  }
}
void warshall_floyd2(){
  rep(k,V){
    rep(i,V){
      rep(j,V)d2[i][j]=min(d2[i][j],d2[i][k]+d2[k][j]);
    }
  }
}

int main(){
  cin >> n >> m >> l;
  V=n;
  rep(i,n){
    rep(j,n){
      if(i!=j){
        d[i][j]=longinf;
        d2[i][j]=longinf;
      }
      else{
        d[i][j]=0;
        d2[i][j]=0;
      }
    }
  }
  rep(i,m){
    int x,y,z;
    cin >> x >> y >> z;
    x--,y--;
    d[x][y]=z;
    d[y][x]=z;
  }
  int q;
  cin >> q;
  int s[q],t[q];
  rep(i,q){
    cin >> s[i] >> t[i];
    s[i]--,t[i]--;
  }
  warshall_floyd();
  rep(i,n){
    rep(j,n){
      if(d[i][j]<=l)d2[i][j]=1;
    }
  }
  warshall_floyd2();
  rep(i,q){
    if(d2[s[i]][t[i]]<longinf)cout << d2[s[i]][t[i]]-1 << endl;
    else cout << -1 << endl;
  }
return 0;}

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

int main(void){
  int N, K;
  cin >> N >> K;
  vector<int> p(N);
  for(int i = 0; i < N; ++i) {
    cin >> p[i];
  }

  sort(p.begin(), p.end());

  int ans = 0;
  for(int i = 0; i < K; ++i) {
    ans += p[i];
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;

int64_t mod = 998244353 ;

vector<int> getprime(int n){
    vector<int> p(0) ;
    vector<bool> table(n+1,0) ;
    for (int i = 2; i <= n; i++)
    {
        if (table.at(i) == 0)
        {
            p.push_back(i) ;
            for (size_t j = 2; j < n/i ; j++)
            {
                table.at(i*j) = 1 ;
            }
            
        }
        
    }
    return p ;
}

int main(){
    int64_t n ;
    cin >> n ;
    int64_t ans = 0 ;
    for (int64_t i = 1; i < n+1; i++)
    {
        int64_t num = n/i ;
        ans += (num*(num+1)) /2 * i ;
    }
    
    
    cout << ans <<endl ;
}

Measured memory_bytes: 3612
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <deque>
#include <queue>
#include <cctype>
#include <cstdio>
#include <math.h>
#include <set>
#define INF 1000000000000
using namespace std;
using ll = long long;
ll ans = 0;
ll n;
string str = "357";
void judge(string a) {
	ll kazu = stoi(a);
	bool san=false, go=false, nana = false;
	if (kazu <= n) {
		for (ll i = 0; i < a.length(); i++) {
			if (a[i] == '3') {
				san = true;
			}
			else if (a[i] == '5') {
				go = true;
			}
			else if (a[i] == '7') {
				nana = true;
			}
		}
		if (san == true && go == true && nana == true) {
			ans++;
		}
	}
}

void num(string s) {
	if (s.length() <= 9) {
		judge(s);
		for (ll i = 0; i < 3; i++) {
			num(s + str.substr(i, 1));
		}
	}
}

int main() {
	cin >> n;
	string str = "357";
	for (ll i = 0; i < 3; i++) {
		num(str.substr(i,1));
	}
	cout << ans << endl;
}

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

int main(){
long long N, i, ans=2020202020; cin >> N ; long long A[N], L[N]={}, R[N]={};
cin >> A[0]; L[0]=A[0];
for(i=1; i<N; i++){ cin >> A[i]; L[i]=L[i-1]+A[i]; }
for(i=0; i<N; i++){ R[i]=L[N-1]-L[i]; ans=min(abs(L[i]-R[i]),ans); }
cout << ans << "\n";
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#include <fstream>
using namespace std;
 
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define Eunique(v) v.erase(unique(all(v)),v.end())
#define pvec(v) rep(i,v.size()){cout << v[i] << " ";};cout<<endl;
#define pb push_back
#define pf push_front
#define mod 1e9+7
#define m_p make_pair
 
typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pii> vpii;
typedef pair<ll,ll> pll;
typedef vector<pll> vpll;
typedef vector<vector<int>> vvi;
const double pi = acos(-1.0);
 
ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
ll lcm(ll x, ll y) { return x * y / gcd(x, y); }

bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return false;
        }
    }
    return true;
}

int main()
{
    ll a,b;
    cin >> a >> b;
    cout << (a+b)%24 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"

int main() {
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    cin>>n;
    ll arr[n];
    map<ll,ll> mp;
    ll sum=0;
    for(ll i=0;i<n;i++)
    {
    	cin>>arr[i];
    	sum=sum+arr[i];
    	++mp[arr[i]];
    }
    ll q;
    cin>>q;
    for(ll i=0;i<q;i++)
    {
    	ll b,c;
    	cin>>b>>c;
    	sum=sum+(mp[b]*(c-b));
    	mp[c]=mp[c]+mp[b];
    	mp[b]=0;
    	cout<<sum<<endl;
    	//sum=sum;
    }
    
	return 0;
}

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

int main(){
    int N, M;
    while(cin >> N >> M, N != 0){
        vector<vector<int> > student(M+1, vector<int>(1262, 0));
        int r;
        cin >> r;
        for(int i=0;i<r;++i){
            int t, n, m, s;
            cin >> t >> n >> m >> s;
            if(s == 1)student[m][t]++;
            else student[m][t]--;
        }
        for(int i=1;i<=M;++i){
            for(int t=540;t<=1260;++t){
                student[i][t] += student[i][t-1];
            }
        }
        int q;
        cin >> q;
        for(int i=0;i<q;++i){
            int ts, te, m;
            cin >> ts >> te >> m;
            int sum = 0;
            for(int t=ts;t<te;++t){
                if(student[m][t] > 0)sum++;
            }
            cout << sum << endl;
        }
    }


    return 0;
}



Measured memory_bytes: 50888
//minamoto
#include<bits/stdc++.h>
#define R register
#define pb emplace_back
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
typedef long long ll;
const int N=2e5+5;
struct node{
	int u,v;ll w;
	inline node(R int uu,R int vv,R ll ww):u(uu),v(vv),w(ww){}
	inline bool operator <(const node &b)const{return w<b.w;}
};vector<node>E;vector<int>st;
struct eg{int v,nx,w;}e[N<<1];int head[N],tot;
inline void add(R int u,R int v,R int w){e[++tot]={v,head[u],w},head[u]=tot;}
ll dis[N];int sz[N],vis[N],mx[N],fa[N],a[N];
int n,rt,size;
inline int find(R int x){return fa[x]==x?x:fa[x]=find(fa[x]);}
void findrt(int u,int fa){
	sz[u]=1,mx[u]=0;
	go(u)if(!vis[v]&&v!=fa){
		findrt(v,u);
		sz[u]+=sz[v],cmax(mx[u],sz[v]);
	}
	cmax(mx[u],size-sz[u]);
	if(mx[u]<mx[rt])rt=u;
}
void get(int u,int fa){
	st.pb(u);
	go(u)if(!vis[v]&&v!=fa)dis[v]=dis[u]+e[i].w,get(v,u);
}
void solve(int u){
	vis[u]=1,dis[u]=0,st.clear(),get(u,0);
	R int p=0;R ll mn=1e18;
	for(auto v:st)if(cmin(mn,dis[v]+=a[v]))p=v;
	for(auto v:st)E.pb(node(p,v,dis[p]+dis[v]));
	R int s=size;
	go(u)if(!vis[v]){
		rt=0,size=(sz[v]<=sz[u]?sz[v]:s-sz[u]);
		findrt(v,0),solve(rt);
	}
}
int main(){
	scanf("%d",&n),mx[0]=n+1;
	fp(i,1,n)scanf("%d",&a[i]);
	for(R int i=1,u,v,w;i<n;++i){
		scanf("%d%d%d",&u,&v,&w);
		add(u,v,w),add(v,u,w);
	}
	rt=0,size=n,findrt(1,0),solve(rt);
	sort(E.begin(),E.end());
	fp(i,1,n)fa[i]=i;
	R ll res=0;
	for(auto e:E)if(find(e.u)!=find(e.v))res+=e.w,fa[find(e.u)]=find(e.v);
	printf("%lld\n",res);
	return 0;
}

Measured memory_bytes: 88160
#include <stdio.h>

#define M 1000000

#define INFTY 999999999

void merge(int *,int,int,int);
void mergeSort(int *,int,int);

int cnt;

int main(){
  int num,A[M],i;
  
  scanf("%d",&num);
  for(i=0;i<num;i++) scanf("%d",&A[i]);
  mergeSort(A,0,num);
  
  for(i=0;i<num-1;i++)printf("%d ",A[i]);
  printf("%d\n",A[i]);
  printf("%d\n",cnt);
  return 0;
}

void merge(int *A,int left,int mid,int right){
  int n1,n2,i,j,k,L[M],R[M];

  n1 = mid - left;
  n2 = right - mid;
  for(i=0;i<n1;i++) L[i] = A[left + i];
  for(i=0;i<n2;i++) R[i] = A[mid + i];

  L[n1] = INFTY;
  R[n2] = INFTY;
  i = 0;
  j = 0;

  for(k=left;k<right;k++){
    if( L[i] <= R[j]){
      A[k] = L[i];
      i = i + 1;
      cnt++;
    }else{ 
      A[k] = R[j];
      j = j + 1;
      cnt++;
    }
  }

}

void mergeSort(int *A,int left,int right){
  int mid;

  if( left+1 < right){
    mid = (left + right)/2;
    mergeSort(A, left, mid);
    mergeSort(A, mid, right);
    merge(A, left, mid, right);
  }
}



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

//#define int long long
#define DBG 0
#define dump(o) if(DBG){cerr<<#o<<" "<<(o)<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

//?????????: n??\???????´???°
vector<int> getPrimes(int n) {
	vector<char> is_prime(n + 1, true);
	is_prime[0] = is_prime[1] = false;
	for (int i = 2; i*i <= n; i++)
		if (is_prime[i]) {
			int j = i + i;
			while (j <= n) {
				is_prime[j] = false;
				j += i;
			}
		}
	vector<int> primes;
	rep(i, 0, n + 1)
		if (is_prime[i])
			primes.emplace_back(i);
	return primes;
}

signed main() {
	vector<int> primes = getPrimes(10000);
	dumpc(primes);
	for (int m, a, b; cin >> m >> a >> b&&m;) {
		int ansp, ansq, ma = 0;
		rep(i, 0, primes.size()) {
			int q = primes[i];
			int j = lower_bound(primes.begin(), primes.end(), (double)q*a / b) - primes.begin();
			for (; j < primes.size(); j++) {
				int p = primes[j];
				if (p*q > m || p > q)break;
				if (ma > p*q)continue;
				ma = p*q;
				ansp = p, ansq = q;
			}
		}
		cout << ansp << " " << ansq << endl;
	}
	return 0;
}

Measured memory_bytes: 3152
s = input()
K = int(input())
ind = 0
for i in range(len(s)):
    if s[i] != "1":
        ind = i
        break
    ind += 1

if ind == len(s):
    print(1)
else:
    if K <= ind:
        print(1)
    else:
        print(s[ind])

Measured memory_bytes: 3060
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
using namespace std;
int main(){
	int x, a, b;
	cin>> x >> a >> b;

	if(abs(x - a) > abs(x - b))
	cout<< 'B' <<endl;

	else 
	cout<< 'A' <<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  ll N; cin >> N;
  ll count = 0;
  for (ll x = 1; x <= N; x++) {
    ll num = 0;
    for (ll i = 1; i*i<= x; i++) {
      if (i*i<x && x%i==0) {num+=2;}
      if (i*i == x) {num++;}
    }
    if (x % 2 == 1 && num == 8) {count++;}
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>


int main(){

	char O[51];
	char E[51];

	scanf("%s %s",O,E);

	if(strlen(O) > strlen(E)){
		for(int i = 0; i < strlen(E); i++){
			printf("%c",O[i]);
			printf("%c",E[i]);
		}
		printf("%c",O[strlen(O)-1]);
	}
	else{
		for(int i = 0; i < strlen(E); i++){
			printf("%c",O[i]);
			printf("%c",E[i]);
		}
	}
	printf("\n");
	return 0;
}

Measured memory_bytes: 128
use std::io::{Read, stdin};

fn main() {
    let stdin = stdin();
    let mut stdin = stdin.lock();

    let mut x = String::new();
    stdin.read_to_string(&mut x).unwrap();
    let x = x.trim().parse::<i32>().unwrap();

    println!("{}", x.pow(3));
}



Measured memory_bytes: 5028
// Template from https://techracho.bpsinc.jp/jhonda/2019_08_05/78537

// input macro for competive-programming from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };

    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, bytes) => {
        read_value!($iter, String).into_bytes()
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    use std::io::Read;
    let mut s = String::new();
    std::io::stdin().read_to_string(&mut s).unwrap();

    println!("{}", solve(&s));
}

macro_rules! test {
    ($($input:expr => $output:expr),* $(,)*) => {
        #[test]
        fn solve_test() {
            $(
                assert_eq!(solve($input), $output);
            )*
        }
    };
}

test! {
r#"abaccaba"# => r#"Yes"#,
r#"hthth"# => r#"No"#,
r#"w"# => r#"No"#,
r#"ww"# => r#"Yes"#,
}

fn solve(src: &str) -> String {
    input! {
        source = src,
        w: chars,
    }
    let mut a = vec![0; 26];

    for i in 0..w.len() {
        a[w[i] as usize - 'a' as usize] += 1;
    }

    if a.iter().filter(|&n| n % 2 != 0).count() > 0 {
        "No"
    } else {
        "Yes"
    }.to_string()
}

Measured memory_bytes: 4352
#include <bits/stdc++.h>
typedef long long ll;
#define F(i,a,b) for(ll i=a;i<=b;i++)
#define Fd(i,a,b) for(ll i=a;i>=b;i--)
using namespace std;
const int N=3*1e4+4;

bool bl[N];
void pre();

 int main()
 {
        pre();   
        vector<int> res;
        int n;
        scanf("%d",&n);
        ll sum=0;
        F(i,1,N-4)
        {
                if(!bl[i]) continue;
                res.push_back(i);
                sum+=i;
                if((int)res.size()==n-1) break;
        }

        int X=res.back()+1;
        int il=2*3*5*7*11;
 
        F(i,X,N-4)
        {
                if((sum+i)%il==0&&bl[i])
                {
                        res.push_back(i);
                        break;
                }
        }

        int W=(int)res.size();
        while(W==n-1)
        {
                //printf("!");
                sum-=res.back();
                res.pop_back();
                
                F(i,X,N-4)
                {
                        if(!bl[i]) continue;
                        res.push_back(i);
                        sum+=i;
                        if((int)res.size()==n-1) break;
                }
    
                X=res.back()+1;
                //printf("%d\n",X);

                F(i,X,N-4)
                {
                        //printf("!\n");
                        if((sum+i)%il==0&&bl[i])
                        {
                                //printf("!\n");
                                res.push_back(i);
                                break;
                        }
                }

                W=(int)res.size();
        }

        //printf("%d %d\n",(int)res.size(),X);

        for(auto z : res) printf("%d ",z);
        printf("\n");
 }
///////
 void pre()
 {
        int primes[6];
        primes[1]=2;
        primes[2]=3;
        primes[3]=5;
        primes[4]=7;
        primes[5]=11;

        F(i,1,N-4) bl[i]=false;

        F(k,1,5)
        {
                F(i,1,N-4)
                {
                        if(i%primes[k]==0) bl[i]=true;
                }
        }
 }

Measured memory_bytes: 640
N = int(input())
A = list(int(a) for a in input().split())

ans = 0
x_sum = 0
a_sum = 0
r = 0
for l in range(N):
    while r < N and x_sum^A[r] == a_sum+A[r]:
        x_sum ^= A[r]
        a_sum += A[r]
        r += 1
    ans += r-l
    #print(l, r, x_sum, a_sum, ans)
    x_sum ^= A[l]
    a_sum -= A[l]

print(ans)

Measured memory_bytes: 32212
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define INF 120000000

using namespace std;

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

int main() {
    int n, a, b;
    cin >> n >> a >> b;

    if ((b - a) % 2 == 1 || n == 2) {
        cout << "Borys" << endl;
    } else {
        cout << "Alice" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ; //何もしない文
#endif

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size()) //unsignedのサイズをint型に変換
#define pb push_back

typedef long long LL; 
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;

//ここから書き始める
int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);	
    int N; cin >> N;
    VI A(N);
    LL sum = 0;
    REP(i,N)
    {
        cin >> A[i];
        sum += A[i];
    }
    sort(A.begin(), A.end());
    sum -= A[N-1];
    LL ans = 0;

    for(int i = N-2; i>=0; i--)
    {
        if(sum * 2 >= A[i+1]) 
        {
            sum -= A[i];
        }
        else
        {
            ans = abs((N-1) - (i));
            break;
        }

        if(i == 0)
        {
            ans = N;
        }
    }

    cout << ans << endl;


}


Measured memory_bytes: 640