akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
//#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

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;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
void vin(Vi &v){REP(i,0,(v).size()) cin>>v[i];}
void vin(Vi &v,Vi &v2){REP(i,0,(v).size()) cin>>v[i]>>v2[i];}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
void accum(Vi &v){REP(i,1,(v).size()) v[i]+=v[i-1];}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

signed main(){
  int a,b;
  cin>>a>>b;
  cout<<6-a-b<<endl;
    return 0;
}


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

int cnt = 0;

void BubbleSort(int *A, int N) {
	bool flg = true;
	while (flg) {
		flg = false;
		for (int i = N - 1; i >= 1; --i) {
			if (A[i] < A[i - 1]) {
				int tmp;
				tmp = A[i];
				A[i] = A[i - 1];
				A[i - 1] = tmp;
				flg = true;
				cnt++;
			}
		}
	}
}

int main() {
	int N; cin >> N;
	int A[110];

	for (int i = 0; i < N; ++i) cin >> A[i];

	BubbleSort(A, N);

	for (int i = 0; i < N; ++i) {
		cout << A[i];
		if (i != N - 1) cout << " ";
	}
	cout << endl;

	cout << cnt << endl;
}


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

int main()
{
	string str1,str2;
	cin>>str1>>str2;

	int m=str1.length(),n=str2.length();
	int dp[m+1][n+1];

	memset(dp,0,sizeof(dp));

	for(int i=1;i<=m;i++)
	{
		for(int j=1;j<=n;j++)
		{
			if(str1[i-1]==str2[j-1])
				dp[i][j]=1+dp[i-1][j-1];

			else
				dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
		}
	}

	string ans="";

	int i=m,j=n;
	while(i>0 && j>0)
	{
		if(str1[i-1]==str2[j-1])
		{
			ans=str1[i-1]+ans;;
			i--;
			j--;
		}

		else
		{
			if(dp[i-1][j]>dp[i][j-1])
				i--;

			else
				j--;
		}
	}

	cout<<ans;
	return 0;
}

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

vector<Int> ps(2e5,0);
vector<Int> pr,c;

map<Int, Int> sq;

template<typename T> 
map<T, Int> factorize(T x){
  map<T, Int> res;
  for(Int i:pr){
    while(x%i==0){
      x/=i;
      res[i]++;
    }
    if(x<i) break;
  }
  if(sq.count(x)) res[sq[x]]+=2,x=1;
  if(x!=1) res[x]++;
  return res;
}

//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  vector<Int> s(n);
  for(Int i=0;i<n;i++) cin>>s[i];
  
  for(Int i=2;i<(Int)ps.size();i++){
    if(ps[i]) continue;
    if(i<=4000){
      pr.emplace_back(i);
      c.emplace_back(i*i*i);
    }
    sq[i*i]=i;
    for(Int j=i+i;j<(Int)ps.size();j+=i) ps[j]=1;
  }
  
  for(Int i=0;i<n;i++){
    for(Int j=0;j<(Int)c.size();j++){
      if(s[i]<c[j]) break;
      while(s[i]%c[j]==0) s[i]/=c[j];
    }
  }

  using MP = map<Int, Int>;
  vector<MP> vm(n);
  map<MP, Int> m;
  for(Int i=0;i<n;i++)
    if(s[i]!=1) m[vm[i]=factorize(s[i])]++;
  
  auto comp=[&](MP a){
    MP b;
    for(auto p:a)
      b[p.first]=3-p.second;
    return b;
  };
  Int ans=0;
  for(Int i=0;i<n;i++) ans|=s[i]==1;
  set<MP> used;
  for(Int i=0;i<n;i++){
    //for(auto p:vm[i]) cout<<i<<":"<<p.first<<" "<<p.second<<endl;
    if(used.count(vm[i])) continue;
    auto a=vm[i];
    auto b=comp(a);
    ans+=max(m.count(a)?m[a]:0LL,m.count(b)?m[b]:0LL);
    
    used.emplace(a);
    used.emplace(b);
  }
  
  cout<<ans<<endl;
  return 0;
}



Measured memory_bytes: 116352
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <cmath>
#include <cstring>
#include <string>
#define pb push_back
#define mod 1000000007
using namespace std;
typedef long long int ll;

int main(void){
  ll n,x;
  vector<ll> a;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>x;
    a.pb(x);
  }
  sort(a.begin(),a.end(),greater<ll>());
  ll t1,t2;
  t1=t2=0;
  for(int i=0;i<n-1;i++){
    if(t1==0){
      if(a[i]==a[i+1]) t1=a[i++];
    }
    else if(t2==0){
      if(a[i]==a[i+1]) t2=a[i++];
    }
    else break;
  }
  cout<<t1*t2<<endl;
  return 0;
}


Measured memory_bytes: 1400
// _______  _____  _______  _____  _______ _______ _____ _______ _____ _    _ _______ 
// |       |     | |  |  | |_____] |______    |      |      |      |    \  /  |______ 
// |_____  |_____| |  |  | |       |______    |    __|__    |    __|__   \/   |______ 
//
//  _____   ______  _____   ______  ______ _______ _______ _______ _____ __   _  ______   /
// |_____] |_____/ |     | |  ____ |_____/ |_____| |  |  | |  |  |   |   | \  | |  ____  / 
// |       |    \_ |_____| |_____| |    \_ |     | |  |  | |  |  | __|__ |  \_| |_____| .  
//
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define FOR(I,A,B) for(int I = int(A); I < int(B); ++I)
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin()) //ai>=v  x is sorted
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin()) //ai>v  x is sorted
ll gcd(ll a,ll b){if(a<b)swap(a,b);if(a%b==0)return b;return gcd(b,a%b);}
ll lcm(ll a,ll b){ll c=gcd(a,b);return ((a/c)*(b/c)*c);}//saisyo kobaisu
const ll INF=1e18+7;
const ll MOD=1e9+7;

class UnionFind{
public:
	vector<int> par;
	//0-indexed
	void init(int n = 1) {
		par.resize(n);
		for (int i = 0; i < n; ++i) par[i] = i;
	}
	int root(int x = 1){
		if(par[x]==x)return x;
		else{
			return par[x] = root(par[x]);
		}
	}
	void unite(int x = 1,int y = 1){
		x = root(x);
		y = root(y);
		if(x==y)return;
		else par[x] = y;
	}
};

int main(){
	int N , M;
	cin >> N >> M;
	UnionFind uf;
	uf.init(N+1);
	vector<int> lang[M+1];
	FOR(i,1,N+1){
		int k;
		cin>>k;
		FOR(j,0,k){
			int la;
			cin >> la;
			lang[la].push_back(i);
		}
	}
	FOR(i,1,M+1){
		FOR(j,0,lang[i].size()-1){
			uf.unite(lang[i][j],lang[i][j+1]);
		}
	}
	set<int> se;
	FOR(i,1,N+1){
		se.insert(uf.root(i));
	}
	if(se.size()==1){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
}


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

int main() {
	int64_t A, V, B, W, T;
	cin >> A >> V >> B >> W >> T;
	if ((V-W) * T >= abs(A-B)) {
		std::cout << "YES" << '\n';
	} else {
		std::cout << "NO" << '\n';
	}
}


Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    string s;
    cin >> s;
    for(int i=0;i<s.length();++i) {
        if(s[i] =='7') {
            cout << "Yes\n";
            return 0;
        }
    }
    cout << "No\n";
    return 0;
}


Measured memory_bytes: 3652
N = int(input())
S = input()
r = 0
g = 0
b = 0
ans = 0

for i in range(N):
    if S[i] == 'R':
        r += 1
        ans += g * b
        for j in range(i-1,-1,-1):
            if 2*j-i >= 0 and set([S[j],S[2*j-i]]) == set(['G','B']):
                ans -= 1
    elif S[i] == 'G':
        g += 1
        ans += b * r
        for j in range(i-1,-1,-1):
            if 2*j-i >= 0 and set([S[j],S[2*j-i]]) == set(['B','R']):
                ans -= 1
    else:
        b += 1
        ans += r * g
        for j in range(i-1,-1,-1):
            if 2*j-i >= 0 and set([S[j],S[2*j-i]]) == set(['R','G']):
                ans -= 1

print(ans)

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

//24
typedef long long ll;

int main() {
	double h, w, x , y;
	cin >> h >> w >> x >> y;
	if (x == h / 2.0 && y == w / 2.0) {
		cout << fixed << setprecision(12) << (double) (h * w) / 2 << " " << 1; 
	}else {
		double ans = (double) (h * w) / 2.0;
		cout << fixed << setprecision(12) << ans << " " <<  0;
	}
	//((1 + 2)  * x)/ 2  
}

//3,0        2,3
     //.      2,2
    
//0,1
//0,0        0,2


Measured memory_bytes: 3752
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <utility>
#include <set>
#include <map>
#include <deque>
#include <stack>

using namespace std;

void out(int n, vector<int> res) {
     for (int i = 0; i < n; ++i)
         cout << (res[i] ? 'S' : 'W');
     cout << "\n";
     
    cin >> n;
     exit(0);
}
 
int main() {
    int n;
    string s;
    cin >> n >> s;
    s += s[0];
    s += s[1];
    vector<int> res(n+2, 0);
    for (res[0] = 0; res[0] <= 1; ++res[0])
        for (res[1] = 0; res[1] <= 1; ++res[1]) {
            for (int i = 1; i <= n; ++i)
                res[i+1] = res[i-1] ^ (s[i] == 'x') ^ res[i] ^ 1;
            if (res[n] == res[0] && res[n+1] == res[1])
               out(n, res);
        }
    cout << "-1\n";
    
    cin >> n;
    return 0;
}


Measured memory_bytes: 1408
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cassert>
#include <functional>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
using namespace std;
using llong = long long;

//===
template<class OperatorMonoid,
         class Merge = function<OperatorMonoid(OperatorMonoid, OperatorMonoid)> >
struct DualSegmentTree {
    int sz, height;
    const OperatorMonoid e;
    const Merge merge_operator;
    vector<OperatorMonoid> lazy;
 
    DualSegmentTree(OperatorMonoid e, const Merge &h):
        e(e), merge_operator(h) {};
    void init(int nmemb) {
        sz = nmemb;
        lazy.assign(sz << 1, e);

        height = -1;
        while (nmemb) nmemb >>= 1, height++;
    };
 
    inline void propagate(int k) {
        if (k >= sz || lazy[k] == e) return;
        lazy[(k << 1) | 0] = merge_operator(lazy[(k << 1) | 0], lazy[k]);
        lazy[(k << 1) | 1] = merge_operator(lazy[(k << 1) | 1], lazy[k]);
        lazy[k] = e;
    };
    void push_down(int k) {
        for (int i = height; i > 0; i--) {
            propagate(k >> i);
        }
    };
 
    // [l, r)
    void update(int l, int r, OperatorMonoid op) {
        l += sz; r += sz;
        push_down(l);
        push_down(r - 1);
         
        while (l < r) {
            if (l & 1) lazy[l] = merge_operator(lazy[l], op), l++;
            if (r & 1) --r, lazy[r] = merge_operator(lazy[r], op);
 
            l >>= 1;
            r >>= 1;
        }
    };
 
    OperatorMonoid operator [] (int k) {
        k += sz;
        push_down(k);
        return lazy[k];
    };
};
//===

llong n, d, a;
vector<llong> x;
vector<llong> h;
vector<pair<llong, llong> > p;
DualSegmentTree<llong> dst(0, [](auto l, auto r){return l + r;});

llong zip(llong t) {
    return upper_bound(x.begin(), x.end(), t) - x.begin() - 1;
};

int main() {
    cin >> n >> d >> a;
    for (int i = 0; i < n; i++) {
        llong X, H;
        cin >> X >> H;
        x.push_back(X);
        h.push_back(H);
        p.push_back({X, H});
    }
    dst.init(n);

    sort(x.begin(), x.end());
    sort(p.begin(), p.end());

    for (int i = 0; i < n; i++) {
        dst.update(zip(x[i]), zip(x[i]) + 1, p[i].second);
    }

    llong ans = 0;

    for (int i = 0; i < n; i++) {
        if (dst[i] <= 0) continue;
        
        llong f = (dst[i] + a - 1) / a;
        ans += f;

        dst.update(zip(x[i]), zip(x[i] + 2 * d) + 1, -a * f);
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 10320
/*************************************************************************
    > File Name: aoj0189.cpp
    > Author:    WArobot 
    > Blog:      http://www.cnblogs.com/WArobot/ 
    > Created Time: 2017??´06???20??\ ????????? 14??¶54???14?§?
 ************************************************************************/

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

#define ll long long
const int MAX_N = 100;
const int INF = 1e9;
int G[MAX_N][MAX_N];
int m , n;

void init(){
	for(int i = 0 ; i < MAX_N ; i++){
		for(int j = 0 ; j < MAX_N ; j++){
			if( i == j )	G[i][j] = 0;
			else			G[i][j] = INF;
		}
	}
}
void floyd(){
	for(int k = 0 ; k < n ; k++){
		for(int i = 0 ; i < n ; i++){
			for(int j = 0 ; j < n ; j++){
				if( G[i][j] > G[i][k] + G[k][j] ){
					G[i][j] = G[i][k] + G[k][j];
				}
			}
		}
	}
}
void solve(){
	ll sum , num = -1 , maxsum = INF;
	for(int i = 0 ; i < n ; i++){
		sum = 0;
		for(int j = 0 ; j < n ; j++)	sum += (ll)G[i][j];
		if( maxsum > sum ){
			num = i ,	maxsum = sum;
		}
	}
	printf("%lld %lld\n",num , maxsum);
}
int main(){
	int u , v , cost;
	while(~scanf("%d",&m) && m){
		init();		n = -1;
		for(int i = 0 ; i < m ; i++){
			scanf("%d%d%d",&u,&v,&cost);
			G[u][v] = G[v][u] = cost;
			n = max( n , u );	n = max( n , v );
		}
		n++;		
		floyd();
		solve();
	}
	return 0;
}

Measured memory_bytes: 3232
def gcd(a, b):
	while b % a:
		b %= a
		a, b = (b, a)
	return a

C = [int(i) for i in input().split()]
m = min(C)
for i in range(3):
	if C[i]%2:
		print(0)
		exit()
	C[i] -= m

C.sort()
if C[2] == 0:
	print(-1)
	exit()
t = C[2]
for c in C:
	t = gcd(t, c)
ans = 0
while not t%2:
	ans += 1
	t //= 2
print(ans)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define modulo 998244353
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 100000000000000000

template <typename T>
struct segtree{
	//元データx[i]はv[n+i]
	//v[i]の親はv[i/2],子はv[i*2]とv[i*2+1]
	vector<T> v;
	int n;
	
	const T init_value = Inf;
	
	segtree(vector<T> &x){
		n=1;
		while(true){
			if(n>=x.size())break;
			n*=2;
		}
		v.resize(2*n,init_value);
		
		for(int i=0;i<x.size();i++){
			v[n+i]=x[i];
		}
		for(int i=n-1;i>=0;i--){
			v[i]=func(v[i*2],v[i*2+1]);
		}
	}

	void update(int x,T val){
		x+=n;
		v[x]=val;
		while(true){
			x=(x)/2;
			v[x]=func(v[x*2],v[x*2+1]);
			if(x<=0)break;
		}
	}
	
	//区間[l,r)におけるクエリ処理
	T query(int l,int r){
		T res = init_value;
		if(l>=r)return res;
		l+=n;r+=n;
		while(true){
			if(l%2==1){
				res=func(v[l],res);
				l++;
			}
			if(r%2==1){
				res=func(v[r-1],res);
				r--;
			}
			if(l>=r)break;
			l/=2;r/=2;
		}
		return res;
	}
	T func(T a,T b){
		return min(a,b);
	}
	
	void show(){
		int n = 1;
		for(int i=1;i<v.size();i++){
			for(int j=0;j<n;j++){
				if(j!=0)cout<<' ';
				cout<<v[i+j];
			}
			cout<<endl;
			i+=n-1;
			n*=2;
		}
	}
	
};

int main(){
	
	int N,M;
	cin>>N>>M;
	
	vector<vector<int>> V(M,vector<int>());
	
	for(int i=0;i<M;i++){
		int l,r,c;
		cin>>l>>r>>c;
		l--;r--;
		V[i].push_back(l);
		V[i].push_back(r);
		V[i].push_back(c);
	}
	
	sort(V.begin(),V.end());
	
	vector<long long> A(N,Inf);
	
	segtree<long long> seg(A);
	seg.update(0,0);
	
	for(int i=0;i<M;i++){
		int l = V[i][0];
		int r = V[i][1];
		long long c = V[i][2];
		long long R = seg.query(r,r+1);
		long long m = seg.query(l,r+1);
		seg.update(r,min(R,m+c));
	}
	
	if(seg.query(N-1,N)==Inf){
		cout<<-1<<endl;
	}
	else{
		cout<<seg.query(N-1,N)<<endl;
	}
	
	
    return 0;
}


Measured memory_bytes: 8448
n=int(input())
s=input()

r_cnt=s.count("R")
g_cnt=s.count("G")
b_cnt=s.count("B")

ans=r_cnt*g_cnt*b_cnt

for i in range(n):
    for d in range(n):
        j=i+d
        k=j+d
        if k>=n:break
        if s[i]!=s[j] and s[j]!=s[k] and s[k]!=s[i]:
            ans -= 1

print(ans)

Measured memory_bytes: 9144
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N, M;
	cin >> N >> M;

	vector<vector<int>> grid(N, vector<int>(M));
	for (int i = 0; i < N; i++) for (int j = 0; j < M; j++) cin >> grid[i][j];
	for (int i = 0; i < N; i++) for (int j = 0; j < M; j++) grid[i][j]--;

	struct dat {
		vector<int> mem;
		int size = 0;
	};

	auto select = [&](int mx) {

		vector<dat> D(M);
		vector<int> ind(N);
		bool res = true;
		queue<int> que;
		for (int i = 0; i < N; i++) que.emplace(i);
		while (!que.empty()) {

			int now = que.front();
			que.pop();
			if (ind[now] == M) {
				res = false;
				break;
			}

			auto &Dnow = D[grid[now][ind[now]]];
			if (Dnow.size != -1) {
				if (Dnow.size < mx) {
					Dnow.size++;
					Dnow.mem.emplace_back(now);
				}
				else {
					Dnow.size = -1;
					for (const auto &e : Dnow.mem) que.emplace(e);
					que.emplace(now);
				}
			}
			else que.emplace(now);
			ind[now]++;
		}

		return res;

	};

	for (int num = N - 1; num >= 0; num--) {
		if (!select(num)) {
			cout << num + 1 << endl;
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 1280
// Ref : https://book.mynavi.jp/ec/products/detail/id=35408

#include <iostream>
#include <vector>
#include <stack>

using namespace std;
static const int NMAX = 100000;
static const int NIL = -1;

int n, group[NMAX];
vector<int> G[NMAX];

void depthFirstSearch(int ix, int id) {
	int y;
	stack<int> S;
	S.push(ix);
	while (!S.empty()) {
		ix = S.top(); S.pop();
		for (unsigned int j = 0; j < G[ix].size(); j++) {
			y = G[ix][j];
			if (group[y] == NIL) {
				group[y] = id;
				S.push(y);
			}
		}
	}
}

void classifyID() {
	int id = 0;
	for (int i = 0; i < n; i++) {
		if (group[i] == NIL) {
			depthFirstSearch(i, id);
			id++;
		}
	}
}

int main(void) {
	int m, x, y;

	cin >> n >> m;
	for (int i = 0; i < n; i++) group[i] = NIL; // initialize group list
	for (int i = 0; i < m; i++) { // create graph in linked list representation
		cin >> x >> y;
		G[x].push_back(y);
		G[y].push_back(x);
	}

	classifyID();

	cin >> n;

	for (int i = 0; i < n; i++) {
		cin >> x >> y;
		if ((group[x] != NIL) && (group[y] != NIL) && (group[x] == group[y]))
			cout << "yes";
		else
			cout << "no";
		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 8864
import sys
sys.setrecursionlimit(4100000)

import math

import logging

logging.basicConfig(level=logging.DEBUG)

logger = logging.getLogger(__name__)


def resolve():
    S = [x for x in sys.stdin.readline().split()][0]  # 文字列 一つ
    # N = [int(x) for x in sys.stdin.readline().split()][0]  # int 一つ
    # N, D = [int(x) for x in sys.stdin.readline().split()]  # 複数int
    # h_list = [int(x) for x in sys.stdin.readline().split()]  # 複数int

    # grid = [list(sys.stdin.readline().split()[0]) for _ in range(N)]  # 文字列grid
    # v_list = [int(sys.stdin.readline().split()[0]) for _ in range(N)]
    # grid = [[int(x) for x in sys.stdin.readline().split()]
    #         for _ in range(N)]  # int grid

    logger.debug('{}'.format([]))

    if S[0] == S[1] == S[2]:
        print('No')
    else:
        print('Yes')


if __name__ == "__main__":
    resolve()

# AtCoder Unit Test で自動生成できる, 最後のunittest.main は消す
# python -m unittest template/template.py で実行できる
# pypy3 -m unittest template/template.py で実行できる
import sys
from io import StringIO
import unittest


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

    def test_入力例_1(self):
        input = """ABA"""
        output = """Yes"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """BBA"""
        output = """Yes"""
        self.assertIO(input, output)

    def test_入力例_3(self):
        input = """BBB"""
        output = """No"""
        self.assertIO(input, output)


Measured memory_bytes: 6716
S = input()
T = input()

if S == T:
    print('Yes')
else:
    Flag = True
    for i in range(len(S)):
        if Flag:
            #print(i)
            S = S[1:] + S[0]
            if S == T:
                print('Yes')
                Flag = False
            else:
                if i == len(S) - 1:
                    print('No')
                    Flag = False
                else:
                    continue

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


int main()
 {
     int n,x,count=0,sum=0;
     cin>>n>>x;
     int a[n];
     for(int i=0;i<n;i++){
         cin>>a[i];
         sum=sum+a[i];
         if(sum<=x){
             count++;
         }
     }
     cout<<count+1<<endl;
 
     
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define PN cout << endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (n-1); i >= (int)(m); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - (a)) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - (a)) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return


ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
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; }


/*
vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}
*/

/*
ll ncr[100][100];
ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

ll npr[100][100]={};
ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

ll nHr(int n,int r){ret nCr(n+r-1,r);}
*/

///////////////////////////////////////////////////////////////////////////

int main(){

    string s;
    cin >> s;

    if(sz(s) & 1){
	No;
	ret 0;
    }
    rep(i,0,sz(s)-1){
	if(s[i] != 'h' || s[i+1] != 'i'){
	    No;
	    ret 0;
	}
	i++;
    }
    Yes;
    return  0;
}


Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
using namespace std;
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();}
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX/10;

int main() {
	int n;
	while(cin >> n, n) {
		int k;
		cin >> k;
		vs cards(n);
		REP(i, n) {
			cin >> cards[i];
		}

		vi num;
		REP(i, n) {
			if(i < k) {
				num.push_back(1);
			} else {
				num.push_back(0);
			}
		}
		sort(ALL(num));

		set<string> ans;
		do {
			vs choice;
			REP(i, n) {
				if(num[i]) {
					choice.push_back(cards[i]);
				}
			}

			sort(ALL(choice));
			do {
				string s;
				REP(i, k) {
					s += choice[i];
				}
				ans.insert(s);
			} while(next_permutation(ALL(choice)));
		} while(next_permutation(ALL(num)));

		cout << ans.size() << endl;
	}
}

Measured memory_bytes: 1484
from collections import defaultdict

def gcd(a, b):
    if a < b:
        return gcd(b, a)
    while b > 0:
        a, b = b, a % b
    return a

def sieve_of_eratosthenes(n):
    sieve = [0] * (n+1)
    sieve[0] = 1 #素数でない
    sieve[1] = 1 #素数でない
    for i in range(2, n):
        if sieve[i] == 0:
            for j in range(2, n // i + 1):
                sieve[i * j] = i
    return sieve

def factorize_by_sieve_of_eratosthenes(x, sieve):
    factor = defaultdict(int)
    while sieve[x]:
        factor[sieve[x]] += 1
        x //= sieve[x]
    factor[x] += 1
    return factor

n = int(input())
a_list = list(map(int, input().split()))
a_list.sort()

sieve = sieve_of_eratosthenes(a_list[-1])
pairwise = True
setwise = True
primes = set()
x = a_list[0]
for a in a_list:
    x = gcd(x, a)
    if pairwise and a != 1:
        factor = set(factorize_by_sieve_of_eratosthenes(a, sieve).keys())
        if not primes.isdisjoint(factor):
            pairwise = False
        else:
            primes |= factor

if pairwise:
    print("pairwise coprime")
elif x == 1:
    print("setwise coprime")
else:
    print("not coprime")




Measured memory_bytes: 197248
#include <bits/stdc++.h>
#define int long long
using namespace std;
int m = 1000000007;

int32_t main()
{
    int k,x;
    cin>>k>>x;
    if(k*500 >= x)
        cout<<"Yes"<<'\n';
    else
        cout<<"No"<<'\n';
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#define m 1000000007
using namespace std;
int a[100017];
int num[100017];
int n;

void slove(){
    if(n%2){
        if(num[0]!=1){
             printf("0\n");
             return ;
        }
      for(int i=2;i<n;i+=2){
        if(num[i]!=2){
            printf("0\n");
            return ;
        }
      }
       int res=1;
       int t=n/2;
       while(t--){
        res=((res%m)*2)%m;
       }
        printf("%d\n",res%m);

    }else{
        if(num[0]!=0){
            printf("0\n");
             return ;
        }
        for(int i=1;i<n;i+=2){
            if(num[i]!=2){
                printf("0\n");
                return ;
            }
        }
        int res=1;
       int t=n/2;
       while(t--){
        res=((res%m)*2)%m;
       }
        printf("%d\n",res%m);
    }
}

int main(){
    int temp;
    memset(num,0,sizeof(num));
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>temp;
        num[temp]++;
    }
    slove();
    return 0;
}

Measured memory_bytes: 640
/*  .　　∧_∧
   　（ ´・ω・)
   　//＼￣￣旦＼
   ／/ ※ ＼＿＿＿＼
   ＼＼ 　※ 　※ 　※ ヽ
   　 ＼ヽ-＿_＿--＿__ヽ*/

#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define sort(v,n) sort(v,v+n);
#define vsort(v) sort(v.begin(),v.end());
#define vvsort(v) sort(v.begin(),v.end(),greater<int>());
#define ll long long
#define pb(a) push_back(a)
#define fi first
#define se second
#define inf 999999999
using namespace std;
typedef pair<int,int> p;
typedef pair<ll,ll> lp;
typedef priority_queue<int> pq;
typedef priority_queue<int,vector<int>,greater<int> > rpq;
bool is_uruu(int y) {
        return y % 4 == 0 && (y % 100 != 0 || y % 400 == 0);
}
const ll MOD=1e9+7;
const double PI=acos(-1.0);
//-------------------------------------------------------------------------------------------------------------------------------------------//
int n,sitai;
int a[100000];
int cp[100000];
int main(){
        cin>>n>>sitai;
        for(int i=0; i<n; i++) {
                cin>>a[i];
                cp[i]=a[i];
        }
        ll ans=0;
        if(a[0]>sitai) {
                ans+=a[0]-sitai;
                a[0]=sitai;
        }
        for(int i=0; i<n-1; i++) {
                if(a[i]+a[i+1]>sitai) {
                        a[i+1]-=(a[i]+a[i+1])-sitai;
                }
        }
        for(int i=1; i<n; i++) {
                ans+=cp[i]-a[i];
        }
        cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include<stdio.h>

int main() {

   int S[100000], T[50000];
   int i, j, n, q, rig, mid;
   int c = 0;
   int lef = 0;

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

   scanf("%d", &q); 
   for (i = 0; i < q; i++) {
      scanf("%d", &T[i]);
   }

   rig = n;
   for (i = 0; i < q; i++) {
      while (lef < rig) {
         mid = (lef + rig) / 2;
         if (S[mid] == T[i]) {
            c++;
            break;
         } else if (T[i] < S[mid]) {
            rig = mid;
         } else {
            lef = mid + 1;
         }
      }
      rig = n;
      lef = 0;
   }
   printf("%d\n", c);

   return 0;
}


Measured memory_bytes: 2260
#include <cstdio>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

const double PI = acos(-1.0);

class Point
{
public:
    double y, x;
    Point(){
        y = x = 0.0;
    }
    Point(double y0, double x0){
        y = y0;
        x = x0;
    }
    Point operator+(const Point& p) const{
        return Point(y + p.y, x + p.x);
    }
    Point operator-(const Point& p) const{
        return Point(y - p.y, x - p.x);
    }
    Point operator*(double a) const{
        return Point(y * a, x * a);
    }
    Point operator/(double a) const{
        return Point(y / a, x / a);
    }
    double length() const{
        return sqrt(y * y + x * x);
    }
    double dist(const Point& p) const{
        return sqrt(pow(y - p.y, 2) + pow(x - p.x, 2));
    }
    double dot(const Point& p) const{
        return y * p.y + x * p.x; // |a|*|b|*cos慮
    }
    double cross(const Point& p) const{
        return x * p.y - y * p.x; // |a|*|b|*sin慮
    }
};

int main()
{
    int n;
    double r, theta;
    cin >> n >> r >> theta;
    theta *= PI / 180;

    vector<Point> p(n);
    for(int i=0; i<n; ++i)
        cin >> p[i].x >> p[i].y;

    vector<vector<double> > dist(n, vector<double>(n));
    for(int i=0; i<n; ++i){
        for(int j=0; j<n; ++j){
            dist[i][j] = p[i].dist(p[j]);
        }
    }

    vector<vector<vector<bool> > > access(n, vector<vector<bool> >(n, vector<bool>(n, false)));
    for(int i=0; i<n; ++i){
        for(int j=0; j<n; ++j){
            for(int k=0; k<n; ++k){
                if(i == k)
                    continue;
                double angle = acos((p[i] - p[j]).dot(p[k] - p[i]) / (p[i] - p[j]).length() / (p[k] - p[i]).length());
                if(angle < theta)
                    access[i][j][k] = true;
            }
        }
    }

    vector<vector<double> > dp(n, vector<double>(n, -1.0));
    for(int i=1; i<n; ++i)
        dp[i][0] = r - dist[0][i];

    int ret = 0;
    for(;;){
        double maxRest = -1.0;
        for(int i=0; i<n; ++i){
            for(int j=0; j<n; ++j){
                maxRest = max(maxRest, dp[i][j]);
            }
        }
        if(maxRest < 0){
            cout << ret << endl;
            return 0;
        }

        vector<vector<double> > next(n, vector<double>(n, -1.0));
        for(int i=0; i<n; ++i){
            for(int j=0; j<n; ++j){
                for(int k=0; k<n; ++k){
                    if(access[i][j][k])
                        next[k][i] = max(next[k][i], dp[i][j] - dist[i][k]);
                }
            }
        }
        dp.swap(next);

        ++ ret;
    }

    return 0;
}

Measured memory_bytes: 972
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int H,W;
  cin >> H >> W;
  for (int i=0;i < W + 2;i++) {
    cout << "#";  
  }
  cout << endl;
  
  vector<string> vec(H);
  for (int i=0;i < H;i++) {
    cout << "#";
    cin >> vec.at(i);
    cout << vec.at(i);
    cout << "#";
    cout << endl;
  }
  
  for (int i=0;i < W + 2;i++) {
    cout << "#";  
  }
  cout << endl;
  
}

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

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

  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> a[i];

  bool flag = true;
  int cnt = 0;
  int dummy;

  while(flag){

    flag = false;

    for(int i = n-1; i > 0; i--){
      if(a[i] < a[i-1]){
        dummy = a[i];
        a[i]  = a[i-1];
        a[i-1]  = dummy;
        cnt++;
        flag = true;
      }
    }
  }

  for(int i = 0; i < n; i++){
    if(i) cout << " ";
    cout << a[i];
  }

  cout << endl;
  cout << cnt << endl;

  return 0;

}



Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline bool chmin(A &a,const B &b){if(a>b){a=b;return true;}else{return false;}}
template<typename A,typename B>inline bool chmax(A &a,const B &b){if(a<b){a=b;return true;}else{return false;}}

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

Measured memory_bytes: 3612
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <vector>
#include <limits.h>
#include <math.h>

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

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;

const ll INF = LONG_LONG_MAX;

typedef ll Weight;
struct Edge {
    int src, dst;
    Weight weight;
    Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
    return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;

bool WarshallFloyd(const Matrix &g,Matrix &dist) {
    int n = (int)g.size();
    dist = g;
    repeat(k, n) repeat(i, n) repeat(j, n) {
        if(dist[i][k] == INF || dist[k][j] == INF) continue;
        if (dist[i][j] > dist[i][k] + dist[k][j]) {
            dist[i][j] = dist[i][k] + dist[k][j];
        }
    }
    bool negative_cycle = false;
    repeat(i,n){
        negative_cycle |= (dist[i][i] < 0);
    }
    return !negative_cycle;
}
int main() {
    // insert code here...    return 0;
    //////
    // input from txt
    /*
     std::ifstream in("input.txt");
     std::cin.rdbuf(in.rdbuf());
     std::ofstream out("output.txt");
     std::cout.rdbuf(out.rdbuf());
     ////
     */
    int H,W;
    cin >> H >> W;
    Matrix g(10,Array(10));
    
    repeat(i, 10){
        repeat(j, 10){
            cin >> g[i][j];
        }
    }
    
    Matrix dist;
    WarshallFloyd(g, dist);
    ll ans = 0;
    repeat(i, W*H){
        int A;
        cin >> A;
        if(A<0) continue;
        ans += dist[A][1];
    }
    cout << ans << endl;
    return 0;
}



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

using namespace std;

int main(){
  int n;
  
  while(cin >> n){
    
    int line[n+1];
    line[0]=1;
    
    for(int i=1;i <= n;i++)
      {
	line[i] = line[i-1] + i;
      }
    cout << line[n] << endl;
  }
  return 0;
}


Measured memory_bytes: 3124
using System;
public class Hello{
    public static void Main(){
        var s = Console.ReadLine();
        var t = Console.ReadLine();
        
        var start = new int[26];
        var end = new int[26];
        
        for(var i = 0;i < 26;i++){
            start[i] = -1;
            end[i] = -1;
        }
        
        for(var i = 0;i < s.Length;i++){
            int a = s[i] - 'a';
            int b = t[i] - 'a';
            if(start[a] != -1 || end[b] != -1){
                if(start[a] != b || end[b] != a){
                    Console.WriteLine("No");
                    return;
                }
            }else{
                start[a] = b;
                end[b] = a;
            }
        }
        Console.WriteLine("Yes");
    }
}


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

int main() {
  int n, ans = 0;
  cin >> n;
  vector<int> l(n);
  for (int i = 0; i < n; i++)
  {
    cin >> l[i];
  }
  for (int i = 0; i < n; i++)
  {
    for (int j = i; j < n; j++)
    {
      for (int k = j; k < n; k++)
      {
        if (l[i]!=l[j] && l[j]!= l[k] && l[k]!=l[i])
        {
          if (l[i]+l[j]-l[k]>0 && l[j]+l[k]-l[i]>0 && l[k]+l[i]-l[j]>0)
          {
            ans++;
          }
          
        }
        
      }
      
    }
    
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3628
#include <stdio.h>

int main(void){

  int m,n,A[100][100],b[100],c[100];

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

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

  for(int i = 0; i < n; i++){
    c[i]=0;
    for(int  j = 0; j < m; j++){
    c[i] += A[i][j]*b[j];
    }
  }
  
  for(int i = 0; i < n; i++){
    printf("%d\n" ,c[i]);
  }
  return 0;
}



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

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
        #define eprintf(...) 42
#endif

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define all(x) (x).begin(),(x).end()
#define foreach(u,v) for(auto (u) : (v))
#define pb push_back
#define mp make_pair
#define mt make_tuple

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

const int inf = 1e9;
const ll linf = 1LL<<60;
const ll mod = 1e9 + 7;
const double eps = 1e-9;

/*
*/

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

  cout << min(b/a, c) << endl;

  return 0;
}


Measured memory_bytes: 256
n = gets.chomp.to_i
 
a = []
 
n.times{|i| a << gets.chomp.chars}
 
x = a.first
 
(1...n).each do |i|
  t = a[i]
  x.delete_if do |c|
    if t.include? c
      t.delete_at(t.find_index(c))
      false
    else
      true
    end
  end
end
 
x = x.sort
puts x.reduce {|sum, s| sum + s }

Measured memory_bytes: 1788
#include<cstdio>
int n,a[1000],cnt,ans;
int main()
{
	scanf("%d",&n);
	while(n) {a[++cnt]=n%10;n/=10;ans+=a[cnt];}
	if(ans==1&&cnt>1) printf("%d\n",10);else printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

map<string,int> mp;

signed main()
{
    int N; cin>>N;
    REP(i,N){
        string s; cin>>s;
        mp[s]++;
    }
    int M; cin>>M;
    REP(i,M){
        string t; cin>>t;
        mp[t]--;
    }
    
    int ans=0;
    for(auto it=mp.begin();it!=mp.end();it++){
        ans=max(ans,it->second);
    }
    cout<<ans<<endl;
 
}


Measured memory_bytes: 256
a,b,x = gets.chomp.split(" ").map(&:to_i)

if x * 2 >= a * a * b then
  y = x / (a*a).to_f
  puts Math.atan(2*(b-y)/a.to_f) * 180 / Math::PI.to_f
else
  y = 2 * x / (a * b).to_f
  puts Math.atan(b/y.to_f) * 180 / Math::PI.to_f
end





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

int n,m,ans,mark[305],cnt[305],g[305][305];

int main(){
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=m;j++)
          scanf("%d",&g[i][j]);
    }
    ans=n+1;
    for(int i=1;i<=m;i++){
        memset(cnt,0,sizeof(cnt));
        for(int j=1;j<=n;j++){
            int k=1;
            while(mark[g[j][k]]==1) k++;
            cnt[g[j][k]]++;
        }
        int mx=0;
        for(int j=1;j<=m;j++)
          if(cnt[j]>cnt[mx]) mx=j;
        ans=min(ans,cnt[mx]);
        mark[mx]=1;
    }
    printf("%d\n",ans);
    return 0;
}

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

int d[10] = {0};

bool contains(int a, int k){
    while(a > 0){
        for(int i=0;i<k;++i){
            if(a % 10 == d[i])return true;
        }
        a /= 10;
    }
    return false;
}

int main(){
    int n, k;
    cin >> n >> k;
    for(int i=0;i<k;++i){
        cin >> d[i];
    }

    while(contains(n, k)){
        n++;
    }

    cout << n << endl;

    return 0;
}


Measured memory_bytes: 256
import std.algorithm, std.conv, std.range, std.stdio, std.string;

void main()
{
  auto n = readln.chomp.to!long;
  auto s = readln.chomp.to!long;
  writeln(calc(n, s));
}

auto calc(long n, long s)
{
  if (n < s) return -1;
  else if (n == s) return n+1;

  auto m = n-s;
  long[] d;
  foreach (i; 1..m.nsqrt+1) {
    if (m % i == 0) {
      d ~= i;
      if (m/i != i) d ~= m/i;
    }
  }
  d.sort();

  foreach (di; d) {
    auto b = di+1, k = n, t = 0L;
    while (k > 0) {
      t += k % b;
      k /= b;
    }
    if (t == s) return b;
  }

  return -1;
}

pure T nsqrt(T)(T n)
{
  import std.algorithm, std.conv, std.range, core.bitop;
  if (n <= 1) return n;
  T m = 1 << (n.bsr / 2 + 1);
  return iota(1, m).map!"a * a".assumeSorted!"a <= b".lowerBound(n).length.to!T;
}


Measured memory_bytes: 380
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n, x;
    cin >> n >> x;
    vector<int> D(n+1);
    D[0] = 0;    
    for(int i=0;i<n;i++){
        int a;
        cin >> a;
        D[i+1] = D[i] + a;
    }
    int count = 0;
    for(int i = 0; i <= n ; i++){
        if (D[i] <= x)
        {
            count++;
        }
    }
    cout << count <<endl;
    return 0;
}

Measured memory_bytes: 256
# include <cstdio>
# include <cstring>
# include <cstdlib>
# include <iostream>
# include <vector>
# include <queue>
# include <stack>
# include <map>
# include <set>
# include <cmath>
# include <algorithm>
using namespace std;
# define lowbit(x) ((x)&(-x))
# define pi acos(-1.0)
# define eps 1e-9
# define MOD 1024523
# define INF 1000000000
# define mem(a,b) memset(a,b,sizeof(a))
# define FOR(i,a,n) for(int i=a; i<=n; ++i)
# define FO(i,a,n) for(int i=a; i<n; ++i)
# define bug puts("H");
# define lch p<<1,l,mid
# define rch p<<1|1,mid+1,r
# define mp make_pair
# define pb push_back
typedef pair<int,int> PII;
typedef vector<int> VI;
# pragma comment(linker, "/STACK:1024000000,1024000000")
typedef long long LL;
int Scan() {
    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 Out(int a) {
    if(a<0) {putchar('-'); a=-a;}
    if(a>=10) Out(a/10);
    putchar(a%10+'0');
}
const int N=200005;

LL a[N];
int main ()
{
    int n, T;
    scanf("%d%d",&n,&T);
    FOR(i,1,n) scanf("%lld",a+i);
    LL sum=0;
    FOR(i,1,n) {
        LL t=a[i]+T;
        if (i<n&&t>a[i+1]) t=a[i+1];
        sum+=t-a[i];
    }
    printf("%lld\n",sum);
    return 0;
}


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

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

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

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,pii> ppii;

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

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

int main(){

    bool flag=false;
    ll ans=0,sum=1;

    ll n;
    cin>>n;

    ll p = n;
    vector<ll> divis1;
    vector<ll> dsmall;
    vector<ll> dlarge;

    rep1(i,2,sqrt(p)+1){
        if(p%i==0){
            dsmall.emplace_back(i);
            if(i!=p/i)dlarge.emplace_back(p/i);
        }
    }
    dlarge.emplace_back(p);

    p=n-1;
    rep1(i,2,sqrt(p)+1){
        if(p%i==0){
            dsmall.emplace_back(i);
            if(i!=p/i)dlarge.emplace_back(p/i);
        }
    }
    dlarge.emplace_back(p);

    
    for(ll can:dsmall){
        ll c=n;
        while(c%can==0)c/=can;
        if(c%can==1){
            ans++;
            //db(can);ln;
        }
    }

    for(ll can:dlarge){
        if(n%can==1){
            ans++;
            //db(can);ln;
        }
    }


    cout<<ans+1<<endl;
    //cout <<fixed<<setprecision(16)<< << endl;
    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;

    return 0;
}


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

int main() {

	int X;
	cin >> X;
	int a=X;
	int K=1;

	while( (a % 360) != 0) {
		a += X;
		K++;
	}

	printf("%d", K);
	return 0;
}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
typedef long long int LL;
typedef unsigned long long int ULL;
using namespace std;

// 插入此處

LL a[100005];
LL suffix[100005];

int main() {
    int n;
    cin >> n;
    for (int i = 0; i <= n; i++) {
        cin >> a[i];
    }
    if (n == 0 && a[0] == 1) {
        cout << 1 << endl;
        return 0;
    }
    if (a[0] != 0) {
        cout << -1 << endl;
        return 0;
    }
    for (int i = n; i >= 0; i--) {
        suffix[i] = suffix[i + 1] + a[i];
    }
    LL ans = 1;
    LL nodes = 1;
    for (int i = 1; i <= n; i++) {
        if (nodes * 2 <= suffix[i]) {
            nodes *= 2;
        } else {
            nodes = suffix[i];
        }
        // printf("depth = %d, nodes = %lld, suffix = %lld\n", i, nodes, suffix[i]);
        ans += nodes;
        nodes -= a[i];
        if (nodes < 0) {
            ans = -1;
            break;
        }
    }
    if (nodes != 0) {
        ans = -1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 5196