akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define MAX 100000
#define SENTINEL 2000000000

struct Card {
    char suit;
    int value;
};

struct Card L[MAX /2 + 2], R[MAX /2 + 2];

void merge(struct Card A[], int n, int left, int mid, int right) {
    int i, j, k;
    int n1 = mid - left;
    int n2 = right - mid;
    for (i = 0; i < n1; i++) {
        L[i] = A[left + i];
    }
    for (i = 0; i < n2; i++) {
        R[i] = A[mid + i];
    }
    L[n1].value = R[n2].value = SENTINEL;
    i = j = 0;
    for (k = left; k < right; k++) {
        if (L[i].value <= R[j].value) {
            A[k] = L[i++];
        }
        else {
            A[k] = R[j++];
        }
    }
}

void mergeSort(struct Card A[], int n, int left, int right) {
    int mid;
    if (left + 1 < right) {
        mid = (left + right) / 2;
        mergeSort(A, n, left, mid);
        mergeSort(A, n, mid, right);
        merge(A, n, left, mid, right);
    }
}

int partition(struct Card A[], int n, int p, int r) {
    int i, j;
    struct Card x;
    x = A[r];
    i = p - 1;
    for (j = p; j < r; j++) {
        if (A[j].value <= x.value) {
            i++;
            swap(A[i], A[j]);
        }
    }
    swap(A[i + 1], A[r]);
    return i + 1;
}

void quickSort(struct Card A[], int n, int p, int r) {
    int q;
    if (p < r) {
        q = partition(A, n, p, r);
        quickSort(A, n, p, q - 1);
        quickSort(A, n, q + 1, r);
    }
}

int main() {
    int n, i, v;
    struct Card A[MAX], B[MAX];
    char S[10];
    int stable = 1;
    scanf("%d", &n);
    for (i = 0; i < n; i++) {
        scanf("%s %d", S, &v);
        A[i].suit = B[i].suit = S[0];
        A[i].value = B[i] .value = v;
    }
    mergeSort(A, n, 0, n);
    quickSort(B, n, 0, n - 1);
    for (i = 0; i < n; i++) {
        if (A[i].suit != B[i].suit) {
            stable = 0;
        }
    }
    if (stable == 1) {
        puts("Stable");
    }
    else {
        puts("Not stable");
    }
    for (i = 0; i < n; i++) {
        cout << B[i].suit << " " << B[i].value << endl;
    }
    return 0;
}


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

int calc_combination(int n, int take){//n : 総数, take : 取るボールの数
  int answer = 1;
  if(n >= 2){
    answer = n * (n - 1);
    answer /= take;
  }else{
    answer = 0;
  }
  return answer;
}

int main(){
  int N, M;
  cin >> N >> M;
  
  cout << calc_combination(N, 2) + calc_combination(M, 2) << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>

#define GYOU_MAX 256
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define s_pri(str) printf("%s\n",str);
#define PRINT(str) printf(#str "\n")
#define v_pri(val) printf("%d\n",val);
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define pi acos(-1.0)
#define sca(x) scanf("%d",&x);

typedef long long int ll;

/*
puts("aa");
//*/


int main(void) {
	

	int N, M;
	sca(N);
	sca(M);

	if (N == M) {
		s_pri("Yes");
	}
	else {
		s_pri("No");
	}



	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// #pragma GCC optimize("unroll-loops,no-stack-protector")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
 
// using namespace __gnu_pbds;
using namespace std;
 
// template <typename T>
// using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
 
typedef long long ll;
typedef long double ld;
typedef pair<long long ,long long> ii; 	
//typedef complex<long double> com;

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll a,b;
	cin >> a >> b;
	vector <string> lol(2);
	for (int z=0;z<b;z++){
		lol[0] += to_string(a);
	}
	for (int z=0;z<a;z++){
		lol[1] += to_string(b);
	}
	sort(lol.begin(),lol.end());
	cout << lol[0] << endl;
}

Measured memory_bytes: 256
$c--;push(@p,$p=$p*2+1),push@c,$c=$c*2+3for<>=~$"..$`;sub f{$x=pop;@p?($p=pop(@p),$x>1+($c=pop@c)?$p+1+f($x-2-$c):f($x-1)):$x>0}print 0+f$'

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

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  while(1) {
    C -= B;
    if(C <= 0) {
      cout << "Yes" << endl;
      return 0;
    }
    A -= D;
    if(A <= 0) {
      cout << "No" << endl;
      return 0;
    }
  }
  return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
typedef pair<int,int> P;
//const int inf=1000000007;
const int MOD=1000000007;
int n,a,b,c,d;
signed main(){
  cin>>n>>a>>b>>c>>d;
  bool flag=false;
  for(int i=n-1;i>=0;--i){
    int sup=d*i-c*(n-i-1);
    int inf=c*i-d*(n-i-1);
    if(b-a>=inf&&b-a<=sup){
      //cout<<i<<"\n";
      flag=true;
      break;
    }
  }
  	if(flag){
      cout<<"YES"<<endl;
    }
    else{
      cout<<"NO"<<endl;
    }
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define rep(i,n) for(int i = 1;i < (n);i++)

void f(int K,int X[]){
    rep(a,3){
        int s = X[a];
        X[a] = 2*X[a];
        K--;
        if(X[0] < X[1] && X[1] < X[2]){printf("Yes\n");exit(0);}
        else if(K > 0){
            f(K,X);
            K++;
        }
        X[a] = s;
    }
}

int main(){
    int X[3],K;
    scanf("%d%d%d%d",X,X+1,X+2,&K);

    if(X[0] < X[1] && X[1] < X[2]){printf("Yes\n");exit(0);}

    f(K,X);
    printf("No\n");
    exit(0);
}

Measured memory_bytes: 1588
#include <iostream>
#include <cstring>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>
#include <stdio.h>
#include <iomanip>
#include <limits>
#include <list>
#include <queue>
#include <tuple>
#include <map>
#include <set>
#include <sstream>
using namespace std;
#define MOD (long long int)(1e9+7)
#define ll long long int
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define reps(i,n) for(int i=1; i<=(int)(n); i++)
#define REP(i,n) for(int i=n-1; i>=0; i--)
#define REPS(i,n) for(int i=n; i>0; i--)
#define FOR(i,a,b) for(int i=a; i<(int)(b); i++)
#define ALL(x) (x).begin(),(x).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort(ALL(x))
#define CLR(a) memset((a), 0 ,sizeof(a))
#define PB push_back
#define MP make_pair
#define SP << " " <<
const int INF = 1001001001;
const ll LINF = 100100100100100100;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;

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

__attribute__((constructor))
void initial(){
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

signed main(){
  int h,w,n; cin>>h>>w>>n;
  int r,c; cin>>r>>c; r--; c--;
  string s,t; cin>>s>>t;

  // まずは左右について
  int left=0, right=w;
  if(s[n-1]=='L') left++;
  if(s[n-1]=='R') right--;
  REP(i,n-1){
    if(t[i]=='L') right=min(right+1,w);
    else if(t[i]=='R') left=max(0,left-1);
    if(s[i]=='L') left++;
    else if(s[i]=='R') right--;
    if(left>=right) return cout<<"NO"<<endl,0;
  }
  if(c<left||right<=c) return cout<<"NO"<<endl,0;


  // 次に上下について
  left=0, right=h;
  if(s[n-1]=='U') left++;
  if(s[n-1]=='D') right--;
  REP(i,n-1){
    if(t[i]=='U') right=min(right+1,h);
    else if(t[i]=='D') left=max(0,left-1);
    if(s[i]=='U') left++;
    else if(s[i]=='D') right--;
    if(left>=right) return cout<<"NO"<<endl,0;
  }
  if(r<left||right<=r) return cout<<"NO"<<endl,0;

  cout << "YES" << endl;

  return 0;
}


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

int main(){
 
  char t1[100][100];
  char t2[100][100];
  int i = 0;
  int j = 0;   

  for(i = 0; i < 8; i++){
      scanf("%s", &t1[i]);
  }
  
  memcpy(t2, t1, sizeof(t1));
  printf("90\n");
  for(i = 0; i < 8;  i++){
    for(j = 0; j < 8; j++){
      t1[j][8 - i - 1] = t2[i][j]; 
    }
  }
  for(i = 0; i < 8; i++){
    for(j = 0; j < 8; j++){
      printf("%c", t1[i][j]);
    }
    printf("\n");
  }




  memcpy(t2, t1, sizeof(t1));
  printf("180\n");

  for(i = 0; i < 8; i++){
    for(j = 0; j < 8; j++){
      t1[j][8 - i - 1] = t2[i][j];
    }
  }
  for(i = 0; i < 8; i++){
    for(j = 0; j < 8; j++){
      printf("%c", t1[i][j]);
    }
    printf("\n");
  }



  memcpy(t2, t1, sizeof(t1));
  printf("270\n");
  for(i = 0; i < 8; i++){
    for(j = 0; j < 8; j++){
      t1[j][8 - i - 1] = t2[i][j];
    }
  }
  for(i = 0; i < 8; i++){
    for(j = 0; j < 8; j++){
      printf("%c", t1[i][j]);
    }
    printf("\n");
  }

 
  return 0;
}

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

/* 大文字を小文字に変換 */
char tolower(char c) {return (c + 0x20);}
/* 小文字を大文字に変換 */
char toupr(char c) {return (c - 0x20);}

// if('A'<=s[i] && s[i]<='Z') s[i] += 'a'-'A';

/*
string s = "abcdefg"
s.substr(4) "efg"
s.substr(0,3) "abc"
s.substr(2,4) "cdef"

// イテレータ要素のインデックス
distance(A.begin(), itr);
*/

int main()
{
    int N; cin >> N;
    int A[N]; int maxA = 0;
    rep(i,N){
        cin >> A[i];
        if(maxA < A[i]) maxA = A[i];
    }
    sort(A, A+N);
    bool T[maxA+1];
    rep(i,maxA+1) T[i] = true;
    int ans = 0;
    rep(i,N){
        if(T[A[i]] == true){
            ans++;
            for(int j=1; j*A[i] <= maxA; j++){
                T[A[i]*j] = false;
            }
            if(i != N-1 && A[i] == A[i+1]){
                ans--;
            }
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 5336
import java.util.Scanner;

public class Main {

	static Scanner sc = new Scanner(System.in);
	static int[] price = { 500, 100, 50, 10, 5, 1 };

	public static void main(String[] args) {
		while (true) {
			int N = 1000 - sc.nextInt();
			if (N == 1000) break;
			int ans = 0;
			for (int i = 0; i < price.length; ++i) {
				while (N >= price[i]) {
					N -= price[i];
					++ans;
				}
			}
			System.out.println(ans);
		}
	}

}

Measured memory_bytes: 12000
#include<bits/stdc++.h>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a,b,c,d;
  cin >>a>>b;
  c=b/2;
  if(a>c){
    d=c,b-=c*2;
  }
  else{
    d=a,b-=a*2;
    d+=b/4;
  }
  cout<<d<<"\n";
  return (0);
}


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

int ok(int P,int n,int w[],int k){
  int i=0;
  for(int j=0;j<k;j++){
    int s=0;
    while(s+w[i]<=P){
      s+=w[i];
      i++;
      if(i==n) return n;
    }
  } 
  return i;
}
int main(){
  int n,k;
  cin>>n>>k;
  int w[n];
  for(int i=0;i<n;i++){
    cin>>w[i];
  }
  int l=0,h=1000000000;
  while(l+1<h){
    int m=(l+h)/2;
    if(ok(m,n,w,k)>=n) h=m; else l=m;
  }
  printf("%d\n",l+1);
  return 0;
}

Measured memory_bytes: 3524
/*  ex4_3
    pptenshi  */

#include<stdio.h>

int west_tower_num(int height_west, int height_east);
int height_tower(int num);

int main(void) {
    int height_west,  // a 
        height_east,  // b
        snowfall;     // 積雪量

    // input
    scanf("%d%d", &height_west, &height_east);

    // calculate ans
    snowfall = height_tower(
            west_tower_num(height_west, height_east)
        ) - height_west;
    
    // output
    printf("%d\n", snowfall);

    return 0;
}


/*  calculate west tower number
    parameter : height of west tower above snow,
                height of east tower above snow    */ 
int west_tower_num(int height_west, int height_east) {
    return height_east - height_west - 1;
}


/*  calculete height of tower
    parameter : tower number   */
int height_tower(int num) {
    return num * (num + 1) / 2; 
}

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

int main() {
	string S, T; cin >> S;
	T="CODEFESTIVAL2016";
	int miss=0;
	for(int i=0; i<16; ++i) if(S[i]!=T[i]) ++miss;
	cout << miss << endl;
	return 0;
}


Measured memory_bytes: 256
import	java.util.*;

public	class	Main{
	public	static	void	main(String[]	args){
		Scanner	sc	=new	Scanner(System.in);
		
		int	a	=sc.nextInt();
		int	b	=sc.nextInt();
		
		if((a*b)%2	!=	1){
			System.out.println("Even");
		}else{
			System.out.println("Odd");
			
		}
	}
}


Measured memory_bytes: 20820
#include <bits/stdc++.h>
#define int long long
#define N 100010
using namespace std;
const int INF = 1LL<<55;
const int mod = (1e9)+7;
const double EPS = 1e-8;
const double PI = 6.0 * asin(0.5);
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template< class T > void prArray(T a,char ch = ' '){
  for(int i=0;i<(int)a.size();i++,cout<<ch){
    if(i) cout<<ch;
    cout<<a[i];
  }
  cout<<endl;
}



signed main(){
  int n;
  cin>>n;
  map<int,int> M;
  for(int i=0;i<n;i++){
    int a;
    cin>>a;
    M[a]++;
  }

  int ans = 0;
  for(auto p:M){
    if(p.first == p.second) continue;
    if(p.first <= p.second) ans += abs(p.first - p.second);
    else ans += p.second;
  }
    cout<<ans<<endl;
  
  return 0;
}


Measured memory_bytes: 6272
// 問題の URL を書いておく
// 

#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>

using namespace std;

//#define ENABLE_PRINT

#if defined(ENABLE_PRINT)

#define Print(v) \
do {\
    cout << #v << ": " << v << endl; \
}while(0)

#define PrintVec(v) \
do {\
    for(int __i = 0; __i < v.size(); ++__i) \
    { \
        cout << #v << "[" << __i << "]: " << v[__i] << endl; \
    }\
}while(0)

#else

#define Print(v) ((void)0)
#define PrintVec(v) ((void)0)

#endif

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

int main(int, const char**)
{
    string s, t;
    cin >> s >> t;
    int ans = 0;
    rep(i, (int)s.size())
    {
        if(s[i] != t[i])
        {
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3912
#include <stdio.h>
#include <string>
#include <iostream>
#include <vector>
#include <queue>
#include <list>
#include <algorithm>
#include <map>
#include <iterator>
#include <limits>
#include <numeric>
#include <type_traits>
#include <cmath>
#include <cstdlib>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;

#define ALL(v) (v).begin(), (v).end()
#define endl "\n"
typedef long long int ll;

template<typename T>
ostream& operator << (ostream& os, vector<T>& vec) {
	for (int i = 0; i<vec.size(); i++) {
		os << vec[i] << (i + 1 == vec.size() ? "" : " ");
	}
	return os;
}

int SumDigitValues(int x)
{
	int sum = 0;
	while (x)
	{
		sum += x % 10;
		x = x / 10;
	}

	return sum;
}

int Factorial(int n)
{
	if (n < 0) return 0;
	if (n == 0) return 1;
	return n * Factorial(n - 1);
}

int factorial(int n)
{
	if (n > 1)
	{
		return n * factorial(n - 1);
	}
	else
	{
		return 1;
	}
}


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

vector<int> Divisors(int x)
{
	vector<int> divisors;
	divisors.push_back(1);
	for (int a = 2; a <= x; a++)
	{
		if (x % a == 0) divisors.push_back(a);
	}
	return divisors;
}

vector<int> CommonDivisors(int a, int b)
{
	vector<int> divisorsA = Divisors(a);
	vector<int> divisorsB = Divisors(b);
	vector<int> commonDivisors;
	set_intersection(divisorsA.begin(), divisorsA.end(), divisorsB.begin(), divisorsB.end(), std::back_inserter(commonDivisors));
	return commonDivisors;
}

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

	int n, a, b;
	cin >> n >> a >> b;

	int densya = n * a;
	int taxy = b;

	if (densya < taxy)
		cout << densya << endl;
	else
		cout << taxy << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#define ll long long
#define pb push_back
#define mp make_pair
#define all(X) (X).begin(), (X).end()
 
#define cmp_all(X) (X).begin(), (X).end(), cmp
 
#define B begin()
#define E end()
#define sz size()
#define skip continue
 
#define ppi pair<pair<int, int>, int>
#define pii pair<int, int> 
#define pli pair<ll, int>
#define pcc pair<char, char>

#define F first
#define S second
 
using namespace std;
 
const int maxn = 1e7 + 17;
const int MAXN = maxn * 4;
const int darr = 1e3 + 17;
const ll INF = 1e17 + 5;
const int mod = 1e9 + 7;
 
void Need_For_Speed () {
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
}

string s;

bool n, so, e, w;

int main () {
	Need_For_Speed();
	cin >> s;
	for (int i = 0; i < s.sz; i++) {
		if (s[i] == 'N') {
			n = true;
		}
		else if (s[i] == 'S') {
			so = true;
		}
		else if (s[i] == 'E') {
			e = true;
		}
		else {
			w = true;
		}
	}
	if ((n == 1 && so == 0) || (so == 1 && n == 0) || (e == 1 && w == 0) || (w == 1 && e == 0)) {
		cout << "No";
	}
	else {
		cout << "Yes";
	}
	return 0;
} 

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define max(p,q)((p)>(q)?(p):(q))
#define min(p,q)((p)<(q)?(p):(q))

//辺の情報を個別に持つタイプ
typedef struct edge{ll s,g;}E;
typedef struct graph{
	int vcnt,ecnt;
	E  e[200010];//適宜変える(ecnt)
	int id[100010];//適宜変える(vcnt)
}G;
G g;

int esort(const void*a,const void*b){
	E*p=(E*)a,*q=(E*)b;
	if((*p).s<(*q).s)return -1;
	if((*p).s>(*q).s)return  1;
	if((*p).g<(*q).g)return -1;
	return 1;
}
void readgraph(){
	//適宜変える
	ll n,m;
	scanf("%lld%lld",&n,&m);
	rep(i,0,m){
		ll x,y,c;
		scanf("%lld%lld",&x,&y);
		x--,y--;
		g.e[i].s=x;
		g.e[i].g=y;
	}
	g.vcnt=n;
	g.ecnt=m;
	qsort(g.e,g.ecnt,sizeof(E),esort);

	int p=0;
	rep(i,0,g.vcnt){
		while(p<g.ecnt&&g.e[p].s<i)p++;
		g.id[i]=p;
	}
	g.id[g.vcnt]=g.ecnt;//番兵
}

double dp[610];
double dpmax[610];	
double p[610];

int main(){
	readgraph();
	for(int v=g.vcnt-2;v>=0;v--){
		double s=0,cnt=0,M=0;
		for(int i=g.id[v];i<g.id[v+1];i++){
			s+=dp[g.e[i].g];
			cnt++;
			M=max(M,dp[g.e[i].g]);
		}
		dp[v]=s/cnt+1;
		dpmax[v]=M;
	}
	p[0]=1;
	for(int v=0;v<g.vcnt-1;v++){
		int cnt=g.id[v+1]-g.id[v];
		for(int i=g.id[v];i<g.id[v+1];i++)p[g.e[i].g]+=p[v]/cnt;
	}
		
	double ans=dp[0];
	for(int v=0;v<g.vcnt-1;v++){
		int cnt=g.id[v+1]-g.id[v];
		if(cnt>1){
			double diff=dp[v]-(((dp[v]-1)*cnt-dpmax[v])/(cnt-1)+1);
			ans=min(ans,dp[0]-diff*p[v]);
		}
	}
	
	printf("%.9f",ans);
}

Measured memory_bytes: 5756
#include<iostream>
#include<algorithm>
#include<vector>
#include<functional>
#include<string>
#include<cmath>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<cstdio>
#include<numeric>
using namespace std;
using ll = long long;
int main(){
  int a, b, k;
  cin >> a >> b >> k;
  int cnt = 0;
  for(int i = min(a,b); i >= 1; i--){
    if(a % i == 0 && b % i == 0){
      cnt++;
      if(cnt == k){
        cout << i << endl;
        return 0;
      }
    }
  }
    return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<pair<int,int>> a(n);
    rep(i,n){
        cin >> a[i].first;
        a[i].second = i+1;
    }
    sort(a.begin(),a.end());
    rep(i,n){
        cout << a[i].second << " ";
    }
    cout << endl;
}

Measured memory_bytes: 3944
#include <iostream>
#include <fstream>
#include <vector>
#include <array>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <functional>
#include <random>
#include <limits>
#include <string>
#include <sstream>
#include <iomanip>

#include <cassert>
#include <cmath>
#include <ctime>

#pragma comment(linker, "/STACK:200000000")

using namespace std;

mt19937 mt (736);

void solve (istream &cin = std::cin, ostream &cout = std::cout)
{
    int n;

    cin >> n;

    vector<int> arr (n);

    for (auto &it : arr)
        cin >> it;

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

    cout << arr.back () << ' ';

    int best = arr.front ();

    for (auto it : arr)
        if (abs (arr.back () / 2.0 - it) < abs (arr.back () / 2.0 - best))
            best = it;

    cout << best << endl;
}

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

#ifdef LOCAL
    solve ();

    cout << "clock: " << clock () << endl;
#else
    solve ();
#endif // LOCAL

    return 0;
}


Measured memory_bytes: 640
#include <algorithm>
#include <iostream>
#include <iterator>
#include <cstdio>
#include <vector>
#include <cmath>
using namespace std;


#ifdef LOCAL
#define DEBUGMSG()                                                              \
{                                                                               \
    cerr << "[调试 @" << __PRETTY_FUNCTION__ << ":" << __LINE__ << "]" ;        \
}
#define DEBUGVAR(x)                                                             \
{                                                                               \
    cerr << "[调试 @" << __PRETTY_FUNCTION__ << ":" << __LINE__ << "]:" ;       \
    cerr << "([" << typeid(x).name() << "]" << #x << ")" << x << endl ;         \
}
#define DEBUGARR(l, r)                                                          \
{                                                                               \
    cerr << "[调试 @" << __PRETTY_FUNCTION__ << ":" << __LINE__ << "]:" ;       \
    copy(l, r, ostream_iterator<decltype(*l)>(cerr, " "));                      \
    cerr << endl ;                                                              \
}
#else
#define DEBUGMSG()
#define DEBUGVAR(x)
#define DEBUGARR(l, r)
#endif // LOCAL

using i64 = long long;

int N;
string str;


int main()
{
    int g = 0, p = 0;
    cin >> str ;

    for(string::iterator itr = str.begin(); itr != str.end(); itr++)
        if(*itr == 'p')
            p++;
        else
            g++;

    DEBUGVAR(p);
    DEBUGVAR(g);

    if(p >= g)
        cout << 0 << endl ;
    else
        cout << (g-p)/2 << endl ;

    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <sstream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <bitset>
#include <assert.h>
#include <deque>
using namespace std;

typedef unsigned long long UL;
typedef long long LL;
typedef long double LD;
#define LP(i, a, b) for (int i = int(a); i < int(b); i++)
#define LPE(i, a, b) for (int i = int(a); i <= int(b); i++)
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef vector<vector<PII> > WAL;
typedef vector<vector<int> > SAL;
#define Ep 1e-8
#define INF 1e9
#define LINF 1e18

int const MaxSize = 300000 + 5;

int n;
bool x[MaxSize];

vector<int> ans;
int main() {
	ios_base::sync_with_stdio(false);
	//freopen("/Users/george/A_1.in", "r", stdin);
	string s;
	cin >> s;

	LP(i, 0, s.length() - 1)
	{
		if (s[i] == 'A' && s[i + 1] == 'C') {
			cout << "Yes";
			return 0;
		}
	}

	cout << "No";

	return 0;

}


Measured memory_bytes: 256
main :: IO ()
main = do
    str <- getLine
    let inputs = [read word :: Int | word <- words str]
    let a = head inputs
    let b = head $ tail inputs
    let c = head $ tail $ tail inputs

    putStrLn $ unwords $ map show $ order a b c

order :: Int -> Int -> Int -> [Int]
order a b c
    | a <= b = if b <= c then [a, b, c]
                else if c <= a then [c, a, b]
                  else [a, c, b]
    | otherwise = if a <= c then [b, a, c]
                    else if c <= b then [c, b, a]
                      else [b, c ,a]

Measured memory_bytes: 3548
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007;



int main() {
    int N;
    cin>>N;
    vector<int> a(N),ans(N);
    rep(i,N){
        cin>>a.at(i);
    }
    for(int i=N;i>=1;i--){
        int count=0;
        for(int j=2;j*i<=N;j++){
            count+=ans.at(i*j-1);
        }
        if(abs(count-a.at(i-1))%2==1)ans.at(i-1)=1;
    }
    int M=0;
    rep(i,N){
        M+=ans.at(i);
    }
    cout<<M<<endl;
    rep(i,N){
        if(ans.at(i))cout<<i+1<<endl;
    }
}

Measured memory_bytes: 2432
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N;
  cin >> N;
  vector<ll> A(N), B(N);
  rep(i, N) cin >> A[i];
  rep(i, N) cin >> B[i];
  priority_queue<pair<ll, int>> q;
  rep(i, N) q.push({B[i], i});
  ll ans = 0;
  while(!q.empty()) {
    auto ele = q.top(); q.pop();
    ll val = ele.first;
    int i = ele.second;
    if(val-A[i] < B[(i+N-1)%N]+B[(i+1)%N]) continue;
    ll rem = (val-A[i])%(B[(i+N-1)%N]+B[(i+1)%N]);
    ll cur = (val-A[i])/(B[(i+N-1)%N]+B[(i+1)%N]);
    ans += cur;
    B[i] = A[i]+rem;
    if(rem) q.push({B[i], i});
  }
  bool ok = true;
  rep(i, N) if(A[i] != B[i]) ok = false;
  cout << (ok ? ans : -1) << endl;
  return 0;
}


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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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 ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;

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

ll ngcd(vector<ll> a) {
  ll res = a[0];
  for(ll i=1; i<a.size() && res!=1; i++) res = gcd(a[i], res);
  return res;
}
ll nlcm(vector<ll> a){
  ll res = a[0];
  for(ll i=1; i<a.size(); i++) res = lcm(a[i], res);
  return res;
}
bool is_prime(ll n) {
  if(n < 2) return false;
  for (ll i = 2; i * i <= n; i++) if (n % i == 0) return false;
  return true;
}
ll digsum(ll n) {
  ll res=0;
  while(n) res += n%10, n /= 10;
  return res;
}
ll digcnt(ll n){
  ll res=0;
  while(n) res++, n /= 10;
  return res;
}
vector<ll> divisor(ll n) {
  vector<ll> res;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      res.push_back(i);
      if (i != n / i) res.push_back(n / i);
    }
  }
  sort(res.begin(), res.end());
  return res;
}
map<ll, ll> prime_factor(ll n) {
  map<ll, ll> res;
  for (ll i = 2; i * i <= n; i++) {
    while (n % i == 0) ++res[i], n /= i;
  }
  if (n != 1) res[n] = 1;
  return res;
}

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll a,b,c,d; cin>>a>>b>>c>>d;
  // cまたはdで割り切れる
  ll ans=b-a+1;
  ll l=lcm(c,d);
  ll x=b/c+b/d-max(0LL,b/l);
  a--;
  x-=a/c+a/d-max(0LL,a/l);
  ans-=x;
  cout<<ans<<endl;
}

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

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

int main()
{
    long long N, M;
    cin >> N >> M;
    rep(i, M){
        long long tmp;
        cin >> tmp;
        N -= tmp;
    }
    if(N <= -1){
        cout << -1 << endl;
    }else{
        cout << N << endl;
    }
}



Measured memory_bytes: 3648
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();

		Set<Integer> set = new TreeSet<>();
		set.add(A);
		set.add(B);
		set.add(C);

		if(set.size()==2) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

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

int main() {
  int n;
  cin >> n;
  
  ll ans=0;
  for(int i=1; i<n-1; i++){
   for(int j=i+1; j<n; j++){
     for(int k=j+1; k<n+1; k++){
       int I=i,J=j,K=k;
       int x=1;
       for(int l=I; l>1; l--){
         if(I%l==0 && J%l==0 && K%l==0){
           x*=l;
           break;
         }
       }
       ans+=x*6;
     }
   }
  }
  
  for(int i=1; i<n+1; i++){
   for(int j=1; j<n+1; j++){
     if(i==j) continue;
       int I=i,J=j;
       int x=1;
       for(int l=I; l>1; l--){
         if(I%l==0 && J%l==0){
           x*=l;
           break;
         }
       }
      ans+=x*3;
   }
  }
  

  
    for(int i=1; i<n+1; i++){
       ans+=i;
   }
  cout << ans << endl;
}


Measured memory_bytes: 3596
#include<bits/stdc++.h> 
using namespace std;
typedef long long ll;
template<typename T1,typename T2> bool chmin(T1 &a,T2 b){if(a<=b)return 0; a=b; return 1;}
template<typename T1,typename T2> bool chmax(T1 &a,T2 b){if(a>=b)return 0; a=b; return 1;}


//a^n (mod m)
const ll mod = 1e9+7;
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}


signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(20);

    ll n,k;
    cin>>n>>k;
    ll ans = 0;
    ll num[k+1]={};
    for(ll i=k;i>=1;i--){
        num[i] += modpow(k/i,n);
        num[i] %= mod;
        ans += (num[i]*i)%mod;
        ans %= mod;
        for(ll j=1;j*j<=i;j++){
            if(i%j==0){
                num[j] += mod - num[i];
                if(j!=1 && j*j!=i) num[i/j] += mod - num[i];
                num[j] %= mod;
                num[j/i] %= mod;
            }
        }
        //cerr << i << " " << num[i] << " "<< ans << endl;
    }
    cout << ans << endl;
}


Measured memory_bytes: 4400
N = int(input())
sho_list = [0] * (N + 1)
for n in range(1, N + 1):
    for j in range(n, N + 1, n):
        sho_list[j] += 1
ans = 0
for k in range(1, N + 1):
    ans += k * sho_list[k]
print(ans)

Measured memory_bytes: 151732
/**
 * @author Video Vocabulary
 * @date 2020-08-02 18:32:17
 */
#include <bits/stdc++.h>

using namespace std;

void solve() {
    
}

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

    int x;
    cin >> x;
    cout << (x<30?"No":"Yes") << endl;
}


Measured memory_bytes: 3636
N = int(input())
def num2alpha(N):
    if N<=26:
        return chr(64+N)
    elif N%26==0:
        return num2alpha(N//26-1)+chr(90)
    else:
        return num2alpha(N//26)+chr(64+N%26)
ans = num2alpha(N)
a = ans.lower()
print(a)

Measured memory_bytes: 9088
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please


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


	int N, D;
	cin >> N >> D;
	int d[500000];
	rep(i, N) cin >> d[i];
	int A[500000];
	A[0] = D;
	rep(i, N - 1) A[i + 1] = min(A[i], abs(A[i] - d[i]));
	ll B[500000];
	B[N - 1] = 0;
	rep1(i, N - 1) {
		if (B[N - i] * 2 + 1 >= d[N - i]) B[N - i - 1] = B[N - i] + d[N - i];
		else B[N - i - 1] = B[N - i];
	}
	int Q;
	cin >> Q;
	rep(i, Q) {
		int q;
		cin >> q;
		q--;
		if (A[q] <= B[q]) co("NO");
		else co("YES");
	}
	
	Would you please return 0;
}

Measured memory_bytes: 9728
#include <bits/stdc++.h>
typedef long long int ll;
#define rep(i,n) for (int i = 0; i< (n); i++)
#define Rep(i,n,m) for (int i = (n); i< (m); i++)
#define Sort(a) sort(a.begin(), a.end())
#define Reverse(a) reverse(a.begin(), a.end())
using namespace std;

int main() {
    long double a, b, c, d;
    
    string s = "Yes";
    
    cin>>a>>b>>c;
    
    
    //if(sqrt(a) + sqrt(b) < sqrt(c)) s ="Yes";
    
    d = (c-(a+b)) / 2;
    
    
    
    if(sqrt(a*b)<d) s ="Yes";
    
    else s = "No";
    
   // cout<<sqrt(a)<<endl<<sqrt(b)<<endl<<sqrt(c)<<endl;
    
    cout<<s<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
namespace FAST_IO
{
	template<typename T> void read(T &a)
	{
		a=0;
		int f=1;
		char c=getchar();
		while(!isdigit(c))
		{
			if(c=='-')
			{
				f=-1;
			}
			c=getchar();
		}
		while(isdigit(c))
		{
			a=a*10+c-'0';
			c=getchar();
		}
		a=a*f;
	}
	template <typename T> void write(T a)
	{
		if(a<0)
		{
			a=-a;
			putchar('-');
		}
		if(a>9)
		{
			write(a/10);
		}
		putchar(a%10+'0');
	}
	template <typename T> void writeln(T a)
	{
		write(a);
		puts("");
	}
}
int main()
{
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b&&b==c)
	{
		cout<<"Yes";
	}
	else
	{
		cout<<"No";
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <string>
#include <map>
#include <list>
#include <vector>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define LargeNum 1000000007

int main(){
    int K, A, B;
    bool flag = false;
    cin >> K >> A >> B;
    for (int i = A; i <= B; i++){
        if (i % K == 0) flag = true;
    }
    if (flag) cout << "OK" << endl;
    else cout << "NG" << endl;
    return 0;
}


Measured memory_bytes: 3592
// 標準入力から一行を読み取り、指定の型に変換する
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

// 標準入力から一行を読み取り、空白文字で分割し、各要素を指定の型に変換する関数
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}

fn main() {
    let nk: Vec<usize> = read_vec();
    let n = nk[0];
    let k = nk[1];
    let p: Vec<f64> = read_vec();

    let mut max = 0.0_f64;

    // 期待値ベクター
    let mut e_vec = vec![0.0; n];
    let mut e_sum = 0.0_f64;

    for i in 0..n
    {
        let mut sum: f64 = 0.0;
        sum = (p[i] * (p[i] + 1.0)) / 2.0;

        e_vec[i] = sum / p[i];
        e_sum += e_vec[i];

        if i >= k
        {
            e_sum -= e_vec[i - k];
        }

        if e_sum > max { max = e_sum; }
    }

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


Measured memory_bytes: 10996
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <vector>
#include <iomanip>
#define ALL(x) (x).begin(), (x).end()
#define dll(x) scanf("%I64d",&x)
#define xll(x) printf("%I64d\n",x)
#define sz(a) int(a.size())
#define all(a) a.begin(), a.end()
#define rep(i,x,n) for(int i=x;i<n;i++)
#define repd(i,x,n) for(int i=x;i<=n;i++)
#define pii pair<int,int>
#define pll pair<long long ,long long>
#define gbtb ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MSC0(X) memset((X), '\0', sizeof((X)))
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define eps 1e-6
#define gg(x) getInt(&x)
#define db(x) cout<<"== [ "<<x<<" ] =="<<endl;
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll powmod(ll a,ll b,ll MOD){ll ans=1ll;while(b){if(b&1)ans=ans*a%MOD;a=a*a%MOD;b>>=1;}return ans;}
inline void getInt(int* p);
const int maxn=1010;
const int inf=0x3f3f3f3f;
/*** TEMPLATE CODE * * STARTS HERE ***/
int bj[maxn];
int ans=0;
std::vector<int> v[maxn];
	int n;int m;
void dfs(int x,int cnt)
{
	if(cnt==n)
	{
		ans++;
		return ;
	}
	for(auto k:v[x])
	{
		if(!bj[k])
		{
			bj[k]=1;
			dfs(k,cnt+1);
			bj[k]=0;
		}
	}
}
int main()
{
	//    freopen("C:\\Users\\DH_M\\Desktop\\code_io\\in.txt.txt","r",stdin);
	//    freopen("C:\\Users\\DH_M\\Desktop\\code_io\\out.txt.txt","w",stdout);
	gbtb;
	cin>>n;
	cin>>m;
	int a,b;
	repd(i,1,m)
	{
		cin>>a>>b;
		v[a].pb(b);
		v[b].pb(a);
	}
	bj[1]=1;
	dfs(1,1);
	cout<<ans<<endl;
	
    return 0;
}

inline void getInt(int* p) {char ch;do {ch = getchar();} 
while (ch == ' ' || ch == '\n');if (ch == '-') {*p = -(getchar() - '0');
while ((ch = getchar()) >= '0' && ch <= '9') {*p = *p * 10 - ch + '0';}}
else {*p = ch - '0';while ((ch = getchar()) >= '0' && ch <= '9') 
{*p = *p * 10 + ch - '0';}}}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    long k = Long.parseLong(sc.next());
    int q = Integer.parseInt(sc.next());
    long[] score = new long[n];
    for(int i = 0; i < n; i++) {
      score[i] = k - q;
    }
    for(int i = 0; i < q; i++) {
      score[Integer.parseInt(sc.next())-1] += 1;
    }
    int count = 0;
    for(int i = 0; i < n; i++) {
      if(score[i] > 0) System.out.println("Yes");
      else System.out.println("No");
    }
  }
}


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

signed main()
{
  int n;
  int now_light = 0;
  int cnt = 0;
  vector<int> a;

  cin >> n;
  for (int i = 1; i <= n; i++) {
    int tmp;
    cin >> tmp;
    a.push_back(tmp - 1);
  }

  while (true) {
    if (now_light == 1) {
      cout << cnt << endl;
      break;
    }
    if (cnt >= n) {
      cout << -1 << endl;
      break;
    }
    cnt++;
    now_light = a[now_light];
  }

  return (0);
}


Measured memory_bytes: 892
a = [list(map(int, input().split())) for _ in range(3)]
n = int(input())
b = [int(input()) for _ in range(n)]
b_set = set(b)

f = [[0] * 3 for _ in range(3)]

for i in range(3):
    for j in range(3):
        if a[i][j] in b_set:
            f[i][j] = 1

for i in range(3):
    if all(f[i]):
        print('Yes')
        exit()

for i in zip(*f):
    if all(i):
        print('Yes')
        exit()

if f[0][0] == 1 and f[1][1] == 1 and f[2][2] == 1:
    print('Yes')
    exit()

if f[0][2] == 1 and f[1][1] == 1 and f[2][0] == 1:
    print('Yes')
    exit()

print('No')

Measured memory_bytes: 38384
#include <atcoder/convolution>
#include <bits/stdc++.h>
using namespace std;
using namespace atcoder;
typedef long long ll;

int main() {
	cin.tie(nullptr); ios_base::sync_with_stdio(false);
	int n, m; cin >> n >> m;
	vector<ll> a(n), b(m);
	for (int i = 0; i < n; ++i) cin >> a[i];
	for (int i = 0; i < m; ++i) cin >> b[i];
	vector<ll> c = convolution<998244353>(a, b);
	for (int i = 0; i < n+m-2; ++i) cout << c[i] << " ";
	cout << c[n+m-2] << "\n";
	return 0;
}

Measured memory_bytes: 27240
#include <bits/stdc++.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

using namespace std;

typedef long long int lli;

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;}

#ifdef LOCAL
	#define eprintf(...) printf(__VA_ARGS__)
#else 
	#define eprintf(...) 1
#endif

#define ROUNDUP(a, b) 		( ((a) + ((b) - 1) ) / b)
#define SET_ZERO(a)	 		( memset((a), 0, sizeof(a)))
#define SET_NUM_ARRAY(a,b)	( memset((a), b, sizeof(a)))
//#define int long long int //dont forget to change int to signed

int main() {
	int a, b;
	scanf("%d %d", &a, &b);
	int d = b - a;
	printf("%d\n", d*(d-1)/2-a);
	return 0;
}


Measured memory_bytes: 256
#if loc||local
#define _GLIBCXX_DEBUG
#endif

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

#define rep(i,n) for(ll i=0;i<ll(n);++i)
#define repr(i,n) for(ll i=ll(n);i-->0;)
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
template<class T>void dump(T&& t){cerr<<t<<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...));}

signed main(){

  int x;
  cin>>x;
  cout<<(x^1)<<endl;

}

Measured memory_bytes: 3580
#!/usr/bin/python
# -*- coding: utf-8 -*-

import numpy as np

def int_mtx(N):
    x = []
    for _ in range(N):
        x.append(list(map(int,input().split())))
    return np.array(x)

N = int(input())
a = list(map(int,input().split()))

ans = 0

for i in range(0,(N+1)//2):
    if a[2*i]%2 == 1:
        ans += 1

print(ans)


Measured memory_bytes: 27124
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

//INSERT ABOVE HERE
signed main(){
  Int n,m;
  cin>>n>>m;
  vector<Int> a(n),b(m);
  for(Int i=0;i<n;i++) cin>>a[i];
  for(Int i=0;i<m;i++) cin>>b[i];
  Int x=0,y=0;
  for(Int i=0;i<n;i++) x+=a[i];
  for(Int i=0;i<m;i++) y+=b[i];
  cout<<x*y<<endl;
  return 0;
}



Measured memory_bytes: 4416
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll h,w,n;
    cin>>h>>w>>n;
    ll a;
    ll ans[h][w];
    ll hidx=0;
    ll widx=0;
    for(int i=0;i<n;i++){
        cin>>a;
        while(a){
            ans[hidx][widx]=i+1;
            if(hidx%2==0){
                widx++;
                if(widx==w){
                    widx--;
                    hidx++;
                }
            }
            else{
                widx--;
                if(widx==-1){
                    widx++;
                    hidx++;
                }
            }
            a--;
            //cout << a<<endl;
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cout << ans[i][j]<<" ";
        }
        cout << endl;
    }
    return 0;
}

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

int main(){
int num[9][9];
for(int n=1; n<=9; n++)
 for(int m =n; m<=9; m++)
  num[n][m]=n*m;

for(int n=1; n<=9; n++)
  for(int m=1; m<=9; m++){
   if(n>m)
    cout << n << "x" << m << "=" << num[m][n] <<endl; 
   else
    cout << n << "x" << m << "=" <<num[n][m] <<endl; 
  }
    return 0;
}

Measured memory_bytes: 1116
#include<bits/stdc++.h>
#define V vector
#define VI vector<int>
#define VVI vector<vector<int>>
#define rep(i,n) for(int i=0;i<(n);i++)
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(void){
    int N,sum=0;
    cin>>N;
    VI L(N);
    rep(i,N)cin>>L[i];
    sort(L.begin(),L.end());
    rep(i,N-1)sum+=L[i];
    if(sum>L[N-1])cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}




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


int main() {
  int H;
  cin >> H;
  int N;
  cin >> N;
  vector <int> vec(N);
  for (int i=0;i<N; i++) {
    cin >> vec.at(i) ;
  }
  int sum=0;
  for (int j=0;j<N; j++) {
    sum += vec.at(j);
  }
  if (sum >=H) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No " << endl;
  }
 
}

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

using namespace std;
typedef long long int ll;

const ll p = 31;
const ll N = 1e9 +1;


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

  ll n;
  cin>>n;
  ll ans = ((n-1)*(n))/2;
  cout<<ans;


}

Measured memory_bytes: 256
#include <stdio.h>

#define max(X, Y) ((X) > (Y) ? (X) : (Y))
#define min(X, Y) ((X) < (Y) ? (X) : (Y))
#define abs(X) ((X) < 0 ? (X) * -1 : (X))

int main()
{
    int h, w;
    int dat[30][30];
    int i, j, k, l;
    int ans = 100000000;

    scanf("%d %d", &h, &w);
    for (i = 0; i < h; i++) {
        for (j = 0; j < w; j++) {
            scanf("%d", &dat[i][j]);
        }
    }

    for (i = 0; i < h; i++) {
        for (j = 0; j < w; j++) {
            int tmp = 0;

            for (k = 0; k < h; k++) {
                for (l = 0; l < w; l++) {

                    tmp += min(abs(i - k), abs(j - l)) * dat[k][l];

                }
            }
            ans = min(ans, tmp);
        }
    }

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

    return 0;
}



Measured memory_bytes: 1932
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S,T;
  cin>>S>>T;
    
  int counter=0;
  
  if(S[0]==T[0])++counter;
  if(S[1]==T[1])++counter;
  if(S[2]==T[2])++counter;
  cout<<counter<<endl;
}

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

void dfs(int v, vector<long long> & dist, const vector<vector<pair<int, int>>> &Es){
    for (auto &edge : Es[v]){
        int u = edge.first;
        if (dist[u] != -1) continue;
        dist[u] = dist[v] + edge.second;
        dfs(u, dist, Es);
    }
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<vector<pair<int, int>>> Es(N + 1, vector<pair<int, int>>());
    for (int i = 1; i != N; ++i){
        int a, b, c;
        cin >> a >> b >> c;
        Es[a].emplace_back(make_pair(b, c));
        Es[b].emplace_back(make_pair(a, c));
    }
    int Q, K;
    cin >> Q >> K;
    vector<long long> dist(N + 1, -1);
    dist[K] = 0;
    dfs(K, dist, Es);
    for (int q = 0; q != Q; ++q){
        int x, y;
        cin >> x >> y;
        cout << dist[x] + dist[y] << '\n';
    }
    return 0;
}

Measured memory_bytes: 12800
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader input = new BufferedReader(new InputStreamReader(System.in));

        while(true){
		String input_line = input.readLine();

		String[] number = input_line.split(" ");

		// 1???until_num?????°
		int until_num = Integer.parseInt(number[0]);

		// 1???until_num??????????????°?????????????¶?????????°
		int num_sum = Integer.parseInt(number[1]);
		 if(until_num ==0&&num_sum==0){
	        	break;
	        }
		int count=0;
		for(int first_num=1; first_num<=until_num ; first_num++){
			for(int second_num=first_num+1; second_num<=until_num; second_num++){
				for(int third_num=second_num+1; third_num<=until_num; third_num++){
					int three_sum=first_num+second_num+third_num;
					if(three_sum==num_sum){
						count++;
					}
				}
			}

		}
		System.out.println(count);
        }

}

}

Measured memory_bytes: 25312