akhauriyash/Code-Regression huggingface dataset:
use proconio::{fastout, input};
use std::{cmp::Reverse, collections::BinaryHeap};

#[fastout]
fn main() {
    input! {
        n: usize,
        m: usize,
        a: [i64; n],
        query: [(i64, i64); m],
    }

    let mut query: Vec<_> = query.iter().copied().map(|(a, b)| (b, a)).collect();
    query.sort();
    query.reverse();

    let mut q = BinaryHeap::new();
    for ai in a {
        q.push(Reverse(ai));
    }

    for (num, max_c) in query {
        for _ in 0..max_c {
            let Reverse(e) = q.peek().unwrap();
            if *e >= num {
                break;
            }

            q.pop();
            q.push(Reverse(num));
        }
    }

    let mut s = 0i64;
    while let Some(Reverse(e)) = q.pop() {
        s += e;
    }
    println!("{}", s);
}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            
            string str = Console.ReadLine();
            int m = int.Parse(str.Substring(2, 2));
            int y = int.Parse(str.Substring(0, 2));
            bool yymm = false;
            bool mmyy = false;


            if (m > 0 && m< 13)
            {
                yymm = true;
            }

            if (y > 0 && y < 13)
            {
                mmyy = true;
            }





            if (mmyy && yymm)
                Console.WriteLine("AMBIGUOUS");
            else if(mmyy)
                Console.WriteLine("MMYY");
            else if (yymm)
                Console.WriteLine("YYMM");
            else
                Console.WriteLine("NA");
            
        }
        
    }
}


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

int main()
{
  ll N, Y; cin >> N >> Y;

  for (int x = 0; x <= N; ++x) {
    for (int y = 0; y <= N; ++y) {
      ll z = N-x-y;
      if (z < 0 or 10000*x+5000*y+1000*z != Y) continue;

      printf("%d %d %lld\n", x, y, z);
      return 0;
    }
  }

  cout << "-1 -1 -1" << endl;
}

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

// @@ !! LIM()

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  string S; cin >> S;
  ll n = S.size();
  vector<bool> v(128);
  for (ll i = 0; i < n; i++) v[S[i]] = true;
  cout << (v['N'] == v['S'] && v['W'] == v['E'] ? "Yes" : "No") << endl;
    

  return 0;
}



Measured memory_bytes: 3664
//h14-1 JOI紋章
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <vector>
#include <map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#include <boost/multiprecision/cpp_int.hpp>
namespace boost_multiprecision = boost::multiprecision;
#define LL long long
#define CINT boost_multiprecision::cpp_int
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define segment_size 65536
#define ROOP() while (true)


int main(){
    int M,N;
    cin >> M >> N;

    string S[1000];
    for(int i=0; i<M; i++){
        cin >> S[i];
    }

    string a[2];
    cin >> a[0] >> a[1];

    int count[1000][1000];
    int changeJ[1000][1000];
    int changeO[1000][1000];
    int changeI[1000][1000];
    for(int i=0; i<M; i++){
        for(int j=0; j<N; j++){
            count[i][j] = 0;
            changeJ[i][j] = 0;
            changeO[i][j] = 0;
            changeI[i][j] = 0;
        }
    }

    LL sum = 0;
    vector<pair<int,int>> l;
    for(int i=0; i<M-1; i++){
        for(int j=0; j<N-1; j++){
            int tmp = 0;
            int y,x;
            if(S[i][j] == a[0][0]) tmp++;
            else{
                y = 0;
                x = 0;
            }
            if(S[i+1][j] == a[1][0]) tmp++;
            else{
                y = 1;
                x = 0;
            }
            if(S[i][j+1] == a[0][1]) tmp++;
            else{
                y = 0;
                x = 1;
            }
            if(S[i+1][j+1] == a[1][1]) tmp++;
            else{
                y = 1;
                x = 1;
            }

            if(tmp == 3){
                l.push_back(make_pair(i+y,j+x));
                if(a[y][x] == 'J') changeJ[i+y][j+x]++;
                if(a[y][x] == 'O') changeO[i+y][j+x]++;
                if(a[y][x] == 'I') changeI[i+y][j+x]++;
            }
            if(tmp == 4){
                count[i][j]++;
                count[i+1][j]++;
                count[i][j+1]++;
                count[i+1][j+1]++;
                sum++;
            }
        }
    }

    LL ans = sum;
    for(int i=0; i<l.size(); i++){
        ans = max(ans, sum + max({changeJ[l[i].first][l[i].second], changeO[l[i].first][l[i].second], changeI[l[i].first][l[i].second]}) - count[l[i].first][l[i].second]);
    }
    cout << ans << endl;


    return 0;
}


Measured memory_bytes: 21732
#include<stdio.h>

int main(void)
{
	 int i,n,a[10000],max,min;
	 long long int sum;
	 scanf("%d",&n);
	((n>0)&&(n<10000));
	
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
		((a[i]>-1000000)&&(a[i]<1000000));
	}
	max = a[0];
	min = a[0];
	sum = a[0];
	for(i=0;i<n;i++)
	{
		if(a[i]	> max)
		{
		  max =a[i];
		}
		if(a[i] < min)
		{
			min=a[i];
		}
	sum+=a[i];
	}
	printf("%d %d %lld\n",min,max,sum-a[0]);
	return 0;
}

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

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

fn parity(bit: u32, v: &Vec<u32>) -> u32 {
    v.iter().fold(0, |acc, x| acc ^ ((bit >> x) & 1))
}

fn main() {
    let n: u32 = read();
    let m: u32 = read();
    let mut vv = Vec::new();
    for _ in 0..m {
        let k: u32 = read();
        let v: Vec<u32> = (0..k).map(|_| read::<u32>() - 1).collect();
        vv.push(v);
    }
    let p: Vec<u32> = (0..m).map(|_| read()).collect();

    let ans = (0..1 << n).filter(|i| {
        vv.iter().zip(p.iter()).all(|(vj, pj)| { parity(*i, &vj) == *pj })
    }).count();

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


Measured memory_bytes: 4352
/*input
10 10 20
1 1
1 4
1 9
2 5
3 10
4 2
4 7
5 9
6 4
6 6
6 7
7 1
7 3
7 7
8 1
8 5
8 10
9 2
10 4
10 9
*/
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<double,double> pdd;
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define F first
#define S second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define pb push_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#ifdef leowang
#define debug(...) do{\
	fprintf(stderr,"%s - %d : (%s) = ",__PRETTY_FUNCTION__,__LINE__,#__VA_ARGS__);\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){cerr<<x<<endl;}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){cerr<<x<<", ";_DO(tail...);}
#else
#define debug(...)
#endif
template<typename T1,typename T2>
ostream& operator<<(ostream& out,pair<T1,T2> P){
	out<<'('<<P.F<<','<<P.S<<')';
	return out;
}
//}}}
const ll maxn=300005;
const ll maxlg=__lg(maxn)+2;
const ll INF64=8000000000000000000LL;
const int INF=0x3f3f3f3f;
const ll MOD=ll(1e9+7);
const double PI=acos(-1);
//const ll p=880301;
//const ll P=31;

ll mypow(ll a,ll b){
	ll res=1LL;
	while(b){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		
		b>>=1;
	}
	return res;
}
ll n,m,q;

bool check(pii A){
	return 2<=A.F&&A.F<=n-1&&2<=A.S&&A.S<=m-1;
}

map<pii,int> mp;
ll ans[10];
int main()
{
	IOS;
	cin>>n>>m>>q;

	while(q--){
		int x,y;
		cin>>x>>y;
		REP(i,3) REP(j,3){
			if(check(MP(x+i-1,y+j-1))){
				mp[MP(x+i-1,y+j-1)]++;
			}
		}
	}
	ans[0]=(n-2)*(m-2)-SZ(mp);
	for(auto i:mp){
		ans[i.S]++;
	}
	REP(i,10) cout<<ans[i]<<'\n';

	return 0;
}


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


long long getMul(long long n, long long b) {
    long long res = 0; 
    int c = 1;
    while (n) {
        res += n / b;
        n /= b;
    }
    return res;
}

int main() {
    long long n;
    cin >> n;
    
    long long res = n & 1 ? 0 : getMul(n / 10, 5) + n / 10;
    cout << res << endl;
    return 0;
}


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

typedef long long lint;

lint dp[100010][2];
int a[100010],n;

int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++) scanf("%d",&a[i]);
	dp[0][0]=a[0]; dp[0][1]=-1e9;
	for(int i=1;i<n;i++){
		dp[i][0]=max(dp[i-1][1],dp[i-1][0])+a[i];
		dp[i][1]=max(dp[i-1][1]-a[i]+2*a[i-1],dp[i-1][0]-2*a[i-1]-a[i]);
	}
	printf("%lld\n",max(dp[n-1][0],dp[n-1][1]));
	return 0;
}

Measured memory_bytes: 2176
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE BangPatterns, CPP, FlexibleContexts, FlexibleInstances         #-}
{-# LANGUAGE KindSignatures, LambdaCase, MagicHash, MultiParamTypeClasses   #-}
{-# LANGUAGE MultiWayIf, OverloadedStrings, RecordWildCards                 #-}
{-# LANGUAGE ScopedTypeVariables, TupleSections, TypeFamilies, ViewPatterns #-}

import           Control.Applicative
import           Control.Exception
import           Control.Monad
import           Control.Monad.Primitive
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Data.Bool
import qualified Data.ByteString             as B
import qualified Data.ByteString.Builder     as B
import qualified Data.ByteString.Char8       as C
import qualified Data.ByteString.Internal    as B
import qualified Data.ByteString.Unsafe      as B
import           Data.Char
import qualified Data.Foldable               as F
import           Data.Function
import           Data.Functor.Identity
import qualified Data.IntMap.Strict          as IM
import qualified Data.IntSet                 as IS
import qualified Data.List                   as L
import qualified Data.Map.Strict             as M
import           Data.Monoid
import           Data.Ord
import           Data.Primitive.MutVar
import           Data.Ratio
import qualified Data.Set                    as S
import           Data.Tuple
import qualified Data.Vector                 as V
import qualified Data.Vector.Generic         as G
import qualified Data.Vector.Generic.Mutable as GM
import qualified Data.Vector.Mutable         as VM
import qualified Data.Vector.Unboxed         as U
import qualified Data.Vector.Unboxed.Mutable as UM
import           Debug.Trace
import           Foreign                     hiding (void)
import           GHC.Exts
import qualified System.IO                   as IO
import           Unsafe.Coerce

main :: IO ()
main = do
    [a, b] <- map read.words <$> getLine :: IO [Int]
    if a < 10 && b < 10
    then print $ a * b
    else print $ -1


-------------------------------------------------------------------------------
rep :: Monad m => Int -> (Int -> m ()) -> m ()
rep !n = U.forM_ $ U.generate n id
{-# INLINE rep #-}

rev :: Monad m => Int -> (Int -> m ()) -> m ()
rev !n = U.forM_ $ U.iterateN n (subtract 1) (n - 1)
{-# INLINE rev #-}

type Parser a = C.ByteString -> Maybe (a, C.ByteString)

parseInt :: Parser Int
parseInt = C.readInt . C.dropWhile isSpace

parseInt2 :: Parser (Int, Int)
parseInt2 = runStateT $
    (,) <$> StateT (C.readInt . C.dropWhile isSpace)
        <*> StateT (C.readInt . B.unsafeTail)

parseInt3 :: Parser (Int, Int, Int)
parseInt3 = runStateT $
    (,,) <$> StateT (C.readInt . C.dropWhile isSpace)
        <*> StateT (C.readInt . B.unsafeTail)
        <*> StateT (C.readInt . B.unsafeTail)

parseInt4 :: Parser (Int, Int, Int, Int)
parseInt4 = runStateT $
    (,,,) <$> StateT (C.readInt . C.dropWhile isSpace)
        <*> StateT (C.readInt . B.unsafeTail)
        <*> StateT (C.readInt . B.unsafeTail)
        <*> StateT (C.readInt . B.unsafeTail)


Measured memory_bytes: 508
#include <stdio.h>

int main(void){
  	int n,i;
  	scanf("%d", &n);
  	
  	for(i=1;i<10;i++){
      	if(n<=100*i+10*i+i){
          break;
        }
    }
  	printf("%d", 100*i+10*i+i);
}


Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>

using namespace std;

int col[1050][1050];
int c;
int h, w;
int ch, cw, dh, dw;
vector<string> s;

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

void dfs(int x, int y) {
	col[x][y] = c;
	for (int i = 0; i < 4; ++i) {
		int nx = x + dx[i], ny = y + dy[i];
		if (nx < 0 || ny < 0 || nx >= h || ny >= w) continue;
		if (col[nx][ny]) continue;
		if (s[nx][ny] == '.') dfs(nx, ny);
	}
}

int main() {
	cin >> h >> w;
	cin >> ch >> cw >> dh >> dw;
	s.resize(h);
	for (string& e : s) cin >> e;
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			if (s[i][j] == '#') continue;
			if (col[i][j] == 0) {
				++c;
				dfs(i, j);
			}
		}
	}

	vector<vector<int> > G(c + 1);
	for (int i = 0; i < h; ++i) {
		for (int j = 0; j < w; ++j) {
			int color = col[i][j];
			if (color == 0) continue;
			for (int k = max(0, i - 2); k < min(h, i + 3); ++k) {
				for (int l = max(0, j - 2); l < min(w, j + 3); ++l) {
					if (col[k][l] == 0) continue;
					if (col[i][j] == col[k][l]) continue;
					if (G[color].size() == 0 || find(G[color].begin(), G[color].end(), col[k][l]) == G[color].end())
						G[color].push_back(col[k][l]);
				}
			}
		}
	}

	vector<int> dist(c + 1, -1);
	queue<int> q;
	dist[col[ch - 1][cw - 1]] = 0;
	q.push(col[ch - 1][cw - 1]);
	while (!q.empty()) {
		int v = q.front(); q.pop();
		for (int& nv : G[v]) {
			if (dist[nv] != -1) continue;
			dist[nv] = dist[v] + 1;
			q.push(nv);
		}
	}

	cout << dist[col[dh - 1][dw - 1]] << endl;

	return 0;
}

Measured memory_bytes: 18268
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include <set>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

#define reps(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reps(i,0,n)

int MOD = 1000000007;

int func(int N)
{
    vi w(N);
    iota(w.begin(), w.end(), 0);
    
    int R;
    cin >> R;
    rep(i, R){
        int s, t;
        cin >> s >> t;
        swap(w[s-1], w[t-1]);
    }
    
    ll fact = 1;
    ll ans = 0;
    set<int> S;
    rep(i, N){
        int r = distance(S.begin(), S.lower_bound(w[N-i-1]));
        S.insert(w[N-i-1]);
        ans += fact * r;
        ans %= MOD;
        fact = (fact * (i+1)) % MOD;
    }
    
    return ans;
}

int main()
{
    int N;
    while(cin >> N, N){
        cout << func(N) << endl;
    }
}

Measured memory_bytes: 6076
#include <bits/stdc++.h>
#define maxx 1101
#define mp make_pair
#define mod 1000000007
using namespace std;
typedef pair<int,int> ii;
long long dp[maxx][maxx],vis[maxx][maxx];
char mat[maxx][maxx];
int m,n;

void bfs(int i,int j){
	queue<ii>q;
	q.push(mp(i,j));
	vis[i][j] = 1;
	while(!q.empty()){
		ii k = q.front();
		q.pop();
		int y = k.first;
		int x = k.second;
		
		if(y == n && x == m) break;
		
		if(y + 1 < n && mat[y+1][x] == '.'){
			if(vis[y+1][x] == 0){
				// cout << " ok " << y+1 << " " << x <<'\n';
				if(dp[y][x] == 0) dp[y+1][x] = 1;
				else dp[y+1][x] = dp[y][x] % mod;
				vis[y+1][x] = 1;
				q.push(mp(y+1,x));
				
			}
			else {
				dp[y+1][x] = ((dp[y+1][x]%mod) + (dp[y][x]%mod)%mod);
				// cout << "nao ok " << y+1 << " " << x << '\n'; 
			}
		}
		if(x + 1 < m && mat[y][x+1] == '.'){
			if(vis[y][x+1] == 0){
				// cout << " ok " << y << " " << x+1 <<'\n';
				if(dp[y][x] == 0) dp[y][x+1] = 1;
				else dp[y][x+1] = dp[y][x] % mod;
				vis[y][x+1] = 1;
				q.push(mp(y,x+1));
				
			}
			else {
				dp[y][x+1] = ((dp[y][x+1]%mod) + (dp[y][x]%mod)%mod);
				// cout << ' ' << y << ' ' << x+1 << "\n";
				}
		}
	}
}
int main() {
    ios_base::sync_with_stdio(false);    
    cin.tie(NULL);

	cin >> n >> m;
	string a;
	cin.ignore();
	for(int i = 0; i < n; i++){
		getline(cin,a);
		for(int j = 0; j < m; j++){
			mat[i][j] = a[j];
		}
	}
	bfs(0,0);
/*	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			cout << dp[i][j] << " ";
		}
		cout << "\n";
	}*/
	cout << dp[n-1][m-1]%mod << "\n";
	
 	return 0;
}

Measured memory_bytes: 21908
#include <stdio.h>
#define L 500000

int s[L];
int workspace[L];
int cnt = 0;

void mergeSort(int *a, int low, int high) {
  int mid, i, j, k;

  if(low >= high)
    return;

  mid = (high + low) / 2;
  mergeSort(a, low, mid);
  mergeSort(a, mid + 1, high);

  for(i = low;i <= mid;i++) {
    workspace[i] = a[i];
  }

  for(i = 0;i <= high - mid - 1;i++) {
    workspace[mid + i + 1] = a[high - i];
  }

  j = low;
  k = high;
  int l;
  for(i = low;i <= high;i++) {
    cnt++;
    if(workspace[j] <= workspace[k])
      a[i] = workspace[j++];
    else
      a[i] = workspace[k--];
  }
}

int main() {
  int n, i;

  scanf("%d", &n);
  for(i = 0;i < n;i++)
    scanf("%d", &s[i]);

  mergeSort(s, 0, n - 1);

  for(i = 0;i < n - 1;i++)
    printf("%d ", s[i]);
  printf("%d\n", s[i]);
  printf("%d\n", cnt);

  return 0;
}



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

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

    int N;
    cin >> N;
    vector<int> A(N);
    for (auto &x : A) cin >> x;

    int ans = A.at(0);
    for (int i = 1; i < N; ++i) {
        ans = __gcd(ans, A.at(i));
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>
#include <string.h>

int main() {
	int N;
	long long int Y, i, j, k;
	scanf("%d%lld", &N, &Y);
	for (i=0; i <= N ;i++) {
		for (j=i; j <= N ;j++) {
			if (i*1000+(j-i)*5000+(N-j)*10000 == Y) {
				printf("%d %d %d\n", (N-j), (j-i), i);
				return 0;
			}
		}
	}
	printf("-1 -1 -1\n");
	return 0;
}

Measured memory_bytes: 128
a,b,c= map(int,input().split())
#a 解毒剤入りの美味しくないクッキー
#b 解毒剤入りの美味しいクッキー
#c 毒入りの美味しいクッキー
if c <= a + b + 1 :
    print(c+b)
else:
    print(a+2*b+1)


Measured memory_bytes: 2940
n = int(input())
s = list(input())
ans = 0
for i in range(n - 1):
  l = set(s[0 : i])
  r = set(s[i: len(s)])
  tmp = 0
  for c in l:
    if c in r:
      tmp += 1
  ans = max(ans, tmp)
print(ans)

Measured memory_bytes: 3060
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	uint[] GU => Strs.Select(uint.Parse).ToArray();
	decimal[] GD => Strs.Select(decimal.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	static T[] ConstantArray<T>(int n, T val) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = val; return a; }
	static T[] MakeArray<T>(int n, Func<int, T> f) { var a = new T[n]; for (var i = 0; i < n; i++) a[i] = f(i); return a; }
	static ulong One(int k) => 1ul << k;
	static ulong All(int k) => One(k) - 1;
	static bool Has(ulong s, int k) => (s & One(k)) != 0;
	const int MOD = 1000000007;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var a = F;
		var s = new HashSet<int> { a };
		var i = 1;
		while (true)
		{
			a = a % 2 == 0 ? a / 2 : 3 * a + 1;
			i++;
			if (s.Contains(a)) { WriteLine(i); return; }
			s.Add(a);
		}
	}
}


Measured memory_bytes: 13396
#include<stdio.h>

#define MAXLENGTH 13

int main(void)
{
	int n, x, i, j;
	int a[4][MAXLENGTH];
	char s, m[4] = { 'S','H','C','D' };

	for (i = 0; i < 4; i++)
	{
		for (j = 0; j < MAXLENGTH; j++)
		{
			a[i][j] = 0;
		}
	}
		
	scanf("%d", &n);

	for (i = 0; i < n; i++)
	{
		scanf(" %c %d", &s, &x);
		if(s=='S')
			a[0][x-1] = 1;
		else if(s=='H')
			a[1][x-1] = 1;
		else if(s=='C')
			a[2][x-1] = 1;
		else if(s=='D')
			a[3][x-1] = 1;
	}
	for (i = 0; i < 4; i++)
		for (j = 0; j < MAXLENGTH; j++)
		{
			if (a[i][j] == 0)
				printf("%c %d\n", m[i], j+1);
		}
	
}


Measured memory_bytes: 2032
n,q = map(int, input().split( ))
s = input()

cnt =[0]
tmp = 0
for i in range(1,n):
    if s[i-1:i+1]=="AC":
        tmp+=1
    cnt.append(tmp)

for i in range(q):
    l,r = map(int, input().split( ))
    l-=1;r-=1
    print(cnt[r]-cnt[l])




Measured memory_bytes: 6180
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

int main(){
  ll K;
  cin>>K;
  ll N=50;
  VL X(N);
  rep(i,N) X[i]=i+K/N;
  rep(i,K%N){
    rep(j,N){
      if(i==j) X[j]+=N;
      else X[j]--;
    }
  }
  cout<<N<<endl;
  rep(i,N){
    if(i) cout<<" "<<X[i];
    else cout<<X[i];
  }
  cout<<endl;
}

Measured memory_bytes: 256
#include <bit>
#include <bitset>
#include <assert.h>
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <sstream>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <stdlib.h>
#include <queue>
#include <stack>


typedef long double ld;
typedef long long ll;

using namespace std;

ll MOD = ((ll)1e9 + 7);

struct mod {
	ll x;

	mod(ll tx = 0) {
		x = tx;
	}
	
	mod& operator=(const ll & tx) {
		x = tx;
		return *this;
	}
	
	mod& operator=(const mod & m2) {
		x = m2.x;
		return *this;
	}

	mod operator+(const mod& m2) const {
		return (x + m2.x) % MOD;
	}

	mod& operator+=(const mod& m2) {
		x += m2.x;
		x %= MOD;
		return *this;
	}

	mod operator-(const mod & m2) const {
		return (x - m2.x + MOD) % MOD;
	}

	mod& operator-=(const mod & m2) {
		x -= m2.x;
		x = (x + MOD) % MOD;
		return *this;
	}

	mod operator*(const mod & m2) const {
		return (x * m2.x) % MOD;
	}

	mod& operator*=(const mod & m2) {
		x *= m2.x;
		x %= MOD;
		return *this;
	}

	mod mypow(ll k) const {
		mod ret = 1;
		mod cur = x;
		while (k) {
			if (k & 1) {
				ret *= cur;
			}
			cur *= cur;
			k >>= 1;
		}
		return ret;
	}

	mod inv() const {
		return mypow(MOD - 2);
	}

	mod operator/(const mod & m2) const {
		return mod(((*this).x * (*this).inv().x) % MOD);
	}

	mod& operator/=(const mod & m2) {
		x *= m2.inv().x;
		x %= MOD;
		return *this;
	}

	bool operator<(const mod & m2) const {
		return x < m2.x;
	}
};

ostream &operator<<(ostream & os, const mod & m) {
	return os << m.x;
}

/* TEMPLATE ENDS HERE */

int main() {
	int n;
	cin >> n;
	if (n & 1) {
		printf("%Lf\n", (ld)((n + 1) / 2) / (ld) n);
	} else {
		cout << "0.5" << endl;
	}
	return 0;
}


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

int main(){
    int n;
    ll total=100000;
    cin >> n;
    rep(i,n){
        total+=total*0.05;
        if(total%1000>0) total+=1000-total%1000;
    }
    cout << total << endl;
    return 0;
}



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

int main() {
  long N;
  cin >> N;
  
  vector<long> vec(N);
  long M, L;
  
  cin >> vec.at(0);
  M = vec.at(0);
  for (long i = 1; i < N; i++) {
    cin >> vec.at(i);
    if (M > vec.at(i)) {
      L += M - vec.at(i);
    } else {
      M = vec.at(i);
    }
  }
  
  cout << L << endl;
}

Measured memory_bytes: 4776
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <numeric>
#include <algorithm>
using namespace std;
int N;
int ans = 0;
int main() {
	cin >> N;
	if (N >= 10 - 1) {
		ans += 9;
		if (N >= 1000 - 1) {
			ans += 999 - 100 + 1;
			if (N >= 100000 - 1) {
				ans += 99999 - 10000 + 1;
			}
		}
	}

	if (N < 10 - 1) {
		ans += N;
	}
	else if (N < 1000 - 1) {
		ans += max(N - 100 + 1,0);
	}
	else if (N < 100000 - 1) {
		ans += max(N - 10000 + 1,0);
	}

	cout << ans;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>
#include <cmath>
#include <iostream>
#include <algorithm>
#include <array>
#include <vector>
#include <unordered_map>
#include <unordered_set>

int main()
{
    int N, K;
    std::cin >> N >> K;

    if (N % K == 0) {
        std::cout << 0 << std::endl;
    } else {
        std::cout << 1 << std::endl;
    }

    return 0;
}

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

namespace Atcoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        private static void Yes() { print("Yes"); }
        private static void No() { print("No"); }
        private static void print(object obj) { Console.WriteLine(obj); }

        static void Main(string[] args)
        {
            var a = ReadInts();

            if(a[0] == a[1] && a[1] == a[2])
            {
                Yes();
            }
            else
            {
                No();
            }

        }
    }
}

Measured memory_bytes: 11092
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#define N 200005
using namespace std;
int n, k;
bool cmp(int x, int y) {
    return x > y;
}
int t[N];
int main() {
    int num, cnt = 0, loc, ans = 0;
    scanf("%d %d", &n, &k);
    for(int i = 1; i <= n; i++) {
        scanf("%d", &num);
        t[num]++;
    }    
    sort(t+1, t+1+n, cmp);
    for(int i = 1; i <= n; i++) {
        if(t[i]) cnt++;
        if(cnt == k) {
            loc = i;
            break;
        }
    }
    if(cnt < k) printf("0\n");
    else {
        for(int i = loc+1; i <= n; i++) 
            ans += t[i];
        printf("%d\n", ans);
    }
    return 0;
}


Measured memory_bytes: 896
#include<iostream>
using namespace std;
int main()
{
	int num;
	double weight,height;
	bool f=true;
	while(scanf("%d,%lf,%lf",&num,&weight,&height)!=EOF){
		if(weight/(height*height) >= 25){
			f = false;
			cout << num << endl;
		}
	}
	if(f) cout <<"ツ該ツ督鳴づ按つオ" << endl;
	return 0;
}

Measured memory_bytes: 0
#include<iostream>

void printData(int data[], int dataNum ) {
    for( int i = 0; i < dataNum; i++ ){
        if( i != 0 ) {
            std::cout << " ";
        }
        std::cout << data[i];
    }
    std::cout << std::endl;
}

void printExchangeCnt( int cnt){
    std::cout << cnt;
    std::cout << std::endl;
}

int main() {
    int lineCnt;
    std::cin >> lineCnt;

    int data[lineCnt];
    for( int i = 0; i < lineCnt; i++ ){
        std::cin >> data[i];
    }

    int swCnt = 0;
    for( int i = 0; i < lineCnt; i++ ) {
        bool exchanged = false;
        for( int k = lineCnt - 1; k-1 >= i; k-- ) {
            if( data[k] < data[k-1]) {
                std::swap(data[k],data[k-1]);
                exchanged = true;
                swCnt++;
            }
        }
        if( !exchanged ) {
            break;
        }
    }

    printData(data,lineCnt);
    printExchangeCnt(swCnt);
}


Measured memory_bytes: 3096
main :: IO ()
main = do
  [a, b, x] <- map read . words <$> getLine
  let n = a * a * b
  let per = x / n
  print $ if per <= 0.5 then atan (b / (x / (b * a) * 2)) * (180 / pi)
                        else atan (((b - (x / (a * a))) * 2) / a) * (180 / pi)


Measured memory_bytes: 508
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define SORT(a) sort(a.begin(), a.end())
#define RSORT(a) sort(a.rbegin(), a.rend())
#define REP(i, n) for (int i = 0; i < n; i++)
#define RREP(i, n) for (int i = n; 0 <= i; i--)
#define FOR(i, start, end) for (int i = start; i < end; i++)
#define FORSTEP(i, start, end, step) for (int i = start; i < end; i += step)
#define RFOR(i, start, end) for (int i = start; end <= i; i--)
#define ALL(a) a.begin(), a.end()
#define MOD(a) a %= 1000000007
typedef long long ll;
const int INF32 = 2147483647;
const ll INF64  = 9223372036854775807;
using namespace std;
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;
}

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

    int N;
    cin >> N;
    vector<string> s(N);
    REP(i, N) cin >> s[i];

    int a = 0, b = 0, ab = 0, aandb = 0;

    REP(i, N) {
        if (s[i][0] == 'B' && s[i][s[i].size() - 1] == 'A')
            aandb++;
        if (s[i][0] == 'B')
            b++;
        if (s[i][s[i].size() - 1] == 'A')
            a++;
        REP(j, s[i].size() - 1) {
            if (s[i][j] == 'A' && s[i][j + 1] == 'B')
                ab++;
        }
    }
    int ans;
    if (a == aandb && b == aandb && aandb != 0) {
        ans = aandb - 1 + ab;
    } else if (N == aandb) {
        ans = min(a, b) - 1 + ab;
    } else {
        ans = min(a, b) + ab;
    }

    std::cout << ans << std::endl;

    return 0;
}

Measured memory_bytes: 768
def main():

    S = input()
    left = [0]
    c = 0
    for i in range(len(S)):
        if S[i] == "<":
            c += 1
        else:
            c = 0
        left.append(c)
    right = [0]
    for i in range(len(S)-1, -1, -1):
        if S[i] == ">":
            c += 1
        else:
            c = 0
        right.append(c)
    right = right[::-1]

    # print(S)
    # print(left)
    # print(right)

    ans = 0
    for i in range(len(left)):
        ans += max(left[i], right[i])
    return ans

if __name__ == '__main__':
    print(main())

Measured memory_bytes: 31900
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int a,b;
    cin>>a>>b;
    if(a+b>a-b&&a+b>a*b)
    {cout<<a+b;}
   else if(a-b>a*b)
   {cout<<a-b;}
   else{
       cout<<a*b;}
       return 0;
       
       
}

Measured memory_bytes: 256
def ABC_103_A():
    A1,A2,A3 = map(int, input().split())

    cost1 = 0 + abs(A2-A3) + abs(A3-A1)
    cost2 = 0 + abs(A2-A1) + abs(A3-A2)
    cost3 = abs(A1-A2) + 0 + abs(A3-A1)
    cost4 = abs(A1-A3) + 0 + abs(A3-A2)
    cost5 = abs(A1-A3) + abs(A2-A1) + 0
    cost6 = abs(A1-A2) + abs(A2-A3) + 0

    print(min(cost1,cost2,cost3,cost4,cost5,cost6))

if __name__ == '__main__':

    ABC_103_A()

Measured memory_bytes: 3064
#include <iostream>
#include <string>

int main()
{
    int N;
    std::cin >> N;

    std::string str;
    std::cin >> str;

    int cnt = 0;
    int cntMax = 0;
    for (int i = 0; i < N; ++i)
    {
        if (str[i] == 'I') ++cnt;
        else --cnt;
        cntMax = std::max(cntMax, cnt);
    }

    std::cout << cntMax << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

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

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
#define SLN(i,N) (i == N-1 ? "\n" : " ")
ll fact(ll n) { ll res = 1; for(ll i=2;i<=n;++i) res = res * i; return res;}
ll nCr(ll n, ll r) {return (fact(n)/fact(n-r)*fact(r)) ;}
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;}
const ll MOD = 1e9+7;
const ll INF = 1LL << 60;
const int inf = 1 << 30;
// clang-format on

int N;
int A[MAX_N];

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >> N;
  REP(i,N) cin >> A[i];

  map<int,int> mp;

  REP(i,N) mp[A[i]]++;

  int ans = 0;
  for(auto m : mp) if(m.second % 2 == 1) ans++;

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 5376
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
	int N,M;
	cin >> N >> M;
	int A[10][10];
	int k[10];
	for (int i = 0; i < M; ++i)
	{
		cin >> k[i];
		for (int j = 0; j < k[i]; ++j)
		{
			int t;
			cin >> t;
			A[i][j] = t-1;
		}
	}

	int p[10];
	for (int i = 0; i < M; ++i)
	{
		cin >> p[i]; 
	}

	int max = pow(2,N);
	int s[10];
	int ans = 0;
	for (int i = 0; i < max; ++i)
	{
		bool flag = true;
		int tempi = i;		
		for (int j = 0; j < N; ++j)
		{
			s[j] = tempi % 2;
			tempi /= 2;
		}

		for (int j = 0; j < M; ++j)
		{
			int temp = 0;
			for (int l = 0; l < k[j]; ++l)
			{
				temp += s[A[j][l]];
			}

			if ((temp % 2) != p[j])
			{
				flag = false;
				break;
			}

		}

		if (flag)
		{
			ans++;
		}
	}

	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 384
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
#include<iomanip>
#include<map>
#include<set>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
void init_io(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(10);
}
signed main(){
  init_io();
  ll x,ans=1;
  cin >> x;
  for(ll i=2;i<x;i++){
    ll v = i;
    for(ll j=0;;j++){
      v*=i;
      if(v>x) break;
      if(x-v<x-ans){
        ans = v;
      }
    }
  }
  cout << ans <<endl;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
  int h, w;
  int a, b;
  while(1){
    cin >> h >> w;
    if(h==0 && w==0) break;
    for(a=0; a<h; a++){
      for(b=0; b<w; b++){
	if(a==0|a==h-1|b==0|b==w-1){
	  cout << "#";
	}else{
	  cout << ".";
	}
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1152
#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#include<bits/stdc++.h>
using namespace std;
int main(){
    string s;
    cin >> s;
    int ans =0;
    for (int i = 0; i < s.size()/2; i++)
    {
        if(s[i] != s[s.size()-1-i])ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define endl '\n'
#define pii pair<ll, ll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)       cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)    cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
#define traceloop(x,a) {for(ll i=0;i<x;i++) cerr<<a[i]<<" "; cerr<<endl;}
ll ab(ll x) {return x>0LL?x:-x;}

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	ll n,k; 
	cin>>n>>k;
	vector<ll> v(n),dp(n,INT_MAX);
	for(int i=0; i<n; i++)
		cin>>v[i]; 
	dp[0]=0;
	for(ll i=1; i<n; i++)
	{
		for(ll j=i-1; j>=max(0LL,i-k); j--)
			dp[i] = min(dp[i],dp[j] + abs(v[i]-v[j]));
	}
	cout<<dp[n-1];
	return 0;
}
	


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
const int INT_INF = 2147483647;
//stoi(s) : string→int stoll(s) :string→longlong  int→string to_string(i)
const double PI = acos(-1.0);
//小数点の表し方 cout << fixed << setprecision(5);
const ll LLMAX = 9223372036854775805;

int main(){
    int n,k;
    cin >> n >> k;
    vector<int> p(n);
    for(int i=0;i<n;i++){
        cin >> p[i];
    }
    sort(p.begin(),p.end());
    int ans = 0;
    for(int i=0;i<k;i++){
        ans += p[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include<iostream>
#include<set>
#include<stack>
#include<queue>
#include<string>
#include<algorithm>//min,max,swap,rand,reverse,sort,lower_bound
#include<functional>
#include<vector>
#include<list>
#include<map>
#include<tuple>
#include<cmath>//abs, sin, cos
#include<bitset>
using namespace std;


unsigned long long int H, count = 0, ans=0;

unsigned long long search(unsigned long long int H)
{
	if (H <= 1) {
		return 1;
	}
	else{
		return (2 * search(H / 2) + 1);
	}
}

int main()
{
	cin >> H;
	cout << search(H) << endl;
	return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> VI;
typedef pair <int,int> ii;
typedef long long LL;
#define pb push_back
const int INF = 2147483647;
const int N = 3005;

char t[N];
string s1, s2;
int i, j, res[N][N];
vector<char> vec;

int main() {
scanf("%s", t);
s1 = t;
scanf("%s", t);
s2 = t;
for (i=1;i<=s1.size();i++) for (j=1;j<=s2.size();j++) {
	if (s1[i - 1] == s2[j - 1]) res[i][j] = res[i - 1][j - 1] + 1; else res[i][j] = max(res[i - 1][j], res[i][j - 1]);
}
vec.clear();
i = s1.size();
j = s2.size();
while (i > 0 && j > 0) {
	if (s1[i - 1] == s2[j - 1]) {
		vec.pb(s1[i - 1]);
		i--;
		j--;
	} else if (res[i - 1][j] == res[i][j]) i--; else j--;
}
for (i = vec.size() - 1;i>=0;i--) printf("%c", vec[i]);
printf("\n");
return 0;
}

Measured memory_bytes: 35456
#include<iostream>
#include<string>
#include<map>

using namespace std;
int N;
map<string, int> kind;

int main()
{
    cin >> N;
    string s;
    for(int i=0; i<N; i++) {
    	cin>>s;
    	if(kind.find(s) == kind.end()) {
    		kind[s] = 1;
    	}
    }
    cout << kind.size() << endl;


    return 0;

}

Measured memory_bytes: 19148
fn main() {
    proconio::input! {
        s: String,
    }
    let mut dp = [[0u64;2019];2];
    let mut i=0;
    let mut t=0;
    for v in s.bytes().map(|c| (c-b'0')as usize) {
        let j=1-i;
        for k in 0..2019 {
            dp[j][(k*10+v)%2019] = dp[i][k];
        }
        dp[j][v] += 1;
        t += dp[j][0];
        i=j;
    }
    println!("{}",t);
}

Measured memory_bytes: 2348
#include <iostream>
#include <iomanip>
#include <vector>
#include <complex>
#include <cmath>
#define shosu(x) fixed<<setprecision(x)
using namespace std;
int gcd(int a,int b){
	if(b==0) return a;
	else return gcd(b,a%b);
}
int main(){
	int x,y;
	cin>>x>>y;
	cout<<gcd(x,y)<<endl;
}

Measured memory_bytes: 1160
#include<stdio.h>
#define MAX 2000001
#define LEN  8
#define INFTY -1

void insert(int);
void heapIncreaseKey(int, int);
int extract(void);
void maxHeapify(int);

int h = 0;
int a[MAX];

int main(){
  char com[LEN];
  int key;

  while(1){
    scanf("%s", com);
    if(com[0] == 'e' && com[1] == 'n') break;
    else if(com[0] == 'i'){
      scanf("%d", &key);
      insert(key);
    }
    else{
      printf("%d\n", extract());
    }
  }
  
  return 0;
}

void insert(int key){
  h++;
  a[h] = INFTY;
  heapIncreaseKey(key, h);
}

void heapIncreaseKey(int key, int i){
  int parent = i / 2;
  int v;
  if(key < a[h]) return;
  a[h] = key;
  while(i > 1 && a[parent] < a[i]){
    //a[i]とa[parent]を交換
    v = a[i];
    a[i] = a[parent];
    a[parent] = v;
    //親子関係更新
    i = parent;
    parent = i / 2;
  }
}

int extract(){
  int max;
  if(h < 1) return 0;
  max = a[1];
  a[1] = a[h];
  h--;
  maxHeapify(1);
  return max;
}

void maxHeapify(int i){
  int l, r; //lは左の子のノード番号, rは右の子のノード番号
  int largest; //自分と左の子と右の子でkeyが最大のノードの番号
  int v;
  
  l = 2 * i;
  r = 2 * i + 1;

  //keyが最大のノードを選ぶ
  if(l <= h && a[l] > a[i]) largest = l;
  else largest = i;
  if(r <= h && a[r] > a[largest]) largest = r;

  //iのこの方が大きい時a[i]とa[largest]を交換
  if(largest != i){
    v = a[i];
    a[i] = a[largest];
    a[largest] = v;
    maxHeapify(largest);
  }
}



Measured memory_bytes: 5628
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
int N,K;
long long int ans=0;
int main(){
	cin >> N >> K;
	for(int b=1;b<=N;b++){
		int p=N/b;
		int r=N%b;
		ans+= p*(max(0,b-K));
		ans+= max(0,r-K+1);
		if(K==0)ans--;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(n); i++)
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; }
int main(){
    ll n; cin>>n;
    map<ll,ll> m;
    rep(i,n){
        ll a; cin>>a;
        if(m[a]) m[a]=0;
        else m[a]=1;
    }
    ll res=0;
    for(auto itr=m.begin(); itr!=m.end(); itr++){
        res+=itr->second;
    }
    cout<<res<<endl;
    return 0;
}

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

int main() {
int n;
cin >> n;
vector<int> a(n);
rep(i,n) cin >> a.at(i);
bool ans = true;
int cnt = 0;
while(true){
rep(i,n){
  if(a.at(i)%2 != 0){
    ans = false;
    break;
  }
}
if(ans){
cnt++;
for(int &i:a) i /= 2;
} else break;
}
cout << cnt << endl;
 }


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

int main(void){
    int a, b;
    cin >> a >> b;
    int total = 1;
    int c = 0;
    while(total < b){
        total = total + a - 1;
        c++;
    }
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;

vector<string> dfs(string s, ll depth, vector<char> symbol)
{
    vector<string> ret;
    if (depth == 0)
    {
        ret.push_back(s);
        return ret;
    }

    for (ll i = 0; i < symbol.size(); i++)
    {
        auto vec = dfs(s + symbol[i], depth - 1, symbol);
        for (auto &&e : vec)
        {
            ret.push_back(e);
        }
    }
    return ret;
}

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

enum Tenki
{
    Sunny,
    Cloudy,
    Rainy
};

int main()
{
    ll N;
    cin >> N;
    cout << (N + 1) * N / 2 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
const ll MOD = 1e9 + 7;
vector<vector<ll>> dp(1e5 + 10, vector<ll>(3, 0));
int main(){
    ll N;
    cin >> N;
    for(ll i = 0; i < N; i++){
        ll a, b, c;
        cin >> a >> b >> c;
        dp[i + 1][0] = max(dp[i][1], dp[i][2]) + a;
        dp[i + 1][1] = max(dp[i][2], dp[i][0]) + b;
        dp[i + 1][2] = max(dp[i][0], dp[i][1]) + c;
    }
    cout << max(dp[N][0], max(dp[N][1], dp[N][2])) << endl;
    return 0;
}


Measured memory_bytes: 6272
import java.lang.*;
import java.util.*;
import java.io.*;

public class Main{
    public Hashtable<Integer,Integer>getNTriplesTbl(int n){
	Hashtable<Integer,Integer>retTab = new Hashtable<Integer,Integer>();
	for(int i=1;i<=100;i++){
	    for(int j=1;j<=100;j++){
		for(int k=1;k<=100;k++){
		    int p = i*i+j*j+k*k+i*j+j*k+k*i;
		    int ct = 0;
		    if(retTab.containsKey(p)){
			ct = retTab.get(p);
		    }
		    retTab.put(p,ct+1);
		}
	    }
	}
	return retTab;
    }
    
    public static void main(String[]args) throws Exception{
	Main m = new Main();
	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
	BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(System.out));
	String nLn = br.readLine();
	int n = Integer.parseInt(nLn);
	Hashtable<Integer,Integer>tripTab = m.getNTriplesTbl(n);
	for(int i=1;i<=n;i++){
	    int nTrip = 0;
	    if(tripTab.containsKey(i)){
		nTrip = tripTab.get(i);
	    }
	    bw.write(Integer.toString(nTrip));
	    bw.newLine();
	    bw.flush();
	}
    }
}


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

using namespace std;
typedef long long ll;

ll N,K;
ll A[200000][64];

int main(){
    cin >> N >> K;
    for(int i=0;i<N;i++){
        cin >> A[i][0];
        A[i][0]--;
    }
    for(int i=1;i<=63;i++){
        for(int j=0;j<N;j++){
            A[j][i] = A[A[j][i-1]][i-1];
        }
    }
    int p = 0;
    for(int i=0;i<64;i++){
        if((K>>i)&1) p = A[p][i];
    }
    cout << p+1 << endl;
    return 0;
}

Measured memory_bytes: 103640
import sys, bisect, math, itertools, string, queue, copy
# import numpy as np
# import scipy
from collections import Counter,defaultdict,deque
from itertools import permutations, combinations
from heapq import heappop, heappush
# input = sys.stdin.readline
sys.setrecursionlimit(10**8)
mod = 10**9+7

def inp(): return int(input()) # n=1
def inpm(): return map(int,input().split()) # x=1,y=2
def inpl(): return list(map(int, input().split())) # a=[1,2,3,4,5,...,n]
def inpls():return list(input().split())  # a=['1','2','3',...,'n']
def inpim(n): return list(int(input()) for _ in range(n)) # x=[] 複数行
def inplm(n): return [list(input()) for _ in range(n)]
def inptm(n): return [tuple(input()) for _ in range(n)]
def inpll(n): return [list(map(int, input().split())) for _ in range(n)] # [[1,1,1,1],[2,2,2,2],[3,3,3,3]] 
def inplt(n): return [tuple(map(int, input().split())) for _ in range(n)] # [[1,1,1,1],[2,2,2,2],[3,3,3,3]] 
def inplls(n): return sorted([list(map(int, input().split())) for _ in range(n)]) # [[1,1,1,1],[2,2,2,2],[3,3,3,3]] 
def graph():
    n=inp()
    g=[[] for _ in range(n)]
    for i in range(n):
        a = inp()
        a -= 1
        g[i].append(a)
        g[a].append(i)
    return n,g

def S(p1,p2,p3):
    a,b = p1
    c,d = p2
    e,f = p3
    return abs((d-b)*(e-a) - (f-b)*(c-a))
 
def disk(p1,p2,p3):
    x1,y1 = p1
    x2,y2 = p2
    x3,y3 = p3
    a2 = (x2 - x3) **2 + (y2 -y3) ** 2 
    b2 = (x1 - x3) **2 + (y1 -y3) ** 2
    c2 = (x2 - x1) **2 + (y2 -y1) ** 2
    area = ((x2 - x1) * (y3 -y1) - (x3 -x1) * (y2- y1)) / 2
    if area == 0:
        return (0,0),10**5
    x = (a2*(b2+c2-a2)*x1 + b2*(c2+a2-b2)*x2 +c2*(a2+b2-c2)*x3) / (16*area*area)
    y = (a2*(b2+c2-a2)*y1 + b2*(c2+a2-b2)*y2 +c2*(a2+b2-c2)*y3) / (16*area*area) 
    r = ((x1 - x ) ** 2 + (y1 - y) ** 2)**.5
    return (x,y), r

def circumcircle(): # 最小包含円
    n = inp()
    l = inplt(n)
    ans = 10**5
    dist = lambda p,q: ((p[0]-q[0])**2 + (p[1]-q[1])**2)**.5
    check = lambda c,d: all(dist(c,p)<=d for p in l)
    for i in range(n-1):
        for j in range(i+1,n):
            c = ((l[i][0]+l[j][0])/2, (l[i][1]+l[j][1])/2)
            d = dist(l[i],l[j])/2
            if check(c,d) and d < ans:
                ans = d
    for i in range(n-2):
        for j in range(i+1,n-1):
            for k in range(j+1,n):
                c,d = disk(l[i],l[j],l[k])
                if check(c,d) and d < ans:
                    ans = d
    print(ans)
    
def main():
    circumcircle()
    
if __name__ == "__main__":
    main()




Measured memory_bytes: 52180
using System;

namespace abc056A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split();
            string A = str[0];
            string B = str[1];
            if (A == "H")
                Console.WriteLine(B);
            else if (A == "D" && B == "H")
                Console.WriteLine("D");
            else
                Console.WriteLine("H");
        }
    }
}


Measured memory_bytes: 13140