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

// 小数点以下桁数
// fixed << setprecision(i)

int64_t gcd(int64_t a,int64_t b){return (a%b==0?b:gcd(b, a%b));}
int64_t lcm(int a,int b){return (int64_t)a*b/gcd(a, b);}
int factorial(int a){int b=1;while(a){b*=a--;}return b;} //13以下対応
bool is_prime(int a){if(a<=1)return false;for(int i=2;(int64_t)i*i<=a;i++){if(a%i==0)return false;}return true;}
int get_adp(double x, int n){return (int)round((x-(int)x)*pow(10,n))%10;} // 小数点以下の指定桁の値を取得
int64_t sigma(int64_t s, int64_t n){return n*(2*s+n-1)/2;}

//順列の全列挙
// vector<int> v(N);
// iota(v.begin(), v.end(), 1);       // v に 1, 2, ... N を設定
// do {
//	for(auto x : v) cout << x << " "; cout << "\n";     // v の要素を表示
// } while( next_permutation(v.begin(), v.end()) ); 

//bit全探索
// for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
//	bitset<ビット数> s(tmp);
//	// (ビット列sに対する処理)
// }

int main()
{
	int64_t n, m, ans;

	cin >> n >> m;
	if (n == 1 && m == 1)
		ans = 1;
	else if (n == 1)
		ans = m - 2;
	else if (m == 1)
		ans = n - 2;
	else
		ans = n * m - n * 2 - m * 2 + 4;
	cout << ans << endl;
}


Measured memory_bytes: 3444
#include <iostream>
#include <iomanip>
#include <ios> 
#include <vector>
#include <string>
#include <algorithm>
#include <functional>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
#include <bitset>
#include <map>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
#define sz(c) ((int)(c).size())

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
const int MAX=2005;
const int INF=1e9+50;


int main(){
	int N,K,Q;
	cin>>N>>K>>Q;
	int A[MAX];
	set<int> st;
	rep(i,N){
		cin>>A[i];
		st.insert(A[i]);
	}
	A[N]=0;
	
	int ans=INF;
	
	for(auto it=st.begin(); it != st.end(); ++it){
		int k=*it;
		vi ca;
		vi v;
		rep(i,N+1){
			if(A[i]>=k)v.push_back(A[i]);
			else{
				if(sz(v)>=K){
					sort(v.begin(), v.end());
					rep(i,sz(v)-K+1)ca.push_back(v[i]);
				}
				v.clear();
			}
		}
		if(sz(ca)>=Q){
			sort(ca.begin(), ca.end());
			ans=min(ans, ca[Q-1]-k);
		}
		else break;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
int main() {
//main関数の中だけ書き込む
  string x;
  cin >> x;
  if(x=="a" || x=="e" || x=="i" || x=="o" || x=="u"){
  cout << "vowel";
  }else{
  cout << "consonant"; 
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;
int main () {
	int n;
	while(cin >> n){
		int ans = 0;
		for(int a = 0; a < 10; a++){
			for(int b = 0; b < 10; b++){
				for(int c = 0; c < 10; c++){
					for(int d = 0; d < 10; d++){
						if(a + b + c + d == n){
							ans++;
						}
					}	
				}	
			}
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 3104
n=int(input());a=0;m=10**9+7
def c(n,r):
    r=min(r,n-r)
    x=1
    for i in range(r):x*=(n-i)*pow(i+1,m-2,m)%m
    return x
for i in range(n//3):a+=c(n-3-2*i,i)
print(a%m*(n>2))

Measured memory_bytes: 9160
import bisect


N = int(input())
A = sorted(list(map(int, input().split())))
B = sorted(list(map(int, input().split())))
C = sorted(list(map(int, input().split())))

N_B = len(B)
N_C = len(C)
T = [0] * N_B

for i, b in enumerate(B):
    T[i] = N_C - bisect.bisect_right(C, b)
TT = [0] * N_B
TT[-1] = T[-1]
for i in range(N_B - 2, -1, -1):
    TT[i] = T[i] + TT[i + 1]

# print(T)
# print(TT)

ans = 0
for a in A:
    i = bisect.bisect_right(B, a)
    if i >= N_B:
        continue
    ans += TT[i]
print(ans)


Measured memory_bytes: 25332
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int solve_1(ll N, vector<ll> A, string S) {
    reverse(S.begin(), S.end());
    reverse(A.begin(), A.end());

    vector<bool> used(N,false);
    for ( int b = 62; b >= 0; b-- ) {
        ll bb = 1LL << b;
        for ( int i = 0; i < N; i++ ) {
            if ( S[i] == '0' && !used[i] && ((A[i] & bb) != 0))  {
                used[i] = true;
                for ( int j = 0; j < N; j++ ) {
                    if ( j == i ) continue;
                    if ( A[j] & bb ) {
                        A[j] ^= A[i];
                    }
                }
            } else {
                if ( S[i] == '1' && ((A[i] & bb) != 0) ) return 1;
            }
        }
    }
    return 0;
}

// int solve_2(ll N, vector<ll> A, string S) {
//     reverse(S.begin(), S.end());
//     unordered_set<ll> s;
//     s.insert(0);
//     for ( int i = 0; i < N; i++ ) {
        
//     }



// }

void test() {
    mt19937_64 mt64(0);
    uniform_int_distribution<ll> rnd(1, 15);
    ll x = rnd(mt64);



}


int main() {
    stringstream ssr;
    int T;
    cin >> T;
    for ( int t = 0 ; t < T ; t++ ) {
        ll N;
        cin >> N;
        vector<ll> A(N);
        for ( int i = 0; i < N; i++ ) {
            cin >> A[i];
        }
        string S;
        cin >> S;
        auto ans = solve_1(N, A, S);
        ssr << ans << '\n';
    }
    cout << ssr.str();
    return 0;
}

Measured memory_bytes: 3552
/* BISMILLAHIR RAHMANIR RAHIM */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for(auto& i : a) cin >> i;
    b[0] = a[0];
    for(int i = 1; i < n; i++) {
        b[i] = min(b[i - 1], a[i]);
    }
    int res = 1;
    for(int i = 1; i < n; i++) {
        if( b[i - 1] >= a[i] ) res++;
    }
    cout << res << "\n";
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
//using static System.Math;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            string co = Console.ReadLine();

            if(co[2] == co[3]&&co[4] == co[5]){
                Console.Write("Yes");

            }else{
                Console.Write("No");
            }


           
           
            
        }
    }
    
}



Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    int N;
    cin >> N;
    vector<long long> a(N);
    map<long long, long long> m;
    REP(i, N) {
        cin >> a[i];
        m[a[i]]++;
    }
    long long ans = m[1];
    for(int i = 1; i < 100001; i++) {
        ans = max(m[i] + m[i - 1] + m[i + 1], ans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 7296
t1,n1 = map(int,input().split())
t2,n2 = map(int,input().split())
t3,n3 = map(int,input().split())
t4,n4 = map(int,input().split())

if t1==1:
    print(n1*6000)
    if t2==2:
        print(n2*4000)
        if t3==3:
            print(n3*3000)
            print(n4*2000)
        if t3==4:
            print(n3*2000)
            print(n4*3000)
        
    if t2==3:
        print(n2*3000)
        if t3==2:
                print(n3*4000)
                print(n4*2000)
        if t3==4:
            print(n3*2000)
            print(n4*4000)
    if t2==4:
        print(n2*2000)
        if t3==2:
                print(n3*4000)
                print(n4*3000)
        if t3==3:
                print(n3*3000)
                print(n4*4000)
                
if t1==2:
    print(n1*4000)
    if t2==1:
        print(n2*6000)
        if t3==3:
                print(n3*3000)
                print(n4*2000)
        if t3==4:
                print(n3*2000)
                print(n4*3000)        
    if t2==3:
        print(n2*3000)
        if t3==1:
                print(n3*6000)
                print(n4*2000)
        if t3==4:
                print(n3*2000)
                print(n4*6000)                
    if t2==4:
        print(n2*2000)
        if t3==1:
                print(n3*6000)
                print(n4*3000)
        if t3==3:
                print(n3*3000)
                print(n4*6000)                
if t1==3:
    print(n1*3000)
    if t2==1:
        print(n2*6000)
        if t3==2:
                print(n3*4000)
                print(n4*2000)
        if t3==4:
                print(n3*2000)
                print(n4*4000)        
    if t2==2:
        print(n2*4000)
        if t3==1:
                print(n3*6000)
                print(n4*2000)
        if t3==4:
                print(n3*2000)
                print(n4*6000)                
    if t2==4:
        print(n2*2000)
        if t3==1:
                print(n3*6000)
                print(n4*3000)
        if t3==3:
                print(n3*3000)
                print(n4*6000)        
if t1==4:
    print(n1*2000)
    if t2==1:
        print(n2*6000)
        if t3==2:
                print(n3*4000)
                print(n4*3000)
        if t3==3:
                print(n3*3000)
                print(n4*4000)        
    if t2==2:
        print(n2*4000)
        if t3==1:
                print(n3*6000)
                print(n4*3000)
        if t3==3:
                print(n3*3000)
                print(n4*6000)        
    if t2==3:
        print(n2*3000)
        if t3==1:
                print(n3*6000)
                print(n4*4000)
        if t3==2:
                print(n3*4000)
                print(n4*6000)        



Measured memory_bytes: 5700
import java.util.Scanner;

/**
 * 大岩達典 J4-170821<br>
 * D-ColouringDominos<br>
 * https://beta.atcoder.jp/contests/abc071/tasks/arc081_b
 * <br>
 * 教壇から見て左中央<br>
 * <br>
 */
public class Main {
	
	public static final int MAX = 1000000007;
	
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
		final int n = scanner.nextInt();
		final String upper = scanner.next();
		//final String lower = 
				scanner.next();
		scanner.close();
		
		long result = 0;
		int i = 0;
		boolean prevFlat;
		
		// 最初の部分
		if (n == 1) {
			i = 1;
			result = 3;
			prevFlat = false;
		} else {
			if (upper.charAt(0) == upper.charAt(1)) {
				result = 6;
				i = 2;
				prevFlat = true;
			} else {
				result = 3;
				i = 1;
				prevFlat = false;
			}
		}
		
		for (; i < n; i++) {
			if (i == n-1) {// 最後
				if (prevFlat) {
				} else {
					result *= 2;
					if (result >= MAX) result -= MAX;
				}
				
			} else {
				if (upper.charAt(i) == upper.charAt(i+1)) {
					// 横
					if (prevFlat) {
						result *= 3;
						if (result >= MAX) result -= MAX;
					} else {
						result *= 2;
					}
					if (result >= MAX) result -= MAX;
					i++;
					prevFlat = true;
				} else {
					// 縦
					if (!prevFlat) {
						result *= 2;
						if (result >= MAX) result -= MAX;
					}
					prevFlat = false;
				}
			}
			//System.out.println(String.valueOf(i) + " "  + prevFlat + " " + result);
		}
		
		System.out.println(String.valueOf(result));
	}
}


Measured memory_bytes: 24148
#include <iostream>
#include <cstdio>
#include <algorithm>
using namespace std;
int n, k, mn=2e9, a[100005];
int main() {
	int i;
	cin>>n>>k;
	for(i=0; i<n; i++) scanf("%d", &a[i]);
	sort(a, a+n);
	for(i=k-1; i<n; i++) mn = min(mn, a[i] - a[i-k+1]);
	cout<<mn;
	return 0;
}


Measured memory_bytes: 640
m=998244353
n=int(input())
s=list(map(int,input().split()))
from collections import Counter as co
if s[0]!=0:
  print(0)
else:
  s=s[1:]
  if 0 in s:
    print(0)
  else:
    ans=1
    d=co(s)
    l=max(s)
    x=d.get(1,0)
    for i in range(2,l+1):
      y=d.get(i,0)
      ans=(ans*(x**y))%m
      x=y
    print(ans%m)

Measured memory_bytes: 19692
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
// const int dy[]={0,-1,0,1,1,-1,-1,1};
// const int dx[]={1,0,-1,0,1,1,-1,-1};

int main() {
	string s, t; cin >> s >> t;
	int sn = s.size();
	int tn = t.size();
	int ans = INF;
	for(int i = 0; i + tn <= sn; ++i) {
		int cnt = 0;
		for(int j = 0; j < tn; ++j) {
			if(s[i + j] != t[j]) ++cnt;
		}
		ans = min(ans, cnt);
	}	
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 3620
#include <iostream>
#include <stack>
#include <string>
using namespace std;

int main(){
    string str;
    while(getline(cin,str)){
        if(str == ".") break;
        stack<char> st;
        char c;
        bool isok = true;
        for(int i=0;i<str.size();i++){
            c = str[i];
            if(c == '(' || c == '['){
                st.push(c);
            }else if(c == ')'){
                if(!st.empty() && st.top() == '('){
                    st.pop();
                }else{
                    isok = false;
                    break;
                }
            }else if(c == ']'){
                if(!st.empty() && st.top() == '['){
                    st.pop();
                }else{
                    isok = false;
                    break;
                }
            }
        }
        if(!st.empty()) isok = false;
        cout << (isok?"yes":"no") << endl;
    }
}

Measured memory_bytes: 0
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

#define MAX(x,y) (x>y?x:y)
#define MIN(x,y) (x<y?x:y)
#define ABS(x) (x>0?x:-(x))
#define INF 2147483647
#define LLINF 9223372036854775807
#define MOD 1000000007

typedef long long int lli;

void swap(int* a, int* b)
{
    int tmp;
    tmp = *a;
    *a = *b;
    *b = tmp;
}

void ll_swap(lli* a, lli* b)
{
    lli tmp;
    tmp = *a;
    *a = *b;
    *b = tmp;
}

int gcd(int a, int b)
{
    if (a < b)
        swap(&a, &b);

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

int lcm(int a, int b)
{
    return a * b / gcd(a, b);
}

long power(long x, int n) {
    long ans = 1;
    while (n > 0) {
        if ((n & 1) == 1) {
            ans = ans * x;
        }
        x = x * x;
        n >>= 1;
    }
    return ans;
}

lli comb(lli n, lli r)
{
    if (n == 0)
        return 0;

    if (r == 0 || r == n)
        return (1);
    else if (r == 1)
        return (n);
    return (comb(n - 1, r - 1) + comb(n - 1, r));
}

/*
#define MAX 100000
long long fac[MAX], finv[MAX], inv[MAX];
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
// 二項係数計算
long long COM(int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
*/   

int main()
{
    //int M, N, K, L;
    lli N, K;
    int X, Y,Z;
    int A[200000];

    lli count = 0;
    lli temp, temp2;
    lli max = -LLINF,min = LLINF;
    lli sum = 0;

  
    scanf("%lld%lld", &N, &K);

    if (N == K)
        printf("0");
    else
        printf("%lld",MIN(N % K, ABS(K-(N%K))));
}


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

int main(){
    int i, j, n;
    char mark;
    char marks[4]={'S', 'H', 'C', 'D'};
    int num;
    bool cards[4][13]={false};

    scanf("%d ", &n);
    for(i=0;i<n;i++){
        scanf("%c %d ", &mark, &num);
        for(j=0;j<4;j++){
            if(mark==marks[j]){
                cards[j][num-1]=true;
                break;
            }
        }
    }
    for(i=0;i<4;i++){
        for(j=0;j<13;j++){
            if(!cards[i][j]){
                printf("%c %d\n", marks[i], j+1);
            }
        }
    }
    return 0;
}


Measured memory_bytes: 2140
#include<stdio.h>
#include<algorithm>
using namespace std;
int main()
{
	int n;
	while(~scanf("%d",&n))
	{
		int a[300]={0};
		int sum=0;
		for(int i=1;i<=2*n;i++)
		scanf("%d",&a[i]);
		sort(a+1,a+n*2+1);
		for(int i=1;i<=n*2;i++)
		{
			if(i%2!=0)
			sum+=a[i];
			else
			continue;
		}
		printf("%d\n",sum);
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int n; cin >> n;
    vector<int> v(n);
    REP(i,n) cin >> v[i];

    ll ans = 0;
    int cnt = 0;
    int l = 0,r = 0;
    REP(i,n) {
        while(cnt+v[i] != (cnt ^ v[i])) {
            cnt -= v[l];
            ans += r-l;
            l++;
        }
        cnt += v[i];
        r++;
        // cerr << ans << endl;
    }
    // cerr << l << " " << r << endl;
    FOR(i,l,r) {
        ans += r-i;
    }

    cout << ans << '\n';

    return 0;
}

Measured memory_bytes: 1024
use std::io::*;
use std::str::FromStr;

pub fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

pub fn read_n<T: FromStr>(n: usize) -> Vec<T> {
    read_n_logic::<T>(n, vec![])
}

pub fn read_n_logic<T: FromStr>(n: usize, mut a: Vec<T>) -> Vec<T> {
    match n {
        0 => a,
        _ => {
            a.push(read::<T>());
            read_n_logic(n - 1, a)
        }
    }
}
use std::cmp::{max, min};

fn main() {
    let n: String = read();
    let m: String = read();
    if n == m {
        println!("{}", "Yes")
    } else {
        println!("{}", "No")
    }
}


Measured memory_bytes: 4352
#include <stdio.h>

void di(int map[10][10], int x, int y)
{
	if (0 <= x && x < 10 && 0 <= y && y < 10){
    	map[y][x]++;
  	}
}

int main(void)
{
	int x, y, s;
	int wc = 0, max_i = 0;
	int map[10][10] = {0};
	
	while (scanf("%d,%d,%d", &x, &y, &s) != EOF){
		di(map, x, y);
		if (1 <= s){
		  	di(map, x + 1, y);
			di(map, x - 1, y);
			di(map, x, y + 1);
			di(map, x, y - 1);
		}
		if (2 <= s){
		  	di(map, x + 1, y + 1);
			di(map, x - 1, y - 1);
			di(map, x - 1, y + 1);
			di(map, x + 1, y - 1);
		}
		if (s == 3){
		  	di(map, x + 2, y);
			di(map, x - 2, y);
			di(map, x, y + 2);
			di(map, x, y - 2);
		}
	}
	
	for (y = 0; y < 10; y++){
		for (x = 0; x < 10; x++){
			if (map[y][x] == 0){
				wc++;
			}
			else if(max_i < map[y][x]){
				max_i = map[y][x];
			}
		}
	}
	
	printf("%d\n%d\n", wc, max_i);
	
	return (0);
}

Measured memory_bytes: 596
#include <iostream>
using namespace std;
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	for(int i = 1; i <= 5; i++){
		int x;
		cin >> x;
		if(x == 0){
			cout << i << "\n";
			break;
		}
	}
}

Measured memory_bytes: 3636
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps = 1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt" > "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\b.txt"


int main() {
	while (1) {
		int y, m, d;
		if (!(cin >> y >> m >> d)) {
			return 0;
		}
		else {
			int hash = y * 10000 + m * 100 + d;
			string gou;
			if (hash >= 1989 * 10000 + 1 * 100 + 8) {
				gou = "heisei";
			}
			else if (hash >= 1926 * 10000 + 12 * 100 + 25) {
				gou = "showa";
			}
			else if (hash >= 1912 * 10000 + 7 * 100 + 30) {
				gou = "taisho";
			}
			else if(hash>=1868*10000+9*100+8){
				gou = "meiji";
			}
			else {
				gou = "pre-meiji";
			}
			if (gou == "pre-meiji") {
				cout << gou << endl;
			}
			else {
				cout << gou << " ";
				map<string, int>mp;
				mp["heisei"] = 1988;
				mp["showa"] = 1925;
				mp["taisho"] = 1911;
				mp["meiji"] = 1867;
				cout << y - mp[gou] << " "<<m << " " << d << endl;
			}
			
		}
	}

	return 0;
}

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

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

Measured memory_bytes: 256
from fractions import gcd
def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)
    divisors.sort()
    return divisors

def is_prime(n):
    if n == 1: return False
    for k in range(2, int(n**0.5)+1):
        if n % k == 0:
            return False
    return True

a, b = map(int, input().split())
# a, b = 10**12, 10**12
ans = 0
GCD = gcd(a, b)
# GCD = 10**12
GCD_list = make_divisors(GCD)
# print(GCD_list)

for i in GCD_list:
    if is_prime(i):
        ans += 1

print(ans + 1)

Measured memory_bytes: 5340
#include <iostream>

using namespace std;
int main()
{
	int n, a[128], h = 0, m = 0;
	cin >> n;
	for (int i = 0; i < n; cin >> a[i], i++);
	for (int i = 0; i < n; i++) {
		if (a[i] >= h) {
			h = a[i];
			++m;
		}
	}
	cout << m;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

int N;

bool ok(s64 x)
{
    bool a = false, b = false, c = false;
    while (x)
    {
        s64 y = x % 10;
        if (y == 3) a = true;
        else if (y == 5) b = true;
        else if (y == 7) c = true;
        x /= 10;
    }
    return a & b & c;
}

int dfs(s64 x)
{
    if (x > N) return 0;
    int ret = (ok(x) ? 1 : 0);
    static const s64 cand[] = {7, 5, 3}; 
    rep (i, 3)
    {
        ret += dfs(x * 10 + cand[i]);
    }
    return ret;
}

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

    cin >> N;
    cout << dfs(0) << "\n";

    return 0;
}



Measured memory_bytes: 256
#define __USE_MINGW_ANSI_STDIO
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <unordered_set>
#include <unordered_map>

using namespace std;

typedef long long ll;
typedef long long ull;
typedef pair<int, int> ii;

#define all(v)		((v).begin()), ((v).end())
#define sz(v)		((int)((v).size()))
#define endl		"\n"
#define fx(n)		fixed<<setprecision(n)
#define mk			make_pair	

void fast()
{
	ios::sync_with_stdio(NULL);
	cout.tie(NULL);
	cin.tie(NULL);
#ifndef ONLINE_JUDGE
	freopen("output.txt", "w", stdout);
	freopen("input.txt", "r", stdin);
#endif
#ifdef ONLINE_JUDGE
	/*freopen("output.txt", "w", stdout);
	freopen("pyramid.in", "r", stdin);*/
#endif
}
const double pi = 2 * acos(0.0);
const ll oo = 0x3f3f3f3f;
const int MOD = 1e9 + 7;
const int nn = 5e3 + 15;
int dx[8] = { -1, 0, 0, 1, 1, -1, 1, -1 };
int dy[8] = { 0, -1, 1, 0, 1, -1, -1, 1 };

int main()
{
	//fast();
	string s;
	cin >> s;
	map<char, int> mp;
	for (int i = 0; i < sz(s); i++)
	{
		mp[s[i]]++;
	}
	bool f = 0;
	for (auto it : mp)
	{
		if (it.second & 1)
			f = 1;
	}
	cout << (f ? "No\n" : "Yes\n");
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
	long long int n, k, ans = 0;
	cin >> n >> k;
	for(int i = k;i <= n + 1;i++){
		ans += ((n - i + 1) * i % 1000000007) + 1;
		ans %= 1000000007;
	}
	cout << ans << endl;
}

Measured memory_bytes: 3632
x,y=map(int,input().split())
yo=[]
yo0=[]
for __ in range(x):
    a,b=map(int,input().split())
    yo.append(a)
    yo0.append(b)
lol=[]
for i in range(x+1):
    lol.append([0]*(y+1))
for i in range(1,x+1):
    for j in range(1,y+1):
        if j<yo[i-1]:
            lol[i][j]=lol[i-1][j]
        else:
            lol[i][j]=max(lol[i-1][j],yo0[i-1]+lol[i-1][j-yo[i-1]])
print(lol[x][y])            

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

#define int long long
#define ffor(i,n) for(int i = 0;i < (n); ++i)
#define all(v) v.begin(),v.end()
#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define vpii vector<pii>
#define ff first
#define ss second


signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	int n,x,y;
	cin >> n >> x >> y;
	unordered_map<int,int> cnt;
	for(int i = 1;i <= n; ++i){
			for(int j = i + 1;j <= n; ++j){
				cnt[min(j - i,abs(x - i) + 1LL + abs(j - y))]++;
			}
	}
	for(int i = 1; i <= n - 1; ++i){
		cout << cnt[i] << '\n';		
	}
}		


Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <queue>
#include <math.h>
#include <bitset>
#define INF 100000000000
#define N 10000000
using namespace std;

int main(){
    char data[3];
    for(int i=0; i<3; i++) cin>>data[i];
    int count=0;
    int max=0;
    for(int i=0; i<3; i++){
        if(data[i]=='R'){
            count++;
            if(max<count) max=count;
        }
        else count=0;
    }
    
    cout<<max<<endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repe(i, n) for (int i = 0; i <= (int)(n); i++)
#define YES cout<<"YES"<<endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define ANS cout << ans << endl
#define all(a) a.begin(),a.end()
#define SORT(a) sort(all(a))
#define REVERSE(a) reverse(all(a))
#define KOZYUN(a) sort(all(a),greater<int>())
#define int ll
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORe(i, m, n) for(int i = m;i <= n;i++)
#define VIin(a) for(int i=0; i<a.size(); i++) cin >> a[i]
#define OUT(a) cout << a << endl
#define IN(a) cin >> a
#define INT(a) int a; cin >> a
typedef vector<int> VI;
typedef vector<VI> VVI;
const int MOD=1e9+7;
const long long INF = 1LL << 60;
/*最大公約数*/int gcd(int x, int y) { return y ? gcd(y,x%y) : x;}
/*最小公倍数*/int lcm(int a, int b) { int g = gcd(a, b); return a / g * b; }
/*素数判定*/int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*約数列挙*/vector<int> getDivisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------------------------------------
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int a,b;
  	int ans = -1;
    while(cin >> a >> b){
        FORe(i,1,1000){
            if(floor(0.08 * i) == a and floor(0.1 * i) == b){
                ans = i;
                break;
            }
        }
    }
    ANS;

    return 0;
}

Measured memory_bytes: 256
import std.stdio, std.conv, std.string, std.array, std.algorithm, std.range;

void main()
{
    long m, d;
    readf("%d %d", &m, &d);

    long cnt = 0;
    foreach (i; 1 .. m + 1)
    {
        foreach (j; 1 .. d + 1)
        {
            auto d1 = j % 10;
            auto d2 = j / 10;
            if (d1 >= 2 && d2 >= 2 && d1 * d2 == i)
            {
                cnt++;
            }
        }
    }
    writeln(cnt);
}


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

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

#define rep(i, N) for (ll i = 0; i < (N); i++)
#define For(i, a, b) for (ll i = (a); i < (b); i++)
#define all(A) (A).begin(), (A).end()

int gcd(int a, int b) {
    if (a < b) swap(a, b);
    if (a % b == 0) return b;
    return gcd(b, a % b);
}


int main(){
    int N;
    cin >> N;
    int A[N];
    rep(i, N) cin >> A[i];
    int tmp;
    tmp = A[0];
    rep(i, N - 1) tmp = gcd(tmp, A[i + 1]);

    cout << tmp << endl;

    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<cstdio>
#include<cstdlib>
#define re register
#define LL long long
#define N 2005
#define Maxn 4000000
using namespace std;
const int Mod=1e9+7;
int n,k;
LL f[N][N],fac[Maxn+5],inv_fac[Maxn+5];
inline LL C(int n,int m){ return (((fac[m]*inv_fac[n])%Mod)*inv_fac[m-n])%Mod; }
LL power(LL x,int P){
    LL ans=1,m=x;
    while(P){
        if(P&1) (ans*=m)%=Mod;
        P>>=1;(m*=m)%=Mod;
    }
    return ans;
}
int main(){
    scanf("%d%d",&n,&k);
    if(k==1){ printf("%d\n",1); return 0; }
    fac[0]=1; for(re int i=1;i<=Maxn;++i) fac[i]=(fac[i-1]*i)%Mod;
    inv_fac[Maxn]=power(fac[Maxn],Mod-2); for(re int i=Maxn-1;i>=0;--i) inv_fac[i]=(inv_fac[i+1]*(i+1))%Mod;
    f[0][0]=1;
    for(re int i=1;i<=n;++i){
        for(re int j=0;j<=i;++j){
            f[i][j]=f[i-1][j];
            if(!j) continue;
            (f[i][j]+=f[i][j-1]*(n-j+1)%Mod*C(k-2,n-i+(n-j+1)*(k-1)-1)%Mod)%=Mod;
        }
    }
    printf("%lld\n",f[n][n]);
    return 0;
}

Measured memory_bytes: 94080
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <sstream>
#include <string>
#define _repargs(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _repargs(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define mod 1000000007
//#define inf 2000000007
#define mp make_pair
#define pb push_back
typedef long long ll;
using namespace std;
template <typename T>
inline void output(T a, int p = 0) {
    if(p) cout << fixed << setprecision(p)  << a << "\n";
    else cout << a << "\n";
}
// end of template

int main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    // source code
    
    int N;
    ll A, B;
    cin >> N >> A >> B;
    vector<ll> X(N);
    rep(i, N) cin >> X[i];
    
    ll ans = 0;
    rep(i, N - 1) {
        ll dist = X[i + 1] - X[i];
        if(dist * A < B) ans += dist * A;
        else ans += B;
    }
    output(ans);
    
    
    
    return 0;
}


Measured memory_bytes: 1024
/*
 * author :Sadik Hassan
 *
*/
#include "bits/stdc++.h"
using namespace std;
#define ll            long long
#define nl            "\n"
#define PB            push_back
#define fi            first
#define se            second
#define _SAD()        ios::sync_with_stdio(0),cin.tie(0), cout.tie(0);
#define rep(i,n)      for(int i=0;i<n;i++)
#define repn(i,n)     for(int i=1;i<=n;i++)
#define rrep(i,n)     for(int i=n-1;i>=0;i--)
#define SZ(s)         s.size()
#define SRT(x,y)      sort(x,x+y)
#define REV(a,b)      reverse(a,a+b)
#define VSRT(x)       sort(x.begin(),x.end())
#define VREV(x)       reverse(x.begin(),x.end())
#define TSFL(s)       transform(s.begin(),s.end(),s.begin(),::toupper);
#define TSFH(s)       transform(s.begin(),s.end(),s.begin(),::tolower);
/*---------------------------------------------------------------------*/
const int N = 2e5+10;
const int INF = (int)1e9+5;

int main()
{
    _SAD()
    int n,a=0,k=0;
    bool fl=false;
    cin>>n;
    map<string,int>m;
    vector<string>v(n);
    rep(i,n)
    {
        cin>>v[i];
        m[v[i]]++;
    }
    vector<pair<string,int> >p;
    int nn=0;
    for(int i=0;i<n;i++)
    {
        p.PB(make_pair(v[i],m[v[i]]));
        if(m[v[i]]>nn)
        {
            nn=m[v[i]];
        }
    }
    VSRT(p);
    set<string>jj;
    for(int i=n-1;i>=0;i--)
    {
        if(nn==p[i].se)
        {
            jj.insert(p[i].fi);
        }
    }
    //cout<<SZ(jj)<<nl;

    while(!jj.empty())
    {
        string oo=*jj.begin();
        cout<<oo<<nl;
        jj.erase(oo);
    }
    return 0;
}


Measured memory_bytes: 38892
w,h,n=map(int,input().split())
xmax=w
xmin=ymin=0
ymax=h
for i in range(n):
    x,y,a=map(int,input().split())
    if a==1:
        xmin=max(xmin,x)
    elif a==2:
        xmax=min(xmax,x)
    elif a==3:
        ymin=max(ymin,y)
    else:
        ymax=min(ymax,y)

width=max(0,xmax-xmin)
height=max(0,ymax-ymin)

print(width*height)

Measured memory_bytes: 3064
import java.util.Scanner;
public class Main{
	public static void main(String[]args) {
		Scanner input=new Scanner(System.in);
		int x;
		do {
			x=input.nextInt();
		}while(x<1||x>3000);
		if(x<1200) {
			System.out.println("ABC");
		}else{
			System.out.println("ARC");
		}
	}
}

Measured memory_bytes: 27080
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
using ll = long long;
using P = pair<int, int>;

int main(){
    vector<string> c(3);
    rep(i,3) cin >> c[i];
    cout << c[0][0] << c[1][1] << c[2][2] << endl;
}

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

#define INF 1e9
#define MAX_H 1000
#define MAX_W 1000

using namespace std;

struct Cood {int x, y; };

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

char field[MAX_H][MAX_W + 1];
int d[MAX_H][MAX_W + 1];
queue<Cood> q;
int h, w, n;
int total_time = 0;

void init_bfs() {
    queue<Cood> new_q;
    swap(q, new_q);
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            d[i][j] = INF;
        }
    }
}
/* current position (y, x) with current power 'current' & last cheeese target is 'last' */
int bfs(int sy, int sx, int target, int last) {
    init_bfs();
    int next_y, next_x;
    q.push(Cood{sx, sy});
    d[sy][sx] = 0;

    while (q.size()) {
        Cood current = q.front(); q.pop();
        if (field[current.y][current.x] == '0' + target) {
            total_time += d[current.y][current.x];
            if (target == last) {
                return total_time;
            } else {
                return bfs(current.y, current.x, target + 1, last);
            }
        }

        for (int i = 0; i < 4; ++i) {
            next_y = current.y + dy[i];
            next_x = current.x + dx[i];
            if (0 <= next_y && next_y < h && 0 <= next_x && next_x < w
                && field[next_y][next_x] != 'X' && d[next_y][next_x] == INF) {
                q.push(Cood{next_x, next_y});
                d[next_y][next_x] = d[current.y][current.x] + 1;
            }
        }
    }
}

int main() {
    //freopen("0558_1.in", "r", stdin);
    cin >> h >> w >> n;
    int sx, sy;
    for (int i = 0; i < h; ++i) {
        for (int j = 0; j < w; ++j) {
            cin >> field[i][j];
            if (field[i][j] == 'S') {
                sy = i, sx = j;
            }
        }
    }
    total_time = 0; // init
    cout << bfs(sy, sx, 1, n) << endl;
    return 0;
}

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

const double pi = 3.14159265359;

int main(){
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    double a,b,x;
    cin >> a >> b >> x;
    
    double area = x / a;
    double height = x / a / a;
    
    double ans = 2*(a*b-area)/a/a;
    
    if(height <= b/2) cout << fixed << setprecision(10) << atan(b/(2*area/b)) * 180.0 / pi << endl;
    else cout << fixed << setprecision(10) << atan(ans) * 180.0 / pi << endl;
}


Measured memory_bytes: 256
N=int(input())
a=[0]+list(map(int,input().split()))
b=[0]*(N+1)

for i in range(N,0,-1):
    cnt=0
    j=2
    while i*j<=N:
        cnt+=b[i*j]
        j+=1
    
    if (cnt+1)%2==a[i]:
        b[i]=1
    else:
        b[i]=0

M=0
s=''

for i in range(1,N+1):
    if b[i]==1:
        s+=str(i)+' '
        M+=1

print(M)
if M>0:
    print(s[:-1])

Measured memory_bytes: 9916
/*Filename: aoj0013.cpp
 *Author: Mushiyo
 */

#include <iostream>
#include <stack>

using namespace std;

int main(){
	int num = 0;
	stack<int> car;

    while(cin >> num){
        if(num == 0){
        	cout << car.top() << endl;
        	car.pop();
        }
        else{
        	car.push(num);
        }
    }

	return 0;
}

Measured memory_bytes: 1200
#include<string>
#include<sstream>
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<ios>
#include<algorithm>
#include<stack>
#include<queue>
#include<cmath>
#include<type_traits>
#include<random>
#include<vector>
#include<map>

using namespace std;

	

int main()
{
	int N;
	string S;
	cin >> N >> S;
	vector<int> cnt(26,1);
	for(int i=97;i<=122;i++)
	{
		for(int j=0;j<N;j++)
		{
			int seisu = S[j];
			if(seisu==i)
			{
				cnt[i-97] = cnt[i-97] + 1;
			}
		}
	}
	long long result = 1;
	for(int i=0;i<26;i++)
	{
		result = result * cnt[i]%1000000007;
	}
	cout << (result - 1)%1000000007 << endl;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using ll=long long;
using namespace std;
#define rep(i, n) for(ll i=0; i<n; i++)
#define Rep(i, j, n) for(ll i=j; i<n; i++)
#define all(vec) vec.begin(), vec.end()
template<class T> inline bool chmin(T& a, T b) {if(a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) {if(a < b) {a = b; return true;} return false;}
ll MM = 1000000000; ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y){ if(y == 0) return x; else return GCD(y, x % y);}
ll LCM(ll x, ll y){ return x / GCD(x, y) * y;}
int dh[4] = {-1, 0, 0, 1};
int dw[4] = {0, -1, 1, 0}; 
using P = pair<int, int>;
const double pi = acos(-1.0);

using Graph = vector<vector<ll>>;

int main(){
  string s;
  cin>>s;
  string tmp="";
  string copy;
  rep(i,s.size()){
    copy=tmp;
    if(s[i]=='0')tmp=tmp+"0";
    else if(s[i]=='1')tmp=tmp+"1";
    else{
      if(tmp.size()==0)continue;
      else if(tmp.size()==1){tmp="";}
      else{
	tmp="";
	rep(i,copy.size()-1){
	  tmp=tmp+copy[i];
	}
      }
    }

  }

  cout<<tmp<<endl;
    
  return 0;
}


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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define TS to_string
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


ll INF = 1e9;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}

//-----------------------------------------
int num[100000+10];

int par(int *A,int las){
  int x = A[las];
  int i = 0;
  for(int j=0;j<las;j++){
    if(A[j] <= x){
      swap(A[i],A[j]);
      i++;
    }
  }
  swap(A[i],A[las]);
  return i;
}
//-----------------------------------------

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

  int n;
  cin >> n;
  REP(i,n) cin >> num[i];
  int k = par(num,n-1);
  REP(i,n){
    if(i) cout << " ";
    if(i==k) cout << "[";
    cout << num[i] ;
    if(i==k) cout << "]";
  }cout <<endl;




  return 0;
}



Measured memory_bytes: 3524
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる



int main() {
  int n;
  string s;
  cin >> n>>s;
  int x = 0;
  int ans = 0;
  
  rep(i,n){
    if(s[i]=='I')x++;
    else x--;
    ans=max(ans,x);
  }
  
  cout << ans << endl;
  
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <map>
using namespace std;
int N;
string S;
const int MOD = 998244353;
map  <int, int> M[666015];
const int M1 = 666013;
const int M2 = 666019;
void Read()
{
    cin >> S;
}
inline void Add(int& x, int y, int mod)
{
    x += y;
    if(x >= mod)
        x -= mod;
}
pair <int, int> Encode(string s)
{
    int h1 = 0, h2 = 0;
    for(int i = 0; i < s.length(); i++)
    {
        int dig = s[i] - '0' + 1;
        h1 = (1LL * h1 * 73) % M1;
        Add(h1, dig, M1);
        h2 = (1LL * h2 * 73) % M2;
        Add(h2, dig, M2);
    }
    return make_pair(h1, h2);
}

int Solve(string s)
{
    pair <int, int> e = Encode(s);
    if(M[e.first].find(e.second) != M[e.first].end())
        return M[e.first][e.second];
    if(s.size() == 0)
        return 1;
    if(s.size() == 1)
    {
        if(s[0] == '0')
            return 1;
        return 2;
    }
    string s2 = s;
    s2.erase(s2.begin());
    int res = 0;
    Add(res, (1LL * (s[0] - '0' + 1) * Solve(s2)) % MOD, MOD);
    for(int j = 1; j < s.length(); j++)
    {
        s2.clear();
        for(int k = 0; k < j; k++)
            s2.push_back(s[k]);
        for(int k = j; k + j <= s.length(); k += j)
        {
            for(int l = k; l < k + j; l++)
                s2[l - k] = min(s2[l - k], s[l]);
            Add(res, (1LL * Solve(s2) * Solve(s.substr(k + j))) % MOD, MOD);
        }
    }
    M[e.first][e.second] = res;
    return res;
}
int main()
{
    Read();
    cout << Solve(S) << "\n";
    return 0;
}


Measured memory_bytes: 33664
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include <iomanip>
#include<deque>
#include<stack>
#include<set>
#include <numeric>

using namespace std;
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;
const int INF = 111111111;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,0,1,-1, 1, 1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1,-1,0,0, 1, -1, 1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const int DIV = 1000000007; //10^9 + 7
const double PI = 3.14159265358979323846264338327950288;



int main() {

	//==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	//==================================
	
	string S;
	cin >> S;

	int even = 0;
	int odd = 0;

	for (int i = 0; i < S.size(); i++) {
		if (S[i] == '0') {
			even++;
		}
		else {
			odd++;
		}
	}

	int ans = min(odd, even) * 2;

	cout << ans;

}





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

const int mod = 1000000007;
int main() {
  int n;
  ll x;
  cin >> n >> x;
  vector<ll> a(n);
  rep(i, n) cin >> a[i];
  ll ans = 0;
  rep(i, n){
    if (a[i] > x){
      ans += a[i] - x;
      a[i] = x;
    }
  }
  for (int i=0; i+1<n; ++i){
    if (a[i] + a[i+1] > x){
      ans += a[i] + a[i+1] - x;
      a[i+1] = x - a[i];
    }
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

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

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
S = input()
n = len(S)
L = list(map(int, list(S)))
D = []
res = 0
for k in range(n-1):
    if L[k] != L[k+1]:
        D.append(max(k+1, n-k-1))

if len(D):
    print(min(D))
else:
    print(n)

Measured memory_bytes: 5836
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>
#include <utility>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    string s;
    cin >> s;
    bool fla=true;
    set<char>ss;
    map<char,int>mpa;
    for(int i = 0;i < s.size();i++)
        ss.insert(s.at(i));

    for(int i = 0;i < s.size();i++)
        mpa[s.at(i)]++;

    for(auto x:ss){
        if(mpa[x] % 2 !=0)
            fla = false;
    }

    if(fla)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

}

Measured memory_bytes: 3628
n, k = map(int, input().split())
A = list(map(int, input().split()))


def is_ok(arg):
    # 条件を満たすかどうか？問題ごとに定義
    cut = 0
    for a in A:
        cut += (a + arg - 1)//arg - 1
    return cut <= k

def meguru_bisect(ng, ok):
    '''
    初期値のng,okを受け取り,is_okを満たす最小(最大)のokを返す
    まずis_okを定義すべし
    ng ok は  とり得る最小の値-1 とり得る最大の値+1
    最大最小が逆の場合はよしなにひっくり返す
    '''
    while (abs(ok - ng) > 1):
        mid = (ok + ng) // 2
        if is_ok(mid):
            ok = mid
        else:
            ng = mid
#        print(ok, ng)
    return ok

print(meguru_bisect(0, 10**9+1))

Measured memory_bytes: 104212
import math

def isPrimeNumber(num):
    isPrimeNum = True
    for i in range(2,math.floor(math.sqrt(num)) + 1):
        if num % i == 0:
            isPrimeNum = False

    if num == 1:
        isPrimeNum = False

    return isPrimeNum

def is2017alikeNum(num):
    is2017alikeNum = False
    alikeNum = (num + 1) / 2
    if isPrimeNumber(num) and isPrimeNumber(alikeNum):
        is2017alikeNum = True
    return is2017alikeNum

count = 0
list = []
for i in range(1,100000,2):
    if is2017alikeNum(i):
        count += 1
    list.append(count)

N = int(input())
inputList = []
for count in range(0,N):
    l,r = map(int, input().split())
    tempList = [l,r]
    inputList.append(tempList)

for i in range(0,N):
    l = inputList[i][0]
    r = inputList[i][1]
    lIndex = int((l-1)/2)
    rIndex = int((r-1)/2)
    if lIndex == 0:
        lIndex += 1
    x = list[rIndex] - list[lIndex-1]

    print(x)

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

#define debug(x) cerr << x << " = "(x) << endl;
#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n; cin >> n;
    ll nal = 26;
    string a;
    while(n>0){
        n-=1; // n - (∑26^(l-1)) を表現している
        a += n%26+'a';
        n /= nal;
    }
    reverse(all(a));
    cout << a <<endl;
}

Measured memory_bytes: 3656