akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define debug(x) cerr<<#x<<" = "<<x
#define sp <<"  "
#define el <<endl
#define LL long long
#define M 100020
using namespace std;
namespace IO{
	const int BS=(1<<20)+5; int Top=0;
	char Buffer[BS],OT[BS],*OS=OT,*HD,*TL,SS[20]; const char *fin=OT+BS-1;
	char Getchar(){if(HD==TL){TL=(HD=Buffer)+fread(Buffer,1,BS,stdin);} return (HD==TL)?EOF:*HD++;}
	void flush(){fwrite(OT,1,OS-OT,stdout);}
	void Putchar(char c){*OS++ =c;if(OS==fin)flush(),OS=OT;}
	void write(int x){
		if(!x){Putchar('0');return;} if(x<0) x=-x,Putchar('-');
		while(x) SS[++Top]=x%10,x/=10;
		while(Top) Putchar(SS[Top]+'0'),--Top;
	}
	int read(){
		int nm=0,fh=1; char cw=getchar();
		for(;!isdigit(cw);cw=getchar()) if(cw=='-') fh=-fh;
		for(;isdigit(cw);cw=getchar()) nm=nm*10+(cw-'0');
		return nm*fh;
	}
}
using namespace IO;
#define bas 1005
int n,m,p[1020][1020],X[M],Y[M],D,ans,c[2020][2020],len[M][2];
void calc(int id,int x){
	int k=sqrt(x);while(k*k<x) k++;
	len[id][0]=k,len[id][1]=(x/k)+(x%k>0);
	len[id][0]*=D,len[id][0]-=D;
	len[id][1]*=D,len[id][1]-=D;
	if(len[id][0]>len[id][1]) swap(len[id][0],len[id][1]);
}
void add(int dt,int x,int y,int xx,int yy){
	c[x][y]+=dt,c[x][yy+1]-=dt,c[xx+1][y]-=dt,c[xx+1][yy+1]+=dt;
}
void mdf(int kd,int x,int y,int t1,int t2,int dis){
	int q1=dis-t1,q2=dis-t2; if(q1<0||q2<0) return;
	if(q1>=D) q1=D-1; if(q2>=D) q2=D-1;
	add(kd,x-q1+bas,y-q2+bas,x+bas,y+bas);	
}
int tot(int x,int y){return c[x+bas][y+bas]+c[x-D+bas][y+bas]+c[x+bas][y-D+bas]+c[x-D+bas][y-D+bas];}
bool solve(int dis){
	memset(c,0,sizeof(c));
	for(int i=1;i<=n;i++){
		int x=X[i],y=Y[i];
		mdf(1,x,y,len[i][0],len[i][1],dis);
		mdf(1,x,y,len[i][1],len[i][0],dis);
		mdf(-1,x,y,len[i][1],len[i][1],dis);
	}
	for(int i=bas-D;i<=bas+D;i++){
		for(int j=bas-D;j<=bas+D;j++) c[i][j]=c[i][j]+c[i-1][j]+c[i][j-1]-c[i-1][j-1];
	}
	for(int i=0;i<D;i++){
		for(int j=0;j<D;j++) if(tot(i,j)==n){return true;}
	} return false;
}
int main(){
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	n=read(),D=read();
	for(int i=1;i<=n;i++){
		X[i]=read(),Y[i]=read();
		X[i]%=D,Y[i]%=D,p[X[i]][Y[i]]++;
	}
	if(n==1){puts("0");return 0;} n=0;
	for(int i=0;i<D;i++){
		for(int j=0;j<D;j++){
			if(!p[i][j]) continue;
			n++,X[n]=i,Y[n]=j,calc(n,p[i][j]);
		}
	}
	for(int l=1,r=2000000002,mid=1000000001;l<=r;mid=((l+r)>>1)){
		if(solve(mid)) ans=mid,r=mid-1;else l=mid+1;
	}printf("%d\n",ans);
	return 0;
}

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

#define REP(i,num) for(ll i=0;i<(num);++i)
#define FOR(i,c,num) for(ll (i)=(c);(i)<(num);++(i))
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=ll>
T in(){T x; cin >> x; return (x);}
template<typename T=ll,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return x;}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

template<typename T>
bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>
bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;}

string dfs(vvll& dp,ll N,ll M,string& S,string& T,string U){
	if(N==0 || M==0){
		return U;
	}

	if(dp[N][M]>dp[N-1][M] && dp[N][M]>dp[N][M-1]){
		U = dfs(dp,N-1,M-1,S,T,U+S[N-1]);
	}
	else{
		if(dp[N-1][M]>dp[N][M-1]){
			U = dfs(dp,N-1,M,S,T,U);
		}
		else{
			U = dfs(dp,N,M-1,S,T,U);
		}
	}
	return U;
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	string S=in<string>(),T=in<string>();
	int N=S.size(),M=T.size();
	vvll dp(N+1,vll(M+1,0));
	REP(i,N){
		REP(j,M){
			chmax(dp[i+1][j+1],dp[i+1][j]);
			chmax(dp[i+1][j+1],dp[i][j+1]);
			if(S[i]==T[j]) chmax(dp[i+1][j+1],dp[i][j]+1);
		}
	}
	auto A=dfs(dp,N,M,S,T,"");
	reverse(ALL(A));
	out(A);
	return 0;
}


Measured memory_bytes: 83312
#include <bits/stdc++.h>
#include <boost/math/constants/constants.hpp>
using namespace std;
typedef long long ll;
long double e = boost::math::constants::e<long double>();
long double pi = boost::math::constants::pi<long double>();
// 条件を見落としていませんか？
int main () {
    int N, X, Y;
    cin >> N >> X >> Y;
    for (int k = 1; k < N; k++) {
        int r = 0;
        for (int i = 1; i < N; i++) {
            set<int> s;
            s.insert(i+k);
            if (abs(X-i) < k) {
                int a = k-abs(X-i)-1;
                s.insert(Y+a);
                s.insert(Y-a);
            }
            for (auto a: s) {
                if (a >= 1 && a <= N && a > i && a-i >= k && abs(X-i)+1+abs(Y-a) >= k && abs(Y-i)+1+abs(X-a) >= k) {
                    r++;
                }
            }
        }
        cout << r << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <set>

int main()
{
    std::ios_base::sync_with_stdio(0);
    std::cin.tie(0);
    std::string str[100010];
    int n;
    std::cin >> n;

    int m;
    std::multiset<long long int> seti;
    for (int i = 0; i < n; ++i)
    {
        std::cin >> str[i];
        std::sort(str[i].begin(), str[i].end());
    }

    std::sort(str, str + n);
    long long int ans = 0, cur = 1;
    for (int i = 1; i < n; ++i)
    {
        if (str[i] == str[i - 1])
        {
            ++cur;
        }
        else
        {
            ans += (cur * (cur - 1)) / 2;
            cur = 1;
        }
    }

    ans += (cur * (cur - 1)) / 2;

    std::cout << ans;
    //std::cout << ans;
}


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

#ifdef LOCAL
#include "/home/shahraaz/bin/debug.h"
#else
#define db(...)
#endif

using ll = long long;
#define f first
#define s second
#define pb push_back
#define all(v) v.begin(), v.end()

const int NAX = 2e5 + 5, MOD = 1000000007;

struct Solution
{
    Solution() {}
    void solveCase();
};

void Solution::solveCase()
{
    string N;
    cin >> N;
    int sum = 0;
    for (auto &x : N)
    {
        sum += x - '0';
        sum %= 9;
    }
    if (sum == 0)
        cout << "Yes\n";
    else
        cout << "No\n";
}

int32_t main()
{
#ifndef LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
    int t = 1;
    // cin >> t;
    Solution mySolver;
    for (int i = 1; i <= t; ++i)
    {
        mySolver.solveCase();
#ifdef LOCAL
        cerr << "Case #" << i << ": Time " << chrono::duration<double>(chrono::steady_clock::now() - TimeStart).count() << " s.\n";
        TimeStart = chrono::steady_clock::now();
#endif
    }
    return 0;
}


Measured memory_bytes: 3780
#include <iostream>

using namespace std;
int a;
int main()
{
    cin>>a;
    for(int i=1;i<=9;i++)
    {
        for(int j=1;j<=9;j++)
        {
            if(i*j==a)
            {
                cout<<"Yes";
                return 0;
            }
        }
    }
    cout<<"No";
    return 0;
}


Measured memory_bytes: 256
from collections import Counter


n = int(input())
lst_v = list(map(int, input().split()))



if len(set(lst_v)) == 1:
    ans = n // 2
else:
    lst_o = lst_v[::2]
    lst_e = lst_v[1::2]
    cnt_o = Counter(lst_o).most_common()
    cnt_e = Counter(lst_e).most_common()

    if cnt_o[0][0] == cnt_e[0][0]:
        rem_number = max(cnt_o[0][1] + cnt_e[1][1], cnt_o[1][1] + cnt_e[0][1])
    else:
        rem_number = cnt_o[0][1] + cnt_e[0][1]
    ans = n - rem_number


print(ans)


Measured memory_bytes: 21084
a,b = map(int, input().split())

def gcd(a, b):
  while b:
      a, b = b, a % b
  return a

def factorization(n):
  arr = {1}
  tmp = n
  for i in range(2,int(tmp**0.5)+1,1):
    while tmp % i == 0:
      tmp //= i
      arr.add(i)
  if tmp != 1:
    arr.add(tmp)
  return arr

g = gcd(a,b)
arr = factorization(g)
print(len(arr))


Measured memory_bytes: 3060
#include <iostream>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main(){
	stack<long> S1;
	stack<pair<long, long> > S2;
	char ch;
	long sum = 0;
	for (long i = 0; cin >> ch; i++){
		if (ch == '\\') S1.push(i);
		else if (ch == '/' && S1.size() > 0){
			long j = S1.top();
			S1.pop();
			sum += i - j;
			long a = i - j;
			while (S2.size() > 0 && S2.top().first > j){
				a += S2.top().second; S2.pop();
			}
			S2.push(make_pair(j, a));
		}
	}

	vector<long> ans;
	while (S2.size() > 0){
		ans.push_back(S2.top().second); S2.pop();
	}
	reverse(ans.begin(), ans.end());
	cout << sum << endl;
	cout << ans.size();
	for (long i = 0; i < ans.size(); i++){
		cout << " ";
		cout << ans[i];
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1360
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod = 1e9 + 7;
int main()
{
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    int sum = 0;
    for (int i = 1;i<=n;i++)
    {
        int x;
        cin>>x;
        if (x != i) sum ++;
    }
//    cout<<sum<<endl;
    if (sum == 2 || !sum) puts("YES");
    else puts("NO");
    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
   ll int n,k;
    cin>>k>>n;
    vector<ll int>s;
    for(ll int i=0;i<n;i++)
    {
       ll int x;
        cin>>x;
        s.push_back(x);
    }
    int z=accumulate(s.begin(),s.end(),0);
    if(z>=k)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;




    return 0;
}



Measured memory_bytes: 1400
import java.util.Scanner;

class Main{
  public static void main(String[]args){
    
  Scanner sc=new Scanner(System.in);
  int A=sc.nextInt();
  int B=sc.nextInt();
  int C=sc.nextInt();
    
  if(A==B){
      int X=A;
      if(X==C){
        System.out.println("No");//AとB，C同じ
      }else{
        System.out.println("Yes");//AとBが同じでCが違う
      }
   }else if(A==C){
      System.out.println("Yes");//AとCが同じでBが違う
   }else if(B==C){
      System.out.println("Yes");//BとC同じでAが違う
   }else{
      System.out.println("No");
   }
  }
 }
        
  

Measured memory_bytes: 21844
# aのLongest Increasing Subsequence (LIS)を求めよ
# https://qiita.com/python_walker/items/d1e2be789f6e7a0851e5
from bisect import bisect_left
n = int(input())
a = [int(input()) for _ in range(n)]  # a[i] >= 0

# dp[i] = min{a_ji | 長さがiのincreasing subsequence a_j0 < a_j1 < ... < a_ji}

dp = [a[0]]  # a[0] < dp[0]となる
for i in range(n):
    k = bisect_left(dp, a[i])
    if k == len(dp):
        dp.append(a[i])
    else:  # k < len(dp)
        dp[k] = a[i]

print(len(dp))


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


int math(int a, int b, int c, int x){
  int ans;

  ans = (a * x + b) % c;

  return ans;
}

int main(){

  int N, A, B, C, X;

  while(cin >> N >> A >> B >> C >> X && (N || A || B || C || X)){

    int cnt = 0, Y[10000];
    int xx;
    int judge = 0;
    int s = 0;

    for(int i = 0; i < N; i++){
      cin >> Y[i];
    }
    int k = 1;
    xx = X;

    for(int j = 0; j <= 10000; j++){
      if(Y[cnt] == X){
	cnt++;
	X = math(A,B,C,X);
	judge = j;
	if(cnt == N){
	  cout << judge  << endl;
	  break;
	}
      }else {
	X = math(A,B,C,X);
      }
    }
    if(cnt != N) cout << -1 << endl;

  }

  return 0;
}

Measured memory_bytes: 1168
import Control.Monad
import Data.List

type Query = ((Int, Int, Int), Int)

toQuery :: [Int] -> Query
toQuery [b, f, r, v] = ((b, f, r), v)

getQuery :: IO Query
getQuery = fmap (toQuery . map read . words) getLine

sumPersons :: Int -> Int -> Int -> [Query] -> Int
sumPersons b f r list = sum [v | (k, v) <- list, k == (b, f, r)]

mkBuildings :: [Query] -> [String]
mkBuildings queries =
  intercalate [replicate 20 '#'] (buildings queries)
  where
    buildings q = [building q b | b <- [1..4]]
    building q b = [floor q b f | f <- [1..3]]
    floor q b f = concat [room q b f r | r <- [1..10]]
    room q b f r = ' ' : (show $ sumPersons b f r q)
main = do
  n <- readLn :: IO Int
  queries <- replicateM n getQuery
  let buildings = mkBuildings queries
  mapM_ putStrLn buildings
  

Measured memory_bytes: 4088
#include <algorithm>
#include <bitset>
#include <boost/multiprecision/cpp_int.hpp>
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <set>
#include <numeric>
#include <sstream>
#include <stdio.h>
#include <string>
#include <tuple>
#include <vector>
#include<iomanip>
namespace mp = boost::multiprecision;
using namespace std;
using ull = unsigned long long;
using ld = long double;
using lll = boost::multiprecision::cpp_int;
using ll = long long;
#define FOR(i, N) for(ll i = 0; i < N; ++i)

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
// using int = ll;
template <typename T>
T gcd(T m, T n) {
    if(n == 0)
        return abs(m);
    return (gcd(n, m % n));
}
void putYN(bool b) {
    if(b) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}
ll combi(ll n, ll k) {
    ll r = 1, rr = 1;
    for(ll i = 0; i < k; ++i) {
        r *= (n - i);
        rr *= (i + 1);
        // r %= 1000000007;
        // rr %= 1000000007;
    }
    r /= rr;
    // r %= 1000000007;
    return r;
}
int main(){
  ll N,K;
  cin>>N>>K;
  vector<ll> P(N);
  FOR(i,N){
    cin>>P[i];
  }
  ll max_=0;
  ll now=0;
  FOR(i,K){
    now+=P[i];
  }
  max_=now;
  for(int i=K;i<N;++i){
    now+=P[i];
    now-=P[i-K];
    if(now>max_)max_=now;
  }
  printf("%.7f",(max_+K)/2.0);
  return 0;
}

Measured memory_bytes: 1792
n,m=map(int,input().split())
li=[list(map(int,input().split())) for i in range(n)]
a=[0] * m
for i in li:
  for j,item in enumerate(i):
    if j==0:
      continue
    else:
      a[item-1] += 1
print(a.count(n))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double lf;
const int Inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3fll;

typedef __int128 lll;
ll n;

inline void exgcd(lll a, lll b, lll &x, lll &y) {b ? (exgcd(b, a % b, y, x), y -= a / b * x) : (x = 1, y = 0);}
inline ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;}

int main() {
	cin >> n; n *= 2;
	ll ans = n;
	for(ll i = 1; i * i <= n; i++) {
		if(n % i) continue;
		ll now = i;
		lll x, y;
		if(gcd(now, n / now) == 1) {
			exgcd(n / now, now, x, y);
			y = -y; ((y %= n / now) += n / now) %= n / now;
			if(y) ans = min(ans, ll(y * now));
		}
		now = n / i;
		if(gcd(now, n / now) == 1) {
			exgcd(n / now, now, x, y);
			y = -y; ((y %= n / now) += n / now) %= n / now;
			if(y) ans = min(ans, ll(y * now));
		}
	}
	cout << ans << endl;
	return 0;
}


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

int main(){
  int m,n,v,tmp;
  double s1,s2;

  while(1){
    cin >> m;
    if(!m)break;

    s1 = 0.0;
    tmp = 360;
    for(int i=1;i<m;i++){
      cin >> v;
      tmp -= v;
      s1 += sin(M_PI*v/180);
    }
    s1 += sin(M_PI*tmp/180);

    cin >> n;
    s2 = 0.0;
    tmp = 360;
    for(int i=1;i<n;i++){
      cin >> v;
      tmp -= v;
      s2 += sin(M_PI*v/180);
    }
    s2 += sin(M_PI*tmp/180);

    if(abs(s1-s2)<1e-10)cout << 0 << endl;
    else if(s1<s2)cout << 2 << endl;
    else cout << 1 << endl;
  }
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
/* {{{ */
/*-------------------------------*/
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define RFOR(i, a, b) for(int i = (b) - 1; i >= (a); i--)
#define REP(i, n) for(int i = 0; i < (n); i++)
#define rep(i, n) for(int i = 0; i < (n); i++)
#define RREP(i, n) for(int i = (n) - 1; i >= 0; i--)
#define rrep(i, n) for(int i = (n) - 1; i >= 0; i--)

#define all(i) (i).begin(),(i).end()
#define rall(i) (i).begin(),(i).end(),greater<int>()
#define MAX_INT 2147483647
#define PB push_back
#define pb push_back
#define mp make_pair
#define FI first
#define SE second

//#define int long long

inline int in(){int x;std::cin>>x;return x;}
struct FAST {FAST(){cin.tie(0);ios::sync_with_stdio(false);}} Fast;
template <class X> void print(X hoge){ cout << hoge<< '\n'; }

typedef long long ll;
typedef pair<int, int> pint;
typedef vector<int> vi;
typedef vector<vector<int> > vii;
typedef vector<long long> llv;
typedef vector<pint> vpint;
/*-------------------------------*/
/* }}} */ 

signed main(void)
{
  int n, m;
  int b;
  vector<pair<int, int> > a;

  cin >> n >> m;
  rep (i, n) {
    int x;
    cin >> x;
    a.pb(mp(x, 0));
  }

  rep (i, m) {
    cin >> b;
    rep (j, n) {
      if (b >= a[j].FI) {
        a[j].SE++;
        break;
      }
    }
  }

  int point = -1;
  int soe;

  rep (i, n) {
    if (point < a[i].SE) {
      point = a[i].SE;
      soe = i;
    }
  }

  cout << soe + 1 << endl;

  return 0;
}

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

const ll MAX = 200000;
const ll INF = 1001001001;
const ll MOD = 1000000007;
const double PI=3.1415926535897932;

ll H, W, N, ans=0, tmp=0;
vector<ll> A;
vector<pair<ll,ll>> P;
vector<vector<ll>> G;
string S;
map<pair<ll,ll>, ll> MP;

signed main(){
    cin >> H >> W >> N;
    A.resize(10, 0);
    A[0] = (H-2)*(W-2);
    for(int i=0;i<N;i++) {
        ll a, b;
        cin >> a >> b;
        a--;
        b--;
        if(a-1>=1&&b-1>=1) MP[make_pair(a-1, b-1)]++;
        if(a>=1&&a<H-1&&b-1>=1) MP[make_pair(a, b-1)]++;
        if(a+1<H-1&&b-1>=1) MP[make_pair(a+1, b-1)]++;
        if(a-1>=1&&b>=1&&b<W-1) MP[make_pair(a-1, b)]++;
        if(a>=1&&a<H-1&&b>=1&&b<W-1) MP[make_pair(a, b)]++;
        if(a+1<H-1&&b>=1&&b<W-1) MP[make_pair(a+1, b)]++;
        if(a-1>=1&&b+1<W-1) MP[make_pair(a-1, b+1)]++;
        if(a>=1&&a<H-1&&b+1<W-1) MP[make_pair(a, b+1)]++;
        if(a+1<H-1&&b+1<W-1) MP[make_pair(a+1, b+1)]++;
    }
    for(map<pair<ll,ll>, ll>::iterator itr=MP.begin();itr!=MP.end();itr++) {
        pair<pair<ll,ll>,ll> tmp1 = *itr;
        A[tmp1.second]++;
        //cout << tmp1.first.first << " , " << tmp1.first.second << " => " << tmp1.second << endl;
    }
    for(int i=1;i<10;i++) {
        //cout << A[i] << endl;
        A[0] -= A[i];
    }
    for(int i=0;i<10;i++) {
        cout << A[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 59884
S=list(input())
K=int(input())
c=0
f=1
if len(S) == 1:
    ans=K//2
else:
    for a in range(len(S)-1):
        if S[a] == S[a+1]:
            c+=1
            if a != len(S)-2 and S[a+1] == S[a+2]:
                f+=1
            else:
                c-=f//2
                f=1
    ans=c*K
    m=1
    u=1
    if S[0] == S[len(S)-1]:
        for i in range(len(S)-1):
            if S[i]==S[i+1]:
                m+=1
            else:
                break
        for i in reversed(range(len(S)-1)):
            if S[i]==S[i+1]:
                u+=1
            else:
                break
        if m%2 == 1 and u%2==1:
            if m == len(S):
                ans+=K//2
            else:
                ans+=K-1
print(ans)


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using pii  = pair<int,int>;
#define rep(i,n) for(auto i=0; i<(n); i++)
#define rep2(i,x,n) for(auto i=x; i<(n); i++)
#define MOD 1000000007
#define INF 1e+9
#define MAX_V 10

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const double PI = 3.141593;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}    //最大公約数
ll lcm(ll a,ll b) {return a * b / gcd(a, b);}   //最小公倍数
ll combination(ll n, ll r) {
  if ( r * 2 > n ) r = n - r;
  ll dividend = 1;
  ll divisor  = 1;
  for ( ll i = 1; i <= r; ++i ) {
    dividend *= (n-i+1);
    divisor  *= i;
  }
  return dividend / divisor;
}

int n;
int a[20];
int x[20][20];
int y[20][20];

int main() {
    cin>>n;
    rep(i,n){
        cin>>a[i];
        rep(j,a[i]){
            cin>>x[i][j]>>y[i][j];
            x[i][j]--;
        }
    }
    int ans=0;
    for(int i=0;i<(1<<n);i++){  //000000~111111のような感じで全探索
        int co=0;       //正しい人の人数
        bool flag=true;
        for(int j=0;j<n;j++){   
            if((i>>j)&1){
                co++;
                for(int k=0;k<a[j];k++){//正しい人の証言チェック
                    if(((i>>x[j][k])&1)!=y[j][k]){
                        flag=false;
                        goto A;
                    }
                } 
            }
        }
        A:
        if(flag){
            ans=max(ans,co);
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

int X;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	
	cin >> X;
	if(X == 3 || X == 5 || X == 7){
      cout << "YES" << endl;
    }else{
   		cout << "NO" << endl;  
    }
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
#define pb push_back
int main(void){
    ll a,b,c,k;
    cin>>a>>b>>c>>k;
    if(a>k){
        cout<<k<<endl;
    }else if(a+b>k){
        cout<<a<<endl;
    }else{
        cout<<a-(k-(a+b))<<endl;
    }
}


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

bool is_square(int n)
{
    for (int i = 0; i <= n; i++)
    {
        if (i * i == n)
        {
            return true;
        }
    }
    return false;
}

int main()
{
    int n;
    cin >> n;
    map<string, int> m;
    for (size_t i = 0; i < n; i++)
    {
        string a;
        cin >> a;
        m[a]++;
    }
    int max_f = 0;
    for (auto &b : m)
    {
        if (max_f < b.second)
        {
            max_f = b.second;
        }
        /* code */
    }
    for (auto &b : m)
    {
        if (max_f == b.second)
        {
            cout << b.first << endl;
        }
        /* code */
    }

    return 0;
}

Measured memory_bytes: 25216
import java.util.*;
 
public class Main{
  public static void main(String[]args){
    Scanner sc =  new Scanner(System.in);
    String[] S = sc.nextLine().split(" ");
    int A = Integer.parseInt(S[0]);
    int B = Integer.parseInt(S[2]);
    String op = S[1];
    int ans = 0;
    if(op.equals("+")){
      ans = A + B;
    }else{
      ans = A - B;
    }
    System.out.println(ans);
  }
}

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

int main(int argc, char const* argv[])
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    int ans = 0;
    if(a<b){
        ans += a;
    }
    else{
        ans += b;
    }

    if(c<d){
        ans += c;
    }
    else{
        ans += d;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#define MOD 1000000007
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(NULL);
#define all(v) (v).begin() , (v).end()
#define sumof(v) accumulate(all(v), 0LL, plus<ll>())
#define maxof(v) max_element(all(v))
#define minof(v) min_element(all(v))
#define inf INT_MAX

int main(){
    FASTIO
    ll L, R, d; cin>>L>>R>>d;
    ll count = 0;
    for(int i=L; i<=R; ++i){
        if(i%d==0) count++;
    }
    cout<<count<<endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define fast_io() ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0)
using namespace std;
int32_t main() {
	fast_io();
	string s;
	cin >> s;
	for (int i = 0; i < 3; i++)
		cout << s[i];
	cout << "\n";
	return 0;
}

Measured memory_bytes: 3608
# coding: utf-8
# Your code here!
n=int(input())
a=[0]*n
b=[0]*n
ca=0
ans=0
for i in range(n):
    a[i],b[i]=map(int,input().split())
for j in range(n):
    if a[j]>ca:
        ca=a[j]
        ans=a[j]+b[j]
print(ans)

Measured memory_bytes: 10868
#include <stdio.h>

#define MAX 100

int main()
{
  int n,i,j,a,b,c,M[MAX][MAX];

  scanf("%d",&n);

  for( i=0 ; i<n ; i++ ){
    for( j=0 ; j<n ; j++ ){
      M[i][j]=0;
    }
  }

  for( i=0 ; i<n ; i++ ){
    scanf("%d%d",&a,&b);
    a--;
    for( j=0 ; j<b ; j++ ){
      scanf("%d",&c);
      c--;
      M[a][c]=1;
    }
  }

  for( i=0 ; i<n ; i++ ){
    for( j=0 ; j<n ; j++ ){
      if( j ) printf(" ");
      printf("%d",M[i][j]);
    }
    printf("\n");
  }

  return 0;
  
}



Measured memory_bytes: 2112
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
const int INF = 100100100;
using namespace std;

int main()
{
  int a , b, c, d;
  cin >> a >> b >> c >>d;
  bool res=false;

  if(a<=c && c-a<=d || a>c && a-c <=d) res = true;
  if((a<=b && b-a<=d || a>b && a-b <=d) && (b<=c && c-b<=d || b>c && b-c <=d))
      res = true;

  if(res) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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


int main() {
int A,B,C;
  cin>>A>>B>>C;
  int counter=0;
  
  for(int i=0;i<C+1;i++){if(B>=A){
    B-=A;
    counter++;
  if(B<=0||counter==C){break;}
  }else{break;}
  }
  
  cout<<counter<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
 
int main ()
{
	int h,w;
	scanf("%d %d\n",&h,&w);
	char line[w];
	for(int i;i<h;++i)
	{
		gets(line,w,stdin);
		puts(line);
		puts(line);
	}
	return 0;
}

Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
// #define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
// #define int ll
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;
#define all(c) begin(c), end(c)
#define range(i,a,b) for(ll i=a; i<ll(b); i++)
#define rep(i,b) range(i,0,b)
#define rangei(i,a,b) for(ll a=a;i<=ll(b);i++)
#define repi(i,b) rangei(i,1,b)
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
template<class T> ostream & operator << (ostream &os, vector<T> const &);
template<int n, class...T>
typename enable_if<(n>=sizeof...(T))>::type
_ot(ostream &, tuple<T...> const &){}
template<int n, class...T>
typename enable_if<(n< sizeof...(T))>::type
_ot(ostream &os, tuple<T...> const &t){
    os << (n==0?"":" ") << get<n>(t); _ot<n+1>(os, t);
}
    template<class...T>
    ostream & operator << (ostream &os, tuple<T...> const &t){
        _ot<0>(os, t); return os;
    }
template<class T, class U>
ostream & operator<<(ostream &os, pair<T,U> const &p){
    return os << "(" << p.first << ", " << p.second << ") ";
}
template<class T>
ostream & operator<<(ostream &os, vector<T> const &v){
    rep(i,v.size()) os << v[i] << (i+1==(int)v.size()?"":" "); return os;
}
#ifdef DEBUG
#define dump(...) (cerr << #__VA_ARGS__ << " = " << mt(__VA_ARGS__) \
                   << " [" << __LINE__ << "]" << endl)
#else
#define dump(...)
#endif
void fastios(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#define endl '\n'
}
template<class T>
size_t uniq(vector<T> &v){
    sort(v.begin(), v.end());
    v.erase(unique(v.begin(), v.end()), v.end());
    return v.size();
}
template<class T>
size_t uniq(T *l, size_t n){
    sort(l,l+n);
    return unique(l,l+n) - l;
}
#define mems(arr,val) memset(arr,val,sizeof(arr));
int const mod = 1000000007;
int const inf = numeric_limits<int>::max();

// RMQ
template<class T>
struct SegmentTree {
    int n;
    vector<T> dat;
    SegmentTree(int n_ = 0) : n(n_){
        for(n = 1; n < n_; n <<= 1);
        dat.resize(n*2, inf);
    }
    T query(int v, int w, int l, int r){
        if(r <= l || w == 0) return inf;
        if(r - l == w) return dat[v]; // assert(l == 0 && r == w);
        int m = w/2;
        return min(query(v*2, m, l, min(r,m)), query(v*2+1, m, max(0,l-m), r-m));
    }
    void update(int i, T x){
        dat[i+=n] = x;
        for(; i!=1; i/=2) dat[i/2] = min(dat[i], dat[i^1]);
    }
    T query(int l, int r){ return query(1,n,l,r); }
    size_t size() const { return n; }
};

int main(){
    fastios();
    int n, q;
    while(cin >> n >> q){
        SegmentTree<int> st(n);
        rep(i,q){
            char c;
            int x, y;
            cin >> c >> x >> y;
            if(c == '0'){
                st.update(x,y);
            } else {
                cout << st.query(x,y+1) << endl;
            }
        }
    }
}

Measured memory_bytes: 2052
#include<iostream>
#include<algorithm>
#include<cassert>
#include<vector>
#include<fstream>
#include<string>
using namespace std;
#define f(n) for(int i=0;i<n;++i)

int main() {
    #define int long long
	string s;
	cin >> s;
	int c = 0;
	for (int i = s.size() / 2 - 1; i > 0; --i) {
		for (int j = 0; j < i; ++j) {
			if (s[j] != s[i + j]) {
				break;
			}
			if (i - 1 == j) {
				cout << i * 2 << endl;
				++c;
			}
		}
		if (c != 0) {
			break;
		}
	}
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define _GLIBCXX_DEBUG
#define INF 100000010
using namespace std;
const int mod = 1000000007;
const int tmpMod = 998244353;

int main() {
 
  int64_t N;
  cin>>N;
  string a;
  cin>>a;
  string b="";
  //vector<int64_t> A(N);
    if(a.size() <= N)cout<<a<<endl;
  else{
  for(int i=0; i<N; i++){b.push_back(a[i]);}
   cout<<b<<"..."<<endl;}

  //vector<vector<int> > A(N,vector<int>(M));
  //for(int i=0; i<N; i++){for(int j=0; j<M; j++){cin>>A[i][j];}}
  //sort(A.begin(),A.end());
  //for (int i = 0; i < N; i++) { maximum = max(maximum , A[i]);}
  //for (int i = 0; i < N; i++) { minimum = min(minimum , A[i]);}
 // cout << N << endl;
}


Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
 
public class Main {
 
    public static final int BIG_NUM  = 2000000000;
    public static final int MOD  = 1000000007;
 
    public static void main(String[] args) {
 
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
 
        try {
 
            String str[] = br.readLine().split("\\s+");
            int array[] = new int[str.length];
 
            for(int i = 0; i < str.length; i++){
                array[i] = Integer.parseInt(str[i]);
            }
 
            Dice dice = new Dice();
            dice.setNumber(array[0], array[1], array[2], array[3], array[4], array[5]);
 
 
            str = br.readLine().split("\\s+");
            for(int i = 0; i < str.length; i++){
                array[i] = Integer.parseInt(str[i]);
            }
            Dice dice2 = new Dice();
            dice2.setNumber(array[0], array[1], array[2], array[3], array[4], array[5]);
 
            if(dice.equals(dice2)){
                System.out.println("Yes");
            }else{
                System.out.println("No");
            }
 
        } catch (IOException e) {
            e.printStackTrace();
        }
    }
}
 
class Dice{
 
    private int number[];
    private int work[];
    private final String order = "NNNNWNNNWNNNENNNENNNWNNN";
 
    Dice(){
        number = new int[6];
        work = new int[6];
    }
 
 
    public void roll(char dst){
        for(int i = 0; i < 6; i++) work[i] = number[i];
        switch(dst){
        case 'E':
            setNumber(work[3],work[1],work[0],work[5],work[4],work[2]);
            break;
        case 'N':
            setNumber(work[1],work[5],work[2],work[3],work[0],work[4]);
            break;
        case 'S':
            setNumber(work[4],work[0],work[2],work[3],work[5],work[1]);
            break;
        case 'W':
            setNumber(work[2],work[1],work[5],work[0],work[4],work[3]);
            break;
        }
    };
 
    public int getTop(){
        return number[0];
    }
 
    public void setNumber(int n0,int n1,int n2,int n3,int n4,int n5){
        number[0] = n0;
        number[1] = n1;
        number[2] = n2;
        number[3] = n3;
        number[4] = n4;
        number[5] = n5;
    }
 
    public boolean equals(Object object){
 
        if(object == this)return true;
        if(object == null)return false;
        if(!(object instanceof Dice))return false;
 
        Dice another = (Dice)object;
 
        boolean FLG;
 
        for(int i = 0; i < order.length(); i++){
            roll(order.charAt(i));
            FLG = true;
            for(int k = 0; k < 6; k++){
                if(this.number[k] != another.number[k]){
                    FLG = false;
                    break;
                }
            }
            if(FLG)return true;
        }
 
        return false;
    }
};


Measured memory_bytes: 24648
N,M = map(int,input().split())
X = []
for i in range(N):
  a,b = map(int,input().split())
  X.append((a,b))
C = []
for i in range(M):
  c,d = map(int,input().split())
  C.append((c,d))
ans = [0 for _ in range(N)]
INF = float("inf")
for i in range(N):
  MIN = INF
  check = -1
  for y in range(M):
    temp = abs(X[i][0]-C[y][0]) + abs(X[i][1]-C[y][1])
    if temp < MIN:
      MIN = temp
      check = y+1
  ans[i] = check
print(*ans,sep="\n")

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

 
int main() {
   int a,b;
   cin>>a>>b;
   if(a>=13)cout<<b<<endl;
   else if(a>=6)cout<<b/2<<endl;
   else cout<<0<<endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
MOD = pow(10, 9) + 7


n = int(input())
a = list(map(int, input().split()))

m = max(a)

num = [0] * 61

for x in a:
    for j in range(61):
        if (x >> j) & 1:
            num[j] += 1

s = 0

#print(num)

for i in range(61):
    s += (n - num[i]) * num[i] * pow(2, i, MOD) % MOD

print(s % MOD)

Measured memory_bytes: 118972
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, j, n) for (ll i = j; i < n; i++)
#define all(x) (x).begin(),(x).end()
#define INF (1000000000)
#define MOD (1000000007)
#define MAX (110)

/////////////////////////////////////////////////////////

vector<ll> pow2(50);

ll mypow2(ll n){
  if(n == 0) return 1;
  return 2 * pow2[n - 1];
}

ll XOR(ll N){
  ll res = 0;
  rep(n, 0, 45){
    ll cnt = 0;
    ll tmp = N;
    if(n == 0){
      tmp %= 4;
      if(tmp == 1 || tmp == 2) cnt = 1;
    }else{
      tmp %= pow2[n + 1];
      if(tmp >= pow2[n] && tmp % 2 == 0) cnt = 1;
    }
    res += pow2[n] * cnt;
  }
  return res;
}

void Main() {
  ll A, B; cin >> A >> B;
  rep(i, 0, 50) pow2[i] = mypow2(i);
  cout << (XOR(A - 1) ^ XOR(B)) << endl;
}

/////////////////////////////////////////////////////////

int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  //cout << std::fixed << std::setprecision(15);

  Main();
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <math.h>
#include <numeric>
using namespace std;
typedef long long int ll;

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n,k; cin >> n >> k;
    vector<ll> a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    ll left=-2e18-1,right=2e18+1;
    while(right-left>1){
        ll mid=(left+right)/2;
        ll cnt=0;
        for(int i=0;i<n;i++){
            if(a[i]<0){
                int l=i,r=n;
                while(r-l>1){
                    int m=(l+r)/2;
                    if(a[i]*a[m]<=mid){
                        r=m;
                    }else{
                        l=m;
                    }
                }
                cnt+=(n-r);
            }else{
                int l=i,r=n;
                while(r-l>1){
                    int m=(l+r)/2;
                    if(a[i]*a[m]<=mid){
                        l=m;
                    }else{
                        r=m;
                    }
                }
                cnt+=l-i;
            }
        }
        if(cnt<k){
            left=mid;
        }else{
            right=mid;
        }
    }
    cout << right << endl;
}

Measured memory_bytes: 1792
def main():
    A, B, C = map(int, input().split())

    rem = set()
    s = 0
    i = 1
    while True:
        s += A * i
        m = s % B
        if m == C:
            print("YES")
            break

        if m in rem:
            print("NO")
            break

        rem.add(m)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
import math

A, B, C, X, Y = map(int, input().split())

cost = []
cost.append(A*X + B*Y)

for i in range(2*min(X,Y), 2*max(X,Y)+1):
    cost.append(C*i + max(0, math.ceil(X-i/2)*A) + max(0, math.ceil(Y-i/2)*B))

print(min(cost))

Measured memory_bytes: 60212
#include <bits/stdc++.h>
using namespace std;
#define boost ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define fi first
#define se second
#define debug(x) cerr << " - " << #x << ": " << x << endl;
#define debugs(x, y) cerr << " - " << #x << ": " << x << " " << #y << ": " << y << endl;
#define debugii(x) cerr << " - " << #x << ": " << x.fi<<","<<x.se << endl;
#define sep() cerr << "--------------------" << endl;
#define all(x) (x).begin(),(x).end()
#define sz(x) (ll)x.size()
#define ll long long
#define int ll
#define ii pair<int,int>
#define v vector<int>
#define vii vector<ii>
#define vv vector<vector<int> >
#define mp make_pair
#define INF ((ll)1e18 +1)
#define pb push_back
int32_t main(){
	boost ;
	int n,w,s=0;
	cin>>n>>w;
	v W(n),V(n);
	for (int i = 0; i < n; ++i)
		cin>>W[i]>>V[i],s+=V[i];
	vector<int> dp(s+1LL,INF);
	dp[0]=0;
	for (int i = 0; i < n; ++i)
		for (int j = s; j >=V[i] ; j--)
			dp[j]=min(dp[j],dp[j-V[i]]+W[i]);

	for (int i = s; i >=0LL; i--)
		if(dp[i]<=w){cout<<i;return 0;}
	return 0;
}

Measured memory_bytes: 1024
#pragma GCC optimze("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
// inbuilt function in c++
// abs(-2)=2 , __gcd(2,3)=1 , swap(a,b) , 
//string/array s = "aba"; sort(s.begin(), s.end());  do {  cout << s << '\n';  } while(next_permutation(s.begin(), s.end()));  
//for all permutation of s.
#include <bits/stdc++.h>
#define int                 long long int
#define double              long double
#define get(a,n)            for(int i=0;i<n;i++){cin>>a[i];}
#define out(a,n)            for(int i=0;i<n;i++){cout<<a[i]<<" ";}cout<<endl;
#define maxm(a)             int maxi=LLONG_MIN;int index;for(int i=0;i<n;i++){if(maxi<a[i]){maxi=a[i];index=i;}}
#define minm(a)             int mini=LLONG_MAX;int index;for(int i=0;i<n;i++){if(mini>a[i]){mini=a[i];index=i;}}
#define db(x)               cout<<x<<" "<<endl;
#define endl                "\n"
#define PI                  acos(-1)
#define half(a)             a%2?cout<<(a/2+1)<<endl:cout<<a/2<<endl;
#define array               int a[n];for(int i=0;i<n;i++){cin>>a[i];}
#define pb(a)                push_back(a)
#define all(a)              a.begin(),a.end()
using namespace std;
void show(int *a)
{
    int size = (*(&a + 1) - a)-1;
    for(int i=0;i<size;i++)
    {
            cout<<a[i]<<" ";
    }   
    cout<<endl;
}
int binary_search(int *a,int n,int e)
{
    int f,l,m;f=0;l=n-1;
    while(f<=l)
    {//returns index of that value.
        m=(f+l)/2;
        if(e==a[m])
            return(m);
        else if(e>a[m])
                f=m+1;
            else
                l=m-1;
    }
    return -1;
}
vector<int> pf;
void primefactors(int n)  
{  
    while (n % 2 == 0)  
    pf.push_back(2),n = n/2;  
    for (int i = 3; i <= sqrt(n); i = i + 2)  
    {  
        while (n % i == 0)  
        {  
            pf.push_back(i); 
            n = n/i;  
        }  
    }  
    if (n > 2)  
        pf.push_back(n);
        //dont forgot to clear pf vector. 
}  
vector<int> fac;
//vector<int,greater<int>>fac;
void factors(int n) 
{ 
    for (int i=1; i<=sqrt(n); i++) 
    { 
        if (n%i == 0) 
        { 
            if (n/i == i) 
            fac.push_back(i);
            else
            fac.push_back(i),fac.push_back(n/i); 
        } 
    } 
    //dont forgot to clear fac vector.
} 
// priority_queue stores the values in descending order q.front() returns maximum element. ".size() works for priority_queue."
signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout << fixed << setprecision(15);
    int t=1;
//    cin>>t;
    while(t--)
    {
        int a[5];
        cin>>a[0]>>a[1]>>a[2]>>a[3]>>a[4];
        for(int i=0;i<5;i++)
        {
            if(a[i]==0)
            {
                cout<<i+1<<endl;
            }
        }
        
        
    }
   

  
}

Measured memory_bytes: 3664
n = int(input())
count = 0
def dfs(x):
    global count
    if x <= n and len(set(str(x)))==3:
        count += 1

    x *= 10
    for i in [3, 5, 7]:
        if x > n: continue
        x += i
        dfs(x)
        x -= i
dfs(0)
print(count)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
//#include <atcoder/all>
#define LOCAL
using namespace std;
//using namespace atcoder;
template <typename A, typename B>
ostream& operator <<(ostream& out, const pair<A, B>& a) {
out << "(" << a.first << "," << a.second << ")";
return out;
}
template <typename T, size_t N>
ostream& operator <<(ostream& out, const array<T, N>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T>
ostream& operator <<(ostream& out, const vector<T>& a) {
out << "["; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "]";
return out;
}
template <typename T, class Cmp>
ostream& operator <<(ostream& out, const set<T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& v : a) { out << (first ? "" : ", "); out << v; first = 0;} out << "}";
return out;
}
template <typename U, typename T, class Cmp>
ostream& operator <<(ostream& out, const map<U, T, Cmp>& a) {
out << "{"; bool first = true;
for (auto& p : a) { out << (first ? "" : ", "); out << p.first << ":" << p.second; first = 0;} out << "}";
return out;
}
#ifdef LOCAL
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 42
#endif
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
const char* comma = strchr(names + 1, ',');
cerr.write(names, comma - names) << ": " << arg1 << " |";
__f(comma + 1, args...);
}
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
//#define int long long
using P = pair<int,int>;
//#########################################
int main(){
    ll x;cin >> x;
    ll ret = x/11*2;
    x %= 11;
    if(x > 6)ret+= 2;
    else if(x > 0)ret++;
    cout << ret << endl;

    return 0;
}

Measured memory_bytes: 3600
#include <stdio.h>

int main(void){

   int i,N,num,a,c=0;
  scanf("%d",&N);
  
  for(i=1;i<=N;i++){
    num=i;
    a=0;
    while(num!=0){
      num=num/10;
      a++;  
    }
    if(a%2==1)
      c++;
  }
  printf("%d",c);
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define LL long long
const int N = 1e5 + 11;
int n;
LL num[N], a[71], nw[N];
void insert(LL x){
    for(int i = 60;i >= 0; i--){
        if((1LL << i & x) == 0)continue;
        if(a[i] != 0) x ^= a[i];
        else{
            for(int j = i - 1;j >= 0; j--){
                if(!a[j]) continue;
                if(1ll << j & x){
                    x ^= a[j];
                }
            }
            for(int j = i + 1;j <= 60; j++){
                if(1LL << i & a[j]){
                    a[j] ^= x;
                }
            }
            a[i] = x;
            return ;
        }
    }
}
int main(){
    cin>>n;
    LL ans = 0;
    for(int i = 1;i <= n; i++){
        scanf("%lld", &num[i]);
    }
    for(int i = 60;i >= 0; i--){
        int tot = 0;
        for(int j = 1;j <= n; j++){
            if(num[j] >> i & 1)tot++;
        }
        if((tot & 1) == 0){
            for(int j = 1;j <= n; j++){
                if(num[j] >> i & 1)nw[j] |= 1LL << i;
            }
        }
        else ans += 1LL << i;
    }
    for(int i = 1;i <= n; i++){
        insert(nw[i]);
    }
    //printf("ans=%lld\n", ans);
    LL x = 0;
    for(int i = 60;i >= 0; i--){
        if(a[i]){
            x ^= a[i];
            //printf("i=%d a=%lld\n", i, a[i]);
        }
    }
    ans += x * 2LL;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1792
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

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

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        #[cfg(debug_assertions)]
        writeln!(&mut std::io::stderr(), concat!("[DEBUG] ", $(stringify!($a), "={:?} "),*), $($a),*);
    }
}

#[allow(unused_imports)]
use std::cmp::{min, max};
#[allow(unused_imports)]
use std::io::{stdout, stdin, BufWriter, Write};

fn main() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }

    input!{
      a: i64,
      b: i64,
    }

    puts!("{}\n", max(a - (b*2), 0));
}


Measured memory_bytes: 4352
import sys
input=lambda: sys.stdin.readline().rstrip()
n,q=map(int,input().split())
edge = [[] for i in range(n)]
for i in range(n-1):
  a,b=map(int,input().split())
  edge[a-1].append(b-1)
  edge[b-1].append(a-1)
Ans=[0]*n
for i in range(q):
  p,x=map(int,input().split())
  Ans[p-1]+=x
S=[0]
C=[True]*n
C[0]=False
append=S.append
while S:
  s=S.pop()
  a=Ans[s]
  for g in edge[s]:
    if C[g]:
      Ans[g]+=Ans[s]
      append(g)
      C[g]=False
print(*Ans)
      

Measured memory_bytes: 55856
import collections

n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))

d_c = collections.Counter(d)
t_c = collections.Counter(t)

ans = 'YES'
for e in t_c.items():
    if d_c[e[0]]:
        if d_c[e[0]] < e[1]:
            ans = 'NO'
            break
    else:
        ans = 'NO'
        break
    
print(ans)

Measured memory_bytes: 57176