akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_macros)]
macro_rules! get {
      ($t:ty) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.trim().parse::<$t>().unwrap()
          }
      };
      ($($t:ty),*) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              let mut iter = line.split_whitespace();
              (
                  $(iter.next().unwrap().parse::<$t>().unwrap(),)*
              )
          }
      };
      ($t:ty; $n:expr) => {
          (0..$n).map(|_|
              get!($t)
          ).collect::<Vec<_>>()
      };
      ($($t:ty),*; $n:expr) => {
          (0..$n).map(|_|
              get!($($t),*)
          ).collect::<Vec<_>>()
      };
      ($t:ty ;;) => {
          {
              let mut line: String = String::new();
              std::io::stdin().read_line(&mut line).unwrap();
              line.split_whitespace()
                  .map(|t| t.parse::<$t>().unwrap())
                  .collect::<Vec<_>>()
          }
      };
      ($t:ty ;; $n:expr) => {
          (0..$n).map(|_| get!($t ;;)).collect::<Vec<_>>()
      };
}

mod util {
    use std::io::{stdin, stdout, BufWriter, StdoutLock};
    use std::str::FromStr;
    use std::fmt::Debug;
    #[allow(dead_code)]
    pub fn line() -> String {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.trim().to_string()
    }
    #[allow(dead_code)]
    pub fn chars() -> Vec<char> {
        line().chars().collect()
    } #[allow(dead_code)]
    pub fn gets<T: FromStr>() -> Vec<T>
    where
        <T as FromStr>::Err: Debug,
    {
        let mut line: String = String::new();
        stdin().read_line(&mut line).unwrap();
        line.split_whitespace()
            .map(|t| t.parse().unwrap())
            .collect()
    }
    #[allow(dead_code)]
    pub fn with_bufwriter<F: FnOnce(BufWriter<StdoutLock>) -> ()>(f: F) {
        let out = stdout();
        let writer = BufWriter::new(out.lock());
        f(writer)
    }
}

fn main() {
	let (n, m) = get!(i32, i32);
	let t = util::gets::<i64>();
	let mut a = vec![0];
	for i in 0..n as usize {
		a.push(t[i]);
	}
	for i in 0..a.len()-1 {
		a[i+1] += a[i];
		a[i+1] %= m as i64;
	}
	let mut res :i64 = 0;
	let mut hash : HashMap<i64, i64> = HashMap::new();
	for i in 0..a.len() {
		let count = hash.entry(a[i]).or_insert(0);
		*count += 1;
	}
	for (_k, v) in hash {
		res += v * (v - 1) / 2;
	}
	println!("{}", res);
}



Measured memory_bytes: 13560
"""
https://atcoder.jp/contests/abc173/tasks/abc173_b
"""

import numpy as np

# from numba import jit


# @jit(nopython=True, parallel=False)  # type: ignore
def calc(S: np.ndarray, keys):
    return {key: np.sum(S == key) for key in keys}


def main() -> None:
    keys = ["AC", "WA", "TLE", "RE"]
    N = int(input())
    S = []
    for i in range(N):
        S.append(input())
    result = calc(np.array(S), keys)
    for key in keys:
        print(f"{key} x {result[key]}")


main()


Measured memory_bytes: 36896
#include<stdio.h>
int main(void)
{
	int n,a,s,i,x[100],max,flg,c;
	while(1){
		scanf("%d %d",&a,&s);
		if(a==0&&s==0) break;
				x[0]=a+s;	
			for(i=1;i<5;i++){
				scanf("%d %d",&a,&s);	
					x[i]=a+s;
			}
		max=-1;
			for(i=0;i<5;i++){
				if(max<x[i]){
					max=x[i];
					c=i;
				}
			}
		if(c==0){
			printf("A %d\n",max);
		}
		if(c==1){
			printf("B %d\n",max);
		}
		if(c==2){
			printf("C %d\n",max);
		}
		if(c==3){
			printf("D %d\n",max);
		}
		if(c==4){
			printf("E %d\n",max);
		}		
	}
	return 0;
}

Measured memory_bytes: 1028
import sys
def input(): return sys.stdin.readline().rstrip()
def main():
    h,w,k=map(int,input().split())
    S=[input() for _ in range(h)]
    ANS=[[0]*w for _ in range(h)]
    cunt=0
    for i,s in enumerate(S):
        for j,ss in enumerate(s):
            if ss=='#':
                cunt+=1
                ANS[i][j]=cunt
            elif j>=1 and ANS[i][j-1]>0:
                ANS[i][j]=ANS[i][j-1]
        if ANS[i][-1]!=0:
            for j in range(w-2,-1,-1):
                if ANS[i][j]==0:
                    ANS[i][j]=ANS[i][j+1]
    for i in range(h-2,-1,-1):
        if ANS[i][0]==0:
            for j,ans in enumerate(ANS[i+1]):
                ANS[i][j]=ans
    for i in range(h):
        if ANS[i][0]==0:
            for j,ans in enumerate(ANS[i-1]):
                ANS[i][j]=ans
    for ans in ANS:
        print(*ans)

if __name__=='__main__':
    main()

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

/* REPmacro */
#define REPS(i, a, n) for (ll i = (a); i < (ll)(n); ++i)
#define REP(i, n) REPS(i, 0, n)

/* alias */
using ll = long long;

ll A[100001];
ll B[100001];

signed main() {
  int N; cin >> N;
  REP(i, N+1) cin >> A[i];
  REP(i, N) cin >> B[i];
  ll ans = 0;
  REP(i, N) {
    ll dim1 = min(A[i], B[i]);
    A[i] -= dim1;
    B[i] -= dim1;
    ans += dim1;
    ll dim2 = min(A[i+1], B[i]);
    A[i+1] -= dim2;
    B[i] -= dim2;
    ans += dim2;
  }
  cout << ans << endl;
  return 0;
}

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

using namespace std;

const int N = 200010;

int p[N], n, cnt[N];

int find(int x) {
    return x == p[x] ? p[x] : p[x] = find(p[x]);
}

int main() {
    int m, res = 0;
    cin >> n >> m;
    for (int i = 1; i <= n; ++i) p[i] = i, cnt[i] = 1;
    for (int i = 1; i <= m; ++i) {
        int a, b;
        cin >> a >> b;
        a = find(a), b = find(b);
        if (a != b) {
            cnt[b] += cnt[a];
            p[a] = b;
        }
    }
    for (int i = 1; i <= n; ++i) {
        int x = find(i);
        res = max(cnt[i], res);
    }
    cout << res << '\n';
    return 0;
}

Measured memory_bytes: 11344
#include <stdio.h>

int main(void){
	int N,i;
	int A[100];
	int maxnum, minnum; 

	scanf("%d", &N);
	for(i=0; i<N; i++){
		scanf("%d",&A[i]);
	}
	maxnum = A[0];
	minnum = A[0];
	for(i=1; i<N; i++){
		if(A[i] > maxnum) maxnum = A[i];
		if(A[i] < minnum) minnum = A[i];
	}
	printf("%d", maxnum - minnum);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repI(i, d, n) for (int i = (d); i < (n); ++i)
#define reps1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

using ll = long long;
using P = pair<int, int>;
using Pl = pair<ll, ll>;
using M = map<int, int>;
using Ml = map<ll, ll>;
ll const INF = 1ll<<61;
double pi = 3.141592653589793238;

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

  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  sort(a.begin(), a.end(), greater<ll>());

  // queue<ll> q;
  // q.push(a[0]);

  ll ans = a[0];

  reps1(i, n-1) {
    /*
    ans += q.front();
    q.pop();
    q.push(a[i]);
    q.push(a[i]);
    */
    ans += a[(i+1)/2];

  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 4860
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define _GLIBCXX_DEBUG
#define all(x) x.begin(), x.end()
using namespace std;
typedef long long ll;
typedef pair<int, int> pair;
const int inf = 1000000000; //10^9
const ll inff = 1000000000000000000; //10^18

int main(){
    string s;
    cin >> s;
    int ans = 0;
    string t, p = "";
    rep(i, s.size()) {
        t += s[i];
        if (t == p) continue;
        p = t;
        t = "";
        ans++;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3764
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def read_ints():
    return list(map(int, read().split()))


def read_a_int():
    return int(read())


def read_tuple(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(tuple(map(int, read().split())))
    return ret


def read_col(H):
    '''
    H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


def read_matrix(H):
    '''
    H is number of rows
    '''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return ret
    # return [list(map(int, read().split())) for _ in range(H)] # 内包表記はpypyでは遅いため


MOD = 10**9 + 7
INF = 2**31  # 2147483648 > 10**9
# default import
from collections import defaultdict, Counter, deque
from operator import itemgetter
from itertools import product, permutations, combinations
from bisect import bisect_left, bisect_right  # , insort_left, insort_right

# https://atcoder.jp/contests/abc065/tasks/arc076_a

# 0のとき abs(N-M)>1 必ず隣り合うところができてしまう
# それ以外のとき、Nの順列×Mの順列×犬と猿の並べ方
# 並べ方→同数→×2
# 異なる場合→×1

N, M = read_ints()
if abs(N - M) > 1:
    print(0)
    exit()

N_per = 1
M_per = 1
for i in range(1, N + 1):
    N_per *= i
    N_per %= MOD

for i in range(1, M + 1):
    M_per *= i
    M_per %= MOD


print((2 if N == M else 1) * N_per * M_per % MOD)


Measured memory_bytes: 38640
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()) {
			double q = sc.nextDouble();
			if(q == -1.0) break;
			double x = q / 2;
			while(Math.abs(x * x * x - q) > 0.00001 * q) {
				x = x - (x * x * x - q) /  (3 * x * x);
			}
			System.out.println(x);
		}
		sc.close();
	}
}


Measured memory_bytes: 28040
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <iterator>
#include <numeric>
#include <cstdint>
#include <cmath>
#include <bitset>
#include <string>
#include <list>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>

#define N_TIMES(i, n)     for ( uint64_t i = 0;     i <  n; ++i )
#define N_TIMES_REV(i, n) for (  int64_t i = n - 1; i >= 0; --i )

using namespace std;

const uint64_t MOD = 1e+9 + 7;

uint64_t power_mod(uint64_t x, uint64_t y)
{
  if (y <= 1) { return (y == 0) ? 1 : x; }

  uint64_t w = power_mod(x, y >> 1);

  uint64_t z = (w * w) % MOD;
  if ((y & 1) == 1) { z = (z * x) % MOD; }

  return z;
}

int main()
{
  uint64_t N, K;
  cin >> N >> K;

  auto calc = [&] (uint64_t X) {
    if (X == 0) { return static_cast<uint64_t>(0); }
    return power_mod(K / X, N);
  };

  uint64_t S = 0;
  vector<uint64_t> A(K + 1, 0);
  for (uint64_t X = K; X >= 1; --X) {
    A[X] = calc(X);

    uint64_t Y = X << 1;
    while (Y <= K) {
      A[X] = ((A[X] + MOD) - A[Y]) % MOD;
      Y += X;
    }

    uint64_t T = (A[X] * X) % MOD;
    S = (S + T) % MOD;
  }
  cout << S << endl;

  return 0;
}

Measured memory_bytes: 4048
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define YY cout << "Yes" << endl
#define NN cout << "No" << endl
const int INF = 1000000007;
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
int solve(){
  int h,w;
  cin >> h >> w;
  vector<string>v(h);
  rep(i,h)cin >> v[i];
  rep(i,h)rep(j,2)cout << v[i] << endl;
  return 0;
}
int main(){
  // ios::sync_with_stdio(false);cin.tie(nullptr);
  // cout << fixed;cout << setprecision(16) << endl; 
  solve();
  return 0;
} 

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

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

const int mod = 1000000007;
//const int mod = 998244353;

struct mint {
    ll x; // typedef long long ll;
    mint(ll x=0):x((x%mod+mod)%mod){}
    mint operator-() const { return mint(-x);}
    mint& operator+=(const mint a) {
        if ((x += a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator-=(const mint a) {
        if ((x += mod-a.x) >= mod) x -= mod;
        return *this;
    }
    mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
    mint operator+(const mint a) const { return mint(*this) += a;}
    mint operator-(const mint a) const { return mint(*this) -= a;}
    mint operator*(const mint a) const { return mint(*this) *= a;}
    mint pow(ll t) const {
        if (!t) return 1;
        mint a = pow(t>>1);
        a *= a;
        if (t&1) a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const { return pow(mod-2);}
    mint& operator/=(const mint a) { return *this *= a.inv();}
    mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}


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

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

// combination mod prime
// https://www.youtube.com/watch?v=8uowVvQ_-Mo&feature=youtu.be&t=1619
struct combination {
    vector<mint> fact, ifact;
    combination(int n):fact(n+1),ifact(n+1) {
        assert(n < mod);
        fact[0] = 1;
        for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
    }
    mint operator()(int n, int k) {
        if (k < 0 || k > n) return 0;
        return fact[n]*ifact[k]*ifact[n-k];
    }
};
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int L; cin >> L;
    double ans = (double)pow(L/3.0, 3.0);

    cout << fixed << setprecision(12) << ans << endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;
int n;
string t;
int main(){
	cin>>n;
	vector<string>s(n);
	for(int i=0;i<n;i++){
		cin>>t;
		sort(t.begin(),t.end());
		s[i]=t;
	}
	sort(s.begin(),s.end());

	t=s[0];
	long count=1L,ans=0L;
	for(int i=1;i<n;i++){
		if(t==s[i])count++;
		else{
			if(count>1)ans+=count*(count-1)/2;
			count=1L;
			t=s[i];
		}
	}
	if(count>1L)ans+=count*(count-1L)/2L;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 5760
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int k;
    cin >> k;
    
    queue<ll> que;

    for(int i = 1; i < 10; i++){
        que.push(i);
    }
    int count = 0;
    while(1){

        ll x = que.front();
        count++;
        
        if(count == k){
            cout << x << endl;
            return 0;
        }
        que.pop();

        if(x % 10 != 0){
            que.push(10*x + (x%10) - 1);
        }

        que.push(10*x+(x%10));

        if(x % 10 != 9){
            que.push(10*x+(x%10)+1);
        }

    }



    


    
}

Measured memory_bytes: 1792
import sys
import collections
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())
nsl = lambda: map(str, sys.stdin.readline().split())

n = ni()
lis = [51 for i in range(26)]
for i in range(n):
    s = ns()
    temp = [0 for i in range(26)]
    for t in s:
        temp[ord(t) - ord('a')] += 1
    for j in range(len(temp)):
        lis[j] = min(lis[j], temp[j])
ans = ''
for i in range(26):
    ans += chr(i + ord('a')) * lis[i]
if len(ans) == 0:
    print()
else:
    print(ans)


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

#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++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair

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

const int inf = 1e9;
const ll linf = 1e18;
const ll mod = 1e9 + 7;

int main()
{
  int n, h, w;
  cin >> n >> h >> w;

  cout << max(1, n-h+1)*max(1, n-w+1) << endl;

  return 0;
}


Measured memory_bytes: 256
N, K = map(int, input().split())
XY = [list(map(int, input().split())) for _ in range(N)]

XY.sort(key=lambda x: x[0])

ans = float("INF")
for i in range(N):
    for j in range(i+K-1, N):
        W = XY[j][0] - XY[i][0]
        Y = [XY[x][1] for x in range(i, j+1)]
        Y.sort()
        for l, k in zip(Y, Y[K-1:]):
                H = k - l
                ans = min(ans, W*H)

print(ans)

Measured memory_bytes: 3064
main(x,y,z,e,m){for(;scanf("%d",&e),m=e;printf("%d\n",m))for(z=0;z*z*z<=e;z++)for(y=0;y*y+z*z*z<=e;y++)if(x=e-z*z*z-y*y+y+z,m>x)m=x;exit(0);}

Measured memory_bytes: 600
#include <stdio.h>

int main(void)
{
        int a[3][3],n,i,j,k;

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

        for(i=0;i<n;i++){
                scanf("%d",&b);
                for(j=0;j<3;j++)
                        for(k=0;k<3;k++)
                                if(a[j][k]==b){ a[j][k]=0; break;}
        }

        for(i=0;i<3;i++)
                if(a[i][0]+a[i][1]+a[i][2]==0) {printf("Yes\n"); return 0;}
        for(i=0;i<3;i++)
                if(a[0][i]+a[1][i]+a[2][i]==0){printf("Yes\n"); return 0;}

        if(a[0][0]+a[1][1]+a[2][2]==0){ printf("Yes\n"); return 0;}
        if(a[0][2]+a[1][1]+a[2][0]==0){ printf("Yes\n"); return 0;}

        printf("No\n");
        return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <cmath>

using namespace std;

typedef long long    ll;
typedef long double  ld;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pld;

template <typename T> bool chmax(T &a, T& b) {if (a < b) {a = b; return true;} return false;}
template <typename T> bool chmin(T &a, T& b) {if (a > b) {a = b; return true;} return false;}
#define rep(i, n)      for (int i = 0; i < (int)(n); ++i)
#define rep3(i, m, n)  for (int i = (m); i < (int)(n); ++i)
#define rrep(i, n)     for (int i = (int)(n)-1; i >= 0; --i)
#define rrep3(i, m, n) for (int i = (int)(n)-1; i >= (m); --i)
#define all(x) x.begin(), x.end()
#define rall(x) x.end(), x.begin()
#define mset(x, val) memset(x, (val), sizeof(x))
#define cons(a, b) make_pair((a), (b))
#define car first
#define cdr second

#define endl '\n'
#define INF  0x7f7f7f7f7f7f7f7f
#define INFi 0x7f7f7f7f


ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }

ll solve(int N, const vector<ll> & a, const vector<ll> & b) {
  vector<ll> res(N);
  rep(i, N) {
    ll tmp=0;
    rep(k, i+1) tmp+=a[k];
    rep3(k, i, N) tmp+=b[k];
    res[i] = tmp;
  }
  return *max_element(all(res));
}

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

  // failed to analyze input format
  // TODO: edit here
  int n;
  cin >> n;
  vector<ll> a(n);
  vector<ll> b(n);
  rep (i, n) {cin >> a[i];}
  rep (i, n) {cin >> b[i];}

  auto ans = solve(n, a, b);
  cout << ans << endl;

  return 0;
}


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

int main(){
	string s;
	cin >> s;
	int n = s.length();
	int ans =0;
	rep(i,n/2){
		if(s[i] == s[n-1-i]) continue;
		ans++;
	}
	cout << ans << endl;
	return 0;

}



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

int main() {
	int N, ans = 0, H[101];
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> H[i];
	}
	H[N] = 0;
	N++;
	while (1) {
		bool check = false, flower = false;
		for (int i = 0; i < N; i++) {
			if (flower && H[i] == 0) {
				flower = false;
				ans++;
			}
			if (H[i] > 0) {
				flower = true;
				check = true;
				H[i]--;
			}
		}
		if (!check) break;
	}
	cout << ans;
}

Measured memory_bytes: 256
# Problem B - Small and Large Integers

A, B, K = map(int, input().split())

# initialization

if B-A<=2*K:
    num_list = [i for i in range(A,B+1)]
    # output process 1
    for i in range(K):
        if len(num_list)<=0:
            break
        n = num_list[0]
        print(n)
        num_list.remove(n)

    # output process 2
    output_list = []
    for i in range(K):
        if len(num_list)<=0:
            break
        n = num_list[-1]
        output_list.append(n)
        num_list.remove(n)

    output_list = output_list[::-1]

    for o in output_list:
        print(o)
else:
    num_list_1 = [i for i in range(A, A+K+1)]
    num_list_2 = [i for i in range(B-K+1, B+1)]
    # output process 1
    for i in range(K):
        n = num_list_1[i]
        print(n)

    # output process 2
    for i in range(K):
        n = num_list_2[i]
        print(n)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define INF 1<<30
#define endl '\n'
#define maxn 1005
#define FASTIO ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
typedef long long ll;
const double PI = acos(-1.0);
#define dbg(x) cerr << #x << " = " << x << endl;
#define dbg2(x, y) cerr << #x << " = " << x << ", " << #y << " = " << y << endl;
#define dbg3(x, y, z) cerr << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl;


int main()
{
    FASTIO
    /*
    //double start_time = clock();
#ifndef ONLINE_JUDGE
    freopen("in.txt", "r", stdin);
    freopen("out.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
#endif
//*/
    int T;
    //cin >> T;
    T = 1;
    for (int cs = 1; cs <= T; cs++) {
        int n;
        cin >> n;
        int a[n + 2];
        for (int i = 1; i <= n; i++) {
            cin >> a[i];
        }
        sort(a + 1, a + n + 1);
        cout << a[n / 2 + 1] - a[n / 2] << "\n";
    }

    //double end_time = clock();
    //printf( "Time = %lf ms\n", ( (end_time - start_time) / CLOCKS_PER_SEC)*1000);
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  int ans = 0;
  for(int i=1;i<=N;i+=2) {
    int total = 0;
    for(int j=1;j<=i;j++) {
      if(i % j == 0) {
        total++;
      }
    }

    if(total == 8) {
      ans++;
    }
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define For(i,n) for(long long i=0;i<n;i++)
#define Fre(i,a,b) for(long long i = a; i < b; i++)
#define sf(n) scanf("%d", &n)
#define sff(a,b) scanf("%d %d", &a, &b)
#define sfff(a,b,c) scanf("%d %d %d", &a, &b, &c)
#define pfn(n) prlong longf("%d\n", n)
#define pfs(n) prlong longf("%d ", n)
#define ff first
#define ss second
#define mem(a,b) memset(a,b,sizeof(a))
#define READ freopen("in.txt", "r", stdin)
#define WRITE freopen("out.txt", "w", stdout)
#define sz size()
#define number_of_digit(n) __builtin_ffs(n);
#define ll long long
#define T long long
ll a[3005][3005],b[3005];
ll sum1,sum2;
ll ans;
bool is;
ll solve(int x,int y)
{
	if(x>y)
	{
		return 0;
	}
	if(a[x][y]!=LONG_LONG_MIN)return a[x][y];
	if(is)
	{
		is=false;
		ll g=solve(x+1,y);
		is=false;
		g=max(g+b[x],solve(x,y-1)+b[y]);
		return a[x][y]=g;
	}
	else
	{
		is=true;
		ll g=solve(x+1,y);
		is=true;
		g=min(g-b[x],solve(x,y-1)-b[y]);
		return a[x][y]=g;
	}
 
}
int main()
{
	ios_base::sync_with_stdio(false);
  	cin.tie(NULL);
  	cout.tie(NULL);
 
  	int n,k;
  	cin>>n;
  	For(i,n)cin>>b[i+1];
  	is=true;
  	sum1=0;
  	sum2=0;
  	For(i,n+1)For(j,n+1)a[i][j]=LONG_LONG_MIN;
  	cout<<solve(1,n)<<endl;
	return 0;
}

Measured memory_bytes: 70912
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010

const int MAX_P = 55555;
bool prime[MAX_P+1];

void Eratosthenes(){
  for(int i=2; i<=MAX_P; i++)
    prime[i] = true;

  for(int i=2; i*i<=MAX_P; i++)
    if(prime[i])
      for(int j=i; i*j<=MAX_P; j++)
        prime[i*j] = false;
}


int main(){
  int n;

  Eratosthenes();

  cin >> n;

  int t = 1;

  for(int i=0;i<n;i++){
    while(!prime[t]) t+=5;
    printf("%d%c", t, " \n"[n-1==i]);
    t+=5;
  }

  return 0;
}


Measured memory_bytes: 256
program blackboard
	implicit none
    integer :: N,devided,i,j
    integer,allocatable :: A(:)
    
    j=0
    devided=0
    read(*,*) N
    allocate(A(N))
    read(*,*) A
    do
    	do i =1,N
        	!write(*,*) mod(A(i),2)
            if(mod(A(i),2)==1) then           	
        		j=1 ! Owarimasu
                exit
            else
            	A(i)=A(i)/2
            endif
        end do
        
        if(j==1) then
        	exit
        endif
        devided=devided+1
    end do
    write(*,'(i0)') devided
    deallocate(A)
    
    
end program blackboard

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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>
#include<unordered_set>
#include<bitset>
#include<complex>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int N, K;
	cin >> N >> K;

	int v = 1;
	rep(i, 0, N)
	{
		v += min(v, K);
	}

	cout << v << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long LL;
const LL MOD = 1e9+7;
const LL INF = 1e18;
LL prod(vector<LL>& a, int k, int j=-1)
{
    LL ans = 1;
    for(int i = 0; i < k; i++)
        if(i!=j)
            ans = (ans*a[i])%MOD;
    return ans;
}
bool any_positive(vector<LL>& a)
{
    for(const int& x : a)
        if(x > 0)
            return true;
    return false;
}
bool even_negatives(vector<LL>& a, int k)
{
    int ans = 0;
    for(int i = 0; i < k; i++)
        ans ^= a[i] < 0;
    return ans^1;
}
LL solve(vector<LL>& a, int k)
{
    if(a.size()==k)
        return prod(a,k);
    
    sort(a.begin(),a.end(),[](LL x, LL y){ return abs(x) < abs(y); });
    reverse(a.begin(),a.end());
    if(!any_positive(a))
    {
        if(k%2==0) // all negative, grab the k largest
            return prod(a,k);
        else
        {
            reverse(a.begin(),a.end());
            return prod(a,k);
        }
    }
    if(even_negatives(a,k))
        return prod(a,k);
    if(a[k-1]==0)
        return 0;

    int smallest_negative = -1, smallest_positive = -1;
    int replace_positive = -1, replace_negative = -1;

    for(int i = k-1; i >= 0; i--)
        if(a[i] < 0)
        {
            smallest_negative = i;
            break;
        }
    for(int i = k-1; i >= 0; i--)
        if(a[i] > 0)
        {
            smallest_positive = i;
            break;
        }
    for(int i = k; i < a.size(); i++)
        if(a[i] < 0)
        {
            replace_negative = i;
            break;
        }
    for(int i = k; i < a.size(); i++)
        if(a[i] > 0)
        {
            replace_positive = i;
            break;
        }

    if(smallest_negative != -1 && smallest_positive != -1 && replace_positive != -1 && replace_negative != -1)
    {
        // |a[r+]/a[s-]| > |a[r-]/a[s+]|
        if(a[smallest_positive]*a[replace_positive] < a[smallest_negative]*a[replace_negative])
            swap(a[smallest_positive],a[replace_negative]);
        else
            swap(a[smallest_negative],a[replace_positive]);
    }
    else if(smallest_positive != -1 && replace_negative != -1)
        swap(a[smallest_positive],a[replace_negative]);
    else if(smallest_negative != -1 && replace_positive != -1)
        swap(a[smallest_negative],a[replace_positive]);
    else
        reverse(a.begin(),a.end());
    return prod(a,k);
}
int main()
{
    int n, k; cin >> n >> k;
    vector<LL> a(n);
    for(int i = 0; i < n; i++)
        cin >> a[i];
    cout<<(solve(a,k)+MOD)%MOD<<endl;
    return 0;
}

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

int main()
{
    int c[3][3],sum=0,s1,s2;
    for(int i=0;i<3;i++)
    {
        for(int j=0;j<3;j++)
        {
            cin>>c[i][j];
            sum=sum+c[i][j];
        }
    }
    s1=c[0][0]+c[1][1]+c[2][2];
    s2=c[0][2]+c[1][1]+c[2][0];
    if(sum==s1*3 && sum==s2*3) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}


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

using namespace std;
typedef long long ll;

int main(void) {
    int N, K;
    ll ret = 0;
    cin >> N >> K;

    if(K == 0) ret -= N;
    for(int k=K; k<N; k++) {
        ret += N - k;
        int i=1;
        for(int b=N-k; b>=k+1; b=(N-k)/i) {
            ret += b - k;
            i++;
        }
    }

    return !printf("%lld\n", ret);
}

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

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi; 
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef priority_queue<int> pqi;
typedef priority_queue<int, vi, greater<int>> mpqi;

#define IOS std::ios::sync_with_stdio(false); cin.tie(0);
#define F0R(i,a) for(int i = 0; i < a; i++)
#define R0F(i,a) for(int i = a - 1; i >= 0; i--)
#define pb push_back
#define mp make_pair
#define ins insert
#define ft front()
#define bk back()
#define f first
#define s second
#define trav(a,x) for(auto& a : x)
#define ALL(x) (x).begin(), (x).end()

const int MOD = 1000000007;
const int MX = 2e5+2;
const ll INF = 1000000000000000000;
const ld PI = 4*atan((ld)1);
const pi dir[4] = {{1,0}, {0,1}, {-1,0}, {0,-1}};

// -----------



int main(){
    IOS;
    int a, x;
    cin >> x >> a;
    if(x < a){
        cout << 0; return 0;
    }
    cout << 10;
    return 0;
    // You should actually read the notes to self.
}

/* NOTES TO SELF:
    Int overflow? Array bounds?
    Edge cases? (n = 1, n = 0)
    Don't be dumbosity please pace yourself.
*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define io ios_base::sync_with_stdio(false); cin.tie(NULL);

#define N 4e7
#define nl "\n"
#define f first
#define s second
#define pi acos(-1.0)
#define MOD 1000000007
#define pb push_back
#define vector<int> VI;
#define vector<long long> VII;

typedef long long ll;
typedef double db;

using namespace std;

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

    ///Let the showdown begin

    string s1,s2;

    cin >> s1 >> s2;

    int sz1=s1.size();
    int sz2=s2.size();

    if(sz1>sz2)
        cout << "GREATER" << nl;
    else if(sz1<sz2)
        cout << "LESS" << nl;
    else
    {
        if(s1.compare(s2) < 0)
            cout << "LESS" << nl;
        else if(s1.compare(s2) > 0)
            cout << "GREATER" << nl;
        else if(s1.compare(s2) == 0)
            cout << "EQUAL" << nl;
    }
    ///Happily DONE

    return 0;
}


Measured memory_bytes: 3640
n = int(input())
list = []
ans = 0
for i in range(n):
    x,u=input().split()
    list.append((float(x), u))
    if list[i][1]=='JPY':
        ans += list[i][0]
    else:
        ans += list[i][0] * 380000
print(ans)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main(){
int N,X;
  cin>>N>>X;
  vector<int> A(N+1);
  A[0]=0;
  for(int i=0;i<N;i++){
  int L;cin>>L;
    A[i+1]=A[i]+L;
  }
  
  int count=0;
  for(int i=0;i<=N;i++){
  if(X>=A[i]){
  count++;
  }
    
  
  }
  cout<<count<<endl;
  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;

public class Main {

	/* several useful subroutines */
	private static final BigDecimal BD1000000007 = new BigDecimal(1000000007);
	private static BufferedReader brStdin = new BufferedReader(new InputStreamReader(System.in));
	private static String[] readBuf = null;
	private static int readPtr = 0;
	private static String getString() throws IOException {
		while ( readBuf == null || readPtr >= readBuf.length ) {
			readBuf = brStdin.readLine().split(" ");
			readPtr = 0;
		}
		return readBuf[readPtr++];
	}
	private static int getInt() throws IOException {
		return Integer.parseInt(getString());
	}
	private static long getLong() throws IOException {
		return Long.parseLong(getString());
	}
	private static BigDecimal getBD() throws IOException {
		return new BigDecimal(getString());
	}
	@SuppressWarnings("unused")
	private static String[] getStringArray(int size) throws IOException {
		String stringArray[] = new String[size];
		for (int i = 0; i < stringArray.length; i++) {
			stringArray[i] = getString();
		}
		return stringArray;
	}
	@SuppressWarnings("unused")
	private static int[] getIntArray(int size) throws IOException {
		int intArray[] = new int[size];
		for (int i = 0; i < intArray.length; i++) {
			intArray[i] = getInt();
		}
		return intArray;
	}
	@SuppressWarnings("unused")
	private static long[] getLongArray(int size) throws IOException {
		long longArray[] = new long[size];
		for (int i = 0; i < longArray.length; i++) {
			longArray[i] = getLong();
		}
		return longArray;
	}
	@SuppressWarnings("unused")
	private static BigDecimal[] getBDArray(int size) throws IOException {
		BigDecimal bdArray[] = new BigDecimal[size];
		for (int i = 0; i < bdArray.length; i++) {
			bdArray[i] = getBD();
		}
		return bdArray;
	}
	private static BigDecimal mod1000000007(BigDecimal bd) {
		return bd.subtract(BD1000000007.multiply(bd.divide(BD1000000007, BigDecimal.ROUND_DOWN))) ;
	}
	@SuppressWarnings("unused")
	private static BigDecimal mod1000000007(int i) {
		return mod1000000007(new BigDecimal(i)) ;
	}
	@SuppressWarnings("unused")
	private static BigDecimal mod1000000007(long l) {
		return mod1000000007(new BigDecimal(l)) ;
	}

	
	/* main routine */
	public static void main(String args[]) throws IOException {
		int n = getInt();
		int h[] = getIntArray(n);
		for ( int i = n-1 ; i >0 ; --i ) {
			if ( h[i] < h[i-1] ) {
				if ( h[i] < --h[i-1] ) {
					System.out.println( "No" );
					return;
				}
			}
		}
		System.out.println( "Yes" );
	}
}


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

const long N = 100;

int main(){
	long n, p[N + 1], m[N + 1][N + 1];
	cin >> n;
	for (long i = 1; i <= n; i++) cin >> p[i - 1] >> p[i];
	for (long i = 1; i <= n; i++) m[i][i] = 0;
	for (long l = 2; l <= n; l++){
		for (long i = 1; i <= n - l + 1; i++){
			long j = i + l - 1;
			m[i][j] = (1 << 21);
			for (long k = i; k <= j - 1; k++){
				m[i][j] = min(m[i][j], m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j]);
			}
		}
	}
	cout << m[1][n] << endl;
	return 0;
}

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

int main(){

    char str[1050]={0};
    char ch[1050]={0};
    char mei[30]={0};
    char pl[1050]={0};
    int i,j,k,l,m,n,o;

    scanf("%s",str);
    scanf("%d",&n);
   
    for(i=0;i<7;i++){
        ch[i]=str[i];
    }

    j=0;
    o=0;
    k=l=0;

    for(i=0;i<n;i++){
        scanf("%s",mei);
        scanf("%d %d",&k,&l);
    
        if(mei[2]=='p'){
     
            scanf("%s",pl);

            for(m=0;m<l-k+1;m++){

	            str[m+k]=pl[m];	
            }
        }

        else if(mei[2]=='v'){
      
            for(m=0;m<strlen(str);m++){
	            ch[m]=str[m];
            }
      
            for(m=0;m<l-k+1;m++){
	            str[k+m]=ch[l-m];
            }
    
        }

        else if(mei[0]=='p'){   
      
            for(m=k;m<=l;m++){
	            printf("%c",str[m]);
            }
            printf("\n");
        }
    
    }

    return 0;

}


Measured memory_bytes: 2104
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<utility>
#include<math.h>
#include<cstdlib>
#define rep(i, n) for(int i=0;i<n;i++)
#define repb(i, a, b) for(int i=a;i<b;i++)

using namespace std;
typedef pair<int, int> P;
typedef long long int ll;

const int INF = 1<<30;

int main(){
  int n, k;cin>>n>>k;
  vector<P> sushi(n);
  rep(i, n){
    int t, d;cin>>t>>d;
    sushi[i]=P(d, --t);
  }
  sort(sushi.begin(), sushi.end(), greater<P>());
  vector<bool> include(n, false);
  vector<int> selected;
  ll kind=0LL;
  ll sum=0LL;
  rep(i, k){
    P p=sushi[i];
    if(!include[p.second]){
      include[p.second]=true;
      kind++;
    }else{
      selected.push_back(p.first);
    }
    sum += p.first;
  }
  sort(selected.begin(), selected.end(), greater<int>());
  ll ans=sum+kind*kind;
  ll id=(ll)kind;
  while(!selected.empty() && id<n){
    if(include[sushi[id].second]){id++;continue;}
    include[sushi[id].second] = true;
    sum -= selected.back();selected.pop_back();
    sum += sushi[id].first;
    id++;kind++;
    ans = max(ans, sum+kind*kind);
  }
  cout<<ans<<endl;
  // system("read -n 1 -s -p \"Press any key to continue...\"");
}


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

int main()
{
	string S;

	cin >> S;

	int size = S.length();
	for(int i=0; i<size; i++){
		S[i] = 'x';
	}

	cout << S;

	return 0;
}

Measured memory_bytes: 256
n = int(input())
xys = []
for i in range(n):
    xi, yi = [int(_) for _ in input().split()]
    xys.append([xi, yi])

dis_sum = 0
for i in range(n):
    for j in range(n):
        dis_sum += ((xys[i][0]-xys[j][0])**2 + (xys[i][1]-xys[j][1])**2) ** (1/2)

print(dis_sum / n)

Measured memory_bytes: 3188
#!/usr/bin/env python3
import sys, math, fractions, itertools, collections, copy, heapq


def solve(S: str):
    counter = 0
    c = 0
    for i, s in enumerate(S):
        if s == 'W':
            counter += i - c
            c += 1
    print(counter)
    return


# Generated by 1.1.4 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = next(tokens)  # type: str
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 5688
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        StringBuilder sb = new StringBuilder();
        Scanner in = new Scanner(System.in);
        int x = in.nextInt();
        int y = in.nextInt();
        int tx = in.nextInt();
        int ty = in.nextInt();
        in.close();

        int dx = tx - x;
        int dy = ty - y;

        for (int i = 0; i < dy; i++) {
            sb.append("U");
        }
        for (int i = 0; i < dx; i++) {
            sb.append("R");
        }
        for (int i = 0; i < dy; i++) {
            sb.append("D");
        }
        for (int i = 0; i <= dx; i++) {
            sb.append("L");
        }
        for (int i = 0; i <= dy; i++) {
            sb.append("U");
        }
        for (int i = 0; i <= dx; i++) {
            sb.append("R");
        }
        sb.append("D");
        sb.append("R");
        for (int i = 0; i <= dy; i++) {
            sb.append("D");
        }
        for (int i = 0; i <= dx; i++) {
            sb.append("L");
        }
        sb.append("U");
        System.out.println(sb.toString());
    }

}


Measured memory_bytes: 23892
#include<stdio.h>
int main(void)
{
	int a,b,k,y,cnt=0,i,x[100],p;
	scanf("%d %d %d",&a,&b,&k);
	p=0;
	for(i=100;i>=1;i--){
		if(a%i==0&&b%i==0){
			x[p]=i;
			p++;
		}
	}
	k=k-1;
	printf("%d\n",x[k]);
	return 0;
}

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

using namespace std;

#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define pb push_back
#define mp make_pair
typedef long long LL;
typedef pair<int, int> PII;

int n;
string s;
bool need[100005];

int main() {
    ios_base::sync_with_stdio(false);
    cin >> s;
    n = s.size();
    forn(i, n) {
        need[i + 1] = (s[i] == '1');
    }
    if (need[n] || !need[1]) {
        cout << -1 << endl;
        return 0;
    }
    for (int i = 1; i <= n / 2; ++i) {
        if (need[i] != need[n - i]) {
            cout << -1 << endl;
            return 0;
        }
    }
    cout << "1 2\n";
    int cur = 2;
    for (int i = 2; i < n; ++i) {
        cout << cur << ' ' << i + 1 << '\n';
        if (i <= n / 2 && need[i]) {
            cur = i + 1;
        }
    }
    return 0;
}


Measured memory_bytes: 1744
#include <iostream>
#include <stdio.h>
#include <vector>
using namespace std;

int HelloWorld(){
	cout << "Hello World" << endl;
	return 0;
}

int XCubic(){
	int x;
	cin >> x;
	if (1 <= x && x <= 100){
		x = x*x*x;
		cout << x << endl;
		return 0;
	}
	return 1;
}

int Rectangle(){
	int a, b, area, perimeter;

	cin >> a >>b;
	if (1 <= a && b <= 100){
		area = a*b;
		perimeter = (a + b) * 2;
		cout << area << " " << perimeter << endl;
		return 0;
	}
	return 1;
}

int Watch(){
	int S;
	cin >> S;
	
	
	int D = 60;
	int s = S%D;
	int m = (S / D) % D;
	int h = (S / D) / D;
	if (0 <= S && S <= 86400){
		printf("%u:%u:%u\n", h, m, s);
		return 0;
	}
	
	return 1;
}

int SmallLargeOrEqual(){
	int a, b;
	cin >> a >> b;
	if (!(a <= a && b <= 1000)) return 1;
	if (a < b)		cout << "a < b" << endl;
	else if (a > b) cout << "a > b" << endl;
	else			cout << "a == b" << endl;
	return 0;
}

int Range(){
	int a, b,c;
	bool flag = true;

	cin >> a >> b >> c;
	if (!(0 <= a && a <= 100)) return 1;
	if (!(0 <= b && b <= 100)) return 1;
	if (!(0 <= c && c <= 100)) return 1;

	if (!(a < b)) flag=false;
	if (!(b < c)) flag = false;

	if (flag) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

int SortingThreeNumbers(){
	int a, b, c,temp;
	cin >> a >> b >> c;

	if (!(1 <= a && a <= 10000)) return 1;
	if (!(1 <= b && b <= 10000)) return 1;
	if (!(1 <= c && c <= 10000)) return 1;

	if (a > b){
		temp = a;
		a = b;
		b = temp;
	}
	if (b > c){
		temp = b;
		b = c;
		c = temp;
	}
	if (a > b){
		temp = a;
		a = b;
		b = temp;
	}

	printf("%u %u %u\n", a, b, c);
	
	
	return 0;
}

int CircleInARectangle(){
	int W, H, x, y, r;
	bool flag = true;
	cin >> W >> H >> x >> y >> r;
	if (!(-100 <= x && x <= 100)) return 1;
	if (!(-100 <= y && y <= 100)) return 1;
	if (!(0 <= W && W <= 100)) return 1;
	if (!(0 <= H && H <= 100)) return 1;
	if (!(0 <= r && r <= 100)) return 1;


	if ((x - r) < 0) flag = false;
	if ((y - r) < 0) flag = false;
	if (W < (x + r)) flag = false;
	if (H < (y + r)) flag = false;

	if (flag) cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

int PrintManyHelloWorld(){
	for (int i = 0; i < 1000; i++){
		HelloWorld();
	}
	return 0;
}

int PrintTestCases(){
	int x,i=1;
	
	while (1){
		cin >> x;
		if (x == 0) break;
		cout << "Case " << i++ << ": " << x << endl;
	}

	return 0;

}


int main(){
	//HelloWorld();
	//XCubic();
	//Rectangle();
	//Watch();
	//SmallLargeOrEqual();
	//Range();
	//SortingThreeNumbers();
	//CircleInARectangle();
	//PrintManyHelloWorld();
	PrintTestCases();
	return 0;
}

Measured memory_bytes: 3076
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<math.h>
#include<map>
#include<functional>
#include<queue>
using namespace std;
int keta(int n){
    int d;
    int s=0;
    while(n){
        d=n%10;
        s+=d;
        n/=10;
    }
  return s;
}
int main(){
    int x;
    cin>>x;
    if(x%keta(x)==0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}



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

int main(){
	int a,b,c;
	cin >> a >> b >> c;
	int sum = a+b+c;
	int x = max({a,b,c});
	if((3*x-sum) % 2 == 0){
		cout << (3*x-sum)/2 << endl;
	}else{
		cout << (3*(x+1)-sum)/2 << endl;
	}
    return 0;
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
 
#define INF 100000000
 
using namespace std;
 
int V,match[2001];
bool used[2001];
vector<int>G[2001];
 
void add_edge(int u,int v){
  G[u].push_back(v);
  G[v].push_back(u);
}

bool dfs(int v){
  used[v]=true;
  for(int i=0;i<G[v].size();i++){
    int u=G[v][i],w=match[u];
    if(w<0 || !used[w] && dfs(w)){
      match[v]=u;
      match[u]=v;
      return true;
    }
  }
  return false;
}

int bipartite_matching(){
  int res=0;
  fill(match,match+2001,-1);
  for(int v=0;v<V;v++){
    if(match[v]<0){
      fill(used,used+2001,false);
      if(dfs(v))res++;
    }
  }
  return res;
}

int main(void){  
  int n,m,l,u,v,d,dist[101][101],graph[1001][1001],p[1001],t[1001];
  
  while(cin >> n >> m >> l,n|m|l){  
    
    for(int i=0;i<2001;i++)G[i].clear();
    
    fill(dist[0],dist[101],INF);
    fill(graph[0],graph[1001],0);
    
    for(int i=0;i<101;i++)dist[i][i]=0;
    for(int i=0;i<m;i++){
      cin >> u >> v >> d;
      dist[u][v]=dist[v][u]=d;
    }
    
    for(int i=0;i<l;i++)
      cin >> p[i] >> t[i];
    
    for(int k=0;k<n;k++)
      for(int i=0;i<n;i++)
	for(int j=0;j<n;j++)
	  dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
    
    for(int i=0;i<l;i++)
      for(int j=0;j<l;j++)
	if(i!=j && dist[p[i]][p[j]]+t[i]<=t[j])
	  graph[i][j]=1;
    
    for(int i=0;i<l;i++){
      for(int j=0;j<l;j++){
	if(i!=j && graph[i][j])add_edge(i,j+l);
      }
    }
    V=2*l;
    cout << l-bipartite_matching() << endl;
  }
  return 0;
}

Measured memory_bytes: 13652