akhauriyash/Code-Regression huggingface dataset:
/*     *******************Bismillahir Rahmanir Rahim************************
                          **************************
                          #    MD. ASFAKUL GHANI   #
                          #       *ProMAGFAT*      #
                          #         CSE-25         #
                          #JAHANGIRNAGAR UNIVERSITY#
                          #    Dhaka,Bangladesh    #
                          &&&&&&&&&&&&&&&&&&&&&&&&&#
*/

#include <bits/stdc++.h>
using namespace std;

#define fasterIO ios_base::sync_with_stdio(false);cin.tie(NULL)
#define Im int main(int argc, char *argv[])
#define ll long long
#define sc scanf
#define pf printf
#define rn0 return 0
#define rn return
#define f0(i,n) for(ll i=0;i<n;i++)
#define f1(i,n) for(ll i=1;i<=n;i++)
#define f2(i,n) for(ll i=n-1;i>=0;i--)
#define pi 2*acos(0.0)
#define modulo 1000003
#define dd double
#define PI 3.14159265358979
#define pi 2*acos(0.0)
#define p_b push_back
#define ps push

/*
ll for_binarySearch(ll a,ll b,ll aa[],ll x){while(a<=b){ll mid=(a+b)/2;if(aa[mid]==x) return 1;else if(aa[mid] > x) b=mid-1;else a=mid+1;}return -1;}
ll for_gcd(ll a,ll b){if(a==0) return b;else return for_gcd(b%a,a);}
ll for_prime(ll x){for (ll i=2;i*i<=x;i++){if(x%i==0) return 0;}return 1;}
void for_swap(char *x,char *y){char temp;temp=*x;*x=*y;*y=temp;}
ll for_big_mod(ll b,ll p,ll m){if(p==0) return 1;else if(p%2==0){ll k=for_big_mod(b,p/2,m);return (k*k)%m;}else return ((b%m)*(for_big_mod(b,p-1,m)))%m;}
ll for_josephus(ll n,ll k){if(n==1) return 1;return (for_josephus(n-1,k)+k-1)%n+1;}
ll for_gcdExtended(ll a,ll b,ll *x,ll *y){if(a==0){*x=0;*y=1;return b;}ll x1,y1;ll gcd=for_gcdExtended(b%a,a,&x1,&y1);*x=y1-(b/a)*x1;*y=x1;return gcd;}
*/

ll vc[105][105];

Im
{
    //fasterIO;

    ll tc;
    cin>>tc;
    ll i=0;
    while (tc--){
        string s1;
        cin>>s1;
        ll sz=s1.size();
        for (ll j=0; j<sz; j++){
            vc[i][s1[j]-97]++;
        }
        i++;
    }

    ll p=i;
    //for (i=0; i<p; i++) sort(vc[i].begin(),vc[i].end());

    string s1;
    for (i=0; i<26; i++){
      ll mn=1234;
        for (ll j=0; j<p; j++){
            mn=min(mn,vc[j][i]);
        }
       for (ll k=0; k<mn; k++){
          s1+=(i+'a');
       }
    }
    sort(s1.begin(),s1.end());
    cout << s1 << endl;

   // main();

    rn0;
}


Measured memory_bytes: 256
import Control.Applicative
import Control.Monad
import Data.List

main :: IO ()
main = do
    [sx, sy, tx, ty] <- fmap read . words <$> getLine :: IO [Int]
    let w = tx - sx
    let h = ty - sy
    let r1 = replicate w 'R' ++ replicate h 'U'
    let r2 = replicate w 'L' ++ replicate h 'D'
    let r3 = 'D' : replicate (w + 1) 'R' ++ replicate (h + 1) 'U' ++ ['L']
    let r4 = 'U' : replicate (w + 1) 'L' ++ replicate (h + 1) 'D' ++ ['R']
    let ans = concat [r1, r2, r3, r4]
    putStrLn ans

Measured memory_bytes: 1020
#include <iostream>
using namespace std;
#include <cstdio>
#include <cmath>
#include <cstring>
#include <string>
#include <algorithm>
#include <functional> //sort(A,A.end(),greater<int>());???????????????
#include <queue>
#include <stack>
#include <vector>

#define INF 10 << 10
#define MP make_pair

int map[124][124];
bool map_flg[124][124];
int x_move[] = { 0,0,1,-1 };
int y_move[] = { -1,1,0,0 };

int main() {
	int w, h;

	while (cin >> w >> h && w != 0 && h != 0) {
		memset(map, 0, sizeof(map));
		memset(map_flg, true, sizeof(map_flg));
		int xs, ys;
		int xg, yg;
		int n;

		cin >> xs >> ys >> xg >> yg >> n;

		for (int i = 1; i <= n; ++i) {
			int c, d, x, y;
			cin >> c >> d >> x >> y;
			int x_, y_;
			if (d == 0) {
				x_ = 4;
				y_ = 2;
			}
			else {
				x_ = 2;
				y_ = 4;
			}
			for (int j = y; j < y + y_; ++j) {
				for (int j2 = x; j2 < x + x_; ++j2) {
					map[j][j2] = c;
				}
			}
		}

		if (map[ys][xs] != map[yg][xg]) {
			cout << "NG" << endl;
			continue;
		}

		stack<pair<int, int> > st;
		st.push(MP(xs, ys));
		int m_c = map[ys][xs];
		bool flg = false;
		while (!st.empty()) {
			int x = st.top().first, y = st.top().second;
			st.pop();
			map_flg[y][x] = false;
			for (int i = 0; i < 4; ++i) {
				int x_ = x + x_move[i], y_ = y + y_move[i];
				if (map[y_][x_] == m_c && map_flg[y_][x_]) {
					if (y_ == yg && x_ == xg) {
						flg = true;
						break;
					}
					st.push(MP(x_, y_));
				}
			}
			if (flg) { break; }
		}

		if (flg) { cout << "OK" << endl; }
		else { cout << "NG" << endl; }
	}

	return 0;
}

Measured memory_bytes: 3144
import sys
sys.setrecursionlimit(1000000000)
from itertools import count
from functools import lru_cache
from collections import defaultdict
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok
#

def main():
    S = input()
    print(sum(S[i]!=S[-(i+1)] for i in range(len(S)//2)))

main()


Measured memory_bytes: 3828
use std::cmp::Ordering;

#[derive(Eq, PartialEq)]
struct Reverse<T>(T);

impl<T: PartialOrd> PartialOrd for Reverse<T> {
  fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
    self.0.partial_cmp(&other.0).map(Ordering::reverse)
  }
}

impl<T: Ord> Ord for Reverse<T> {
  fn cmp(&self, other: &Self) -> Ordering {
    self.0.cmp(&other.0).reverse()
  }
}

fn main() {
  use std::io::{Read, Write, BufWriter};
  let mut a = Vec::new();
  std::io::stdin().read_to_end(&mut a).unwrap();
  let a = String::from_utf8(a).unwrap();
  let mut a = a.split_whitespace();
  let mut b = BufWriter::new(std::io::stdout());
  macro_rules! yomu { () => (a.next().unwrap().parse().unwrap()) }
  macro_rules! kaku { ($($arg:tt)*) => (writeln!(b, $($arg)*).unwrap()) }

  let x: usize = yomu!();
  let y: usize = yomu!();
  let z: usize = yomu!();
  let k: usize = yomu!();
  let mut a: Vec<i64> = Vec::new();
  let mut b: Vec<i64> = Vec::new();
  let mut c: Vec<i64> = Vec::new();
  for _ in 0..x { a.push(yomu!()); }
  for _ in 0..y { b.push(yomu!()); }
  for _ in 0..z { c.push(yomu!()); }
  a.sort();
  b.sort();
  c.sort();
  a.reverse();
  b.reverse();
  c.reverse();

  use std::collections::{BinaryHeap, BTreeSet};
  let mut h: BinaryHeap<(i64, Reverse<(usize, usize, usize)>)> = BinaryHeap::new();
  let mut used: BTreeSet<(usize, usize, usize)> = BTreeSet::new();

  macro_rules! ireru {
    ($i:expr, $j:expr, $k:expr) => {
      if $i < x && $j < y && $k < z && !used.contains(&($i, $j, $k)) {
        let cost = a[$i] + b[$j] + c[$k];
        h.push((cost, Reverse(($i, $j, $k))));
        used.insert(($i, $j, $k));
      }
    }
  }
  ireru!(0, 0, 0);

  for _ in 0..k {
    let (v, Reverse((i, j, k))) = h.pop().unwrap();
    kaku!("{}", v);
    ireru!(i+1, j, k);
    ireru!(i, j+1, k);
    ireru!(i, j, k+1);
  }
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define popcnt(x) __builtin_popcount(x)
#define inf 0x3f3f3f3f
#define watch(x) cout << (#x) << " is " << (x) << endl
#define rand() (rand() << 15 | rand())
using namespace std;
typedef long long  ll;
#define EPS 1e-9
#define PI acos(-1.0)
const int P = 31 , MOD = 1e9 + 9; // Hashing parameters

void compute_hash(string const& s , vector<int> &preH) {
   int n = (int)s.size();
   preH.resize(n);
   long long hash_value = 0;
   long long p_pow = 1;
   for(int i = 0 ; i < n ; ++i){
      hash_value = (hash_value + (s[i] - 'a' + 1) * p_pow) % MOD;
      p_pow = (p_pow * P) % MOD;
      preH[i] = hash_value;
   }
}

int power(int b, int p) {
   if (p == 0) return 1;
   int res = power(b, p / 2);
   res = 1LL * res * res % MOD;
   if (p & 1) {
      res = 1LL * b * res % MOD;
   }
   return res;
}

int modInv(int x) {
   return power(x, MOD - 2);
}

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

int add(int a , int b , int m){
   return (1LL * (a % m) + (b % m)) % m;
}

long long get_hash(int l , int r , vector<int> &preH){
   long long ret = (preH[r] - (l ? preH[l - 1] : 0) + MOD) % MOD;
   return mul(ret , modInv(power(P , l)) , MOD);
}

int n;
string s;
bool valid(int sz , vector<int> &preH){
   unordered_map<int , bool> mp;
   for(int i = n - sz; i >= 0 ; --i){
      int cur = get_hash(i , i + sz - 1 , preH);
      mp[cur] = true;
      int j = i - sz;
      if(j < 0)return false;
      int nxt = get_hash(j , j + sz - 1 , preH);
      if(mp.count(nxt)){
         return true;
      }
   }
   return false;
}

int main() {
   ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
   cin >> n;
   cin >> s;
   vector<int> preH;
   compute_hash(s , preH);
   int l = 1 , r = n , ans = 0;
   while (l <= r){
      int mid = (l + r) / 2;
      if(valid(mid , preH)){
         ans = mid , l = mid + 1;
      }
      else{
         r = mid - 1;
      }
   }
   cout << ans << "\n";
}

Measured memory_bytes: 608
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		final Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] x = new int[n];
		int[] y = new int[n];
		int[] h = new int[n];
		for (int i = 0; i < n; i++) {
			x[i] = sc.nextInt();
			y[i] = sc.nextInt();
			h[i] = sc.nextInt();
		}

		int ansX = 0;
		int ansY = 0;
		int ansH = 0;
		boolean flag = true;
		for (int tmpX = 0; tmpX <= 100; tmpX++) {
			for (int tmpY = 0; tmpY <= 100; tmpY++) {
				int tmpH = 0;
				for (int k = 0; k < n; k++) {
					if (h[k] > 0) {
						tmpH = Math.abs(tmpX - x[k]) + Math.abs(tmpY - y[k]) + h[k];
						break;
					}
				}
				flag = true;
				for (int j = 0; j < n; j++) {
					if (h[j] != Math.max(tmpH - Math.abs(tmpX - x[j]) - Math.abs(tmpY - y[j]), 0)) {
						flag = false;
						break;
					}
				}
				if (flag) {
					ansH = tmpH;
					ansY = tmpY;
					break;
				}
			}
			if (flag) {
				ansX = tmpX;
				break;
			}
		}
		System.out.println(ansX + " " + ansY + " " + ansH);
	}
}


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

int main(){
  int h,w,n;
  cin>>h>>w>>n;
  int sr,sc;
  cin>>sr>>sc;
  sr--; sc--;
  string s,t;
  cin>>s>>t;
  
  vector<vector<int>> kosu1(2,vector<int>(n+1));
  vector<vector<int>> kosu2(2,vector<int>(n+1));
  rep(i,n){
    if(s[i]=='L') kosu1[0][i+1]=-1;
    if(s[i]=='R') kosu1[0][i+1]=1;
    if(s[i]=='U') kosu1[1][i+1]=-1;
    if(s[i]=='D') kosu1[1][i+1]=1;
    if(t[i]=='L') kosu2[0][i+1]=-1;
    if(t[i]=='R') kosu2[0][i+1]=1;
    if(t[i]=='U') kosu2[1][i+1]=-1;
    if(t[i]=='D') kosu2[1][i+1]=1;
  }
  
  int p1=sr,p2=sr,q1=sc,q2=sc;
  rep(i,n+1){
    if(kosu1[0][i]==1) q2++;
    if(kosu1[0][i]==-1) q1--;
    if(kosu1[1][i]==1) p2++;
    if(kosu1[1][i]==-1) p1--;
    if(p1<0||p2>=h||q1<0||q2>=w){
      cout<<"NO"<<endl;
      return 0;
    }
    if(kosu2[0][i]==-1&&q2>0) q2--;
    if(kosu2[0][i]==1&&q1<w-1) q1++;
    if(kosu2[1][i]==-1&&p2>0) p2--;
    if(kosu2[1][i]==1&&p1<h-1) p1++;
  }
  cout<<"YES"<<endl;
}

Measured memory_bytes: 7596
#include <cstdio>
#include <cstdlib>
#include <cstring>

struct Node {
    int key;
    Node *next, *prev;
};

Node *nil;

Node* listrSearch(int key)
{
    Node *cur = nil -> next;  // 番兵の次の要素からたどる
    while(cur != nil && cur -> key != key) {
        cur = cur -> next;
    }
    return cur;
}

void init()
{
    nil = (Node *)malloc(sizeof(Node));
    nil -> next = nil;
    nil -> prev = nil;
}

void printList()
{
    Node *cur = nil -> next;
    int isf = 0;
    while(1) {
        if (cur == nil) break;
        if(isf++ > 0) printf(" ");
        printf("%d", cur -> key);
        cur = cur -> next;
    }
    printf("\n");
}

void deleteNode(Node *t)
{
    if(t == nil) return;  // tが番兵のときは処理しない
    t -> prev -> next = t -> next;
    t -> next -> prev = t -> prev;
    free(t);
}

void deleteFirst()
{
    deleteNode(nil -> next);
}

void deleteLast()
{
    deleteNode(nil -> prev);
}

void deleteKey(int key)
{
    //検索したノードを削除
    deleteNode(listrSearch(key));
}

void insert(int key)
{
    Node *x = (Node*)malloc(sizeof(Node));
    x -> key = key;
    // 番兵の直後に要素を追加
    x -> next = nil -> next;
    nil -> next -> prev = x;
    nil -> next = x;
    x -> prev = nil;
}

int main()
{
    int key, n, i;
    int size = 0;
    char com[20];
    int np = 0, nd = 0;
    scanf("%d", &n);
    init();
    for(i =0; i < n; i++){
        scanf("%s%d", com, &key);  // より高速な入力関数を使用
        if(com[0] == 'i'){insert(key); np++; size++;}
        else if(com[0] == 'd'){
            if(strlen(com) > 6){
                if(com[6] == 'F') deleteFirst();
                else if(com[6] == 'L') deleteLast();
            } else {
                deleteKey(key); nd++;
            }
            size--;
        }
    }

    printList();

    return 0;
}


Measured memory_bytes: 33856
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
typedef long long LL;
int main(){
	LL A,B,C;
	scanf("%lld%lld%lld",&A,&B,&C);
	int tim = 0;
	while((A % 2 == 0) && (B % 2 == 0) && (C % 2 == 0)){
		LL ta,tb,tc;
		ta = (B+C)>>1;tb = (A+C)>>1;tc = (A+B)>>1;
		A = ta;B = tb;C = tc;tim++;
		//printf("A = %lld,B = %lld,C = %lld\n",A,B,C);
		if(tim > 1e8){tim = -1;break;}
	}
	printf("%d\n",tim);
	return 0;
}

Measured memory_bytes: 128
<?php

while(1){
 
$values=trim(fgets(STDIN));


if(($values[0]<=1000 && $values[0]>=(-1000)) || ($values[1]<=1000 && values[1]>=(-1000))) break;

}
$values=explode(" ",$values);

/*
$values[0]=1;
$values[1]=1;
*/

if($values[0]<$values[1]){
    echo "a < b";
}else if($values[0]>$values[1]){
    echo "a > b";
}else{
    echo "a == b";
}

echo "\n";

?>


Measured memory_bytes: 9212
#include <stdio.h>

int main(void){
    int a,b;
    scanf("%d%d",&a,&b);
    
if(0 <= a && a <= 100 && 2 <= b && b <= 1000 && b % 2 == 0){
    if(a <= 5){
        printf("0\n");
    }else if(6 <= a&&a <= 12){
        int c;
        c = b/2;
        printf("%d\n",c);
    }else if(a >= 13){
        printf("%d\n",b);
    }

}

}

Measured memory_bytes: 128
N = int(input())
l = list(map(int,input().split()))
l_ans = [[] for _ in range(201)]

for i in range(-100,101):
    sum = 0

    for j in range(N):
        sum = sum + (i-l[j])**2

    l_ans[i+100] = sum

print(min(l_ans))

Measured memory_bytes: 9076
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>

using namespace std;

int main() 
{
	int a;
	string s;

	cin >> a >> s;

	if (a >= 3200)
		cout << s << endl;
	else
		cout << "red" << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
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;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n;
    cin >> n;
    vector<int> a(n+2);
    a[0] = 0;
    rep(i,n) cin >> a[i+1];
    a[n+1] = 0;
    int sum = 0;
    rep(i,n+1) sum += abs(a[i]-a[i+1]);
    rep2(i,1,n+1) {
        int nans = sum;
        nans -= abs(a[i]-a[i+1]);
        nans -= abs(a[i]-a[i-1]);
        nans += abs(a[i-1]-a[i+1]);
        cout << nans << endl;
    }
}


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

int main(void)
{
    int a, b, c, swap1=0, swap2=0;
    cin >> a >> b >> c;

    swap1 = a; a = b; b = swap1;
    swap2 = a; a = c; c = swap2;

    cout<<a<<" "<<b<<" "<<c<<endl;
}


Measured memory_bytes: 256
argStr = input()
ret=0
tmp=0
flag = False
for s in argStr:
    
    if (s=='A') | (s == 'C') | (s=='G') | (s=='T'):
        flag = True
        tmp+=1
    else:
        if flag :
            if( ret < tmp):
                ret = tmp
                tmp = 0
            flag = False
if( ret < tmp):
    ret = tmp
print(ret)


Measured memory_bytes: 9040
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep_1(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main(){
    int n,q;
    string t;
    cin >>n>>q>>t;
    vector<int> s(n+1);
    rep(i,n){
        if(t[i]=='A' && t[i+1] == 'C'){
            s[i+1]=1+s[i];
        }else{
            s[i+1] = s[i];
        }
    }
    rep(i,q){
        int l,r;cin>>l>>r;
        l--;r--;
        cout<< s[r]-s[l]<<endl;
    }



}



Measured memory_bytes: 1408
/*
        |___________________________Arshit Mangukiya_____________________________|
        |_______________________________DA-IICT__________________________________|
        |_____________________________201801173__________________________________|
*/
        /*______________________WRITE  YOUR  CODE  HERE_________________________*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int  ll;            
typedef long double ld;
#define ff first
#define ss second
#define pi acos(-1)
#define mr_ad_0501 ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
#define all(a)      a.begin(),a.end()
//#define F(i,n) for(ll i=0;i<n;i++)
#define MOD 1000000007
#define MAX 200005
#define sz size()
#define p(x) 		cout<< x << " ";
#define pe(x)		cout<< x << endl ;
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
		const ll N=1e5;
		ll i,j,k;
    		bool fun(pair<int,int>a , pair<int,int>b)
			{
				if(a.ff == b.ff)	return a.ss < b.ss;
				else			return a.ff > b.ff;
			}
bool fun(string s,string t)
	{
		ll c=0;
		for(ll i=0;i<s.sz;i++)
		{
			if(c<t.sz && s[i]==t[c])c++;
			
		}
		return c==t.sz;
	}
//ll dp[64];
//ll ans=1;
// vector<ll> v[N+1];
 //vector<ll> l(N+1,0);
 //vector<ll>vis(N+1);
 ll cnt=0,cnt1=0;
 /*void bfs(ll x)
 {
 	queue<ll> q;
	q.push(x);
    while(!q.empty())
    {
        ll k=q.front();
        q.pop();
        for(auto X:v[k])
        {
            if(!vis[X])
            {
            	l[X]=l[k]+1;
                vis[X]=1;
                q.push(X);
            }
        }
    }
 }*/
void solve()
{
	ll r;
	cin>>r;
	ll a[r];
	ll b[r+2]={0};
	for(ll i=0;i<r-1;i++)
	{
		cin>>a[i];
		b[a[i]]++;
	}
	for(ll i=1;i<=r;i++)
	cout<<b[i]<<endl;
}

int32_t main(){
	mr_ad_0501;
	ll t=1;
	//cin >> t;
	while(t--)
	{
		solve();
	}
}

Measured memory_bytes: 6772
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;

#ifdef BTK
#include<dvector.h>
#define DEBUG if(1)
#else
#define CIN_ONLY if(1)
struct cww{cww(){
    CIN_ONLY{
        ios::sync_with_stdio(false);cin.tie(0);
    }
}}star;
#define DEBUG if(0)
#endif

#define fin "\n"
#define FOR(i,bg,ed) for(int i=(bg);i<(ed);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
#define pb push_back
#define REC(ret, ...) std::function<ret (__VA_ARGS__)>
template <typename T>inline bool chmin(T &l,T r)
{bool a=l>r;if(a)l=r;return a;}
template <typename T>inline bool chmax(T &l,T r)
{bool a=l<r;if(a)l=r;return a;}
template <typename T>
istream& operator>>(istream &is,vector<T> &v){
    for(auto &it:v)is>>it;
    return is;
}

const string ok="Yes";
const string ng="No";

typedef vector<int> V;
typedef vector<V> VV;
#define non 0
#define all 1
#define dec 2
#define one 3
int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    vector<int> v;
    {
        int id=0;
        while(id<n){
            v.pb(0);
            while(id<n&&s[id]=='1'){
                id++;
                v.back()++;
            }
            id++;
        }
    }
    int m=v.size();
    VV dp(m,V(4,-1e8));
    dp[0][all]=0;
    FOR(i,1,m){
        REP(j,4)chmax(dp[i][all],dp[i-1][j]);
        if(v[i]>=1&&v[i-1]>=2)chmax(dp[i][dec],dp[i-1][dec]+v[i-1]-1);
        if(v[i]>=1&&v[i-1]>=1)chmax(dp[i][dec],dp[i-1][all]+v[i-1]);
        if(v[i]>=1)chmax(dp[i][dec],dp[i-1][one]+1);
        if(v[i-1]>=2)chmax(dp[i][non],dp[i-1][dec]+v[i]);
        if(v[i-1]>=1)chmax(dp[i][non],dp[i-1][all]+v[i]);
        if(v[i-1]>=1)chmax(dp[i][non],dp[i-1][one]+v[i]);
        if(v[i]>=1&&v[i-1]>=2)chmax(dp[i][one],dp[i-1][dec]+v[i]-1);
        if(v[i]>=1&&v[i-1]>=1)chmax(dp[i][one],dp[i-1][all]+v[i]-1);
        if(v[i]>=1&&v[i-1]>=1)chmax(dp[i][one],dp[i-1][one]+v[i]-1);
    }
    int ret=0;
    REP(i,4)
        chmax(ret,dp.back()[i]);
    cout<<ret<<endl;
    return 0;
}


Measured memory_bytes: 30100
import java.io.*;

public class Main {
    public static void main(String[] args) throws Exception {
        try{
            BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
            
            int N = Integer.parseInt(br.readLine());
            String strSplit[] = br.readLine().split(" ");
            long A[] = new long[N];
            
            for(int i=0; i<N; i++){
                A[i] = Integer.parseInt(strSplit[i]);
            }
            
            int ans = 0;
            boolean even = true;
            while(true){
                for(int i=0; i<N; i++){
                    if(A[i]%2 != 0){
                        even = false;
                        break;
                    }else if(i == N-1){
                        ans++;
                    }
                    
                    A[i] = A[i]/2;
                }
                
                if(!even){
                    break;
                }
            }
            
            System.out.println(ans);
        }catch(Exception e){
            
        }
    }
}

Measured memory_bytes: 32656
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
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; }
typedef long long ll;
const int INF = 1e9;

int main(){
    int n;cin >> n;
    vector<int> a(n);
    REP(i,n) cin >> a[i];
    sort(a.begin(),a.end());
    int ans = 0;

    int r = 0;
    for(int l = 0; l < n; ++l){
        while(a[r]-a[l] < 3 && r < n) ++r;
        chmax(ans, r - l);
        if(l==r) ++r;
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
Z = 10 ** 9 + 7


def z_pow(a, n):
    # a ^ n
    if n == 0:
        return 1
    if n == 1:
        return a % Z
    m = n // 2
    i = n - m * 2
    x = z_pow(a, m)
    return (x * x * z_pow(a, i)) % Z


def n_comb(n, i):
    if n - i < i:
        return n_comb(n, n - i)
    e = [1 for j in range(n + 1)]
    for j in range(n):
        e[j + 1] = (e[j] * (j + 1)) % Z
    return (e[n] * z_pow(e[i], Z - 2) * z_pow(e[n - i], Z - 2)) % Z


def calc(X, Y):
    if (X + Y) % 3 != 0:
        return 0
    n = (X + Y) // 3
    if X < n or Y < n:
        return 0
    return n_comb(n, X - n)


(X, Y) = tuple([int(s) for s in input().split()])
print(calc(X, Y))

Measured memory_bytes: 29464
n=int(input())
arr=[0]*n
for i in range(n):
    arr[i]=int(input())

arr=sorted(arr)
num=arr[0]
tmp=1
ans=0
for i in range(1,n):
    if arr[i]==num:
        tmp+=1
    else:
        if tmp%2==1:
            ans+=1
        num=arr[i]
        tmp=1
if tmp%2==1:
    ans+=1    
print(ans)

Measured memory_bytes: 14156
#include <iostream>
#include <iomanip>
#include <fstream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>

#define _GLIBCXX_DEBUG
using namespace std;
using vi = vector<int64_t>;
using vvi = vector<vi>;

int main(int argc, const char * argv[]) {
    // fasten cin
    cin.tie(0);
    ios::sync_with_stdio(false);
    // implement
    int64_t n,x;
    cin >> n >> x;
    vi l(n);
    for(int i=0; i<n; i++){
        cin >> l.at(i);
    }
    int64_t res = 1, distance = 0;
    for(int i=0; i<n; i++){
        if(distance + l.at(i) > x){
            break;
        }
        res++;
        distance += l.at(i);
    }
    cout << res << endl;
}


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    a = I()
    if n%500 <= a:
        return 'Yes'

    return 'No'


print(main())




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

#define ff first
#define ss second
#define endl '\n'

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

	int n;
	cin >> n;

	int ans = n;
	int req = 1;
	for (int i = 0, x; i < n; ++i) {
		cin >> x;
		if (x == req) {
			++req;
			--ans;
		}
	}

	ans = (ans == n) ? -1 : ans;
	cout << ans << endl;

	return 0;
}

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

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

    // ソート済みの部分列について、それらの末尾インデックスの集合
    let mut I = std::collections::HashSet::new();
    let mut c = 1;
    for i in 1..N {
        if P[i] > P[i - 1] { c += 1; } else { c = 1; }
        if c >= K { I.insert(i); }
    }
    // スライド最小値により、部分列の最小値と最大値を効率的に求める
    let mut min_q = std::collections::VecDeque::new();
    for i in 0..K {
        while !min_q.is_empty() && P[*min_q.back().unwrap()] > P[i] { min_q.pop_back(); }
        min_q.push_back(i);
    }
    let mut max_q = std::collections::VecDeque::new();
    for i in 0..K {
        while !max_q.is_empty() && P[*max_q.back().unwrap()] < P[i] { max_q.pop_back(); }
        max_q.push_back(i);
    }
    let mut res = if I.contains(&(K - 1)) { 0 } else { 1 };
    for i in K..N {
        let j = *min_q.front().unwrap();
        while !min_q.is_empty() && P[*min_q.back().unwrap()] > P[i] { min_q.pop_back(); }
        min_q.push_back(i);
        if *min_q.front().unwrap() == i - K { min_q.pop_front().unwrap(); }
        while !max_q.is_empty() && P[*max_q.back().unwrap()] < P[i] { max_q.pop_back(); }
        max_q.push_back(i);
        if *max_q.front().unwrap() == i - K { max_q.pop_front().unwrap(); }
        if (j != i - K || *max_q.front().unwrap() != i) && !I.contains(&i) { res += 1; }
    }
    if !I.is_empty() { res += 1; }
    let ans = res;

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

Measured memory_bytes: 13996
#include <bits/stdc++.h>
using namespace std;
using ll= long long;
using vi= vector<int>;
using vvi= vector<vi>;
using vd= vector<double>;
using vvd= vector<vd>;
using vc= vector<char>;
using vb= vector<bool>;
using vl= vector<ll>;
using vs= vector<string>;
#define rep(i,x,n) for(int i=x; i<n; i++)
#define all(x) x.begin(), x.end()

int main(){
  string s;
  cin >> s;
  int tmp;
  vi v(4);
  rep(i,0,4){
    v[i]= s[i]-'0';
  }
  rep(bit,0,1<<3){
    tmp= v[0];
    rep(i,0,3){
      if(bit & (1<<i)){
        tmp+= v[i+1];
      }else{
        tmp-= v[i+1];
      }
    }
    if(tmp==7){
      cout << v[0];
      rep(i,0,3){
        if(bit & (1<<i)){
          cout << "+";
        }else{
          cout << "-";
        }
        cout << v[i+1];
      }
      cout << "=7" << endl;
      return 0;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void) {

	int a, b, c, d;

	scanf("%d", &a);
	scanf("%d", &b);
	scanf("%d", &c);
	scanf("%d", &d);

	if (-d<=a-c&&a-c<=d)
		puts("Yes");

	else if ((-d<=a-b&&a-b<=d)&&(-d<=b-c&&b-c<=d))
		puts("Yes");
	else
		puts("No");


	return 0;


}

Measured memory_bytes: 128
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();
		char[] t = sc.next().toCharArray();
		Arrays.sort(s);
		for(int i = 0 ; i < t.length - 1 ; i++) {
			for(int j = i + 1 ; j < t.length ; j++) {
				if(t[i] < t[j]) {
					char temp = t[i];
					t[i] = t[j];
					t[j] = temp;
				}
			}
		}
		String S = new String(s);
		String T = new String(t);
		if(S.compareTo(T) < 0) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 21844
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using static System.Console;

class Program
{
    static void Main(string[] args)
    {
        new Program().Calc();
    }

    Scanner cin;

    public Program() { }

    bool chmax<T>(ref T a, T b) where T : IComparable<T> { if (a.CompareTo(b) < 0) { a = b; return true; } return false; }
    bool chmin<T>(ref T a, T b) where T : IComparable<T> { if (b.CompareTo(a) < 0) { a = b; return true; } return false; }

    void Calc()
    {
        cin = new Scanner();

        int[] P = cin.ArrayInt(3);

        Array.Sort(P);

        WriteLine(P[0]+P[1]);
    }
}

public static class StringExtension
{
    public static char GetChar1(this string str, int indexOneBase)
    {
        return str[indexOneBase - 1];
    }
}

class Scanner
{
    string[] s;
    int i;

    char[] cs = new char[] { ' ' };

    public Scanner()
    {
        s = new string[0];
        i = 0;
    }

    public string next()
    {
        if (i < s.Length) return s[i++];
        string st = Console.ReadLine();
        while (st == "") st = Console.ReadLine();
        s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
        if (s.Length == 0) return next();
        i = 0;
        return s[i++];
    }

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

    public long nextLong()
    {
        return long.Parse(next());
    }

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

    public double nextDouble()
    {
        return double.Parse(next());
    }


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


Measured memory_bytes: 13140
#include<cstdio>
#include<cmath>

int main(void){
int n,i;
scanf("%d",&n);
double x[n],y[n],a[n];
for(i=0;i<n;i++){
	scanf("%lf",&x[i]);
}
for(i=0;i<n;i++){
	scanf("%lf",&y[i]);
}
for(i=0;i<n;i++){
	a[i]=fabs(x[i]-y[i]);
}

double d1=0;
for(i=0;i<n;i++){
	d1=d1+a[i];
}

double d2=0;
for(i=0;i<n;i++){
	d2=d2+(a[i]*a[i]);
}
d2=sqrt(d2);

double d3=0;
for(i=0;i<n;i++){
	d3=d3+(a[i]*a[i]*a[i]);
}

double j;
j=1.0/3.0;
d3=pow(d3,j);

double d4=a[0];
for(i=1;i<n;i++){
	if(d4<a[i]){
		d4=a[i];
	}
}
		
printf("%f\n%f\n%f\n%f\n",d1,d2,d3,d4);

return 0;
}

		

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

int main() {
  int N;
  cin >> N;
  ll sum = 0;
  
  for(int i=1; i<=N; i++){
    if(i%3!=0 && i%5!=0){
      sum += i;	
    }
  }
  cout << sum << endl;
  return 0;
}




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

const int MAX = 100000;
int n, pa[MAX], le[MAX], ri[MAX], cnt, H[MAX];

void dfs_h(int a, int res){
  cnt = max(cnt,res);
  if(le[a] != -1) dfs_h(le[a], res+1);
  if(ri[a] != -1) dfs_h(ri[a], res+1);
}

void solve(){
  for(int i=0;i<n;i++){
    int cnt = 0;
    for(int j=i; j!=-1; j=pa[j]){
      if(H[j] < cnt) H[j] = cnt;
      cnt++;
    }
  }

  for(int i=0;i<n;i++){
    cout << "node " << i << ": parent = " << pa[i] << flush;

    if(pa[i] == -1) cout << ", sibling = " << -1 << flush;
    else if(le[pa[i]] != i) cout << ", sibling = " << le[pa[i]] << flush;
    else cout << ", sibling = " << ri[pa[i]] << flush;

    cnt = 0;
    if(le[i] != -1) cnt++;
    if(ri[i] != -1) cnt++;
    cout << ", degree = " << cnt << flush;

    cnt = 0;
    for(int j=pa[i]; j!=-1; j=pa[j]) cnt++;
    cout << ", depth = " << cnt << flush;

    cout << ", height = " << H[i] << flush;

    if(pa[i] == -1) cout << ", root" << endl;
    else if(le[i] == -1 && ri[i] == -1) cout << ", leaf" << endl;
    else cout << ", internal node" << endl;
  }

}

int main(){
  cin >> n;
  fill(pa,pa+MAX,-1);
  fill(le,le+MAX,-1);
  fill(ri,ri+MAX,-1);
  fill(H,H+MAX,-1);
  for(int i=0;i<n;i++){
    int a,b,c;
    cin >> a >> b >> c;
    le[a] = b;
    ri[a] = c;
    pa[b] = a;
    pa[c] = a;
  }
  solve();
}

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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if(a == b && b == c){
    cout << 1 << endl;
  }
  else if(a ==b || b == c || c == a){
    cout << 2 << endl;
  }
  else{
    cout << 3 << endl;
  }
}


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

int main() {
    char s[3];
    std::cin >> s[0] >> s[1] >> s[2];

    int cnt = 0;
    for (int i = 0; i < 3; ++i) {
        if (s[i] == '1') {
            ++cnt;
        }
    }

    std::cout << cnt << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;
#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define FOREACH(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define MOD 1000000007
using namespace std;
int main(){
    int H, W, M; cin >> H >> W >> M;
    int rows[H] = {0};
    int cols[W] = {0};
    set<pair<int,int>> seen;
    for(int i = 0; i < M; i++){
        int h,w;
        cin >> h >> w;
        rows[h-1]++;
        cols[w-1]++;
        seen.insert(pair<int,int> (h-1, w-1));
    }
    int rowMax = *max_element(rows, rows+H);
    int colMax = *max_element(cols, cols+W);
    vector<int> rowMaxes;
    vector<int> colMaxes;
    for(int i = 0; i < H; i++){
        if(rows[i] == rowMax) rowMaxes.push_back(i);
    } 
    for(int i = 0; i < W; i++){
        if(cols[i] == colMax) colMaxes.push_back(i);
    } 
    bool overlap = true;
    for(auto i = rowMaxes.begin(); i != rowMaxes.end() && overlap; i++){
        FOREACH(j, colMaxes){
            if(seen.find(pair<int, int>(*i,*j)) == seen.end()){ overlap = false; break;}
        }
    }
    if(overlap) cout <<rowMax + colMax -1 << endl;
    else cout << rowMax + colMax;
}

Measured memory_bytes: 23788
#include <iostream>
#include <cmath>
#include <vector>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int>a(n);
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    int sum = 0;
    for(int i=0; i<n-1; i++){
        sum += abs(a[i+1]-a[i]);
    }
    sum += abs(a[0])+abs(a[n-1]);
    int sum1 = sum;
    for(int i=0; i<n; i++){
        if(i==0){
            sum -= abs(a[0])+abs(a[1]-a[0]);
            sum += abs(a[1]);
            cout << sum << endl;
            sum = sum1;
            continue;
        }
        if(i==n-1){
            sum -= abs(a[n-2]-a[n-1])+abs(a[n-1]);
            sum += abs(a[n-2]);
            cout << sum << endl;
            sum = sum1;
            continue;
        }
        sum -= abs(a[i]-a[i-1])+abs(a[i]-a[i+1]);
        sum += abs(a[i-1]-a[i+1]);
        cout << sum << endl;
        sum = sum1;
    }
    return 0;
}

Measured memory_bytes: 3792
n, m = map(int, input().split())
a = set()
for i in range(m):
    a.add(int(input()))

b = [0] * (n + 1)
b[0] = 1
if 1 not in a:
    b[1] = 1
for i in range(2, n + 1):
    if i in a:
        b[i] = 0
    else:
        b[i] = b[i - 1] + b[i - 2]
print(b[n] % 1000000007)

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


int main() {
    i64 N; cin >> N;
    string S; cin >> S;
    vector<i64> W(N + 1, 0);
    vector<i64> B(N + 1, 0);
    REP(i, N) {
        W[i + 1] = W[i];
        B[i + 1] = B[i];
        if (S[i] == '.') W[i + 1]++;
        if (S[i] == '#') B[i + 1]++;
    }

    i64 minc = N;
    REP(i, N + 1) {
        // W-B
        i64 cnt = 0;
        cnt += B[i];
        cnt += W[N] - W[i];
        chmin(minc, cnt);
    }
    cout << minc << endl;

    return 0;
}

Measured memory_bytes: 3732
#include<iostream>
#include<string.h>
#include<math.h>
#include<vector>
#include<algorithm>
using namespace std;
long long n,x[200000],y[200000],i,a,b;
int main()
{
    cin >> n;
    for(i=0;i<n;i++){
        cin >> x[i];
        y[i]=x[i];
    }
    sort(y,y+n);
    a=y[n/2-1];
    b=y[n/2];
    for(i=0;i<n;i++){
        if(x[i]>=b)printf("%lld\n",a);
        else printf("%lld\n",b);
    }
}

Measured memory_bytes: 5376
# hand_a = 'abcb'.chars.to_a
# hand_b = 'aacb'.chars.to_a
# hand_c = 'bccc'.chars.to_a
hand_a, hand_b, hand_c  = 3.times.map{gets.chomp.chars.to_a}

class Card
    attr_accessor :str, :hand_a, :hand_b, :hand_c
    
    def initialize(str)
        @str = str
    end
    
    def logic(str)
        
        # p "bef-str:", @hand_a
        if str == 'a'
            @str = @hand_a[0]
            @hand_a.delete_at(0)
        elsif str == 'b'
            @str = @hand_b[0]
            @hand_b.delete_at(0)
        elsif str == 'c'
            @str = @hand_c[0]
            @hand_c.delete_at(0)
        end
        # p "aft-str:", @hand_a
            
    end
end

card = Card.new(hand_a[0])
card.hand_a = hand_a
card.hand_b = hand_b
card.hand_c = hand_c


# puts hand_a.class
# puts hand_b
# puts hand_c

# puts "length", card.hand_a.length, card.hand_b.length, card.hand_c.length
end_A = true
end_B = true
end_C = true

while end_A and end_B and end_C do 
    card.logic(card.str)
    
    if (card.hand_a.length == 0 && card.str == "a")
        end_A = false
        win = "A"
    end
    if (card.hand_b.length == 0 && card.str == "b")
        end_B = false
        win = "B"
    end
    if (card.hand_c.length == 0 && card.str == "c")
        end_C = false
        win = "C"
    end
end
# puts "length", card.hand_a.length, card.hand_b.length, card.hand_c.length

puts win
# p "a:", card.hand_a
# p "b:", card.hand_b
# p "c:", card.hand_c

Measured memory_bytes: 14284
#include <iostream>
#include <queue>
#include <vector>
#include <set>
using namespace std;

#define INF 1e+9
#define MAX_V 10

int main() {
    int N;
    cin >> N;
    int M;
    cin >> M;
    set<int> st[N];
    queue<int> q;
    for (int i=0; i<M; ++i) {
        int a, b;
        cin >> a >> b;
        st[a-1].insert(b-1);
        st[b-1].insert(a-1);
    }
    // BFS のためのデータ構造
    vector<int> dist(N, -1); // 全頂点を「未訪問」に初期化
    vector<int> mark(N, -1); // 全頂点を「未訪問」に初期化
    queue<int> que;

    // 初期条件 (頂点 0 を初期ノードとする)
    dist[0] = 0;
    que.push(0); // 0 を橙色頂点にする

    // BFS 開始 (キューが空になるまで探索を行う)
    while (!que.empty()) {
        int v = que.front(); // キューから先頭頂点を取り出す
        que.pop();

        // v から辿れる頂点をすべて調べる
        //for (auto itr = st[v].begin(); itr != st[v].end(); ++itr) {
        for (auto itr : st[v]) {
            if (dist[itr] != -1) continue; // すでに発見済みの頂点は探索しない

            // 新たな白色頂点 nv について距離情報を更新してキューに追加する
            mark[itr] = v+1;
            dist[itr] = dist[v] + 1;
            que.push(itr);
        }
    }

    // for (int i=0; i<N; ++i) {
    //     for(auto itr = st[i].begin(); itr != st[i].end(); ++itr) {
    //         cout << *itr+1 << "\n";      // イテレータの指す先のデータを表示
    //     }
    //     cout << "-------" << endl;
    // }
    cout << "Yes" << endl;
    for (int v = 1; v < N; ++v) {
        //cout << v << ": " << dist[v] << endl;

        cout << mark[v] << endl;
    }

}

Measured memory_bytes: 27744
#include <iostream>
#include <algorithm>
//#include <array>
#include <stdbool.h>
using namespace std;
bool mod[10000];


void find(int a,int b,int c){
	int m =2;
	for(m=a;m<=b;m++){
		if(c%m==0){
			mod[m]=1;
			continue;
		}
	}
	int i;
	int s=0;
	for(i=0;i<=10000;i++){
		if(mod[i]==1)s++;
	}
	cout <<s <<endl;
	
}
int main(){
	int a,b,c;
	cin >>a >>b >>c;
	fill(mod,mod+10000,0);
	find(a,b,c);
	return 0;
}

Measured memory_bytes: 1172
data = []
for i in range(3):data.append(list(map(int, input().split())))

n = int(input())

for i in range(n):
    m = int(input())
    for j in range(3):
        for k in range(3):
            if(data[j][k] == m):
                data[j][k] = True

if(data[0][0] == True and data[1][1] == True and data[2][2]):
    print("Yes")

elif(data[0][2] == True and data[1][1] == True and data[2][0]):
    print("Yes")

elif(data[0] == [True, True, True]):
    print("Yes")
elif(data[1] == [True, True, True]):
    print("Yes")
elif(data[2] == [True, True, True]):
    print("Yes")

elif(data[0][0]==True and data[1][0]==True and data[2][0]==True):
    print("Yes")
elif(data[0][1]==True and data[1][1]==True and data[2][1]==True):
    print("Yes")
elif(data[0][2]==True and data[1][2]==True and data[2][2]==True):
    print("Yes")

else:
    print("No")

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

#define MAX(A, B) (((A) > (B)) ? (A) : (B))

int main () {
  int r;
  scanf("%d", &r);
  
  r = 3 * r * r;
  printf("%d\n", r);
  
  return 0;
}



Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <ctype.h>

#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <sstream>
#include <stack>
#include <queue>
#include <bitset>

using namespace std;

#define deb(a)    cout<<__LINE__<<"# "<<#a<<" -> "<<a<<endl;
#define pb push_back
#define OO 2e9+10

#define ConPnt(a)   {for(auto it: a){cout<<it<<", ";}cout<<endl;}
#define MapPnt(a)   {for(auto it: a){cout<<it.first<<": "<<it.second<<", ";}cout<<endl;}

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

template<class T> T abs(T x){
    if(x<0) return -x;
    return x;
}
template<class T>T sqr(T a){
    return a*a;
}

const double pi = acos(-1.0);
const double eps = 1e-8;


int main()
{
//    freopen("in.txt","r",stdin);
//    freopen("output.txt","w",stdout);

    int i,n,k;
    char str[10010];
    while(2==scanf("%s%d",str,&k))
    {
        n = strlen(str);
        for(i=0;i<n;i++)
        {
            if(i==0)
                printf("%c",str[i]);
            else if(i%k==0)
                printf("%c",str[i]);
        }
        printf("\n");
    }

    return 0;
}


Measured memory_bytes: 888
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define PI acos(-1)
#define Mod (int)1000000007
#define INFTY (int)INT_MAX
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Count(vec, x) count(vec.begin(), vec.end(), x)
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define Find(S, s) S.find(s) != string::npos

int main() {
	int N, q;
	cin >> N >> q;
	vector<queue<int>> Q(N);
	Rep(i, q) {
		int n;
		cin >> n;
		if (n == 0) {
			int t, x;
			cin >> t >> x;
			Q[t].push(x);
		}
		else if (n == 1) {
			int t;
			cin >> t;
			if (!Q[t].empty()) {
				cout << Q[t].front() << endl;
			}
		}
		else if (n == 2) {
			int t;
			cin >> t;
			if (!Q[t].empty()) {
				Q[t].pop();
			}
		}
	}
	return 0;
}


Measured memory_bytes: 4228
import sys
import fractions


def solve():
    sys.setrecursionlimit(2000)
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    a, b, k = list(map(int, input().rstrip('\n').split()))
    gcd = fractions.gcd(a, b)
    ans = [1]
    for i in range(2, gcd + 1):
        if gcd % i == 0:
            ans.append(i)
    print(ans[-k])


if __name__ == '__main__':
    solve()


Measured memory_bytes: 64364
#include<iostream>
using namespace std;
int main()
{
    int k,x;
    cin>>k>>x;

    bool _=false;
    for (int i = -1e6; i <= 1e6; i++) {
      if(x-k+1<=i && i<x+k){
        cout << (_?" ":"") << i;
        _=true;
      }
    }
    cout<<endl;
    return 0;
}


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

int main() {
  int A, B;
  int a, b, c;
  cin >> A >> B;
  a = A + B;
  b = A - B;
  c = A * B;
  if (max(a, b) == b)
  {
    cout << max(b, c) << endl;
  }
  else
  {
    cout << max(a, c) << endl;
  }
}

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

int main()
{
	//2.すごろく	
	int n;
	cin >> n;
	int A, _A = 1;
	int k = 0;
	int A_count[100];
	A_count[0] = 1;
	for (int i = 0; i < n; i++)
	{
		cin >> A;
		if (A == 1)
		{
			if (A == _A)
			{
				A_count[k]++;
			}
			else
			{
				k++;
				A_count[k] = 2;
			}
		}
		_A = A;
	}
	sort(A_count, A_count + k + 1);
	cout << A_count[k] << endl;

	return 0;
}


Measured memory_bytes: 3156
import java.util.*;

public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		
		String S = sc.next();
		String T = sc.next();
		
		for(int i = 0; i < N; i++){
			System.out.print(S.charAt(i));
			System.out.print(T.charAt(i));
		}
		System.out.println();
	}
}

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

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

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

int main() {
  ll a, b, c, d;
  cin >> a >> b >> c >> d;
  ll ans = b - a + 1;
  ans -= b / c - (a - 1) / c;
  ans -= b / d - (a - 1) / d;
  ll l = lcm(c, d);
  ans += b / l - (a - 1) / l;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3608