akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <list>
#include <queue>
#include <deque>
#include <algorithm>
#include <numeric>
#include <utility>
#include <complex>
#include <functional>
using namespace std;
const int MOD = 1000000007;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = (1 << 28);
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
string s;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> s;
    ll count[3];
    count[0]=0;
    count[1]=0;
    count[2]=1;
    ll ans=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='A'){
            count[0]+=count[2];
        }
        if(s[i]=='B'){
            count[1]+=count[0];
            count[1]%=MOD;
        }
        if(s[i]=='C'){
            ans+=count[1];
            ans%=MOD;
        }
        if(s[i]=='?'){
            ll temp1=count[0], temp2=count[1], temp3=ans, temp4=count[2];
            count[0]+=temp4;
            count[0]+=temp1*2;
            count[0]%=MOD;
            count[1]+=temp1;
            count[1]+=temp2*2;
            count[1]%=MOD;
            ans+=temp2;
            ans%=MOD;
            ans+=temp3*2;
            ans%=MOD;
            count[2]*=3;
            count[2]%=MOD;
        }
    }
    cout << ans << "\n";
}

Measured memory_bytes: 512
# coding: utf-8
import sys
from collections import defaultdict
from math import gcd

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

# 0除算、グループ分け
MOD = 10 ** 9 + 7
N = ir()
AB = [lr() for _ in range(N)]  # 0-indexed
dic = defaultdict(set)
zero = [set() for _ in range(3)]
for i, (a, b) in enumerate(AB, 1):
    g = gcd(a, b)
    #print('g, a, b:', g, a, b)
    if a != 0 and b != 0:
        a //= g; b //= g
        if a < 0:
            a *= -1; b *= -1
        dic[(a, b)].add(i)
    elif a == 0:
        if b == 0:
            zero[0].add(i)
        else:
            zero[1].add(i)
    elif b == 0:
        zero[2].add(i)

answer = 1
used = set()
for k, v in dic.items():
    a, b = k
    k2 = (-b, a)
    if -b < 0:
        k2 = (b, -a)
    if k in used:
        continue
    if k2 in dic:
        v2 = dic[k2]
        answer *= (-1 + pow(2, len(v), MOD) + pow(2, len(v2), MOD))
        used.add((k2))
    else:
        answer *= pow(2, len(v), MOD)
    used.add(k)
    answer %= MOD

# zero
answer *= -1 + pow(2, len(zero[1]), MOD) + pow(2, len(zero[2]), MOD)
answer += len(zero[0])
answer -= 1  # 何も選ばなかった場合
print(answer % MOD)
# np.int64とint型の違いに注意
# 07

Measured memory_bytes: 150332
#include <bits/stdc++.h>
using namespace std;
/*{{{*/  //template
#define rep(i,n) for(int i=0;i<(int)(n);i++)
constexpr int INF = numeric_limits<int>::max()/2;
constexpr long long LINF = numeric_limits<long long>::max()/3;
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
#define sz(x) (int)(x).size()
#define debug(x) cerr<<#x<<":"<<x<<endl
#define debug2(x,y) cerr<<#x<<","<<#y":"<<x<<","<<y<<endl
//struct fin{ fin(){ cin.tie(0); ios::sync_with_stdio(false); } } fin_;
struct Double{ double d; explicit Double(double x) : d(x){} };
ostream& operator<<(ostream& os,const Double x){ os << fixed << setprecision(20) << x.d; return os; }
template<typename T> ostream& operator<<(ostream& os,const vector<T>& vec){ os << "["; for(const auto& v : vec){ os << v << ","; } os << "]"; return os; }
template<typename T,typename U> ostream& operator<<(ostream& os,const pair<T,U>& p){ os << "(" << p.first << ","<< p.second <<")"; return os; }
template<typename T> ostream& operator<<(ostream& os,const set<T>& st){ os<<"{"; for(T v:st) os<<v<<","; os <<"}"; return os; }
template<typename T,typename U> inline void chmax(T &x,U y){ if(y>x) x = y; }
template<typename T,typename U> inline void chmin(T &x,U y){ if(y<x) x = y; }
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
ll gcd(ll a,ll b){ if(b==0) return a; else return gcd(b,a%b); }
//constexpr double eps = 1e-14; 
constexpr double eps = 1e-10; 
constexpr ll mod = 1e9+7;
const int dx[]={1,0,-1,0} ,dy[] = {0,1,0,-1};
/*}}}*/

bool check[500][100005];

int main(){
    int N; cin >> N;
    int k;
    for(int i=1;i<=N+10;i++){
        int t = i * (i-1) / 2;
        if(t > N){
            cout << "No" << endl;
            return 0;
        }
        if(t == N){
            k = i;
            break;
        }
    }

    int s = 0;
    for(int i=0;i<k;i++){
        const int len = k-1-i;
        for(int j=s;j<s+len;j++){
            //cout << i << " " << j << endl;
            check[i][j] = true;
        }

        for(int j=0;j<len;j++){
            check[i+1+j][s+j] = true;
        }
        s = s + len;
    }
    cout << "Yes" << endl;
    cout << k << endl;
    for(int i=0;i<k;i++){
        int cnt = 0;
        for(int j=0;j<N;j++) if(check[i][j]) cnt++;
        cout << cnt;
        for(int j=0;j<N;j++){
            if(check[i][j]) cout << " " << j+1;
        }
        cout << endl;
    }
}


Measured memory_bytes: 44544
def low(list, j, tag):
    ok = j
    ng = n
    while abs(ok - ng) > 1:
        mid = (ok + ng) // 2
        if list[mid] >= tag:ok = mid
        else:ng = mid
    return ok

n = int(input())
l = list(map(int,input().split()))
l = sorted(l, reverse = True)
#print(l)
cnt = 0
for i in range(n - 2):
    for j in range(i + 1, n - 1):
        temp0 = l[i] - l[j]
        temp1 = l[j] + l[i]
        cnt += low(l, j, temp0 + 1) - j
        #print((l[i],l[j]), j, low(l, j, temp0 + 1) - j, cnt)
print(cnt)


Measured memory_bytes: 45564
letters = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']
while True:
  try:
    s = input()
  except:
    break
    
  l = len(s)
  for i in range(26):
    t = ""
    for j in range(len(s)):
      c = s[j]
      if 'a' <= c and c <= 'z':
        x = letters.index(c)
        cc = letters[(x + i) % 26]
        t += cc
      else:
         t += c
    if ("the" in t) or ("this" in t) or ("that" in t):
      print(t)
  


Measured memory_bytes: 5564
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iostream>
#include <sstream>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <queue>

using namespace std;

typedef long long LL;

void solve(long long n, long long m, std::string s) {
	LL goal = n, prev = -1;
	vector<LL> ans;
	for (LL i = n - 1; i >= 0; --i) {
		if (i + m < goal) {
			if (prev < 0) {
				cout << -1 << endl;
				return;
			}
			ans.push_back(goal);
			goal = prev;
			prev = -1;
		}
		if (s[i] == '0') {
			prev = i;
		}
	}
	ans.push_back(goal);
	if (prev >= 0) {
		ans.push_back(0);
	}
	reverse(ans.begin(), ans.end());
	for (LL i = 1; i < (LL)ans.size(); ++i) {
		if (i > 1) {
			cout << " ";
		}
		cout << (ans[i] - ans[i - 1]);
	}
	cout << endl;
}

int main() {
    long long N;
	(void)scanf("%lld", &N);
	long long M;
	(void)scanf("%lld", &M);
	std::string S;
	std::cin >> S;
	solve(N, M, S);
	return 0;
}


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

int main(){
    int n,m; cin >> n >> m;
    vector<int> a(n);
    int sum =0;
    rep(i,n){
        cin >> a[i];
        sum += a[i];
    }
    sort(a.rbegin(),a.rend());
    if(a[m-1]*4*m >= sum) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
int n,f[100005];
long long m;
long long calc(int k)
{
	int l,r;
	long long cnt=0;
	r=n+1;
	for (l=1;l<=n;l++)
	{
		while (f[l]+f[r-1]>=k&&r>1) --r;
		cnt=cnt+(n-r+1);
	}
	return cnt;
}
int bs(int l,int r)
{
	if (l==r) return l;
	int mid=(l+r+1)/2;
	if (calc(mid)>=m) return bs(mid,r);
	else return bs(l,mid-1);
}
long long solve(int k,long long p)
{
	int l,r;
	long long ans=0,cnt=0;
	r=n+1;
	for (l=1;l<=n;l++)
	{
		while (f[l]+f[r-1]>=k&&r>1) --r;
		ans=ans+1ll*(n-r+1)*f[l];
		cnt=cnt+(n-r+1);
	}
	ans=ans*2;
	if (cnt>p) ans=ans-k*(cnt-p);
	return ans;
}
int main()
{
	scanf("%d%lld",&n,&m);
	for (int i=1;i<=n;i++) scanf("%d",&f[i]);
	std::sort(f+1,f+n+1);
	int k=bs(1,200000);
	printf("%lld\n",solve(k,m));
	return 0;
}

Measured memory_bytes: 512
import std.algorithm;
import std.array;
import std.conv;
import std.math;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

T read(T)() { return readln.chomp.to!T; }
T[] reads(T)() { return readln.split.to!(T[]); }
alias readint = read!int;
alias readints = reads!int;

void main() {
    readint;
    string s = read!string;

    int lparen = 0;
    int h = 0;
    foreach (c; s) {
        if (c == '(') h++;
        else {
            h--;
            lparen = min(lparen, h);
        }
    }

    foreach (_; 0..-lparen) write('(');
    write(s);
    foreach (_; 0..h-lparen) write(')');
    writeln();
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#define rep(i, n) for(int i=0; i<n; i++)

using namespace std;

void print(int array[], int N){
  rep(i, N)
    cout << array[i] << " " ;
  cout << endl;
}

int main(void){
  int N;
  cin >> N;
  int A[N], B[N], C[N];
  //入力
  rep(i, N)
    cin >> A[i];
  rep(i, N)
    cin >> B[i];
  rep(i, N)
    cin >> C[i];

  //A, B, Cをソートする
  sort(A, A+N);
  sort(B, B+N);
  sort(C, C+N);

  //ソートした配列の表示
  //print(A, N); print(B, N); print(C, N);

  //ansにパーツの個数を格納する
  //最大でN^3=10^15程度になるため，int型では収まりきらない
  long long int ans = 0;

  //small_numは，A[j] < B[i]となるjの個数
  //big_nunm は，B[i] < C[k]となるkの個数
  long long int small_num, big_num;

  rep(i, N){
    //cout << "B[" << i << "] = " << B[i] << "のとき" << endl;
    small_num = lower_bound(A, A+N, B[i])-A;
    big_num   = N-(upper_bound(C, C+N, B[i])-C);
    //cout << "A[j] < B[i]となるA[j]の数 : " << small_num << endl;
    //cout << "B[i] < C[k]となるC[k]の数 : " << big_num << endl;
    ans += small_num * big_num;
    //cout << "ans = " << ans << endl << "----------------" << endl;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

int main () {
    // input
    string str;
    cin >> str;

    int q;
    cin >> q;

    string result = str;
    int res_len = result.length();
    for (int i=0; i<q; i++) {
        string order;
        int a, b;
        cin >> order >> a >> b;
        if (order == "print") {
            // output
            cout << result.substr(a, b-a+1) << endl;
        } else if (order == "reverse") {
            string reversed = "";
            for (int j=0; j<a; j++) {
                reversed += result[j];
            }
            for (int jj=b; jj>a-1; jj--) {
                reversed += result[jj];
            }
            for (int jjj=b+1; jjj<res_len; jjj++) {
                reversed += result[jjj];
            }
            result = reversed;
            //cout << reversed << endl;
        } else if (order == "replace") {
            string p;
            cin >> p;
            string replaced = "";
            for (int k=0; k<a; k++) {
                replaced += result[k];
            }
            for (int kk=a; kk<b+1; kk++) {
                replaced += p[kk-a];
            }
            for (int kkk=b+1; kkk<res_len; kkk++) {
                replaced += result[kkk];
            }
            result = replaced;
            //cout << result << endl;
        }
    }
}


Measured memory_bytes: 3236
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
#define all(v) v.begin(), v.end()
#define bigger (char)toupper
#define smaller (char)tolower
using namespace std;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef long long ll;
typedef unsigned long long ull;

int main() {
    int N;
    cin>>N;
    vector<tuple<string,int,int>> v;
    for(int i=1; i<=N; i++) {
        string s;
        int a;
        cin>>s>>a;
        a=-1*a;
        v.pb(tie(s,a,i));
    }
    sort(all(v));
    rep(i,N) {
        cout<<get<2>(v.at(i))<<endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <cmath>
using namespace std;
 
int main() {
    int h,w;
    cin >> h >> w;
    
    for(int i=0 ; i < w+1 ; i++){//一番上の#
        cout << "#" ;
    }
    cout << "#" << endl;
    for (int j = 0; j < h; j++)
    {
    vector<string> vec(h);
    cin >> vec[j];
    cout << "#" << vec[j] << "#" << endl;
    }
    for(int i=0 ; i < w+1 ; i++){//一番下の#
        cout << "#" ;
    } 
    cout << "#"<< endl;
}

Measured memory_bytes: 3552
import java.util.Map.Entry;
import java.io.*;
import java.math.BigInteger;
import java.util.*;

public class Main {
	
	public static void main(String[] args) throws IOException {
		FastScanner sc = new FastScanner(System.in);
		
		int N = sc.nextInt();
		int P = sc.nextInt();
		int[] A = new int[N+1];
		for(int i = 1; i <= N; i++) A[i] = sc.nextInt();
		
		long[][] dp = new long[N+1][2];
		dp[0][0] = 1;
		
		for(int i = 1; i <= N; i++){
			if(A[i] % 2 == 0){
				dp[i][0] = dp[i-1][0] * 2;
				dp[i][1] = dp[i-1][1] * 2;
			}else{
				dp[i][0] = dp[i-1][0] + dp[i-1][1];
				dp[i][1] = dp[i-1][1] + dp[i-1][0];
			}
		}
		
		if(P == 1) System.out.println(dp[N][1]);
		else System.out.println(dp[N][0]);
	}
}

class FastScanner {
    private InputStream in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    public FastScanner(InputStream in) {
		this.in = in;
	}
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        }else{
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
    private int readByte() {
    	if (hasNextByte()) return buffer[ptr++];
    	else return -1;
    }
    private static boolean isPrintableChar(int c){
    	return 33 <= c && c <= 126;
    }
    public boolean hasNext() {
    	while(hasNextByte() && !isPrintableChar(buffer[ptr]))
    		ptr++; return hasNextByte();
    }
    public String next() {
        if (!hasNext()) throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while(isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
    public long nextLong() {
        if (!hasNext()) throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while(true){
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            }else if(b == -1 || !isPrintableChar(b)){
                return minus ? -n : n;
            }else{
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) throw new NumberFormatException();
        return (int) nl;
    }
    public double nextDouble() {
    	return Double.parseDouble(next());
    }
}


Measured memory_bytes: 23124
#include <cstdio>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>
#include <iomanip>
#include <deque>
#include <queue>
#include <unordered_map>
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;
ll intpow(ll N, ll P){
    if(P==0) return 1;
    if(P%2==0){
        ll t = intpow(N, P/2);
        return t*t;
    }
    return N * intpow(N, P-1);
}
ll modpow(ll N, ll P,ll k){
    if(P==0) return 1;
    if(P%2==0){
        ll t = modpow(N, P/2,k)%k;
        return t*t%k;
    }
    return N * modpow(N, P-1,k)%k;
}
ll modkai(ll n,ll m,ll k){//n*(n-1)*(n-2)*...(m+1)%k
    if(n == m)return 1;
    return modkai(n-1,m,k)*n%k;
}
ll mod_cnb(ll n,ll m,ll k){//nCm%k,kは十分大きい素数
  int m_=modkai(m,0,k);
  return modkai(n,n-m,k)*modpow(m_,k-2,k)%k;
}
ll gcd(ll n,ll m){
    ll n_ = max(n,m);
    ll m_ = min(n,m);
    if(n_%m_ == 0)return m_;
    return gcd(m_,n_%m_);
}
ll lcm(ll n,ll m){
    return n*m/gcd(n,m);
}

using Graph = vector<vector<int>>;
vector<ll> gnum(100000,0);
vector<ll> fnum(100000,0);
vector<ll> bnum(100000,0);
vector<int> seen;
void dfs(const Graph &F,const Graph &B, int v,int i) {
    seen[v]=i;
    gnum[i]++;
    // v から行ける各頂点 next_v について
    for (auto b : B[v]){
        if(seen[b]==i){
            bnum[v]++;
            bnum[b]++;
        }
    }
    for (auto next_v : F[v]) { 
        fnum[v]++;
        if (seen[next_v]!=-1) continue; // next_v が探索済だったらスルー
        dfs(F,B,next_v,i); // 再帰的に探索
    }
}
int main() {
    // 頂点数と辺数
    int n,m,k;cin>>n>>m>>k;

    // グラフ
    Graph f(n);
    Graph b(n);

    rep(i,m){
        int a,b;cin>>a>>b;
        a--;b--;
        f[a].push_back(b);
        f[b].push_back(a);
    }
    rep(i,k){
        int c,d;cin>>c>>d;
        c--;d--;
        b[c].push_back(d);
        b[d].push_back(c);
    }
    seen.assign(n,-1);
    int group=-1;
    rep(i,n){
        if(seen[i]!=-1)continue;
        if(seen[i]==-1)group++;
        dfs(f,b,i,group);
    }
    ll ans=0;
    rep(i,n)cout<<gnum[seen[i]]-1-bnum[i]-fnum[i]<<" ";
}

Measured memory_bytes: 15360
N, A, B, C =map(int,input().split())
l = []
for i in range(N):
    a = int(input())
    l.append(a)

infty = 1000000

def DFS(i,uselist0,uselista,uselistb,uselistc):
    if i == N:
        return calc_mp(uselista,uselistb,uselistc)
    mplist = []
    u0 = uselist0 + [l[i]]
    ua = uselista + [l[i]]
    ub = uselistb + [l[i]]
    uc = uselistc + [l[i]]
    mplist.append(DFS(i+1, u0,uselista,uselistb,uselistc))
    mplist.append(DFS(i+1, uselist0,ua,uselistb,uselistc))
    mplist.append(DFS(i+1, uselist0,uselista,ub,uselistc))
    mplist.append(DFS(i+1, uselist0,uselista,uselistb,uc))
    return min(mplist)


def calc_mp(uselista,uselistb,uselistc):
    mp = 0
    #合成魔法
    mp += (max(len(uselista) - 1, 0)) * 10
    mp += (max(len(uselistb) - 1, 0)) * 10
    mp += (max(len(uselistc) - 1, 0)) * 10

    #その他魔法
    mp += abs(A - sum(uselista))
    mp += abs(B - sum(uselistb))
    mp += abs(C - sum(uselistc))

    if len(uselista)==0:
        mp += infty
    if len(uselistb)==0:
        mp += infty
    if len(uselistc)==0:
        mp += infty
    return mp

print(DFS(0,[],[],[],[]))

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

int main(){
  long long N,ans=0;
  cin >> N;
  
  for(long long i=1;i<=N;i++){
    long long x = N/i;
    ans += x;
    if(x*i==N) ans--;
  }
  
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Math;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;

public static class P
{
    public static void Main()
    {
        int n = Reader.NextInt;
        int last = 0;
        int cur = 0;
        int max = 0;
        for (int i = 0; i < n; i++)
        {
            var h = Reader.NextInt;
            if (last >= h) max = Max(max, ++cur);
            else cur = 0;
            last = h;
        }
        Console.WriteLine(max);
    }
}

static class Reader
{
    const int BUF_SIZE = 1 << 12;
    static Stream Stream = Console.OpenStandardInput();
    static byte[] Buffer = new byte[BUF_SIZE];
    static int ptr = 0;

    private static void Read() { Stream.Read(Buffer, 0, BUF_SIZE); }

    private static byte Next { get { if (ptr >= Buffer.Length) { Read(); ptr = 0; } return Buffer[ptr++]; } }

    public static int NextInt
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        get
        {
            int res = 0; byte next; while ((next = Next) < 48) ;
            do { res = res * 10 + (next ^ 48); } while (48 <= (next = Next));
            return res;
        }
    }

    public static int NextSInt
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        get
        {
            int res = 0; byte next; int sign = 1; do { next = Next; } while (next < 45); if (next == 45) { next = Next; sign = -1; }
            do { res = res * 10 + (next ^ 48); next = Next; } while (48 <= next);
            return res * sign;
        }
    }

    public static long NextLong
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        get
        {
            long res = 0; byte next; do { next = Next; } while (next < 48);
            do { res = res * 10 + (next ^ 48); next = Next; } while (48 <= next);
            return res;
        }
    }

    public static long NextSLong
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        get
        {
            long res = 0; byte next; int sign = 1; do { next = Next; } while (next < 45); if (next == 45) { next = Next; sign = -1; }
            do { res = res * 10 + (next ^ 48); next = Next; } while (48 <= next);
            return res * sign;
        }
    }
}


Measured memory_bytes: 11092
/* template.cpp(shinobu_menkoi) {{{ */
#include <bits/stdc++.h>
using namespace std;

// clang-format off
#define GET_MACRO(_1, _2, _3, _4, NAME, ...) NAME
#define rep(...) GET_MACRO(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rep1(n) rep2(_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, n) rep4(i, a, n, 1)
#define rep4(i, a, n, s) for (lint i = (a); i < (lint)(n); i += (s))
#define rrep(...) GET_MACRO(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rrep1(a) rrep2(_, a)
#define rrep2(i, a) rrep3(i, a, 0)
#define rrep3(i, a, n) rrep4(i, a, n, 1)
#define rrep4(i, a, n, s) for (lint i = (a); i >= (lint)(n); i -= (s))
#define each(i, ctn) for (auto &&i : (ctn))

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define all(v) begin(v), end(v)
#define debug(x) cerr << (x) << " (L:" << __LINE__ << ")" << '\n'
#define TEMP_T template <class T>
#define TEMP_TU template <class T, class U>

TEMP_T using vec = vector<T>;
TEMP_T using heap = priority_queue<T>;
TEMP_T using minheap = priority_queue<T, vec<T>, greater<T>>;
using lint = long long;
using ulint = unsigned long long;
using ld = long double;
using vi = vec<int>;
using vvi = vec<vi>;
using vvvi = vec<vvi>;
using pii = pair<int, int>;
using vs = vec<string>;

TEMP_TU ostream &operator<<(ostream &os, const pair<T, U> &p) { return os << p.fi << " " << p.se; }
TEMP_TU istream &operator>>(istream &is, pair<T, U> &p) { return is >> p.fi >> p.se; }

const int INF{1001001001};
const lint LINF{1001001001001001001ll};
const int MOD{(int)1e9 + 7};
const double EPS{1e-9};
const double PI{acos(-1)};
const int dx[]{0, 1, 0, -1, 1, -1, 1, -1}, dy[]{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; }
TEMP_T inline bool chmin(T &a, const T &b) { if (a > b) a = b; return a > b; }
TEMP_T inline bool chmax(T &a, const T &b) { if (a < b) a = b; return a < b; }
TEMP_T inline void print(const T &x) { cout << x << '\n'; }
TEMP_T inline void print(const vec<T> &v, string d = "\n") { rep(i, v.size()) cout << v[i] << (i == (lint)v.size() - 1 ? "\n" : d); }
template <class T = int> inline T in() { T x; cin >> x; return x; }
template <class T = string> vec<T> split(const string &s, char d = ',') {
  vec<T> v; stringstream ss(s); for (string b; getline(ss, b, d); ) {
    stringstream conv(b); T t; conv >> t; v.eb(t); } return v;
}
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } pre__;
// clang-format on
/* }}} */

signed main() {
  int a, b, c;
  cin >> a >> b >> c;
  int n = a * 100 + b * 10 + c;
  if (n % 4 == 0) {
    print("YES");
  } else {
    print("NO");
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define space putchar(' ')
#define enter putchar('\n')
#define eps 1e-10
#define MAXN 1000005
//#define ivorysi
using namespace std;
typedef long long int64;
typedef unsigned int u32;
typedef double db;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 +c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) {
	out(x / 10);
    }
    putchar('0' + x % 10);
}
const int MOD = 1000000007;
int N;
int f[MAXN][3],g[MAXN],fac[MAXN],invfac[MAXN],inv[MAXN];
int inc(int a,int b) {
    return a + b >= MOD ? a + b - MOD : a + b;
}
int mul(int a,int b) {
    return 1LL * a  * b % MOD;
}
int fpow(int x,int c) {
    int res = 1,t = x;
    while(c) {
	if(c & 1) res = mul(res,t);
	t = mul(t,t);
	c >>= 1;
    }
    return res;
}
int C(int n,int m) {
    if(n < m) return 0;
    return mul(fac[n],mul(invfac[m],invfac[n - m]));
}
void Solve() {
    read(N);
    fac[0] = 1;
    for(int i = 1 ; i <= N; ++i) fac[i] = mul(fac[i - 1],i);
    invfac[N] = fpow(fac[N],MOD - 2);
    for(int i = N - 1 ; i >= 0 ; --i) invfac[i] = mul(invfac[i + 1],i + 1);
    inv[1] = 1;
    for(int i = 2 ; i <= 1000000 ; ++i) inv[i] = mul(inv[MOD % i],MOD - MOD / i);
    f[0][0] = 1;
    int iv3= fpow(inv[3],N - 1);
    int ans = 0;
    for(int i = 1 ; i <= N ; ++i) {
	f[i][1] = inc(f[i - 1][0],f[i - 1][2]);
	f[i][0] = inc(f[i - 1][1],f[i - 1][2]);
	f[i][2] = inc(f[i - 1][0],f[i - 1][1]);
	g[i] = mul(mul(inv[3],inv[N]),inv[i]);
	int p = mul(mul(f[i][1],C(N,i)),iv3);
	ans = inc(ans,mul(g[i],p));
    }
    out(ans);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
}


Measured memory_bytes: 27648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define MOD (int) (1e9+7)
#define INF (int) 2e9
#define LLINF (ll) 2e18

int main(){
    char c;
    cin >> c;
    cout << (char)(c+1) << endl;
    // printf("%d\n", N);
    return 0;
}

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

using namespace std;

#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}


typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1000000007;
//const ll MOD = 998244353;
const double pi = 3.14159265358979323846;
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { -1,0, 1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
// #define mp make_pair
//#define endl '\n'

//const ll MOD = 13;

ll mod_pow(ll x, ll p, ll M = MOD) {
  ll a = 1;
  while (p) {
    if (p % 2)
      a = a*x%M;
    x = x*x%M;
    p /= 2;
  }
  return a;
}


int main() {
  string s;
  cin >> s;
  reverse(all(s));
  int n = s.size();
  vll dp(n + 1, vl(13));
  dp[0][0] = 1;
  ll now = 1;
  rep (i, n) {
    rep (j, 13) {
      if (s[i] != '?') {
        int nj = j + (s[i] - '0') * now % 13;;
        nj %= 13;
        (dp[i + 1][nj] += dp[i][j]) %= MOD;
      }
      else {
        rep (k, 10) {
          int nj = (j + k * now % 13) % 13;
          (dp[i + 1][nj] += dp[i][j]) %= MOD;
        }
      }
    }
    now *= 10;
    now %= 13;
  }
  cout << dp[n][5] << endl;
}


Measured memory_bytes: 13696
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

signed main(){
    int n;
    cin >> n;
    int A[n];
    REP(i,n) cin >> A[i];

    set<pair<int,int>> S;
    S.insert(mp(-A[0],0));
    S.insert(mp(-INF,0));
    S.insert(mp(INF,0));
    FOR(i,1,n){
        pair<int,int> tmp = mp(-A[i],i);

        auto itr = S.lower_bound(tmp);
        ///cout << itr->fi << " " << itr->se << endl;
        if( itr->fi != INF ){
            S.erase(*itr);
            S.insert(mp(-A[i],i));
        }
        else{
            S.insert(mp(-A[i],i));

        }
    }
    cout << S.size() - 2 << endl;

}

Measured memory_bytes: 7296
#include<bits/stdc++.h>
#include<algorithm>
using namespace std;
int b[10000];
int main()
{

    long long int k,n,i,s=0,x,y;

    cin>>n>>x>>y;
    int a[n][n];
    for(i=1;i<=n;i++)
    {
    for(k=i+1;k<=n;k++)
    {
    if(i==k)
       a[i][k]=0;
    else if(abs(x-i)+abs(y-k)+1>=abs(i-k))
        a[i][k]=abs(i-k);
    else
    {
        a[i][k]=abs(x-i)+abs(y-k)+1;
    }
    b[a[i][k]]++;
   // cout<<a[i][k]<<"  ";
    }
    //cout<<endl;
    }
for(i=1;i<=n-1;i++)
{
 cout<<b[i]<<endl;
}


}



Measured memory_bytes: 15872
n, k = map(int, input().split())
v = [int(i) for i in input().split()]
ans = 0
for a in range(min(n, k) + 1):
    pa, va = v[:a], v[a:]
    for b in range(min(n, k) - a + 1):
        pb = pa + va[-b:] if b > 0 else pa
        pb.sort()
        s = sum(pb)
        ans = max(s, ans)
        for c in range(min(k - a - b, a + b)):
            s -= pb[c]
            ans = max(s, ans)
print(ans)


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

int main() {
  int N,K;
  cin>>N>>K;
  vector<int> vec(N);
  rep(i,N){cin >> vec.at(i);}
  sort(vec.begin(), vec.end());
  int Ans;
  Ans=0;
  rep(i,K){Ans+=vec.at(i);}
  cout<<Ans<<endl;
}

Measured memory_bytes: 3628
import java.util.*;

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

		for(int i=0; i<data; i++){
			String str = sc.next();
			HashSet<String> hs = new HashSet<String>();

			hs.add(str);
			for(int j=1;j<str.length();j++){
				String before = str.substring(0, j);
				String after = str.substring(j, str.length());
				hs.add(after + before);
				before = new StringBuilder(before).reverse().toString();
				hs.add(before + after);
				hs.add(after + before);
				after = new StringBuilder(after).reverse().toString();
				hs.add(before + after);
				before = new StringBuilder(before).reverse().toString();
				hs.add(before + after);
				hs.add(after + before);
			}
			str = new StringBuilder(str).reverse().toString();
			hs.add(str);

			System.out.println(hs.size());
		}
	}
}

Measured memory_bytes: 60728
class Tree
  AND, OR, XOR = (0..2).to_a
  ALL = "1111".to_i(2)

  def initialize(exp, sweet)
    @size = 0
    @root = parse(exp, sweet)
  end

  class Node
    attr_accessor :left, :right, :value
  end

  def parse(exp, sweet)
    node = Node.new
    case exp.chr
      when "("
        @size += 1
        exp.slice!(0) # "("
        node.left = parse(exp, sweet)
        exp.slice!(0) # " "
        node.right = parse(exp, sweet)
        exp.slice!(0) # ")"
      else
        node.value = sweet[exp.slice!(0).to_i - 1]
    end
    node
  end

  def solve(depth = 0, operator = Array.new)
    return (calculate(operator.dup) == ALL ? 1 : 0) if (depth == @size)
    [AND, OR, XOR].map{|op|
      operator[depth] = op
      solve(depth + 1, operator)
    }.inject(&:+)
  end

  def calculate(operator, node = @root)
    return node.value if node.value
    case operator.shift
      when AND
        calculate(operator, node.left) & calculate(operator, node.right)
      when OR
        calculate(operator, node.left) | calculate(operator, node.right)
      when XOR
        calculate(operator, node.left) ^ calculate(operator, node.right)
    end
  end
end

until (exp = gets.chomp) == "END"
  p Tree.new(exp, gets.to_i.times.map{gets.delete(" ").to_i(2)}).solve
end

Measured memory_bytes: 6160
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    int c[n+1];//かかる時間
    int s[n+1];//一本目
    int f[n+1];//その後
    int t;
    for(int i = 1;i < n;i++){
        cin >> c[i] >> s[i] >> f[i];
    }
    for(int i = 1;i < n;i++){
        t = 0;
        for(int j = i;j < n;j++){
            if(t < s[j])t = s[j];
            else if(t % f[j] == 0);
            else t = t + (f[j]-t%f[j]);
            t += c[j];
        }
        cout << t << endl;
    }
  cout << 0 << endl;
}


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

#define INF 1e9
using namespace std;
typedef long long ll;

int main() {

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

    int ans = 1;

    for (int i = 1; i <= n; ++i) {
        ans = min(ans * 2, ans + k);
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;


int main(){
    int X, N;
    cin >> X >> N;
    vector<int> p;

    for(int i=0; i<N; ++i){
        int a;
        cin >> a;
        p.push_back(a);
    }

    int ans;
    if( count(p.begin(), p.end(), X) == 0 ){
        ans = X;
    }else{
        //left
        int l = X-1;
        while( count(p.begin(), p.end(), l) > 0 ){
            --l;
        }

        //right 
        int r = X+1;
        while( count(p.begin(), p.end(), r) > 0 ){
            ++r;
        }

        if( abs(X-l) <= abs(r-X) ){
            ans = l;
        }else{
            ans = r;
        }

    }
    cout << ans << endl;

    // //left
    // int tmp = X;
    // int left_idx = -1;
    // int left_dist;
    // while(tmp >= 0){
    //     if(cant_use[tmp] == true){
    //         tmp--;
    //     }else{
    //         left_idx = tmp;
    //         left_dist = abs(X- left_idx);
    //         break;
    //     }

    // }

    // //right
    // int tmp2 = X;
    // int right_idx = -1;
    // int right_dist;
    // while(tmp2 <= 100){
    //     if(cant_use[tmp2] == true){
    //         tmp2++;
    //     }else{
    //         right_idx = tmp2;
    //         right_dist = abs(tmp2 - X);
    //         break;
    //     }
    // }


    // //ans
    // int ans;
    // if(left_idx == -1){
    //     ans = right_idx;
    // }else if(right_idx == -1){
    //     ans = left_idx;
    // }else{
    //     if(left_dist <= right_dist){
    //         ans = left_idx;
    //     }else{
    //         ans = right_idx;
    //     }
    // }


    // cout << ans << endl;
}

Measured memory_bytes: 3628
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <queue>
#include <utility>
#include <map>
#include <bitset>
#include <numeric>
#define ll long long
using namespace std;
using p = pair<ll, ll>;
ll dx[8]={ 0, 1, 0,-1, 1, 1,-1,-1}; // x軸方向への変位
ll dy[8]={ 1, 0,-1, 0, 1,-1, 1,-1}; // y軸方向への変位


int main(void) {
    string s, t;
    cin >> s >> t;
    bool ok = true;
    for(ll i = 0; i < s.length(); i++){
        if(s[i]!=t[i]) ok = false;
    }
    if(ok==true)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3624
def makeSet(x)
  $ps << x
  $rank << 0
end
def union(x,y)
  link(findSet(x), findSet(y))
end
def link(x,y)
  if $rank[x] > $rank[y]
    $ps[y] = x
  else
    $ps[x] = y
    if $rank[x] == $rank[y]
      $rank[y] = $rank[y] + 1
    end
  end
end
def findSet(x)
  if x != $ps[x]
    $ps[x] = findSet($ps[x])
  end
  return $ps[x]
end
$ps = []
$rank = []

n,q = gets.split.map(&:to_i)
n.times{|i|
  makeSet(i)
}
q.times{|i|
  com, x, y = gets.split.map(&:to_i)
  if com == 0
    union(x,y)
  elsif com == 1
    puts findSet(x) == findSet(y) ? "1" : "0"
  end
}


Measured memory_bytes: 9076
n=input()
list1=[int(i) for i in input().split(" ")]
list2=[int(i) for i in input().split(" ")]
a=list1[0]
b=list1[1]
count1=0
count2=0
count3=0
for i in list2:
    if i<=a:
        count1+=1
    elif a<i<=b:
        count2+=1
    else:
        count3+=1
print(min(count1,count2,count3))

Measured memory_bytes: 3064
n = int(input().split()[0])
c = list(filter(lambda x:x <= n,map(int,input().split())))
m = len(c)

minimum = [n] * (n+1)
minimum[0] = 0
for i in c:
    minimum[i] = 1

for i in range(1,n+1):
    for j in range(m):
        if c[j]<=i and minimum[i-c[j]] + 1 < minimum[i]:
            minimum[i] = minimum[i-c[j]]+1

print(minimum[n])

Measured memory_bytes: 9196
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=2020,MAX=5005;
const ll INF=1LL<<62;

vector<int> dh={0,1,0,-1},dw={1,0,-1,0};

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int H,W;cin>>H>>W;
    
    vector<string> S(H);
    for(int i=0;i<H;i++) cin>>S[i];
    
    vector<pair<int,int>> use;
    
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(S[i][j]!='.'){
                for(int k=0;k<H;k++) use.push_back({k,j});
                for(int k=0;k<W;k++) use.push_back({i,k});
            }
        }
    }
    int ans=0;
    
    for(int t=0;t<26;t++){
        bool ok=false;
        for(pair<int,int> p:use){
            int a=p.first,b=p.second;
            
            if(S[a][b]!='.') continue;
            
            vector<pair<int,int>> goal(4,{-3,-3});
            
            for(int k=0;k<4;k++){
                int hnow=a,wnow=b;
                
                while(hnow>=0&&hnow<H&&wnow>=0&&wnow<W){
                    if(S[hnow][wnow]!='.'){
                        goal[k]={hnow,wnow};
                        break;
                    }
                    hnow+=dh[k];
                    wnow+=dw[k];
                }
            }
            
            for(int i=0;i<4;i++){
                if(goal[i].first==-3) continue;
                for(int j=0;j<4;j++){
                    if(goal[j].first==-3) continue;
                    if(i==j) continue;
                    if(S[goal[i].first][goal[i].second]==S[goal[j].first][goal[j].second]&&S[goal[i].first][goal[i].second]!='.'){
                        ans+=2;
                        S[goal[i].first][goal[i].second]='.';
                        S[goal[j].first][goal[j].second]='.';
                        goal[i].first=-3;
                        goal[j].first=-3;
                        
                        ok=true;
                        
                        break;
                    }
                }
            }
        }
        if(!ok) break;
    }
    
    cout<<ans<<endl;
}




Measured memory_bytes: 3848
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <set>
#include <map>
#include <cassert>

using namespace std;
using ll = long long;

int main()
{
    string s;
    cin >> s;
    if(s == "SUN") cout << 7 << endl;
    else if(s == "MON") cout << 6 << endl;
    else if(s == "TUE") cout << 5 << endl;
    else if(s == "WED") cout << 4 << endl;
    else if(s == "THU") cout << 3 << endl;
    else if(s == "FRI") cout << 2 << endl;
    else if(s == "SAT") cout << 1 << endl;
    return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int gcd(int a, int b) {  
  return b != 0 ? gcd(b, a % b) : a;
}//MAX
int lcm(int a, int b) { 
   return a * b / gcd(a, b);
   }
//MIN

 main() {
 int h,w;
 cin >> h >> w;
vector<string>s(h);
for(int i=0;i<h;i++){
    cin >> s.at(i);
    for(int j=0;j<2;j++){
        cout << s.at(i)<<endl;
    }
}
 }


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ;
char a[10010]; 
bool c, f;
int main() {
    scanf("%s", a);
    for(int i=0; i<strlen(a); i++) {
        if(a[i]=='C') c=true;
        if(a[i]=='F'&&c==true) f=true; 
    }
    if(f==true) printf("Yes\n");
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>

using namespace std;

int main(int argc, char const *argv[])
{
    int W, H, x, y;
    cin >> W >> H >> x >> y;

    cout << fixed << setprecision(12) << (double)W * (double)H / 2.0 << ' ';

    int other = 0;
    if ((double)x == (double)W / 2.0 && (double)y == (double)H / 2)
    {
        other++;
    }
    
    cout << other << endl;

    return 0;
}

Measured memory_bytes: 256
R, C, K = map(int, input().split())
dp0 = [[0]*(R+1) for _ in range(C+1)]
dp1 = [[0]*(R+1) for _ in range(C+1)]
dp2 = [[0]*(R+1) for _ in range(C+1)]
dp3 = [[0]*(R+1) for _ in range(C+1)]
val = [[0]*(R+1) for _ in range(C+1)]

for i in range(K):
    r, c, v = map(int, input().split())
    val[c][r] = v

for i in range(1, C+1):
    for j in range(1, R+1):
        temp = max(dp0[i][j-1], dp1[i][j-1])
        temp = max(dp2[i][j-1], temp)
        temp = max(dp3[i][j-1], temp)
        dp0[i][j] = max(temp, dp0[i-1][j])
        if val[i][j]>0:
            dp1[i][j] = max(dp0[i-1][j]+val[i][j], dp1[i-1][j],temp+val[i][j])
            dp2[i][j] = max(dp1[i-1][j]+val[i][j], dp2[i-1][j])
            dp3[i][j] = max(dp2[i-1][j]+val[i][j], dp3[i-1][j])
        else:
            dp1[i][j] = dp1[i-1][j]
            dp2[i][j] = dp2[i-1][j]
            dp3[i][j] = dp3[i-1][j]

print(max(dp0[-1][-1], dp1[-1][-1], dp2[-1][-1],dp3[-1][-1]))

Measured memory_bytes: 432232
//by yjz
#include<bits/stdc++.h>
using namespace std;
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
#define bged(v) (v).begin(),(v).end()
#define foreach(it,s) for(__typeof((s).begin()) it=(s).begin();it!=(s).end();it++)
typedef long long ll;
const int Imx=2147483647;
const ll Lbig=2e18;
const int mod=1e9+7;
//My i/o stream
struct fastio
{
	char s[100000];
	int it,len;
	fastio(){it=len=0;}
	inline char get()
	{
		if(it<len)return s[it++];it=0;
		len=fread(s,1,100000,stdin);
		if(len==0)return EOF;else return s[it++];
	}
	bool notend()
	{
		char c=get();
		while(c==' '||c=='\n')c=get();
		if(it>0)it--;
		return c!=EOF;
	}
}_buff;
#define geti(x) x=getnum()
#define getii(x,y) geti(x),geti(y)
#define getiii(x,y,z) getii(x,y),geti(z)
#define puti(x) putnum(x),putchar(' ')
#define putii(x,y) puti(x),puti(y)
#define putiii(x,y,z) putii(x,y),puti(z)
#define putsi(x) putnum(x),putchar('\n')
#define putsii(x,y) puti(x),putsi(y)
#define putsiii(x,y,z) putii(x,y),putsi(z)
inline ll getnum()
{
	ll r=0;bool ng=0;char c;c=_buff.get();
	while(c!='-'&&(c<'0'||c>'9'))c=_buff.get();
	if(c=='-')ng=1,c=_buff.get();
	while(c>='0'&&c<='9')r=r*10+c-'0',c=_buff.get();
	return ng?-r:r;
}
template<class T> inline void putnum(T x)
{
	if(x<0)putchar('-'),x=-x;
	register short a[20]={},sz=0;
	while(x)a[sz++]=x%10,x/=10;
	if(sz==0)putchar('0');
	for(int i=sz-1;i>=0;i--)putchar('0'+a[i]);
}
inline char getreal(){char c=_buff.get();while(c<=32)c=_buff.get();return c;}
int n,m;
char s[100111];
int a[100111];
vector<int> con[100111];
ll sum;
bool vis[100111];
void dfs(int x)
{
	vis[x]=1;
	sum+=a[x];
	for(int i=0;i<con[x].size();i++)
	{
		int u=con[x][i];
		if(!vis[u])dfs(u);
	}
}
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	for(int i=0;i<=n;i++)a[i]=((s[i+1]-s[i])%26+26)%26;
	scanf("%d",&m);
	for(int i=1;i<=m;i++)
	{
		int l,r;
		scanf("%d%d",&l,&r);
		con[l-1].PB(r);
		con[r].PB(l-1);
	}
	for(int i=0;i<=n;i++)
	{
		con[i].PB(n-i);
	}
	for(int i=0;i<=n;i++)
	{
		if(!vis[i])
		{
			sum=0;
			dfs(i);
			if(sum%26!=0)
			{
				puts("NO");
				return 0;
			}
		}
	}
	puts("YES");
	return 0;
}


Measured memory_bytes: 8064
#include <stdio.h>
#include<string.h>
int main()
{
	while(1){
		char record[101]={};
		int a=0,b=0;
		scanf("%s",record);
		if(record[0]!='A'&&record[0]!='B')
			break;
		for(int i=1;i<strlen(record);i++){
			if(record[i]=='A')
				a++;
			else
				b++;
		}
		if(a>b)
			a++;
		else if(b>a)
			b++;
		printf("%d %d\n",a,b);
	}
	return 0;
}

Measured memory_bytes: 964
a,b,c,d = map(int,input().split())

for i in range(1,202):
	if i/2 % 1 :
		c = c-b
	else:
		a = a-d
	
	if a <= 0:
		print('No')
		break
	elif c <= 0:
		print('Yes')
		break



	
	

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

int main() {
  int N;
  cin >> N;
  vector<int> v (N);
  for (int i = 0; i < N; i++) {
    int a;
    cin >> a;
    v.at(i) = a - 1;
  }
  vector<int> w (N);
  int x = 0;
  for (int i =  0; i < N; i++) {
    w.at(i) = x;
    x = v.at(x);
  }
  for (int i = 0; i < N; i++) {
    if (w.at(i) == 1) {
      cout << i << endl;
      break;
    }
    if (i == N-1) {
      cout << -1 << endl;
    }
  }
}

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

using LL = long long;

#define ALL(a) begin((a)), end((a))
#define FOR(i, a, b) for (int(i) = (a); (i) < (b); (i)++)
#define debug(x) cout << #x << " : " << x << '\n'

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

  int ans;
  string S;
  cin >> S;
  LL K;
  cin >> K;

  int i;
  for (i = 0; i < 100; i++) {
    if ((i + 1) == K) {
      break;
    }

    if (S[i] == '1') {
      continue;
    } else {
      break;
    }
  }

  cout << S[i] << '\n';

  return 0;
}

Measured memory_bytes: 256