akhauriyash/Code-Regression huggingface dataset:
// +build ignore
package main

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

func solve(sc *scanner, wr *bufio.Writer) int {
	N := sc.i()
	K := sc.i()
	A := make([]int, N+1)
	for i := 1; i <= N; i++ {
		A[i] = sc.i()
	}

	index := map[int]int{1: 0}
	root := []int{1}
	last := 1

	for i := 1; i <= K; i++ {
		last = A[last]
		if _, ok := index[last]; !ok {
			index[last] = i
			root = append(root, last)
		} else {
			j := index[last]
			k := (K-i)%(i-j) + j
			last = k
			break
		}
	}

	if len(root) == K+1 {
		fmt.Println(root[len(root)-1])
	} else {
		fmt.Println(root[last])
	}

	return 0
}

func main() {
	sc := newScanner(os.Stdin)
	wr := bufio.NewWriter(os.Stdout)
	ret := solve(sc, wr)
	wr.Flush()
	os.Exit(ret)
}

// I/O
type scanner struct {
	sc *bufio.Scanner
}

func newScanner(input io.Reader) *scanner {
	sc := bufio.NewScanner(input)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &scanner{sc}
}

func (s *scanner) s() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *scanner) i() int {
	i, e := strconv.Atoi(s.s())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *scanner) f() float64 {
	f, e := strconv.ParseFloat(s.s(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *scanner) bs() []byte {
	return []byte(s.s())
}

func (s *scanner) is(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.i()
	}
	return res
}

func (s *scanner) fs(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.f()
	}
	return res
}


Measured memory_bytes: 18856
import itertools,sys
def f(a):
 if len(a)<2:yield[a[0]]*2
 for i in range(1,len(a)):
  for p,s in f(a[:i]):
   for q,t in f(a[i:]):
    yield(p+q,f'({s} + {t})')
    yield(p-q,f'({s} - {t})')
    yield(p*q,f'({s} * {t})')
def s(a):
 for p in itertools.permutations(a):
  for n,s in f(p):
   if n==10:print(s);return 1
for e in sys.stdin:
 a=list(map(int,e.split()))
 if sum(a)and not s(a):print(0)


Measured memory_bytes: 5656
/*input
198 1.10

*/
 
/*
                                                    ______________
                                                          |       )
                                                          |   )   /
                                                          |______/
                                                    |     |      \
                                                    |     |   )   \
                                                    |_____|_______)
 
*/
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <iomanip>
#include <fstream>
#include <stack>

using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PII;
typedef pair<ll , ll> PLL;
typedef long double ld;
 
#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
int mod = 1000000007;
const int inf = 1034567891;
const ll LL_INF = 1234567890123456789ll;
#define PI 3.14159265
#define endl '\n'
#define F first
#define S second
#define debug(x) cout << #x << " = " << x << endl;
#define TRACE
 
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
 
#define out(container) for (auto it : container) cout << it << " "; cout << endl;
 
 
template < typename T > T GCD(T a, T b)            { ll t; while(a) { t = a; a = b % a; b = t; } return b; }
template < typename T > string toString(T a)       { return to_string(a); }
template < typename T > void toInt(string s, T &x) { stringstream str(s); str >> x;}
inline int add(int x, int y){ x += y; if(x >= mod) x -= mod; return x;}
inline int sub(int x, int y){ x -= y; if(x < 0) x += mod; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % mod;}
inline int powr(int a, ll b){
  int x = 1 % mod;
  while(b){
    if(b & 1) x = mul(x, a);
    a = mul(a, a);
    b >>= 1;
  }
  return x;
}
inline int inv(int a){ return powr(a, mod - 2);}

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  int n;
  cin >> n;
  ll v = 1, ans = 1, mx = 1e18;
  bool ok = true, zero = false;
  for (int i = 0; i < n; i++) {
    cin >> v;
    zero += (v == 0);
    if (ok && ans <= mx / v) {
      ans *= v;
    } else {
      ok = false;
    }
  }
  if (zero) {
    cout << 0 << endl;
    return 0;
  }
  if (!ok) {
    cout << -1 << endl;
    return 0;
  }
  cout << ans << endl;

  return 0;
}

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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

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

// const ll MAX = 20;
const ll MAX = 100010;

ll tb[MAX];

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll n; cin >> n;
    for(int i=0;i<n;i++){
        ll a, b; cin >> a >> b;
        tb[a]++;
        tb[b+1]--;
    }

    ll cnt[MAX+1];
    cnt[0] = 0;
    for(int i=0;i<MAX-1;i++){
        cnt[i+1] = cnt[i] + tb[i+1];
    }
    /*
    for(int i=0;i<20;i++) cout << cnt[i];
    cout << endl;
    */
    ll ans = 0;
    for(ll i=0;i<MAX-1;i++){
        if(cnt[i] >= i - 1){
            // cout << i << endl;
            ans = max(ans, i - 1);
        }
    }
    cout << ans << endl;
}


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

#define pb         push_back

typedef long long ll;
const ll INF = 1000000000ll;
const ll MOD = 1000000007ll;
const double EPS = 1e-8;

int main(void) {
	//ios_base::sync_with_stdio(false);
	//cin.tie(0);
	
	long long a, b;
	cin >> a >> b;
	int sign = 1;

	if(a*b <= 0){
		puts("Zero");
	}else if(a > 0 && b > 0){
		puts("Positive");
	}else{
		if((abs(b) - abs(a) + 1) % 2 == 0){
			puts("Positive");
		}else{
			puts("Negative");
		}
	}

	

	return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);
#define ppp(a) (cout << (a) << endl); 
#define cop(a) for(auto x:(a)){cout << x << endl;}


using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
using mint = map<int, int>;

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

const char sp = ' ';
const char cmm = ',';
const int MOD = 1e9+7;
const int INF = 1e9;
const ll LINF = 1e18;

ll mod(ll a, ll b){return (a%b+b)%b;}
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);}
void Yes(){cout << "Yes" << endl;}
void No(){cout << "No" << endl;}
void Judge(bool b){b?Yes():No();}
void YES(){cout << "YES" << endl;}
void NO(){cout << "NO" << endl;}
void JUDGE(bool b){b?YES():NO();}
ll powmod(ll b, ll e){ll r=1;while(e>0){if(e&1)r=(r%MOD)*(b%MOD)%MOD;b=(b%MOD)*(b%MOD)%MOD;e>>=1;}return r;}
double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));}

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    int len = v.size();
    s << '[';
    for (int i = 0; i < len; ++i) {
        s << v[i]; if (i < len-1) s << ", ";
    }
    s << ']';
    return s;
}

struct aaa{
    aaa(){
        // comment this out when you use scanf or printf
        // cin.tie(0); ios::sync_with_stdio(0);
        cout<<fixed<<setprecision(15);
    };
}fastio;

int main(){
    
    int n; scanf("%d", &n);    
    vector<ll> t(n), a(n);
    ll mt = 0, ma = 0;
    rep(i, n){
        scanf("%lld", &t[i]);
        chmax(mt, t[i]);
    }
    rep(i, n){
        scanf("%lld", &a[i]);
        chmax(ma, a[i]);
    }


    if(mt != ma) {cout << 0 << endl; return 0;}
    
    ll ans = 1;
    set<int> cfd = {0, n-1};
    for(int i = 1; i < n; ++i){
        if(t[i-1] != t[i]){
            cfd.insert(i);
            if(t[i] > a[i]){
                ans = 0;
                break;        
            }
        }
    }
    for(int i = n-2; i >= 0; --i){
        if(a[i] != a[i+1]){
            cfd.insert(i);
            if(a[i] > t[i]){
                ans = 0;
                break;
            }
        }
    }


    rep(i, n){
        if(cfd.find(i) == cfd.end()){
            (ans *= min(a[i], t[i])) %= MOD;
        }
    }
    ppp(ans);

    return 0;
}


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

int main() {
  string s;
  cin >> s;
  int prev = 0;
  s += '#';
  bool ok = false;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] != s[prev]) {
      if (i - prev >= 3) ok = true;
      prev = i;
    }
  }

  cout << (ok ? "Yes" : "No") << endl;
  return 0;
} 

Measured memory_bytes: 3600
import java.util.*;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        long D[] = new long[5];
        long N = sc.nextLong();

        D[0] = sc.nextLong();
        D[1] = sc.nextLong();
        D[2] = sc.nextLong();
        D[3] = sc.nextLong();
        D[4] = sc.nextLong();

        long min = N;

        for(int i=0;i<5;i++){
            if(D[i] < min){
                min = D[i];
            }
        }
        if(min >= N){
            System.out.println(5);
        } else if(N % min == 0){
            System.out.println(N / min +4);
        } else {
            System.out.println(N / min + 5);
        }



    }

}


Measured memory_bytes: 23124
#include <stdio.h>
int main(){
  int n,m,k,i,j,f,r=0,c=0,a[900];
  scanf("%d%d",&n,&m);
  for(i=0;i<n;i++){
    scanf("%d",&k);
    for(j=0;j<k;j++){
      scanf("%d",&a[c]);
      c++;
    }
  }
  for(i=1;i<=m;i++){
    f=0;
    for(j=0;j<c;j++)if(i==a[j])f++;
    if(f==n)r++;
  }
  printf("%d",r);
  return 0;
}

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

using namespace std;

int main() {
	int n;
	cin >> n;
	long long mult = 1;
	bool can = true;
	bool zero = false;
	long long arr[n];
	for (int i = 0; i < n; i++) {
		cin >> arr[i];
	}
	
	sort(arr, arr + n);
	for (int i = 0; i < n; i++) {
		if (!arr[i]) {
			zero = true;
			break;
		}
		if (can && mult > ((long long)1e18 + arr[i] - 1) / arr[i]) {
			can = false;
			break;
		}
		if (can) {
			mult *= arr[i];
		}
		
	}
	
	if (zero) {
		cout << 0 << endl;
	} else {
		if (!can || mult > (long long) 1e18) {
			cout << -1 << endl;;
		} else {
			cout << mult << endl;
		}
	}
	
	return 0;
}

Measured memory_bytes: 4380
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define fast ios_base::sync_with_stdio(false),cin.tie(nullptr),cout.tie(nullptr);
int main() {
    fast
    ll a, b, x, y;
    cin >>a >> b >> x >> y;
    ll n1 = b*x, n2 = b*y, n3 =a*y, n4 = a*x;
    cout << max(max(n1,n2),max(n3,n4));
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>  
#define Max(x,y) ((x)>(y)?(x):(y))  
#define Min(x,y) ((x)<(y)?(x):(y))  
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();++it)  
#define Abs(x,y) ((x)>(y)?((x)-(y)):((y)-(x)))  
#define ll long long  
#define Mem0(x) memset(x,0,sizeof(x))  
#define Mem1(x) memset(x,-1,sizeof(x))  
#define MemX(x) memset(x,0x3f,sizeof(x))  
#define pb push_back  
using namespace std;  
const int N=20;  
bool flag[N];  
  
int main(){  
  int k,i,x,j;  
  char n[N],s[N];  
  while(~scanf("%s%d",n,&k)){  
    Mem0(flag);  
    for(i=0;i<k;++i){  
      scanf("%d",&x);  
      flag[x]=1;  
    }  
    int len=strlen(n),f1=0,f2=0;  
    for(i=0;i<len;++i){  
      if(f2){  
        for(j=0;j<=9;++j){  
          if(flag[j]==0 && j>n[i]-'0'){  
            s[i]='0'+j;  
            n[i]=s[i];  
            break;  
          }  
        }  
        if(j==10){  
          if(!i){ f1=1; break; }  
          i-=2,f2=1;  
          continue;  
        }else{  
          f2=i;  
          break;  
        }  
      }  
      if(flag[n[i]-'0']){  
        for(j=0;j<=9;++j){  
          if(flag[j]==0 && j>n[i]-'0'){  
            s[i]='0'+j;  
            n[i]=s[i];  
            break;  
          }  
        }  
        //cout<<"i="<<i<<" f1="<<f1<<endl;  
        if(j==10){  
          if(!i){ f1=1; break; }  
          f2=1,i-=2;  
          continue;  
        }else{  
          f2=i;  
          break;  
        }  
      }else s[i]=n[i];  
    }  
    //cout<<"f1="<<f1<<endl;  
    if(f1){  
      //cout<<"--------"<<endl;  
      for(i=1;i<=9;++i)  
        if(flag[i]==0){  
          printf("%d",i);  
          break;  
        }  
      for(i=0;i<=9;++i)  
        if(flag[i]==0){  
          while(len--)printf("%d",i);  
          break;  
        }  
    }else{  
      if(i==len)printf("%s",n);  
      else{  
        for(i=0;i<=f2;++i)  
          printf("%c",s[i]);  
        for(j=0;j<=9;++j)  
          if(flag[j]==0){  
            for(;i<len;++i)  
              printf("%d",j);  
            break;  
          }  
      }  
    }  
    puts("");  
  }  
}  

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define M 200005
#define N 15
using namespace std;

int m,n,w[M],t[M],c[N],b[N];
int dp[(1<<N)],W[M],T[M];

int calc(int x,int C,int arr[]){
  C+=arr[x];
  int L=x+1,R=m+1;
  while(L<R){
    int mid=(L+R)/2;
    if(C<arr[mid])R=mid;
    else L=mid+1;
  }
  return L-1;
}

int main(){
  cin>>m>>n;
  for(int i=0;i<m;i++){
    cin>>w[i]>>t[i];
    W[i+1]=W[i]+w[i];
    T[i+1]=T[i]+t[i];
  }
  for(int i=0;i<n;i++)cin>>c[i]>>b[i];
  for(int i=0;i<(1<<n);i++){
    for(int j=0;j<n;j++){
      if((i&(1<<j)))continue;
      int r=min(calc(dp[i],c[j],W),calc(dp[i],b[j],T));
      dp[i|(1<<j)]=max(dp[i|(1<<j)],r);
    }
  }
  cout<<dp[(1<<n)-1]<<endl;
  return 0;
}

Measured memory_bytes: 4412
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
using namespace std;
typedef long long ll;
ll n;
int bj[4];
int dfs(ll now) {
	ll temp=10*now;
	if(now>n) return 0;
	int ans=0;
	if(bj[1]&&bj[2]&&bj[3]) ans++;
	if(temp>n) return ans;
	bj[1]++;
	ans+=dfs(temp+3);
	bj[1]--;
	bj[2]++;
	ans+=dfs(temp+5);
	bj[2]--;
	bj[3]++;
	ans+=dfs(temp+7);
	bj[3]--;
	return ans;
}
int main() {
	scanf("%lld",&n);
	printf("%d",dfs(0));
	return 0;
}

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

int main() {
  int N, a;
  a = 0;
  cin >> N;
  for (int i = 1; i < 10; i++){
    for (int j = 1; j < 10; j++){
      if (N == i * j) {
        cout << "Yes" << endl;
        a = 1;
        break;
      }
      if (a == 1){
        break;
      }
    }
    if (a == 1){
      break;
    }
  }
  if (a == 0){
    cout << "No" << endl;
  }
      
}
    


Measured memory_bytes: 256
/*  -*- coding: utf-8 -*-
 *
 * 2840.cc: Unique Subsequence
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 500000;

/* typedef */

/* global variables */

char t[MAX_N + 4], p[MAX_N + 4];
int as[MAX_N], bs[MAX_N];

/* subroutines */

/* main */

int main() {
  scanf("%s%s", t, p);
  int m = strlen(t), n = strlen(p);

  int an = 0;
  for (int i = 0; i < m && an < n; i++)
    if (t[i] == p[an]) as[an++] = i;
  if (an < n) {
    puts("no");
    return 0;
  }

  int bn = n - 1;
  for (int i = m - 1; i >= 0 && bn >= 0; i--)
    if (t[i] == p[bn]) bs[bn--] = i;

  bool ok = true;
  for (int i = 0; ok && i < n; i++)
    ok = (as[i] == bs[i]);

  if (ok) puts("yes");
  else puts("no");
  return 0;
}



Measured memory_bytes: 8048
n, m, c = map(int,input().split())

b = list(map(int,input().split()))
a = [list(map(int,input().split())) for _ in range(n)]

cnt = 0
for i in range(n):
    calc = 0
    for j in range(m):
        calc += a[i][j] * b[j]
    if calc + c <= 0:
        pass
    else:
        cnt += 1
print(cnt)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int n,a,b;
	cin >> n >> a >>b;
	cout << min(b,a*n) << endl;
	return 0;
}

Measured memory_bytes: 256
N  = int(input())
A = list(map(int, input().split()))
INF = 10**18
over = False
ans = 1
for a in A:
    ans *= a
    if ans > INF:
        over = True
        break
if 0 in A:
    print(0)
elif over:
    print(-1)
else:
    print(ans)

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

int N;
int d[6];
void change(int i,int j,int k,int l){
    i--;j--;k--;l--;
    int x=d[i];
    d[i]=d[j];
    d[j]=d[k];
    d[k]=d[l];
    d[l]=x;
}
void solve(){
    for(int i=0;i<6;i++)d[i]=i+1;
    int sum=1;

    while(N--){
        string str;
        cin>>str;
        switch(str[0]){
        case 'N':change(1,2,6,5);break;
        case 'E':change(1,4,6,3);break;
        case 'W':change(1,3,6,4);break;
        case 'S':change(1,5,6,2);break;
        case 'R':change(2,3,5,4);break;
        case 'L':change(2,4,5,3);break;
        }
        sum+=d[0];
    }
    cout<<sum<<endl;
}

int main(){
    while(cin>>N,N)solve();
    return 0;
}

Measured memory_bytes: 1208
#include<map>
#include<set>
#include<bitset>
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<chrono>
#include<stack>
#include<fstream>
#include<list>
#define REP(i,x,y) for(ll i=x;i<=y;i++)
#define SIZE(a) ll(a.size())
#define vll vector<ll> 
#define MEMSET(a, n, m) for(ll i=0;i<=n;i++) a[i] = m
#define BIT(n) (ll(1)<<n)
#define UNIQUE(v) v.erase(unique(v.begin(),v.end()),v.end()) 
#define UNIQUE_ARRAY(a,x) unique(a + 1, a + x + 1) - a - 1
#define SORT(a,n) sort(a+1,a+n+1)
#define SORT_O(a,n,order) sort(a+1,a+n+1,order)
#define PER(i,y,x) for(ll i=y;i>=x;i--)
typedef long long ll;
using namespace std;

ll const MAX = 3e3 + 5;
ll const MOD = 1e9 + 7;
ll mod_p(ll x, ll y) {
	return(x + y + MOD) % MOD;
}
ll mod_m(ll x, ll y) {
	return x * y%MOD;
}

ll dp[MAX][MAX] = {};

int main() {
	ll n;
	cin >> n;
	string s;
	cin >> s;
	dp[1][1] = 1;
	REP(i, 1, n-1) {
		REP(j, 1, i) {
			if (s[i - 1] == '<') {
				dp[i + 1][1] = mod_p(dp[i + 1][1], dp[i][j]);
				dp[i + 1][j + 1] = mod_p(dp[i + 1][j + 1], MOD - dp[i][j]);
			}
			else {
				dp[i + 1][j + 1] = mod_p(dp[i + 1][j + 1], dp[i][j]);
			}
		}
		REP(j, 2, i + 1) {
			dp[i + 1][j] = mod_p(dp[i + 1][j], dp[i + 1][j - 1]);
		}
	}
	ll ans = 0;
	REP(j, 1, n) {
		ans = mod_p(ans, dp[n][j]);
	}
	cout << ans << endl;
}

Measured memory_bytes: 68992
N = int(input())
#0<cake<=25 0<donatu<=14
#4*cake+7*donatu==N
buy = False
break_flag  = False

for cake in range(25):
    for donatu in range(14):
        if 4*cake+7*donatu==N:
            buy = True
            break_flag=True
            break
    
    if break_flag:
        break

if buy:
    print("Yes")
else:
    print("No")

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

#define REPI(i, n) for(int i = 0; i < n; i++)
#define REPJ(j, n) for(int j = 0; j < n; j++)

using namespace std;

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

    string odd, even; cin >> odd >> even;

    REPI(i, odd.length()){
        cout << odd[i];
        if(i < even.length()) cout << even[i];
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;using ll=long long;using vi=vector<int>;using vvi=vector<vi>;using vl=vector<ll>;using vvl=vector<vl>;using P=pair<int,int>;using PL=pair<ll,ll>;using vp=vector<P>;using vpl=vector<PL>;
template<typename T>constexpr auto inf=numeric_limits<T>::max()/2;constexpr int INF=inf<int>,MOD=1000000007;constexpr ll LINF=inf<ll>;
#define _ol3(_1,_2,_3,name,...)name
#define _rep(i,n)_repi(i,0,n)
#define _repi(i,a,b)for(int i=a,i##_l=(b);i<i##_l;++i)
#define REP(...)_ol3(__VA_ARGS__,_repi,_rep,)(__VA_ARGS__)
#define REPR(i,n)for(int i=n-1;i>=0;--i)
#define REPA(i,v)REP(i,(v).size())
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define bit(n)(1ll<<(n))
#define F first
#define S second
#define endl '\n'
#define cho(n,a,b)cout<<((n)?a:b)<<endl
void YES(int n){cho(n,"YES","NO");}void Yes(int n){cho(n,"Yes","No");}void Poss(int n){cho(n,"Possible","Impossible");}
void _print(ostream&){}template<class T,class...U>void _print(ostream&s,const T&t,const U&...u){s<<t<<(sizeof...(u)?' ':'\n');_print(s,u...);}
template<class...T>void print(const T&...t){_print(cout,t...);}template<class...T>void dprint(const T&...t){_print(cerr,t...);}
#ifndef LOCAL
struct osd{template<class T>osd&operator<<(const T&t){return*this;}};osd cer_;
#define dprint(...)
#define cerr cer_
#endif
template<class T>bool chmax(T&a,const T&b){bool x=a<b;x?a=b:b;return x;}template<class T>bool chmin(T&a,const T&b){bool x=a>b;x?a=b:b;return x;}
template<class T,class U>ostream&operator<<(ostream&o,const pair<T,U>&p){return o<<p.F<<' '<<p.S;}
template<class T,class U>istream&operator>>(istream&i,pair<T,U>&p){return i>>p.F>>p.S;}
template<class T>class iterable{template<class U>static auto c(U v)->decltype(all(v),true_type());static false_type c(...);public:const static bool value=decltype(c(declval<T>()))::value;};
//template<class T,typename=enable_if_t<iterable<T>::value>>ostream&operator<<(ostream&o,const T&v){for(auto&&i:v)o<<i<<' ';return o;}
template<class T>istream&operator>>(istream&i,vector<T>&v){for(T&j:v)i>>j;return i;}
template<class T>vector<T>&operator<<(vector<T>&v,const T&t){v.push_back(t);return v;}
template<class T>set<T>&operator<<(set<T>&v,const T&t){v.insert(t);return v;}
template<class T>multiset<T>&operator<<(multiset<T>&v,const T&t){v.insert(t);return v;}

int main(){
    cin.tie(0);ios::sync_with_stdio(0);
    int n,k,q;
    cin>>n>>k>>q;
    vi score(n,k-q);
    REP(i,q){
        int a;
        cin>>a;
        score[a-1]++;
    }
    REP(i,n){
        Yes(score[i]>0);
    }
}


Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		String[] a = new String[]
				{"a", "b", "c", "d", "e", "f", "g", "h",
						"i", "j", "k", "l", "m", "n",
						"o", "p", "q", "r", "s", "t",
						"u", "v", "w", "x", "y", "z"};
		int before = 0;
		int after = 0;
		int i = 0;
		for(i = 0; i < 26; i++) {
			before = s.length();
			s = s.replace(a[i], "");
			after = s.length();
			if(before == after) {
				break;
			}
		}
		if(i == 26) {
			System.out.println("None");
		} else {
			System.out.println(a[i]);
		}
	}
}

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

int c()
{
    int n, m;
    std::cin >> n >> m;
    
    std::vector<long long> height(n + 1, 0);
    for(int i = 0; i < n; i++)
    {
        long long temp = 0;
        std::cin >> temp;
        height[i + 1] = temp;
    }
    
    std::vector<std::vector<int>> neighborList(n + 1);
    for(int i = 0; i < m; i++)
    {
        int a, b;
        std::cin >> a >> b;
        neighborList[a].push_back(b);
        neighborList[b].push_back(a);
    }
    
    int ans = 0;
    for(int i = 1; i < n + 1; i++)
    {
        int isGood = true;
        long long myHeight = height[i];
        for(int k = 0; k < neighborList[i].size(); k++)
        {
            if(myHeight <= height[neighborList[i][k]])
            {
                isGood = false;
                break;
            }
        }
        if(isGood)
        {
            ans++;
        }
    }
    
    std::cout << ans << std::endl;
    
    return 0;
}

int main(int argc, const char * argv[])
{
    c();
    return 0;
}

Measured memory_bytes: 9020
#include <bits/stdc++.h> 
using namespace std;
 
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<long, long> PLL;
 
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a)  (a).begin(),(a).end()
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 

int main(){
    long R,G,B,N;
    cin>>R>>G>>B>>N;
    long res=0;
    for(long r=0;r*R<=N;r++)for(long g=0;g*G<=N-r*R;g++){
        if((r*R+g*G-N)%B==0){
            res++;
        }
    }
    cout<<res<<endl;
    return 0;
}

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

using namespace std;

typedef long long ll;

double getTime() {
  return clock() / (double) CLOCKS_PER_SEC;
}

void read() {};

template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}

void print() {};

template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}

int n; ll k;

bool can(vector <ll> &a, ll x) {
  ll cnt = 0;
  for(int i = 0; i < n; i++) {
    if(a[i] == 0) {
      if(x >= 0) cnt += (n - i - 1);
    }
    else {
      long double need = x / (long double)a[i];
      if(a[i] > 0) {
        cnt += upper_bound(a.begin() + i + 1, a.end(), need) - (a.begin() + i + 1);
      }
      else {
        cnt += a.end() - lower_bound(a.begin() + i + 1, a.end(), need);
      }
    }
  }
  return cnt >= k;
}

int main() {
  read(n);
  read(k);
  vector <ll> a(n);
  for(int i = 0; i < n; i++) {
    read(a[i]);
  }
  sort(a.begin(), a.end());
  ll L = -1e18, R = 1e18;
  ll ans = -1;
  while(L <= R) {
    ll mid = (L + R) / 2LL;
    if(can(a, mid)) {
      ans = mid;
      R = mid - 1;
    }
    else {
      L = mid + 1;
    }
  }
  print(ans);
}

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

answer = (a*n)//b - a*(n//b)
answer_x = 0

if n >= b:
    x = b*(n//b)-1
    answer_x = (a*x)//b - a*(x//b)

answer = max(answer, answer_x)

# print(x)
print(answer)

Measured memory_bytes: 9088
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<set>
#include<map>
#include<queue>
using namespace std;
typedef long long LL;
#define sqr(x) ((x)*(x))
#define mp make_pair
inline long long read(){
	long long x = 0; char ch = getchar(); bool positive = 1;
	for (; !isdigit(ch); ch = getchar())	if (ch == '-')	positive = 0;
	for (; isdigit(ch); ch = getchar())	x = x * 10 + ch - '0';
	return positive ? x : -x;
}
inline void write(long long a){
    if(a>=10)write(a/10);
    putchar('0'+a%10);
}
inline void writeln(long long a){
    if(a<0){
    	a=-a; putchar('-');
	}
	write(a); puts("");
}
const long long N=100005;
long long n,a[3][N],f[3][N],sum[3][N];
int main(){
	n=read();
	for(long long i=0;i<3;i++)for(long long j=1;j<=n;j++)a[i][j]=read();
	sort(&a[1][1],&a[1][n+1]); sort(&a[2][1],&a[2][n+1]); sort(&a[0][1],&a[0][n+1]);
	for(long long i=1;i<=n;i++){f[0][i]=1; sum[0][i]=i;}
	for(long long i=1;i<3;i++){
		for(long long j=1;j<=n;j++){
			long long t=lower_bound(&a[i-1][1],&a[i-1][n+1],a[i][j])-&a[i-1][0];
			t--;
			f[i][j]=sum[i-1][t]; sum[i][j]=sum[i][j-1]+f[i][j];
		}
	}
	cout<<sum[2][n]<<endl;
}

Measured memory_bytes: 7296
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <bitset>
 
#pragma GCC optimize("Ofast")
//#pragma GCC optimization("unroll-loops, no-stack-protector")
//#pragma GCC target("avx,avx2,fma")
 
using namespace std;

using ll = long long;
using ld = long double;
using uint = unsigned int;
using ull = unsigned long long;
template<typename T>
using pair2 = pair<T, T>;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;

#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define endl '\n';
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
template <class T> inline T gcd(T a, T b) { while (b) { a %= b; swap(a, b); } return a; }
template <class T> inline T lcm(T a, T b) { return a * b / gcd(a, b); }

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__);fflush(stderr);
#else
    #define eprintf(...) 42
#endif

clock_t startTime;
double getCurrentTime() {
    return (double)(clock() - startTime) / CLOCKS_PER_SEC;
}

const ll MOD = (ll)1e9 + 7;
ll add(ll x, ll y) {
    x += y;
    if (x >= MOD) return x - MOD;
    return x;
}
ll sub(ll x, ll y) {
    x -= y;
    if (x < 0) return x + MOD;
    return x;
}
ll mult(ll x, ll y) {
    return (x * y) % MOD;
}
ll bin_pow(ll x, ll p) {
    if (p == 0) return 1;
    if (p & 1) return mult(x, bin_pow(x, p - 1));
    return bin_pow(mult(x, x), p / 2);
}

const int N = (1 << 16) + 7;
int dp[2][N];
int n, m, W;

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    
    startTime = clock();
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    int x, y, z;
    cin >> n >> x >> y >> z;
    m = x + y + z - 1;
    W = (1 << (x + y + z - 1)) ^ (1 << (y + z - 1)) ^ (1 << (z - 1));
    
    dp[0][0] = 1;
    while (n --> 0) {
        for(int i = 0; i <= (1 << m); ++i)
            dp[1][i] = 0;
        dp[1][1 << m] = mult(dp[0][1 << m], 10);
        for (int mask = 0; mask < (1 << m); ++mask) {
            for (int x = 1; x <= 10; ++x) {
                int nmask = (mask << x) ^ (1 << (x - 1));
                if ((nmask & W) == W)
                    nmask = 1 << m;
                else
                    nmask &= (1 << m) - 1;
                dp[1][nmask] = add(dp[1][nmask], dp[0][mask]);
            }
        }
        for (int i = 0; i <= (1 << m); ++i)
            dp[0][i] = dp[1][i];
    }
    
    cout << dp[0][1 << m] << endl;
    return 0;
}


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

int main(){
        ll n, t, q;
        scanf("%lld %lld %lld", &n, &t, &q);

        vector<ll> dist(n+2);
        dist[0] = -3e18;
        dist[n+1] = 3e18;
        vector<ll> vect(n+2);
        vect[0] = 1;
        vect[n+1] = 2;

        vector<ll> talkin(0);
        vector<ll> talkinin(n+2);
        talkinin[0] = 0;

        ll inin = 0;
        bool flag=false;
        for(ll i=1; i<n+1; i++){
                scanf("%lld %lld", &dist[i], &vect[i]);
                if(vect[i-1]==1 and vect[i]==2)talkin.push_back((dist[i-1]-dist[i])/2+dist[i]);
                if(vect[i-1]==2 and vect[i]==1) inin++;

                talkinin[i] = inin;
        }
        if(vect[n]==1)talkin.push_back((dist[n]-dist[n+1])/2+dist[n+1]);
        for(int i=0; i<n+2; i++) talkinin[i] = talkin[talkinin[i]];

        vector<ll> imp(q);
        for(int i=0; i<q; i++) scanf("%lld", &imp[i]);
        for(int i=0; i<q; i++){
                ll m = imp[i];
                if(vect[m]==1) cout << min(dist[m]+t, talkinin[m]) << endl;
                else cout << max(dist[m]-t, talkinin[m]) << endl;
        }
        return 0;
}


Measured memory_bytes: 5596
import Foundation
import CoreFoundation

#if swift(>=4.0)
#else
extension String {
    func split(separator separator: Character) -> [String] {
        return self.characters.split(separator).map{String($0)}
    }
    var count: Int {
        return self.characters.count
    }
    func toArray() -> [String] {
        return self.characters.map{String($0)}
    }
    func uppercased() -> String {
        return self.uppercaseString
    }
    func lowercased() -> String {
        return self.lowercaseString
    }
}
extension Array where Element: Comparable {
    func max() -> Element? {
        return self.maxElement()
    }
    func min() -> Element? {
        return self.minElement()
    }
    func sorted() -> Array {
        return self.sort()
    }
    mutating func sort() {
        self.sortInPlace()
    }
}
extension Array {
    func joined(separator separator: String = " ") -> String {
        return self.map{String($0)}.joinWithSeparator(separator)
    }
    func reversed() -> Array {
        return self.reverse()
    }
    mutating func reverse() {
        self = self.reversed()
    }
    func enumerated() -> EnumerateSequence<[Element]> {
        return self.enumerate()
    }
    init(repeating: Element, count: Int) {
        self.init(count: count, repeatedValue: repeating)
    }
}
func stride<T: Strideable>(from start: T, to end: T, by stride: T.Stride) -> StrideTo<T> {
    return start.stride(to: end, by: stride)
}
#endif
func readInt() -> Int? {
    return Int(readLine()!)
}
func readStringSplit(by separator: Character = " ") -> [String] {
    return readLine()!.split(separator: separator)
}
func readIntSplit(by separator: Character = " ") -> [Int] {
    return readLine()!.split(separator: separator).map{Int($0)!}
}
infix operator ** { associativity right precedence 155 }    // 右結合，乗除算より強くビットシフトより弱い
func **(lhs: Int, rhs: Int) -> Int {
    return (0..<rhs).reduce(1){i,_ in i*lhs}
}
func **(lhs: Int, rhs: Double) -> Double {
    return pow(Double(lhs), rhs)
}
//func gcd(_ x: Int, _ y: Int) -> Int {
//    return y>0 ? gcd(y, x%y) : x
//}
//func lcm(_ x: Int, _ y: Int) -> Int {
//    return x * y / gcd(x, y)
//}

/*************** テストスペース ***************/

//arr.sort{$0.0==$1.0 ? $0.1<$1.1 : $0.0<$1.0}  // タプル配列のソート
//print("Ready")

/*************** メインプログラム ***************/

let N = readInt()!
let p = readIntSplit()
let q = p.sorted()
var ans = "NO"
for i in 0..<N {
    for j in i+1..<N {
        var tmp = p
        swap(&tmp[i], &tmp[j])
        if tmp == q {
            ans = "YES"
        }
    }
}
if p == q {
    ans = "YES"
}
print(ans)


Measured memory_bytes: 7268
def main():
  s = input()
  n = len(s)
  x, y = map(int, input().split())

  dpx = [[False, False] for _ in range(n+2)]
  dpy = [[False, False] for _ in range(n+2)]

  dpx[0][0] = True
  dpy[0][0] = True
  x_turn = False
  y_turn = False
  judge = True
  turn = False
  xcount = 0
  count = 0
  for i in range(n):
    if judge and s[i] == "F":
      xcount += 1
      continue
    if judge:
      judge = False
      turn = False if turn else True
      continue
    if s[i] == "F":
      count += 1
      if i != n-1:
        continue
    if turn:
      y_turn = False if y_turn else True
      if y_turn:
        p, q = 0, 1
      else:
        p, q = 1, 0
      for i in range(n+1):
        
        dpy[i][q] = False
      for i in range(n+1):
        if dpy[i][p]:
          dpy[abs(i-count)][q] = True
          dpy[i+count][q] = True
    else:
      x_turn = False if x_turn else True
      if x_turn:
        p, q = 0, 1
      else:
        p, q = 1, 0
      for i in range(n+1):
        dpx[i][q] = False
      for i in range(n+1):
        if dpx[i][p]:
          dpx[abs(i-count)][q] = True
          dpx[i+count][q] = True
    turn = False if turn else True
    count = 0
  
  p = 1 if x_turn else 0
  q = 1 if y_turn else 0
  x -= xcount
  if abs(x) > n:
    print("No")
  elif dpx[abs(x)][p] and dpy[abs(y)][q]:
    print("Yes")
  else:
    print("No")
  
if __name__ == "__main__":
  main()

Measured memory_bytes: 75780
//bismillahir rahmanir rahim            //Author:Fayed Anik

#include <bits/stdc++.h>

using namespace std;


#define         ll                          long  long
#define         lf                          double
#define         pb(x)                       push_back(x)
#define         ull                         unsigned long long
#define         sfl(a)                      scanf("%lld",&a)
#define         sf(a)                       scanf("%d",&a)
#define         pf(a)                       printf("%d\n",a)
#define         pfl(a)                      printf("%lld\n",a)
#define         FOR(x,n)                    for(ll x=1;x<=n;++x)
#define         pii                         pair< ll , ll >
#define         SET(m)                      memset(m, 1,sizeof m)
#define         RESET(m)                    memset(m,0,sizeof m)
#define         mp(a,b)                     make_pair(a,WWb)
#define         mod                         1000000007
#define         INF                         1e17
#define         f1                          first
#define         f2                          second
#define         all(v)                      v.begin(),v.end()
#define         PI                          acos(-1)
#define         printminusone               printf("-1\n")
#define         bug                         printf("bug")
#define         FILEIN                      freopen("in.txt","r",stdin)
#define         FILEOUT                     freopen("out.txt","w",stdout)

//ll SET(ll mask,ll pos){ return mask = (mask | (1ll<<pos)); }
//ll RESET(ll mask,ll pos){ return mask = mask & ~(1ll<<pos); }
//bool CHECK(ll mask,ll pos) { return (bool) (mask & (1ll<<pos)); }
//priority_queue <ll, vector<ll>, greater<ll> > pq;

int main(){
    ll n,m;
    cin>>n>>m;
    if(n==m){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    return 0;


}



Measured memory_bytes: 256
N = int(input())
A = list(map(int, input().split()))

col = set()
wildc = 0

for i in range(N):
  if A[i] >= 3200:
    wildc += 1
  else:
    col.add(A[i] // 400)

a = len(col) if len(col) > 0 else 1
b = len(col)+wildc
print(a, b)

Measured memory_bytes: 3064
#include <stdio.h>
#define N 500000
#define S_IN 1000000000
int L[N],R[N];
int count=0;
void merge(int A[],int left,int mid,int right){
  int n1 = mid - left;
  int n2 = right - mid;
  int i,j;
  for(int i=0;i<n1;i++)L[i] = A[left + i];
  for(int i=0;i<n2;i++)R[i] = A[mid + i];
  L[n1] = 2*S_IN;
  R[n2] = 2*S_IN;
  i = 0;
  j = 0;
  for (int k = left;k<right;k++){
    count++;
    if (L[i] <= R[j]){
      A[k] = L[i];
      i++;
    }
    else {
      A[k] = R[j];
      j++;
    }
  }
}

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

int main(){
  int A[N],n,i;
  scanf("%d",&n);
  for(i=0;i<n;i++)scanf("%d",&A[i]);
  mergeSort(A,0,n);
  for(i=0;i<n;i++){
    if(i==n-1)printf("%d\n",A[i]);
    else printf("%d ",A[i]);
  }
  printf("%d\n",count);

  return 0;
}



Measured memory_bytes: 5624
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;
int main(){
  int n;
  cin >> n;
  map<ll, ll> m, ans;
  vector<ll> a(n);
  for(int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    tmp--;
    a[i] = tmp;
    m[tmp]++;
  }
  ll sum = 0;
  for(auto p : m) {
    sum += p.second * (p.second - 1) / 2;
    if(p.second > 1){
      ans[p.first] = (p.second - 2) * (p.second - 1) / 2 - p.second * (p.second - 1) / 2;
    }else{
      ans[p.first] = 0;
    }
  }
  for(int i = 0; i < n; i++){
    cout << sum + ans[a[i]] << '\n';
  }
  return 0;
}

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

#define REP(i,m,n) for(int i=(m); i<(int)(n); i++)
#define RREP(i,m,n) for(int i=(int)((n)-1); i>=m; i--)
#define rep(i,n) REP(i,0,n)
#define rrep(i,n) RREP(i,0,n)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define fi first
#define se second
#define debug(...) {cerr<<"[L"<<__LINE__<<"] "; _debug(__VA_ARGS__);}

template<typename T>
string join(const vector<T>&v, string del=", "){ stringstream s;
    for(auto x : v) s << del << x; return s.str().substr(del.size());
}
template<typename T>
ostream& operator<<(ostream& o, const vector<T>&v){
    if(v.size()) o << "[" << join(v) << "]"; return o;
}
template<typename T>
ostream& operator<<(ostream& o, const vector<vector<T> >&vv){
    int l = vv.size();
    if(l){ o<<endl; rep(i,l) o << (i==0 ? "[ " : ",\n  " ) << vv[i] << (i==l-1 ? " ]" : ""); }
    return o;
}
template<typename T1, typename T2>
ostream& operator<<(ostream& o, const pair<T1, T2>& p){
    return o << "(" << p.first << ", " << p.second << ")";
}
inline void _debug(){cerr<<endl;}
template<class First, class... Rest>
void _debug(const First& first, const Rest&... rest){cerr<<first<<" ";_debug(rest...);}

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

const double PI = (1*acos(0.0));
const double EPS = 1e-9;
const int INF = 0x3f3f3f3f;
const ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const ll mod = 1e9 + 7;

inline void finput(string filename) {
    freopen(filename.c_str(), "r", stdin);
}

int main(){
    ios_base::sync_with_stdio(0);
    // finput("./input");
    int h,w,m; cin >> h >> w >> m;
    vi hcnt(h+1), wcnt(w+1);
    set<pii> bomb;
    rep(i,m){
        int hi,wi;
        cin >> hi >> wi;
        hi--; wi--;
        hcnt[hi]++;
        wcnt[wi]++;
        bomb.emplace(hi,wi);
    }

    int hm = *max_element(all(hcnt));
    int wm = *max_element(all(wcnt));
    vi hmax,wmax;
    rep(hi,h) if(hcnt[hi] == hm) hmax.push_back(hi);
    rep(wi,w) if(wcnt[wi] == wm) wmax.push_back(wi);

    int ans = hm + wm - 1;
    for(auto hi : hmax) for(auto wi : wmax){
        if(bomb.find({hi,wi}) == bomb.end()){
            ans = hm + wm;
            cout << ans << endl;
            return 0;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 23824
n = int(input())
m = [int(x) for x in input().strip().split()]
if n % 2 == 0:
    nm = m[::-2] + m[::2]
else:
    nm = m[::-2] + m[1::2]
for i,x in enumerate(nm):
    if i == n-1:
        print(str(x), end='')
    else:
        print(str(x) + ' ', end='')

Measured memory_bytes: 26360
#include<stdio.h>

int color[8];
int any;
int sum;

int main(){
	int N;
	scanf("%d",&N);
	int a[N];

	for(int i=0;i<N;i++){
		scanf("%d",&a[i]);
		if(a[i]<400)color[0]=1;
		else if(a[i]<800)color[1]=1;
		else if(a[i]<1200)color[2]=1;
		else if(a[i]<1600)color[3]=1;
		else if(a[i]<2000)color[4]=1;
		else if(a[i]<2400)color[5]=1;
		else if(a[i]<2800)color[6]=1;
		else if(a[i]<3200) color[7]=1;
		else any++;
	}
	for(int i=0;i<8;i++)sum+=color[i];
	if(sum==0 && any>0){
		sum=1;
		any--;
	}
	printf("%d %d\n",sum,sum+any);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main(void){
    // Your code here!
    long long int N;
    cin >> N ;
    long long int NN=N-1;
    int i;
    vector<int> a(25);
    for(i=0;i<24;i++){
        a.at(i)=NN%26;
        NN = NN/26-1;
        // cout<<i<<":"<<a.at(i)<<endl;
    }
    for(i=23;i>-1;i--){
        string s;
        if(a.at(i)!=-1){
            s=97+a.at(i);
            cout << s << "";
        }
    }
    // cout<<a.at(0)<<endl;
}


Measured memory_bytes: 3584
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll, ll>;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
const ll INF = 1e18;
#define pu push
#define pb push_back
#define mp make_pair
#define print(x) cout << (x) << endl;
#define rep(i,n) for(ll i = 0; i < (n); i++)
#define SORT(x) sort(x.begin(),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define fi first
#define sc second

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> H(N);
    rep(i,N) cin >> H.at(i);
    vector<vector<int>> AB(N,vector<int>());
    rep(i,M){
        int A,B;
        cin >> A >> B;
        A--;
        B--;
        AB.at(A).push_back(B);
        AB.at(B).push_back(A);
    }
    int ans = 0;
    rep(i,N) {
        bool check = true;
        rep(j,AB.at(i).size()) {
            if(H.at(i)<=H.at(AB.at(i).at(j))) check = false;
        }
        if (check == true) {
            ans++;
            // cout << i+1 << "はいい" << endl;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 8804
#include<bits/stdc++.h>
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long
#define vi vector<ll>
#define vvi vector<vi>
#define BITLE(n) (1LL<<((ll)n))
#define SUBS(s,f,t) ((s).substr((f),(t)-(f)))
#define ALL(a) (a).begin(),(a).end()
#define Max(a) (*max_element(ALL(a)))
#define Min(a) (*min_element(ALL(a)))
using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n;cin>>n;
  vi A(n);
  ll xo = 0;
  for(auto &a:A){cin>>a;xo ^= a;}
  for(int i=0;i<n;i++){
    cout<<(xo^A[i])<<" ";
  }
  cout<<endl;
  return 0;
}


Measured memory_bytes: 4720
import heapq


class Dijkstra:

    def __init__(self, rote_map, start_point, goal_point=None):
        self.rote_map = rote_map
        self.start_point = start_point
        self.goal_point = goal_point

    def execute(self):
        """
        :param rote_map:
        :param start_point:
        :param distance:
        :return:
        """
        num_of_city = len(self.rote_map)
        dist = [float("inf") for _ in range(num_of_city)]
        prev = [float("inf") for _ in range(num_of_city)]

        dist[self.start_point] = 0
        heap_q = []
        heapq.heappush(heap_q, (0, self.start_point))
        while len(heap_q) != 0:
            prov_cost, src = heapq.heappop(heap_q)

            if dist[src] < prov_cost:
                continue

            for dest, cost in self.rote_map[src].items():
                if cost != float("inf") and dist[dest] > dist[src] + cost:
                    dist[dest] = dist[src] + cost
                    heapq.heappush(heap_q, (dist[dest], dest))
                    prev[dest] = src
        if self.goal_point is not None:
            return self.get_path(self.goal_point, prev)
        else:
            return dist

    def get_path(self, goal, prev):
        path = [goal]
        dest = goal

        while prev[dest] != float("inf"):
            path.append(prev[dest])
            dest = prev[dest]

        return list(reversed(path))


n, m, s, t = map(int, input().split())
yen_route_map = [dict() for _ in range(n)]
snuuk_route_map = [dict() for _ in range(n)]

for i in range(m):
    u, v, a, b = map(int, input().split())
    u, v = u-1, v-1
    yen_route_map[u][v] = yen_route_map[v][u] = a
    snuuk_route_map[u][v] = snuuk_route_map[v][u] = b
yen_dijkstra = Dijkstra(yen_route_map, s-1).execute()
snuuk_dijkstra = Dijkstra(snuuk_route_map, t-1).execute()

from itertools import accumulate
ans = list(accumulate([y+s for y, s in zip(yen_dijkstra, snuuk_dijkstra)][::-1],min))
[print(10**15-ans[i]) for i in range(n-1,-1,-1)]




Measured memory_bytes: 96272
#include <iostream>
#include <queue>
#include <string>
#include <utility>

using namespace std;

typedef pair<string, char> P;

int n;
queue<P> q;

int main() {
  cin >> n;
  
  q.push(P("a", 'a'));
  
  while (q.size()) {
    P p = q.front();
    q.pop();
    string s = p.first;
    char ch = p.second;
    if (s.length() == n) {
      cout << s << endl;
      continue;
    }
    for (char c = 'a'; c <= ch; c++) {
      q.push(P(s+c, ch));
    }
    ch++;
    q.push(P(s+ch, ch));
  }
  
  return 0;
}

Measured memory_bytes: 8832