akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1e9 + 7;
#define pival 3.14159265359
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pqq priority_queue
#define all(a) a.begin(),a.end()
#define sz(a) (ll)(a.size())
ll power(ll x,ll y,ll p) 
{ 
    ll res=1;  
    x=x%p;
    while (y > 0) 
    { 
        if(y&1) 
            res=(res*x)%p; 
        y=y>>1;
        x=(x*x)%p;   
    } 
    return res; 
}
const ll L = 1e5 + 5;
ll dp[L][4];
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll i,n;
    cin >> n;
    ll a,b,c;
    cin >> a >> b >> c;
    dp[0][0] = a;
    dp[0][1] = b;
    dp[0][2] = c;
    for(i=1;i<n;i++)
    {
    	cin >> a >> b >> c;
    	dp[i][0] = max(dp[i-1][1] + a,dp[i-1][2] + a);
    	dp[i][1] = max(dp[i-1][0] + b,dp[i-1][2] + b);
    	dp[i][2] = max(dp[i-1][0] + c,dp[i-1][1] + c);
    }
    ll ans = max(dp[n-1][0],dp[n-1][1]);
    ans = max(ans,dp[n-1][2]);
    cout << ans << endl;
	return 0;
}

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

int main() {
  long long N;
  cin >> N;
  int f_min=1.0e9;
  for(long long i=1;i<=sqrt(N);i++){
    if(N%i == 0){
      long long j = N/i;
      int f = max(to_string(i).length(),to_string(j).length());
      if(f < f_min){
        f_min = f;
      }
    }
  }
  
  cout << f_min << endl;
  return(0);
}

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

#define ll long long

using namespace std;

int main()
{
    ll n, k, q, i;

    cin >> n >> k >> q;

    ll a[q], b[n];

    for(i = 0; i < n; i++){
        b[i] = k;
    }

    for(i = 0; i < q; i++){
        cin >> a[i];
        b[a[i] - 1]++;
    }

    for(i = 0; i < n; i++){
        if(b[i] - q <= 0){
            cout << "No" << endl;
        }
        else{
            cout << "Yes" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 2176
import sys


fin = sys.stdin.readline
N = int(fin())
a_list = [int(elem) for elem in fin().split()]
num_dividable_by_4 = 0
num_dividable_by_2 = 0
for a in a_list:
    if a % 4 == 0:
        num_dividable_by_4 += 1
    elif a % 2 == 0:
        num_dividable_by_2 += 1
num_odds = N - num_dividable_by_2 - num_dividable_by_4
if not num_dividable_by_2:
    is_objective_viable = num_dividable_by_4 >= num_odds - 1
else:
    is_objective_viable = num_dividable_by_4 >= num_odds
print("Yes" if is_objective_viable else "No")


Measured memory_bytes: 58864
module Main where

import Control.Applicative
import Control.Monad
import Control.Monad.State
import Data.Array
import Data.Graph
import Data.List

import qualified Data.ByteString.Lazy.Char8 as L

type Tokenizer = State [L.ByteString]

nextInt :: Tokenizer Int
nextInt = state $ \(s:ss) -> case L.readInt s of
                               Just (x, _) -> (x, ss)
                               Nothing -> error $ "Can't parse Int: " ++ (L.unpack s)

maxDepth :: Graph -> Vertex -> Int
maxDepth g u | null ds = 0
             | otherwise = maximum $ zipWith (+) [n, n - 1 ..] ds
    where ds = sort $ map (maxDepth g) (g ! u)
          n = length ds

graph0 = buildG (1, 5) [(1, 2), (1, 3), (2, 4), (4, 5)]

go :: Tokenizer Int
go = do
  n <- nextInt
  ss <- replicateM (n - 1) nextInt
  let ts = [2 .. n]
      graph = buildG (1, n) (zip ss ts)
  return $ maxDepth graph 1

main :: IO ()
main = do
  contents <- L.words <$> L.getContents
  let depth = evalState go contents
  print depth
  


Measured memory_bytes: 24700
#include <iostream>
#include <string>
#include <cstdio>
using namespace std;

int n, h;
string s[100]; int t[100];
int typeNum, acTypeNum;

//r???c???(r>=0,c>=0)????????£?????????????????¨???
//????????£????????????1, ?????£????????????0?????????
int query(int r, int c){
	cout << "? ";
	for( int i = 0; i < c; i++ )
		cout << "_";
	for( int i = c; i < s[r].length(); i++ )
		cout << s[r][i];
	cout << endl;
	cout.flush();
	char result[5];
	cin >> result;
	char x = (result[0] <= 'Z') ? result[0] : result[0] - 'a' + 'A';
	char y = (s[r][c] <= 'Z') ? s[r][c] : s[r][c] - 'a' + 'A';
	if( x == y )
		return 0;
	return 1;
}

//r??????????????£?????????????????¨???
//????????????????¶?????????????1, ???????????¨????????????0?????????
int play(int r){
	int c;
	int damage = 0;
	for( c = 0; c < s[r].length(); ){
		typeNum++;
		int result = query(r, c);
		damage += result;
		if( damage > t[r] )
			return 1;
		c += (!result);
		acTypeNum += (!result);
	}
	return 0;
}

void init(){
	cin >> n >> h;
	for( int i = 0; i < n; i++ )
		cin >> s[i] >> t[i];
	typeNum = 0;
	acTypeNum = 0;
}

void gameClear(){
	//acTypeNum * 100 / typeNum ????°???°???????????¨???????±????????????????
	int ans10 = acTypeNum * 1000 / typeNum;
	double ans = (double)ans10 / 10;
	printf("! Game Clear %.1lf\n", ans);
	fflush(stdout);
}

int main(){
	init();
	for( int i = 0; i < n; i++ ){
		h -= play(i);
		if( h == 0 ){
			cout << "! Game Over" << endl;
			cout.flush();
			return 0;
		}
	}
	gameClear();
	return 0;
}

Measured memory_bytes: 1300
def max(a,b);       a > b ? a : b                              end
def min(a,b);       a < b ?  a : b                             end
def swap(a,b);      a, b = b, a                                end

n = gets.to_s.to_i
# a = gets.to_s.split.map{|e|e.to_i}
# m = Array.new(n){ gets.to_s.split.map{|e|e.to_i} }
# s = gets.to_s.chomp

puts n * 3.1415 * 2


Measured memory_bytes: 14396
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double dbl;
#define sqr(int) (int * int)
#define sqr3(int) (int * int * int)
#define pi M_PI
#define nl "\n"



  
  int main(){
	ios::sync_with_stdio(true);
	cin.tie(0);
	int a;
	cin >> a;
	if(a >= 1200){
		cout << "ARC";
	}
	else{
		cout << "ABC";
	}
   
  
 }


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

int main() {
  vector<char> A(3);
  for (int i = 0; i < 3; i++) cin >> A.at(i);

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

  if (A.at(0) == 'a' && A.at(1) == 'b' && A.at(2) == 'c') cout << "Yes" << endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
int main() {
	long long N, X;
	cin >> N >> X;
	vector<long>M(N);
	int MIN = 99999999;
	for (long long i = 0; i < N; i++) {
		cin >> M.at(i);
		X -= M.at(i);
		if (MIN > M.at(i))MIN = M.at(i);
	}
	long ans = N;
	if (X != 0) ans += (X / MIN);
	cout << ans << endl;
}

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

#define out cout 
#define in cin
#define el endl

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

int main()
{
	int a, c = 0;
	string s;
	map<string, vector<int>> m;

	while (in >> s >> a){
		m[s].push_back(a);
	}
	for (auto chie : m) {
		cout << chie.first << '\n';
		sort(chie.second.begin(), chie.second.end());
		rep(i, chie.second.size() - 1) {
			cout << chie.second[i] << " ";
		}
		cout << chie.second[chie.second.size() - 1] << '\n';
	}

	return (0);
}

Measured memory_bytes: 3144
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    c=SI()
    if c in "aiueo":print("vowel")
    else:print("consonant")

main()

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int h, w, k;
string s[300];
int ans[310][310];
int cnt;

signed main() {
	cin >> h >> w >> k;
	for (int i = 0; i < h; i++) {
		cin >> s[i];
	}
	int m = 1;
	for (int i = 0; i < h; i++) {
		bool bl = false;
		for (int j = 0; j < w; j++) {
			if (s[i][j] == '#') {
				bl = true;
				cnt++;
			}
		}
		if (bl) {
			for (int j = 0; j < w; j++) {
				if (s[i][j] == '.')ans[i][j] = m;
				else {
					ans[i][j] = m;
					m = min(m + 1, cnt);
				}
			}
		}
		if(bl)m++;
	}
	for (int i = h - 2; i >= 0; i--) {
		if (!ans[i][0]) {
			if (ans[i + 1][0]) {
				for (int j = 0; j < w; j++)ans[i][j] = ans[i + 1][j];
			}
		}
	}
	for (int i = 1; i < h; i++) {
		if (!ans[i][0]) {
			if (ans[i - 1][0]) {
				for (int j = 0; j < w; j++)ans[i][j] = ans[i - 1][j];
			}
		}
	}
	for (int i = 0; i < h; i++) {
		for (int j = 0; j < w; j++) {
			if (j != w - 1)cout << ans[i][j] << " ";
			else cout << ans[i][j] << endl;
		}
	}
}

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

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

    double sum = 0.0;
    for (int i = 0; i < n; i++) {
        double x;
        string u;
        cin >> x >> u;
        if (u == "JPY") sum += x;
        else sum += x * 380000.0;
    }

    printf("%f\n", sum);

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
const int INF = 1<<29;
typedef long long ll;
inline int two(int n) { return 1 << n; }
inline int test(int n, int b) { return (n>>b)&1; }
inline void set_bit(int & n, int b) { n |= two(b); }
inline void unset_bit(int & n, int b) { n &= ~two(b); }
inline int last_bit(int n) { return n & (-n); }
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res;}
lli lint(lli a,lli b)
{
	return a%b==0?a/b:a/b+1;}
int main()
{
	lli n,m,v,p,sum=0;
	cin>>n>>m>>v>>p;
	lli a[100005];
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	lli i=0;
	for(i=n-(p+1);i>=0;i--)
		if(a[i]!=a[i+1])
			break;
	lli ans=(n)-(i+1);
	while(i>=0)
	{
		lli k=p+i;lli inc;
		if(k>=v)
			inc=0;
		else
		{inc=lint((m*(v-k)-sum),(n-p)-i);
			if(inc<0)
				inc=0;
		}
		if(inc+a[n-p]<=a[i]+m)
			ans++;
		sum+=a[n-p]-a[i];
		i--;
	}
cout<<ans;
}


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

int main() {
  int n;
  bool frag = false;
  cin >> n;
  int a[4];
  for (int i = 0; i < 4; i++) {
    a[i] = n % 10;
    n /= 10;
  }
  for (int i = 0; i < 3; i++) {
    if (a[i] == a[i + 1]) frag = true;
  }
  if (frag) cout << "Bad" << endl;
  else cout << "Good" <<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>
#include <map>
#include <queue>
#include <cmath>
#include <complex> // complex<double> a(1.2 , 2.3);// real(): 1.2, imag()2.3
using namespace std;

#define MOD 1000000007
#define ll long long
#define ld long double
#define FOR(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rmsame(a) sort(all(a)),a.erase(unique(all(a)), a.end())
#define rmvector(a,b) rep(i,a.size())rep(j,b.size())if(a[i]==b[j]){a.erase(a.begin()+i);i--;break;}
#define first_more_idx(ve, num) upper_bound(all(ve), num)-ve.begin() // idx = first_more_idx(ve,num); if(idx = ve.size()) , then not exist
#define first_lessequal_idx(ve, num) lower_bound(all(ve), num)-ve.begin()
#define pq_pair_tB priority_queue <pair<ll,ll>, vector<pair<ll,ll> > , greater<pair<ll,ll> > >
#define pq_pair_ts priority_queue <pair<ll,ll> > // only sort first param
template<typename X> bool exist(vector<X> vec, X item){return find(all(vec), item)!=vec.end();}
ll gcd(ll a, ll b){if(b==0)return a;return gcd(b,a%b);}
ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
ll power(ll x, ll n){if(n == 0) return 1;return  (n%2)? x*power(x, n-1)%MOD : power(x*x%MOD, n/2);}
ll dx[]={0, 0, -1, 1};
ll dy[]={1, -1, 0, 0};// up,down,left right


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

    ll N ;
    cin >> N ;
    vector<ll> A, B, C;
    
    rep(i, N){
        ll inp; cin >> inp;
        inp --;
        A.pb(inp);
    }
    rep(i, N){
        ll inp; cin >> inp;
        B.pb(inp);
    }
    
    rep(i, N-1){
        ll inp; cin >> inp;
        C.pb(inp);
    }
    
    ll ans = 0;
    rep(i, N){
        ans += B[A[i]];
        if(i != 0){
            if((A[i] - A[i-1]) == 1){
                ans += C[A[i-1]];
            }
        }
    }
    cout << ans << endl;
    
    //cout << fixed << setprecision(16) << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;

public class Main {

	int INF = 1 << 28;

	void run() {
		Scanner sc = new Scanner(System.in);
		for(;;) {
			int n= sc.nextInt();
			if( n == 0) break;
			int a = 0, b = 0;
			for(int i=0;i<n;i++) {
				int a_ = sc.nextInt();
				int b_ = sc.nextInt();
				if( a_ > b_ ) a += a_+ b_;
				if( a_ < b_ ) b += a_+ b_;
				if( a_ == b_ ) {a += a_; b += b_; }
			}
			System.out.println(a + " " + b);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}

	void debug(Object... os) {
		System.err.println(Arrays.deepToString(os));
	}
}

Measured memory_bytes: 12000
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

using namespace std;
//#define int long long
using ll = long long;
const int MX = 1e6;
const ll inf = 1e13;
const int mod = 1e9+7;
map<ll, ll> prime_factors(ll n) {
    map<ll, ll> res;
    if(n == 1) { // n=1 の素因数分解は n^1
        res[n] = 1;
        return res;
    }
    for(ll i = 2, _n = n; i*i <= _n; ++i) {
        while(n % i == 0) {
            ++res[i]; // 素数i^{res[i]}
            n /= i;
        }
    }
    if(n != 1) res[n] = 1;
    return res;
}
signed main() {
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> b(MX+1);
    bool f = false;
    rep(i,n) {
        cin>> a[i];
    }
    sort(a.begin(),a.end());
    
    int tmp = a[0];
    FOR(i,0,n){
        if(a[i]==1) continue;
        map<ll, ll> pf = prime_factors(a[i]);
        for(auto now:pf) {
            if(now.first==1) continue;
            if(b[now.first]>0) {
                f=true;
                //cout << now.first << endl;
                break;
            }
            b[now.first]++;
        }
        if(f)break;
    }
    if(f) {
        int ans = __gcd(a[0],a[1]);
        FOR(i,2,n) {
            ans = __gcd(ans,a[i]);
        }
        if(ans==1)cout << "setwise coprime" << endl;
        else cout << "not coprime" << endl;
        return 0;
    }else {
        cout << "pairwise coprime" << endl;
    }
    return 0;
}



Measured memory_bytes: 11072
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include <iostream>
#include <algorithm>
#include <math.h>
#define INF 100000000000000
using namespace std;

int main() {
    string s;
    getline(cin, s);
    for(int i=0; i<s.size(); i++){
        if(isalpha(s.at(i))){
            //小文字かどうか？
            if(islower(s.at(i))){
                s.at(i) = toupper(s.at(i));
            }
            else if(isupper(s.at(i))){
                s.at(i) = tolower(s.at(i));
            }

        }
    }
    cout << s << endl;
}


Measured memory_bytes: 3148
#include <bits/stdc++.h>
typedef long long ll;
 
using namespace std;
 
int main() {
	ll N, M;
	cin >> N >> M;
	vector<ll> a(N);
	vector<ll> d(N + 1, 0);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
 
		d[i + 1] += d[i] + a[i];
	}

	map<ll, ll> mp;
	for (int i = 1; i <= N; i++) {
		ll mod = d[i] % M;
		mp[mod]++;
	}

	ll max_size = 0;
	for (auto it = mp.begin(); it != mp.end(); it++) {
		ll size = it->second;
		max_size = max(max_size, size);
	}

	vector<ll> sum(max_size + 1, 0);
	for (int i = 1; i <= max_size; i++) {
		sum[i] += sum[i - 1] + i;
	}

	ll res = 0;
	for (auto it = mp.begin(); it != mp.end(); it++) {
		ll size = it->second;

		if (it->first == 0) {
			res += sum[size];
		} else {
			res += sum[size - 1];
		}
	}

	cout << res << endl;
	return 0;
}


Measured memory_bytes: 5760
# N個の最大公約数
# ユークリッド互除法
# Check


def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)


def lcm(a, b):
    return a*b // gcd(a, b)


def good(A, N):
    # A = sorted(A)
    ans = A[0]
    # for i in range(1, N):
    #     ans = fractions.gcd(A[i], ans)
    for i in range(1, N):
        ans = lcm(ans, A[i])
    return ans


def my(A, N):
    A = sorted(A)

    while True:
        v = A[0]
        tmp = [v]
        for i in range(len(A)):
            if A[i] % v == 1:
                print(1)
                return
            if A[i] % v == 0:
                pass
            else:
                tmp.append(A[i] % v)

        if len(A) == 1:
            print(A[0])
            return

        A = sorted(tmp)
        # print(A)


def main():
    N = int(input())
    A = list(map(int, input().split()))
from heapq import heappush, heappop, heapify
from collections import deque, defaultdict, Counter
import itertools
from itertools import permutations, combinations, accumulate
import sys
import bisect
import string
import math
import time


def I(): return int(input())


def S(): return input()


def MI(): return map(int, input().split())


def MS(): return map(str, input().split())


def LI(): return [int(i) for i in input().split()]


def LI_(): return [int(i)-1 for i in input().split()]


def StoI(): return [ord(i)-97 for i in input()]


def ItoS(nn): return chr(nn+97)


def input(): return sys.stdin.readline().rstrip()


def show(*inp, end='\n'):
    if show_flg:
        print(*inp, end=end)


YNL = {False: 'No', True: 'Yes'}
YNU = {False: 'NO', True: 'YES'}
MOD = 10**9+7
inf = float('inf')
IINF = 10**10
l_alp = string.ascii_lowercase
u_alp = string.ascii_uppercase
ts = time.time()
sys.setrecursionlimit(10**6)
nums = ['1', '2', '3', '4', '5', '6', '7', '8', '9', '10']

show_flg = False
# show_flg = True

def gcd(a, b):
    if b == 0:
        return a
    return gcd(b, a % b)

def main():
    N = I()
    A = LI()
    n = A[0]

    for i in range(1, N):
        n = gcd(n, A[i])

    print(n)


if __name__ == '__main__':
    main()


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

#define SIZE 100000
#define ll long long

int comp(const void *c1, const void *c2);
void swap(ll *x, ll *y);
void array_reverse(ll array[], ll n);

int main()
{
  ll n, i, a[SIZE];
  ll height, width, x, y, j, cnt;
  
  scanf("%lld", &n);
  for (i=0; i<n; i++) scanf("%lld", &a[i]);
  qsort(a, n, sizeof(ll), comp);
  array_reverse(a, n);

  height = -1; width = -1;
  i = 0;
  while (i < n){
    x = a[i];
    cnt = 1;
    for (j=i+1; j<n; j++){
      if (cnt == 4) break;
      y = a[j];
      if (x != y) break;
      cnt++;
    }
    if (1 < cnt && cnt < 4 && height == -1){
      height = x;
    } else if (1 < cnt && cnt < 4 && width == -1){
      width = x;
      printf("%lld\n", height*width);
      break;
    } else if (cnt == 4 && height == -1){
      height = x;
      printf("%lld\n", height*height);
      break;
    } else if (cnt == 4){
      width = x;
      printf("%lld\n", height*width);
      break;
    }
    i = j;
  }
  if (height == -1) printf("%d\n", 0);
  
  return 0;
}

int comp(const void *c1, const void *c2)
{
  int tmp1 = *(ll *)c1;
  int tmp2 = *(ll *)c2;

  if (tmp1 < tmp2) return -1;
  if (tmp1 == tmp2) return 0;
  if (tmp1 > tmp2) return 1;
}

void swap(ll *x, ll *y)
{
  ll tmp = *x;
  *x = *y;
  *y = tmp;
}

void array_reverse(ll a[], ll n)
{
  ll i=0;
  while (i < n/2){
    swap(&a[i], &a[n-i-1]);
    i++;
  }
}

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

using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz size()
#define pb(x) push_back(x) 
#define bg begin()
#define ed end()
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define mp(x,y) make_pair(x,y)
const ll MOD=1000000007;
const ll INF=-10000000000;

ll maxx(ll x,ll y,ll z){
	return max(max(x,y),z);
}
ll minn(ll x,ll y,ll z){
	return min(min(x,y),z);
}
ll gcd(ll x,ll y){
	if(x%y==0) return y;
    else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
	return x*(y/gcd(x,y));
}

//a,b x
int main(){
	string s; cin>>s;
  sort(s.bg,s.ed);
  char mem=s[0];
  rep1(i,s.sz-1){
   if(s[i]==mem){
    cout<<"no";
    return 0; 
   }
    mem=s[i];
  }
  cout<<"yes";
}

Measured memory_bytes: 256
//#pragma Gbb optimize("Ofast") 
#include<set>
#include<map>
#include<cmath>
#include<queue>
#include<cstdio>
#include<string>
#include<vector>
#include<fstream>
#include<cstdlib>
#include<cstring>
#include<iostream>
#include<time.h>
#include<algorithm>
#define inf 0x3f3f3f3f
using namespace std;

long long n;

int main()
{
	ios::sync_with_stdio(false);
	cin >> n;
	long long ans = n / 500 * 1000;
	ans += n % 500 / 5 * 5;
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>
#include <array>

using namespace std;

using ll = long long;
using ull = unsigned long long;

bool ok(string s)
{
    int n = s.size();
    for (int i = 0; i < n/2; ++i) {
        if (s[i] != s[n-1-i]) {
            return false;
        }
    }

    return true;
}

int main()
{
    string S;
    cin >> S;

    int N = S.size();

    if (ok(S) && ok(S.substr(0, (N-1)/2)) && ok(S.substr((N+3)/2-1))) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 888
import java.util.*;
import java.lang.*;

public class Main {
	public static void main(String[] args) {
		ArrayList<ArrayList<Long>> vs = new ArrayList<>();
		for (long i = 0; i < 4; i++) {
			vs.add(new ArrayList<Long>());
		}
		
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		long W = sc.nextLong();
		long basew = 0;

		for (int i = 0; i < n; i++) {
			long w = sc.nextLong();
			long v = sc.nextLong();

			if (i == 0) basew = w;

			vs.get((int)(w - basew)).add(v);			
		}

		ArrayList<ArrayList<Long>> accs = new ArrayList<>();
		for (int i = 0; i < 4; i++) {
			ArrayList<Long> v = new ArrayList<Long>();
			v.add(0L);
			accs.add(v);
		}

		for (int i = 0; i < 4; i++) {
			vs.get(i).sort(Comparator.reverseOrder());
			for (int j = 0; j < vs.get(i).size(); j++) {
				long accum = accs.get(i).get(j) + vs.get(i).get(j);
				accs.get(i).add(accum);
			}
		}

		long maxv = 0;
		for (int i = 0; i < accs.get(0).size(); i++) {
		for (int j = 0; j < accs.get(1).size(); j++) {
		for (int k = 0; k < accs.get(2).size(); k++) {
		for (int l = 0; l < accs.get(3).size(); l++) {
			long w = basew * i + (basew + 1) * j +
			        (basew + 2) * k + (basew + 3) * l;
 			long v = accs.get(0).get(i) +
			        accs.get(1).get(j) +
			        accs.get(2).get(k) +
			        accs.get(3).get(l);
			if (w <= W) {
				if (maxv < v) {
					maxv = v;
				}
			}
		}}}}

		System.out.println(maxv);
	}
}


Measured memory_bytes: 26208
#include <cstdio>
#include <cstdint>
#include <map>
#include <stdio.h>
#include <string.h>
#include <vector>
#include <algorithm>
#include <cstddef>
#include <cctype>
#include <iomanip>
#include <iostream>
#include <tuple>
#include <utility>
#include <math.h>
#include <stack>

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

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

const long long mod = 1e9+7;

void chmod(long long &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

long long modpow(long long x, long long n){
    if(n==0) return 1;
    long long res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };



/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */

bool search(std::vector<int> const &a, int q) {
    int n = a.size();
    for(int i=0; i<n; ++i) if(a[i] == q) { return true; }
    return false;
}

int main() {
    int n;
    scanf("%d", &n);
    std::vector<int> s(n);
    for(int i=0; i<n; ++i) { scanf("%d", &s[i]); }
    int q;
    scanf("%d", &q);
    std::vector<int> t(q);
    for(int i=0; i<q; ++i) { scanf("%d", &t[i]); }

    int ans = 0;
    for(int i=0; i<q; ++i) if(search(s, t[i])) { ans += 1; }
    printf("%d\n", ans);

    return 0;
}



Measured memory_bytes: 3192
import java.util.*;
public class Main {
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        Double[] x = new Double[n];
        String[] u = new String[n];
        for(int i = 0 ; i < n ; i++ ){
            x[i] = sc.nextDouble();
            u[i] = sc.next();
            if(u[i].equals("BTC")){
                x[i] *= 380000;
            }
            if(i != 0){
                x[0] += x[i];
            }
        }
        System.out.println(x[0]);
        sc.close();
    }
}

Measured memory_bytes: 36680
n=int(input())
S=list(map(int,input().split()))
q=int(input())
T=list(map(int,input().split()))

import bisect
ans=0

for t in T:
    b=bisect.bisect(S,t)
    #print(b)
    if b!=0 and t==S[b-1]:
        ans+=1
print(ans)



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

int main()
{
    int N, K; cin >> N >> K;
    vector<pair<int, int>> xy(N); for (auto& p : xy) cin >> p.first >> p.second;
    sort(xy.begin(), xy.end());

    ll ans = LLONG_MAX;
    for (int i = 0; i < N-1; i++) {
        for (int j = i + K - 1; j < N; j++) {
            vector<int> y;
            for (int m = i; m <= j; m++) {
                y.push_back(xy[m].second);
            }
            sort(y.begin(), y.end());
            for (int m = 0; m + K - 1 < y.size(); m++) {
                int n = m + K - 1;
                ll a = (ll)(xy[j].first - xy[i].first) * (y[n] -y[m]);
                if (a < ans) ans = a;
            } 
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 10000

int main(){
    int H[MAX], W[MAX];
    int i, j, k;

    for(i = 0; i < MAX; i++){
        scanf("%d %d", &H[i], &W[i]);
        if(H[i] == 0 && W[i] == 0) break;
    }

    for(i = 0; i < MAX; i++){
        if(H[i] == 0 && W[i] == 0) break;
        for(j = 0; j < H[i]; j++){
            for(k = 0; k < W[i]; k++){
                if(k % 2 == 0 && j % 2 == 0) printf("#");
                else if(k % 2 == 0 && j % 2 == 1) printf(".");
                else if(k % 2 == 1 && j % 2 == 0) printf(".");
                else if(k % 2 == 1 && j % 2 == 1) printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }

    return 0;
}


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

ll N,K,S;
int main(){
    cin>>N>>K>>S;
    for(ll i=0;i<K;i++){
        cout<<S<<" ";
    }
    const ll MAX=1000000000;
    for(ll i=K;i<N;i++){
        cout<<((S==MAX)?1:MAX)<<" ";
    }cout<<endl;

    return 0;
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto& x:c){cout<<x<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

constexpr int atcoder_mod = 1e9+7;

using namespace std;
using ll = long long;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

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

	int N=in();
	auto A=vecin<ll>(N);
	A.push_back(0);
	deque<ll> F(N+1,0),B(N+1,0),C(N+1,0);
	C[0] = abs(A[0]);
	for(int i=1;i<=N;i++){
		C[i] = abs(A[i]-A[i-1]);
	}
	F[0]=C[0],B[N]=C[N];
	for(int i=1;i<=N;i++){
		F[i] = F[i-1]+C[i];
		B[N-i] = B[N+1-i]+C[N-i];
	}
	F.push_front(0),B.push_back(0);
	A.insert(A.begin(),0);
	REP(i,N){
		out(F[i]+B[i+2]+abs(A[i]-A[i+2]));
	}

	return 0;
}


Measured memory_bytes: 4464
#include <stdio.h>
int main(void){
    int h,m,s;
    scanf("%d",&s);
    h = s/3600;
    m = (s-h*3600)/60;
    s = s-h*3600-m*60;
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}


Measured memory_bytes: 2048
using System;
using System.Collections.Generic;
using System.Linq;

namespace CSharpSample01
{


    class Program
    {

        

        static void Main(string[] args)
        {

            int X = int.Parse(Console.ReadLine());

            int max = 1;

            for(int i = 2; i <= (int)Math.Sqrt(X); i++)
            {
                int a = i;
                while(a <= X)
                {
                    a *= i;
                }

                a /= i;
                //Console.WriteLine(a);
                if (max < a) max = a;

            }

            Console.WriteLine(max);

        }
    }
}

Measured memory_bytes: 11092
N = int(input())
A = list(map(int,input().split()))

cnt = {}
for i in A:
    if i in cnt:
        cnt[i] += 1
    else:
        cnt[i] = 1
total = 0
for i in cnt:
    if cnt[i]>=2:
        total += cnt[i] * (cnt[i]-1) // 2
        
for i in A:
    if cnt[i] == 1:
        print(total)
    else:
        #print(total - cnt[i]* (cnt[i]-1) // 2 + (cnt[i]-1) * (cnt[i]-2) // 2)
        print(total - (cnt[i]-1))

Measured memory_bytes: 32088
#include<iostream>
#include<string>
using namespace std;
int x[10000], H, W; string S;
int main() {
	cin >> W >> H;
	for (int i = 0; i < H; i++) {
		cin >> S; for (int j = 0; j < W; j++)if (S[j] == 'W')x[j + 1] += 1;
	}
	for (int i = 1; i <= W; i++)x[i] += x[i - 1];
	int SUM = x[H];
	int minid = 0, maxn = 10000000;
	for (int i = 0; i <= W; i++) {
		int cnt = (i*H - x[i]);
		int P = SUM - x[i]; cnt += P;
		if (maxn > cnt) { minid = i; maxn = cnt; }
	}
	cout << minid << ' ' << minid + 1 << endl;
	return 0;
}

Measured memory_bytes: 1268
#include <bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
// #include <ext/rope>
// using namespace __gnu_cxx;
typedef long long int ll;
typedef long double ld;
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define mxe(v) *max_element(v.begin(), v.end())
#define mne(v) *min_element(v.begin(), v.end())
#define ve vector
#define lb lower_bound
#define ub upper_bound
#define bb break
#define cc continue
#define rem 1000000007
#define PI 3.141592653589793238462643383279502
ll power(ll x, ll y, ll p)
{
    ll res = 1; // Initialize result
    x = x % p;  // Update x if it is more than or
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1; // y = y/2
        x = (x * x) % p;
    }
    return res;
}
ll modInverse(ll n, ll p)
{
    return power(n, p - 2, p);
}
struct point
{
    ll x, y;
};
int main()
{
    FAST
    // freopen("input1.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
    ll h1,m1,h2,m2,k;
    cin>>h1>>m1>>h2>>m2>>k;
    ll x1=h1*60+m1;
    ll x2=h2*60+m2;
    ll diff=x2-x1;
    diff-=k;
    cout<<max(diff,(ll)(0));
}


Measured memory_bytes: 3692
#include <iostream>

using namespace std;

typedef long long ll;

int main(){

    ll a, b, c;
    cin >> a >> b >> c;

    int k;
    cin >> k;

    while (k--){
        if (a >= b && a >= c){
            a *= 2;
        }
        else if (b >= a && b >= c){
            b *= 2;
        }
        else {
            c *= 2;
        }
    }

    cout << a + b + c << endl;

    return 0; 
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <inttypes.h>
#include <string.h>
#include <math.h>

intmax_t get_gcd (intmax_t a, intmax_t b)
{
    if (b == 0) return a;
    else return get_gcd(b, a % b);
}

intmax_t get_lcm (intmax_t a, intmax_t b)
{
    intmax_t g = get_gcd(a, b);
    return a / g * b;
}

int main (int argc, char const *argv[])
{
    intmax_t A, B, C, D;
    intmax_t lcm, ans = 0;

    scanf("%jd%jd%jd%jd", &A, &B, &C, &D);

    lcm = get_lcm(C, D);

    ans += B / C;
    ans += B / D;
    ans -= B / lcm;
    
    ans -= (A - 1) / C;
    ans -= (A - 1) / D;
    ans += (A - 1) / lcm;

    ans = B - A + 1 - ans;

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

    return 0;
}


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

using namespace std;

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

#define FOR(i, n, m) for(ll (i)=(m);(i)<(n);++(i))
#define REP(i, n) FOR(i,n,0)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;
const ll INF = (ll) 1e15;

ll dp[100005][5][5];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S;
    cin >> S;
    ll N = S.length();
    memset(dp, 0, sizeof(dp));
    ll p = 1;
    REP(i, N) {
        REP(j, 3) {
            REP(n, 3) {
                if (S[i] != '?' && S[i] - 'A' != n)
                    continue;
                REP(t, 3) {
                    dp[i + 1][n][j] += dp[i][t][j];
                }
                dp[i + 1][n][j] %= MOD;
            }
        }
        REP(j, 3) {
            if (S[i] != '?' && S[i] - 'A' != j)
                continue;

            if (j == 0) {
                dp[i + 1][0][0] += p;
            }
            if (j == 1) {
                REP(t, 3) {
                    dp[i + 1][1][1] += dp[i][t][0];
                }
            }
            if (j == 2) {
                REP(t, 3) {
                    dp[i + 1][2][2] += dp[i][t][1];
                }
            }
            dp[i + 1][j][j] %= MOD;
        }
        if (S[i] == '?')
            p = (p * 3LL) % MOD;
    }

#if false
    REP(i, N) {
        REP(j, 3) {
            REP(k, 3) {
                cout << dp[i + 1][j][k] << " ";
            }
            cout << endl;
        }
        cout << "--------" << endl;
    }
#endif


    ll ans = dp[N][0][2] + dp[N][1][2] + dp[N][2][2];
    cout << ans % MOD << endl;
    return 0;
}

Measured memory_bytes: 20048
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <algorithm>
#include <bitset>
#include <complex>

#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,n) for(int i=0;i<(n); i++)

using namespace std;
typedef long long ll;
const int MAX_N = 100000;
const int MAX_W = 1000000000;
static const int INF = 1<<29;
string s,t,ans;
int dp[3001][3001];

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0); //この2行はより速度を向上させる
    // 追加２, 以降 cin の入力元が 'input.txt' になる
    //提出時に消す！！

    int r;
    cin >> r;
    int ans =3*r*r;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N, A = map(int, input().split())
X = list(map(int, input().split()))

dp = [[[0]*(50*(N+1)+1) for _ in range(N+1)] for _ in range(N+1)]
dp[0][0][0] = 1

for i in range(N):
    for k in range(N):
        for s in range(50*N+1):
            dp[i+1][k][s] += dp[i][k][s]
            dp[i+1][k+1][s+X[i]] += dp[i][k][s]

ans = 0
for k in range(1, N+1):
    ans += dp[N][k][A*k]

print(ans)

Measured memory_bytes: 95452
n,m,a,b=[int(i) for i in input().split()]
l=[[0 for i in range(m)] for j in range(n)]

for i in range(n):
    for j in range(m):
        if i<b:
            if j<a:
                l[i][j] = 0
            else:
                l[i][j] = 1
        else:
            if j<a:
                l[i][j] = 1
            else:
                l[i][j] = 0
for i in range(n):
    print("".join(str(e) for e in l[i]))

Measured memory_bytes: 53468
n=gets.to_i
t=1.0*4/n
a=[]
b=[0]
1.upto(3500) do |i|
  b<< 1.0/i
end
1.upto(3500) do |i|
  gg = b[i]
  i.upto(3500) do |j|
    g = t-gg - b[j]
    if g>0
      if (ggg=(1.0/g).round) <= 3500 && (g-(b[ggg])).abs <= 0.000000000001
        a << [i,j,ggg]
        a << [i,j,ggg+1]
      end
    end
  end
end
a.each do |e|
  if e[0]*e[1]*e[2]*4 == (e[0]*e[1]+e[0]*e[2]+e[2]*e[1])*n
    puts e.* " "
    break
  end
end



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


int main(){
    int N, A, B;
    cin >> N >> A >> B;

    int train = N * A;
    int min;
    if(train > B){
        min = B;
    }else{
        min = train;
    }

    cout << min << endl;

    return 0;
}


Measured memory_bytes: 256
#include"stdio.h"

int main(void)
{
  unsigned int X,Y,ans;
  
  //input
  scanf("%d %d",&X,&Y);
  
  //check&output
  if(Y%2 != 0||Y-2*X>2*X)
  {
  	printf("No");
  }else{
  	printf("Yes");
  }
  
  return 0;
}

Measured memory_bytes: 1728
//Dragon_warrior7(IITK)
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define pb push_back
#define nl cout << '\n'
#define sor(x) sort(x.begin(), x.end())
#define rev(v) reverse(v.begin(), v.end())
#define maxin(v) *max_element(v.begin(), v.end())
#define minin(v) *min_element(v.begin(), v.end())
#define sumall(vect) accumulate(vect.begin(), vect.end(), 0)
#define count(x, vect) count(vect.begin(), vect.end(), x)
#define lb(v, temp) lower_bound(v.begin(), v.end(), temp)
#define ub(v, temp) upper_bound(v.begin(), v.end(), temp)
#define fi first
#define se second
#define llmax 100000000000000000
#define deb(x) cout << #x << " " << x << "\n"
#define pll pair<ll, ll> 
#define vll vector<ll> 
#define rub cout << "------------------------------------\n"
#define min(a, b, c) min(a, min(b, c))
#define max(a, b, c) max(a, max(b, c))
void read(vector<ll> &v)
{
	for (int i = 0; i < v.size(); i++)
		cin >> v[i];
}

void print(vector<ll> v)
{
	for (int i = 0; i < v.size(); i++)
		cout << v[i] << " ";
}
ll n,m,a,b,temp;
string str;
set<ll> s;
vll v;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int m1,m2,d1,d2;
	cin>>m1>>d1;
	cin>>m2>>d2;
	if(m2>m1)
	cout<<1;
	else
	cout<<0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define MAX 10000000
using namespace std;
int par[MAX];
int N,Q;

void init()
{
  rep(i,MAX)par[i] = i;
}

int find(int x)
{
  if(x == par[x])return x;
  return find(par[x]);
}

bool unit(int x,int y)
{
  x = find(x);
  y = find(y);
  if(x != y)par[y] = x;
}

bool same(int x,int y)
{
  return find(x) == find(y);
}

int main()
{
  while(cin >> N >> Q,N|Q)
    {
      init();
      REP(i,1,N)
	{
	  int variable;
	  cin >> variable;
	  variable--;
	  par[i] = variable;
	}

      long long cost = 0;
      rep(i,Q)
	{
	  char Query;
	  int v;
	  cin >> Query >> v;
	  v--;
	  if(Query == 'Q')
	    {
	      cost += find(v)+1;
	    }
	  else 
	    {
	      par[v] = v;
	    }
	}
      cout << cost << endl;
    }
  return 0;
}

 

Measured memory_bytes: 40216
#!/usr/bin/env python3
import sys
import networkx as nx
def input(): return sys.stdin.readline().rstrip()

def main():
    n,q = map(int, input().split())
    uf=nx.utils.UnionFind()
    for _ in range(q):
        t,u,v=map(int, input().split())
        if t==0:
            uf.union(u,v)
        else:
            print(1 if uf[u]==uf[v] else 0)
 
 
 
if __name__ == '__main__':
    main()

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

using namespace std;

int n, k, a[200005];

int main()
{
	scanf("%d%d", &n, &k);
	for(int i = 1; i <= n; ++i) scanf("%d", &a[i]);
	for(int i = k + 1; i <= n; ++i)
	{
		if(a[i] > a[i - k]) printf("Yes\n");
		else printf("No\n");
	}
	return 0;
}

Measured memory_bytes: 4408
# 累積和してXを越えるところまでいったら、そこまでの数の組み合わせで達成できる
# （ことがエスパーでわかる）
# TLEなったけど1WAなんで1かなこれ
# 配列は使わないことにする
X = int(input())
n = 0
c = 0
while True:
    if n >= X:
        break
    else:
        c += 1
        n += c

print(c)


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

typedef long long int ll;
typedef unsigned long long int ull;
#define rep(i,n) for(ll i=0;i<(n);i++)

using namespace std;


int main(){
    ll x;
    cin >> x;

    int t[2] = {6, 5};
    int i = 0;
    ll cnt = 0;

    cnt += 2 * (x / 11);
    x -= 11*(x/11);


    while(0 < x){
        x -= t[i];
        i++;
        i %= 2;
        cnt++;
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string[] str = Console.ReadLine().Split();
		long A = long.Parse(str[0]);
		long B = long.Parse(str[1]);
		long C = long.Parse(str[2]);
		for(var i=1;i<=10;i++){
			C = A*C-B;
			Console.WriteLine(C);
		}
	}
}

Measured memory_bytes: 11092
import sys
input = sys.stdin.readline

n,m,k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
sa = [0] * (n+1)
sb = [0] * (m+1)
for i in range(n):
  sa[i+1] = sa[i] + a[i]
for i in range(m):
  sb[i+1] = sb[i] + b[i]
rx = 0
rb = m
for ra in range(0,n+1): 
  while (sb[rb] + sa[ra]) > k and rb>0 :
    rb-=1
  if (sb[rb] + sa[ra]) <= k:
    rx = max(rx,ra+rb)
print(rx)


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

unordered_map<int, int> m1, m2, m3;
int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	long long r = 0;
	long long g = 0;
	long long b = 0;
	for (auto i = 0;i < n;i++ ) {
		if (s[i] == 'R') {
			r++;
			
		}
		if (s[i] == 'G') {
			g++;

		}
		if (s[i] == 'B') {
			b++;
		}
	}
	long long ans = r*g*b;

	for (int i = 0;i < n;i++) {
		for (int j = 0;j < n;j++) {
			if (i< 2 * j - i &&2 * j - i >= 0 && (2 * j) - i < n && i<j && 2 * j - i>j&& s[i] != s[j] && s[j] != s[(2 * j) - i] && s[i] != s[(2 * j) - i]) {
				ans--;
			}

		}


	}
	cout << ans;

}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5,M=2e4+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a,b) memset(a,b,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first
#define se second
#define pb push_back
#define il inline
int n,a[N];
int main(){
	cin>>n>>a[1];
	deque<int>q;
	q.push_back(a[1]);
	int pos=1;
	for(int i=2;i<=n;i++){
		cin>>a[i];
		if(i%2==0) q.push_back(a[i]);
		else q.push_front(a[i]);
		pos=(pos==1)?q.size():1;
	}
	if(pos==1){
		while(!q.empty()){
			printf("%d ",q.front());
			q.pop_front();
		}
	}
	else {
		while(!q.empty()){
			printf("%d ",q.back());
			q.pop_back();
		}
	}
	return 0;
}

Measured memory_bytes: 5332
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
//        int a = sc.nextInt();
//        int b = sc.nextInt();
//        int c= sc.nextInt();
//        int d= sc.nextInt();
//        int e= sc.nextInt();
       
        int ar[] = new int[5];
        boolean what = true;
        for(int i = 0 ; i<5 ; i++){
            ar[i] = sc.nextInt();
        }
         int k= sc.nextInt();
         for(int i = 0 ; i<ar.length-1 ; i++){
             for(int j = i; j<ar.length-1 ;j++){
                 
                 if(Math.abs((ar[i] - ar[j+1])) >k) {what = false;

                 break ;}
                
             }
              if(what == false) break;
         }
         
         if(what == false) System.out.println(":(");
         else System.out.println("Yay!");
    }
}


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

int main() {
	double x1,x2,y1,y2;
	cin >> x1 >> y1 >> x2 >> y2;
	double length;
	length=pow(x2-x1,2.0)+pow(y2-y1,2.0);
	cout << fixed << setprecision(10);
	cout << sqrt(length) << endl;
}


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

const int MAX = 1 << 19;
class BIT {
  vector<int> v;
public:
  BIT() : v(MAX) {}
  void add(int i, int val) {
    ++i;
    for (; i <= MAX; i += i & -i) {
      v[i] += val;
    }
  }
  int get(int i) {
    int sum = 0;
    for (; i > 0; i -= i & -i) {
      sum += v[i];
    }
    return sum;
  }
  int get(int l, int r) {
    return get(r) - get(l);
  }
};

BIT bits[26];
int main() {
  int n, q;
  string s;
  cin >> n >> s >> q;
  for (int i = 0; i < n; ++i) {
    bits[s[i] - 'a'].add(i, 1);
  }
  for (int i = 0; i < q; ++i) {
    int t;
    cin >> t;
    if (t == 1) {
      int p;
      char c;
      cin >> p >> c;
      --p;
      int x = s[p] - 'a';
      int y = c - 'a';
      s[p] = c;
      bits[x].add(p, -1);
      bits[y].add(p, 1);
    } else {
      int l, r;
      cin >> l >> r;
      --l;
      int cnt = 0;
      for (int c = 0; c < 26; ++c) {
        cnt += bits[c].get(l, r) > 0;
      }
      cout << cnt << endl;
    }
  }
}


Measured memory_bytes: 54276