akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define INF 1e9
using namespace std;

#define REPR(i,n) for(int i=(n); i >= 0; --i)
#define FOR(i, m, n) for(int i = (m); i < (n); ++i)
#define REP(i, n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(a)  (a).begin(),(a).end()
#define endl "\n"

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

void solve() {
    int N,M;
    cin >> N >> M;
    vector<int> h(N);
    vector<priority_queue<int>> vp(N,priority_queue<int>());
    REP(i,N) cin >> h[i];

    REP(i,M) {
        int A,B;
        cin >> A >> B;
        A--; B--;
        vp[A].push(h[B]);
        vp[B].push(h[A]);
    }

    int cnt=0;
    REP(i,N) {
        if (vp[i].empty() || vp[i].top() < h[i]) cnt++;
    }

    cout << cnt << endl;

}

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


Measured memory_bytes: 9592
{-# LANGUAGE BangPatterns #-}
import Control.Arrow
import Control.Monad.Fix
import Data.Char
import Data.Int
import Data.Foldable
import Data.List
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B

solve :: B.ByteString -> String
solve !s = if B.count 'x' s <= 7 then "YES" else "NO"

main = do
  let readInt :: Integral a => B.ByteString -> Maybe (a, B.ByteString)
      readInt = fmap (first fromIntegral . second B.tail) . B.readInt

  s <- B.getLine
  putStrLn $ solve s


Measured memory_bytes: 380
#include<stdio.h>
#include<math.h>
int main(void) {
	long long int i, X, kane = 100;
	
	scanf("%lld", &X);
	
	
		for (i = 0; X>kane; i++) {
			kane = kane+kane/100;
		}
	
		
	
		
	printf("%lld\n", i);

	return 0;
}

Measured memory_bytes: 2152
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define mod ((int)1e9+7)
#define lim 1000000000000000007
#define lim1 18446744073709551615  //Unsigned
#define sq(a) ((a)*(a))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mms(v,i) memset(v,i,sizeof(v))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REPN(i,a,b) for (int i = a; i >= b; i--)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> PL;
typedef pair<ll,int> PLI;
typedef pair<int,ll> PIL;
typedef pair<int,pair<int,int> > pii;
typedef pair<double,double> pdd;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a,ll b) {
   ll res=1;
   while(b){
      if(b%2==1) res=(res*a)%mod;
      a=(a*a)%mod;
      b>>=1;
   }
   return res;
}
ll gcdll(ll a,ll b) {
    if (b==0) return a;
    return gcdll(b,a%b);
}
int gcd(int a,int b) {
    if (b==0) return a;
    return gcd(b,a%b);
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

const int N = (int)1e5+5;
const int M = (int)3e3+5;
const int Q = 401;
const int logN = 19;

ll dp[Q][Q], a[N], sum[N];
ll solve1(int l,int r) {
    if(l==r) return 0;
    else if(l==r-1) return a[l]+a[r];
    else if(dp[l][r]) return dp[l][r];
    dp[l][r] = lim;
    REP(i,l,r-1) {
        dp[l][r] = min(dp[l][r],solve1(l,i)+solve1(i+1,r)+sum[r]-sum[l-1]);
    }
    return dp[l][r];
}
void solve() {
    int n;
    cin>>n;
    REP(i,1,n) {
        cin>>a[i];
        sum[i] = a[i] + sum[i-1];
    }
    cout<<solve1(1,n);
}
int main() {
    //freopen("output.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int T=1;
    //cin>>T;
    REP(TC,1,T) {
        //cout<<"Case #"<<TC<<": ";
        solve();
        cout<<"\n";
    }
}


Measured memory_bytes: 1536
#include<bits/stdc++.h>
const int N=55;
typedef long long ll;
int n,a[N],b[N],c[N],xb,oxb,i,j;
ll ans,f[N];
bool check(){
	int i,j,k;
	memset(f,0,sizeof f);
	for(i=0;i<=50;++i)
		for(j=1,f[i]=1ll<<i;j<=xb;++j)
			f[i]|=f[i%c[j]];
	for(i=1;i<=n;++i)if(!(f[a[i]]>>b[i]&1))return 0;
	return 1;
}
int main(){
	scanf("%d",&n);
	for(i=1;i<=n;++i)scanf("%d",a+i);
	for(i=1;i<=n;++i){
		scanf("%d",b+i);
		if(b[i]*2>=a[i] && b[i]!=a[i])return puts("-1"),0;
	}
	for(i=50;i;--i){
		oxb=xb;
		for(j=1;j<i;++j)c[++xb]=j;
		if(!check())xb=oxb,c[++xb]=i;else xb=oxb;
	}
	for(i=1;i<=xb;++i)ans+=1ll<<c[i];
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <deque>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <iomanip>
#include <bitset>
#include <set>
#include <map>
#include <stdio.h>

#define rep(i,n) for (int i = 0; i < (n); i++)
#define FOR(i,a,b) for (int i=(a); i < (b); i++)
#define INF 100000000000
#define MOD 1000000007 //10^9+7
using namespace std;
using ll = long long;
using P = pair<int, int>;

// 負の数にも対応した % 演算
long long mod(long long val, long long m) {
    long long res = val % m;
    if (res < 0) res += m;
    return res;
}

int main()
{
    int n,m;
    cin >> n >> m;
    vector<int> a(n,0);
    rep(i,m*2) {
        int tmp;
        cin >> tmp;
        tmp--;
        a[tmp]++;
    }
    rep(i,n)
        cout << a[i] << endl;

    return 0;
}


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

using namespace std;

int main(){
	int N;
	cin >> N;
	int a[N];
	for(int i = 0; i < N; i++){
		cin >> a[i];
	}
	int cnt = 0;
	while(true){
		int flag = 1;
		for(int i = 0; i < N; i++){
			if(a[i]%2==0){
				a[i] /= 2;
			}
			else{
				flag = 0;
				break;
			}
		}
		if(flag == 0){
			break;
		}
		cnt++;
	}
	cout << cnt << "\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
using namespace std;
int a;
string s;
int main()
{
	cin >> s;
	int i, j;
	for(i = 0; s[i] != 'A'; i++);
	for(j = s.size() - 1; s[j] != 'Z'; j--);
	cout << j - i + 1;
    return 0;
}


Measured memory_bytes: 640
import sys


N = int(input())
PRICE_CAKE = 4
PRICE_DOUGHNUT = 7

for i in range(0, int(N / 4) + 1):
    for j in range(0, int(N / 7) + 1):
        if PRICE_CAKE * i + PRICE_DOUGHNUT * j == N:
            print('Yes')
            sys.exit()
print('No')


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxn = 1e5 + 5;
const int mod = 1e9 + 7;

int n, m;
int vis[maxn];
int dp[maxn];

int main()
{
   ios::sync_with_stdio(false); cin.tie(0);cout.tie(0);
   cin >> n >> m;
   for(int i = 0 ; i < m; i++) {
        int tmp;
        cin >> tmp;
        vis[tmp]++;
   }
   dp[0] = 1;
   if(!vis[1]) dp[1] = 1;
   for(int i = 2 ; i <= n ; i++){
        if(!vis[i - 2]) dp[i] = (dp[i] + dp[i-2])%mod;
        if(!vis[i - 1]) dp[i] = (dp[i] + dp[i-1])%mod;
   }
   cout << dp[n] << endl;
   return 0;
}

Measured memory_bytes: 1024
N = int(input())
S =list(input())
ans = N
W = 0
E = S.count('E')

for i in range(N):
    if S[i] =='E':
        E -= 1
    ans = min(ans, W+E)
    if S[i] == 'W':
        W += 1
print(ans)

Measured memory_bytes: 86308
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <cmath>
typedef long long ll;
using namespace std;

int main(){
  int N;
  cin >> N;
  int ans = 1;
  while(ans*ans <= N){
    ans++;
  }
  ans--;
  cout << ans*ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)

using namespace std;

int main() {
   int n;
   cin >> n;
   cout << (double)(n-n/2)/n << endl;
}

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

total = 0
lst = []
for i in range(1, N + 1):
    total += abs(A[i]-A[i-1])
    lst += [abs(A[i+1]-A[i-1])-(abs(A[i-1]-A[i])+abs(A[i]-A[i+1]))]
total += abs(A[N]-A[N+1])
# print (total)
# print (lst)
for i in range(N):
    print (total+lst[i])

Measured memory_bytes: 14068
#!/usr/bin/env python3
import sys


input = sys.stdin.readline
def IS(cb): return cb(input().strip())
def IL(cb): return [cb(s) for s in input().strip().split()]
def IR(cb, rows): return [IS(cb) for _ in range(rows)]
def ILL(cb, rows): return [IL(cb) for _ in range(rows)]


def solve():
    X, Y = IL(int)
    ans = 1
    while Y // 2 >= X:
        ans += 1
        Y //= 2
    print(ans)

solve()


Measured memory_bytes: 3060
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		
		if((A==5&&B==5) && (C==7)){
			System.out.println("YES");
		}
		
		else if((A==5&&C==5) &&(B==7)){
			System.out.println("YES");
		}
		
		else if((B==5&&C==5) && (A==7)){
			System.out.println("YES");
		}
		
		else {
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 21844
#include<bits/stdc++.h>
#define ll long long
#define pii_ pair<int,int>
#define mp_ make_pair
#define pb push_back
#define fi first
#define se second
#define rep(i,a,b) for(int i=(a);i<=(b);i++)
#define per(i,a,b) for(int i=(a);i>=(b);i--)
#define show1(a) cout<<#a<<" = "<<a<<endl
#define show2(a,b) cout<<#a<<" = "<<a<<"; "<<#b<<" = "<<b<<endl
using namespace std;
const ll INF = 1LL<<60;
const int inf = 1<<30;
const int maxn = 2e5+5;
inline void fastio() {ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);}



int main()
{
    fastio();
    int a,b,c,k,ans=0; cin>>a>>b>>c>>k;
    while(b<=a) b*=2,ans++;
    while(c<=b) c*=2,ans++;
    if(k>=ans) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using namespace std;
using ll = long long ;
using P = pair<int,int> ;
using pll = pair<long long,long long>;
constexpr int INF = 1e9;
constexpr long long LINF = 1e17;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;

struct Sieve {
    int n;
    vector<int> f,primes;
    
    Sieve(int n=1):n(n),f(n+1){
        f[0] = f[1] = -1;
        for(long long i=2;i<=n;++i){
            if(f[i]) continue;
            primes.push_back(i);
            f[i] = i;
            for(long long j = i*i;j <= n;j += i) {
                if(!f[j]) f[j] = i;
            }
        }
    }
    
    bool isPrime(int x){return f[x] == x;}
    
    vector<int> factorList(int x){
        vector<int> res;
        while(x != 1){
            res.push_back(f[x]);
            x /= f[x];
        }
        return res;
    }
    
    vector<pair<int,int>> factor(int x){
        vector<int> fl = factorList(x);
        if(fl.size() == 0) return {};
        vector<pair<int,int>> res(1,pair<int,int>(fl[0],0));
        for(int p:fl){
            if(res.back().first == p){
                res.back().second ++;
            }else{
                res.emplace_back(p,1);
            }
        }
        return res;
    }

    long long divisorCalc(long long x){
        long long res = 1;
        long long now = -1;
        long long nowCnt = 0;
        while(x != 1){
            if(now==f[x]) ++ nowCnt;
            else{
                res *= nowCnt + 1;
                now = f[x];
                nowCnt = 1;
            }
            x /= f[x];
        }
        res *= nowCnt+1;
        return res;
    }     
};

int main(){
    int N; cin >> N;
    Sieve siv(N + 1);
    ll ans = 0;
    rep(i,N) {
        ans += (ll)(i + 1)*(ll)siv.divisorCalc(i + 1);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 46440
a,b,k=map(int, input().split())
while True:
  if k< 1:
    break
  if a %2==1:
    a=a-1
  c = a // 2
  a = c
  b = b + c
  k=k-1
  if k<1:
    break
  if b %2==1:
    b=b-1
  b = b//2
  a = a + b
  k=k-1
  #print(a,b,k)
print(a, b)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(n); i++)
#define REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
long long X, Y, cnt{};
bool dfs( long long i )
{
    if( i > Y )
    {
        return 0;
    }
    cnt++;
    return dfs( i * 2 );
}
int main()
{
    cin >> X >> Y;
    dfs( X );
    cout << cnt << endl;
    return 0;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    if (n % 2 == 0) {
        if (k <= n / 2) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    } else {
        if (k <= (n + 1) / 2) {
            cout << "YES" << endl;
        } else {
            cout << "NO" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<cassert>
#include<math.h>
#include<complex>
#include<algorithm>
#include<utility>
#include<queue>
#include<string.h>
#include<string>
#include<set>
#include<map>
#include<unordered_map>
#include<functional>
#include<vector>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
const ll INF=2e18;
const ll MOD=1e9+7;

ll N;
string S;
int main(){
    cin>>N>>S;
	ll ans=0;
	for(ll state=0;state<(1<<N);state++){
		string a,b;
		for(ll bit=0;bit<N;bit++){
			if(state & (1<<bit)){
				a+=S[bit];
			}else{
				b+=S[bit];
			}
		}
		reverse(a.begin(),a.end());
		reverse(b.begin(),b.end());
		// cout<<"a:"<<a<<endl;
		// cout<<"b:"<<b<<endl;
		ll dp[20][20]={};
		dp[0][0]=1;
		for(ll i=0;i<N;i++){
			char c=S[i+N];
			for(ll j=0;j<=min(i,(ll)a.length());j++){
				if(c==a[j]){
					dp[i+1][j+1]+=dp[i][j];
				}
				if(c==b[i-j]){
					dp[i+1][j]+=dp[i][j];
				}
			}
		}
		ans+=dp[N][a.length()];
	}
	cout<<ans;
    return 0;
}

Measured memory_bytes: 384
D = gets.to_i
C,*S = (0..D).map{gets.split.map &:to_i}
L,M,N = [-1]*27,2,10
1 < (I=(0..25).select{C[_1]==0}).size and S.each {|s;z|
  I.each {|i| if i!=(z||=i); s[z]<s[i] ? z = i+s[z]=0 : s[i]=0 end }
}
def calc(d,n)
  s,x = S[d],0
  n = D-d  if n > D-d
  t = (0..25).map { C[_1]*(d-L[_1])*n+s[_1] }
  i = (0..25).max_by(n){t[_1]}
  i = n==1 ? i[0] : [i[0],i[n>>1]].max_by {|i|
    l,L[i] = L[i],d
    c = t[i] + (calc(d+1,n-1) >> 5)
    L[i] = l
    x < c ? x=c : c
  }
  ((x>0 ? x : t[i]) << 5) + i
end
D.times { p 1 + i=calc(_1,N)&31; L[i]=_1 }

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

using namespace std;

int main(){
    int n;
    cin>>n;
    vector<pair<long long,long long>> A(n);
    for(int i=0;i<n;i++){
        cin>>A[i].first>>A[i].second;
    }
    long long ans=0;
    /* O(n^2) approach
    for(int i=0;i<n;i++){
        for(int j=i+1;j<n;j++){
            ans=max(ans, abs(A[i].second-A[j].second)+abs(A[i].first-A[j].first));
        }
    }
    */
   long long maxSum=INT_MIN, minSum=INT_MAX;
   long long maxDiff=INT_MIN, minDiff=INT_MAX;

   for(int i=0;i<n;i++){
       long long curr=A[i].first+A[i].second;
       maxSum=max(maxSum, curr);
       minSum=min(minSum, curr);
       curr=(A[i].first-A[i].second);
       maxDiff=max(maxDiff, curr);
       minDiff=min(minDiff, curr);
   }

    cout<<max(maxSum-minSum, maxDiff-minDiff)<<endl;
}

Measured memory_bytes: 6272
#include <iostream>
#include<bits/stdc++.h>
#define rep(k,i,n) for(int i=k;i<n;++i)
using namespace std;
int N,H,W;
int main(void){
    // Your code here!
    cin>>N;
    cin>>H;
    cin>>W;
    cout<<(N-H+1)*(N-W+1)<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, a, n) for (int i = (a); i < (int)(n); ++i)
#define REPC(i, a, n) for (int i = (a); i <= (int)(n); ++i)
#define ALL(t) t.begin(), t.end()
#define RALL(t) t.rbegin(), t.rend()
#define MATINIT(type, row, col, init) \
  vector<vector<type>>(row, vector<type>(col, init));
#define Yes(cond) cout << (cond ? "Yes" : "No") << endl;
#define YES(cond) cout << (cond ? "YES" : "NO") << endl;
using namespace std;
using LL = long long;
using ULL = unsigned long long;
template <class T>
using VEC = std::vector<T>;
template <class T>
using MAT = std::vector<std::vector<T>>;
void DUMP() { cerr << endl; }
template <class Head, class... Tail>
void DUMP(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  DUMP(std::move(tail)...);
}
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec) {
  os << "{";
  for (auto v : vec) os << v << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, map<T1, T2> &m) {
  os << "{";
  for (auto p : m) os << p << ",";
  os << "}";
  return os;
}
template <typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2> p) {
  os << "[" << p.first << " " << p.second << "]";
  return os;
}

int n;

int main() {
  cin >> n;
  int k = 1;
  LL a;
  VEC<list<pair<int, int>>> G(1e5);
  for (a = 0; a * (a - 1) / 2 < n; ++a) {
  }
  if (a * (a - 1) / 2 == n) {
    REP(i, 0, a) {
      REP(j, i + 1, a) {
        G[i].push_back({j, k});
        G[j].push_back({i, k});
        // DUMP(i,k);
        ++k;
      }
    }
    cout<<"Yes"<<endl;
    cout << a << endl;
    REP(i, 0, a) {
      cout << G[i].size() << " ";
      int q = G[i].size();
      REP(j, 0, q) {
        auto p = G[i].front();
        cout << p.second << " ";
        G[i].pop_front();
      }
      cout << endl;
    }
  } else
    cout << "No" << endl;
  return 0;
}


Measured memory_bytes: 9216
# -*- coding: utf-8 -*-


def main():
    n, l = map(int, input().split())
    taste = [l + i for i in range(n)]
    total = sum(taste)
    value_min = min(taste)
    value_max = max(taste)

    if value_min > 0:
        print(total - value_min)
    elif 0 in taste:
        print(total)
    elif value_max < 0:
        print(total - value_max)


if __name__ == '__main__':
    main()


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

typedef long long ll;

int main() {
    int h, w;
    cin >> h >> w;
    pair<int, int> c, d;
    cin >> c.first >> c.second;
    cin >> d.first >> d.second;
    c.first--;
    d.first--;
    c.second--;
    d.second--;
    vector<string> s(h);
    for (int i = 0; i < h; i++)
        cin >> s[i];
    int dx[] = {1,-1,0,0};
    int dy[] = {0,0,1,-1};
    queue<pair<int, int>> q, q_w;
    vector<vector<int>> count(h, vector<int>(w, 1000000));
    q.push({c.first, c.second});
    count[c.first][c.second] = 0;
    bool goal = false;
    while (!q.empty() || !q_w.empty()) {
        pair<int, int> front;
        if (!q.empty()) {
            front = q.front();
            q.pop();
        } else {
            front = q_w.front();
            q_w.pop();
        }
        int ch = front.first;
        int cw = front.second;
        if (ch == d.first && cw == d.second) {
            goal = true;
            break;
        }
        for (int i = 0; i < 4; i++) {
            int nh = ch + dx[i];
            int nw = cw + dy[i];
            if (nh < 0 || h <= nh)
                continue;
            if (nw < 0 || w <= nw)
                continue;
            if (s[nh][nw] == '.' && count[nh][nw] > count[ch][cw]) {
                count[nh][nw] = count[ch][cw];
                q.push({nh, nw});
            }
        }
        for (int i = -2; i < 3; i++) {
            for (int k = -2; k < 3; k++) {
                int nh = ch + i;
                int nw = cw + k;
                if (nh < 0 || h <= nh)
                    continue;
                if (nw < 0 || w <= nw)
                    continue;
                if (s[nh][nw] == '.' && count[nh][nw] > count[ch][cw] + 1) {
                    count[nh][nw] = count[ch][cw] + 1;
                    q_w.push({nh, nw});
                }
            }
        }
    }
    if (goal)
        cout << count[d.first][d.second];
    else
        cout << -1;
    return 0;
}

Measured memory_bytes: 9428
#include <iostream>
#include <vector>
#include <string>
#include <iomanip>

using namespace std;

int main()
{
    int n,k;
    double ans;
    cin >> n >> k;
    for(int i = 1;i <= n; i++){
      double winrate = 1 / (double)n;
      int gain = i;
      if(i >= k){
        ans += winrate;
      }else{
        while(gain < k){
          winrate = winrate / 2;
          gain = gain * 2;
        }
        ans += winrate;
      }
    }
    cout << setprecision(15) << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
ll DP[61][61][2601];
int main() {
  int N,A;
  cin >> N >> A;
  int x[N];
  for (int i = 0; i < N; i++) {
    cin >> x[i];
  }
  for (int i = 0; i <= 60; i++) {
    for (int j = 0; j <= 60; j++) {
      for (int k = 0; k <= 2600; k++) {
        DP[i][j][k] = 0;
      }
    }
  }
  DP[0][0][0] = 1;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      for (int k = 0; k <= 2500; k++) {
        DP[i+1][j+1][k+x[i]] += DP[i][j][k];
        DP[i+1][j][k] += DP[i][j][k];
      }
    }
  }
  ll ans = 0;
  for (int i = 1; i <= N; i++) {
    ans += DP[N][i][i*A];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 79240
import sys
import resource
sys.setrecursionlimit(10000)
n,k=map(int,input().rstrip().split())
p=list(map(int,input().rstrip().split()))
c=list(map(int,input().rstrip().split()))
def find(start,now,up,max,sum,count,flag):
    if start==now:
        flag+=1
    if start==now and flag==2:
        return [max,sum,count]
    elif count==up:
        return [max,sum,count]
    else:
        count+=1
        sum+=c[p[now-1]-1]
        if max<sum:
            max=sum
        return find(start,p[now-1],up,max,sum,count,flag)
result=-10000000000
for i in range(1,n+1):
    m=find(i,i,n,c[p[i-1]-1],0,0,0)
    if m[2]>=k:
        m=find(i,i,k,c[p[i-1]-1],0,0,0)
        if m[0]>result:
            result=m[0]
        ans=result
    elif m[1]<=0:
        if m[0]>result:
            result=m[0]
        ans=result
    else:
        w=k%m[2]
        if w==0:
            w=m[2]
        spe=find(i,i,w,c[p[i-1]-1],0,0,0)[0]
        if m[1]+spe>m[0] and m[1]*(k-w)//m[2]+spe>result:
            result=m[1]*(k-w)//m[2]+spe
        elif m[1]+spe<=m[0] and m[1]*((k-w)//m[2]-1)+m[0]>result:
            result=m[1]*((k-w)//m[2]-1)+m[0]
        ans=result
print(ans)

Measured memory_bytes: 237044
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

void f(string& s) {
    char p[256] = {};
    char t = 'A';
    for (auto& c : s) {
        if (!p[c]) p[c] = t++;
        c = p[c];
    }
}

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

    f(s);
    f(t);

    cout << (s == t ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 776
MODULE divisorMod
      IMPLICIT NONE
      
      contains
      function allDivisor( N ) result( resArray )
        implicit none
        integer(16),intent(in) :: N
        integer(16),allocatable :: resArray(:),buffer(:)
        integer(16) :: i,c
        
        !N must be N>=1
        !resArray must be deallocated
        
        allocate( buffer(floor(sqrt(real(N)))*2) )
        
        !c : counter
        c = 1
        do i = 1,floor(sqrt(real(N+1)))
          if( mod(N,i)==0 )then
            buffer(c) = i
            c = c + 1
          end if
        end do
        
        !c is allways over 1
        c = c - 1
        
        
        if( buffer(c)*buffer(c)==N )then
          !n is Square number
          buffer(c:2*c-1) = N / buffer(c:1:-1)
          c = 2*c - 1
        else
          buffer(c+1:2*c) = N / buffer(c:1:-1)
          c = 2*c
        end if
        
        !c is now number of divisor
        allocate( resArray(1:c) )
        resArray(1:c) = buffer(1:c)
      end function allDivisor
      END MODULE divisorMod


      PROGRAM divisionOrSubtraction
      use divisorMod
      IMPLICIT NONE
      integer(16) :: ans,n,k,sz,i,m
      integer(16),allocatable :: divisor(:)
      
      read*,n
      
      !case: only subtraction
      ans = size( allDivisor(n-1) )
      !divisor 1 would be excepted
      ans = ans - 1
      
      divisor = allDivisor( n )
      sz = size( divisor )
      
      !for all divisors
      do i = 2,sz
      m = n
        do while(.true.)
          
          if( mod( m,divisor(i) )==0 )then
            m = m / divisor(i)
            
          else
            exit
          end if
          
        end do
        if( mod(m,divisor(i))==1 ) ans = ans + 1
      end do
      
      print*,ans
      
      
      END PROGRAM

Measured memory_bytes: 2300
#include<bits/stdc++.h>
using namespace std;
int change(int a){
    int re = 0;
    while(a>0){
        re += a%10;
        a/=10;
    }
    return re;
}
int main(){
    int n,a,b;
    cin >> n>> a >> b;
    long long int ans = 0;
    for(int i = 0 ; i <= n ; i ++){
        int re = change(i);
        if(re >= a && re <= b){
            ans += i;
//            cout << i <<endl;
        }
    }
    cout << ans <<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdlib.h>
#define INC(i, a, b) for(int i = a; i < b; ++i)
#define DEC(i, a, b) for(int i = a; i > b; --i)
#define REP(i, n)    for(uint i = 0; i < n; ++i)
#define comp(a, b) int comp(const void *a, const void *b)
typedef unsigned int uint;
typedef unsigned long ul;
typedef long long  ll;
typedef unsigned long long ull;

using namespace std;

void TFprint(bool b, std::string T, std::string F){
    if(b){
        cout << T << endl;
    }else{
        cout << F << endl;
    }
}
int abs(int x){
    return x > 0 ? x : -x;
}
int min(int a, int b){
    return a < b ? a : b;
}

typedef struct{
    int d;
    int index;
}s;
comp(a, b){
    s s_a = *(s*)a, s_b = *(s*)b;
    return s_a.d - s_b.d;
}
int main(){
    int N; cin >> N;
    int A[N];
    int max = -1;

    REP(i, N){
        cin >> A[i];
        if(max < A[i]){
            max = A[i];
        }
    }

    s deff[N];
    REP(i, N){
        if(max % 2 == 0){
            deff[i].d = abs(max / 2 - A[i]);
        }else{
            deff[i].d = min(abs(max / 2 - A[i]), abs(max / 2 + 1 - A[i]));
        }
        deff[i].index = i;
    }
    qsort(deff, N, sizeof(s), comp);

    cout << max << ' ' << (A[deff[0].index] == max? A[deff[1].index] : A[deff[0].index]) << endl;
    return 0;
}

Measured memory_bytes: 2172
import qualified Data.Text.Lazy as T
import qualified Data.Text.Lazy.IO as T
import qualified Data.Text.Lazy.Read as T
import qualified Data.Vector.Unboxed as VU
import Data.List (intercalate)

main :: IO ()
main = do
  n <- unsafeTextToInt <$> T.getLine :: IO Int
  as <- map unsafeTextToInt . T.words <$> T.getContents :: IO [Int]
  let
    as' = VU.fromList as :: VU.Vector Int
    x1 = VU.sum . VU.zipWith (*) (VU.iterateN n negate 1) $ as' :: Int
    xs = VU.prescanl subtract x1 . VU.map (2 *) $ as' :: VU.Vector Int
--    xs = VU.tail . VU.prescanl subtract x1 . VU.map (2 *) $ as' :: VU.Vector Int
  putStrLn . intercalate " " . map show . VU.toList $ xs
--  putStr . show $ x1
--  VU.mapM_ (\x -> putChar ' ' >> putStr (show x)) $ xs

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n
{-# INLINE unsafeTextToInt #-}


Measured memory_bytes: 7220
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import accumulate, permutations, combinations, product, groupby
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
from decimal import Decimal, ROUND_DOWN
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

X, Y = MAP()

print(1+((Decimal(str(Y))/Decimal(str(X))).log10()/Decimal("2").log10()).quantize(Decimal('0'), rounding=ROUND_DOWN))


Measured memory_bytes: 5200
from numba import njit
import numpy as np


def main(N, M, X, C):
    min = 10000000000000
    for i in range(2**N):
        a = np.zeros(N)
        cost = 0
        for j in range(N):
            a[j] = (i//(2**j)) % 2
            if a[j] == 1:
                cost += C[j][0]
        for l in range(M):
            sum = 0
            for k in range(N):
                if a[k] == 1:
                    sum += C[k][l+1]
            if sum < X:
                break
            if l == M-1:
                if cost <= min:
                    min = cost
    return min


N, M, X = map(int, input().split())
C = [list(map(int, input().split()))for _ in range(N)]
ans = main(N, M, X, C)
if ans == 10000000000000:
    ans = -1
print(ans)


Measured memory_bytes: 91844
#define STOPIT
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;
using tiii = tuple<int, int, int>;

void debug_impl() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
    #define debug(...)\
    do {\
        cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
        debug_impl(__VA_ARGS__);\
        cerr << std::noboolalpha;\
    } while (false)
#else
    #define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, enable_if_t<!is_same< Container, string >::value, nullptr_t> = nullptr>
istream& operator>> (istream& is, Container& v)
  { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, enable_if_t<!is_same< Container, string >::value, nullptr_t> = nullptr >
ostream& operator<< (ostream& os, Container const& v) {
  os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}";
}

const int INF = 1000000000;


int main()
{
    // read input
    int H, W;
    cin >> H >> W;
    vector<string> grid(H);
    rep(i,0,H) cin >> grid[i];

    int maxd = 0;
    rep(i, 0, H)
        rep(j, 0, W)
        {
            // do dfs
            debug("***");
            vector<vector<bool>> visited(H, vector<bool>(W, false));
            queue<tiii> que;
            que.push(make_tuple(i, j, 0));
            while (que.size()>0)
            {
                // get now
                int y, x, d;
                tie(y, x, d) = que.front();
                que.pop();

                // check
                if (y<0 or H<=y) continue;
                if (x<0 or W<=x) continue;
                if (grid[y][x]=='#') continue;
                if (visited[y][x]) continue;
                visited[y][x] = true;
                debug(y,x,d);

                // update distance
                maxd = max(maxd, d);

                // move to next
                que.push(make_tuple(y+1,x,d+1));
                que.push(make_tuple(y-1,x,d+1));
                que.push(make_tuple(y,x+1,d+1));
                que.push(make_tuple(y,x-1,d+1));
            }
        }

    cout << maxd << endl;
    return 0;
}

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

int main() {
	int n;
	cin >> n;
	vector<int> p(n,0);
	string k = "NO";
	for(int i=0;i<n;i++)
	{
		cin >> p.at(i);
	}
	int sw= n;
	for(int i=0;i<n-1;i++)
	{
		if(p.at(i)>p.at(i+1))
		{
			sw=i;
			break;
		}
	}
	if(sw==n)
	{
		k = "YES";
	}
	else
	{
		int dm = p.at(sw);
		for(int j=0;j<n;j++)
		{
			p.at(sw) = p.at(j);
			p.at(j) = dm;
			int f = 0;
		for(int i=0;i<n-1;i++)
		{
			if(p.at(i)>p.at(i+1))
			{
				f=1;
				break;
			}
		}
		if(f==0)
		{
			k = "YES";
			break;
		}
		else
		{
			p.at(j) = p.at(sw);
			p.at(sw) = dm;
		}
		}
	}
	cout << k << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
int n,m,N,M,ans[600][600];
int main(){
	scanf("%d%d%d%d",&n,&m,&N,&M);
	if (n%N==0&&m%M==0){
		printf("No\n"); return 0;
	}
	int a=n%N,b=m%M,tot=0; ans[1][1]=1e8; tot=1e8;
	ans[N][M]=-tot-1; printf("Yes\n");
	for (int i=1;i<=n;i++){
		for (int j=1;j<=m;j++) printf("%d ",ans[(i-1)%N+1][(j-1)%M+1]); printf("\n");}
	return 0;
}

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

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


int main(){
  ll ans = 0;
  vector<ll> o(5);
  rep(i,5) {
    cin >> o[i];
  }
  ll min = 10;
  ll id = 0;
  rep(i,5){
    if(o[i]%10==0) continue;
    if(o[i]%10<min){
      id = i;
      min = o[i]%10;
    }
  }

  rep(i,5){
    if(i==id){
      ans += o[i];
      continue;
    }else if(o[i]%10==0){
      ans += o[i];
    }else{
      ans += (o[i]/10+1)*10;
    }
  }

  cout << ans << endl;

  return 0;
} 



Measured memory_bytes: 3600
#include<bits/stdc++.h>
using namespace std;
int main(){
    // data loader
    int n;
    cin>>n;
    int p[n];
    for (int i=0;i<n;i++){
        cin>>p[i];
    }
    
    //main
    int rem=0;
    for (int i=0;i<n;i++){
        if (i+1!=p[i]){
            rem++;
        }
    }
    if (rem==0 || rem==2){
        cout<<"YES"<<endl;
    }else{
        cout<<"NO"<<endl;
    }
}


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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define INF         INT_MAX/3
#define LLINF       LLONG_MAX/3
#define MOD         (1000000007LL)
#define MODA(a, b)  a=((a)+(b))%MOD
#define MODP(a, b)  a=((a)*(b))%MOD
#define inc(i, l, r)   for(int i=(l);i<(r);i++)
#define dec(i, l, r)   for(int i=(r)-1;i>=(l);i--)
#define pb          push_back
#define se          second
#define fi          first
#define mset(a, b)  memset(a, b, sizeof(a))

using LL  = long long;
using G   = vector<vector<int>>;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    string s;
    cin >> s;
    int a = 0;
    for(auto c : s){
        a += c-'0';
    }

    int b = s[0]-'0'-1;
    b += (int(s.size())-1)*9;

    cout << max(a, b) << endl;
    return 0;
}


Measured memory_bytes: 764
=begin
－－－－－－－－－－－－－－ 
A = 100*A 水
B = 100*B 水
C,D = １回の投入可能砂糖量
E = 100(g)あたりに溶かすことのできる砂糖量
F = ビーカー許容量(水 + 砂糖 = 総質量)
sugar = F 質量内でできる砂糖の質量を格納(Ci + Dj を組み合わせてできる質量の列挙)
water = F 質量内でできる水の質量を格納(100Ai + 100Bjの組み合わせでできる質量の列挙)
sum = water[i]とsugar[j]の総質量
pos = water[i] に溶かせる砂糖量
con = sugar[j]*100 / (sugar[j] + water[i])  の砂糖濃度(%)
ans = 答え
－－－－－－－－－－－－－－
=end

A,B,C,D,E,F = gets.split.map(&:to_i);

tmp = {};
tmp[:waters] = [];
(0..30).each{|i|
  (0..30).each{|j|
    x = (100*A*i) + (100*B*j);
    tmp[:waters] << x if x <= F;
  }
}
tmp[:waters].sort!.uniq!;

tmp[:sugars] = []
(0..100).each{|i|
  (0..100).each{|j|
    y = C * i + D * j;
    tmp[:sugars] << y if y <= F;
  }
}
tmp[:sugars].sort!.uniq!;

sum_ans = 0;
sugar_ans = 0;
dif = -1;
con = 0.0;

tmp[:waters].each{|w|
  pos = w / 100 * E;
  tmp[:sugars].each{|s|
    sum = w + s;
    next if pos < s || F < sum
    
    con = (s*100) / (s + w).to_f;
    if dif < con
      sum_ans = sum;
      sugar_ans = s;
      dif = con;
    end
  }
}

puts "#{sum_ans} #{sugar_ans}"

Measured memory_bytes: 2040
import sys,queue,math,copy,itertools,bisect,collections
sys.setrecursionlimit(10**7)
INF = 10**18
MOD = 10**9 + 7
LI = lambda : [int(x) for x in sys.stdin.readline().split()]
_LI = lambda : [int(x)-1 for x in sys.stdin.readline().split()]
NI = lambda : int(sys.stdin.readline())

N = NI()
edge = [[] for _ in range(N+1)]
color = [-1] * (N+1)
for _ in range(N-1):
    u,v,w = LI()
    edge[u].append((v,w))
    edge[v].append((u,w))

def set_color(u,c):
    color[u] = c
    for v,w in edge[u]:
        if color[v] >= 0 : continue
        set_color(v,(w % 2) ^ c)
set_color(1,0)
print(*color[1:],sep='\n')


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

using namespace std;
#define rep(i, n) for(int i = 0 ; i < (int)(n) ; i++)
typedef long long ll;
typedef long double Double;

#ifndef INPUTS_DIR
#define INPUTS_DIR "./"
#endif


ll f(ll big, ll small) {
    if (small > big)
        return f(small, big);
    if (small == 0) return -big;
    return ((big / small) * 2) * small + f(big % small, small);

}

void solve(ll N, ll X) {
    cout << N + f(N - X, X) << endl;
}


void main_(istream &cin) {
    ll N;
    ll X;
    cin >> N;
    cin >> X;
    solve(N, X);
}

int main() {
#ifdef INTELLIJ
    ifstream ifs(string(INPUTS_DIR) + "in_1.txt");
    if (ifs.is_open()) {
        main_(ifs);
        ifs.close();
    } else {
        cerr << "Error: no input." << endl;
    }
#else
    ios::sync_with_stdio(false);
    cin.tie(0);
    main_(cin);
#endif
}





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

int main(void){
    int s, w;
    scanf("%d",&s);
    if(1>s || s>100){
        while(1>s || s>100){
            scanf("%d",&s);
        }
    }
    scanf("%d",&w);
    if(1>w || w>100){
        while(1>w || w>100){
            scanf("%d",&w);
        }
    }
    if(s>w){
        printf("safe\n");
    }else{
        printf("unsafe\n");
    }
}


Measured memory_bytes: 1644
import java.util.*; import java.io.*; import java.math.*;
public class Main{
	//Don't have to see. start------------------------------------------
	static class InputIterator{
		ArrayList<String> inputLine = new ArrayList<String>(1024);
		int index = 0; int max; String read;
		InputIterator(){
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			try{
				while((read = br.readLine()) != null){
					inputLine.add(read);
				}
			}catch(IOException e){}
			max = inputLine.size();
		}
		boolean hasNext(){return (index < max);}
		String next(){
			if(hasNext()){
				return inputLine.get(index++);
			}else{
				throw new IndexOutOfBoundsException("There is no more input");
			}
		}
	}
	static HashMap<Integer, String> CONVSTR = new HashMap<Integer, String>();
	static InputIterator ii = new InputIterator();//This class cannot be used in reactive problem.
	static PrintWriter out = new PrintWriter(System.out);
	static void flush(){out.flush();}
	static void myout(Object t){out.println(t);}
	static void myerr(Object t){System.err.print("debug:");System.err.println(t);}
	static String next(){return ii.next();}
	static boolean hasNext(){return ii.hasNext();}
	static int nextInt(){return Integer.parseInt(next());}
	static long nextLong(){return Long.parseLong(next());}
	static double nextDouble(){return Double.parseDouble(next());}
	static ArrayList<String> nextStrArray(){return myconv(next(), 8);}
	static ArrayList<String> nextCharArray(){return myconv(next(), 0);}
	static ArrayList<Integer> nextIntArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Integer> ret = new ArrayList<Integer>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Integer.parseInt(input.get(i)));
		}
		return ret;
	}
	static ArrayList<Long> nextLongArray(){
		ArrayList<String> input = nextStrArray(); ArrayList<Long> ret = new ArrayList<Long>(input.size());
		for(int i = 0; i < input.size(); i++){
			ret.add(Long.parseLong(input.get(i)));
		}
		return ret;
	}
	static String myconv(Object list, int no){//only join
		String joinString = CONVSTR.get(no);
		if(list instanceof String[]){
			return String.join(joinString, (String[])list);
		}else if(list instanceof ArrayList){
			return String.join(joinString, (ArrayList)list);
		}else{
			throw new ClassCastException("Don't join");
		}
	}
	static ArrayList<String> myconv(String str, int no){//only split
		String splitString = CONVSTR.get(no);
		return new ArrayList<String>(Arrays.asList(str.split(splitString)));
	}
	public static void main(String[] args){
		CONVSTR.put(8, " "); CONVSTR.put(9, "\n"); CONVSTR.put(0, "");
		solve();flush();
	}
	//Don't have to see. end------------------------------------------
	static void solve(){//Here is the main function
		ArrayList<String> O = nextCharArray();
		ArrayList<String> S = nextCharArray();
		String output = "";
		for(int i = 0; i < S.size(); i++){
			output += O.get(i);
			output += S.get(i);
		}
		if(O.size() > S.size()){
			output += O.get(O.size() - 1);
		}
		myout(output);
	}
	//Method addition frame start



	//Method addition frame end
}


Measured memory_bytes: 25520
using ll=long long;using ull=unsigned long long;
#include<limits>
namespace pcl{template<typename T>constexpr T TNF=std::numeric_limits<T>::max()/2;constexpr int INF=TNF<int>;constexpr ll LNF=TNF<ll>;constexpr double DNF=TNF<double>;constexpr double EPS=1e-8;constexpr int P7=1'000'000'007;constexpr int DX[]={1,0,-1,0,1,1,-1,-1};constexpr int DY[]={0,1,0,-1,-1,1,1,-1};}
#include<algorithm>
#include<cmath>
#include<iostream>
namespace pcl{template<typename T>void updmax(T&a,T const&b){a=std::max(a,b);}template<typename T>void updmin(T&a,T const&b){a=std::min(a,b);}template<typename T,typename U,typename V>bool in_range(T const&begin,U const&mid,V const&end){return begin<=mid&&mid<end;}template<typename T,typename U,typename V>bool in_range(T const&begin,std::initializer_list<U>list,V const&end){auto p=std::minmax_element(list.begin(),list.end());return begin<=*p.first&&*p.second<end;}template<typename T,typename U,typename V>bool in_range_strict(T const&begin,std::initializer_list<U>list,V const&end){if(!std::is_sorted(list.begin(),list.end()))return false;return in_range(begin,list,end);}template<typename T>inline T cget(){T x;std::cin>>x;return x;}}
#include<iostream>
#include<vector>
namespace pcl{template<typename T>std::ostream&operator<<(std::ostream&os,std::vector<T>const&v){os<<'[';for(size_t i=0;i<v.size();i++){if(i!=0)os<<",";os<<v[i];}os<<']';return os;}template<typename T>std::istream&operator>>(std::istream&is,std::vector<T>&v){for(size_t i=0;i<v.size();i++)is>>v[i];return is;}}
#include<bits/stdc++.h>
using namespace std;using namespace pcl;int main(){int N,K;cin>>N>>K;vector<ll>v(N);for(int i=0;i<N;i++)cin>>v[i];ll ma=0;for(int l=0;l<=K;l++){for(int r=0;r<=K-l;r++){if(l+r>N)continue;int d=min(K-(l+r),l+r);vector<ll>taken;taken.reserve(K);for(int i=0;i<l;i++)taken.push_back(v[i]);for(int i=N-r;i<N;i++)taken.push_back(v[i]);assert((int)taken.size()==l+r&&(int)taken.size()<=l+r);sort(taken.begin(),taken.end());int start=0;while(start<d&&taken[start]<0)start++;ll res=accumulate(taken.begin()+start,taken.end(),0ll);updmax(ma,res);}}cout<<ma<<endl;}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int r,g,b,sum;
  //入力
  scanf("%d %d %d",&r,&g,&b);
  //処理
  sum=r*100+g*10+b*1;
  //出力
  if(sum%4 == 0){
    printf("YES");
  }
  else{
    printf("NO");
  }
  return 0;
}

Measured memory_bytes: 128
// includes {{{
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<random>
#include<cassert>
// }}}
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;

int y[212345], x[212345];
int mi[212345];

// smin, smax {{{
// clang-format off
template < class T, class U > inline void smin(T &a, const U &b) { a = a < (T) b ? a : b; }
template < class T, class U > inline void smax(T &a, const U &b) { a = a < (T) b ? b : a; }
// clang-format on
// }}}

vector<int> ys[212345];


int main() {
  std::ios::sync_with_stdio(false), std::cin.tie(0);
  int h, w;
  cin >> h >> w;
  int n;
  cin >> n;
  int ans = 1e9;
  set<pair<int, int>> st;
  for(int i = 0; i < n; i++) {
    cin >> y[i] >> x[i];
    st.emplace(y[i], x[i]);
    ys[x[i]].emplace_back(y[i]);
  }
  for(int i = 0; i <= w; i++) mi[i] = 1e9;
  int j = 1;
  mi[1] = 1;
  for(int i = 1; i <= h; i++) {
    auto p = make_pair(i + 1, j);
    if(st.count(p)) {
      smin(mi[j], i + 1);
      break;
    } else {
      smin(mi[j], i + 1);
      p.second++;
      if(st.count(p)) {
      } else {
        j++;
      }
    }
  }
  for(int i = 1; i <= w; i++) {
    for(int y : ys[i]) {
      if(y >= mi[i]) {
        ans = min(ans, (y - 2));
      }
    }
  }
  ans = min(ans, (h + 1 - 2));
  cout << ans + 1 << endl;
  return 0;
}


Measured memory_bytes: 20864
#include <stdio.h>
int main(void){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if((a>b)&&(a>c)){
		printf("%d",b+c);
	}else if((b>c)&&(b>a)){
		printf("%d",a+c);
	}else{
		printf("%d",a+b);
	}
	return 0;
}

Measured memory_bytes: 128
SA = input()
SB = input()
SC = input()

Aidx, Bidx, Cidx = 0, -1, -1
X = SA[0]
i = 0

while True:
    if X == 'a':
        Aidx += 1
        if Aidx == len(SA):
            ans = 'A'
            break
        X = SA[Aidx]
    elif X == 'b':
        Bidx += 1
        if Bidx == len(SB):
            ans = 'B'
            break
        X = SB[Bidx]
    elif X == 'c':
        Cidx += 1
        if Cidx == len(SC):
            ans = 'C'
            break
        X = SC[Cidx]


print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define leading zero str.erase(0, min(str.find_first_not_of('0'), str.size()-1));
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
string text="abcdefghijklmnopqrstuvwxyz";
const int maxn=1e6+7;
//        .--------------.
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin>>n;
    int cnt[10][10]={};
    for(int i=1;i<=n;i++){
        string s=to_string(i);
        cnt[s.front()-'0'][s.back()-'0']++;
    }
    ll ans=0;
    for(int i=1;i<=n;i++){
        string s=to_string(i);
        ans+=cnt[s.back()-'0'][s.front()-'0'];
    }
    cout<<ans;
}


Measured memory_bytes: 3772
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,sum=0,count=0,pt=0;
    cin>>n;
    int *a = new int[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
        if(a[i]%2==0){
            sum+=a[i];
        }else{
            count+=1;
        }
    }
    for(int i=0;i<n;i++){
        if(a[i]%2==1){
            pt+=1;
            sum+=a[i];
            if(pt==1){
                a[0]=a[i];
            }
            if(a[0]>a[i]){
                a[0]=a[i];
            }
        }
    }
    if(count%2==0){
        cout<<sum/2<<endl;
    }else{
        cout<<(sum-a[0])/2<<endl;
    }
}


Measured memory_bytes: 3080