akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
int main(void){
    int a;
    int b;
    int c;
    scanf("%d%d%d",&a,&b,&c);
    if(a == b){
        if(a != c)
            printf("Yes");
        else
            printf("No");
    }
 
    else if(a == c){
        if(a != b)
            printf("Yes");
        else
            printf("No");
    }
 
    else if(b == c){
        if(b != a)
            printf("Yes");
        else
            printf("No");
    }
 
    else{
        printf("No");
    }
}

Measured memory_bytes: 1720
<?php
fscanf(STDIN, "%d", $n);
$s = str_split(trim(fgets(STDIN)));

$rgb = array(
  'R' => 0,
  'G' => 0,
  'B' => 0,
);
foreach ($s as $k => $v) {
  $rgb[$v]++;
}
$sum = $rgb['R'] * $rgb['G'] * $rgb['B'];

$count = 0;
for ($i=0; $i < $n; $i++) {
  for ($j=$i+1; $j < $n; $j++) {
    $k = 2 * $j - $i;
    if ($k >= $n) {
      continue;
    }
    if ($s[$i] != $s[$j] && $s[$i] != $s[$k] && $s[$j] != $s[$k]) {
      if ($j-$i == $k-$j) {
        $count++;
      }
    }
  }
}

echo $sum - $count;


Measured memory_bytes: 16216
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pi;
typedef pair<ll,ll> pii;
typedef vector<pi> vpi;
typedef set<ll> si;
typedef long double ld;
#define mp make_pair
#define pb push_back
#define f first
#define s second
ll INF = 1e9;
ll MOD = 1e9+7;
#define lb lower_bound
#define ub upper_bound
#define SZ(x) (ll)x.size()
#define ALL(x) x.begin(),x.end()

vpi V[100100];
int N,M,a,b,offset;
int fw[200100];

void up(int x, int v){
  for (;x<=M*2;x += x&(-x))fw[x] += v;
}

int sum(int x){
  int res = 0;
  for (;x;x-=x&(-x))res += fw[x];
  return res;
}

int main(){
  // freopen("in.txt","r",stdin);
  cin >> N >> M;
  for (int i=0;i<N;++i){
    cin >> a >> b;
    V[b-a+1].pb(mp(a,b));
  }
  offset = N;
  for (int k=1;k<=M;++k){
    // cout<<"add stuff distance " << k-1<<'\n';
    for (auto v : V[k-1]){
      up(v.f, 1);
      up(v.s+1, -1);
      --offset;
    }
    vector<int> v;
    v.clear();
    for (int i=0;i<M;i = i+k){
      v.pb(sum(i+k) - sum(i));
    }
    // for (auto i : v)cout<<i<<' ';cout<<'\n';
    int ans = 0, cur = 0;
    for (auto i : v){
      cur += i;
      ans += cur;
      assert(cur >= 0);
    }
    cout<<offset+ans<<'\n';
  }
}


Measured memory_bytes: 11260
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		//String line = br.readLine();
		Scanner scan = new Scanner(System.in);

	    String a = scan.next();
	    String b = scan.next();
	    String[] c = a.split("");
	    String[] d = b.split("");

	    for(int i=0;i<c.length-1;i++){
	    System.out.print(c[i]);
	    	System.out.print(d[i]);
	    }
	    if(c.length>d.length)
	    	System.out.println(c[c.length-1]);
	    else
	    {System.out.print(c[c.length-1]);
	    System.out.println(d[c.length-1]);}
	    
	    	

	}
}


Measured memory_bytes: 21716
mod = 10 ** 9 + 7


def modpow(x, n):
    if n == 1:
        return x % mod
    elif n % 2 == 0:
        return modpow((x ** 2) % mod, n // 2) % mod
    else:
        return ((modpow((x ** 2) % mod, n // 2) % mod) * x) % mod

def nCk(N, K):
    ans = 1
    for i in range(1, K + 1):
        ans *= (N - i + 1)
        ans %= mod
        ans *= inv[i]
        ans %= mod
    return ans


inv = [0 for i in range(10 ** 5 * 2 + 1)]
inv[1] = 1
for i in range(2, len(inv)):
    inv[i] = modpow(i, mod - 2)

n, a, b = map(int, input().split(" "))
ans = (modpow(2, n) + mod - 1) % mod
ans -= nCk(n, a) + nCk(n, b)
print(ans % mod)

Measured memory_bytes: 53360
n = int(input())
a = list(map(int,input().split()))
res = []
ind = {}
for i in range(n):
    res.append([a[i],i])
jun = [0]*n
res.sort()
for i in range(n):
    jun[res[i][1]] = i+1

#a[i]はjun[i]番目に大きいよ
ans = [0]*n
for i in range(n):
    if jun[i] <=n//2:ans[i]  = res[n//2][0]
    else:ans[i] = res[n//2-1][0]
print(*ans)
    

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

int main() {
    int a,b,c;
    cin>>a>>b>>c;
    int aa,bb,cc;
    int count = 0;
    for (size_t i = 0; i < 10000; i++)
    {
        if(a%2==1||b%2==1||c%2==1){
            cout << count << endl;
            return 0;
        }
        aa=a/2;
        bb=b/2;
        cc=c/2;
        a=bb+cc;
        b=aa+cc;
        c=aa+bb;
        count++;
        /* code */
    }
    cout << -1<<endl;
    
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
#include <time.h>
using namespace std;
#define pi pair<int,int>
#define pl pair<long long,long long>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

long long func(long long a,long long b){
    return a/b;
}

int main(){
    int a; string s; cin >> a >> s;
    if (a >= 3200) cout << s << endl;
    else cout << "red" << endl;
}





Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("fast-math")
#pragma GCC optimize("trapv")
#pragma GCC target("sse4")

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

#define deb(x) cout << #x << " is " << x << "\n"
#define int long long
#define mod 1000000007
#define PI acos(-1)
int32_t main()
{
    string s, d;
    cin>>s>>d;
    int n = s.length();
    int m = d.length();
    int p = INT32_MAX;
    for (int i = 0; i < n - m + 1; i++)
    {
        int c= 0;
        string ss = s.substr(i, m);
        //int k =0;
        for (int j = 0; j < m; j++)
        {
            if (ss[j] != d[j])
                c++;
        }
       
        p = min(p, c);
    }cout<<p<<endl;
    return 0;
}

Measured memory_bytes: 3568
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::io::{BufWriter, Write};

// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn check(a: &[usize]) -> bool {
    let n = a.len();
    for i in 0..n {
        if a[i] == 1 {
            return true;
        }
    }
    return false;
}

fn solve() {
    input!(
        n: usize,
        a: [usize; n],
    );

    if !check(&a) {
        println!("{}", -1);
        return;
    }

    let mut cnt = 1;

    for i in 0..n {
        if a[i] == cnt {
            cnt+=1;
        }
    }

    println!("{}", n - (cnt-1));

}

fn main() {
    let stack_size = 1 << 28;
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}

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

using namespace std;

#define all(x) (x).begin(), (x).end()

typedef long long ll;

const int N = 3e5;

int sz[N];
int can[N];

void solve() {
  int n, m; cin >> n >> m;
  fill(sz + 1, sz + 1 + n, 1);
  can[1] = 1;
  for (int i = 1; i <= m; i++) {
    int x, y; cin >> x >> y;
    if (can[x]) {
      if (sz[x] == 1) {
        can[x] = 0;
      }
      can[y] = 1;
    }
    sz[x]--, sz[y]++;
  }
  int ans = 0;
  for (int i = 1; i <= n; i++) {
    ans += can[i];
  }
  cout << ans;
}

// CHECK LIMITS (n <= 10^5)
// CHECK CORNER CASES (n == 1)

int main() {
  ios::sync_with_stdio(NULL), cin.tie(0), cout.tie(0);
  cout.setf(ios::fixed), cout.precision(20);
  //cout << 1.0 * clock() / CLOCKS_PER_SEC << endl;
  solve();
}


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

using namespace std;
#define                     IO                                              ios_base::sync_with_stdio(0); cin.tie(0)

int main(){
    IO;
    int n;
    cin >> n;
    //scanf("%d",&n);
    int a[n + 1];
    int dp[n + 1];
    for(int i = 0; i < n; i++) cin >> a[i];
    /*
    dp[0] = a[0];
    dp[1] = a[0] + a[1];
    for(int i = 2; i <= n; i++){
        dp[i] = min(dp[i - 1] + a[i],dp[i - 2] + a[i]);
    }
    cout << dp[n - 1] << endl;
    */
    dp[0] = 0;
    dp[1] = abs(a[0] - a[1]);
    for(int i = 2; i <= n; i++){
        dp[i] = min(dp[i - 1] + abs(a[i] - a[i - 1]),dp[i - 2] + abs(a[i] - a[i - 2]));
    }
    cout << dp[n - 1] << endl;
    //printf("%d\n",dp[n - 1]);
}

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

using namespace std;
typedef long long ll;
#define MOD 1000000007
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}


int main() {
    int A, B, C;
    cin >> A >> B >> C;
    if(A+B+C>=22) cout << "bust" << endl;
    else cout << "win" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double PI = acos(-1);
const ll MOD = 1000000007;

int main() {
  string s; cin >> s;
  
  bool can = true;
  string t;
  for (int i = 0; i < s.size(); i++) {
    if (s[i] != 'x') t = t + s[i];
  }
  
  for (int i = 0; i < t.size() / 2; i++) {
    if (t[i] != t[t.size()-1-i]) can = false;
  }
  
  int count = 0;
  string ss = s;
  while (ss.size() > 1) {
    if (ss[0] != ss[ss.size()-1]) {
      count++;
      if (ss[0] == 'x') ss.erase(0,1);
      else ss.erase(ss.size()-1,1);
    } else {
      ss.erase(ss.size()-1,1);
      ss.erase(0,1);
    }
  }
  
  if (can) cout << count << endl;
  else cout << -1 << endl;
}

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

#define f first
#define s second
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define ll long long
#define ull unsigned long long
#define db double
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define pli pair<ll, int>
#define px pair<db, db>
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define input(a) for (auto& el : a) cin >> el;
#define output(a) cout << '!'; for (auto& el : a) cout << el << ' '; cout << '\n'; cout.flush();
#define sz(el) int(el.size())
#define sq(a) ((a) * (a))
#define xll bitset<128>
#define xmin(a,b) a = min(a, b)
#define xmax(a,b) a = max(a, b)
#define sun(a) sort(all(a)); a.resize(unique(all(a)) - a.begin());
/**/  /// extra
//#define forn(i,n) for (int i = 0; i < n; ++i)
//#define rforn(i,n) for (int i = n - 1; i >= 0; --i)
#define bn '\n'
#define vi vector<int>
#define vii vector<vi>
#define vl vector<ll>
#define vll vector<vl>
//#define G vector<vector<pii>>
#define GVE vector<vector<edge>>
#define usi unordered_set<int>
#define usp set<pii>
/**/

using namespace std;

const int INF = 1'000'000'017;
const ll LLINF = 1'000'000'000'000'000'017LL;
const ld inf = 1.0 / 0.0;
const ld eps = 1e-9;
const int MOD = 998244353;

//mt19937_64 rng(chrono::high_resolution_clock::now().time_since_epoch().count());

//uniform_int_distribution<int> uid(l, r); [l, r]
//int x = uid(rng);

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

    ll n;
    cin >> n;
    if (n & 1) {
        cout << 0;
    } else {
        ll cnt = 0;
        ll cur = 10;
        while (cur <= n) {
            cnt += n / cur;
            cur *= 5;
        }
        cout << cnt;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
  ll n,k,m=0,c=0,a;
  cin>>n>>k;
  vector<ll> b(n);
  for(int i=0;i<n;i++){
    cin>>a>>b[i];
    m=max(a,m);
  }
  sort(b.begin(),b.end(),greater<ll>());
  for(int i=0;i<n;i++){
    k-=max(b[i],m);
    c++;
    if(k<=0){
      cout<<c;
      return 0;
    }
  }
  cout<<c+(k%m==0?k/m:k/m+1);
}

Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
using namespace std;
typedef long long LL;

int main(){
    int n,A[100000],rest;
    pair<int,int> min,hold;
    min.first=2000000000;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>A[i];
        if(min.first>A[i]){
            min=make_pair(A[i],i);
        }
    }
    rest=n;
    hold=min;
    while(rest>1){
        for(int i=0;i<n;i++){
            if(i==min.second)continue;
            if(A[i]==0)continue;
            A[i]=A[i]%min.first;
            if(A[i]==0){
                rest--;
            }else if(hold.first>A[i]){
                hold=make_pair(A[i],i);
            }
        }
        min=hold;
    }
    cout<<min.first<<endl;
}


Measured memory_bytes: 640
_, k = map(int, input().split())
a = list(map(int, input().split()))
d = {1: 0}

k += 1
next = 1
cnt = 1
flg = True
while cnt < k:
    next = a[next - 1]
    if flg and next in d:
        flg = False
        d_next = d[next]
        loop_cnt = cnt - d_next  # 1ループの回数
        k -= ((k - d_next) // loop_cnt - 2) * loop_cnt
    d[next] = cnt
    cnt += 1
print(next)

Measured memory_bytes: 32376
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do{cout << "\033[32;1m" << #x << "->" ; err(x);} while(0)
void err(){cout << "\033[39;0m" << endl;}
template<template<typename...> class T,typename t,typename... A>
void err(T<t> a,A... x){for (auto v:a) cout << v << ' '; err(x...);}
template<typename T,typename... A>
void err(T a,A... x){cout << a << ' '; err(x...);}
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> vi;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
        print(v[i],i==(int)(v.size())-1?suc:2);
}
const int INF=0x3f3f3f3f;
const int mod=1e9+7;
ll quick(ll a,ll b)
{
	ll ret=1;
	while(b)
	{
		if(b&1) ret=ret*a%mod;
		a=a*a%mod;
		b>>=1;
	}
	return ret;
}
#define lson o<<1
#define rson o<<1|1
#define Lson L,mid,lson
#define Rson mid+1,R,rson
const int maxn=2e5+7;
int mx[maxn<<2];
int n;
int query(int l,int r,int L=1,int R=n,int o=1)
{
	if(r<1) return 0;
	if(l<=L&&r>=R)
		return mx[o];
	int mid=L+R>>1;
	int ret=INF;
	if(l<=mid)	ret=query(l,r,Lson);
	if(r>mid) ret=min(ret,query(l,r,Rson));
	return ret;
}
void update(int p,int val,int L=1,int R=n,int o=1)
{
	if(L==R)
	{
		mx[o]=val;
		return;
	}
	int mid=L+R>>1;
	if(p<=mid) update(p,val,Lson);
	else update(p,val,Rson);
	mx[o]=min(mx[lson],mx[rson]);
}
int b[maxn];
vi r[maxn];
int main()
{
	memset(mx,0x3f,sizeof(mx));
	cin>>n;
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		cin>>b[i];
		ans+=(!b[i]);
	}
	int q;
	cin>>q;
	for(int i=0,l,rr;i<q;i++)
	{
		cin>>l>>rr;
		r[l].push_back(rr);
	}
	int cur=0;//(0,1)-(0,0)
	for(int i=1;i<=n;i++)
	{
		for(auto u:r[i])
			update(u,min(query(max(1,i-1),u),cur));
		cur=min(cur,query(i-1,i-1))+(b[i]?1:-1);
		//dbg(i,cur,query(i-1,i-1));
	}
	cout<<ans+min(cur,query(n,n))<<'\n';
	
}

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

#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
typedef long long ll;
const int N = 300;
const ll INF = 1e18;

int n;
bool edgeUsed[N][N];
ll minLen[N][N];
vector<pair<int, int>> conn[N];
bool valid = true;

ll sum;

// Djikstra to check if it's correct
void dijkstra(int v) {
	vector<ll> dist(n, INF), parent(n, -1), teo(n, INF);
	vector<bool> used(n, false);
	dist[v] = 0;
		
	for (int i = 0; i < n; ++i) {
		int c = -1;
		for (int j = 0; j < n; ++j) {
			if (!used[j] && (c == -1 || dist[j] < dist[c] || (dist[j] == dist[c] && teo[j] < teo[c])))
				c = j;
		}
		
		used[c] = true;
		if (parent[c] != -1 && !edgeUsed[c][parent[c]]) {
			sum += teo[c];
			edgeUsed[c][parent[c]] = true;
			edgeUsed[parent[c]][c] = true;
		}
		for (auto edge : conn[c]) {
			ll to = edge.first, len = edge.second;
			if (dist[c] + len < dist[to] || (dist[c] + len == dist[to] && len < teo[to])) {
				dist[to] = dist[c] + len;
				parent[to] = c;
				teo[to] = len;
			}
				
		}
	}
	
	for (int i = 0; i < n; ++i) {
		if (minLen[v][i] != dist[i]) valid = false;
	}
}

int main() {
	cin.sync_with_stdio(0); cin.tie(0);
	cin >> n;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			int len; cin >> len;
			minLen[i][j] = len;
			if (i <= j) continue;
			conn[i].push_back({j, len});
			conn[j].push_back({i, len});
		}
	}
	
	 for (int i = 0; i < n; ++i) {
		 dijkstra(i);
	 }
	
	valid ? cout << sum : cout << -1;
}


Measured memory_bytes: 5440
#include <iostream>
#include <iomanip>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <cfloat>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <numeric>

using namespace std;

typedef unsigned int UI;
typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int,int> PII;
typedef istringstream ISS;
typedef ostringstream OSS;

#define REP( i, m, n ) for ( int i = (int)( m ); i < (int)( n ); ++i )
#define FOR( v, c ) for ( auto &v : c )

#define ITER( c ) __typeof( (c).begin() )
#define EACH( it, c ) for ( ITER(c) it = c.begin(); it != c.end(); ++it )
#define ALL( c ) (c).begin(), (c).end()

#define PB( n ) push_back( n )
#define MP( a, b ) make_pair( ( a ), ( b ) )
#define EXIST( c, e ) ( (c).find( e ) != (c).end() )

#define fst first
#define snd second

#define DUMP( x ) cerr << #x << " = " << ( x ) << endl
#define DEBUG( x ) cerr << __FILE__ << ":" << __LINE__ << ": " << #x << " = " << ( x ) << endl

const int dir[][2] = {
	1, 0,
	0, 1,
	-1, 0,
	0, -1
};

PII c2idx( char c )
{
	int n = c - 'A';
	return MP( n / 3, n % 3 );
}

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

	while ( true )
	{
		int n;
		cin >> n;
		if ( !n )
		{
			break;
		}
		
		char s_, t_, b_;
		cin >> s_ >> t_ >> b_;
		
		PII s = c2idx( s_ ), t = c2idx( t_ ), b = c2idx( b_ );

		vector< vector< vector<double> > > dp( n + 1, vector< vector<double> >( 3, vector<double>( 3, 0 ) ) );
		dp[0][ s.fst ][ s.snd ] = 1;

		REP( t, 0, n )
		{
			REP( i, 0, 3 )
			{
				REP( j, 0, 3 )
				{
					REP( d, 0, 4 )
					{
						int di = i + dir[d][0], dj = j + dir[d][1];

						if ( !( 0 <= di && di < 3 && 0 <= dj && dj < 3 ) || MP( di, dj ) == b )
						{
							dp[ t + 1 ][i][j] += dp[t][i][j] / 4;
						}
						else
						{
							dp[ t + 1 ][ di ][ dj ] += dp[t][i][j] / 4;
						}
					}
				}
			}
		}

		cout << dp.back()[ t.fst ][ t.snd ] << endl;
	}

	return 0;
}

Measured memory_bytes: 1276
# 競プロ幼稚園にはN人の子供がいます。えび先生は、子供たちを一列に並べ、一人目にはキャンディーを1個,二人目には2個,...,N人目にはN個あげるこ
# とにしました。必要なキャンディーの個数の合計は何個でしょう?

N = int(input())

print(N * (N + 1 )// 2)


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

int main()
{
	int a1,a2,a3;
	cin >> a1 >> a2 >> a3;
	if (a1 + a2 + a3 >= 22)
	{
		cout << "bust" << endl;
	}
	else
	{
		cout << "win" << endl;
	}
	
	return 0;
}


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

int main()
{
    int n;cin>>n;
    int k;cin>>k;
    int x,c=0;
    REP(i,k){cin>>x;c|=1<<x;}
    for(int i=0;i<(1<<n);i++)
    {
        if((i&c)!=c)continue;
        cout<<i<<":";
        
        for(int j=0;j<n;j++)
        {
            if((i>>j)&1)cout<<" "<<j;
        }
        cout<<endl;
    }
}



Measured memory_bytes: 3100
#include <iostream> 
#include <cstring>
#include <algorithm>
#define INF 500050
double a[INF];
using namespace std;
int main()
{
	int n;
	cin>>n;
	for(int i=1; i<=n; i++) {
		cin>>a[i];
	}
	sort(a+1,a+1+n);
	long double sum = a[1]+a[2];
	long long k = 2;
	for(int i=3; i<=n; i++) {
		sum += 1.0*k*a[i];
		k *= 2;
	}
	sum/=k*1.0;
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cctype>
#include <cstdio>
#include <cstdlib>
 
using namespace std;
 
int main(){
long long n,z,x,x1,x2,x3,x4,x5,x6,x7,x8,x9;
z=1;
x=1000000007;
x1=x*10;
x2=x1*10;
x3=x2*10;
x4=x3*10;
x5=x4*10;
x6=x5*10;
x7=x6*10;
x8=x7*10;
x9=x8*10;
cin>>n;
long long t[n],a[n],m[n],b[n],c[n],r[n];
 
 
 
for (int i = 0; i < n; ++i)
{
	m[i]=1;
	b[i]=0;
	c[i]=0;
	cin>>t[i];
}
for (int i = 0; i < n; ++i)
{
	cin>>a[i];
}

/*
int copy[n];
for(int i=0;i<n;i++){
	copy[i] = a[i];
}
for (int i = 0; i < n; ++i)

	r[i] = copy[n-1-i];
}
*/ 
 
 
for (int j = 0; j < n; ++j)
{
	if (t[j]<=a[j]){
		m[j]=t[j];
	}
	else m[j]=a[j];
	
}
 
/*
cout<<m[0]<<" "<<m[1]<<" "<<m[2]<<" "<<m[3]<<" "<<m[4]<<" "<<m[5]<<endl;
*/
b[0]=t[0];
for (int i = 0; i < n; ++i)
{
	if (t[i]<t[i+1]){
		m[i+1]=1;
		b[i+1]=t[i+1];
	}
}
 
c[n-1]=a[n-1];
for (int i = 0; i < n; ++i)
{
	if (a[i]>a[i+1]){
		m[i]=1;
		c[i]=a[i];
	}
}
/*
cout<<m[0]<<" "<<m[1]<<" "<<m[2]<<" "<<m[3]<<" "<<m[4]<<endl;
*/
 
for (int i = 0; i < n; ++i)
{
 
	if(m[i]==1 && b[i]!=0 && c[i]!=0 && b[i]!=c[i]) z=0;
	if (b[i]>a[i]) z=0;
	if (c[i]>t[i]) z=0;
}
 
/*
for (int i = 0; i < n; ++i)
{
	cout<<b[i]<<" ";
}
cout<<endl;
for (int i = 0; i < n; ++i)
{
	cout<<c[i]<<" ";
}
cout<<endl;
for (int i = 0; i < n; ++i)
{
	cout<<m[i]<<" ";
}
cout<<endl;
*/
 
for (int i = 1; i < n-1; ++i)
{
	z=z*m[i];
	while (z>x9){
		z=z-x9;
	}
	while (z>x8){
		z=z-x8;
	}
	while (z>x7){
		z=z-x7;
	}
	while (z>x6){
		z=z-x6;
	}
	while (z>x5){
		z=z-x5;
	}
	while (z>x4){
		z=z-x4;
	}
	while (z>x3){
		z=z-x3;
	}
	while (z>x2){
		z=z-x2;
	}
	while (z>x1){
		z=z-x1;
	}
	while (z>x){
		z=z-x;
	}
}
cout<<z%x<<endl;
 
return 0;
}

Measured memory_bytes: 4224
a,b,h,m = map(int, input().split())
import math
ar = h / 12 + m / 12 / 60
ax = a * math.cos(ar * 2 * math.pi)
ay = a * math.sin(ar* 2 * math.pi)
br = m / 60
bx = b * math.cos(br* 2 * math.pi)
by = b * math.sin(br* 2 * math.pi)
#print(ar, br)
#print(ax, ay, bx, by)
#print((ax**2+ ay**2)**0.5, (bx**2+ by**2)**0.5)
#print((ax - bx) , (ay - by) )
print(((ax - bx) ** 2 + (ay - by) ** 2) ** 0.5)


Measured memory_bytes: 9516
#include <stdio.h>

int main (void)
{
  int h1,m1,h2,m2,k;
  int s1,s2;
  int total;
  
  scanf("%d %d %d %d %d", &h1,&m1,&h2,&m2,&k);
 
   s1 = h2 - h1;
  
  if(m1<=m2)
    s2 = m2 - m1;
  else{
    s2 = m1 - m2;
    s2 = 60 - s2;
    s1 = s1 - 1;
  }
  
  total = s1*60 + s2 - k;
  
  if(total<0)
    total = 0;
  
  printf("%d", total);
  
  return 0;
}


Measured memory_bytes: 1736
#include <iostream>
using namespace std;
#define MAX 2000000

int H, A[MAX + 1];

void maxHeapify(int i)
{
    int l, r, largest;
    l = 2 * i;
    r = 2 * i + 1;

    if (l <= H && A[l] > A[i])
    {
        largest = l;
    }
    else
    {
        largest = i;
    }
    if (r <= H && A[r] > A[largest])
    {
        largest = r;
    }
    if (largest != i)
    {
        swap(A[i], A[largest]);
        maxHeapify(largest);
    }
}

int main()
{
    cin >> H;
    for (int i = 1; i <= H; i++)
    {
        cin >> A[i];
    }
    for (int i = H / 2; i >= 1; i--)
    {
        maxHeapify(i);
    }
    for (int i = 1; i <= H; i++)
    {
        cout << " " << A[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 5052
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;

template <class T> using Tree = tree<T, null_type, less<T>, rb_tree_tag,tree_order_statistics_node_update>;

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100005;

int n, m;
ll cum[MX], cumX[MX], a[MX];

void ad(int l, int r, int x) {
    cum[l] += x, cum[r+1] -= x;
}

void adX(int l, int r, int x) {
    cumX[l] += x, cumX[r+1] -= x;
}

void process(int ind) {
    if (a[ind] <= a[ind+1]) {
        int dif = a[ind+1]-a[ind];
        ad(1,a[ind],dif); ad(a[ind+1]+1,m,dif);
        ad(a[ind]+1,a[ind+1],a[ind+1]+1), adX(a[ind]+1,a[ind+1],-1);
    } else {
        int dif = a[ind+1]-a[ind]+m;
        ad(a[ind+1]+1,a[ind],dif);
        ad(a[ind]+1,m,m+a[ind+1]+1), adX(a[ind]+1,m,-1);
        ad(1,a[ind+1],a[ind+1]+1), adX(1,a[ind+1],-1);
    }
}

int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin >> n >> m;
    F0R(i,n) cin >> a[i];
    F0R(i,n-1) process(i);
    ll ans = INF;
    FOR(i,1,m+1) {
        cum[i] += cum[i-1];
        cumX[i] += cumX[i-1];
        // cout << "HI " << cumX[i]*i+cum[i] << "\n";
        ans = min(ans,cumX[i]*i+cum[i]);
    }
    cout << ans;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?) ARRAY OUT OF BOUNDSS

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

#define debug(x) cout <<"DEBUG"<<" "<< #x << ":" << x << '\n'
#define rep(i,n) for(int_fast32_t i = 0; i < ((int_fast32_t)(n)); i++)   // 0-indexed up
#define rep1(i,n) for(int_fast32_t i = 1; i <= ((int_fast32_t)(n)); i++) // 1-indexed up
#define rrep(i,n) for(int_fast32_t i = ((int_fast32_t)(n)-1); i >= 0; i--)  // 0-indexed down
#define rrep1(i,n) for(int_fast32_t i = ((int_fast32_t)(n)); i >= 1; i--)   // 1-indexed down
#define all(x) (x).begin(),(x).end()

using namespace std;

template<typename T>
using vec = vector<T>;
using i32 = int_fast32_t;
using i64 = int_fast64_t;
using u32 = uint_fast32_t;
using u64 = uint_fast64_t;
using ll = long long;
using ld = long double;
using vi = vec<int_fast32_t>;
using vl = vec<int_fast64_t>;
using vld = vec<ld>;
using vii = vec<vi>;
using PII = pair<int_fast32_t, int_fast32_t>;

template<class T>
using maxheap = std::priority_queue<T>;
template<class T>
using minheap = std::priority_queue<T, std::vector<T>, std::greater<T>>;

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

const ld Pi = std::acos(-1.0L);
constexpr ll infll = (1LL<<62)-1;
constexpr int inf = (1<<30)-1;
const int mod = 1000000007;
// const int mod = 998244353;


/*FUNCs=================================================*/


/*MAIN==================================================*/
signed main(){
    int START_TIME = clock();
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
//    cout << fixed << setprecision(15);

    i32 x,n, tmp, ans; cin>> x >> n;
    vi p(1000);
    rep(i,n) {
        cin >> tmp;
        p[tmp] = 1;
    }

    tmp = inf, ans = inf;
    rrep(i, 1000) if(!p[i]) {
        if(chmin(tmp, abs(x-i))) {
            chmin(ans, i);
        }
    }

    cout << ans << '\n';

    // printf("ExecutionTime: %d /ms\n",1000*(int)((clock()-START_TIME)/CLOCKS_PER_SEC));
}


Measured memory_bytes: 3680
#include <iostream>
#include <math.h>
#include <algorithm>

using namespace std;

int main(void){
  long long int n, h_new, h_old;
  int i = 1, max = 0, c = 0;
  
  cin >> n;
  cin >> h_old;
  while( i < n ){
	cin >> h_new;
    if(h_old >= h_new){
      c++;
      if(max < c){
        max = c;
      }
    }
    else{
      c = 0;
    }
    h_old = h_new;
    i++;
  }
  cout << max << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
static inline int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
static inline int lcm(int a, int b) { return a * (b / gcd(a, b)); }

int pow(long x, int n, int m){
    long ret = 1;
    while (n > 0) {
        if (n & 1) ret *= x, ret %= m;
        x *= x, x %= m;
        n >>= 1; 
    }
    return ret % m;
}

int euler_phi(int n) {
   int ret = n;
   for(int i = 2; i * i <= n; ++i){
       if(n % i == 0) {
           ret -= ret / i;
           while(n % i == 0) n /= i;
       }
   }
   if(n > 1) ret -= ret / n;
   return ret;
}

int main()
{
    int K;
    scanf("%d", &K);

    K /= gcd(K, 7);
    K *= 9;

    int res = euler_phi(K);

    if(gcd(K, 10) != 1) {
        printf("%d\n", -1);
        return 0;
    }

    int ans = 1000000;
    for(int i = 1; i * i <= res; ++i){
        if(res % i == 0) {
            if(pow(10, i, K) == 1){
                printf("%d\n", i);
                return 0;
            }
            if(pow(10, res / i, K) == 1) ans = min(ans, res / i);
        }
    }
    printf("%d\n", ans);

    return 0;
}

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

using namespace std;

int main(void){
	int n, pot = 0, poh = 0;
	string strt, strh;

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> strt >> strh;
		if (strt > strh) {
			pot += 3;
		}
		else if (strt < strh) {
			poh += 3;
		}
		else {
			pot++;
			poh++;
		}
	}
	
	cout << pot << " " << poh << "\n";
	return 0;
}

Measured memory_bytes: 3152
#include <algorithm>
#include<stdio.h>
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <stack>
#include <queue>
#include<map>
#include <set>
#include<math.h>
using namespace std;
#define int long long
#define ll long long
#define double long double
#define rep(i,n) for(ll i=0;i<n;++i)
#define Rep(i,n) for(ll i=1;i<=n;++i)
#define loop(i,m,n) for(ll i=m;i<n;++i)
#define ggr getchar(); getchar();return 0;
#define pie 3.141592653589793238462643383279
#define elif else if
#define P pair<ll,ll>
#define prique priority_queue<ll>
#define ALL(a)  (a).begin(),(a).end()
const int mod = 1000000007;
const int mod2 = 998244353;
int bin(int bina) {
	int ans = 0;
	for (int i = 0; bina > 0; i++)
	{
		ans = ans + (bina % 2) * pow(10, i);
		bina = bina / 2;
	}
	return ans;
}
bool prime(int n) {
	for (ll i = 2; i <= sqrt(n); i++) {
		if (n % i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int nCr(int n, int r) {
	int ans = 1;
	for (ll i = n; i > n - r; --i) {
		ans = ans * i;
	}
	for (ll i = 1; i < r + 1; ++i) {
		ans = ans / i;
	}
	return ans;
}
int per(int n, int r) {
	r = n - r;
	int sum = 1;
	int i;
	for (i = n; i >= r + 1; i--)sum *= i;
	return sum;
}
struct union_find {
	int par[200010], size_[200010];
	void init(int x) {
		rep(i, x) { par[i] = i; size_[i] = 1; }
	}
	int find(int x) {
		if (par[x] == x)return x;
		return par[x] = find(par[x]);
	}
	void unite(int x, int y) {
		x = find(x); y = find(y);
		if (x == y)return;
		if (size_[x] < size_[y]) {
			par[x] = y;
			size_[y] += size_[x];
		}
		else {
			par[y] = x;
			size_[x] += size_[y];
		}
	}
};

int ctoi(const char c) {
	switch (c) {
	case '0': return 0;
	case '1': return 1;
	case '2': return 2;
	case '3': return 3;
	case '4': return 4;
	case '5': return 5;
	case '6': return 6;
	case '7': return 7;
	case '8': return 8;
	case '9': return 9;
	default: return -1;
	}
}
int keta(int a) {
	return to_string(a).size();
}

signed main() {
	int a, b, c;
	cin >> a >> b >> c;
	int d = (a + c - 1) / c;
	int e = b / c;
	cout << e - d + 1 << endl;
}


Measured memory_bytes: 256
cmp [] [] = True
cmp [] _  = False
cmp (s:ss) (b:bs) = if b == '_' || s == b then cmp ss bs else False


ans' _ _ [] = "No"
ans' l b a@(_:as) = if c then "Yes" else (ans' l b as)
    where
        s = take l a
        c = cmp s b

ans [a,b] = 
    let l = length b
    in
        ans' l b a

main = do
    c <- getContents
    let i = lines c
        o = ans i
    putStrLn o



Measured memory_bytes: 4152
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <limits>
#include <numeric>
#include <queue>
#include <cmath>
#include <set>
#include <map>

using namespace std;

#define INF (1ll<<60)
#define INFint (1<<30)
#define MOD 1000000007
#define BOUND 27182818284

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i, a, b) for(int i=int(a);i<int(b);++i)

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

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

// gcd
template<typename T>
T gcd(T a, T b) {
    if (a == 0)
        return b;
    return gcd(b % a, a);
}

int findGCD(int arr[], int n) {
    int result = arr[0];
    for (int i = 1; i < n; i++)
        result = gcd(arr[i], result);
    return result;
}

template<typename T>
T lcm(T m, T n) {
    // 引数に0がある場合は0を返す
    if ((0 == m) || (0 == n))
        return 0;
    return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    fill((T *) array, (T *) (array + N), val);
}


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

// v.front() = -BOUND;
// v.back() = BOUND;

//struct edge{
//    int cost, to;
//
//    edge(int in_cost, int in_to){
//        cost=in_cost;
//        to=in_to;
//    }
//    bool operator<(const edge &a) const
//    {
//        return cost > a.cost;
//    }
//};

int main() {
    int N; cin >> N;
    string left_s, right_s;

    cout << 0 << endl;
    cin >> left_s;
    if(left_s=="Vacant")
        return 0;

    cout << N-1 << endl;
    cin >> right_s;
    if(right_s=="Vacant")
        return 0;

    int left=0,right=N-1;
    while(true){
        int mid=(left+right)/2;
        string m_string;
        cout << mid << endl;
        cin >> m_string;

        if(m_string=="Vacant")
            return 0;

        bool odd = ((mid - left + 1) % 2==1);
        bool same = (m_string == left_s);
        if(odd ^ same) {
            right = mid;
            right_s = m_string;
        }
        odd = ((right - mid + 1) % 2==1);
        same = (m_string == right_s);
        if(odd ^ same) {
            left = mid;
            left_s = m_string;
        }
    }
    return 0;
}

Measured memory_bytes: 852
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

int main(void) {
    ll n,m;
    cin>>n>>m;
    vector<ll> va;
    vector<ll> vb;
    vector<ll> vc;
    rep(i,0,n){
        ll a,b,c;
        cin>>a>>b>>c;
        va.pb(a);
        vb.pb(b);
        vc.pb(c);
    }
    ll d[2] = {-1,1};
    ll mx = 0;
    rep(a,0,2){
        rep(b,0,2){
            rep(c,0,2){
                vector<ll> v;
                rep(i,0,va.sz){
                    v.pb(va[i]*d[a]+vb[i]*d[b]+vc[i]*d[c]);
                }
                sort(all(v));
                reverse(all(v));
                ll ans = 0;
                rep(i,0,m){
                    ans += v[i];
                }
                mx = max(mx,ans);
            }
        }
    }
    cout << mx << endl;
    return 0;
}

Measured memory_bytes: 256
N=int(input())
T,A = list(map(int,input().split()))
H = list(map(int,input().split()))
delta_T = 700
ind  = 0
for i in range(N):
    if abs(T-H[i]*0.006 -A) < delta_T:
        delta_T = abs(T-H[i]*0.006 -A)
        ind = i
print(ind+1)


Measured memory_bytes: 9184
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <stack>
#include <algorithm>
#include <iostream>
#include <string>
#include <map>
#include <queue>
#include <stdio.h>
#include <math.h>


using namespace std;

typedef long long ll;

typedef vector<vector<ll>> V;
typedef vector<int> vi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<ll> vll;

typedef pair<int, ll> P;
#define mp(x, y) make_pair(x, y)

typedef queue<int> qi;
typedef queue<string> qs;


#define rep(i, n) for(int i=0; i<(n); ++i)
#define repp(i, a, b) for(int i = (a); i <= (b); i++)
#define repm(i, n) for(int i=n; i >= 0; i--)

#define all(v) v.begin(), v.end()
//sort( all(v) )　などと使える


int main() {
	ll n; cin >> n;
	ll N = n;
	cout << n << ":";
	for (ll i = 2; i * i <= N; i++) {
		while (n % i == 0) {
			cout << " " << i;
			
			n = n / i;
		}
	}
	if (n != 1) cout << " " << n;
	cout << endl;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define ve vector
#define pq priority_queue
#define vi vector<int>
#define vl vector<long long>
#define vii vector<vector<int>>
using namespace std;
typedef long long ll;
typedef long double ld;
const ll mod = 1000000007;



int main()
{

    int a,b;
    cin >> a >> b;
    string c=to_string(a),d=to_string(b);
    
    rep(i,b-1){
        c += to_string(a);
    }
    rep(i,a-1){
        d += to_string(b);
    }
    if(c < d) out(c);
    else out(d);


    return 0;
}


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

int main() {
    int N, count1=0, count2=0;
    cin >> N;
    char ch1,ch2;
    vector <string> W(N);
    
    for(int i=0; i < N; i++) cin >> W.at(i);
    for(int i=1; i < W.size(); i++){
        ch1 = W[i][0];
        ch2 = W[i-1][W[i-1].length()-1];
        if(ch1 == ch2) count1 += 1;
        else break;
    }
    for(int i=0; i < W.size(); i++){
        for(int j=0; j < W.size(); j++){
            if(W.at(i) == W.at(j)) count2 += 1;
        }
    }
    if(count1 == N-1 && count2 == N) puts("Yes");
    else puts("No");
}

Measured memory_bytes: 256
import sys
from collections import defaultdict as dd
input = sys.stdin.readline
N, P = map(int, input().split())
S = list(map(int, list(input())[: -1]))
rcs = [0] * (N + 1)
for i in range(N, 0, -1): rcs[i - 1] = (rcs[i] + S[i - 1] * pow(10, N - i, P)) % P
#print(rcs)
d = dd(list)
for i in range(N + 1):d[rcs[i]].append(i)
res = 0
if P == 2 or (P == 5):
  for i in range(N - 1, -1, -1):
    res += (S[i] % P == 0) * (i + 1)
  print(res)
  exit(0)
table = [0] * P
for i in range(N, -1, -1):
  x = rcs[i]
  res += table[x]
  table[x] += 1
print(res)

Measured memory_bytes: 68544
X, N = list(map(int, input().split()))
if N!=0:
    P = set(list(map(int, input().split())))
else:
    print(X)
    exit(0)

dist = 100
r = None
for i in range(105, -1, -1):
    if not i in P and abs(X-i) <= dist:
        dist = abs(X-i)
        r = i

print(r)


Measured memory_bytes: 9072
n=int(input())
a=list(map(int,input().split()))
s=[0]*9
for i in range(n):
  if a[i]<400:
    s[0]+=1
  elif 400<=a[i]<800:
    s[1]+=1
  elif 800<=a[i]<1200:
    s[2]+=1
  elif 1200<=a[i]<1600:
    s[3]+=1  
  elif 1600<=a[i]<2000:
    s[4]+=1  
  elif 2000<=a[i]<2400:
    s[5]+=1  
  elif 2400<=a[i]<2800:
    s[6]+=1  
  elif 2800<=a[i]<3200:
    s[7]+=1       
  else:
    s[8]+=1
ans=0
ans1=0
for k in range(8):
  if s[k]!=0:
    ans+=1
ans1=ans+s[8]

if ans==0:
  ans=1
print(ans,ans1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int N;
	cin >> N;
	vector<int> h(N);
	for(auto &x:h)cin>>x;
	int ans = h[0];
	for(int i=1;i<N;i++){
		if(h[i-1]<h[i]){
			ans += h[i] - h[i-1];
		}
	}
	cout << ans << endl;
}


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

using namespace std;

int main(){
  string O, E;

  cin >> O >> E;

  for(int i = 0; i < O.size()+E.size(); i++){
    if(i%2 == 0) cout << O[i/2];
    else cout << E[i/2];
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;

ll choose(ll i)
{
	return i*(i - 1) / 2;
}
int main()
{
	
	int n; cin >> n;
	vector<string> ss(n);
	map<string, ll> mp;
	rep(i, n) {
		cin >> ss[i];
		sort(ss[i].begin(), ss[i].end());
		mp[ss[i]]++;
	}
	ll cnt = 0;
	rep(i, n) {
		cnt += choose(mp[ss[i]]);
		mp[ss[i]] = 1;
	}
	cout << cnt;
}

Measured memory_bytes: 14316
#include<cstdio>
#include<iostream>
using namespace std;
char s[5];
bool a,b,c;
int main()
{
	scanf("%s",s);
	for(int i=0;i<3;i++)
	{
		if(s[i]=='a')	a=1;
		if(s[i]=='b')	b=1;
		if(s[i]=='c')	c=1;
	}
	if(a&&b&&c)	printf("Yes");
	else		printf("No");
	return 0;
}

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

#define LL long long
#define LD long double
#define SC(t,x) static_cast<t>(x)
#define AR(t) vector < t >
#define PII pair < int, int >
#define PLL pair < LL, LL >
#define PIL pair < int, LL >
#define PLI pair < LL, int >
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define PRF first
#define PRS second
#define INIT(ar,val) memset ( ar, val, sizeof ( ar ) )
#define lp(loop,start,end) for ( int loop = start; loop < end; ++loop )
#define lpd(loop,start,end) for ( int loop = start; loop > end; --loop )
#define lpi(loop,start,end) for ( int loop = start; loop <= end; ++loop )
#define lpdi(loop,start,end) for ( int loop = start; loop >= end; --loop )
#define qmax(a,b) (((a)>(b))?(a):(b))
#define qmin(a,b) (((a)<(b))?(a):(b))
#define qabs(a) (((a)>=0)?(a):(-(a)))

const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MAXN = 1000007;
const int MOD = 998244353;

int n, m;
LL frac[MAXN], rf[MAXN];

void init ();
void input ();
void work ();

void addv ( int &x, int y )
{
	x += y;
	if ( x >= MOD ) x -= MOD;
}

int qpow ( int a, int b )
{
	LL base = a, ans = 1;
	while ( b ){
		if ( b & 1 ) ( ans *= base ) %= MOD;
		( base *= base ) %= MOD;
		b >>= 1;
	}
	return SC ( int, ans );
}

int C ( int n, int m )
{
	return SC ( int, frac[n] * rf[m] % MOD * rf[n-m] % MOD );
}

int getmd ( int n, int m )
{
	return C ( n + m, n );
}



int main()
{
	init();
	input();
	work();
}



void init ()
{
	// Init Everything Here
	
	ios::sync_with_stdio ( false );
	
	frac[0] = 1;
	lp ( i, 1, MAXN ) frac[i] = frac[i-1] * i % MOD;
	rf[MAXN-1] = qpow ( frac[MAXN-1], MOD-2 );
	lpdi ( i, MAXN-2, 0 ) rf[i] = rf[i+1] * ( i + 1 ) % MOD;
}

void input ()
{
	// input method
	
	scanf ( "%d%d", &n, &m );
}

void work ()
{
	// main work
	
	int ans = 0;
	lpi ( i, 1, qmin ( n, m ) ) addv ( ans, SC ( LL, getmd ( n-i, m-i ) ) * getmd ( i, i ) % MOD );
	ans = SC ( LL, ans ) * qpow ( getmd ( n, m ) * 2 % MOD, MOD-2 ) % MOD;
	addv ( ans, qmax ( n, m ) );
	cout << ans << endl;
}

Measured memory_bytes: 15872
#include <iostream>
using namespace std;
#define MAX 100000
int main()
{
	int n, k, q;
	int a[MAX] = { 0 };
	int c[MAX] = { 0 };		// プレイヤーiが正解した回数

	cin >> n >> k >> q;
	for (int i = 0; i < q; i++) {
		cin >> a[i];
		c[a[i] - 1]++;
	}
	
	for (int i = 0; i < n; i++) {
		if ((q - c[i]) >= k) {
			cout << "No" << endl;
		}
		else
		{
			cout << "Yes" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1408
import sys
from io import StringIO
import unittest
import math


# 検索用タグ、広義単調増加
def resolve():
    a, b, n = map(int, input().split())

    x = min(b - 1, n)

    ans = math.floor(a * x / b) - a * math.floor(x / b)

    print(int(ans))


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """5 7 4"""
        output = """2"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """11 10 9"""
        output = """9"""
        self.assertIO(input, output)


if __name__ == "__main__":
    # unittest.main()
	resolve()

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

int N;
const int SIZE = 100005;
int h[SIZE];
int mem[SIZE];
int K;

int dp(int i) {

    if (i == N - 1) return 0;

    if (i == N - 1) return 0;

    if (mem[i] != -1) return mem[i];

    int ret = INT_MAX;

    for (int j =1; j<=K; j++ ) {
      if (i + j < N)
          ret = min(ret, abs(h[i] - h[i+j]) + dp(i+j));
    }
    return  mem[i] = ret;
}

int main() {

    cin >> N;
    cin >> K;

    for (int i = 0; i < N; i++) {
        cin >> h[i];
    }

    memset(mem, -1, sizeof mem);

    cout << dp(0);
}

Measured memory_bytes: 12220
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); ++i)

using namespace std;
using ll = long long;

void solve(ll X) {
  ll m = 100;
  ll ans = 0;
  while (m < X) {
    m *= 1.01;
    ans++;
  }
  cout << ans << endl;
}

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

  ll X;
  cin >> X;

  solve(X);

  return 0;
}


Measured memory_bytes: 3648
n,m=map(int,input().split())
a=[-1]*n
for i in range(m):
    s,c=map(int,input().split())
    s-=1
    if a[s]==-1 or a[s]==c:
        a[s]=c
    else:
        print(-1)
        exit()
if n==1 and (a[0]==0 or a[0]==-1):
    print(0)
    exit()
if a[0]==-1:
    a[0]=1
if a[0]==0:  
    print(-1)
    exit()
b=""
for i in a:
    if i==-1:
        b+="0"
    else:
        b+=str(i)
print(int(b)) 

Measured memory_bytes: 3064