akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream> //入出力
#include <stdio.h>
#include <map>
#include <set>
#include <string>
#include <math.h> //算術演算子
#include <vector>
#include <cstdlib>
#include <queue>
#include <stack>
#include <list>
#include <iomanip> //小数点以下を表示させる(setprecision())
//#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //64bit型

#define debug(x) cerr << x << " " \
                      << "(L:" << __LINE__ << ")" << '\n'
#define PRINT(V)                                   \
        {                                          \
                for (int i = 0; i < V.size(); i++) \
                {                                  \
                        cout << V[i] << " ";       \
                }                                  \
                cout << endl;                      \
        }

int gcd(int a, int b)
{
        return b ? gcd(b, a % b) : a;
}
int dp[(int)1e6 + 1] = {0};

int main()
{
        //input->compute->output//
        int N;
        cin >> N;

        cout << 3 * N * N << endl;

        return 0;
}


Measured memory_bytes: 256
N, M, X, Y = map(int, input().split())
xs = [int(x) for x in input().split()]
ys = [int(y) for y in input().split()]
if max(xs) < min(ys) and max(xs) < Y and min(ys) > X: 
    print('No War')
else:
    print('War')

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

int main () {
    int W, a, b; cin >> W >> a >> b;

    if (a+W < b) cout << b-a-W << endl;
    else if (b+W < a) cout << a-b-W << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 256
n,m = map(int,input().split())
x = list(map(int,input().split()))
x.sort()
if m <= n:
  print(0)
  exit()

l = []

for i in range(len(x)-1):
  l.append(x[i+1] - x[i])
  
l.sort(reverse = True)

for i in range(n-1):
  l[i] = 0
  
print(sum(l))

Measured memory_bytes: 13968
T=input()
ans=""
if T=="?":
    print("D")
    exit()

for i in range(len(T)):
    if T[i]=="P" or T[i]=="D":
        ans+=T[i]
    else:
        if i==0:
            if T[i+1]=="P":
                ans+="D"
            elif T[i+1]=="D":
                ans+="P"
            elif T[i+1]=="?":
                ans+="P"
        elif i!=len(T)-1:
            if ans[-1]=="P" and T[i+1]=="P":
                ans+="D"
            elif ans[-1]=="P" and T[i+1]=="D":
                ans+="D"
            elif ans[-1]=="P" and T[i+1]=="?":
                ans+="D"
            elif ans[-1]=="D" and T[i+1]=="P":
                ans+="D"
            elif ans[-1]=="D" and T[i+1]=="D":
                ans+="P"
            elif ans[-1]=="D" and T[i+1]=="?":
                ans+="P"
        else:
            if ans[-1]=="P":
                ans+="D"
            else:
                ans+="D"
print(ans)

Measured memory_bytes: 9432
import Control.Applicative
import Control.Monad
import Control.Monad.ST
import Data.Functor
import Data.Function
import Data.Monoid
import Data.Maybe
import Data.List
import Data.Foldable (foldMap)
import Data.List.Split
import Data.Bits
import Data.Char
import Data.Ix
import Data.Ratio
import Data.Ord
import Data.Tuple
import Data.Array
import Data.Array.IO
import Data.Array.ST
import Data.IORef
import Data.STRef
 
readInt = read :: String -> Int
readDouble = read :: String -> Double
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
getDouble = readLn :: IO Double
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
apply2 :: (a -> a -> b) -> [a] -> b
apply2 f [x,y] = f x y
apply3 :: (a -> a -> a -> b) -> [a] -> b
apply3 f [x,y,z] = f x y z
fnBin :: (b -> c -> d) -> (a -> b) -> (a -> c) -> a -> d
fnBin op f g x = op (f x) $ g x
fnTuple :: (a -> b, a -> c) -> a -> (b, c)
fnTuple (f,g) a = (f a, g a)
replace :: (Eq a) => a -> a -> [a] -> [a]
replace x y = map (\z -> if z==x then y else z)
modifyArray :: (Ix i, MArray a e m) => a i e -> i -> (e -> e) -> m ()
modifyArray arr ix f = readArray arr ix >>= writeArray arr ix . f
-- end of templete

f x
  | x < 165.0 = 1
  | x < 170.0 = 2
  | x < 175.0 = 3
  | x < 180.0 = 4
  | x < 185.0 = 5
  | otherwise = 6

g s = zipWith (++) [show i ++ ":" | i <- [1..6]] $ map (flip replicate '*') $ map length $ map ($(map f s)) $ map filter $ map (==) [1..6]

main = getInt >>= flip replicateM getDouble >>= mapM_ putStrLn . g

Measured memory_bytes: 4320
#include <stdio.h>
#include <cstdlib>
#include <iostream>
#include <string>
#include <set>
#include <tuple>
#include <algorithm>

using namespace std;

int main()
{
	int X;
	int A;
	int B;

	cin >> X >> A >> B;

	cout << (X-A)%B;

	return 0;
}

Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		sc.close();

		int n2 = n * 2;
		int mod = 1000000007;
		BigInteger bm = BigInteger.valueOf(mod);

		long[] total = new long[n2];
		total[n2 - 1] = power(100 - c, n2 - 1, mod);
		total[n2 - 1] = BigInteger.valueOf(total[n2 - 1]).modInverse(bm).longValue();
		for (int i = n2 - 2; i >= n; i--) {
			total[i] = total[i + 1] * (100 - c) % mod;
		}

		long[] pa = new long[n + 1];
		pa[0] = 1;
		long[] pb = new long[n + 1];
		pb[0] = 1;
		for (int i = 1; i <= n; i++) {
			pa[i] = pa[i - 1] * a % mod;
			pb[i] = pb[i - 1] * b % mod;
		}
		NCR ncr = new NCR(n2, mod);

		long ans = 0;
		for (int i = n; i < n2; i++) {
			long val1 = ncr.calc(i - 1, n - 1);
			long val2 = (pa[n] * pb[i - n] + pa[i - n] * pb[n]) % mod;
			ans += val1 * val2 % mod * i % mod * total[i] % mod;
			ans %= mod;
		}

		long draw = 100 * BigInteger.valueOf(100 - c).modInverse(bm).longValue() % mod;
		ans *= draw;
		ans %= mod;
		System.out.println(ans);
	}

	static class NCR {
		long[] p, pi;
		int m;

		public NCR(int n, int mod) {
			n++;
			m = mod;
			p = new long[n];
			pi = new long[n];
			p[0] = 1;
			pi[0] = 1;
			for (int i = 1; i < n; i++) {
				p[i] = p[i - 1] * i % m;
			}
			pi[n - 1] = BigInteger.valueOf(p[n - 1])
					.modInverse(BigInteger.valueOf(m)).longValue();
			for (int i = n - 1; i > 1; i--) {
				pi[i - 1] = pi[i] * i % m;
			}
		}

		public long calc(int n, int r) {
			if (n < r) return 0;
			return p[n] * pi[r] % m * pi[n - r] % m;
		}
	}

	static long power(long x, long n, int m) {
		if (n == 0) {
			return 1;
		}
		long val = power(x, n / 2, m);
		val = val * val % m;
		if (n % 2 == 1) {
			val = val * x % m;
		}
		return val;
	}
}


Measured memory_bytes: 28848
#include <algorithm>
#include <array>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


#define W 0
#define B 1
#define H 0
#define V 1

#define WB(x, y) (((x) % K2 < K) ^ ((y) % K2 < K) ? B : W)


int N, K, K2, x, y, a[2222][2222], aa[2222][2222], b[2222][2222], bb[2222][2222];

char c;


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);

  std::cin >> N >> K;

  K2 = K + K;

  for (int i = 0; i < N; i ++) {
    std::cin >> x >> y >> c;

    (c == 'W' ? a : b)[y % K2][x % K2] ++;
  }

  for (int i = 0; i < K2; i ++)
    for (int j = 0; j < K2; j ++) {
      aa[i + 1][j + 1] = aa[i + 1][j] + a[i][j];
      bb[i + 1][j + 1] = bb[i + 1][j] + b[i][j];
    }

  for (int i = 0; i < K2; i ++)
    for (int j = 0; j <= K2; j ++) {
      aa[i + 1][j] += aa[i][j];
      bb[i + 1][j] += bb[i][j];
    }

  int rp = 0;

  for (int i = 0; i < K2; i ++)
    for (int j = 0; j < K2; j ++) {
      int r = 0;
      
      for (int k = 0; k < 4; k ++)
        for (int l = 0; l < 4; l ++) {
          int xx = j + l * K - K2, yy = i + k * K - K2, xxx = xx + K, yyy = yy + K;

          if (xxx <= 0 || yyy <= 0 || xx >= K2 || yy >= K2)
            continue;

          xx  = std::max(xx,  0);
          yy  = std::max(yy,  0);
          xxx = std::min(xxx, K2);
          yyy = std::min(yyy, K2);

          if (((k % 2) ^ (l % 2)) == 0) {
            r += aa[yyy][xxx] - aa[yyy][xx] - aa[yy][xxx] + aa[yy][xx];
          }
          else {
            r += bb[yyy][xxx] - bb[yyy][xx] - bb[yy][xxx] + bb[yy][xx];
          }
        }

      rp = std::max(r, rp);
    }

  std::cout << rp << std::endl;

  return 0;
}


Measured memory_bytes: 76032
#include <bits/stdc++.h>
using namespace std;
static const int INF = 1<<20;

int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    set<int> dic;
    for(int i=0; i<n; i++){
        cin>>a[i];
        dic.insert(a[i]);
    }

    int ans = INF;

    for(int num=-100; num<=100; num++){
        int tmp = 0;
        for(int i=0; i<n; i++){
            tmp += ((a[i] - num)*(a[i] - num));
        }

        ans = min(tmp,ans);
    }

    if(dic.size() == 1) ans = 0;

    cout<<ans<<endl;

    return 0;
}

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

void chmax(ll& a, ll b) { a = max(a, b); }
void chmin(ll& a, ll b) { a = min(a, b); }


int main() {
    string s,t; cin >> s >> t;
    sort(s.begin(), s.end());
    sort(t.rbegin(), t.rend());
    if(s < t) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;

}


Measured memory_bytes: 256
//shan61916
#include <bits/stdc++.h>
  using namespace std;
typedef   long long ll;
typedef   unsigned long long ull ;
typedef   double dll ;

#define   mp make_pair
#define   pb push_back
#define   ff first 
#define   ss second
#define   IOS ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define   endl "\n" 
#define   pll pair<ll, ll>
#define   all(x) x.begin(), x.end()
#define   vll vector<ll> 

const ll inf = (ll)(1e17 + 17);
const ll mod = (ll)(1e9 + 7);


int main(){
 IOS
#ifdef SHAN
    freopen("input.txt" , "r" , stdin);  
#endif
  ll n;
  cin >> n;
  multiset<ll, greater<ll>> st;
  vll a(n);
  for(ll i = 0; i < n; i++) {cin >> a[i]; st.insert(a[i]);}
  for(ll i = 0; i < n; i++) {
  	st.erase(st.find(a[i]));
  	cout << *st.begin() << endl;
  	st.insert(a[i]);
  }
  return 0;
} //good night.

Measured memory_bytes: 12672
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

ll factorial(ll n) {
  ll answer = 1;
  while (n > 1) {
    answer *= n;
    answer %= mod;
    n--;
  }
  return answer;
}

ll combination(ll n, ll r) {
  return factorial(n) / (factorial(r) * factorial(n - r));
}

ll permutation(ll n, ll r) { return factorial(n) / factorial(n - r); }

template <typename T>
void remove(std::vector<T>& vector, unsigned int index) {
  vector.erase(vector.begin() + index);
}

map<ll, ll> prime_factor(ll n) {
  map<ll, ll> ret;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if (n != 1) ret[n] = 1;
  return ret;
}
// for (auto p : prime_factor(n)) {
//	while (p.second--) {
//		cout << p.first << endl;
//	}
//}

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

int main() {
  int n;
  cin >> n;
  vector<ll> a(n);
  ll sum = 0;
  REP(i, n) {
    cin >> a[i];
    sum += a[i];
  }
  ll leftSum = 0;
  ll minIn = 0;
  ll minSum = 2020202021;
  ll ans = 0;
  REP(i, n - 1) {
    leftSum += a[i];
    ll rightSum = sum - leftSum;
    if (rightSum == leftSum) {
      cout << 0 << endl;
      return 0;
    } else {
      ll dif = abs(leftSum - rightSum);
      if (minSum > dif) {
        minIn = i;
        minSum = dif;
      }
    }
  }

  cout << minSum << endl;
  return 0;
}

Measured memory_bytes: 1792
from collections import deque
ans = deque()
n=int(input())
*l, = map(int,input().split())
r=True
for i in l:
  if r:
    r=False
    ans.append(i)
  else:
    r=True
    ans.appendleft(i)
s = [str(i) for i in ans]
if len(l)%2 == 1:
  s.reverse()
print(' '.join(s))
    

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

int main()
{
	int i,j,x,s,t;
	s=t=0;
	for (i=0;i<3;i++)
	  for (j=0;j<3;j++)
	  {
	  	cin>>x;
	  	if (i==j) t+=x;
	  	else s+=x;
	  }
	if (t*2==s) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

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

#define REP(i, x) REPI(i, 0, x)
#define REPI(i, a, b) for (int i = int(a); i < int(b); ++i)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
using namespace std;

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

  int A, B;
  cin >> A >> B;
  if (A % 2 == 1 && B % 2 == 1) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp> // Common file 
//#include <ext/pb_ds/tree_policy.hpp> 
#define int long long
#define pb push_back
#define ff first
#define ss second
#define ii insert
#define ld long double
#define sz(x) (int)x.size()
#define all(v) v.begin(),v.end()
#define ppb pop_back
#define nuenxfiu ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
#define input freopen("input.txt", "r", stdin),freopen("output.txt", "w", stdout);
#define TT int testcases;cin>>testcases;while(testcases--)
#define mk make_pair
#define MAX ((int)2e9+17)
#define mod ((int)1e9+7)
#define MOD 1000003
//int fact[1000007]={0};
#define N 1e5+5
int fpow(int n, int k, int p = mod) {int r = 1; while(k > 0) {if (k & 1) r = r * n%p; n = n * n%p; k = k >> 1;} return r;}
int expo(int x,int y){ int res=1; while(y) {if(y%2) res=(res*x%mod)%mod; x=(x*x)%mod; y/=2; } return res;}
int sub(int a, int b) {return (a%mod - b%mod + mod)%mod;}
int mul(int a, int b) {return ((a%mod)*(b%mod) + mod)%mod;}
int inv(int x) {return expo(x, mod-2);}
using namespace std;

int a[100005];
int dp[100005];
int n;
int k;
int func(int id)
{
	if(id==n)	return 0;
	
	if(dp[id]!=-1) return dp[id];
	
	int mini=1e18;
	
	for(int i=id+1;i<=min(n,id+2);i++)
	{
		mini=min(mini,abs(a[i]-a[id])+func(i));
	}
	
	return dp[id]=mini;

}

void solve()
{
	cin>>n;
	
	for(int i=1;i<=n;i++)
		cin>>a[i];
	
	memset(dp,-1,sizeof(dp));
	
	cout<<func(1)<<endl;;
	
	return ;

}
signed main()
{
    
	nuenxfiu
	//TT
	solve();
     return 0;
}

Measured memory_bytes: 11436
#include <cstdio>
#include <iostream>
#include <iomanip>
#include<cmath>
#include<string>
#include<algorithm>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main() {
	int a;
	cin >> a;
	if (a % 10 == 0) { cout << 10 << endl; }
	else { cout <<(a % 1000000/100000) +( a % 100000/10000 )+( a%10000/1000) +( a%1000/100) +( a %100/10) +( a % 10 )<< endl; }
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<sstream>
#include<string>
#include<utility>
#include<vector>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 1000000000+7
using namespace std;
typedef long long ll;

int main(){
  char b; cin >> b;
  switch(b){
    case 'A':
    cout << 'T';
    break;
    case 'T':
    cout << 'A';
    break;
    case 'C':
    cout << 'G';
    break;
    case 'G':
    cout << 'C';
    break;
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>

static const int MOD = 1000000007;
using ll = long long;
using u32 = unsigned;
using namespace std;

template<class T>
constexpr T INF = ::numeric_limits<T>::max() / 32 * 15 + 208;

template <class T>
ostream& operator<<(ostream& os, vector<T> v) {
    os << "[";
    for (int i = 0; i < v.size(); ++i) {
        if(i) os << ",";
        os << v[i];
    }
    return os << "]";
}

template <class L, class R>
ostream& operator<<(ostream& os, pair<L, R> p) {
    return os << "(" << p.first << "," << p.second << ")";
}

int main() {
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
    int ans = 0;
    for (int j = 1; j <= 100; ++j) {
        int x = -1;
        for (int i = 0; i < n; ++i) {
            if(!v[i]) {
                if(x != -1){
                    ans++;
                }
                x = -1;
            } else {
                if(x == -1) x = i;
                v[i]--;
            }
        }
        if(x != -1) ans++;
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
import numpy as np
#値の入力
N,A,B = list(map(int,input().split( )))
#data(数値)を入力したときに桁の総和とdataを返す関数。
def digits(data):
    #入力した数をAとする。
    A = data
    #Aの桁数
    dig = int(np.log10(A) + 1)
    j   = []
    for i in range(1,dig+1):
        #Aの最高位の桁数B
        B = int(A/(10**(dig - i)))
        #C
        A-= B * 10**(dig - i)
        #取り出した桁数をjに保存
        j = np.append(j,B)
    ans = np.sum(j)
    return int(ans) ,data

j = []
for i in range(1,N+1):
    if (A<= digits(i)[0] <=B):
        j = np.append(j,digits(i)[1])
print(int(np.sum(j)))


Measured memory_bytes: 12620
#pragma once
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <deque>
using namespace std;
void MaximizetheFormula() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << max(a * 10 + b + c,max( a + b * 10 + c, a + b + c * 10)) << "\n";
}
int main() {
	MaximizetheFormula();
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(int argc, const char * argv[]) {
    int i,j;

    for (i=1; i<=9; i++) {
        for (j=1; j<=9; j++) {
            printf("%dx%d=%d\n", i, j, i*j);
        }
    }

    return 0;
}

Measured memory_bytes: 924
#include <bits/stdc++.h>
#define REP(i,s,e) for(int i=(s); i<(e);i++)
#define rep(i,n) REP(i,0,n)
#define rep1(i,n) REP(i,1,n)
#define repe(i,n) for(auto &&i:n)
#define all(v) (v).begin(),(v).end()
#define decimal fixed<<setprecision(20)
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
using LL = long long;
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; }
const int INF = 1e9;
const LL LLINF = 1e16;

int main(){
    int n;
    cin >> n;
    vector<int> w(n);
    rep(i, n) cin >> w[i];

    vector<int> v(n+1, 0);
    rep(i, n) v[i+1] = v[i] + w[i];
    int mn = INF;
    rep(i, n){
        chmin(mn, abs(v[n]-v[i]-v[i]));
        //cout << v[n]-v[i+1] << v[i] << endl;
    }
    cout << mn << endl;
}

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

// syntax sugar: `for (int i = 0; i < N; ++i)`
#define rep(i, N) for (int i = 0; i < (int)(N); ++i)
#define rep2(i, startValue, N) for (int i = (int)(startValue); i < (int)(N); ++i)
// syntax sugar: `for (int i = 0; i < N; ++i)`
#define REP(type, name, beginValue, endCondValue) \
  for (type name = beginValue; name < endCondValue; ++name)
// syntax sugar: 多次元vector
#define VECTOR_DIM3(T, name, d1, d2, d3, initValue) \
    std::vector<std::vector<std::vector<T>>> name(d1, std::vector<std::vector<T>>(d2, std::vector<int>(d3, initValue)));
#define VECTOR_DIM2(T, name, d1, d2, initValue) \
    std::vector<std::vector<T>> name(d1, std::vector<T>(d2, initValue));
#define VECTOR_DIM1(T, name, d1, initValue) \
    std::vector<T> name(d1, initValue);
#define ll long long
#define ld long double

int main(){
  ll n, d;
  cin >> n >> d;
  const ll dsq = d * d;
  ll x, y, ans = 0;
  rep(i,n) {
    cin >> x >> y;
    if ((x * x + y * y) <= dsq) { ++ans; }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef pair<string , int> s_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
//#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
const int64 INF = 1LL << 58;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
template<typename T> void remove(T & vector, unsigned int index){vector.erase(vector.begin() + index);}

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

    int M, D; cin >> M >> D;
    int ans = 0;
    rep1(i,M+1) rep1(j,D+1) {
        if(j < 20) continue;
        else {
            int d10 = j / 10;
            int d1 = j % 10;
            if(d10 >= 2 and d1 >= 2 and d10 * d1 == i) ans++;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(void)
{
  char a[200002],b[200002];
  int i,count=0;
  
  fgets(a,sizeof(a),stdin);
  fgets(b,sizeof(b),stdin);
  
  for(i=0;a[i]!=0;i++)
  {
    if(a[i]!=b[i])
    {
      count++;
    }
  }
  
  printf("%d",count);
  
  return 0;
}

Measured memory_bytes: 2344
#include <iostream>
#include <vector>
#include <unordered_set>
#include <algorithm>

using namespace std;

// typedef
typedef long long ll;

// container util
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c) (c).rbegin(), (c).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(c) int((c).size())
#define EACH(i,c) for(auto (i)=(c).begin(); (i)!=(c).end(); ++(i))
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort(ALL(c))

// repetition
#define FOR(i,m,n) for(ll (i) = ((ll) m); (i) < ((ll) n); ++(i))
#define RFOR(i,m,n) for(ll (i) = ((ll) (m)-1); (i) >= ((ll) n); --(i))
#define REP(i,n) FOR(i,0,n)

// i/o
#define TFOUT(b,t,f) cout << ((b)? (t) : (f)) << endl

// constant
const double    EPS     = 1e-10;
const int       INFTY   = (1<<21);
const ll        MOD     = (ll) 1e9+7;

// clear memory
#define CLR(a) memset((a),0,sizeof(a))

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << " " << __FILE__ << endl;

int solve(int n) {
    vector<unordered_set<int>> personals;
    unordered_set<int> out;
    REP(i, n) {
        int m; cin >> m;
        unordered_set<int> person;
        REP(j, m) {
            int e;
            cin >> e;
            person.emplace(e);
        }
        personals.push_back(person);
    }
    int m; cin >> m;
    REP(j, m) {
        int e;
        cin >> e;
        out.emplace(e);
    }
    int x = 0;
    int ret = -1;
    REP(i, n) {
        bool is_subset = true;
        EACH(j, out) is_subset &= EXIST(personals[i], *j);
        if(is_subset) {
            x++;
            if(x == 1) ret = i + 1;
            else ret = -1;
        }
    }
    return ret;
}

int main() {
    while(true) {
        int n; cin >> n;
        if(n == 0) break;
        cout << solve(n) << endl;
    }
    return 0;
}


Measured memory_bytes: 3468
#include <iostream>
#include <stdio.h>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>
#include <set>
#include <math.h>
#include <utility>
#include <stack>
#include <string.h>
#include <complex>
using namespace std;
typedef pair<int,int> P;
const int INF = 1<<29;


int main(){
    while(1){
        int hand[5];
        int gcp[4] = {};
        scanf("%d",&hand[0]);
        if(hand[0]==0)break;

        gcp[hand[0]]++;
        int hand_num = 1;
        for(int i=1;i<5;i++){
            scanf("%d",&hand[i]);
            gcp[hand[i]]++;
            if(gcp[hand[i]]==1){
                hand_num++;
            }
        }
        if(hand_num==2){
            int win;
            if(gcp[1]>0 && gcp[2]>0){
                win = 1;
            }else if(gcp[2]>0 && gcp[3]>0){
                win = 2;
            }else{
                win = 3;
            }
            for(int i=0;i<5;i++){
                if(hand[i]==win){
                    printf("1\n");
                }else{
                    printf("2\n");
                }
            }
        }else{
            for(int i=0;i<5;i++)printf("3\n");
        }
    }

    return 0;
}

Measured memory_bytes: 1168
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int m;
vector<string> train;

bool input() {
	cin >> m;
	for(int i = 0; i < m; i++) {
		string tmp;
		cin >> tmp;
		train.push_back(tmp);
	}
	return true;
}

string rev_str(string s) {
	string ret;
	for(int i = 0; i < s.size(); i++) {
		ret += s[s.size() - 1 - i];
	}

	return ret;
}

int solve(int n) {
	vector<string> mem;

	for(int i = 1; i < train[n].size(); i++) {
		string strage1, strage2;
		string s[10];
		for(int j = 0; j < i; j++) {
			strage1 += train[n][j];
		}
		for(int j = i; j < train[n].size(); j++) {
			strage2 += train[n][j];
		}

		s[0] = strage1 + strage2;
		s[1] = rev_str(strage1) + strage2;
		s[2] = strage1 + rev_str(strage2);
		s[3] = strage2 + strage1;
		s[4] = rev_str(strage2) + strage1;
		s[5] = strage2 + rev_str(strage1);
		s[6] = rev_str(strage1) + rev_str(strage2);
		s[7] = rev_str(strage2) + rev_str(strage1);
		s[8] = rev_str(s[0]);
		s[9] = rev_str(s[3]);

		for(int j = 0; j < 10; j++) {
			bool flag = true;
			for(int k = 0; k < mem.size(); k++) {
				if(mem[k] == s[j]) {
					flag = false;
					break;
				}
			}
			if(flag) {
				mem.push_back(s[j]);
			}
		}
	}
	return mem.size();
}

int main() {
	input();
	for(int i = 0; i < m; i++) {
		cout << solve(i) << endl;
	}
	return 0;
}

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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}
#if loc||local
void dump(){cerr<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

ll N,a,b,c,d;
map<ll,ll> memo;

ll dfs(ll n){
  if(n==0)return memo[0]=0;
  if(n==1)return memo[1]=d;
  if(memo.count(n))return memo[n];
  ll d2,u2;
  d2 = n+2-n%2;
  u2 = n+n%2;
  ll d3,u3;
  d3 = n+3-n%3;
  u3 = n+n%3;
  ll d5,u5;
  d5 = n+5-n%5;
  u5 = n+n%5;
  ll res = INF;
  if(n<res/d)res=n*d;
  if(n%2==0)chmin(res,dfs(n/2)+a);
  else{
    chmin(res,dfs(d2/2)+abs(n-d2)*d+a);
    chmin(res,dfs(u2/2)+abs(n-u2)*d+a);
  }
  if(n%3==0)chmin(res,dfs(n/3)+b);
  else{
    chmin(res,dfs(d3/3)+abs(n-d3)*d+b);
    chmin(res,dfs(u3/3)+abs(n-u3)*d+b);
  }
  if(n%5==0)chmin(res,dfs(n/5)+c);
  else{
    chmin(res,dfs(d5/5)+abs(n-d5)*d+c);
    chmin(res,dfs(u5/5)+abs(n-u5)*d+c);
  }
  return memo[n] = res;
}

void solve(){
  cin>>N>>a>>b>>c>>d;
  memo.clear();
  dfs(N);
  cout<<(memo[N])<<endl;
  //for(auto [k,v]:memo)cout<<k<<","<<v<<endl;
}

signed main(){

  int t;
  cin>>t;
  while(t--)solve();

}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

int k;

ll ans;

ll solve() {
  deque<pair<int, ll>> deq;
  set<int> visited;

  deq.push_front(make_pair(1, 0LL));

  ll ret = 0;

  while (!deq.empty()) {
    auto cur = deq.front();
    deq.pop_front();

    int node = cur.first;
    ll cost = cur.second;

    visited.insert(node);

    if (node == 0) {
      ret = cost;
      break;
    }

    int next_p1 = (node + 1) % k;
    if (visited.find(next_p1) == visited.end()) {
      deq.push_back(make_pair(next_p1, cost + 1LL));
    }

    int next_t10 = (node * 10) % k;
    if (visited.find(next_t10) == visited.end()) {
      deq.push_front(make_pair(next_t10, cost));
    }
  }

  return ret + 1LL;
}

int main(void) {
  // Here your code !
  scanf("%d", &k);

  ans = solve();

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

  return 0;
}


Measured memory_bytes: 5760
n,k = map(int,input().split())
memo = list(map(int,input().split()))

d = []
for i in range(10):
    if not(i in memo):
        d.append(i)

N = n
flug = False
while(1):
    n_st = list(str(n))
    n_st = list(map(int,n_st))

    for i in range(len(n_st)):
        if not(n_st[i] in d):
            break
        if i == len(n_st)-1:
            flug = True

    if(flug):
        break
    n+=1

print(n)



 




Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <misc/C++/Debug.cpp>
#else
#define dump(...) ((void)0)
#endif

#define gcd __gcd

using namespace std;
template <class T> constexpr T lcm(T m, T n){return m/gcd(m,n)*n;}

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}

struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
  }
}init;


int main(){
  int a,b;
  while(cin >> a >> b){
    if(a < 10 and b < 10){
      cout << a*b << endl;
    }else{
      cout << -1 << endl;
    }


    
  }


  return 0;
}


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

int main() {
    int H, W, D;
    cin >> H >> W >> D;
    int N = H * W;
    using P = pair<int, int>;
    vector<P> A(N + 1);
    rep(i, 0, H) rep(j, 0, W) {
        int a; cin >> a;
        A[a] = {i + 1, j + 1};
    }
    function<int(P, P)> calc = [&](P a, P b) {
        int y = abs(a.first - b.first);
        int x = abs(a.second - b.second);
        return y + x;
    };
    vector<int> sum(N + 1);
    for(int i = 0; i + D <= N; i++) {
        sum[i + D] = sum[i] + calc(A[i + D], A[i]);
    }
    int Q; cin >> Q;
    while(Q--) {
        int l, r;
        cin >> l >> r;
        cout << sum[r] - sum[l] << '\n';
    }
    return 0;
}


Measured memory_bytes: 2176
S = input()
T = input()
maxMatch = 0
for x in range(len(S) - len(T) + 1):
    count = 0
    for y in range(len(T)):
        if S[x + y] == T[y]:
            count += 1
    if count >= maxMatch:
        maxMatch = count
print(len(T) - maxMatch)


Measured memory_bytes: 67400
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;

int main(){
    string s;
    cin >> s;
    int seq=0, cnt=0;
    rep(i, 3){
        if(s[i]=='R'){
            seq++;
        }else{
            seq = 0;
        }
        cnt = max(cnt, seq);
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3608
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef vector<int> vi;

int main(void) {
	int N;
	cin >> N;

	vector<int>b(N + 5);

	for (int i = 2; i <= N; i++) {
		int a;
		cin >> a;
		b[a]++;
	}

	for (int i = 1; i <= N; i++) {
		cout << b[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 4044
/**
 *   Praveen Fulera    
**/


// #pragma GCC optimize("O3", "unroll-loops")
// #pragma GCC target("avx2")

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

typedef long long int ll;

#define endl '\n'
#define int long long
#define pb push_back
#define pii pair <int, int>
#define ff first
#define ss second
#define point pair <double, double>
#define watch(x) cerr << "\n" << (#x) << " is " << (x) << endl

void __print(int x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "\n[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

const int mod = 1e9 + 7;
//const int mod = 998244353;

void solve(){
    int n; cin >> n;
    map <string, int> vote;
    int cnt = 0;
    for(int i = 1; i <= n; i++){
        string s; cin >> s;
        vote[s]++;
        cnt = max(cnt, vote[s]);
    }
    for(auto i : vote){
        if(i.ss == cnt){
            cout << i.ff << '\n';
        }
    }
}

signed main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
        clock_t t1 = clock();
  int t = 1; //cin >> t;
  while(t--){      
     solve();
  }
        clock_t t2 = clock();
  //cout << "Time-Taken: " << ((t2 - t1) / (double)CLOCKS_PER_SEC) << endl;      
}


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

public class PriorityQueue<T> where T : IComparable
{
	private IComparer<T> _comparer = null;
	private int _type = 0;
	private T[] _heap;
	private int _sz = 0;
	private int _count = 0;
	public PriorityQueue(int maxSize, IComparer<T> comparer)
	{
		_heap = new T[maxSize];
		_comparer = comparer;
	}
	public PriorityQueue(int maxSize, int type = 0)
	{
		_heap = new T[maxSize];
		_type = type;
	}
	private int Compare(T x, T y)
	{
		if (_comparer != null) return _comparer.Compare(x, y);
		return _type == 0 ? x.CompareTo(y) : y.CompareTo(x);
	}
	public void Push(T x)
	{
		_count++;
		var i = _sz++;
		while (i > 0)
		{
			var p = (i - 1) / 2;
			if (Compare(_heap[p], x) <= 0) break;
			_heap[i] = _heap[p];
			i = p;
		}
		_heap[i] = x;
	}
	public T Pop()
	{
		_count--;
		T ret = _heap[0];
		T x = _heap[--_sz];
		int i = 0;
		while (i * 2 + 1 < _sz)
		{
			int a = i * 2 + 1;
			int b = i * 2 + 2;
			if (b < _sz && Compare(_heap[b], _heap[a]) < 0) a = b;
			if (Compare(_heap[a], x) >= 0) break;
			_heap[i] = _heap[a];
			i = a;
		}
		_heap[i] = x;
		return ret;
	}
	public int Count() => _count;
	public T Peek() => _heap[0];
	public bool Contains(T x)
	{
		for (int i = 0; i < _sz; i++) if (x.Equals(_heap[i])) return true;
		return false;
	}
	public void Clear()
	{
		while (this.Count() > 0) this.Pop();
	}
	public IEnumerator<T> GetEnumerator()
	{
		var ret = new List<T>();
		while (this.Count() > 0)
		{
			ret.Add(this.Pop());
		}
		foreach (var r in ret)
		{
			this.Push(r);
			yield return r;
		}
	}
	public T[] ToArray()
	{
		T[] array = new T[_sz];
		int i = 0;
		foreach (var r in this)
		{
			array[i++] = r;
		}
		return array;
	}
}

public class P
{
	public int b { get; set; }
	public int c { get; set; }
}

public class Hello
{
	public static void Main()
	{
		string[] line = Console.ReadLine().Trim().Split(' ');
		var n = int.Parse(line[0]);
		var m = int.Parse(line[1]);
		var pq = new PriorityQueue<int>(n + 10,1);
		line = Console.ReadLine().Trim().Split(' ');
		for (int i = 0; i < n; i++) pq.Push(int.Parse(line[i]));
		var ps = new P[m];
		for (int i = 0; i < m; i++)
		{
			line = Console.ReadLine().Trim().Split(' ');
			var b = int.Parse(line[0]);
			var c = int.Parse(line[1]);
			ps[i] = new P { b = b, c = c };
		}
		var count = 0;
		var ans = 0L;
		foreach (var x in ps.OrderByDescending(y => y.c))
		{
			for (int i = 0; i < x.b; i++)
			{
				pq.Push(x.c);
				ans += pq.Pop();
				count++;
				if (count == n) { Console.WriteLine(ans); goto exit; }
			}
		}
		while (true)
		{
			ans += pq.Pop();
			count++;
			if (count == n) { Console.WriteLine(ans); goto exit; }
		}
	exit:;
	}
}

Measured memory_bytes: 30780
#include <stdio.h>

int main(void) {
	int n,d,x,a[101],sum=0;
	scanf("%d%d%d",&n,&d,&x);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		sum+=(d-1)/a[i]+1;
	}
	printf("%d",sum+x);
}


Measured memory_bytes: 128
prime = [True]*1111111;
prime[0] = False
prime[1] = False
i = 0
while i < 1111111:
	if prime[i]:
		j = 2*i
		while j < 1111111:
			prime[j] = False
			j += i
	i += 1
while True:
	try:
		n = int(raw_input())
		ans = 0
		for i in range(n+1):
			if(prime[i]):
				ans += 1
		print ans
	except EOFError:
		break

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

using namespace std;
typedef long long LL;
typedef pair<int,int> pii;

const int MAXN = 2e5 + 1;
const int MOD = 1e9 + 7;
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second 
#define FAIL0 {printf("0\n"); return 0;}
#define FAIL1 {printf("-1\n"); return 0;}
#define FAILNO {printf("NO\n"); return 0;}

int N;

int main(int argc, char **argv) {
#ifdef OJ
    freopen("input.txt", "rt", stdin);
    //freopen("output.txt", "wt", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    //scanf("%d", &N);

    int a,b,k;
    scanf("%d %d %d", &a, &b, &k);

    int c = 0;
    for (int i = min(a,b); i >= 1; i--) {
        if (a%i == 0 && b%i == 0) {
            c++;
            if (c == k) {
                printf("%d\n", i);
                return 0;
            }
        }
    }

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


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int fivehun_cnt = 0;
		int five_cnt = 0;
		fivehun_cnt = x / 500;
		five_cnt = (x - fivehun_cnt * 500) / 5;
		
		System.out.println((long)fivehun_cnt * 1000 + (long)five_cnt * 5);
	}
}


Measured memory_bytes: 23508
//#pragma once
#include <stdio.h>
#include <string>
#include <iostream>
#include <queue>
#include <algorithm>
#include <sstream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#include <numeric>
#include<bitset>

using namespace std;
#define modd 1000000007
#define moda 1000003


typedef pair<long long, long long> pl;



#define ll long long




/*
class UnionFind {
public:
	vector <ll> par; 
	vector <ll> siz;
	vector <ll> gr;

	// Constructor
	UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) ,gr(sz_){
		for (ll i = 0; i < sz_; ++i) par[i] = i; 
	}
	void init(ll sz_) {
		par.resize(sz_);
		siz.assign(sz_, 1LL);  // resize だとなぜか初期化されなかった
		for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
	}

	// Member Function
	// Find
	ll root(ll x) { // 根の検索
		while (par[x] != x) {
			x = par[x] = par[par[x]]; // x の親の親を x の親とする
		}
		return x;
	}

	// Union(Unite, Merge)
	bool merge(ll x, ll y) {
		x = root(x);
		y = root(y);
		if (x == y) return false;

		// merge technique（データ構造をマージするテク．小を大にくっつける）
		if (siz[x] < siz[y]) swap(x, y);
		siz[x] += siz[y];
		par[y] = x;
		return true;
	}



	bool issame(ll x, ll y) { // 連結判定
		return root(x) == root(y);
	}

	ll size(ll x) { // 素集合のサイズ
		return siz[root(x)];
	}


};*/


long long N, M, K, a, b, c, d,e, H, W, X;
long long A[200005] = {};
long long B[200005] = {};
long long C[200005] = {};
bool f, ff,fff;
string S;
set <long long>sll;
pl bufpl;
vector <long long>vl[100005];
vector <pl>vpl[2];
vector <string> vs;
set<ll> llset;

struct ST
{
	long long Kati;
	int bangou;

	bool operator<(const ST& another) const
	{
		return Kati < another.Kati;//比較
	};

};



vector <ST> vst;
ST st[200005];
ST bufst;

bitset<5000> bits;

int main() {

	cin >> a>>b>>c;
	
	d = 1000000000000000000;
	if (d > a * b) {
		d = a * b;
	}
	if (d > b * c) {
		d = c * b;
	}
	if (d > a * c) {
		d = a * c;
	}

	if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0) {
		d = 0;
	}

	cout << d << endl;

	return 0;

}


Measured memory_bytes: 4352
using System;
 
class Program{
	public static void Main(string[] args){
		string s;
		while((s = Console.ReadLine()) != null){
			string[] n = s.Split(' ');
			int sum = int.Parse(n[0]) + int.Parse(n[1]);
			Console.WriteLine(sum.ToString().Length);
		}
	}
}

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

int main() {
#ifdef HOME
	freopen("atc.in", "r", stdin);
	freopen("atc.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	vector<int> v;
	int n, ant(0);

	cin >> n;
	v.resize(2 * n);	
	for (auto &i: v)
		cin >> i;

	sort(begin(v), end(v));
	for (int i = 0; i < n; ++i)
		ant+= v[2 * i];

	cout << ant << endl;

	return 0; }


Measured memory_bytes: 256
# -*- coding: utf-8 -*-


def main():
    from collections import Counter

    n = int(input())
    c = Counter()
    ans = 0

    for i in range(n):
        si = sorted(input())
        c[''.join(map(str, si))] += 1

    for idx, ci in c.items():
        ans += ci * (ci - 1) // 2

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 18232
extern crate core;

use std::io::{self, Read};

#[macro_use]
mod parser {
    macro_rules! input {
    ($s:expr=>$($t:tt)*) => {
        let mut lines=$s.split("\n");
        $(
            line_parse!(lines,$t);
        )*
    };
    }

    macro_rules! line_parse {
    ($lines:expr,($($name:ident:$t:tt)*)) => {
        let mut line=$lines.next().unwrap().split_whitespace();
        $(value_def!(line,$name,$t);)*
    };

    //複数行
    ($lines:expr,{$n:expr;$name:ident:$t:tt}) => {
        values_def!($lines,$n,$name,$t);
    };
    }

    macro_rules! value_def {
    ($line:expr,$name:ident,$t:tt) => {
        let $name=value!($line,$t);
    };
    }

    macro_rules! values_def {
    ($lines:expr,$n:expr,$name:ident,$t:tt) => {
        let $name={
        let mut vec=Vec::new();
        for i in 0..$n{
            let mut next=$lines.next().unwrap().split_whitespace();
            vec.push(value!(next,$t));
        }
        vec
        };
    };
    }

    macro_rules! value {
    //配列
    ($line:expr,[$t:tt]) => {
        $line.map(|x|{
        let mut iter=::std::iter::once(x);
        value!(iter,$t)
        }).collect::<Vec<_>>()
    };
    //タプル
    ($line:expr,($($t:tt),*)) => {
        ($(value!($line,$t),)*)
    };
    //文字列
    ($line:expr,#) => {
        $line.next().unwrap()
    };
    //単一値
    ($line:expr,$t:ty) => {
        $line.next().unwrap().parse::<$t>().unwrap()
    };
    }
}

fn main() {
    let mut input = String::new();
    io::stdin().read_to_string(&mut input).unwrap();
    let output = solve(input.trim().to_string());
    println!("{}", output);
}

fn solve(input: String) -> String {
    input!(input=>(h:usize w:usize){h;list:#});
    let list = list.into_iter()
        .map(|x| x.chars().map(|x| x == '#').collect::<Vec<_>>())
        .collect::<Vec<_>>();
    for y in 0..h {
        for x in 0..w {
            if list[y][x] {
                let t = y != 0 && list[y - 1][x];
                let b = y != h - 1 && list[y + 1][x];
                let l = x != 0 && list[y][x - 1];
                let r = x != w - 1 && list[y][x + 1];
                if !(t || b || l || r) {
                    return "No".to_string();
                }
            }
        }
    }
    "Yes".to_string()
}

macro_rules! tests {
    ($($name:ident: $input:expr=>$output:expr,)*) => {
        mod tests {
            $(
                #[test]
                fn $name() {
                    assert_eq!($output.trim().to_string(),super::solve($input.trim().to_string()));
                }
            )*
        }
    }
}

tests! {
    test1: "3 3\n.#.\n###\n.#." => "Yes",
    test2: "5 5\n#.#.#\n.#.#.\n#.#.#\n.#.#.\n#.#.#" => "No",
    test3: "11 11\n...#####...\n.##.....##.\n#..##.##..#\n#..##.##..#\n#.........#\n#...###...#\n.#########.\n.#.#.#.#.#.\n##.#.#.#.##\n..##.#.##..\n.##..#..##." => "Yes",
}


Measured memory_bytes: 4352
#include<iostream>
#include<cmath>
#include<string>
#include<cstdlib>
#include<stdio.h>
#include<cctype>
#include<algorithm>
#include<string.h>

#include<iomanip>
#define PI 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342117067982148
using namespace std;
#define A 0.33333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333333


int main()
{
	string str;
		
			while(getline(cin,str)){
				for(unsigned int i=0;i<str.size();i++)//??????????°??????¢?????§?????????????????§?????¢????°????
					{
						if(islower(str[i]))//??????????????\???????????¢???????±?????????\????????¬????????¨????????\??????ascll????????¨???
						str[i]=toupper(str[i]);
						else 
							if(isupper(str[i]))
						str[i]=tolower(str[i]);//???????°±???????????????????°±???????????\?????????????????§??????????????????????????????????????????????°±????????????????????°????????????????????????????????????
						cout<<str[i];

						
				
				
				
				
				
				
				}
				cout<<endl;
			}


		
		
		
		
}

Measured memory_bytes: 3160