akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define _GLIACXX_DEAUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;

int		main(void)
{
	int N;
	cin >> N;
	vector<vector<int>> A(N, vector<int>(26));
	for (int i = 0; i < N; i++)
	{
		string S;
		cin >> S;
		for (int j = 0; S[j]; j++)
			A[i][S[j] - 'a']++;
	}
	for (int i = 0; i < 26; i++)
	{
		int C = 1e9;
		for (int j = 0; j < N; j++)
			C = min(C, A[j][i]);
		for (int j = 0; j < C; j++)
			cout << (char)(i + 'a');
	}
	cout << endl;
}


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


int main(void){
    int h,w;
    cin >> h >> w;
    int count = 0;
    vector<vector<bool>> grid(h+2, vector<bool>(w+2, false));
    for(int i=1; i<=h; i++){
        for(int j=1; j<=w; j++){
            char c;
            cin >> c;
            if(c == '.'){
                grid[i][j] = true;
            }else{
                count++;
            }
        }
    }
    queue<tuple<int,int,int>> que;
    vector<pair<int,int>> v = {{-1,0}, {0,-1}, {1,0}, {0,1}};
    for(auto i : v){
        que.push(make_tuple(1 + i.first, 1 + i.second, 2));
    }
    while(!que.empty()){
        tuple<int,int,int> tp = que.front();
        que.pop();
        int x = get<0>(tp), y = get<1>(tp), c = get<2>(tp);
        if(!grid[x][y]){
            continue;
        }
        if(x == h && y == w){
            cout << h * w - count - c << endl;
            return 0;
        }
        grid[x][y] = false;
        for(auto i : v){
            que.push(make_tuple(x + i.first, y + i.second, c + 1));
        }
    }

    cout << -1 << endl;    

    return 0;
}

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

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

int main()
{
    int64_t a, b, k;
    cin >> a >> b >> k;
    int64_t d = min(a, k);
    a -= d;
    k -= d;
    b -= min(b, k);
    cout << a << " " << b << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int t;
  cin >> t;
  string str[t + 1];
  unordered_set<string>st;
  for(int i = 0; i < t; ++i)
  {
    cin >> str[i];
    st.insert(str[i]);
  }
  cout << st.size() << endl;
}

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

#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for(int i=a; i<b; i++)
typedef long long ll;

#define N 100005
int n;
ll a[N*2];

int src(int i, ll sz){
	// if(a[2*n]-a[i]<sz) return 2*n;
	int mi=i, mx=2*n; //mi->g mx=le
	while(mx-mi>1){
		int md=(mi+mx)/2;
		if(a[md]-a[i]<sz){
			mi=md;
		}else{
			mx=md;
		}
	}
	// printf("(%d, %lld)=%d\n", i, sz, mx);
	return mx;
}

int main(){
	scanf("%d", &n);
	REP(i, n){
		scanf("%lld", a+i+1);
	}
	REP(i, n) a[n+i+1]=a[i+1];
	a[0]=0;
	REP(i, 2*n) a[i+1]+=a[i];
	ll mi=0, mx=a[2*n]; //mi->ok mx->ng
	// while(1){
	// 	int i; ll s;
	// 	scanf("%d%lld", &i, &s);
	// 	printf("%d\n", src(i, s));
	// }
	while(mx-mi>1){
		ll md=(mi+mx)/2;
		REP(i, n){
			int j=src(i, md);
			int k=src(j, md);
			if(a[i+n]-a[k]>=md){
				mi=md;
				goto end;
			}
		}
		mx=md;
end:;
	}
	printf("%lld\n", mi);
}

Measured memory_bytes: 4784
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main() {
   ll n;cin>>n;
   string s;cin>>s;ll cnt=0;
   for(int i=2;i<n;i++){
       if(s[i-2]=='A' && s[i-1]=='B' && s[i]=='C')cnt++;
   }
   cout<<cnt;
}

Measured memory_bytes: 256
import java.util.Scanner;

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

		System.out.println(a / b + " " + a % b + " " + String.format("%.8f", (double)a / (double)b));
	}
}



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

using namespace std;

int n;
int v[2010];
int main() {
    cin >> n;

    for (int i = 0; i < n; ++i)
        cin >> v[i];

    sort(v, v + n);
    int ans = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i + 1; j < n; ++j) {
            int pos = upper_bound(v, v + n, v[j] - v[i]) - v;
            ans += max(0, i - pos);
        }
    }
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define IO std::ios_base::sync_with_stdio(false); std::cin.tie(NULL); std::cout.tie(NULL);
#define FIN freopen("entrada.txt", "r", stdin);
#define FOUT freopen("saida.sol", "w", stdout);

#define ull unsigned long long
#define ll long long
#define pii pair<int, int>
#define pb push_back
#define MAX int(1e9+6)

const int INF = 0x3f3f3f3f;
using namespace std;



int main() {

   IO

   string s;

   cin >> s;

   for(int i=0; i<s.size(); i++) {
      if(s[i]=='?') {
//         if(s[i-1]=='P') {
//            s[i]='D';
//            continue;
//         }
//         if(s[i-1]=='D' &&) {
//            s[i]
//         }
         s[i]='D';
      }
   }

   cout << s << "\n";

   return 0;
}


Measured memory_bytes: 3784
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

using namespace std;

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

	int A, B;
	cin >> A >> B;

	if (A <= 9 && B <= 9)
	{
		cout << A * B;
	}
	else
	{
		cout << "-1";
	}

	return 0;
}


Measured memory_bytes: 3568
#include <iostream>
#include <cassert>
#include <iomanip>
#include <utility>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <algorithm>
#include <queue>
#include <string>

using namespace std;

typedef long long ll;
typedef pair<int, int> p_i;

#define rep(i, n) for (int i = 0; i < n; i++)
#define repext(i, a, b) for (int i = a; i < b; i++)
#define reprev(i, n) for (int i = n - 1; i >= 0; i--)
#define repextrev(i, a, b) for (int i = b - 1; i >= a; i--)

#define vec_all(vec) vec.begin(), vec.end()
#define sum(vec) accumulate(vec_all(vec), 0)
#define srt(vec) sort(vec_all(vec))

// vectorデバッグ
template <typename T>
void dump_vec(vector<T> vec)
{
    rep(i, vec.size())
    {
        cout << i << ": " << vec[i] << endl;
    }
}

// --- notice ---
// intの和はllにしろ

int main()
{
    int n, m;
    cin >> n >> m;
    vector<int> x(m);
    rep(i, m) {
        cin >> x[i];
    }

    srt(x);

    vector<int> d(m - 1);
    rep(i, m - 1) {
        d[i] = x[i + 1] - x[i];
    }

    srt(d);

    ll sum = 0;
    rep(i, m - n) {
        sum += d[i];
    }

    cout << sum << endl;

    return 0;
}

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

int main()
{
    size_t N, Q;
    cin >> N >> Q;
    atcoder::dsu dsu(N);

    int t, u, v;
    for (size_t i = 0; i < Q; i++)
    {
        cin >> t >> u >> v;
        if (t == 0)
        {
            dsu.merge(u, v);
        }
        else
        {
            cout << dsu.same(u, v) << endl;
        }
    }
}


Measured memory_bytes: 4088
def prime(t):
    i=2
    while i**2<=t:
        if t%i==0:
            return 0
        i+=1
    return 1
l=[]
for i in range(2,104740):
    if prime(i):
        l.append(i)
while 1:
    n=int(raw_input())
    if n==0:
        break
    ans=0
    while n>0:
        n-=1
        ans+=l[n]
    print ans

Measured memory_bytes: 9632
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define rep1(i,n)for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=(int)(n)-1;0<=i;i--)
#define rrep1(i,n) for(int i=(int)(n);1<=i;i--)

#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define all(obj) (obj).begin(),(obj).end() 

#define pcount __builtin_popcount
#define SZ(x) ((int)(x).size())
#define LEN(x) ((int)(x).length())

#define dump(x)  cerr << #x << " = " << (x) << endl;

#define endl "\n"

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

typedef long long lint;

using namespace std;
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin>>n;
	vector<string>w(n);
	rep(i,n)cin>>w[i];
	rep(i,n){
		if(i==0)continue;
		if(w[i].at(0)!=w[i-1].at(LEN(w[i-1])-1)){
			cout<<"No"<<endl;
			return 0;
		}
		rep(j,n){
			if(w[i]==w[j]&&i!=j){
				cout<<"No"<<endl;
				return 0;
			}
		}
	}
	cout<<"Yes"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<cmath>
#include<vector>
using namespace std;
//  n, k;
#define loop(i, start, end) for(int i = start; i < end; i++)
#define ll long long int
#define pb push_back
vector<ll> weight, value;
ll n, w;
int main(){
	int n;
	cin>>n;
	int h[n];
	for(int i=0;i<n;i++)
	    cin>>h[i];
    int dp[n];
	
    dp[0] = 0;
    dp[1] = abs(h[1]-h[0]);
	for(int i=2;i<n;i++){
        dp[i] = min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
	}
	cout<<dp[n-1];
	return 0;
}

Measured memory_bytes: 1024
main = do
    [a,b,c,d] <- map read . words <$> getLine :: IO [Integer]
    let ab = b-a+1
    let c' = (div b c) - (div (a-1) c)
    let d' = (div b d) - (div (a-1) d)
    let cd' = (div b (lcm c d)) - (div (a-1) (lcm c d))
    print $ ab-(c'+d'-cd')

Measured memory_bytes: 4056
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(dead_code)]

fn main() {
    let (N, T): (usize, usize) = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        let mut iter = line.split_whitespace();
        (
            iter.next().unwrap().parse().unwrap(),
            iter.next().unwrap().parse().unwrap()
        )
    };
    let t: Vec<usize> = {
        let mut line: String = String::new();
        std::io::stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|x| x.parse().unwrap())
            .collect()
    };

    let (res, _) = t[1..]
        .iter()
        .fold((0, t[0]), |(res, prev), &x| (res + std::cmp::min(T, x - prev), x));
    let ans = res + T;

    println!("{}", ans);
}


Measured memory_bytes: 10492
N = int(input())
X = list(map(int, input().split()))
P = [p for p in range(1, max(X) + 1)]
min = 0
energy = 0

for x in X:
    min += (1 - x) ** 2

for p in P:
    for x in X:
        energy += (x - p) ** 2

    if energy < min:
        min = energy
    energy = 0
print(min)

Measured memory_bytes: 63536
#include <bits/stdc++.h>
using namespace std;
int A[3];
int main()
{
        for (size_t i = 0; i < 3; i++) {
                /* code */
                scanf("%d\n",&A[i] );
        }
        sort(A,A+3);
        printf("%d\n",A[2]-A[0] );
        return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
//#define mt make_tuple
//typedef tuple<double,int,double> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf=sizeof(Def)==sizeof(long long)?9e18:1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int a,b,c;
	cin>>a>>b>>c;
	cout<<(a^b^c)<<endl;
}









Measured memory_bytes: 256
#!/usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from bisect import bisect_left, bisect_right
import sys, random, itertools, math
sys.setrecursionlimit(10**5)
input = sys.stdin.readline
sqrt = math.sqrt
def LI(): return list(map(int, input().split()))
def LF(): return list(map(float, input().split()))
def LI_(): return list(map(lambda x: int(x)-1, input().split()))
def II(): return int(input())
def IF(): return float(input())
def S(): return input().rstrip()
def LS(): return S().split()
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#solve
def solve():
    h, m, g, m2, k = LI()
    hm = h * 60 + m
    gm = g * 60 + m2
    print(max(0, gm - hm - k))
    return


#main
if __name__ == '__main__':
    solve()


Measured memory_bytes: 76768
import sys
def input():
    return sys.stdin.readline()[:-1]


def main():

  n = int(input())

  a = list(map(int, input().split()))
  b = list(map(int, input().split()))

  d = 0
  for i in range(n):
    if a[i] >= b[i]:
      d += b[i]

    else:
      d += a[i]
      b[i] = b[i] - a[i]

      if a[i+1] - b[i] >= 0:
        d += b[i]
        a[i+1] = a[i+1] - b[i]

      else:
        d += a[i+1]
        a[i+1] = 0


  print(d)


if __name__ == '__main__':
    main()

Measured memory_bytes: 76416
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

n = int(read())


def check(s):
    if len(s) == n:
        print(s)
    else:
        for i in range(97, ord(max(s)) + 2):
            check(s + chr(i))


check('a')


Measured memory_bytes: 4340
xy = list(map(int, input().split()))

x = xy[0]
y = xy[1]

if x == 1 and y == 1:
	ans = 400000
else:
	ans = 0

if x == 1:
	ans += 300000
if y == 1:
	ans += 300000
if x == 2:
	ans += 200000
if y == 2:
	ans += 200000
if x == 3:
	ans += 100000
if y == 3:
	ans += 100000

print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <math.h>

#define ll long long
#define ull unsigned long long

using namespace std;

const int inf = 1000000000;
const double eps = 1e-7;

void solve() {
	int n, m;
	cin >> n >> m;
	vector<string> a(n);
	for (int i = 0; i < n; ++i)
		cin >> a[i];
	
	vector<vector<int>> d(n, vector<int>(m, inf));
	deque<pair<int, int>> q;
	q.push_back({0, 0});
	d[0][0] = (a[0][0] == '#');
	while (!q.empty()) {
		int x = q.front().first;
		int y = q.front().second;
		q.pop_front();
		if (x + 1 < n) {
			int tx = x + 1;
			int ty = y;
			int w = (a[tx][ty] != a[x][y]);
			if (d[x][y] + w < d[tx][ty]) {
				if (w)
					q.push_back({tx, ty});
				else
					q.push_front({tx, ty});
				d[tx][ty] = d[x][y] + w;
			}
		}
		if (y + 1 < m) {
			int tx = x;
			int ty = y + 1;
			int w = (a[tx][ty] != a[x][y]);
			if (d[x][y] + w < d[tx][ty]) {
				if (w)
					q.push_back({tx, ty});
				else
					q.push_front({tx, ty});
				d[tx][ty] = d[x][y] + w;
			}
		}
	}
	
	cout << (d[n - 1][m - 1] + 1) / 2 << endl;
}

int main() {
	int t = 1;
	//cin >> t;
	for (int i = 0; i < t; ++i)
		solve();
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define re register
#define int long long
using namespace std;

inline int read(){
	re int ans = 0;re bool f = 1;re char ch = getchar();
	while(ch<'0'||ch>'9'){if (ch=='-')f = 0;ch = getchar();}
	while(ch>='0'&&ch<='9'){
		ans = (ans<<3)+(ans<<1)+(ch^48);
		ch = getchar();
	}
	return f?ans:~(ans-1);
}

signed main(void){
	int a,b,c;
	a = read(),b = read(),c = read();
	if((4*a*b)<((c-a-b)*(c-a-b))&&(c-a-b)>0)printf("Yes\n");
	else printf("No\n");
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <vector>
#include <string>

using namespace std;

int main(void)
{
    int n;
    cin >>n;

    vector<int> v;
    for(int i = 0; i < n; i++){
        int tmp;
        cin >>tmp;
        v.push_back(tmp);
    }

    sort(v.begin(), v.end());

    double ans = v[0];
    for(int i = 1; i < n; i++){
        ans = (ans + v[i]) / 2;
    }

    printf("%.10lf\n", ans);

    return 0;
}

Measured memory_bytes: 256
H, W = map(int,input().split())
HW = [input() for _ in range(H)]
HW = [''.join(hw) for hw in zip(*HW) if hw.count('#') > 0]
HW = [''.join(hw) for hw in zip(*HW) if hw.count('#') > 0]
print('\n'.join(HW))

Measured memory_bytes: 3060
#![allow(non_snake_case)]
#![allow(unused_imports)]
use proconio::input;
use std::cmp::max;
// use std::cmp::min;
// use std::collections::HashMap;
// use std::collections::VecDeque;

// a^n % m
fn mod_pow(a: i64, n: u32, m: i64) -> i64 {
    if n == 0 {
        return 1;
    }

    if n == 1 {
        return a % m;
    }

    if n % 2 == 1 {
        let k = mod_pow(a, (n - 1) / 2, m);
        let mut ans = (a * k) % m;
        ans = (ans * k) % m;
        return ans;
    } else {
        let k = mod_pow(a, n / 2, m);
        let ans = (k * k) % m;
        return ans;
    }
}

// O(N^2)の解法しか思い浮かばなかったので答えを見た
fn main() {
    input! {
        X: usize,
        Y: usize,
    }

    const MOD: i64 = 1000_000_000 + 7;
    if (X + Y) % 3 != 0 {
        println!("0");
        return;
    }

    // n + 2m = X, 2n + m = Yより、
    // 3n + 3m = X + Y
    // n + m = (X + Y) / 3

    // m = X - (X+Y) / 3 = (2X - Y) / 3
    // n = Y - (X+Y) / 3 = (-X + 2Y) / 3

    // O(N^2)だと間に合わない
    // カウントをテーブルで持っておきつつ幅優先みたいな感じで広げていけば間に合うか?
    // ダメー。

    if 2 * X < Y || 2 * Y < X {
        println!("0");
        return;
    }

    let M = 2 * X - Y;
    let N = 2 * Y - X;
    if M % 3 != 0 || N % 3 != 0 {
        println!("0");
        return;
    }

    let n: usize = N / 3;
    let m: usize = M / 3;

    let mut fact_memo: Vec<i64> = vec![0; n + m + 1];
    fact_memo[0] = 1;
    fact_memo[1] = 1;
    for i in 2..n + m + 1 {
        fact_memo[i] = (fact_memo[i - 1] * i as i64) % MOD;
    }

    let fact_n = fact_memo[n];

    // a * a^(p-2) = 1 (mod p)
    // (MOD - 2) 乗を愚直に計算するとだめ
    let fact_inv_n = mod_pow(fact_n, (MOD - 2) as u32, MOD);

    let fact_m = fact_memo[m];
    // a * a^(p-2) = 1 (mod p)
    let fact_inv_m = mod_pow(fact_m, (MOD - 2) as u32, MOD);

    let mut ans = (fact_memo[n + m] * fact_inv_n) % MOD;
    ans = (ans * fact_inv_m) % MOD;

    println!("{}", ans);
}


Measured memory_bytes: 7340
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>
/*#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
#pragma GCC target("avx2")  //Enable AVX*/

using namespace std;

using ll = long long;

#define mp make_pair

const int p = 1000000007;


int mul(int a, int b) {
    return (1LL * a * b) % p;
}

int add(int a, int b) {
    int s = (a+b);
    if (s>=p) s-=p;
    return s;
}

int sub(int a, int b) {
    int s = (a+p-b);
    if (s>=p) s-=p;
    return s;
}

int po(int a, int deg)
{
    if (deg==0) return 1;
    if (deg%2==1) return mul(a, po(a, deg-1));
    int t = po(a, deg/2);
    return mul(t, t);
}

int inv(int n)
{
    return po(n, p-2);
}

/*struct DSU {
    vector<int> sz;
    vector<int> parent;

    void make_set(int v) {
        parent[v] = v;
        sz[v] = 1;
    }

    int find_set(int v) {
        if (v == parent[v])
            return v;
        return parent[v] = find_set(parent[v]);
    }

    void union_sets(int a, int b) {
        a = find_set(a);
        b = find_set(b);
        if (a != b) {
            if (sz[a] < sz[b])
                swap(a, b);
            parent[b] = a;
            sz[a] += sz[b];
        }
    }

    DSU(int n) {
        sz.resize(n);
        parent.resize(n);
        for (int i = 0; i < n; i++) make_set(i);
    }
};*/

/*const int N = 1000000;

vector<int> facs(N), invfacs(N);

void init()
{
    facs[0] = 1;
    for (int i = 1; i<N; i++) facs[i] = mul(facs[i-1], i);
    invfacs[N-1] = inv(facs[N-1]);
    for (int i = N-2; i>=0; i--) invfacs[i] = mul(invfacs[i+1], i+1);
}

int C(int n, int k)
{
    return mul(facs[n], mul(invfacs[k], invfacs[n-k]));
}*/

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

    string s;
    cin>>s;
    if (s[2]==s[3]&&s[4]==s[5]) cout<<"Yes"; else cout<<"No";




}


/*
1
5
4 1 3
1 5 2
2 5 1
3 5 2

 1
 4
 1 2 0
 3 4 0
 1 4 5

 */

Measured memory_bytes: 256
A, B = list(map(int, input().split()))
a = "Alice"
b = "Bob"
d = "Draw"
if A == B:
  print(d)
  exit()
if A == 1:
  print(a)
  exit()
if B == 1:
  print(b)
  exit()
if A > B:
  print(a)
else:
  print(b)



Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
bool contains(vector<int> &adj, int M){
  if(find(adj.begin(),adj.end(),M)!=adj.end()) return true;
  else return false;
}

int main(){
  int N,M;
  int a,b;
  cin>>N>>M;
  vector<vector<int> > adj(N+1);
  for(int i=0;i<M;i++){
    cin>>a>>b;
    adj[a].push_back(b);
  }
  if(contains(adj[1],N)) {
    cout<<"POSSIBLE"<<endl;
    return 0;
  }else{
    for(int c: adj[1]){
      if(contains(adj[c],N)) {
        cout<<"POSSIBLE"<<endl;
        return 0;
      }
    }
    cout<<"IMPOSSIBLE"<<endl;
  }
  return 0;
}

Measured memory_bytes: 8576
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<stack>
#include<queue>
#include<sstream>
#include<string>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i);

using namespace std;
int main(){

  while(1){
    int r,n;
    cin >> r >> n;
    if(r==0&&n==0) break;
    int field[41]={};
    int *hs = &field[20];

    rep(i,n){
      int x1,x2,h;
      cin >> x1 >> x2 >> h;
      REP(j,x1,x2) hs[j]=max(hs[j],h);
    }
    
    double ans = 1e15;
    for(int i=-r;i<r;i++){
      double x;
      if(i<0) x = i+1;
      else x = i;
      ans = min(ans,r-sqrt(r*r-x*x)+hs[i]);
    }
    
    cout << ans << endl;
  }

}

Measured memory_bytes: 1228
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define ssort(n) sort((n).begin(),(n).end())
using ll=long long;
using ld=long double;
typedef pair<int,int> P;

void solve()
{
    string s,t;
    cin >> s >> t;
    sort(s.begin(),s.end());
    sort(t.begin(),t.end(),greater<char>());
    if(s<t){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }

}

int main(){
    int t;
    t=1;
    rep(i,t){
        solve();
    }
}

Measured memory_bytes: 256
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int num = in.nextInt();
		int cltopping[] = new int [num];
		int prdough = in.nextInt();
		int prtopping = in.nextInt();
		int cldough = in.nextInt();
		for(int i = 0; i < num; i++){
			cltopping[i] = in.nextInt();
		}
		Arrays.sort(cltopping);
	if(num == 1){
			System.out.println( ((cldough + cltopping[0]) / (prdough + prtopping)));
		}
		else{
			int sum = 0;
			for(int i = 2; i <= num; i++){
				int totalcltp = 0;
				int totalcl = 0;
				int clperdol = 0;
				for(int k = 0; k < i; k++){
					totalcltp += cltopping[num - 1 - k];
				}
				totalcl = totalcltp + cldough;
				clperdol = totalcl / (i * prtopping + prdough);
				if(sum < clperdol){
					sum = clperdol;
				}	
			}
			System.out.println(sum);
		}
	
	}
}

Measured memory_bytes: 18116
/* ex4_2
  bonbonc */

#include<stdio.h>
#include<math.h>
int main(void){
	int length_hours,length_minutes,hours,minutes;
	double theta_hours,theta_minutes;
	scanf("%d%d%d%d",&length_hours,&length_minutes,&hours,&minutes);
	
	theta_hours = (double)((hours+(double)minutes/60)*(M_PI/6));//時針の回転角（ラジアン）
	theta_minutes = (double)(minutes*(M_PI/30));//分針の回転角（ラジアン）
	
	printf("%.20lf\n",sqrt(pow((double)length_hours,2.0)+pow((double)length_minutes,2.0)-(double)(2*length_hours*length_minutes*cos(theta_hours-theta_minutes))));
	//余弦定理で時針と分針の先の距離を計算して出力。
	return 0;
}

Measured memory_bytes: 2608
n = int(input())
a = list(map(int,input().split()))
c = [10**9]*n
c[0]=0
c[1]=abs(a[0]-a[1])
for i in range(n-1):
    for j in range(i+1,min(n,i+2+1)):
        c[j] = min(c[j],c[i]+abs(a[i]-a[j]))
print(c[n-1])

Measured memory_bytes: 52208
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>
#include <set>
#include <cstdlib>
#include <queue>

using namespace std;

typedef long long llint;
typedef long double ld;

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

int n;
llint a[100005][3];
llint dp[100005][3];
void solve(){
  cin >> n;
  for(int i=0;i<n;i++){
    for(int j=0;j<3;j++)cin >> a[i][j];
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<3;j++){
      for(int k=0;k<3;k++){
        if(j==k)continue;
        chmax(dp[i+1][k],dp[i][j]+a[i][k]);
      }
    }
  }
  llint ans=0;
  for(int i=0;i<3;i++)chmax(ans,dp[n][i]);
  cout << ans << endl;
}

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


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

using ll = long long;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n;
  cin >> n;
  
  vector<ll> a(n), b(n);
  ll asum = 0, bsum = 0;
  for(int i = 0; i < n; i++){
    cin >> a.at(i);
    asum += a.at(i);
  }
  for(int i = 0; i < n; i++){
    cin >> b.at(i);
    bsum += b.at(i);
  }
  
  if(asum < bsum){
    cout << -1 << '\n';
    return 0;
  }
  
  priority_queue<ll> pq;
  ll lack = 0, ans = 0;
  for(int i = 0; i < n; i++){
    if(a.at(i) < b.at(i)){
      lack += b.at(i) - a.at(i);
      ans++;
    }
    else if(a.at(i) > b.at(i)){
      pq.push(a.at(i) - b.at(i));
    }
  }
  
  while(lack > 0){
    lack -= pq.top();
    pq.pop();
    ans++;
  }
  
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 2428
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B;
  cin>>A>>B;
  int AB;
  if(B<=9) AB=A*10+B;
  else if (B<=99) AB=A*100+B;
  else AB=A*1000+100;
  bool ans=false;
  for(int i=1;i<AB;i++){
    if(i*i==AB){
      ans=true;
    }
    if(i*i>AB){
      break;
    }
  }
  if(ans) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}

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

int main(){
  int a,b,c,k;
  cin>>a>>b>>c>>k;
  if(k<=a){
    cout<<k;
    return 0;
  }else if(k<=a+b){
    cout<<a;
    return 0;
  }else{
    cout<<a-(k-a-b);
  }
}



Measured memory_bytes: 3672
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			Scanner cin = new Scanner();
			int n = cin.Int();
			string s = cin.Next();

			var ss = s.ToList();
			int index = 0;
			int lcnt = 0;
			int rcnt = 0;
			while (index < ss.Count()) {
				if (ss[index] == '(') {
					++lcnt;
				} else {
					++rcnt;
					if (rcnt > lcnt) {
						ss.Insert(0, '(');
						++lcnt;
						++index;
					}
				}

				++index;
			}

			int remain = lcnt - rcnt;
			for (int i = 0; i < remain; i++) {
				ss.Add(')');
			}

			string ans = new string(ss.ToArray());
			Console.WriteLine(ans);
		}
	}

	public class Scanner
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private string[] buf_;
		private int index_;

		public Scanner()
		{
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = Console.ReadLine();
			while (st == "") {
				st = Console.ReadLine();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}
	}
}

Measured memory_bytes: 13268
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
template< typename FirstType, typename SecondType >
struct PairComparator {
  bool operator()( const pair<FirstType, SecondType>& p1, const pair<FirstType, SecondType>& p2 ) const 
    {  
		return p1.first > p2.first;
    }
};
bool inMST(vector< std::pair<int,int> > & MST,int j) {
	for (int k=0;k<(int)MST.size();++k){
		if(j == MST[k].second)
			return true;
	}
	return false;
}
int main(){
	int n;
	cin >> n;
	vector<int> E(n*n);
	vector< std::pair<int,int> > MST;

	for(int k=0;k<n*n;++k) {
		cin >> E[k];
	}
	priority_queue<pair<int,pair<int,int> >,vector< pair<int,pair<int,int> > >,
		PairComparator<int,pair<int,int> > > r;

	//put Node 0
	int cost = 0;
	int i=0;
	MST.push_back(pair<int,int>(i,i));
	while((int)MST.size() < n) {
		int ii=i*n;
		for (int j=0;j<n;++j) {
			if (E[ii+j] >= 0) {
				pair<int,int> add = std::make_pair(i,j);
				if (!inMST(MST,add.second)){
					r.push(std::pair<int,std::pair<int,int> >(E[ii+j],add));
				}
			}
		}
		pair<int,pair<int,int> > top;
		while (!r.empty()) {
			top = r.top();
			r.pop();
			if (!inMST(MST,top.second.second)){
				break;
			}
		}
		cost += top.first;
		MST.push_back(top.second);
		i = top.second.second;
	}
	cout << cost << endl;
}

Measured memory_bytes: 1328
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <list>
#include <stack>
#include <unordered_set>
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1LL << 50;
static const int NIL = -1;
static const int MOD = 1000000007;
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define REP(i, n) for(int i = 0; i < (n); ++i)
#define SORT(v) sort(v.begin(), v.end());
#define pb push_back
#define mp make_pair
#define np next_permutation
#define pq priority_queue
 
int gcd(int a, int b) { int c; while (b != 0) { c = a%b; a = b; b = c; }return a; }
int lcm(int a, int b) { int c = gcd(a, b); a /= c; return a*b; }
int nCr(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; }return r; }
int pow(int a, int b) { int i, r = 1; for (i = 1; i <= b; i++) { r *= a; }return r; }
long long llpow(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= a; }return r; }
long long llgcd(long long a, long long b) { long long c; while (b != 0) { c = a%b; a = b; b = c; }return a; }
long long lllcm(long long a, long long b) { long long c = llgcd(a, b); a /= c; return a*b; }
long long llnCr(long long a, long long b) { long long i, r = 1; for (i = 1; i <= b; i++) { r *= (a + 1 - i); r /= i; }return r; }
 
//int dx4[4] = {0,1,0,-1}, dy4[4] = {-1,0,1,0};
//int dx5[5] = {-1,0,0,0,1}, dy5[5] = {0,-1,0,1,0};
//int dx8[8] = {-1,0,1,1,1,0,-1,-1}, dy8[8] = {1,1,1,0,-1,-1,-1,0};
//int dx9[9] = {-1,0,1,1,1,0,-1,-1,0}, dy9[9] = {1,1,1,0,-1,-1,-1,0,0};
 
struct edge{
    int from, to; ll cost;
};

int main(){
    ll n, y;
    cin >> n >> y;
    if(y % 1000 || n * 10000 < y){
        cout << "-1 -1 -1" << endl;
        return 0;
    }
    y /= 1000;
    for(int c = 0; c <= y; c++){
        if(c > n) break;
        for(int b = 0; b * 5 + c <= y; b++){
            if(b + c > n) break;
            for(int a = 0; a * 10 + b * 5 + c <= y; a++){
                if(a + b + c > n) break;
                if(a + b + c == n){
                    if(a * 10 + b * 5 + c == y){
                        cout << a << " " << b << " " << c << endl;
                        return 0;
                    }
                }
            }
        }
    }
    cout << "-1 -1 -1" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define inc(i, l, r) for (int i = l; i <= r; i++)

const int maxn = 1005;
const int mod = 1000003;

int n, k;
int dp_a[maxn][maxn], dp_b[maxn][maxn];  //一定以a开头,总长为i, 结尾是j个a/b
int sum_a[maxn], sum_b[maxn];

inline ll ksm(ll a, ll n) {
    ll r = 1;
    while (n) {
        if (n & 1) r = r * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return r;
}

int main() {
    while (cin >> n >> k && n) {
        memset(dp_a, 0, sizeof(dp_a));
        memset(dp_b, 0, sizeof(dp_b));
        dp_a[1][1] = 1;
        inc(i, 1, n - 1) {
            inc(j, 1, min(i, k)) {
                if (j + 1 <= k)
                    dp_a[i + 1][j + 1] =
                        (dp_a[i + 1][j + 1] + dp_a[i][j]) % mod;
                dp_b[i + 1][1] = (dp_b[i + 1][1] + dp_a[i][j]) % mod;
            }
            inc(j, 1, min(i - 1, k)) {
                dp_a[i + 1][1] = (dp_a[i + 1][1] + dp_b[i][j]) % mod;
                if (j + 1 <= k)
                    dp_b[i + 1][j + 1] =
                        (dp_b[i + 1][j + 1] + dp_b[i][j]) % mod;
            }
        }

        memset(sum_a, 0, sizeof(sum_a));
        memset(sum_b, 0, sizeof(sum_b));
        for (int i = 1; i <= n; i++) {
            for (int j = 1; j <= min(i, k); j++) {
                sum_a[i] = (sum_a[i] + dp_a[i][j]) % mod;
                sum_b[i] = (sum_b[i] + dp_b[i][j]) % mod;
            }
        }
        ll res = 0;
        for (int i = 1; i <= n; i++) {
            int l = __gcd(i, n);
            //循环节长度
            for (int j = 2; j <= min(k, l - 1); j++) {
                //首尾a之和
                res = (res + (j - 1) * sum_a[l - j]) % mod;
            }
            //结尾b
            res = (res + sum_b[l]) % mod;
            if (k >= n) res++;  //全a
        }
        printf("%lld\n", res * 2 * ksm((ll)n, mod - 2LL) % mod);
    }
}


Measured memory_bytes: 11116
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define pb push_back
#define ll long long


void test_case()
{
    ll n,i,j;
    cin>>n;
    long double p[n];
    for(ll i=0;i<n;i++)
        cin>>p[i];
    long double dp[n+1][n+1]={};
    dp[0][0]=1;
    for(i=1;i<=n;i++)
    {
        for(j=0;j<=n;j++)
        {
            if(i>=1)
            {
                if(j>=1)
                    dp[i][j]=p[i-1]*dp[i-1][j-1]+(1-p[i-1])*dp[i-1][j];
                else
                    dp[i][j]=(1-p[i-1])*dp[i-1][j];
            }
        }
    }
    long double sum=0;
    for(i=n/2+1;i<=n;i++)
        sum+=dp[n][i];
    cout<<setprecision(10)<<sum;
}

int main()
{
    fastio
//    int t;
//    cin>>t;
//    while(t--)
    test_case();
}


Measured memory_bytes: 140928
sn, tn, *s = map(int, open(0).read().split())
sy_oi = [[s[i * 2], s[i * 2 + 1]] for i in range(sn)]
sy_oi.sort(key=lambda x: -x[1])
cho = sy_oi[tn - 1::-1]
zan = sy_oi[tn:]
zn = sn - tn
# チョイスした種類の辞書
sydic = {}
for x in cho:
    if x[0] in sydic:
        sydic[x[0]] += 1
    else:
        sydic[x[0]] = 1
ot = sum([x[1] for x in cho])  # おいしさポイント
mt = len(sydic)  # まんぞくポイント
ans = ot + mt ** 2
ci = 0
zi = 0
while 1:
    # チョイスから削除できるものを探す
    for i in range(ci, tn):
        if sydic[cho[i][0]] > 1:
            sydic[cho[i][0]] -= 1
            ot -= cho[i][1]
            ci = i + 1
            break
    else:
        break
    # 残から加えるものを探す
    for i in range(zi, zn):
        if zan[i][0] not in sydic:
            sydic[zan[i][0]] = 1
            ot += zan[i][1]
            mt += 1
            zi = i + 1
            break
    else:
        break
    # 得点計算して更新
    ans = max(ans, ot + mt ** 2)
print(ans)


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

int main(int argc, const char * argv[]) {
    char str[5];
    
    scanf("%s", str);
    str[4] = '\0';
    if (str[0] == str[1] || str[1] == str[2] || str[2] == str[3]){
        printf("Bad\n\n");
        return 0;
    }
    printf("Good\n");
    return 0;
}


Measured memory_bytes: 128
str = {}
str["a"] = gets.chomp
str["b"] = gets.chomp
str["c"] = gets.chomp

nex = "a"
while 1 do
  break if str[nex].length == 0
  now = nex
  nex = str[now][0]
  str[now].slice!(0)
end
puts nex.upcase

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
#define REP(i, n) for(int i=0; i<n; i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll MOD = 1e9+7;


int main(){
    int N;
    cin >> N;
    vector<ll> S(N+1);
    S[0] = 0;
    REP(i,N){
        ll a;
        cin >> a;
        S[i+1] = a;
        S[i+1] += S[i];
    }

    map<ll, ll> ma;
    for(auto&& s : S){
        ma[s]++;
    }

    ll ans = 0;
    for(auto&& p : ma){
        ll cnt = p.second;
        ans += cnt*(cnt-1)/2;
    }

    cout << ans << endl;

    return 0;
}


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

using namespace std;

#define REP(i,n) for(ll (i) = (0); (i) < (n); ++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define ALL(v) v.begin(),v.end()
#define INF 1100000000
#define LLINF 1000000000000000000LL
#define MOD 1000000007
#define Decimal fixed << setpresicion(20)


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


int main()
{
  int N;
  cin >> N;
  bool odd = false;
  REP(i, N) {
    int a; cin >> a;
    if (a % 2 == 1) odd = true;
  }
  if (odd) cout << "first" << endl;
  else cout << "second" << endl;

  return 0;
}



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

using namespace std;


#define int long long


main(){

	int n; cin >> n;


	string s; cin >> s;


	int cnt = 0;

	for(int i = 1; i < n; i++){
		if(s[i] != s[i - 1]){
			cnt++;
		}
	}


	cout << cnt + 1 << endl;	
	

	return 0;
}

Measured memory_bytes: 512
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>

#define                           int                         long long
#define                           fi                          first
#define                           si                          second
#define                           mp                          make_pair
#define                           pb                          push_back
#define                           pi                          pair<int,int>
#define                           f(i,l,r)                    for(int i=l;i<=r;i++)
#define                           rf(i,r,l)                   for(int i=r;i>=l;i--)
#define                           done(i)                     cout<<"done = "<<i<<endl;
#define                           fast                        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);




using namespace std;

const int inf=1e18;
const int mod=1e9+7;
const int M=100009;

inline int bigmod(int B,int P){int R=1;while(P>0){if(P&1){R=(R*B)%mod;}P>>=1;B=(B*B)%mod;}return R;}
inline int ad(int x,int y){int ret=(x%mod+y%mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline int sub(int x,int y){int ret=((x%mod)-(y%mod)+mod)%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}
inline int gun(int x,int y){int ret=((x%mod)*(y%mod))%mod;if(ret<0){ret+=mod,ret=ret%mod;}return ret;}


 main()

{
    fast
    int a,b,c,ses=0;
    cin>>a>>b>>c;
    int tmp=min(a,c);
    a-=tmp;
    c-=tmp;
    ses+=tmp;
    tmp=min(c,b);
    c-=tmp;
    b-=tmp;
    ses+=(2*tmp);
    ses+=b;
    if(c>=1)ses++;
    cout<<ses<<endl;
    return 0;

}






































Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define fi first
#define se second
using namespace std;
const int N=2e5+10;
typedef long long ll;
typedef pair<ll,ll> pll;
int gi() {
    int x=0,o=1;char ch=getchar();
    while((ch<'0'||ch>'9')&&ch!='-') ch=getchar();
    if(ch=='-') o=-1,ch=getchar();
    while(ch>='0'&&ch<='9') x=x*10+ch-'0',ch=getchar();
    return x*o;
}
struct edge { int to,w,nxt; } e[N];
int tot=1,h[N];
void adde(int u,int v,int w) {
    e[++tot]=(edge){v,w,h[u]};h[u]=tot;
}
int n;
vector<pll> f[N];
ll mid;
void ins(int u,pll x) {
    if(!f[u].empty()&&f[u].back()<=x) return;
    while(!f[u].empty()&&f[u].back().se>=x.se) f[u].pop_back();
    f[u].pb(x);
}
bool dfs(int u) {
    f[u].clear();
    if(!h[u]) { f[u].pb(mp(0,0)); return 1; }
    int ls=0,rs=0;
    ll disl=0,disr=0;
    for(int i=h[u];i;i=e[i].nxt) {
        int v=e[i].to;
        if(!dfs(v)) return 0;
        if(!ls) ls=v,disl=e[i].w;
        else rs=v,disr=e[i].w;
    }
    ll lim=mid-disl-disr;
    if(lim<0) return 0;
    vector<pll> vl,vr;
    int pl=0,pr=0,sl=f[ls].size(),sr=f[rs].size();
    for(int i=0;i<sl;i++) {
        while(pr<sr&&f[ls][i].se+f[rs][pr].fi>lim) pr++;
        if(pr==sr) break;
        else vl.pb(mp(f[ls][i].fi+disl,f[rs][pr].se+disr));
    }
    for(int i=0;i<sr;i++) {
        while(pl<sl&&f[rs][i].se+f[ls][pl].fi>lim) pl++;
        if(pl==sl) break;
        else vr.pb(mp(f[rs][i].fi+disr,f[ls][pl].se+disl));
    }
    pl=pr=0,sl=vl.size(),sr=vr.size();
    while(pl<sl&&pr<sr) {
        if(vl[pl].fi>vr[pr].fi) ins(u,vl[pl++]);
        else ins(u,vr[pr++]);
    }
    while(pl<sl) ins(u,vl[pl++]);
    while(pr<sr) ins(u,vr[pr++]);
    return !f[u].empty();
}
int main() {
    cin>>n;
    for(int i=2,a,v;i<=n;i++) a=gi(),v=gi(),adde(a,i,v);
    ll l=0,r=1e11,ret=0;
    while(l<=r) {
        mid=(l+r)>>1;
        if(dfs(1)) ret=mid,r=mid-1;
        else l=mid+1;
    }
    printf("%lld\n",ret);
    return 0;
}
//orzgzy
//鸡贼明年进队超稳


Measured memory_bytes: 29816
#include <stdio.h>

int main(void)
{
  char s[101];
  long long int k;
  int t[101];
  char current;
  int last_index_of_s;
  int last_index_of_t;
  long long int ans;
  int j;

  scanf("%s", s);
  scanf("%lld", &k);

  for(int i = 0; i < 101; i++) {
    t[i] = 0;
  }

  j = 0;
  current = s[0];
  for(int i = 0; i < 101; i++) {
    if(s[i] == '\0') {
      last_index_of_s = i-1;
      t[j+1] = -1;
      break;
    }

    if(s[i] == current) {
      t[j]++;
    }
    else {
      j++;
      t[j]++;
      current = s[i];
    }
  }

  if(last_index_of_s == 0) {
    printf("%lld\n", k/2);
    return 0;
  }

  ans = 0;
  for(int i = 0; i < 101; i++) {
    if(t[i] == -1) {
      last_index_of_t = i-1;
      break;
    }
    else if(t[i] == 1) {
      continue;
    }
    else {
      ans += (long long int)(t[i] / 2) * k;
    }
  }

  if(last_index_of_t == 0) {
    printf("%lld\n", (t[0]*k)/2);
    return 0;
  }

  if(s[0] == s[last_index_of_s]) {
    ans -= (long long int)(t[last_index_of_t]/2)*k;
    ans -= (long long int)(t[0]/2)*k;
    ans += (long long int)((t[0]+t[last_index_of_t])/2)*(k-1);

    if(t[last_index_of_t] >= 1) {
      ans += (long long int)(t[last_index_of_t] / 2);
    }

    if(t[0] >= 1) {
      ans += (long long int)(t[0] / 2);
    }
  }

  printf("%lld\n", ans);

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
const int MAX_N = int(3e5 + 5);

int main() {
    int N, Q, cmax[MAX_N]{};
    cin >> N >> Q;
    for(int i=0;i<N;i++){
        int c;
        cin >> c;
        cmax[c] = c;
    }
    for(int i=1;i<MAX_N;i++){
        cmax[i] = max(cmax[i], cmax[i-1]);
    }
    for(int i=0;i<Q;i++){
        int q, ans = 0;
        cin >> q;
        for(int j=q-1;j<MAX_N;j+=q){
            ans = max(ans, cmax[j]%q);
        }
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 4252
#入力x y
x, y = map(int, input().split())

#鶴の数 i, カメの数 z
z = 0
#答えに合致するかの判定 ju
ju = 0
for i in range(x+1):
    #print(i)
    z = x - i
    #print(z)
    if i*2 + z*4 == y :
        ju += 1
    else :
        ju += 0

if ju >= 1:
    print("Yes")
else :
    print("No")


Measured memory_bytes: 9172
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int K = scan.nextInt();
		int s[] = new int[N];
      int answer=0;
      int d;
      int A;
		for (int i = 0; i < K; i++) {
			d = scan.nextInt();
			for (int y = 0; y < d; y++) {
				A = scan.nextInt();
				s[A - 1]++;
			}
		}
		for (int i = 0; i < N; i++) {
			if (s[i] == 0) {
				answer += 1;
			}
		}
		System.out.println(answer);
	}
}


Measured memory_bytes: 46220
#include <iostream>
#include "string"
using namespace std;
int main() {
   string a, b, c;
   cin >> a >> b >> c;

   a[0] = toupper(a[0]);
   b[0] = toupper(b[0]);
   c[0] = toupper(c[0]);
   
   cout << a[0] << b[0] << c[0] << endl;
}


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

#define ll long long
#define pb push_back
#define F first
#define S second

using namespace std;

const int N = 100005;
const int MOD = 1e9 + 7;

struct data{
    string s;
    int x, id;
};

bool cmp(data a, data b) {
    if (a.s == b.s) return a.x > b.x;
    return a.s < b.s;
}

int main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int n;
    cin >> n;
    vector <data> v(n);
    for (int i = 0; i < n; i++) {
        cin >> v[i].s >> v[i].x;
        v[i].id = i;
    }
    sort(v.begin(), v.end(), cmp);
    for (data i : v) {
        cout << i.id + 1 << endl;
    }
    return 0;
}


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

using ll=long long;
using P=pair<ll,ll>;
#define mod 1000000007

ll gcd(ll a,ll b){
  if(a%b==0) return b;
  else{
    return gcd(b,a%b);
  }
}

ll modpow(ll n,ll m=mod-2){
  ll r=1;
  while(m) r=r*((m%2)?n:1)%mod,n=n*n%mod,m>>=1;
  return r;
}

int main(){

  int n;
  cin >> n;

  map<P,P> mp;
  long long zero=0;
  ll sum = 1;

  for(int i=0;i<n;i++){
    ll a,b;
    cin >> a >> b;
    if(a==0 && b==0) zero++;
    else if(a==0){
      mp[make_pair(1,0)].first++;
    }else if(b==0){
      mp[make_pair(1,0)].second++;
    }else{
      ll g = gcd(a, b);
      a=a/g;
      b=b/g;
      if(mp[make_pair(b,-a)].first>0) mp[make_pair(b,-a)].second++;
      else if(mp[make_pair(-b,a)].first>0) mp[make_pair(-b,a)].second++;
      else mp[make_pair(a,b)].first++;
    }
  }

  for(auto p:mp){
    ll s = p.second.first%mod;
    ll t = p.second.second%mod;
    ll now = 1;
    now += modpow(2,s)-1;
    now = now%mod;
    now += modpow(2,t)-1;
    now = now%mod;
    sum *= now;
    sum = sum%mod;
  }

  cout << (sum+zero-1+mod)%mod << endl;

}

Measured memory_bytes: 50344
#include<bits/stdc++.h>
using namespace std;
#define int long long int
void solve()
{
    int n;

cin>>n;
if(n>=30)
    cout<<"Yes"<<"\n";
else
    cout<<"No"<<"\n";
}

signed main()
{
 ios_base::sync_with_stdio(false);
 cin.tie(NULL);
 cout.tie(NULL);
 int t=1;
//cin>>t;
while(t--)
{
  solve();
}
  return 0;
}


Measured memory_bytes: 3648
#include <stdio.h>

int n;
int data[10];
int ans[100];

bool solve(int i, int l, int r){
  if(i==10)
    return true;
  if(data[i] > l)
    return solve(i+1,data[i],r);
  if(data[i] > r)
    return solve(i+1,l,data[i]);
  return false;
}
int main(){
  scanf("%d", &n);
  for(int i = 0; i < n; i++){
    for(int j = 0; j < 10; j++){
      scanf("%d", &data[j]);
      if(solve(0,0,0)){
        ans[i] = 1;
      }else{
        ans[i] = 0;
      }
    }
  }
  for(int i = 0; i < n; i++){
    if(ans[i])
      printf("YES\n");
    else
      printf("NO\n");
  }
}

Measured memory_bytes: 2608