akhauriyash/Code-Regression huggingface dataset:
from collections import deque

# 頂点数と辺数
N, M = map(int, input().split())
# 辺
AB = [map(int, input().split()) for _ in range(M)]

# 無向グラフの隣接リスト
link = [[] for _ in range(N + 1)]
for a, b in AB:
  link[a].append(b)
  link[b].append(a)
    
# BFSのデータフレーム
dist = [-1] * (N + 1)  # 始点から頂点iの距離
que = deque([1])       # 頂点1を始点としたキュー

# BFS 開始 (キューが空になるまで探索を行う)
while que:
    v = que.popleft() # キューから先頭頂点 v を取り出す
    
    for i in link[v]:
      # 未訪問頂点 i について距離情報を更新してキューに追加する
      if dist[i] == -1:
        dist[i] = v
        que.append(i)

# 結果出力（各頂点の頂点1からの距離）        
print('Yes')
print('\n'.join(str(v) for v in dist[2:]))

Measured memory_bytes: 155196
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
#define str string
#define rep(x,y) for(int i=x;i<y;i++)
#define REP(x,y) for(int j=x;j<y;j++)
#define all(x) x.begin(),x.end()
#define int long long
signed  main(){
  int N,K;
  str S;
  vector<int>A(3);
  cin>>N;
  sort(all(A));
  if(N%2==1)cout<<2*N<<endl;
  else cout<<N<<endl;
}


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

int main()
{
  int N;
  cin >> N;
  vector<long long int> L(N + 1);
  L[0] = 2;
  L[1] = 1;
  for (int i = 2; i <= N; i++)
  {
    L[i] = L[i - 1] + L[i - 2];
  }
  cout << L[N] << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }
#define dump(x) cerr<<#x<<": "<<x<<endl;
#define bit(k) (1LL<<(k))
#define Yes "Yes"
#define No "No"
#define YES "YES"
#define NO "NO"
typedef long long ll;

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

const int INF = (ll)1e9;
const ll INFLL = (ll)1e18+1;
const ll MOD = (ll)1e9+7;
const double PI = acos(-1.0);
/*
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
const string dir = "DRUL";
*/
struct mint {
    long long x;
    mint(long long _x=0):x((_x%MOD+MOD)%MOD){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += MOD-a.x) >= MOD) x -= MOD;
        return *this;
    }
    mint& operator*=(const mint a) {
        (x *= a.x) %= MOD;
        return *this;
    }
    mint operator+(const mint a) const {
        mint res(*this);
        return res+=a;
    }
    mint operator-(const mint a) const {
        mint res(*this);
        return res-=a;
    }
    mint operator*(const mint a) const {
        mint res(*this);
        return res*=a;
    }
    mint modpow(long long t) const {
        if (!t) return 1;
        mint a = modpow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }
    // for prime MOD
    mint inv() const {
        return modpow(MOD-2);
    }
    mint& operator/=(const mint a) {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const {
        mint res(*this);
        return res/=a;
    }
};
struct combination {
    vector<mint> fact, ifact;
    //constructor(initiation)
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < MOD);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint Comb(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
    mint H(int n, int m){
        return Comb(n + m, m);
    }
};

combination Comb(2e5 + 1);

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

    int N,M,K;
    cin>>N>>M>>K;
    mint ans = 0;
     //x座標の差がkになる場合の数
     rep1(d,N){
         ans += mint(d) * mint(N-d) * mint(M) * mint(M) * Comb.Comb(N*M-2, K-2);
     }
     //y座標の差がkになる場合の数
     rep1(d,M){
         ans += mint(d) * mint(M-d) * mint(N) * mint(N) * Comb.Comb(N*M-2, K-2);
     }
     cout<<ans.x<<endl;
}

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

int main(){
    ll n,m,k;
    cin>>n>>m>>k;
    vector<ll> a(n+1,0),b(m+1,0);
    rep(i,n) cin>>a[i+1],a[i+1]+=a[i];
    rep(i,m) cin>>b[i+1],b[i+1]+=b[i];
    ll nowj=m,ans=0;
    rep(i,n+1){
        if(k-a[i]<0) break;
        while(b[nowj]>k-a[i]) nowj--;
        ans=max(ans,i+nowj);
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 6368
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string str = Console.ReadLine();
		for(var i=0;i<str.Length;i++){
			string a = str.Substring(i,1);
			if(a=="?"){
				Console.Write("D");
			} else {
				Console.Write(a);
			}
		}
	}
}

Measured memory_bytes: 21536
import java.util.Scanner;

public class Main{
public static void main(String[] args){
  Scanner sc = new Scanner(System.in);
  int a = sc.nextInt();

  int box[] = new int[a];
  for(int i=0;i<a;i++){
    box[i] = sc.nextInt();
  }
  int m = 1000000007;
  long total = 0;
  long sum = 0;
   
  for(int i=0;i<a;i++){
    sum +=box[i];
    sum %= m;
  }
  
  for(int i=0;i<a;i++){
    sum -= box[i];
    if(sum<0) sum += m;
    
    total += box[i]*sum;
    total %= m;
  }
System.out.println(total);
  
}
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define fi first
#define se second
#define repl(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rep(i,n) repl(i,0,n)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define mmax(x,y) (x>y?x:y)
#define mmin(x,y) (x<y?x:y)
#define maxch(x,y) x=mmax(x,y)
#define minch(x,y) x=mmin(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt __builtin_popcount

#define INF 9e18
#define mod 1000000007

ll n;
ll st;
ll dp[3];

int main(){
  cin>>n>>st;
  dp[0]=st;dp[1]=-INF;dp[2]=-INF;
  rep(i,n-1){
    char c;
    ll a;
    cin>>c>>a;
    ll nxt[3];
    nxt[0]=nxt[1]=nxt[2]=-INF;
    if(c=='+'){
      maxch(nxt[0],dp[0]+a);

      maxch(nxt[1],dp[1]-a);
      maxch(nxt[0],dp[1]+a);

      maxch(nxt[2],dp[2]+a);
      maxch(nxt[1],dp[2]+a);
      maxch(nxt[0],dp[2]+a);
    }else{
      maxch(nxt[0],dp[0]-a);
      maxch(nxt[1],dp[0]-a);

      maxch(nxt[1],dp[1]+a);
      maxch(nxt[0],dp[1]-a);
      maxch(nxt[2],dp[1]+a);

      maxch(nxt[2],dp[2]+a);
      maxch(nxt[1],dp[2]+a);
      maxch(nxt[0],dp[2]+a);
    }
    dp[0]=nxt[0]; dp[1]=nxt[1]; dp[2]=nxt[2];
  }
  cout<<*max_element(dp,dp+3)<<endl;
  return 0;
}


Measured memory_bytes: 384
import qualified Data.ByteString.Char8 as BS
import Data.Char
import Data.List

main = do
  li <- BS.getLine
  let Just (n,_) = BS.readInt li
  li <- BS.getLine
  let as = unfoldr (BS.readInt . BS.dropWhile isSpace) li
  let ans = compute n as
  print ans

compute :: Int -> [Int] -> Int
compute n as
  | q == 0 = amax + 2 * sum (take p as1)
  | True   = amax + 2 * sum (take p as1) + as1 !! p
  where
    (amax:as1) = sortBy (flip compare) as
    (p,q) = divMod (n-2) 2

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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> p_ll;

template<class T>
void debug(T itr1, T itr2) { auto now = itr1; while(now<itr2) { cout << *now << " "; now++; } cout << endl; }
#define repr(i,from,to) for (ll i=(ll)from; i<(ll)to; i++)
#define all(vec) vec.begin(), vec.end()
#define rep(i,N) repr(i,0,N)
#define per(i,N) for (int i=(int)N-1; i>=0; i--)

const ll MOD = pow(10,9)+7;
const ll LLINF = pow(2,61)-1;
const int INF = pow(2,30)-1;

vector<ll> fac;
void c_fac(int x=pow(10,6)+10) { fac.resize(x,true); rep(i,x) fac[i] = i ? (fac[i-1]*i)%MOD : 1; }
ll inv(ll a, ll m=MOD) { ll b = m, x = 1, y = 0; while (b!=0) { int d = a/b; a -= b*d; swap(a,b); x -= y*d; swap(x,y); } return (x+m)%m; }
ll nck(ll n, ll k) { return fac[n]*inv(fac[k]*fac[n-k]%MOD)%MOD; }
ll gcd(ll a, ll b) { if (a<b) swap(a,b); return b==0 ? a : gcd(b, a%b); }
ll lcm(ll a, ll b) { return a/gcd(a,b)*b; }


int main() {
  ll N, X, M; cin >> N >> X >> M;
  vector<ll> idx(M,-1);
  ll px[M*2] = {}; rep(i,M*2) px[i] = i==0 ? X : px[i-1]*px[i-1]%M;

  ll now = X, from = -1, len = -1;
  rep(i,M*2) {
    if (idx[px[i]]==-1) idx[px[i]] = i;
    else { from = idx[px[i]]; len = i - idx[px[i]]; break; }
  }
  // cout << from << " " << len << endl;

  ll st = 0, loopsum = 0, left = 0;
  rep(i,from) st = st+px[i];
  rep(i,len) loopsum = loopsum+px[i+from];
  rep(i,(N-from)%len) left = left+px[i+from];

  ll result = st + loopsum*((N-from)/len) + left;
  cout << result << endl;
  return 0;
}

Measured memory_bytes: 5632
#include <stdio.h>
int main(){
  int m[100][100];
  int n,u,k,v;
  scanf("%d",&n);
  int i,j;
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      m[i][j] = 0;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d %d",&u,&k);
    u--;
    for(j=0;j<k;j++){
      scanf("%d",&v);
      v--;
      m[u][v] = 1;
    }
  }
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      if(j!=0)printf(" ");
      printf("%d",m[i][j]);
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <string>
#include <iostream>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <unordered_map>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD=1e9+7;
int main()
{
	int n, m;
  cin>>n>>m;
  vector<int> l[3][301];
  for(int i=0; i<m; i++){
    int li, ri, x;
    cin>>li>>ri>>x;
    l[x-1][ri].push_back(li);
  }
  for(int i=1; i<=n; i++){
    for(int x=0; x<3; x++){
      sort(l[x][i].begin(), l[x][i].end());
    }
    if((!l[0][i].empty() && !l[1][i].empty() && l[0][i][0]<=l[1][i].back()) || (!l[1][i].empty() && !l[2][i].empty() && l[1][i][0]<=l[2][i].back())){
      cout<<0<<endl;
      return 0;
    }
  }
  ll dp[301][301][301]={};
  dp[1][0][0]=3;
  for(int i=2; i<=n; i++){
    int m0=(l[0][i].empty()?n:l[0][i][0]);
    int M1=(l[1][i].empty()?0:l[1][i].back());
    int m1=(l[1][i].empty()?n:l[1][i][0]);
    int M2=(l[2][i].empty()?0:l[2][i].back());
    if(M1==0 && M2==0){
      dp[i][0][0]=dp[i-1][0][0];
    }
    for(int j=M1; j<min(m0, i); j++){
      for(int k=M2; k<min(m1, j); k++){
        if(j<i-1){
          dp[i][j][k]=dp[i-1][j][k];
        }else{
          if(k==0){
            dp[i][j][k]=(dp[i-1][0][0]*2)%MOD;
            for(int p=1; p<i-1; p++){
              dp[i][j][k]+=dp[i-1][p][0];
              dp[i][j][k]%=MOD;
            }
            continue;
          }
          for(int p=0; p<k; p++){
            dp[i][j][k]+=dp[i-1][k][p];
            dp[i][j][k]%=MOD;
          }
          for(int p=k+1; p<i-1; p++){
            dp[i][j][k]+=dp[i-1][p][k];
            dp[i][j][k]%=MOD;
          }
        }
      }
    }
  }
    ll ans=dp[n][0][0];
    for(int i=0; i<n; i++){
      for(int j=0; j<i; j++){
        ans+=dp[n][i][j];
        ans%=MOD;
      }
    }
    cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 213376
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
long long gcd(long long x, long long y){
    if(y==0) return x;
    else return gcd(y,x%y);
}
//最小公倍数
long long lcm(long long x, long long y){
    return x / gcd(x, y) * y;
}
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int N,X; cin >> N >> X;
    vector<int> m(N);
    int out=N;
    for(int i=0;i<N;i++){
        cin >> m[i];
        X -= m[i];
    }
    sort(m.begin(),m.end());
    out += X/m[0];
    cout << out << endl;
    return 0;
}


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

int main() {
	int N,a;
	double ans, sum = 0;
	vector<int> A;
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> a;
		A.emplace_back(a);
	}
	for (int i = 0; i < N; i++) {
		sum += 1 / (double)A[i];
	}
	ans = 1 / sum;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define dl double
#define ull unsigned long long
#define eps (1e-6)
using namespace std;
const int N = 1e5;
int c[3] = {1, 100, 10000};
int div(int x)
{
    int cnt = 0;
    while(x%100==0)
    {
        x /= 100;
        cnt++;
    }
    return cnt;
}
int main()
{
    int d, n, ans = 0;
    scanf("%d%d", &d, &n);
    while(n--)
    {
        ans += c[d];
        if(div(ans)!=d)
        {
            n++;
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;

int s[111111];
int q,n,t;
int c=0;

int main(){

  scanf(" %d",&n);

  for(int i=0;i<n;i++){
    scanf(" %d",&s[i]);
  }

  scanf(" %d",&q);

  for(int j=0;j<q;j++){
    scanf(" %d",&t);

    //bynary search                                                             
    int l,r,m;
    l=0;
    r=n;

    while(l<r){
      m=(r+l)/2;
      if(s[m]==t){
        c++;
        //cout << t << endl;                                                    
        break;
      }
      if(s[m]>=t){
        r=m;
      }else{
        l=m+1;
      }
    }

  }

  cout << c << endl;

  return 0;

}

Measured memory_bytes: 3524
from sys import stdin
import math
import re
import queue

input = stdin.readline

MOD = 1000000007

def solve():
    S = (input().rstrip())
    if len(S) < 4:
        print("No")
        return
    if(S[:4] == "YAKI"):
        print("Yes")
    else:
        print("No")

if __name__ == '__main__':
    solve()


Measured memory_bytes: 3948
/*
Author: Sagar Gupta
E mail: sagar.june97p@gmail.com
*/

#pragma comment(linker, "/STACK:268435456")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define endl ("\n")
#define deb(n) cerr << #n << " = " << (n) << '\n'
#define PI (3.141592653589)
using ll = long long;
#define ordered_set tree<int, null_type, std::less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define MOD 1000000007

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed;
    cout.precision(10);
    // Those who forgive themselves, and are able to accept their true nature...THEY ARE THE STRONG ONES

    bool yes = true;
    int n;
    cin >> n;
    for(int i = 0;i < n;i++)
    {
        int a;cin >> a;
        if(a % 2 == 0)
        {
            if(a%3 == 0 or a%5 == 0)
            {
                continue;
            }
            yes = false;
        }
    }
    cout << (yes?"APPROVED":"DENIED");
    return 0;
}

Measured memory_bytes: 256
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdio.h>
#define MOD 998244353
int main(int argc, const char * argv[]) {
    int n,s;
    scanf("%d%d",&n,&s);
    long long a[n];
    for(int i=0;i<n;i++){
        scanf("%lld",&a[i]);
    }
    long long dp[n+1][s+1];
    for(int i=0;i<=n;i++){
        for(int j=0;j<=s;j++){
            dp[i][j]=0;
        }
    }
    dp[0][0]=1;
    for(int i=0;i<n;i++){
        for(int j=0;j<=s;j++){
            dp[i+1][j]+=dp[i][j]*2;//Tの部分集合Uに選ばない場合とTに選ばない場合
            dp[i+1][j]%=MOD;
            if(a[i]+j<=s&&dp[i][j]>0){
                dp[i+1][j+a[i]]+=dp[i][j];//Uに選ぶ場合
                dp[i+1][j]%=MOD;
            }
        }
    }
    printf("%lld",dp[n][s]);
    return 0;
}


Measured memory_bytes: 72036
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long
#define ll_MAX LONG_LONG_MAX
#define ll_MIN LONG_LONG_MIN
#define pi pair<int,int>
#define endl "\n"
#define MAXN 100005
#define mod 1000000007
using namespace std;

void solve()
{
    
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	cout.tie(NULL);
    solve();
    ll n,W;
    cin>>n>>W;
    ll w[n], v[n];
    ll maxi = 0;
    for(ll i=0; i<n; i++)
    {
        cin>>w[i]>>v[i];
        maxi += v[i];
    }
    vector< vector<ll> >  dp(2, vector<ll>(maxi + 1, 1e10));
    dp[0][0] = 0;
    dp[0][v[0]] = w[0];
    ll ans = 0;
    if(w[0]<=W)
    {
        ans = v[0];
    }
    for(ll i=1; i < n; i++)
    {   
        ll mask = i&1;
        ll prev = (i-1)&1;
        for(ll j=0; j<=maxi; j++)
        {
            if(j>=v[i])
            {
                dp[mask][j] = min(dp[prev][j - v[i]] + w[i], dp[prev][j]);
            }
            else
            {
                dp[mask][j] = dp[prev][j];
            }
            if( i==(n-1) )
            {
                if( dp[mask][j] <= W)
                {
                    ans = max(ans, j);
                }
            }
        }
    }
    cout<<ans<<'\n';
}

Measured memory_bytes: 5552
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
void Main(){
    ll n;cin>>n;
    vector<ll> a(n),b(n);
    For(i,0,n) cin >> a[i] >> b[i];
    sort(ALL(a));
    sort(ALL(b));
    ll centermin,centermax;
    if(n%2==1){
        centermin=a[n/2];
        centermax=b[n/2];
        ans=centermax-centermin+1;
    }
    else{
        centermin=a[n/2]+a[n/2-1];
        centermax=b[n/2]+b[n/2-1];
        ans=centermax-centermin+1;
    }    
    cout << ans << endl;

}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}


Measured memory_bytes: 6436
#include<stdio.h>
int main(){
char ch[1001];
int i=0;

while(scanf("%c",&ch[i])!=EOF){
if (ch[i]=='C') ch[i]='Z';
else if (ch[i]=='B') ch[i]='Y';
else if (ch[i]=='A') ch[i]='X';
else if (ch[i]<='Z' && ch[i]>='D')ch[i]-=3;
printf("%c",ch[i]);
i++;
}
return 0;
}

Measured memory_bytes: 524
n,a,b = gets.chomp.split.map(&:to_i)
MOD = 10 ** 9 + 7
def mod_pow(base,n,mod)
  if n == 1
    res = base
  elsif n % 2 == 0
    res = mod_pow(base,n/2,mod) ** 2 % mod
  else
    res = mod_pow(base,n-1,mod) * base % mod
  end
  res
end

require 'openssl'
def combination_mod(n,k,mod)
  if n < k || (n < 0 || k < 0)
    0
  elsif k == 0 || k == n
    1
  else
    k = n - k if k > n - k
    x = (n-k+1..n).inject{|res,i| res * i % mod}
    y = (1..k).inject{|res,i| res * i % mod}
    inv_y = OpenSSL::BN.new(y).mod_inverse(mod)
    x * inv_y % mod
  end
end

def mod(a,mod)
  (a % mod + mod) % mod
end

all = mod_pow(2,n,MOD) - 1
puts mod(all - combination_mod(n,a,MOD) - combination_mod(n,b,MOD),MOD)

Measured memory_bytes: 5244
s = input()
n = len(s) - 1

op_list = []

for i in range(2**n):
  op = [""] * n
  for j in range(n):
    if (i >> j) & 1:
      op[j] = "+"
  op_list.append(op)

f_list = []

for op in op_list:
  f = s[0]
  for i in range(n):
    f += op[i]
    f += s[i+1]
  f_list.append(f)

ans = 0

for f in f_list:
  ans += eval(f)

print(ans)

Measured memory_bytes: 3064
#define FNAME ""
 
#include <iostream>
#include <cstdio>
#include <ctime>
#include <cassert>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cstdlib>
#include <cstring>
#include <string>
 
#define hash padjf9srpi
#define y0 sdkfaslhagaklsldk
#define y1 aasdfasdfasdf
#define yn askfhwqriuperikldjk
#define j1 assdgsdgasghsf
#define tm sdfjahlfasfh
#define lr asgasgash
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define forn(i, n) for (int i = 0; i < (n); i++)
#define fornr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define forab(i, a, b) for (int i = (a); i < (b); i++)
#define gcd __gcd
#define all(a) (a).begin(), (a).end()
 
#ifdef _WIN32
    #define I64 "%I64d"
#else
    #define I64 "%lld"
#endif
 
using namespace std;
 
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair <int, int> pii;                                                                                                                                                                                      
typedef vector <int> vi;
 
template <class T> T sqr(const T &a) {return a * a;}
const int M = 1e6;
int a[M];

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
 
#ifdef LOCAL
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif

    int n;
    string s;
    cin >> n >> s;

    s = s + s;

    for (int i1 = 0; i1 < 2; i1++) {
        for (int i2 = 0; i2 < 2; i2++) {
            a[0] = i1;
            a[1] = i2;
            for (int i = 2; i <= n + 1; i++) {
                if (s[i - 1] == 'o' && a[i - 1] == 0) a[i] = 1 - a[i - 2];
                if (s[i - 1] == 'o' && a[i - 1] == 1) a[i] = a[i - 2];
                if (s[i - 1] == 'x' && a[i - 1] == 0) a[i] = a[i - 2];
                if (s[i - 1] == 'x' && a[i - 1] == 1) a[i] = 1 - a[i - 2];
            }
            if (a[n] == a[0] && a[n + 1] == a[1]) {
                for (int i = 0; i < n; i++) {
                    cout << (a[i] ? "S" : "W");
                }
                return 0;
            }
        }
    }
    cout << -1;
    return 0;
    
    
    return 0;
}

Measured memory_bytes: 1004
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    string a, b;
    cin >> a;
    cin >> b;
    ll k=a.size();
    ll l=b.size();
    ll c=0,i;
    if(k==l)
    {
        for(i=0;i<k;i++)
        {
            if(a[i]!=b[i])
                c++;
        }
    }
    cout << c;
    cout << endl;

}


Measured memory_bytes: 3832
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt(),B = sc.nextInt();
		if(A % 3 == 0 || B % 3 == 0 || (A+B) % 3 == 0) System.out.println("Possible");
		else System.out.println("Impossible");
	}
}


Measured memory_bytes: 21204
#ifdef DEBUG

#else

#    pragma GCC optimize("O3,no-stack-protector")
#    pragma GCC optimize("unroll-loops")

#    if __cplusplus >= 201703L
#        pragma GCC target("avx2")
#    else
#        pragma GCC target("avx")
#    endif

#endif
// 実数の場合
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

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

    Int n, d, x;
    cin >> n >> d >> x;
    vector<Int> a(n);
    for (Int i = 0; i < n; i++) {
        cin >> a[i];
    }

    Int ans = x + n;
    d--;
    for (Int i = 0; i < n; i++) {
        ans += d / a[i];
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
import sys
from collections import deque

inf = 1<<30

def solve():
    n = int(input())
    Adj = [None] * n

    for i in range(n):
        u, k, *line = [int(i) - 1 for i in input().split()]
        Adj[u] = line

    d = bfs(n, Adj)

    for i, di in enumerate(d, start=1):
        if di == inf:
            print(i, -1)
        else:
            print(i, di)

def bfs(n, Adj):
    d = [inf] * n
    d[0] = 0
    nxts = deque([0])

    while nxts:
        u = nxts.popleft()

        for v in Adj[u]:
            if d[v] == inf:
                d[v] = d[u] + 1
                nxts.append(v)

    return d

if __name__ == '__main__':
    solve()

Measured memory_bytes: 8048
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep1(i, n) for(int i = 1; i < n+1; i++)
#define all(A) A.begin(),A.end()
typedef long long ll;

int main(){
  
  int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  sort(all(a));
  int maxValue = a[n-1];//配列の最大値を取得
  
  vector<bool> b(maxValue+1,1);//カウントするかどうかのbool配列
  
  map<int,int> c;//重複をチェックするためのmap
  rep(i,n) c[a[i]]++;
  
  rep(i,n){
    int now = a[i];
    if(b[now] == 0) continue;//カウントなしであればスルー
    for(int j=now*2;j<=maxValue;j+=now){//後続の約数をカウントなしにしていく
      b[j] = 0;
    }
  }
  
  int ans = 0;//集計開始
  rep(i,n){
    int now = a[i];
    if(c[now]>1) continue;//重複していればスルー
    ans += b[now];
  }
  cout << ans << endl;
}


Measured memory_bytes: 13464
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
	int n;cin>>n;
	vector<int> l(n);
	for(int i=0;i<n;i++)cin>>l[i];
	int ans=0;
	sort(l.begin(),l.end(),greater<int>());
	for(int i=0;i<n;++i)
	{
		for(int j=i+1;j<n;++j)
		{
			for(int k=j+1;k<n;++k){
				if(l[i]<(l[j]+l[k]))ans++;
				else break;
				//cout<<l[i]<<l[j]<<l[k]<<endl;
			}
		}
	}
	cout<<ans<<endl;
   return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m;i<n;i++)
#define c(n) cin>>n
#define c2(n,m) cin>>n>>m
#define c3(n,m,k) cin>>n>>m>>k
#define c4(n,m,k,l) cin>>n>>m>>k>>l
#define co(n) cout<<n<<endl
using namespace std;

int main(){
  long a=0,b,c=0,d=0,e,n;
  c2(a,b);
  char s[a][b];
  string ans="Possible";
  rep(i,0,a) rep(j,0,b) c(s[i][j]);
  s[c][d]='.';
  
  while(1){
    if(c<a && s[c+1][d]=='#' && d<b && s[c][d+1]=='#'){
      ans="Impossible";
      break;
    }
    
    else if(c>0 && s[c-1][d]=='#'){
      ans="Impossible";
      break;
    }
    else if(d>0 && s[c][d-1]=='#'){
      ans="Impossible";
      break;
    }
    else if(c<a && s[c+1][d]=='#'){
      c++;
      s[c][d]='.';
      continue;
    }
    else if(d<b && s[c][d+1]=='#'){
      d++;
      s[c][d]='.';
      continue;
    }
    if(c==a-1 && d==b-1) break;
    
  }
  co(ans);
    
  return 0;
}


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

int main() {
  int r, D, x;
  cin >> r >> D >> x;
  vector<int> vec(12);
  vec.at(0) = x;
  for (int i = 0; i < 11; i++) {
    vec.at(i + 1) = r * vec.at(i) - D;
  } 
  for (int i = 0; i < 10; i++) {
    cout << vec.at(i + 1) << endl;
  }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e18
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

signed main()
{
    int n,m;
    cin>>n>>m;
    vector<bool>a(10,false);
    vector<int>d(10,0);
    REP(i,m) {
        int s,c;
        cin>>s>>c;
        s--;
        if(!a[s]){
            a[s]=true;
            d[s]=c;
        }
        else{
            if(d[s] !=c){
            cout<<-1<<endl;
            return 0;
            }
        }
    }
    if(n==1){
        cout<<d[0]<<endl;
        return 0;
    }
    for (int i = 0; i < n; i++)
    {
        if(i==0){
            if(!a[i]) cout<<1;
            else if(d[i]==0){
                cout<<-1<<endl;
                return 0;
            }
            else {
                cout<<d[i];   
            }
        }
        else{
            if(!a[i]) cout<<0;
            else cout<<d[i];
        }
    }
    cout<<endl;
   
    return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
A_li = list(map(int,input().split()))
cnt = 0
lim = (1 / (4*M)) * sum(A_li)
for i in A_li:
    if i >= lim:
        cnt += 1
if cnt >= M:
    print("Yes")
else:
    print("No")



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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll  = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main() {
    int n, m;
    cin >> n >> m;
    vll                   p(m), y(m);
    vector<pair<pll, ll>> city;

    rep(i, m) {
        cin >> p[i] >> y[i];
        // 年 県 添字
        city.push_back(make_pair(make_pair(y[i], p[i]), i));
    }
    // ソート
    sort(all(city));
    vll num(m), cnt(n + 1);
    rep(i, city.size()) {
        // 県をカウント
        cnt[city[i].first.second]++;
        // 県を添え字に入れる
        num[city[i].second] = cnt[city[i].first.second];
    }

    rep(i, m) {
        cout << setfill('0') << setw(6) << p[i];
        cout << setfill('0') << setw(6) << num[i];
        cout << endl;
    }
    return 0;
}


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

int main(){
  int n,r;
  cin >> n >> r;
  if(n<10)
    cout << r + 100*(10-n) << endl;
  else
    cout << r;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <math.h>

using namespace std;

int main() {
	int n;
	bool res = false;
	cin >> n;
	for (int i = 0; i <= n / 4; i++) {
		for (int j = 0; j <= n / 7; j++) {
			if (i * 4 + j * 7 == n) {
				res = true;
			}
		}
	}
	if (res) {
		cout << "Yes" << endl;
	}
	else
	{
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
n = int(input())
TXY = [(0, 0, 0)]
for i in range(n):
	TXY.append(tuple(map(int, input().split())))
for (t1, x1, y1), (t2, x2, y2) in zip(TXY, TXY[1:]):
	dist = abs(x2 - x1) + abs(y2 - y1)
	d = t2 - t1
	flag = False
	for t in range(d, -1, -2):
		if t == dist:
			flag = True
			break
	if flag == False:
		print("No")
		exit()
else:
	print("Yes")

Measured memory_bytes: 62552
import sys

sys.setrecursionlimit(10 ** 8)
ini = lambda: int(sys.stdin.readline())
inm = lambda: map(int, sys.stdin.readline().split())
inl = lambda: list(inm())
ins = lambda: sys.stdin.readline().rstrip()
debug = lambda *a, **kw: print("\033[33m", *a, "\033[0m", **dict(file=sys.stderr, **kw))

s = ins()


def solve():
    ss = set(s)
    ans = 10000
    ach = None
    for c in range(26):
        ch = chr(ord("a") + c)
        if ch not in ss:
            continue
        msk = sk = 0
        for i, x in enumerate(s):
            if x == ch:
                if msk < sk:
                    msk = sk
                sk = 0
            else:
                sk += 1
        if msk < sk:
            msk = sk
        if ans > msk:
            ans = msk
            ach = ch

    return ans


print(solve())


Measured memory_bytes: 8964
#include <iostream>
  #include <string>
  #include <vector>
  #include <algorithm>
  #include <utility>
  using namespace std;
  typedef long long ll;
  #define rep(i,n) for (int i=0;i < (int)(n);i++)
  
  
  int main(){
    int x,y;
    bool can = false;
    cin >> x >> y;
    for (int i = 0; i <= x; i++){
      for (int j = 0; j <= x; j++){
        if (2*i + 4*j == y && i + j == x){
          can = true;
        }
      }
    }
    if (can) cout << "Yes" << endl;
    else cout << "No" << endl;
    
      

    
    return 0;
  }


Measured memory_bytes: 3648
#include <bits/stdc++.h>
 
#define TRACE(x) cerr << #x << " = " << x << endl
#define pb push_back
#define mp make_pair
#define fi first
#define se second
 
#define SZ(x) (int)(x).size()
 
using namespace std;
 
typedef unsigned long long ll;
typedef pair<int, int> pii;
 
template<class Num>
Num mabs(Num A){
  if(A < 0) return -A;
  return A;
}

const int N = 2005, mod = 1e9 + 7;

inline int add(int a, int b){
  int ret = a + b;
  if(ret >= mod) ret -= mod;
  return ret;
}

int S;
int c[N];

int main(){
  scanf("%d", &S);
  
  if(S < 3){
    printf("0\n");
    return 0;
  }
  
  c[0] = 1;
  for(int i = 3; i <= S; i++){
    for(int j = 3; j <= i; j++)
      c[i] = add(c[i], c[i - j]);
  }

  printf("%d\n", c[S]);
  
  return 0;
}


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

int main(void){
    int n;
    cin >> n;
    int x[n];
    for(int i = 0;i < n;i++)cin >> x[i];
    sort(x,x+n,greater<int>());
    long long sum[x[0]+1];
    for(int i = 0;i <= x[0];i++){
        sum[i] = 0;
        for(int j = 0;j < n;j++){
            sum[i] += ((x[j]-i)*(x[j]-i));
        }
    }
    sort(sum,sum+x[0]+1);
    cout << sum[0] << endl;
}

Measured memory_bytes: 256
def insertionSort(A, n, g, cnt):
    for i in range(g,n):
        v = A[i]
        j = i - g
        while j >= 0 and A[j] > v:
            A[j+g] = A[j]
            j = j - g
            cnt += 1
        A[j+g] = v
        
    return cnt

def shellSort(A, n):
    cnt_s = 0
    k = 0
    G = []
    while k <= n:
        k = 3*k + 1
        if k <= n:
            G.append(k)
    G.reverse()
    m = len(G)
    for i in range(m):
        cnt_s = insertionSort(A, n, G[i], cnt_s)

    return A, m, G, cnt_s

n = int(input())
A = [0]*n

for i in range(n):
    A[i] = int(input())

A_out, m, G, cnt_out = shellSort(A, n)

G_str = list(map(str,G))
print(str(m))
print(" ".join(G_str))
print(str(cnt_out))
for i in range(n):
    print(str(A_out[i]))


Measured memory_bytes: 45480
#include <stdio.h>

int main(void)
{
  char b;
  scanf("%c",&b);

  if(b == 'A') {
    printf("T\n");
  } else if(b == 'C') {
    printf("G\n");
  } else if(b == 'G') {
    printf("C\n");
  } else if(b == 'T') {
    printf("A\n");
  }

  return 0;
}


Measured memory_bytes: 128
# -*- coding: utf-8 -*-
import sys 
from itertools import accumulate
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
N, K = map(int, readline().split())
P = [0] + list(map(int,readline().split()))
C = [0] + list(map(int,readline().split()))

ans = -10 ** 10
for i in range(1,N+1):
    l = 1
    j = P[i]
    s = C[j]
    ans = max(ans, s) #iを始まりとして
    while j != i:     # 1周期もしないときの最大値
        j = P[j]
        s += C[j]
        l += 1
        if K >= l:
            ans = max(ans, s)
    
    c = 1
    j = P[j]
    t = C[j]
    ans = max(ans, t + ((K - c) // l) * s) # 1回と周期分
    
    while j != i:
        j = P[j]
        t += C[j]
        c += 1
        if K >= c:
            ans = max(ans, t + ((K - c) // l) * s) # c回と周期分
print(ans)

Measured memory_bytes: 74284
#include <bits/stdc++.h> 
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x,y,z) max((x),max((y),(z)))
#define tmin(x,y,z) min((x),min((y),(z)))
typedef long long ll;ll MM = 1000000000;ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y) {if (y == 0) return x;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x / GCD(x, y) * y;}
//cout << fixed << setprecision(10);

int main(){
  ll n,t,ans; cin>>n>>t;
  ans=t;
  rep(i,n-1){
   cin>>t;
    ans=LCM(ans,t);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<algorithm>
using namespace std;
int gcd(int x,int y)
{
    return x%y==0?y:gcd(y,x%y);
}
int main()
{
    int n,k,i,j,x,flag,t;
    scanf("%d%d",&n,&k);
    flag=0;
        scanf("%d",&x);
        if(x==k)
            flag=1;
            j=x;
            t=x;
        for(i=1;i<n;i++)
        {
            scanf("%d",&x);
            if(x==k)
                flag=1;
            j=gcd(j,x);
            t=max(t,x);
        }
        if(k%j==0&&t>=k)
            flag=1;
        if(flag)
            printf("POSSIBLE\n");
        else
            printf("IMPOSSIBLE\n");
        return 0;
}


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

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<< #str << " " str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7



int main()
{
	stack<char> st;
	string x;
	cin >> x;

	for (char c : x) {
		if (st.empty() || st.top() != 'S' || c != 'T')st.push(c);
		else st.pop();
	}
	cout << st.size() << endl;

	return 0;
}


Measured memory_bytes: 644
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG_ 
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

// -80*159 が最小 
constexpr ll m = 160*159+1;
bool dp[80][80][m];
int main(void) {
    ll h, w;
    cin >> h >> w;
    vector<vector<ll>> a(h, vector<ll>(w)), b(h, vector<ll>(w));
    REP(i, h) REP(j, w) cin >> a[i][j];
    REP(i, h) REP(j, w) cin >> b[i][j];

    vector<vector<ll>> d(h, vector<ll>(w));
    REP(i, h) REP(j, w) d[i][j] = a[i][j] - b[i][j];

    ll p = 80*159;
    dp[0][0][p+d[0][0]] = dp[0][0][p-d[0][0]] = true;
    REP(i, h) REP(j, w) REP(k, m) {
        if(!dp[i][j][k]) continue;
        if(i+1<h) {
            dp[i+1][j][k+d[i+1][j]] = true;
            dp[i+1][j][k-d[i+1][j]] = true;
        }
        if(j+1<w) {
            dp[i][j+1][k+d[i][j+1]] = true;
            dp[i][j+1][k-d[i][j+1]] = true;
        }
    }

    ll ret = INF;
    REP(i, m) if(dp[h-1][w-1][i]) chmin(ret, abs(i-p));
    cout << ret << endl;

    return 0;
}

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

int main(){
  int N, M;
  cin >> N >> M;
  const int NMMAX = 50;
  int A[NMMAX], B[NMMAX];//A,Bの配列には、A[i](B[i])番目に入っている都市から一本道路が伸びているという情報が入ってる
  
  
  for(int i = 0; i < M ;i++){ //道路の本数ぶんなのでM
    cin >> A[i] >> B[i]; //A,Bに入力 
  }
  
  int road[NMMAX];//各都市から何本の道路が伸びているかの配列を用意。
  for(int i = 0; i < N; i++){ 
    road[i] =0; //i番目の都市からはこの時点では0本伸びている。A,Bを参照して足していく
  }
  for(int i = 0; i < M; i++){
    road[A[i]-1] += 1; //Aの配列に入っている、i番目の都市から1本生えている情報を足す。
    //Aの配列に入っているi番目の都市から生えている、ということは配列のi-1番目に入れるべき（0スタート。Nは1から数えている)
    road[B[i]-1] += 1; //一本伸びてるよ情報をroad配列に加える    
  }
  
  for(int i = 0; i < N; i++){
    cout << road[i] << endl; //i番目の都市からは道路がroad[i]本伸びている。 
  }
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
		int a = scn.nextInt();
      	int b = scn.nextInt();
      	if((b-a)%2==0) System.out.println("Alice");
      	else System.out.println("Borys");
	}
}

Measured memory_bytes: 35704
N,X = list(map(int,input().split()))
a = list(map(int,input().split()))
ans = 0
for i in range(N-1):
    if X < a[i]:
        ans += a[i]-X
        a[i] = X
        
    if X < a[i]+a[i+1]:
        ans += a[i]+a[i+1]-X
        a[i+1] = X-a[i]
print(ans)

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

#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
// #define int long long
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using ul = unsigned long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { return a * b / GCD(a, b); }

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

inline bool inside(int y, int x, int H, int W) {
    return (y >= 0 && x >= 0 && y < H && x < W);
}

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

ll N;
ll ans;

void dfs(ll x, int use){
  if(x > N) return;
  if(use == 0b111) ans++;
  if(x <= N){
    dfs(10*x+7, use|0b100);
    dfs(10*x+5, use|0b010);
    dfs(10*x+3, use|0b001);
  }
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  cin>>N;
  dfs(0, 0b000);
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int h[30];
    for(int i = 0;i < n;i++)cin >> h[i];
    int cnt = 0;
    int ma = 0;
    for(int i = 0;i < n;i++){
        if(ma <= h[i])cnt++,ma = h[i];
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    int A,B;
    scanf("%d %d",&A,&B);
    if(B==1){
        printf("0");
        return 0;
    }
    B = B-A;
    int count=1;
    while(B>0){
        B = B-A+1;
        count ++;
    }
    printf("%d",count);
    return 0;
}

Measured memory_bytes: 128
from math import factorial as F
def comInit(mx=510000, mod=pow(10,9)+7):
    fac = [0]*mx
    finv = [0]*mx
    inv = [0]*mx
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2,mx):
        fac[i] = fac[i-1]*i%mod
        inv[i] = mod - inv[mod%i]*(mod//i)%mod
        finv[i] = finv[i-1]*inv[i]%mod
    return fac, finv

def com(fac, finv, n, k):
    if n<k: return 0
    if (n<0 or k<0): return 0
    return fac[n] * (finv[k]*finv[n-k]%mod)%mod

x, y = map(int, input().split())
mod = pow(10,9)+7
if (x+y)%3!=0:
    print(0)
else:
    w = (2*y-x)//3
    h = (2*x-y)//3
    if w<0 or h<0:
        print(0)
    else:
        fac, finv = comInit(w+h+1)
        print(com(fac, finv, w+h,w))

Measured memory_bytes: 87900
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;


#define LETS_GET_SCHWIFTY ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);  
#define ff              first
#define ss              second
#define int             long long
#define ll              long long
#define pb              push_back
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)      __builtin_ctzll(x)
#define mod             998244353
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define vpii            vector<pair<int,int> >
#define all(x)          x.begin(),x.end()
#define matrixprint(arr,a,b,c,d) for(int i=a;i<=c;i++){for(int j=b;j<=d;j++){cout<<arr[i][j]<<" ";}cout<<"\n";}
#define show(arr,x,y)   for(int i=x;i<=y;i++){cout<<arr[i]<<" ";}cout<<"\n"
#define sz(x)           (int)x.size()
#define db(x)           cout<<x<<"\n";

const int N = 2e5 + 5;

#define TRACE
#ifdef TRACE
#define deb(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1) {
    cout << name << " : " << arg1 << std::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 deb(...)
#endif

	
//////////////////////////////code//////////////////////////////

void solve()
{
  //  cout << "-------------------" << "\n";
     
  int n,d;
  cin>>n>>d;
  int cnt=0;
 
  for(int i=0;i<n;i++)
  {
      int u,v;
      cin>>u>>v;
      
      long double dis = sqrt(pow(( long double)u,2)+pow(( long double)v,2));
      
      if(dis<=(long double)d)
      cnt++;
  }
  
  db(cnt)

  //  cout << "-------------------" << "\n";

}

int32_t main()
{

    LETS_GET_SCHWIFTY;

    int t = 1;
    //cin >> t;

    while (t--)
        solve();

}

// check out for following mistakes-
// if using pb operation on vector and then trying to access index..check if sizeof that vec could remain 0 only
// is using prime sieve make sure it fits
// when using factorial template or combinatorics make sure that you edit fillfac fun values and array values


Measured memory_bytes: 3668
N = int(input())

ans = 0
for i in range(1, N + 1):
    res = 0
    for q in range(1, N + 1):
        if i % 2 != 0:
            if i % q == 0:
                res += 1
    if res == 8:
        ans += 1

print(ans)

Measured memory_bytes: 2940