akhauriyash/Code-Regression huggingface dataset:
#include <map>
#include <algorithm>
#include <cassert>
#include <climits>
#include <complex>
#include <cstdio>
#include <string>
#include <iostream>
#include <queue>
#include <string>
#include <tuple>
#include <vector>
using namespace std;
#define FOR(i,x,y) for(int i=(x);i<(int)(y);i++)
#define FORP(i,x,y) for(int i=(x);i<=(int)(y);i++)
#define REP(i,y) for(int i=0;i<(int)(y);i++)
#define REPP(i,y) for(int i=1;i<=(int)(y);i++)
#define REPB(i,n) for(int i=(int)(n)-1;i>=0;i--)

int h,w;
map<int,int> mp;

void err() {
  cout << "No" << endl;
  exit(0);
}

int main()
{
  cin>>h>>w;
  int a=h*w;
  bool ht = h%2==0;
  bool wt = w%2==0;
  REP(i,h)
  {
    string s; cin>>s;
    for (char c : s) mp[c-'a']++;
  }

  if (ht&&wt)
  {
    REP(i,26) if (mp[i]%4!=0) err();
    cout << "Yes" << endl;
    return 0;
  }
  else if (ht||wt)
  {
    int left = a - (ht ? h : w);
    REP(i,26)
    {
      int s = mp[i];
      if (s/4!=0)
      {
        mp[i] -= min(left/4, s/4) * 4;
        left -= min(left/4, s/4) * 4;
      }
      if (left==0) break;
    }
    if (left!=0) err();
    REP(i,26)
    {
      if(mp[i]%2!=0) err();
    }
    cout << "Yes" << endl;
    return 0;
  }
  else if (!ht&&!wt)
  {
    REP(i,26) if (mp[i]%2==1) { mp[i]--; break; }
    int left = (a - ((h-1) + (w-1) + 1)) / 4;
    REP(i,26)
    {
      int s = mp[i];
      if (s/4!=0)
      {
        mp[i] = s - min(s/4, left) * 4;
        left -= min(s/4, left);
      }
      if (left == 0) break;
    }
    if (left != 0) err();
    REP(i,26)
    {
      if (mp[i]%2!=0) err();
    }

    cout << "Yes" << endl;
    return 0;
  }
}


Measured memory_bytes: 256
import sys
from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt, ceil, floor
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache, reduce
from operator import xor
INF = float("inf")
sys.setrecursionlimit(10**7)

# 4近傍（右, 下, 左, 上）
dy = [0, -1, 0, 1]
dx = [1, 0, -1, 0]


def inside(y: int, x: int, H: int, W: int) -> bool: return 0 <= y < H and 0 <= x < W


def main():
    N = input()
    if N[0] == N[1] == N[2] or N[1] == N[2] == N[3]:
        print("Yes")
    else:
        print("No")


if __name__ == '__main__':
    main()


Measured memory_bytes: 4080
#include<bits/stdc++.h>
using namespace std;
char c[200009][12];
map<string,int>mp;
int n,m,i,j,k,l,t;
vector<string>v;
int main()
{
  scanf("%d",&n);
  for(i=0;i<n;i++)
  {
      scanf("%s",&c[i]);
      mp[c[i]]++;
  }
  k=0;
  for(auto &it: mp)
  {
      l=it.second;
      if(l>k)
      {
          t=0;
          k=l;
          v.clear();
          v.push_back(it.first);
      }
      else if(l==k)
      {
          v.push_back(it.first);
      }
  }
  sort(v.begin(),v.end());
  for(i=0;i<v.size();i++)
    cout << v[i] << endl;

}


Measured memory_bytes: 27888
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
typedef pair<string,string> Ps;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};
struct pos{
	// 1 変数を入れる;
	ll x,cost;
};
int main() {

	int n,r;
	cin>>n>>r;
	if(n<10)cout<<100*(10-n)+r<<endl;
	else cout<<r<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
  public static void main(String args[]){
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    String abc[] = s.split("");
    Arrays.sort(abc);
    if(abc[0].equals("a") && abc[1].equals("b") && abc[2].equals("c")){
      System.out.println("Yes");
    }else{
      System.out.println("No");
    }
  }
}

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

using namespace std;

#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef vector <int> vi;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;

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

	int A;
	cin >> A;
	if (A < 1200) cout << "ABC";
	else if (A < 2800) cout << "ARC";
	else cout << "AGC";

	return 0;
}

Measured memory_bytes: 892
#2問目
import math
MAX = 10 ** 9 + 7
N, M = map(int, input().split())
if(abs(N - M) > 1):
    print(0)
elif(abs(N - M) == 0):
    #犬と猿が同数いる時
    print((((math.factorial(N) % MAX) * (math.factorial(M) % MAX) * 2)) % MAX)
else:
    #犬と猿の差が1の時
    print(((math.factorial(N) % MAX) * (math.factorial(M) % MAX)) % MAX)

Measured memory_bytes: 46960
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;

string lol[100000];

int main(){
    int n;
    cin >> n;
    for (int i = 0; i < n; i++){
        cin >> lol[i];
        sort(lol[i].begin(), lol[i].end());
    }
    sort(lol, lol + n);
    long long j = 1, ans = 0;
    for (int i = 1; i < n; i++){
        if (lol[i] == lol[i-1]) j++;
        else{
            ans += (j*(j-1))/2;
            j = 1;
        }
    }
    ans += (j*(j-1))/2;
    cout << ans << '\n';
}


Measured memory_bytes: 7296
#include"bits/stdc++.h"
using namespace std;
int main(){
	long long n;
	cin>>n;
	vector<long long> x;
	for(long long i=0;i!=n;++i){
		long long t;
		cin>>t;
		x.push_back(t);
	}
	reverse(x.begin(),x.end());
	long long ans=0;
	for(long long i=0;i!=x.size()-1;++i){
		if(i!=0 && x[i]==(x[i-1]-1))
			continue;
		else
			ans+=x[i];
	}
	if(x.back()!=0)
		ans=-1;
	for(long long i=0;i!=x.size()-1;++i){
		if((x[i]-x[i+1])>1)
			ans=-1;
	}
	cout<<ans;
}

Measured memory_bytes: 2420
#include<stdio.h>
#include<algorithm>
#include<iostream>
#include<math.h>
const int MAX=1e5+10;
const int mod=1e9+7;
typedef long long ll;
using namespace std;
ll n,vis[MAX];
ll fac[MAX]={1,1};
ll inv[MAX]={1,1};
ll fi[MAX]={1,1};
void init()
{
    for(int i=2;i<MAX;i++)
    {
        fac[i]=fac[i-1]*i%mod;
        inv[i]=(mod-mod/i)*inv[mod%i]%mod;
        fi[i]=fi[i-1]*inv[i]%mod;
    }
}
ll C(ll n,ll m)
{
    return fac[n]*fi[n-m]%mod*fi[m]%mod;
}
ll x,d;
int main()
{
    init();
    scanf("%lld",&n);
    for(ll i=1;i<=n+1;i++)
    {
        scanf("%lld",&x);
        if(vis[x])
            d=vis[x]+n-i;
        vis[x]=i;
    }

    ll ans=0;
    for(ll i=1;i<=n+1;i++)
    {
        ans=C(n+1,i)%mod;
        if(d>=i-1)
            ans=(ans-C(d,i-1)+mod)%mod;
        printf("%lld\n",ans);
    }
    return 0;
}



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

int main() {
int a,b;
cin >> a >>b;
int ans =0;
if((a+b)%3==0)ans++;
if(a%3==0)ans++;
if(b%3==0)ans++;
if(ans>0){
    cout <<"Possible"<<endl;
}
else{
    cout <<"Impossible"<<endl;
}
}





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

int main(){
  string s,t;
  cin >> s >> t;
  //文字列sを昇順にする
  sort(s.begin(),s.end());
  //文字列tを降順にする
  sort(t.begin(),t.end());
  reverse(t.begin(),t.end());
  
  if(s < t) cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
n=int(input())
l=list(map(int,input().split()))
m=0
f=False
f2=True
for i in l:
  a=i
  c=0
  while True:
    if f and c>m:
      break
    if a%2:
      if f2 or m>c:
        m=c
      f=True
      break
    else:
      a/=2
      c+=1
print(m)

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

int main() {
  set<int> arr;
  for (int i = 0; i < 3; ++i) {
    int x;
    cin >> x;
    arr.insert(x);
  }
  if (arr.size() == 2) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <cmath>
#include <set>
#include <algorithm>
#include <iomanip>

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;


int main(){
    int n,k;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }

    int tmp = 0;
    for(int i = 0; i < n; i++){
        tmp = tmp ^ a[i];
    }
    for(int i = 0; i < n; i++){
        cout << (tmp ^ a[i]);
        if(i != n-1) cout << " ";
    }
    cout << endl;

    
    return 0;
}

Measured memory_bytes: 4768
{-# LANGUAGE FlexibleInstances    #-}
{-# LANGUAGE TypeSynonymInstances #-}

import           Control.Applicative
import           Control.DeepSeq
import           Control.Monad
import           Control.Monad.ST
import qualified Data.Array                    as A
import qualified Data.Array.IArray             as IA
import qualified Data.Array.IO                 as AI
import qualified Data.Array.MArray             as MA
import qualified Data.Array.ST                 as STA
import qualified Data.Array.Unboxed            as AU
import           Data.Bits
import qualified Data.ByteString.Char8         as BS
import           Data.Char
import qualified Data.Graph                    as G
import           Data.Int
import qualified Data.IntMap                   as IM
import qualified Data.IntSet                   as IS
import           Data.List
import qualified Data.Map.Strict               as M
import           Data.Maybe
import           Data.Ord
import qualified Data.Sequence                 as SQ
import qualified Data.Set                      as S
import           Data.Time
import qualified Data.Tree                     as T
import qualified Data.Vector                   as V
import qualified Data.Vector.Mutable           as VM
import qualified Data.Vector.Unboxed           as VU
import qualified Data.Vector.Unboxed.Mutable   as VUM

readInt :: IO [Int]
readInt = map (fst . fromJust . BS.readInt) . BS.words <$> BS.getLine

readInts :: Int -> IO [[Int]]
readInts n = replicateM n readInt

readInteger :: IO [Integer]
readInteger = map (fst . fromJust . BS.readInteger) . BS.words <$> BS.getLine

readIntegers :: Int -> IO [[Integer]]
readIntegers n = replicateM n readInteger

readString :: IO [String]
readString = map BS.unpack . BS.words <$> BS.getLine

readStrings :: Int -> IO [[String]]
readStrings n = replicateM n <$> readString

toPair :: [a] -> (a, a)
toPair [x, y] = (x, y)

count :: Eq a => a -> [a] -> Int
count a as = length $ filter (== a) as

put :: Show a => a -> IO ()
put = putStr . show

putList :: Show a => [a] -> IO ()
putList [n     ] = put n
putList (n : ns) = do
  put n
  putStr " "
  putList ns

putStrList :: [String] -> IO ()
putStrList [n     ] = putStr n
putStrList (n : ns) = do
  putStr n
  putStr " "
  putStrList ns

yesNoUpper b | b         = putStrLn "YES"
             | otherwise = putStrLn "NO"

yesNo b | b         = putStrLn "Yes"
        | otherwise = putStrLn "No"

main = do
  [a, op, b] <- readString
  if op == "+" then print $ read a + read b else print $ read a - read b


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

int main(){
    ll n ; cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a.at(i);
    ll ans = 0;
    bool flag = false;

    rep(i,n){
        ll x = a.at(i);
        ans += x/2;
        bool flag2 = false;
        if(x==1 && flag) flag2 = true;

        if(i<(n-1) && x%2 && !flag2){
            a.at(i+1)++;
            flag = true;
        }else{
            flag = false;
        }        
    }

    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <stdio.h>

int main(){

	int N, min_j, cnt=0, temp, i, j;
	int A[100];

	scanf("%d", &N);
	for(i=0; i<N; i++){
		scanf("%d", &A[i]);
	}

	for(i=0; i<N; i++){
		min_j = i;
		for(j=i; j<N; j++){
			if(A[j]<A[min_j]){
				min_j = j;
			}
		}
		if(i!=min_j){
			temp = A[min_j];
			A[min_j] = A[i];
			A[i] = temp;
			cnt++;
		}
	}

	for(i=0; i<N; i++){
		if(i!=0){
			printf(" ");
		}
		printf("%d", A[i]);
	}
	printf("\n%d\n", cnt);

	return 0;
}

Measured memory_bytes: 604
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<stack>
#include<bitset>
#include<deque>
using namespace std;
#define ll long long
#define inf 0x3f3f3f3f
#define ri register int
#define il inline
#define fi first
#define se second
#define mp make_pair
#define pi pair<int,int>
#define mem0(x) memset((x),0,sizeof (x))
#define mem1(x) memset((x),0x3f,sizeof (x))
#define pb push_back
#define gc getchar
template<class T>void in(T &x)
{
    x = 0; bool f = 0; char c = gc();
    while (c < '0' || c > '9') {if (c == '-') f = 1; c = gc();}
    while ('0' <= c && c <= '9') {x = (x << 3) + (x << 1) + (c ^ 48); c = gc();}
    if (f) x = -x;
}
#undef gc
#define N 200010
#define M N<<3
#define int ll
struct Edge {
    int u, v, w, nx;
    Edge() {}
    Edge(int uu, int vv, int ww, int nxt) {
        u = uu, v = vv, w = ww, nx = nxt;
    }
    friend bool operator<(const Edge& a, const Edge& b) {
        return a.w < b.w;
    }
} edge[M];
int cnt, head[M];
il void add(int u, int v, int w) {
    edge[++cnt] = Edge(u, v, w, head[u]);
    head[u] = cnt;
}
int f[N];
int find(int x) {
    return x == f[x] ? x : f[x] = find(f[x]);
}
bool cmpy(int x, int y) {
    int fx = find(x), fy = find(y);
    if (fx == fy) return 0;
    if (fy > fx) f[fy] = fx;
    else f[fx] = fy;
    return 1;
}
int n, q;
int d[N];
signed main() {
    in(n), in(q);
    mem1(d);
    for (ri i = 1, a, b, c; i <= q; ++i) {
        in(a), in(b), in(c);
        add(a, b, c);
        d[a] = min(d[a], c + 1);
        d[b] = min(d[b], c + 2);
    }
    for (ri i = 0; i < n; ++i) {
        d[i] = min(d[i], d[(i - 1 + n) % n] + 2);
    }
    for (ri i = 0; i < n; ++i) {
        d[i] = min(d[i], d[(i - 1 + n) % n] + 2);
    }
    for (ri i = 0; i <= n; ++i) {
        add(i, (i + 1) % n, d[i]);
    }
    sort(edge + 1, edge + 1 + cnt);
    for (ri i = 1; i < n; ++i) f[i] = i;
    int lt = n, ans = 0;
    for (ri i = 1; i <= cnt && lt > 1; ++i) {
        if (cmpy(edge[i].u, edge[i].v)) {
            ans += edge[i].w;
            --lt;
        }
    }
    printf("%lld", ans);
    return 0;
}

Measured memory_bytes: 20736
I,O,T,J,L,S,Z=map(int,input().split())
A=((I-1)//2)*2+O+((J-1)//2)*2+((L-1)//2)*2+3
B=(I//2)*2+O+(J//2)*2+(L//2)*2
if I==0 or J==0 or L==0:
  print(B)
else:
  print(max(A,B))


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

using namespace std;
using ll = long long;

#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define REP(i,n) FOR(i, 0, n)
#define FORD(i,a,n) for(int i=(a); i>=(n); i--)
#define REPD(i,n) FOR(i, n, 0)

#define ALL(o) (o).begin(), (o).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T, vector<T>, greater<T> >;

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

	if(s[0] == '7' || s[1] == '7' || s[2] == '7') {
		cout << "Yes" << endl;
	} else {
		cout << "No" << endl;
	}

	return 0;
}




Measured memory_bytes: 3624
//インクルードなど
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
//FORAは範囲for文(使いにくかったら消す)
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define FORA(i,I) for(const auto& i:I)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

signed main(){
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int x;
    cin >> x;
    if (x < 30){
        cout << "No";
    } else {
        cout << "Yes";
    }
    cout << endl;
}

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

using namespace std;

typedef long long ll;

ll MOD = 1000000007;

int main(int, char**) {
	ll h; cin >> h;
	ll p = h;
	ll n = 1;
	ll cnt = 0;
	while(p!=0) {
		cnt += n;
		p /= 2;
		n *= 2;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <stdint.h>
#include <string>
 
// C++ Libraries
#include <map>
 
#define NUM 200010
 
unsigned int n, k, l;
unsigned int road[NUM][2];
unsigned int rail[NUM][2];
 
unsigned int check[NUM];
unsigned int passed[NUM];
unsigned int station[NUM];
unsigned int ans[NUM];
 
unsigned int road_category[NUM];
unsigned int rail_category[NUM];
 
 
 
 
 
 
 
// unsigned int union_road[NUM];
unsigned int par_road[NUM];
unsigned int rank_road[NUM];
unsigned int count_road[NUM];
// unsigned int union_rail[NUM];
unsigned int par_rail[NUM];
unsigned int rank_rail[NUM];
unsigned int count_rail[NUM];
// uint16_t count[NUM][NUM];
 
 
unsigned int hash_length=0;
 
unsigned int root(unsigned int x, unsigned int* par, unsigned int* rank) {
    return par[x]==x ? x : (par[x]=root(par[x], par, rank));
}
 
 
 
void unite(unsigned int x, unsigned int y, unsigned int* par, unsigned int* rank, unsigned int* count) {
    x = root(x, par, rank);
    y = root(y, par, rank);
    if (x == y) return;
    
    if(rank[x] < rank[y]) {
        par[x] = y;
        count[y] = count[x] + count[y] + 1;
    } else {
        par[y] = x;
        count[x] = count[y] + count[x] + 1;
        if (rank[x] == rank[y]) rank[x]++;
    }
}
 
 
 
int main(){
    unsigned int i, j, h;
    unsigned int terminal_road, terminal_rail;
    int flag;
    scanf("%d%d%d", &n, &k, &l);
    
    
    for(i=0; i<NUM; i++) {
        par_road[i] = i;
        rank_road[i] = 0;
        count_road[i] = 0;
        par_rail[i] = i;
        rank_rail[i] = 0;
        count_rail[i] = 0;
        
        // for(j=1; j<n; j++) {
        //     count[i][j] = 0;
        // }
    }
    
    for(i=1; i<=k; i++) {
        scanf("%d%d", &road[i][0], &road[i][1]);
        int c1 = road[i][0];
        int c2 = road[i][1];
        unite(c1, c2, par_road, rank_road, count_road);
    }
    for(i=1; i<=l; i++) {
        scanf("%d%d", &rail[i][0], &rail[i][1]);
        int c1 = rail[i][0];
        int c2 = rail[i][1];
        unite(c1, c2, par_rail, rank_rail, count_rail);
    }
    
    uint64_t hash_num;
    // std::map<unsigned long long int, unsigned int> mp;
    std::map<uint64_t, unsigned int> mp;
    std::string hash_str;
    
    for(i=1; i<=n; i++) {
        hash_num = (uint64_t)root(i, par_road, rank_road)*(uint64_t)(n+2) + (uint64_t)root(i, par_rail, rank_rail);
        // hash_str = std::to_string(root(i, par_road, rank_road)) + "with" + std::to_string(root(i, par_rail, rank_rail));
        
        auto itr = mp.find(hash_num);        // "xyz" が設定されているか？
        if( itr != mp.end() ) {
            mp[hash_num]++;
        } else {
            mp[hash_num] = 1;
        }
 
        
    }
    
    for(i=1; i<=n; i++) {
        hash_num = (uint64_t)root(i, par_road, rank_road)*(uint64_t)(n+2) + (uint64_t)root(i, par_rail, rank_rail);
 
        printf("%d ", mp[hash_num]);
    }
    
    return 0;
}

Measured memory_bytes: 22272
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
using namespace std;
typedef double  dbl;
typedef long long int lld;
#define foi(i,n) for(i = 0; i < n; i+=1)
#define fod(i,n) for(i=n-1; i >=0; i-=1)
#define MAX std::numeric_limits<lld>::max()
#define MIN std::numeric_limits<lld>::min()
#define FastIO  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define LEN 2000
lld level [LEN];
set <lld> BFS_ (vector <lld> V[], lld s)
{
	cerr << s << "\n";
	set <lld> visit;
	queue< lld> que;
	lld y;
	que.push(s);
	level[s]= 0;
	visit.insert(s);
	while (!que.empty())
	{
		y=que.front();
		que.pop();
		for(lld i = 0; i<V[y].size(); i+=1)
		{
			if (!visit.count(V[y][i])==1)
			{
			level[V[y][i]] = level[y]+1;
				visit.insert(V[y][i]);
				que.push(V[y][i]);
			}
		}
	}
	return visit;
}
int main ()
{
      FastIO
      lld h, w;
      cin >> h;
      cin >> w;
      vector <lld>V[LEN];
      lld A[LEN] , k = 0;
      char dda[h+1][w+1];
      for(lld i = 1; i <= h; i+= 1)
      {
      	for(lld j = 1;j<=w;j++)
      	{
      		cin >> dda[i][j];
      		if (dda[i][j] == '.')
      		{
      			if (i > 1 && dda[i-1][j] == '.')
      			{
      				V[(((i+j)*(i+j+1))/2)+j].push_back(((((i-1)+j)*((i-1)+j+1))/2)+(j-0));
      				V[((((i-1)+j)*((i-1)+j+1))/2)+(j-0)].push_back((((i+j)*(i+j+1))/2)+j);
      			}
      			if (i < h && dda[i+1][j] == '.')
      			{
      				V[(((i+j)*(i+j+1))/2)+j].push_back(((((i+1)+j)*((i+1)+j+1))/2)+(j-0));
      				V[((((i+1)+j)*((i+1)+j+1))/2)+(j-0)].push_back((((i+j)*(i+j+1))/2)+j);
      			}
      			if (j > 1 && dda[i][j-1] == '.')
      			{
      				V[(((i+j)*(i+j+1))/2)+j].push_back((((i+(j-1))*(i+(j-1)+1))/2)+(j-1));
      				V[(((i+(j-1))*(i+(j-1)+1))/2)+(j-1)].push_back((((i+j)*(i+j+1))/2)+j);
      			}
      			if (j < w && dda[i][j+1] == '.')
      			{
      				V[(((i+j)*(i+j+1))/2)+j].push_back((((i+(j+1))*(i+(j+1)+1))/2)+(j+1));
      				V[(((i+(j+1))*(i+(j+1)+1))/2)+(j+1)].push_back((((i+j)*(i+j+1))/2)+j);
      			}
      			A[k] = (((i+j)*(i+j+1))/2)+j;
      			k++;
      		}
      	}
      }
      set <lld> vis;
      lld max   = 0;
      lld i, j;
      foi(i, k)
      {
      	foi(j, LEN)
      	{
      		level[j] = -1;
      	}
      	vis = BFS_(V, A[i]);
      	foi(j, k)
      	{
      		if (level[A[j]] != -1)
      		{
      			if (level[A[j]] > max)
      			{
      				max=level[A[j]];
      			}
      		}
      	}
      }
      cout << max <<"\n";
      return 0;
}

Measured memory_bytes: 384
#include<iostream>  
#include<algorithm>  
#include<string>  
#include<sstream>  
#include<set>  
#include<vector>  
#include<stack>  
#include<map>  
#include<queue>  
#include<deque>  
#include<cstdlib>  
#include<cstdio>  
#include<cstring>  
#include<cmath>  
#include<ctime>  
#include<functional> 
#define INT_MAX 2147483647
#define INT_MIN -2147483648
typedef long long LL;
using namespace std;

int main()
{
	//freopen("data_in.txt", "r", stdin);
	//freopen("data_out.txt", "w", stdout);
	int n = 0;
	cin >> n; 
	if (n > 999) cout << "ABD";
	else cout << "ABC";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std;

const int M=5005;
char s[M];
int nxt[M];
int get_nxt(char p[],int m,int nxt[])
{
	nxt[0]=m;
	int j=-1,a,l;
	int ans=0;
	for(int i=1;i<m;i++,j--)
	{
		if(j==-1||i+nxt[i-a]>=l)
		{
			if(j==-1) j=0,l=i;
			for(;l<m&&j<m&&p[l]==p[j];l++,j++);
			nxt[i]=j; a=i;
		}
		else nxt[i]=nxt[i-a];
		//cout<<i<<" "<<nxt[i]<<endl;
		ans=max(ans,min(nxt[i],i));
	}
	return ans;
}

int main()
{
	int n;
	scanf("%d%s",&n,s);
	int ans=0;
	for(int i=0;i<n;i++)
	{
		//cout<<i<<" : "<<endl;
		ans=max(ans,get_nxt(s+i,n-i,nxt));
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(int argc, char* argv[]) {
    int n;
    char a[101], b[101], c[101];
    int min;
    int i;
    
    scanf("%d\n%s\n%s\n%s", &n, a, b, c);
    
    min = n*3;
    
    for(i=0; i<n; i++) {
    	if(a[i] == b[i]) {
    		min -= 2;
    		if(a[i] == c[i]) {
    			min--;
    		}
    	} else if(b[i] == c[i]) {
    		min -= 2;
    		if(b[i] == a[i]) {
    			min--;
    		}
    	} else if(c[i] == a[i]) {
    		min -= 2;
    		if(c[i] == b[i]) {
    			min--;
    		}
    	} else {
    		min--;
    	}
    }
    printf("%d\n", min);
    return 0;
}

Measured memory_bytes: 128
N = int(input())
H = [int(i) for i in input().split()]
H = H[::-1]
can_move_nums = [0] * N
start = 0

for i in range(1, N):
    if H[i] >= H[i-1]:
        can_move_nums[i] = can_move_nums[i-1]+1        
        
print(max(can_move_nums)) 

Measured memory_bytes: 63984
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


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


int main(){
    string S,T;
    cin>>S>>T;
    ll sum = 0;
    ll ans = INF;
    rep(i,0,S.size()-T.size() + 1){
        sum=0;
        rep(j,0,T.size()){
            if(S[i+j] != T[j])sum++;
        }
        ans = min(ans,sum);
        //cout<<sum<<endl;
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define alpha_size 26


int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr), cout.tie(nullptr);
  
  int a, b, c, k;
  cin >> a >> b >> c >> k;
  int total = min(a, k);
  k -= min(a, k);
  k -= min(b, k);
  total -= min(c, k);
  cout << total << endl;
  
}

Measured memory_bytes: 3652
import sys

s = sys.stdin.readline().rstrip()

def main():
    c1 = s[::2].count('1') + s[1::2].count('0')
    c2 = s[::2].count('0') + s[1::2].count('1')
    print(min(c1, c2))

if __name__ ==  '__main__':
    main()

Measured memory_bytes: 3188
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>
#include<set>
 
using namespace std;
 
#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define P(p) cout<<(p)<<endl;
#define PP(p) cout<<(p)<<" ";
#define INF 1e18

typedef long long ll;
#define int ll
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pi;
//int dy[8]={1,1,1,0,-1,-1,-1,0};
//int dx[8]={-1,0,1,1,1,0,-1,-1};
int dx[4]={0,1,0,-1};
int dy[4]={1,0,-1,0};
int N,K;
vi a;
vi memo1,memo2;

int rec(int i,int cnt){
    if(memo1[i]<0) {
        if(memo2[i]>0){
         memo1[i]= cnt - memo2[i];
        }else{
            memo2[i] = cnt;
        }
    }
    if(memo1[i]>=0){
        int tmp = ((K-cnt)/memo1[i])*memo1[i];
        cnt += tmp;
    }
    if(cnt>=K)return i;
    return rec(a[i],++cnt);
}
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>N>>K;
    a.resize(N+1);
    memo1.resize(N,-1);
    memo2.resize(N,-1);
    rep(i,N){
        cin>>a[i];
        a[i]--;
    }
    int ans = rec(0,0);
    cout << ans +1 << endl;
    return 0;
}


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

int main() {
	// your code goes here
	int n;
	cin>>n;
	long long int ans=0;
	for(int i=1;i<=n;i++){
		ans=ans+(n-1)/i;
	}
	cout<<ans;
	return 0;
}			

Measured memory_bytes: 3588
// Union Find 木
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);


// UnionFind
const int MAX_N = 200010;

struct union_find {
    int par[MAX_N]; // 親
    int rank[MAX_N]; // 木の深さ

    // n要素で初期化
    union_find (int n) {
        for (int i = 0; i < n; i++) {
            par[i] = i;
            rank[i] = 0;
        }
    }

    // 木の根を求める
    int find (int x) {
        if ((par[x] == x)) 
            return x;
        else 
            return par[x] = find(par[x]);
    }

    // xとyの属する集合を併合
    void unite (int x, int y) {
        x = find(x);
        y = find(y);
        if (x == y) return;

        if (rank[x] < rank[y]) {
            par[x] = y;
        } else {
            par[y] = x;
            if (rank[x] == rank[y]) rank[x] ++;
        }
    }

    // xとyが同じ集合に属するか判定
    bool same (int x, int y) {
        return find(x) == find(y);
    }
};

int main() {

    int N, M;
    cin >> N >> M;

    vector<int> p(N);
    REP(i, N) {
        cin >> p[i];
        p[i]--;
    }

    union_find uni(N);

    int x, y;
    for (int i = 0; i < M; i++) {
        cin >> x >> y;
        x--, y--;
        uni.unite(x, y);
    }
    
    int ans = 0;
    REP(i, N) {
        if (uni.find(i) == uni.find(p[i]))
            ans++;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	int ans;
	int v,c;
	vector<int> vec;
	vector<int> tor;
	
	cin >> n;

	for(int i=0;i<n;i++){
		cin>>v;
		vec.push_back(v);
	}
	for(int i=0;i<n;i++){
		cin>>c;
		tor.push_back(c);
	}

	for(int i=0;i<n;i++){
		if(vec[i]<=tor[i]){
			vec[i]=0;
			tor[i]=0;
		}
	}
	ans= accumulate(vec.begin(),vec.end(),0)-accumulate(tor.begin(),tor.end(),0);
	cout<<ans<<endl;
	return 0;


	}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
#define max(a, b)	(((a) > (b)) ? (a) : (b))		/* ２個の値の最大値 */
#define min(a, b)	(((a) < (b)) ? (a) : (b))		/* ２個の値の最小値 */
#define ENTER		printf("\n")					/* 改行プリント */
int DBG = 0;										/* デバッグプリント 提出時は0 */
/* main *************************************************************/

int main()
{
	int		a,c,k,q,n,m,x,y,ans = 0;
	long long  num,sqr,i,j;
	
	scanf("%lld", &num);
	
	sqr = (long long)sqrt( (double)num ) + 1;
	for(i=sqr;i>=2;i--) {
		if ( (num%i) == 0 ) {
			ans = 1;
			break;
		}
	}
	
	if (ans) {
		j = num / i;
		i = i + j - 2;
	} else {
		i = num - 1;
	}
	
	printf("%lld\n", i );


	return 0;
}


Measured memory_bytes: 128
n = int(input())
a = list(map(int,input().split()))
ans1,ans2 = 0,0
sum1,sum2 = 0,0
for i in range(n):
    sum1 += a[i]
    if i%2 == 1 and sum1 >= 0:
        ans1 += sum1 + 1
        sum1 = -1
    elif i%2 == 0 and sum1 <= 0:
        ans1 += -sum1 + 1
        sum1 = 1
for i in range(n):
    sum2 += a[i]
    if i%2 == 0 and sum2 >= 0:
        ans2 += sum2 + 1
        sum2 = -1
    elif i%2 == 1 and sum2 <= 0:
        ans2 += -sum2 + 1
        sum2 = 1
print(min(ans1,ans2))


Measured memory_bytes: 14644
#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define DB double
#define ST string
#define BS bitset
#define PA pair<LL,LL>
#define VE vector
#define VL vector<LL>
#define VP vector<pair<LL,LL>>
#define VVL vector<vector<LL>>
#define PQ priority_queue
#define PQS priority_queue<LL,vector<LL>,greater<LL>>
#define PB push_back
#define POB pop_back
#define PF push_front
#define POF pop_front
#define EB emplace_back
#define MP make_pair
#define TS to_string
#define TU to_ullong
#define BPL __builtin_popcountll
#define FOR(i,a,n) for(i=a;i<n;i++)
#define FORR(i,a,n) for(i=n-1;i>=a;i--)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) FOR(i,0,n)
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define UB(a,n) *upper_bound(ALL(a),n)
#define LB(a,n) *lower_bound(ALL(a),n)
#define INF 1145141919810364364
#define PI 3.14159265358979
#define MOD 1000000007
//#define MOD 998244353
#define ERR 0.00000001
//#define ERR 0.00000000000001
#define NUM 200010
#define FAST cin.tie(0);ios::sync_with_stdio(false)

void Yn(LL a){if(a)printf("Yes\n");else printf("No\n");}
void YN(LL a){if(a)printf("YES\n");else printf("NO\n");}
LL pwmn(LL a,LL n){LL ans=1;while(ans<a)ans*=n;return ans;}
LL LBn(VL &v,LL a){LL mx=v.size(),mn=-1,md;while(mx-mn>1){md=(mx+mn)/2;if(v[md]<a)mn=md;else mx=md;}return mx;}
LL GCD(LL a,LL b){LL c=1,tmp=max(a,b);b=min(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int lcmpr(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return -1;if(*(LL*)a<*(LL*)b)return 1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int ccmpr(const void* a,const void* b){return *(char*)b-*(char*)a;}
int scmp(const void* a,const void* b){return strcmp((char*)a,(char*)b);}
int scmpr(const void* a,const void* b){return strcmp((char*)b,(char*)a);}
LL mod(LL a,LL m){if(a<0)return a%m+m;else return a%m;}
LL DIV(LL a,LL d){LL m=MOD,x=1,y=0,k;while(m){k=d/m;d-=k*m;swap(m,d);x-=k*y;swap(x,y);}return mod(a*mod(x,MOD),MOD);}
LL POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return ans;}
LL fact[NUM],finv[NUM],inv[NUM];
void comi(){LL i;fact[0]=fact[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fact[i]=fact[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
LL com(LL n,LL k){if(n<k||n<0||k<0)return 0;return fact[n]*(finv[k]*finv[n-k]%MOD)%MOD;}
bool cmps(pair<LL,LL> a,pair<LL,LL> b){if(a.second!=b.second)return a.second<b.second;return a.first<b.first;}
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;}

int main(){
  FAST;
  LL i,j,k,ans=0,K;
  cin>>K;
  FOR(i,1,K+1)FOR(j,1,K+1)FOR(k,1,K+1)ans+=GCD(i,GCD(j,k));

  cout<<ans<<endl;
}


Measured memory_bytes: 3624
# -*- coding: utf-8 -*-
def solve():
    M, D = map(int, input().split())
    res = 0 
    for i in range(1,D+1):
        if (i//10)>=2 and (i%10)>= 2 and 1 <= (i//10)*(i%10) <= M:
            res += 1
    return str(res)

if __name__ == '__main__':
    print(solve())

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    int a,b,m,A[200001],B[200001],X[200001][3];
    cin>>a>>b>>m;
    rep(i,a) cin>>A[i];
    rep(i,b) cin>>B[i];
    rep(i,m)rep(j,3) cin>>X[i][j];
    int ma=1e9,mb=1e9;
    rep(i,a) ma=min(ma,A[i]);
    rep(i,b) mb=min(mb,B[i]);
    int ans=ma+mb;
    rep(i,m) ans=min(ans,A[X[i][0]-1]+B[X[i][1]-1]-X[i][2]);
    cout<<ans;
}

Measured memory_bytes: 3200
#include<stdio.h>
int main(void)

{
	int a,b,c;
	scanf("%d",&a);
	scanf("%d",&b);
	scanf("%d",&c);

	if((a<b)&&(b<c))
	{
		printf("Yes\n");
	}
	else
	{
		printf("No\n");
	}

	return 0;


}

Measured memory_bytes: 580
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
//auto PS = new Tuple!(long,string)[](M);
//x[]=1;でlong[]全要素1に初期化
void main()
{
    auto n = lread();
    // writeln(n);
    long 余り = n % 100;
    // writeln(余り);
    long これだけ個買える = (n - 余り) / 100;
    // writeln(これだけ個買える);
    if (これだけ個買える * 5 >= 余り)
    {
        writeln(1);
    }
    else
    {
        writeln(0);
    }
}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}

void arywrite(T)(T a)
{
    a.map!text.join(' ').writeln;
}


Measured memory_bytes: 3712
#include <stdio.h>

#define NMAX 100001
#define SENT 1000000002

struct Card{
  char suit;
  int num;
};

struct Card L[2 + NMAX/2],R[2 + NMAX/2];

void merge(struct Card A[],int n,int left,int mid,int right){
  int i,j,k;
  int n1 = mid - left,n2 = right - mid;

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

  L[n1].num = R[n2].num = SENT;
  i = j = 0;
  for(k = left;k < right;k++){
    if(L[i].num <= R[j].num){
      A[k] = L[i++];
    }else{
      A[k] = R[j++];
    }
  }
}

void mergeSort(struct Card A[],int n,int left,int right){
  int mid;

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

int partition(struct Card A[],int n,int p,int r){

  int i,j;
  struct Card temp,x;

  x = A[r];
  i = p - 1;
  for(j = p;j < r;j++){
    if(A[j].num <= x.num){
      i++;
      temp = A[i];
      A[i] = A[j];
      A[j] = temp;
    }
  }
  temp = A[i + 1];
  A[i + 1] = A[r];
  A[r] = temp;

  return i + 1;
}

void quickSort(struct Card A[],int n,int p,int r){

  int q;
  if(p < r){
    q = partition(A,n,p,r);
    quickSort(A,n,p,q - 1);
    quickSort(A,n,q + 1,r);
  }
}

int main(void){

  int i,n,v,stable = 1;
  struct Card A[NMAX],B[NMAX];
  char S[10];

  scanf("%d",&n);

  for(i = 0;i < n;i++){
    scanf("%s %d",S,&v);
    A[i].suit = B[i].suit = S[0];
    A[i].num = B[i].num = v;
  }

  mergeSort(A,n,0,n);
  quickSort(B,n,0,n - 1);

  for(i = 0;i < n;i++){
    if(A[i].suit != B[i].suit){
    stable = 0;
    }
  }

  if(stable == 1){
    printf("Stable\n");
  }else{
    printf("Not stable\n");
  }
  for(i = 0;i < n;i++){
      printf("%c %d\n",B[i].suit,B[i].num);
  }

  return 0;
}
  

  



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

# define ll long long

vector<ll> buns, patties;

ll findPatties(int N, ll X) {
  if(N == 0) {
    return 1;
  }
  if(X <= 1 && N > 0) {
    return 0;
  }
  
  ll length = buns[N] + patties[N];
  ll prevLength = buns[N-1] + patties[N-1];
  
  if(X == length/2+1) {
    return patties[N]-patties[N-1];
  }
  if(X > length/2+1) {
    return patties[N-1] + 1 + findPatties(N-1, X-(length/2+1));
  }
  
  return findPatties(N-1, X-1);
}

int main() {
	ll N, X;
  cin >> N >> X;
  
  buns.push_back(0);
  patties.push_back(1);
  
  for(int i = 1; i < N+1; i++) {
    buns.push_back(buns[i-1]*2+2);
    patties.push_back(patties[i-1]*2+1);
  }
  
  ll ans = findPatties(N, X);
  
  cout << ans << endl;
  
  return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python3

from math import sqrt

while True:
    e = int(input())

    if e == 0: break
    z, ans = 0, e

    while z ** 3 <= e:
        y = int(sqrt(e - z**3))
        x = e - y**2 - z**3
        ans = min(ans, x + y + z)
        z += 1

    print(ans)


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


using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VP vector<pair<int,int>>
#define VPP vector<pair<int,pair<int,int>>>
#define VLL vector<long long>
#define VVI vector<vector<int>>
#define VVLL vector<vector<long long>>
#define VC vector<char>
#define VS vector<string>
#define VVC vector<vector<char>>
#define VB vector<bool>
#define VVB vector<vector<bool>>
#define fore(i,a) for(auto &i:a)
typedef pair <int, int> P;
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;

const int  INF = 1 << 29;
const ll INFL = 1LL << 60;
const ll mod = 998244353;





int main() {


	int n, k;
	cin >> n >> k;

	cout << k + 100 * max(0, 10 - n) << endl;

}




Measured memory_bytes: 256
#include "bits/stdc++.h"
#define FI first.first
#define SE first.second
#define TH second
#define fi first
#define se second
#define th second

using namespace std;

void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef DEBUG
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

class DebugStream {}LOG;
template <typename T>DebugStream &operator<<(DebugStream &s, const T&) { return s; }
#ifdef DEBUG
#define LOG clog
#endif

typedef long long ll;
typedef pair<ll, ll> ii;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());

const int maxN = 50 + 9, maxV = 1e6 + 9, MOD = 1e9 + 7, SQ = 335, lg = 20;

vector<int> adj[maxN];
int as[maxN][maxN], bs[maxN][maxN], cs[maxN], ds[maxN], n, m, s, lmt;
ll dp[maxN][maxN * maxN];

ll& gdp(ii x) {
	return dp[x.fi][x.se];
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	#ifdef DEBUG
	freopen("input.txt", "r", stdin);
	#endif

	cin >> n >> m >> s;
	lmt = n * 50;
	s = min(lmt, s);
	for(int i = 0, u, v, a, b; i < m; i++) {
		cin >> u >> v >> a >> b, u--, v--;
		adj[u].push_back(v);
		adj[v].push_back(u);
		as[u][v] = as[v][u] = a;
		bs[u][v] = bs[v][u] = b;
	}
	for(int i = 0; i < n; i++) cin >> cs[i] >> ds[i];

	for(int i = 0; i < n; i++)
		for(int j = 0; j <= lmt; j++)
			dp[i][j] = -1;
	dp[0][s] = 0;
	auto compare = [&](const ii& a, const ii& b) {
		return gdp(a) < gdp(b) || (gdp(a) == gdp(b) && a < b);
	};
	set<ii, decltype(compare)> mys(compare);
	auto cnsd = [&](ii elm, ll vlu) {
		if(elm.se > lmt) return;
		if(gdp(elm) == -1 || vlu < gdp(elm)) {
			if(vlu < gdp(elm)) mys.erase(elm);
			gdp(elm) = vlu;
			mys.insert(elm);
		}
	};

	mys.insert(ii(0, s));

	while(mys.size()) {
		auto cr = *mys.begin(); mys.erase(mys.begin());
		int nd = cr.fi, silv = cr.se;
		cnsd(ii(nd, silv + cs[nd]), gdp(cr) + ds[nd]);
		for(auto sn: adj[nd])
			if(silv >= as[nd][sn])
				cnsd(ii(sn, silv - as[nd][sn]), gdp(cr) + bs[nd][sn]);
	}

	for(int i = 1; i < n; i++) {
		ll ans = -1;
		for(int j = 0; j <= lmt; j++)
			if(ans == -1 || (dp[i][j] != -1 && dp[i][j] < ans)) ans = dp[i][j];
		cout << ans << '\n';
	}
}



Measured memory_bytes: 8084
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=3005;
int read(){
	int f=1,g=0;
	char ch=getchar();
	for (;!isdigit(ch);ch=getchar()) if (ch=='-') f=-1;
	for (;isdigit(ch);ch=getchar()) g=g*10+ch-'0';
	return f*g;
}
int qpow(int x,int k,int p){
	int t=1;
	for (;k;k>>=1){
		if (k&1) t=(ll)t*x%p;
		x=(ll)x*x%p;
	}
	return t;
}
int n,p,ans,s[N][N],C[N][N];
void check(int &x,int y){if ((x+=y)>=p) x-=p;}
int main(){
	n=read();p=read();
	s[0][0]=C[0][0]=1;
	for (int i=1;i<=n+1;i++){
		C[i][0]=1;
        for (int j=1;j<=i;j++)
        s[i][j]=(s[i-1][j-1]+(ll)s[i-1][j]*j)%p,
        C[i][j]=(C[i-1][j]+C[i-1][j-1])%p;
	}
	for (int i=0;i<=n;i++){
		int r=qpow(2,n-i,p),t=1,sum=0;
		for (int j=0;j<=i;j++){
			sum=(sum+(ll)t*s[i+1][j+1])%p;
			t=(ll)t*r%p;
		}
		sum=(ll)sum*C[n][i]%p*qpow(2,qpow(2,n-i,p-1),p)%p;
		check(ans,(i&1) ? (p-sum) : sum);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 69504
while True:
    x, y = map(int, input().split())
    
    if x==0 and y==0:
        break
    
    if x<y:
        x, y = y, x
    
    count = 0
    while y>0:
        x = x%y
        x, y = y, x
        count += 1
    
    print(x,count)


Measured memory_bytes: 5604
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner input = new Scanner(System.in);
        int n = input.nextInt();
        int[] p = new int[n+1];
        int[][] m = new int[n+1][n+1];
        for(int i = 1; i <= n; i++) {
            p[i-1] = input.nextInt();
            p[i] = input.nextInt();
        }
        matrixChainMultiplication(m, p, n);
        System.out.println(m[1][n]);
    }
    public static void matrixChainMultiplication(int[][] m, int[] p, int n) {
        for(int i = 0; i <=n; i++) { // 初始化，所有(Mi)成本为0
            m[i][i] = 0;
        }
        for(int l = 2; l <= n; l++) { // 对象矩阵的数量
            for(int i = 1; i <= n-l+1; i++) {
                int j = i + l - 1;
                m[i][j] = Integer.MAX_VALUE;
                for(int k = i; k <= j - 1; k++) {
                    m[i][j] = Math.min(m[i][j], m[i][k] + m[k+1][j] + p[i-1]*p[k]*p[j]);
                }
            }
        }
    }
}



Measured memory_bytes: 26404
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

int main() {
    string s;
    cin >> s;
    vector<pair<char, ll>> v;
    v.emplace_back(s[0], 1);
    for (int i = 1; i < s.size(); ++i) {
        if(v.back().first == s[i]){
            v.back().second++;
        }else v.emplace_back(s[i], 1);
    }
    ll ans = 0;
    int l = 0, r = v.size();
    if(v.front().first == '>'){
        ans += (v.front().second+1)*(v.front().second)/2;
        l++;
    }
    if(v.back().first == '<'){
        ans += (v.back().second+1)*(v.back().second)/2;
        r--;
    }
    for (int i = l; i < r; i += 2) {
        ans += max(v[i].second, v[i+1].second);
        ans += (v[i].second-1)*(v[i].second)/2;
        ans += (v[i+1].second-1)*(v[i+1].second)/2;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 6264
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()
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;}
template <typename T> string toString(const T& input) { ostringstream oss; oss << input; return oss.str(); }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k;cin>>k;
    queue<ll> a;
    int cnt = 0;
    rep(i, 9) {
        a.push(i+1);
    }
    ll ans = 0;
    while(true){
        ll t = a.front();
        a.pop(); cnt++;
        if(cnt==k) {
            ans=t; break;
        }
        if(t%10!=0){
            a.push(t*10+(t%10)-1);
        }
        a.push(t*10+(t%10));
        if(t%10!=9){
            a.push(t*10+(t%10)+1);
        }
    }
    cout<<ans<<endl;
}

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

using namespace std;

int main(){

  long long int n;
  cin>>n;
  
  double sqrtNum=sqrt(n);
  vector<long long> cnt(n,0);

  for(int i=1; i<sqrtNum; i++){
    for(int j=1; j<sqrtNum; j++){
      for(int r=1; r<sqrtNum; r++){
        long long int ans=0;
        ans=i*i+j*j+r*r+i*j+j*r+r*i;
        if(ans<=n){
          cnt[ans]++;
        }else{
          break;
        }
      }
    }
  }

  for(int i=1; i<=n; i++){
    cout<<cnt[i]<<endl;
  }
}


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

#define rep(i,n) for (int i = 0; i< (n); ++i)
#define vvec(m,n) vector<vector<int>> (int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()

using ll = long long;

int main(){
    int N,i;
    cin >> N >> i;
    cout << N - (i - 1) << endl;
}

Measured memory_bytes: 256