akhauriyash/Code-Regression huggingface dataset:
// #define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES	// M_PI=3.1415...
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>	// 20桁出力 cout << setprecision(20) << double;
#include <queue>
#include <bitset>	// bitset<8> bs1(131uL); // 10000011 bs1[0]は1 01stringからビット集合生成可
#include <numeric>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<LL> VL;
typedef vector<pair<int, int> > VPII;
typedef vector<string> VS;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<int, int> P;
typedef pair<int, pair<P, P> > PP;

#define INF 999999999999999997;
#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define FORL(i,a,b) for(LL i=(a);i<(b);i++)
#define FOR_REV(i,a,b) for(int i=(a);i>=(b);i--)
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
#define FOR_ITR(d) for(auto itr=d.begin(),d_end=d.end();itr!=d_end;++itr)	// C++11
#define O(s) cout<<s<<endl;

#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}

template<class T>T IN() { T d; cin >> d; return d; }

LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; } // 最大公約数（Greatest Common Divisor）
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; } // 最小公倍数（Least Common Multiple）
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); } // うるう年判定

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };
int dxx[8] = { 0,1,1,1,0,-1,-1,-1 };
int dyy[8] = { 1,1,0,-1,-1,-1,0,1 };

// vector注意
// vec[i][j]の形に入力を入れるとき、vecは初期化してある必要がある.

// ------------------- include, typedef, define END. -------------------

int main() {
	FAST_IO;
	bool dbgF = true; // for D_OUT(str, value)  ... cout<< str <<" : "<< value <<endl;

	string s;
	cin >> s;
	int ans = 0;
	FOR(i, 0, s.length()) {
		if (s[i] == '1')ans++;
	}
	O(ans)
	return 0;
}

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

int main(){
    int N;
    cin >> N;
    ll ans = 1;
    vector<ll> a(N);
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
        if(a[i]==0)ans=0;
    }
    for (int i = 0; i < N; i++)
    {
        if(ans==0)break;
        if(a[i]*ans>ll(1e18)||double(a[i])>double(ll(1e18)/ans)){
            ans=-1;
            break;
        }
        ans *= a[i];
    }    
    cout << ans << endl;
}

Measured memory_bytes: 3928
#include<cstdio>
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<algorithm>
#include<cstring>
#define maxn 15
using namespace std;

int n;
int a[maxn],tmp[maxn];
int ans;

inline int in()
{
	int x=0,f=1;char ch=getchar();
	while(ch<'0' || ch>'9')
	{if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0' && ch<='9')
	{x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

void judge()
{
	int tot=1;
	for(int i=1;i<=n;i++)
		tot*=tmp[i];
	if(tot%2==0)
		ans++;
	return ;
}

void dfs(int now)
{
	if(now==n+1)
	{
		judge();
		return ;
	}
	tmp[now]=a[now]-1;
	dfs(now+1);
	tmp[now]=a[now];
	dfs(now+1);
	tmp[now]=a[now]+1;
	dfs(now+1);
}

int main()
{
	n=in();
	for(int i=1;i<=n;i++)
		a[i]=in();
	dfs(1);
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python

from collections import deque
import itertools as it
import sys
import math

sys.setrecursionlimit(1000000)

INF = 10 ** 18
MOD = 10 ** 9 + 7

H, W = map(int, raw_input().split())
a, b = map(int, raw_input().split())

print H * W - (H / a * a) * (W / b * b)


Measured memory_bytes: 5020
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
int main(void){
	int H,W,h,w;
	cin>>H>>W>>h>>w;
	cout<<(H-h)*(W-w)<<endl;
}


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

int main() {
	int n,i,j,k,cur;
	cin >> n;
	k=1;
	while(true){
		if(k*(k+1)>2*n){
			cout << "No"; return 0;
		}else if(k*(k+1)==2*n){
			break;
		}
		k++;
	}
	cout << "Yes" << endl << k+1 << endl;
	vector<vector<int>> a(k+1, vector<int> (k));
	cur=1;
	for(i=0; i<k; i++){
		for(j=i; j<k; j++){
			a[i][j]=cur;
			cur++;
		}
	}
	cur=1;
	for(i=0; i<k; i++){
		for(j=i+1; j<k+1; j++){
			a[j][i]=cur;
			cur++;
		}
	}
	
	for(i=0; i<k+1; i++){
		cout << k;
		for(j=0; j<k; j++){
			cout << ' ' << a[i][j];
		}
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 2176
#include<iostream>
#include<vector>
 using namespace std;
 const long long mod=1e9+7;

int main(){
int N,M;
cin>>N>>M;
vector<int>oks(N+1,true);
 for(int i=0;i<M;++i){
 int a;cin>>a;
 oks[a]=false;
 }

 vector<long long int>dp(N+1);
 dp[0]=1;
 for(int now=0;now<N;++now){
 for(int next=now+1;next<=min(N,now+2);++next){
 if(oks[next]){
 dp[next]+=dp[now];
 dp[next]%=mod;
 }
 }
 }

 cout<<dp[N]<<endl;
 return 0;
}


Measured memory_bytes: 1408
#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


int main() {
  int K, X;

  cin >> K >> X;

  bool first = true;
  for (int i=X-K+1; i<X+K; i++) {
    if (!first) cout << " ";
    cout << i;
    first = false;
  }

  cout << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long INF = (1LL << 32);
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll>> vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl

/*--------------------template--------------------*/


int main() {
    cin >> n;
    vi v(n);
    set<ll> st;
    REP(i,n) {
        cin >> v[i];
        st.insert(v[i]);
    }
    cout << st.size() << endl;
    
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<utility>
using namespace std;

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

ll gcd(ll x, ll y) {
    if (y == 0) return x;
    else return gcd(y, x%y);
}

vector<pair<ll, int>> factorize(ll n) {
    vector<pair<ll, int>> res;
    for (ll i = 2; i*i <= n; ++i) {
        if (n%i) continue;
        res.emplace_back(i, 0);
        while(n%i ==0) {
            n /= i;
            res.back().second++;
        }
    }
    if (n != 1) res.emplace_back(n, 1);
    return res;
    
}

int main() {
    ll a, b;
    cin >> a >> b;
    ll g = gcd(a, b);
    auto f = factorize(g);
    int ans = f.size() + 1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
int main(void){
    // Your code here!
    char s[1000], t[1000], a;
    int x, i=0, j;
    
    scanf("%s%s",s,t);
    
    x=strlen(s);
    while(i!=x){
        a=s[x-1];
        for(j=0;j<x;j++){
            s[x-1-j]=s[x-2-j];
        }
        s[0]=a;
        if(strcmp(s,t)==0){
            printf("Yes\n");
            return 0;
        }
        i++;
    }
    printf("No\n");
    return 0;
}

Measured memory_bytes: 128
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		// 整数の入力
		//int a = int.Parse(Console.ReadLine());
		// スペース区切りの整数の入力
		string[] NM = Console.ReadLine().Split(' ');
		int N = int.Parse(NM[0]);
		int M = int.Parse(NM[1]);

		List<int> bingo = new List<int>(){-1,-1,-1};

		for(int i=0; i<M; i++)
		{
			// 条件を満たすかチェックする
			string[] sc = Console.ReadLine().Split(' ');
			int s = int.Parse(sc[0]);
			int c = int.Parse(sc[1]);

			int a = s-1 + (3-N);

			if(a < 0 || a > 2 || (bingo[a] != -1 && bingo[a] != c))
			{
				Console.WriteLine("-1");
				return;
			}
			else
			  {
					bingo[a] = c;
				}
		}

//Console.WriteLine("aaa " + bingo[0] + ";" + bingo[1] + "; " + bingo[2]);
		// 条件を満たす整数を求める
		if(N==1)
		{
			if(bingo[0] > 0 || bingo[1] > 0)
			{
				Console.WriteLine("-1");
			}
			else
			{
				if(bingo[2] == -1)
				  bingo[2] = 0;

				Console.WriteLine(bingo[2]);
			}
		}
		else if(N==2)
		{
			if(bingo[0] > 0 || bingo[1] == 0)
			{
				Console.WriteLine("-1");
			}
			else
			{
				if(bingo[1] == -1)
				  bingo[1] = 1;
				if(bingo[2] == -1)
				  bingo[2] = 0;

				Console.WriteLine(bingo[1].ToString() + bingo[2].ToString());
			}
		}
		else if(N==3)
		{
			if(bingo[0] == 0)
			{
				Console.WriteLine("-1");
			}
			else
			{
				if(bingo[0] == -1)
				  bingo[0] = 1;
				if(bingo[1] == -1)
				  bingo[1] = 0;
				if(bingo[2] == -1)
				  bingo[2] = 0;

				Console.WriteLine(bingo[0].ToString() + bingo[1].ToString() + bingo[2].ToString());

			}
		}

		// 文字列の入力
		//string s = Console.ReadLine();
		//出力
		//Console.WriteLine((a+b+c) + " " + s);
	}
}


Measured memory_bytes: 13140
#include <iostream>
#include <stdlib.h>
#include <math.h>

using namespace std;

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

    for(int i = a;i <= b;++i){
        if(c % i == 0){
            num++;
        }
    }
    cout << num << endl;

    return 0;
}



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

#define debug(x) cerr << x << " = "(x) << endl;
#define ll long long
#define rep(i,x,y) for(int i=x;i<y;i++)
#define rel(i,x,y) for(int i=x-1;i>=y;i--)
#define all(x) x.begin(),x.end()

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    int n; cin >>n;
    deque<int> dq;
    bool rev=false;
    rep(i,0,n){
        int tmp;
        cin >> tmp;
        if(rev) dq.push_front(tmp);
        else dq.push_back(tmp);
        rev ^= 1;
    }
    if(rev){
        rel(i,dq.size(),0){
            cout << dq[i] << " ";
        }
    }else{
        rep(i,0,dq.size()){
            cout << dq[i] << " ";
        }
    }
    cout << endl;
}

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

int N;
int64_t K;
std::vector<int> A;

void calcAns(int, int64_t);

int main()
{
	scanf("%d%lld", &N, &K);
	K *= N;
	A.resize(N);
	for (int& e: A)
	{
		scanf("%d", &e);
		e--;
	}
	std::vector<int> to(N), dp_table(200'000);
	for (int i{N - 1}; i >= 0; i--)
		dp_table[A[i]] = N + i;
	for (int i{N - 1}; i >= 0; i--)
	{
		to[i] = dp_table[A[i]] + 1;
		dp_table[A[i]] = i;
	}
	std::vector<int> order(N, -1);
	int begin, loop_size, now_i{};
	for (int i{}; i < N; i++)
	{
		order[now_i] = i;
		int next{to[now_i] % N};
		if (order[next] >= 0)
		{
			begin = next;
			loop_size = i + 1 - order[next];
			break;
		}
		now_i = next;
	}
	// ループに入る前の挙動
	now_i = 0;
	int64_t now_dist{};
	while (now_i != begin)
	{
		int64_t delta{to[now_i] - now_i};
		if (now_dist + delta > K)
		{
			calcAns(now_i, K - now_dist);
			return 0;
		}
		now_dist += delta;
		now_i = to[now_i] % N;
	}
	// 今now_dist <= K
	// ループの長さ
	int64_t loop_length{to[begin] - begin};
	now_i = to[begin] % N;
	while (now_i != begin)
	{
		int64_t delta{to[now_i] - now_i};
		loop_length += delta;
		now_i = (now_i + delta) % N;
	}
	// K == (beginからの距離)
	K = (K - now_dist) % loop_length;
	now_i = begin;
	now_dist = 0;
	while (true)
	{
		int64_t delta{to[now_i] - now_i};
		if (now_dist + delta > K)
		{
			calcAns(now_i, K - now_dist);
			break;
		}
		now_dist += delta;
		now_i = to[now_i] % N;
	}

	return 0;
}

void calcAns(int begin, int64_t dist)
{
	std::vector<int> count(200'000), st;
	for (int64_t i{}; i < dist; i++)
	{
		int num{A[(begin + i) % N]};
		if (count[num] == 0)
		{
			st.push_back(num);
			count[num]++;
		}
		else
			while (count[num] > 0)
			{
				count[st.back()]--;
				st.pop_back();
			}
	}
	for (int i{}; i < (int)st.size(); i++)
	{
		printf("%d", st[i] + 1);
		if (i + 1 != (int)st.size()) putchar(' ');
	}
	putchar('\n');
	return;
}

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

bool is_prime(int n)
{

    if(n==2)
        return true;
    if(n%2==0)
        return false;
    for(int i=3;i<=sqrt(n);i+=2)
    {
        if(n%i==0)
            return false;
    }
    return true;
}
#define ll long long
#define loop(n) for(int i=0;i<n;i++)

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



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define all(x) (x).begin(),(x).end()
using ll = long long;
using namespace std;

int main() {
  int n;
  string s;
  cin>>n>>s;
  /////////
  
  int ans=0;
  
  rep(i,n){
    map<char,int> x,y;
    int cnt=0;
    for(int j=0;j<=i;j++){
    x[s[j]]++;
    }
    for(int j=i+1;j<n;j++){
      y[s[j]]++;
    }
    for(auto v:x){
     if(y.count(v.first)){
      cnt++; 
     }
    }
    //cout<<cnt<<endl;
    ans=max(ans,cnt);
    
  }
  cout<<ans<<endl;
}

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

int main() {
  string b;
  cin >> b;
  string ans;
  switch (b[0]) {
    case 'A':
      ans = "T";
      break;
    case 'C':
      ans = "G";
      break;
    case 'G':
      ans = "C";
      break;
    case 'T':
      ans = "A";
      break;
  }

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


Measured memory_bytes: 3572
N, M = gets.split.map(&:to_i)

roads = Array.new(N+1, 0)
M.times do |i|
    a, b = gets.split.map(&:to_i)
    roads[a] += 1
    roads[b] += 1
end

(1..N).each do |i|
    puts roads[i]
end

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

int main()
{
    int l,r,n,i;
    cin>>l>>r>>n;
    int cnt=0;
    for(i=l;i<=r;i++)
    {
        if(i%n==0)
            cnt++;
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  ll a,b;
  cin >> a >> b;
  if(a == 1)a = 100;
  if(b == 1)b = 100;
  if(a == b)cout << "Draw" << endl;
  else if(a > b)cout << "Alice" << endl;
  else cout << "Bob" << endl;
}

Measured memory_bytes: 3628
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>

#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

#include <stdexcept>

using namespace std;

// type alias
using ll = long long;
using ull = unsigned long long;

//conversion
//------------------------------------------
inline int toint(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class t> inline string tostring(t x) { ostringstream sout; sout << x; return sout.str(); }

//debug
#define DUMP(x)  cerr << #x << " = " << (x) << endl
#define DEBUG(x) cerr << #x << " = " << (x) << " (l" << __line__ << ")" << " " << __file__ << endl

inline ll floor(ll a, ull b)
{
	ll llb = b;
	if (a >= 0)
	{
		return a / llb;
	}
	else
	{
		return - ( (-a + llb - 1) / llb);
	}
}

inline ll ceil(ll a, ull b)
{
	ll llb = b;
	if (a >= 0)
	{
		return (a + llb - 1) / llb;
	}
	else
	{
		return - (-a / llb);
	}
}

inline ll getLowestOneBit(ll a)
{
	return a & (-a);
}

inline ll getHighestOneBit(ll a)
{
	while ((a & (a - 1)) != 0)
	{
		a = a & (a - 1);
	}
	return a;
}

inline bool isPower2(ull a)
{
	if (a == 0)
	{
		return false;
	}
	return !(a & (a - 1));
}

inline ll getSpecifiedBit(ll a, unsigned bit)
{
	return (a & (1LL << bit)) >> bit;
}

// computational complexity: o(log(max(a, b))) 
inline ull getGcd(ull a, ull b)
{
	if (b == 0)
	{
		return a;
	}
	return getGcd(b, a % b);
}

template<class Integer>
inline Integer getPower(Integer base, ull exponential)
{
	Integer result = 1;
	while (exponential >= 1)
	{
		if (exponential & 1)
		{
			result = result * base;
		}
		base = base * base;
		exponential >>= 1;
	}

	return result;
}

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

	ll N;
	cin >> N;

	map<ll, ll> S;
	ll s;
	for (ll i = 0; i < 1LL << N; ++i)
	{
		cin >> s;
		if (S.count(s) == 0)
		{
			S[s] = 0;
		}
		++S[s];
	}

	bool can_make = true;

	ll limit = 1;
	ll cum_limit = limit;

	auto cum_iter = S.end();
	ll cum_count = 0;
	for (ll i = 0; i < N; ++i)
	{
		if (cum_iter-- == S.begin())
		{
			can_make = false;
			break;
		}
		cum_count += cum_iter->second;
		if (cum_count > cum_limit)
		{
			can_make = false;
			break;
		}
		limit = limit * (N - i) / (i + 1);
		cum_limit += limit;
	}

	limit = (1LL << N) >> 1;
	cum_limit = limit;

	cum_iter = S.begin();
	cum_count = 0;
	for (ll i = 0; i < N; ++i)
	{
		if (cum_iter == S.end())
		{
			can_make = false;
			break;
		}
		cum_count += cum_iter->second;
		if (cum_count > cum_limit)
		{
			can_make = false;
			break;
		}

		++cum_iter;
		limit >>= 1;
		cum_limit += limit;
	}

	cout << (can_make ? "Yes" : "No") << endl;

	return 0;
}


Measured memory_bytes: 16640
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;

using Graph = vector<vector<int>>;
Graph G;

int cost[200005];

void dfs(int v, int p){
    for(auto nv: G[v]){
        if(nv == p) continue;
        cost[nv] += cost[v];
        dfs(nv, v);
    }
}

int main(){
    int n, q;
    cin >> n >> q;
    G.assign(n+1, vector<int>());
    rep(i, n-1){
        int a, b;
        cin >> a >> b;
        G[a].push_back(b);
        G[b].push_back(a);
    }

    rep(i, q){
        int p, x;
        cin >> p >> x;
        cost[p] += x;
    }

    dfs(1, -1);

    for(int i=1; i<=n; i++) cout << cost[i] << " ";
    cout << endl;
}

Measured memory_bytes: 23424
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  string S,T;
  cin >> S >> T;
  int N = S.size();
  rep(i,N)
  {
    if(S==T)
    {
      cout << "Yes" << endl;
      return 0;
    }
    else
    {
      string S2 = S;
      S[0] = S[N-1];
      for(int i=1;i<N;i++)
      {
        S[i] = S2[i-1];
      }
    }
    
  }
  cout << "No" << endl;
  return 0;
}


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

int main(){
    string s;
    cin >> s;
    int ans = 0;
    for (int i = 0; i < 4; i++){
        if (s[i] == '+'){
            ans++;
        }else{
            ans--;
        }
    }
    cout << ans << endl;
}

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

using ll = long long int;

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

const int MAX_N = (int)(1e5 + 5);

int n;
ll m;

vector<pair<ll, ll>> pairs;

ll ans = 0;

int main(void) {
  // Here your code !

  scanf("%d %d", &n, &m);

  for (int i = 0; i < n; ++i) {
    ll a, b;
    scanf("%lld %lld", &a, &b);
    pairs.push_back(make_pair(a, b));
  }

  sort(pairs.begin(), pairs.end());

  ll bought = 0;

  for (auto e: pairs) {
    if (bought < m) {
      ans += e.first * min(e.second, m - bought);
      bought += min(e.second, m - bought);
    }
  }

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

  return 0;
}


Measured memory_bytes: 2420
#include<iostream>
#define MAXN 200005
using namespace std;
int main(){
	int n;
	int a[MAXN];
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	int max=-0x3f3f3f3f;
	int min=a[0];
	for(int i=1;i<n;i++){
		max=max>(a[i]-min)?max:(a[i]-min);
		min=min<a[i]?min:a[i];
	}
	cout<<max<<endl;
	return 0;
} 


Measured memory_bytes: 3840
#include <bits/stdc++.h>
 
#define MAX_NUM (1000000000 + 7)
 
typedef uint64_t u64;
typedef int64_t i64;
typedef uint32_t u32;
typedef int32_t i32;
 
using namespace std;
 
template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}
 
template <typename T>
static inline void ArrayPut(const vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}
 
bool Sec_compare(pair<uint64_t, uint64_t> a, pair<uint64_t, uint64_t> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}
 
u64 dec_dig(u64 num) {
  u64 res = 0;
  while (num > 0) {
    num /= 10;
    ++res;
  }
  return res;
}
 
u64 gcd(u64 a, u64 b) {
  if (a < b) {
    a ^= b;
    b ^= a;
    a ^= b;
  }
 
  return b ? gcd(b, a % b) : a;
}
 
int main() {
  cout << setprecision(18);
  u64 S, W;
  cin >> S >> W;
  if (W >= S)
    cout << "unsafe" << endl;
  else
    cout << "safe" << endl;
  return 0;
}

Measured memory_bytes: 3632
n=int(input())

a=[input() for i in range(n)]

ans=True
if all(a.count(w) <2  for w in a):
    for i in range(n-1):
        if a[i][-1]!=a[i+1][0]:
            ans=False
else:
    ans=False
    
if ans:    
    print('Yes')
else:
    print('No')

Measured memory_bytes: 3064
from collections import deque

N,M=map(int,input().split())
startx=0
starty=0
goalx=M-1
goaly=N-1

S = [["" for j in range(M)] for i in range(N)]#2行3列の場合
#iがyｊがx

point=0

for i in range(N):
    tmp=input()
    for j in range(M):
        S[i][j]=tmp[j]
        if S[i][j]==".":
            point+=1
        
        
seen=[[-1 for j in range(M)] for i in range(N)]
#S = [[0 for j in range(3)] for i in range(2)]　2行3列の場合

dx=[1,0,-1,0]
dy=[0,1,0,-1]

def dfs(y,x):

    todox=deque()
    todoy=deque()
    seen[y][x]=1
    todox.append(x)
    todoy.append(y)
    
    while len(todox) !=0:
        x=todox.popleft()
        y=todoy.popleft()
        
        for i in range(4):
            nx=x+dx[i]
            ny=y+dy[i]
            if nx>=0 and nx<M and ny>=0 and ny<N :
                if nx==goalx and ny==goaly:
                    seen[ny][nx]=seen[y][x]+1
                    #print(seen)
                    return seen[ny][nx]
                        
                if S[ny][nx]==".":
                    
                    
                    
                    if seen[ny][nx] ==-1:
                        #print("mohu",nx,ny)
                        seen[ny][nx] =seen[y][x]+1
                        todox.append(nx)
                        todoy.append(ny)
                
    return -1

ret=dfs(starty,startx)
if ret==-1:
    print(-1)
else:
    print(point-ret)


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

template <typename T, typename F>
class SegTree{
  int n; T uni; F f;
  vector<T> dat;
public:
  SegTree(int _n, F f, T uni) : f(f), uni(uni) {
    n = 1;
    while(n < _n) n *= 2;
    dat = vector<T>(2*n,uni);
  }
  void set(int k, const T x) {
    dat[k+n] = x;
  }
  void build() {
    for(int i = n-1; i >= 0; i--) {
      dat[i] = f(dat[2*i],dat[2*i+1]);
    }
  }
  void update(int k, T x) {
    k += n;
    dat[k] = x;
    while(k >>= 1){
      dat[k] = f(dat[2*k],dat[2*k+1]);
    }
  }
  T query(int a, int b) {
    T l = uni, r = uni;
    for(a += n, b += n; a < b; a >>= 1, b >>= 1) {
      if(a & 1) l = f(l,dat[a++]);
      if(b & 1) r = f(dat[--b],r);
    }
    return f(l,r);
  }
};

int main(){
  int n, l;
  cin >> n >> l;
  auto f = [](int a, int b){return min(a,b);};
  SegTree<int,decltype(f)> st(n,f,INF);
  rep(i,n) {
    int a;
    cin >> a;
    st.set(i,a);
  }
  st.build();
  rep(i,n-l+1) {
    cout << st.query(i,i+l);
    if(i < n-l) cout << " ";
    else cout << endl;
  }
  return 0;
}


Measured memory_bytes: 11020
#include <stdio.h>

int l;
char s[20];

bool good() {
  if (s[0] != 'A') return false;
  int at = -1;
  for (int i = 2; i < l - 1; ++i) {
    if (s[i] == 'C') {
      at = i;
      break;
    }
  }
  if (at == -1) return false;
  for (int i = 1; i < l; ++i) {
    if (i == at) continue;
    if (s[i] < 'a') return false;
  }
  return true;
}

int main() {
  scanf("%s", s);
  while (s[l]) ++l;
  puts(good() ? "AC" : "WA");
  return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define MOD 1000000007
#define len(x) x.size()
#define min3(a, b, c) min(a, min(b, c))
#define max3(a, b, c) max(a, max(b, c))
#define all(v) v.begin(), v.end()
#define alla(a,n) a, a + n
using namespace std;

typedef long long int ll;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<string> vs;
using namespace std;

string s;
int main() {
    //freopen("input.txt", "r", stdin) ;
    //freopen("output.txt", "w", stdout) ;
    ios_base::sync_with_stdio(false);
    cin.tie(NULL) ; cout.tie(NULL) ;
    cin>>s;
    int sum=0;
    for(int i=0;i<s.length();i++){
        sum+=(int)(s[i]-'0');
    }
    if(sum%9==0) cout<<"Yes";
    else cout<<"No";
    return 0;
}




Measured memory_bytes: 3776
package main

import (
	"bufio"
	"fmt"
	"os"
	"sort"
	"strconv"
)

func main() {
	var x, y, z, k int
	fmt.Scan(&x, &y, &z, &k)
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	as := make([]int, x)
	for i := range as {
		sc.Scan()
		as[i], _ = strconv.Atoi(sc.Text())
	}
	sort.Sort(sort.Reverse(sort.IntSlice(as)))
	bs := make([]int, y)
	for i := range bs {
		sc.Scan()
		bs[i], _ = strconv.Atoi(sc.Text())
	}
	sort.Sort(sort.Reverse(sort.IntSlice(bs)))
	cs := make([]int, z)
	for i := range cs {
		sc.Scan()
		cs[i], _ = strconv.Atoi(sc.Text())
	}
	sort.Sort(sort.Reverse(sort.IntSlice(cs)))

	ans := make([]int, 0, x+y+z)
	for ia, a := range as {
		if ia+1 > k {
			break
		}
		for ib, b := range bs {
			if (ia+1)*(ib+1) > k {
				break
			}
			for ic, c := range cs {
				if (ia+1)*(ib+1)*(ic+1) > k {
					break
				}
				ans = append(ans, a+b+c)
			}
		}
	}
	sort.Sort(sort.Reverse(sort.IntSlice(ans)))
	for _, v := range ans[:k] {
		fmt.Println(v)
	}
}


Measured memory_bytes: 5376
import itertools
args = []
for _ in range(5):
    tmp = int(input())
    args.append(tmp)
best = 643
for perm in itertools.permutations(args):
    remainder = 0
    cook = 0
    for i, t in enumerate(perm):
        cook += t
        if i == 4:
            break
        while(cook % 10 != 0):
            cook += 1

    cook += remainder
    if cook < best:
        best = cook
print(best)


Measured memory_bytes: 3060
#include <stdio.h>

int main()
{
    int a, b, c;
    scanf("%d%d%d", &a, &b, &c);
    if (a < b) {
    	if (c - b > a)
        	printf("dangerous\n");
		else	
			printf("safe\n");    	
    }

    else {
        if (b >= c)
            printf("delicious\n");
        if (c > b && c - b <= a)
            printf("safe\n");
    }
    return 0;
}


Measured memory_bytes: 128
Q=int(input())

n = 10**5
primes = set(range(2, n+1))
for i in range(2, int(n**0.5+1)):
    primes.difference_update(range(i*2, n+1, i))
primes=list(primes)

from bisect import bisect_left,bisect_right
import numpy as np

ls=[]
rs=[]
for i in range(Q):
    l,r=map(int, input().split())
    ls.append(l)
    rs.append(r)
lmin=min(ls)
rmax=max(rs)
bool_prime=np.zeros(rmax+1,dtype=np.int64)
bool_2007=np.zeros(rmax+1,dtype=np.int64)

for p in primes:
    if p>rmax:
        break
    bool_prime[p]=1
    if p!=2 and bool_prime[(p+1)//2]==1:
        bool_2007[p]=1

cum2007=np.cumsum(bool_2007)
for i in range(Q):
    print(cum2007[rs[i]]-cum2007[ls[i]-1])

Measured memory_bytes: 32076
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
int main() {
  
 int n;
  cin >> n;
  vector<int> a(n);
  rep(i,n) cin >> a[i];
  vector<int> b(n);
  rep(i,n) cin >> b[i];
  vector<int> c(n-1);
  rep(i,n-1) cin >> c[i];
  rep(i,n) a[i]--;
 
  int ans = 0;
  rep(i,n) {
    ans += b[a[i]];
  }
 
  rep(i,n-1) {
    if (a[i]+1 == a[i+1]) {
      ans += c[a[i]];
    }
  }
  cout << ans << endl;
  return 0;
  

  
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int x, a, b, m, n;
  scanf("%d %d %d", &x, &a, &b);

  m = x-a;
  if(m<0)
    m = -1 * m;
  n = x-b;
  if(n<0)
    n = -1 * n;

  if(m>n)
    printf("B\n");
  else
    printf("A\n");
  return(0);
}

Measured memory_bytes: 128
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;


int main() {
  int n;
  cin >> n;
  map<string, int> s;
  rep(i, n){
    string t;
    cin >> t;
    s[t]++;
  }

  int mx = 0;
  for(pair<string, int> t: s) mx = max(t.second, mx);
  vector<string> ans;
  for(pair<string, int> t: s){
    if (t.second == mx) ans.push_back(t.first);
  }

  sort(ans.begin(), ans.end());
  rep(i, ans.size()) cout << ans[i] << endl;
  return 0;
}

Measured memory_bytes: 28788
#include<cstdio>
#include<math.h>
#include<algorithm>
#include<vector>
#include<queue>
#include<string>
#include<set>
#include<cstring>
#include<map>
 
 
using namespace std;
#define int long long int
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define mp make_pair
#define pb push_back
#define mod 1000000007
//#define mod 998244353

char S[1005];
signed main(){
    scanf("%s",S);
    int N=strlen(S);
    if(S[N-1]=='s'){
        printf("%ses",S);
    }else{
        printf("%ss",S);
    }
}

Measured memory_bytes: 1736
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;

int main(){
    int k,a,b;
    string s="NG";
    cin>>k>>a>>b;
    for(int i=a;i<=b;i++){
        if(i%k==0){
            s="OK";
        }
    }
    cout<<s<<endl;
    return 0;
}

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

using namespace std;

int main(){
  int n,k,d;
  cin>>n>>k;
  int cnt=n;
  set<int> set;
  for(int i=0;i<k;i++){
    cin>>d;
    for(int j=0;j<d;j++){
      int a;
      cin>>a;
      set.insert(a);
    }
  }
  cout<<cnt - set.size()<<endl;
}


Measured memory_bytes: 3644
using System;
using System.Linq;
class p
{
  static void Main()
  {
    string[] input = Console.ReadLine().Split(' ');
    int N = int.Parse(input[0]);
    int L = int.Parse(input[1]);
    
    int[] arr = new int[N];
    int min = int.MaxValue, minIndex = -1;
    for (int i = 0; i < N; i++) {
      arr[i] = (L + i);
      if (Math.Abs(arr[i]) < min) {
        min = Math.Abs(arr[i]);
        minIndex = i;
      }
    }
    arr[minIndex] = 0;
    Console.WriteLine(arr.Sum());
  }
}

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


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

    int n;
    cin>>n;

    double arr[n+1];
    for(int i=1;i<=n;i++)
    	cin>>arr[i];

    double dp[n+1][n+1];

   	for(int i=0;i<n+1;i++)
   	{
   		for(int j=0;j<n+1;j++)
	   		dp[i][j]=0;
   	}

	dp[0][0]=1;
	
   	for(int i=1;i<=n;i++)
   	{
   		dp[i][0]=dp[i-1][0]*(1-arr[i]);
   		for(int j=1;j<=i;j++)
   		{
   			dp[i][j]=dp[i-1][j]*(1-arr[i])+dp[i-1][j-1]*arr[i];
   		}
   	}

   	double ans=0;

   	for(int i=n;i>n/2;i--)
   	{
   		ans+=dp[n][i];
   	}

   	cout<<setprecision(10)<<ans;
}

Measured memory_bytes: 70656
import numpy as np
N, W = map(int, input().split())
dp = np.zeros(W + 1, dtype = np.int64)

for _ in range(N):
    w,v = map(int, input().split())
    np.maximum(dp[w:], dp[:-w] + v, out=dp[w:])

print(dp[W])

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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;

Node root, NIL;
int maxh;

void insert(int k){
  int H;
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while( x != NIL ){
    y = x;
    if ( z->key < x->key ){
      x = x->left;
    } else {
      x = x->right;
    }
  }

  z->parent = y;
  if ( y == NIL ){
    root = z;
  } else {
    if (z->key < y->key) {
      y->left = z;
    } else {
      y->right = z;
    }
  }
}

void inorder(Node u){
  if ( u == NIL ) return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}
void preorder(Node u){
  if ( u == NIL ) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);
  maxh = 0;
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( strcmp(com, "insert") == 0 ){
      scanf("%d", &x);
      insert(x);
    } else if ( strcmp(com, "print") == 0 ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }

  return 0;
}




Measured memory_bytes: 25128
#include<bits/stdc++.h>
#define del(a,i) memset(a,i,sizeof(a))
#define ll long long
#define inl inline
#define il inl void
#define it inl int
#define ill inl ll
#define re register
#define ri re int
#define rl re ll
#define mid ((l+r)>>1)
#define lowbit(x) (x&(-x))
#define INF 0x3f3f3f3f
using namespace std;
template<class T>il read(T &x){
	int f=1;char k=getchar();x=0;
	for(;k>'9'||k<'0';k=getchar()) if(k=='-') f=-1;
	for(;k>='0'&&k<='9';k=getchar()) x=(x<<3)+(x<<1)+k-'0';
	x*=f;
}
template<class T>il _print(T x){
	if(x/10) _print(x/10);
	putchar(x%10+'0');
}
template<class T>il print(T x){
	if(x<0) putchar('-'),x=-x;
	_print(x);
}
ll mul(ll a,ll b,ll mod){long double c=1.;return (a*b-(ll)(c*a*b/mod)*mod)%mod;}
it qpow(int x,int m,int mod){
	int res=1,bas=x;
	while(m){
		if(m&1) res=(1ll*res*bas)%mod;
		bas=(1ll*bas*bas)%mod,m>>=1;
	}
	return res;
}
ll n,ans=1;
int main(){
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	read(n);
	for(ri i=2;1ll*i*i<=n;++i){
		if(n%i) continue;
		ll t=n;
		while(t%i==0) t/=i;
		if(t%i==1) ++ans;
		if(1ll*i*i==n) continue;
		t=n;
		while(t%(n/i)==0) t/=n/i;
		if(t%(n/i)==1) ++ans;
	}
	--n;
	for(ri i=2;1ll*i*i<=n;++i){
		if(n%i) continue;
		++ans;
		if(1ll*i*i!=n) ++ans;
	}
	print(ans+(n!=1));
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
#define opr iterator
typedef long long ll;
using namespace std;
int n;
int per[200010];
bool ok[200010];
void get(int standard)
{
	for(int i=1;i<=2*n-1;i++)
	{
		ok[i]=(per[i]>=standard);
//		cout<<ok[i]<<"   ";
	}
	return;
}
bool check()
{
	int i,j;
	for(i=n,j=n;i>1&&j<2*n-1;i--,j++)
	{
		if(ok[i]==ok[i-1])
		{
		 	return ok[i];
		}
		else if(ok[j]==ok[j+1])
		{
			return ok[j];
		}
	}
	return ok[1];
}
int main()
{
	cin>>n;
	for(int i=1;i<=2*n-1;i++)
	{
		cin>>per[i];
	}
	int left=1;
	int right=2*n-1;
	int mid;
	while(left<right)
	{
		mid=(left+right+1)/2;
//		cout<<endl<<endl<<left<<"  LLL   RRR   "<<right<<endl<<endl;
//		cout<<"mid "<<mid<<endl; 
		get(mid);/*
		cout<<"mid= "<<mid<<endl;
		cout<<"left=  "<<left<<"      "<<"right=  "<<right<<endl;
		for(int i=1;i<=2*n-1;i++)
		{
			cout<<ok[i]<<" ";
		}
		cout<<endl;
		cout<<check()<<endl;*/
		if(check())
		{
			left=mid;
		}
		else
		{
			right=mid-1;
		}
//		system("pause");
	}
	cout<<right<<endl;
	return 0;
}

Measured memory_bytes: 1280
while True:
    n=int(input())
    if n==0:
        break
    
    con=[0]*10
    
    for i in range(n):
        con[int(input())]+=1
        
    for i in range(10):
        if con[i]==0:
            print("-")
        else:
            for j in range(con[i]-1):
                print("*",end="")
            print("*")


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

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

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

using f32 = float;
using f64 = double;

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

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

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

#define pb push_back
#define mp make_pair
#define F first
#define S second

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

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

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


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

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


int main() {
    i64 A, B, K; cin >> A >> B >> K;

    i64 k = 0;
    RREPS(i, min(A, B)) {
        if (A % i == 0 && B % i == 0) {
            if (++k == K) {
                cout << i << endl;
                break;
            }
        }
    }

    return 0;
}

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

using uint=unsigned;
using ll=long long;
using ull=unsigned long long;
#define int ll

#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=a;i--)
#define per(i,b) gnr(i,0,b)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define fs first
#define sc second
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#ifdef LOCAL
#define dmp(x) cerr<<__LINE__<<" "<<#x<<" "<<x<<endl
#else
#define dmp(x) void(0)
#endif
#define tmp template<class t>

tmp void chmax(t&a,t b){if(a<b)a=b;}
tmp void chmin(t&a,t b){if(a>b)a=b;}

tmp using vc=vector<t>;
tmp using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class t,class u>
ostream& operator<<(ostream& os,const pair<t,u>& p){
	return os<<"{"<<p.fs<<","<<p.sc<<"}";
}

tmp ostream& operator<<(ostream& os,const vc<t>& v){
	os<<"{";
	for(auto e:v)os<<e<<",";
	return os<<"}";
}

constexpr ll ten(int n){
	return n==0?1:ten(n-1)*10;
}

tmp void mkuni(vc<t>&v){
	sort(all(v));
	v.erase(unique(all(v)),v.ed);
}

ll read(){ll i;cin>>i;return i;}

using ld=long double;
using cm=complex<ld>;
#define x real()
#define y imag()
const ld eps=1e-12;
int sgn(ld a){return a<-eps?-1:(a>eps?1:0);}
auto cmcmp=[](const cm&a,const cm&b){
	if(sgn(a.x-b.x))return a.x<b.x;
	else return sgn(a.y-b.y)<0;
};

struct ln{
	cm a,b;
	cm dir(){return b-a;}
};
ld dot(cm a,cm b){return a.x*b.x+a.y*b.y;}
ld crs(cm a,cm b){return a.x*b.y-a.y*b.x;}
int ccw(cm a,cm b){return sgn(crs(a,b));}
int ccw(cm a,cm b,cm c){return ccw(b-a,c-a);}
int ccw(ln a,cm b){return ccw(a.a,a.b,b);}

//(-2)[a,-1](0)[b,1](2)
int bet(cm a,cm b,cm c){
	cm d=b-a;
	ld e=dot(d,c-a);
	if(sgn(e)<=0)return sgn(e)-1;
	return sgn(e-norm(d))+1;
}

ld tri2(cm a,cm b,cm c){
	return crs(b-a,c-a);
}

cm readcm(){
	ld a,b;
	cin>>a>>b;
	return cm(a,b);
}

signed main(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(20);
	
	int n=read();
	
	rep(_,n){
		cm a=readcm();
		cm b=readcm();
		cm c=readcm();
		cm d=readcm();
		if(ccw(b-a,d-c)==0)
			cout<<"YES"<<endl;
		else
			cout<<"NO"<<endl;
	}
}



Measured memory_bytes: 3192
import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner in = new Scanner(System.in);
        
        while(true){
            int a = in.nextInt();
            char op = in.next().charAt(0);
            int b = in.nextInt(), res=0;

            if(op == '?')break;

            switch (op){
                case '+':
                    res = a + b;
                    break;
                
                case '-':
                    res = a - b;
                    break;

                case '*':
                    res = a * b;
                    break;

                case '/':
                    res = a / b;
                    break;
            }

            System.out.println(res);
        }
    }
}


Measured memory_bytes: 26204
#include <bits/stdc++.h>
#define mp make_pair
#define ff first
#define ss second

using namespace std;
using vi=vector<int>;
using pii=pair<int, int>;
using ull=unsigned long long;

typedef long long ll;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
	map<string, int> freq;

	int n; cin >> n;
	ull ans = 0;
	while(n--)
	{
		string s; cin >> s;
		sort(s.begin(), s.end());

		ans += freq[s]++;
	}

	cout << ans << "\n";
	
    
    return 0;
}


Measured memory_bytes: 11264
//\\//\\ * * * //\\// ||
#include <bits/stdc++.h> 

#define debug(x) cerr << #x << ": " << x << endl

using namespace std;

typedef long long ll;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll x;
  cin >> x;
  cout << (x >= (ll) 30 ? "Yes" : "No") << '\n';
  return 0;
}


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

# CODE FESTIVAL 2017 A
# Problem B

if __name__ == '__main__':
    from collections import Counter

    n = int(input())
    ds = Counter(list(map(int, input().split())))
    m = int(input())
    ts = Counter(list(map(int, input().split())))

    for t_key, t_value in ts.items():
        if (ds[t_key] - t_value) < 0:
            print('NO')
            exit()

    print('YES')


Measured memory_bytes: 55264
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  string S, T;
  cin >> S >> T;
  const int64_t SL = static_cast<int64_t>(S.length());
  const int64_t TL = static_cast<int64_t>(T.length());
  int64_t result = kInf;
  for (int64_t i = 0; i + TL <= SL; ++i) {
    int64_t temp = 0;
    for (int64_t j = 0; j < TL; ++j) {
      if (S[i + j] != T[j]) {
        ++temp;
      }
    }
    result = min(result, temp);
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 3652
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<cstring>

using namespace std;
typedef long long ll;
#define INF 2000000

ll graph[101][101],n;

void warshall_floyd(void);

int main(void){
  int u,k,v,c;

  cin >> n;

  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
      graph[i][j]=INF;

  for(int i=0;i<n;i++)graph[i][i]=0;

  for(int i=0;i<n;i++){
    cin >> u >> k;
    while(k--){
      cin >> v >> c;
      graph[u][v]=c;
    }
  }

  warshall_floyd();

  for(int i=0;i<n;i++)
    cout << i << " " << graph[0][i] << endl;
  
  return 0;
}

void warshall_floyd(void){
  for(int k=0;k<n;k++)
    for(int i=0;i<n;i++)
      for(int j=0;j<n;j++)
	graph[i][j]=min(graph[i][j],graph[i][k]+graph[k][j]);
  
}

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

// clang-format off
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); --(i))

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define endl '\n'
#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

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

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

void solver() {
    string s, t;
    cin >> s >> t;
    int a = input(), b = input();
    
    string u;
    cin >> u;
    if (u == s) a--;
    else b--;
    
    cout << a << " " << b << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <cstdio>
#include <algorithm>
#include <functional>
#include <string>
#include <numeric>
#include <stack>

using namespace std;

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

#define rep(i, a, N) for(int i = a; i < N; i++)
#define rrep(i, a, N) for(int i = a; i >= N; i--)

const int INF = 1e9+7;

int main() {
    int N;
    cin >> N;
    string s;
    cin >> s;
    int red = 0, blue = 0;
    rep(i, 0, s.size()) {
        if (s[i] == 'R') red++;
        if (s[i] == 'B') blue++;
    }
    if (red > blue) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 888