akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
int main()
{
    int a,b;
    while(~scanf("%d %d",&a,&b))
    {
        if(a==2||b==2)
            printf("No\n");
        else if(a==1)
        {
            if(b==3||b==5||b==7||b==8||b==10||b==12)
                printf("Yes\n");
            else
                printf("No\n");
        }
        else if(a==3)
        {
            if(b==5||b==7||b==8||b==10||b==12)
                printf("Yes\n");
            else
                printf("No\n");
        }
        else if(a==5)
        {
            if(b==7||b==8||b==10||b==12)
                printf("Yes\n");
            else
                printf("No\n");
        }
        else if(a==7)
        {
            if(b==8||b==10||b==12)
                printf("Yes\n");
            else
                printf("No\n");
        }
        else if(a==8)
        {
            if(b==10||b==12)
                printf("Yes\n");
            else
                printf("No\n");
        }
        else if(a==10)
        {
            if(b==12)
                printf("Yes\n");
            else
                printf("No\n");
        }
        else if(a==12)
            printf("No\n");
        else if(a==4)
        {
            if(b==6||b==9||b==11)
                printf("Yes\n");
            else
                printf("No\n");
        }
        else if(a==6)
        {
            if(b==9||b==11)
                printf("Yes\n");
            else
                printf("No\n");
        }
        else if(a==9)
        {
            if(b==11)
                printf("Yes\n");
            else
                printf("No\n");
        }
        else if(a==11)
            printf("No\n");
    }
    return 0;
}


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

using namespace std;

typedef short sho;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;
typedef string str; 
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll; 
typedef pair<ld,ld> pld;
 
typedef vector<int> vi; 
typedef vector<ll> vl; 
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<pld> vpd;

#define STDIO
#define MP make_pair 
#define FF first
#define SS second
#define sz(x) (int)x.size()
#define begin(x) (x).begin() 
#define end(x) (x).end()
#define rbegin(x) (x).rbegin()
#define rend(x) (x).rend()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define PF push_front 
#define PB push_back
#define PP push
#define lb lower_bound 
#define ub upper_bound
#define INF 2e9

inline void checkmin(int &x, int y){x = min(x, y);}
inline void checkmax(int &x, int y){x = max(x, y);}

const int Maxn=1e5+10;

int x,y,a,b,c;
ll p[Maxn],q[Maxn],r[Maxn];

int main() 
{
	#ifndef STDIO
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /* start code */
    cin>>x>>y>>a>>b>>c;
    int tmp1=x,tmp2=y;
    vi v1,v2,v3;
    for(int i=0;i<a;i++) cin>>p[i],v1.PB(p[i]);
    for(int i=0;i<b;i++) cin>>q[i],v2.PB(q[i]);
    for(int i=0;i<c;i++) cin>>r[i],v3.PB(r[i]);
    sort(rall(v1));
    sort(rall(v2));
    sort(rall(v3));
    ll add=0;
    for(int i=0;i<sz(v3);i++)
    {
    	if(x==0&&y==0) break;
    	if(x==0&&v3[i]<=v2[y-1]) break;
    	if(y==0&&v3[i]<=v1[x-1]) break;
    	if(x&&y&&v3[i]<=v1[x-1]&&v3[i]<=v2[y-1]) break;
    	int val1,val2;
    	if(x==0) val1=INF;
    	else val1=v1[x-1];
    	if(y==0) val2=INF;
    	else val2=v2[y-1];
    	add+=v3[i]-min(val1,val2);
    	if(val1==min(val1,val2)) x--;
    	else y--;
	}
	ll sum=0;
	for(int i=0;i<tmp1;i++) sum+=v1[i];
	for(int i=0;i<tmp2;i++) sum+=v2[i];
	cout<<add+sum<<endl;
    /* end code */
	return 0;
}

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    for (int i = 0; i < N; ++i) {
        cin >> A[i];
    }
    for (int i = K; i < N; ++i) {
        if (A[i] > A[i - K]) {
            cout << "Yes\n";
        } else {
            cout << "No\n";
        }
    }
    return 0;
}

Measured memory_bytes: 3988
// by Balloons
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#define mpr make_pair
#define debug() puts("okkkkkkkk")
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)

using namespace std;

typedef long long LL;

const int inf = 1e9;
const double pi=acos(-1); 

signed main(){
	int a,b,h,m;scanf("%d%d%d%d",&a,&b,&h,&m);
	double thetaH = 2*pi/12*h + 2*pi/12/60*m;
	double thetaM = 2*pi*m/60;
	double th = fabs(thetaH - thetaM);
//	if(th > pi/2.0)th = 2*pi - th;
//	printf("%f\n",th);
	printf("%.11f\n",sqrt(a*a+b*b-2.0*a*b*cos(th)));

	return 0;
}



Measured memory_bytes: 4176
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define F first
#define S second
#define PB push_back
#define MAXN 100005
#define MP make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define debug(x) cout << '>' << #x << ':' << x << endl;
#define SQ(a) (a)*(a)
#define nl "\n"
#define INF std::numeric_limits<int>::max()
using namespace std;
using namespace __gnu_pbds;
typedef tree<int,null_type,less<int>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
ll mod=1e9+7;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	ll n;
	cin>>n;
	ll a[n] = {0};
	ll cmn_cnt[63] = {0};
	for(ll i = 0 ; i < n ; i++) {
		cin>>a[i];
	}
	ll ans = 0;
	for(ll i = 0; i <= 60;i++){
		ll cnt=0;
		for(int j = 0; j < n; j++){
				cnt+=(a[j]>>i)&1;
		}
		int temp =(1LL<<i)%mod;
		ans=(ans+(((temp*cnt)%mod)*(n-cnt))%mod)%mod;
	}
	cout<<ans%mod<<nl;
	return 0;
}






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

int main(){
  int A,B,C,K,cnt=0;
  cin >> A >> B >> C >> K;
  if(K>=A){
    K -= A;
    cnt += A;
  }else if(K<A){
    cnt += K;
    K = 0;
  }
  if(K>=B){
    K -= B;
  }else if(K<B){
    K = 0;
  }
  if(K>=C){
    cnt -= C;
  }else if(K<C){
    cnt -= K;
    K = 0;
  }
  cout << cnt << endl;
}


Measured memory_bytes: 3632
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <algorithm>

#define int long long
#define MOD7 1000000007
#define MOD9 1000000009

#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(a) (a).begin(), (a).end()

using namespace std;

int nextInt() {int a; cin >> a; return a;}
char nextChar() {char a; cin >> a; return a;}
double nextDouble() {double a; cin >> a; return a;}
string nextString() {string a; cin >> a; return a;}

void inputVector(vector<int> &v, int &n) {rep(i,n){v.push_back(nextInt());}}
void inputVector(vector<double> &v, int &n) {rep(i,n){v.push_back(nextDouble());}}
void inputVector(vector<string> &v, int &n) {rep(i,n){v.push_back(nextString());}}

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

	string pos = "Positive";
	string neg = "Negative";
	string zero = "Zero";

	if (a > 0) {
		cout << pos << endl;
		return 0;
	}

	if (a <= 0 && b >= 0) {
		cout << zero << endl;
		return 0;
	}

	if ((b - a) % 2) {
		cout << pos << endl;
	} else {
		cout << neg << endl;
	}

	return 0;
}


Measured memory_bytes: 384
N , A, B = map(int, input().split())
if (B-A)%2 == 0:
    ans = (B-A)//2
else:
    if A-1>N-B:
        ans = N-B+(B-A)//2+1
    else:
        ans = A-1+(B-A)//2+1
print(ans)


Measured memory_bytes: 38492
s = input()

if len(s)%2 == 0:
    count = 0
    for i in range(len(s)//2):
        
        if s[i] != s[-i-1]:
            count += 1
    print(count)

else:
    count = 0
    for i in range(len(s)//2):
        
        if s[i] != s[-i-1]:
            count += 1
    print(count)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)

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

	int H;
	int T[10][5];
	while (cin >> H)
	{
		if (H == 0) return 0;

		rep(y, 0, H) rep(x, 0, 5) cin >> T[y][x];

		int ans = 0;
		bool f = true;
		while (f)
		{
			f = false;

			rep(y, 0, H)
			{
				rep(k, 0, 3)
				{
					if (T[y][k] < 0) continue;
					int c = T[y][k];
					int kk = k + 1;
					while (T[y][kk] == c)
					{
						kk++;
						if (kk == 5) break;
					}
					int len = kk - k;
					if (3 <= len)
					{
						ans += len * c;
						//cout << " " << ans << endl;
						rep(ii, k, kk) T[y][ii] = -1;
						f = true;
					}
				}
			}

			rep(x, 0, 5)
			{
				vector<int> t;
				rrep(y, H-1, 0) if (0 <= T[y][x]) t.push_back(T[y][x]);
				rep(y, 0, H) T[y][x] = -1;
				rep(i, 0, t.size()) T[H - 1 - i][x] = t[i];
			}
		}

		cout << ans << endl;
	}
}

Measured memory_bytes: 3152
#include <stdio.h>

typedef unsigned long ulong;

ulong
gcd(ulong a, ulong b)
{
    ulong i, gcd;

    for (gcd = 1, i = 2; (i <= a) && (i <= b); i++) {
        while (1) {
            if (a % i) break;
            if (b % i) break;
            gcd *= i;
            a /= i, b /= i;
        }
    }
    return gcd;
}

ulong
lcm(ulong a, ulong b)
{
    ulong i, lcm;

    for (lcm = 1, i = 2; (1 < a) || (1 < b); i++) {
        while (1) {
            ulong ma = a % i, mb = b % i;
            if ( ma && mb ) break;
            if (!ma) a /= i;
            if (!mb) b /= i;
            lcm *= i;
        }
    }
    return lcm;
}

int
main(int argc, char *argv[])
{
    ulong a, b;

    while (EOF != scanf("%lu %lu\n", &a, &b)) {
        printf("%lu %lu\n", gcd(a, b), lcm(a, b));
    }

    return 0;
}

Measured memory_bytes: 608
//Author : Gaara

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

#define ll long long
#define pb push_back
#define endl "\n"
#define fo(i,n) for(ll i=0;i<n;i++)
#define ro(i,n) for(ll j=n-1;i>=0;i--)
#define vll vector<long long>
#define mod 1000000007

int main(){
    int t=1;
    //cin>>t;
    while(t--){
		int d,t,s;
		cin>>d>>t>>s;
		if(d<=s*t) cout<<"Yes";
		else cout<<"No";
	}
    return 0;
}

Measured memory_bytes: 3600
#pragma GCC optimize("Ofast")
#include<cstdio>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include<set>
using namespace std;
#define INF 1LL<<62
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
//typedef pair<int,int> P;
//typedef pair<pair<int,int>,int> p;
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());
//#define int ll
//http://drken1215.hatenablog.com/entry/2018/08/28/193000

int N;
vector<ll> A;
vector<ll> sum;

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

    cin>>N;
    A.resize(N); sum.resize(N+1); sum[0]=0;
    for(int i=0;i<N;i++) cin>>A[i],sum[i+1]=sum[i]+A[i];

    ll res=1LL<<60;
    for(int i=2;i<=N-2;i++){
        int low=1,high=i;
        while(high-low>1){
            int mid=(low+high)/2;
            if(sum[mid]>=sum[i]-sum[mid]) high=mid;
            else low=mid;
        }
        ll P=sum[low],Q=sum[i]-sum[low];
        ll P2=sum[high],Q2=sum[i]-sum[high];
        ll left_min=min(P,Q),left_max=max(P,Q);
        if(abs(P2-Q2)<abs(P-Q)) left_min=min(P2,Q2),left_max=max(P2,Q2);

        low=i+1,high=N;
        while(high-low>1){
            int mid=(low+high)/2;
            if(sum[mid]-sum[i]>=sum[N]-sum[mid]) high=mid;
            else low=mid;
        }
        ll R=sum[low]-sum[i],S=sum[N]-sum[low];
        ll R2=sum[high]-sum[i],S2=sum[N]-sum[high];
        ll right_min=min(R,S),right_max=max(R,S);
        if(abs(R2-S2)<abs(R-S)) right_min=min(R2,S2),right_max=max(R2,S2);

        ll temp=max(left_max,right_max)-min(left_min,right_min);
        chmin(res,temp);
    }
    cout<<res<<endl;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
int N;
int a[123456],cnt[3];
int main(){
	scanf("%d",&N);
	for(int i=1;i<=N;i++){
		scanf("%d",a+i);
		if(a[i]%4==0)cnt[2]++;
		else if(a[i]%2==0)cnt[1]++;
		else cnt[0]++;
	}
	if(cnt[0]<=cnt[2]||(cnt[0]==cnt[2]+1&&!cnt[1]))puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#include <map>
using namespace std;
int main(){
	int N, M; cin >> N >> M; 
	int INF = 1e9+7; 
	int A[1005] = {}; int B[1005] = {};  
	for(int i = 0; i < M; i++){
		cin >> A[i]; 
		int b; cin >> b; 
		for(int j = 0; j < b; j++){
			int c; cin >> c; 
			B[i] += (1 << (c-1)); 
		}
	}
	int dp[4100] = {}; 
	fill(dp, dp + (1 << N), INF); 
	dp[0] = 0; 
	for(int i = 0; i < (1 << N) - 1; i++){
		for(int j = 0; j < M; j++){
			dp[i | B[j]] = min(dp[i | B[j]], dp[i] + A[j]); 
		}
	}
	if(dp[(1 << N) - 1] == INF) cout << -1 << endl; 
	else cout << dp[(1 << N) - 1] << endl; 
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#define invrep(i,n) for(int64_t i=n-1;i >= 0;i--)
using namespace std;

//////全探索したいときに開けよ////////
vector<vector<int>> fspattern;
vector<int> fspattern_draft;
int fspcnt = 0;

void setfspattern_core(int floor,int number,int degree){
  if(floor==degree){
    fspattern.at(fspcnt) = fspattern_draft;
    fspcnt++;
  }else{
    rep(i,number){
      fspattern_draft.at(floor) = i;
      setfspattern_core(floor+1,number,degree);
    }
  }
}

void setfspattern(int number,int degree){
  fspcnt = 0;
  int64_t array_num = 1;
  rep(i,degree){
    array_num *= number;
  }
  fspattern = vector<vector<int>>(array_num,vector<int>(degree));
  fspattern_draft = vector<int>(degree);
  setfspattern_core(0,number,degree);
}

//////nCrのmodを求めたいときに開けよ/////////
//int64_t univMod = 1000000007;
//int64_t factnum = 100000
//vector<int64_t> modfact(factnum);
//vector<int64_t> modinvfact(factnum);

/*void setmodfact(){
  for(int i=0;i<factnum;i++){
    if(i == 0){
      modfact.at(i) = 1;
    }else{
      modfact.at(i) = (modfact.at(i-1)*i)%univMod;
    }
  }
}

int64_t calcmodpower(int64_t a,int64_t n){
  int64_t res = 1;
  while(n != 0){
    if(n & 1){
      res = (res * a) % univMod;
    }
    a = (a*a) % univMod;
    n = n >> 1;
  }
  return res;
}

int64_t calcinverse(int64_t n){
	return calcmodpower(n,univMod-2);
}

void setmodinvfact(){
  for(int i=0;i<factnum;i++){
    if(i==0){
      modinvfact.at(i) = 1;
    }else{
      modinvfact.at(i) = calcmodpower(modfact.at(i),univMod-2);
    }
  }
}*/


/*
int64_t calcGCD(int64_t a,int64_t b){
	int64_t p = a;
	int64_t q = b;
	int64_t c = a%b;
	while(c != 0){
		p = q;
		q = c;
		c = p%q;
	}
	return q;
}
*/

int main(){
  int n,k;
  cin >> n >> k;
  if(n % k == 0){
    cout << 0 << endl;
  }else{
    cout << 1 << endl;
  }
    
}

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

#define MOD 1000000007

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

int binary_square(int x, int n);

int main() {
  int h, w, k;
  cin >> h >> w >> k;
  vector<string> c;
  vector<vector<int>> col(h);
  vector<int> row(w, 0), tmp(w, 0);
  rep(i, h) {
    string s;
    cin >> s;
    c.push_back(s);
  }
  rep(i, h) {
    rep(j, w) {
      if (c[i][j] == '#') {
        col[i].push_back(j);
        row[j]++;
        tmp[j]++;
      }
    }
  }
  int cnt=0;
  int check = binary_square(2, h+w);
  rep(x, check){
      int xnum = x;
      rep(i, h){
          if(xnum%2){
              int len = col[i].size();
              rep(j, len){
                  tmp[col[i][j]]--;
              }
          }
          xnum >>= 1;
      }
      int sum = 0;
      rep(i, w){
          if(xnum%2){
              sum += tmp[i];
          }
          tmp[i] = row[i];
          xnum >>= 1;
      }
      if(sum==k){
          cnt++;
      }
  }
  cout << cnt << endl;
  return 0;
}

int binary_square(int x, int n) {
  int m = MOD;
  int ans = 1;
  while (n) {
    if (n % 2 == 1) {
      ans = ans * x % m;
    }
    x = x * x % m;
    n >>= 1;
  }
  return ans % m;
}

Measured memory_bytes: 3576
#include <iostream>

using namespace std;

int main() {
  int many;
  int turned_pancake = 0;
  int min_turnd = 1410065407;

  cin >> many;

  int turnd[many];
  for (int i = 0; i < many; i++ ){   
    cin >> turnd[i]; 
  }



  int checkLoop = turnd[0];
  for (int checkNumber = 0;  checkNumber <= checkLoop; checkNumber++){

    turned_pancake = 0;
    int checkTurned[many];
    for (int i = 0; i < many; i++ ){   
      checkTurned[i] = turnd[i]; 
    }

    for (int j = 0; j < checkNumber; j++ ){
      turned_pancake += 1;
      checkTurned[0] -= 1;
    }

    for (int i = 1; i < (many - 1); i++) {

        while(checkTurned[i] > 0) {
      
          // どっちをひっくり返すか。
          if (checkTurned[(i - 1)] > 0 ) { // 一つ前の数値がある。

            // i 盤目 と i-1 盤ん目をひっくり返す。
            checkTurned[(i - 1)] -= 1;
            checkTurned[i] -= 1;
            turned_pancake += 2;

          } else if (checkTurned[(i + 1)] > 0) { // 一つ後ろの数値がある。

            // i 盤目 と i+1 盤ん目をひっくり返す。
            checkTurned[(i + 1)] -= 1;
            checkTurned[i] -= 1;
            turned_pancake += 2;

          } else {

              // i 盤目 と i-1 盤ん目をひっくり返す。
            checkTurned[(i - 1)] -= 1;
            checkTurned[i] -= 1;
            turned_pancake += 2;

          }
        }
    }

    // 端の調整
    if (checkTurned[0] > 0) {
      turned_pancake += checkTurned[0];
      checkTurned[0] = 0;
    }
    if (checkTurned[(many-1)] > 0) {
      turned_pancake += checkTurned[(many-1)];
      checkTurned[(many-1)] = 0;
    }

    // 終わった
    if (min_turnd > turned_pancake) {
        min_turnd = turned_pancake;
    }
  }

  cout << min_turnd << endl;

}


Measured memory_bytes: 3100
#include<iostream>
using namespace std;
int main(){
  int i,j,H,W;
  
  while(1){
    cin >> H >> W;
    if(H==0 && W==0){
      break;
    }
    for(i=0;i<H;i++){
      for(j=0;j<W;j++){
	cout << "#";
      }
      cout << endl;
    }
    cout << endl;
  }
  return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
 
using namespace std;
 
#define forsn(i, s, n) for(int i=s;i<int(n);i++)
#define forn(i, n) forsn(i, 0, n)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
 
typedef long long tint;

const int INF = 1e6;
const long double PI = acos(-1);
 
int main() {
	int n; cin >> n;
	vector<int> v(n), c(n);
	forn(i, n){
		cin >> v[i];
	}
	forn(i, n){
		cin >> c[i];
	}
	int cont = 0;
	forn(i, n){
		if(v[i] > c[i]) cont+=v[i]-c[i];
	}
	cout << cont << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const char ASCII_N_OFFSET = 0x30;
int main() {
    #ifdef DEBUG
    std::ifstream in("/home/share/inputf.in");
    std::cin.rdbuf(in.rdbuf());
    #endif
    string S;
    int K;
    cin >> S;
    cin >> K;
    int ans = 1;
    for(int i = 0; i < K; i++) {
        if(S[i] != '1') {
            ans = S[i] - ASCII_N_OFFSET;
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <algorithm>
#define N_MAX 300000

using namespace std;

bool getudosu(int a){
    if(a%7==1 || a%7==6){
        return true;
    }
    return false;
}

int main(int argc, const char * argv[]) {
    // insert code here...
    
    
    /////////
    //write//
    /////////
    
    while(1){
        int N = 0; cin >> N;
        if(N==1)break;
        int arr[N_MAX];
        
        for(int i=0; i<N; i++){
            arr[i] = 1;
        }
        
        for(int i=2; i<N; i++){
            if(getudosu(i)){
                for(int j=0; i*(j+2)<N; j++){
                    arr[i*(j+2)] = 0;
                }
            }
            else{
                arr[i] = 0;
            }
        }
        
        cout << N << ":";
        bool  output = false;
        for(int i=2; i<N; i++){
            if(arr[i]){
                //getudosusosu
                if(N%i==0){
                    cout << " " << i;
                    output = true;
                }
            }
        }
        if(!output)cout << " " << N;
        cout << endl;
    }
    
    return 0;
}




Measured memory_bytes: 4268
card_A = input()
card_B = input()
card_C = input()
 
def changeTarget(target):
  ans = 'default'
  if(target == 'A'):
    ans = card_A
  elif(target == 'B'):
    ans = card_B
  elif(target == 'C'):
    ans = card_C
 
  return ans
 
target = [card_A, 'A', '']
while target[0] != '':
  if(target[0][0] == 'a'):
    target[2] = 'A'
  elif(target[0][0] == 'b'):
    target[2] = 'B'
  elif(target[0][0] == 'c'):
    target[2] = 'C'
 
  if(target[1] == 'A'):
    card_A = card_A[1:]
    target[1] = target[2]
    target[0] = changeTarget(target[2])
  elif(target[1] == 'B'):
    card_B = card_B[1:]
    target[1] = target[2]
    target[0] = changeTarget(target[2])
  elif(target[1] == 'C'):
    card_C = card_C[1:]
    target[1] = target[2]
    target[0] = changeTarget(target[2])
 
print(target[1])

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

typedef long long int ll;
ll MOD = 1000000007;
ll INFL = 1ll << 60;
ll INF = 1 << 28;

// ====================================================================

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

  int a = n - 2;
  int m = a * (a + 1) / 2;  // 対の最大
  if (m < k) {
    cout << "-1" << endl;
    return 0;
  }

  cout << (n - 1) + (m - k) << endl;

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

  int now = 2;
  int count = 3;
  for (int i = 0; i < m - k; i++) {  // 辺をつなげていく
    cout << now << " " << count << endl;
    if (count >= n) {
      now++;
      count = now + 1;
    } else {
      count++;
    }
  }
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<cmath>
#include<iterator>
#include<algorithm>
#include<cstdlib>
#include<queue>
#include<vector>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef ostream_iterator<int> os_iter_int;

const ll mod=1e9+7;

map<int,int> lpos;
ll dp[1000010];
ll pref[1000010];
ll ans=1,n,c[1000010];

template<typename inp_t>
void readx(inp_t& x)
{
	x=0; int k=1; char ch=0;
	while (ch<'0' || ch>'9') { ch=getchar(); if (ch=='-') k=-1; }
	while (ch>='0' && ch<='9') { x=x*10+ch-'0'; ch=getchar(); }
	x*=k;
}



int main()
{
	readx(n);
	for (int i=1;i<=n;i++) readx(c[i]);
	
	lpos[c[1]]=1;
	for (int i=2;i<=n;i++)
	{
		int pos=lpos[c[i]]; lpos[c[i]]=i;
		if (!pos || pos==i-1) { pref[i]=pref[i-1]; continue; }
		dp[i]=(pref[pos]+1)%mod;
		pref[i]=(pref[i-1]+dp[i])%mod;
		
	}
	cout<<(pref[n]+1)%mod<<endl;
	
}

Measured memory_bytes: 16000
local mma, mmi = math.max, math.min
local n = io.read("*n")
local t = {}
for i = 1, n do
  t[i] = {io.read("*n", "*n")}
  t[i][3] = i
end
local lmaxp, rminp = 1, 1
for i = 2, n do
  if t[lmaxp][1] < t[i][1] then
    lmaxp = i
  end
  if t[i][2] < t[rminp][2] then
    rminp = i
  end
end
local cand = mma(0, t[rminp][2] - t[lmaxp][1] + 1)
do
  local maxlen = 0
  for i = 1, n do
    if i ~= lmaxp and i ~= rminp then
      maxlen = mma(maxlen, t[i][2] - t[i][1] + 1)
    end
  end
  cand = cand + maxlen
end
if lmaxp ~= rminp then
  local l_r, r_l = t[rminp][2], t[lmaxp][1]

  local l_l, r_r = false, t[lmaxp][2]
  table.sort(t, function(a, b) return a[1] > b[1] end)
  for i = 1, n do
    if t[i][3] ~= lmaxp then
      l_l = t[i][1]
      cand = mma(cand, mma(0, l_r - l_l + 1) + mma(0, r_r - r_l + 1))
    end
    if t[i][3] ~= rminp then
      r_r = mmi(r_r, t[i][2])
    end
  end
  cand = mma(cand, mma(0, l_r - l_l + 1) + mma(0, r_r - r_l + 1))
end
print(cand)


Measured memory_bytes: 12276
N = int(input())
S = input()

color_cnt = {'R': 0, 'G': 0, 'B': 0}
for i in range(N):
    color_cnt[S[i]] += 1

ans = color_cnt['R']*color_cnt['G']*color_cnt['B']
for i in range(N):
    for diff in range(1, (N-i-1)//2 +1):
        ans -= len({S[i], S[i+diff], S[i+2*diff]}) == 3

print(ans)




Measured memory_bytes: 73364
#include <iostream>
#include <vector>
#include <algorithm>
#define rep(i, a, n) for(int i = a; i < n; i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main()
{
    int n;
    cin >> n;
    vector<int> l(n);
    rep(i, 0, n){
        cin >> l[i];
    }
    sort(l.begin(), l.end());
    int ans = 0;
    rep(i, 0, n-1){
        ans += l[i];
    }
    cout << (l[n-1] < ans ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), m = sc.nextInt();
		boolean[][] map = new boolean[n][m];
		boolean[] nn = new boolean[n], mm = new boolean[m];
		String str;
		for(int i = 0; i < n; i++) {
			str = sc.next();
			for(int j = 0; j < m; j++) {
				map[i][j] = str.charAt(j) == '#' ? true : false;
				nn[i] |= map[i][j];
				mm[j] |= map[i][j];
			}
		}
		for(int i = 0; i < n; i++) {
			if(!nn[i])continue;
			for(int j = 0; j < m; j++) {
				if(!mm[j])continue;
				System.out.print(map[i][j]?'#':'.');
			}
			System.out.println();
		}
	}
}


Measured memory_bytes: 23252
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct _OMAZINAI_ { _OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } __omazinai_instance__;
#define INF (1LL<<61 + 1<<29)
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
void _INPUT_IMPL_() {};
template <class T, class... Args> void _INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; _INPUT_IMPL_(args...); }
void _OUTPUT_IMPL_() {};
template <class T, class... Args> void _OUTPUT_IMPL_(T dest, Args... args) { cout<< dest << (sizeof...(Args)?" ":""); _OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; _INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define sort_v(v) std::sort(v.begin(), v.end())
#define out(...) _OUTPUT_IMPL_(__VA_ARGS__)

int main() {
	in(int, a, b);
	if (a + b > 9)
		cout << "error" << endl;
	else
		cout << a + b << endl;
}

Measured memory_bytes: 256
def c(n,r):
    a = 1
    for i in range(r):
        a *= (n-i)
        a %= mod
    return a*ifact[r]%mod

mod = pow(10,9)+7
inv = [0,1]
fact = [1,1]
ifact = [1,1]
for i in range(2,16):
    inv.append(inv[mod%i]*(mod-mod//i)%mod)
    fact.append(i*fact[-1]%mod)
    ifact.append(ifact[-1]*inv[i]%mod)

t = int(input())
for _ in range(t):
    ans = 0
    n = int(input())-5
    for o in range(12):
        m = n-o
        if (m<0 or m&1):
            continue
        ans += c(11,o)*c(m//2+15,15)
        ans %= mod
    print(ans)

Measured memory_bytes: 74936
#include<iostream>
#include<string>
using namespace std;
int main(){
	int N,i,j,l;
	int num[5];
	long long buf,ans = 0;
	string S;
	cin >> N;
	for(i=0;i<5;i++) num[i] = 0;
	for(i=0;i<N;i++){
		cin >> S;
		if(S[0] == 'M') num[0]++;
		else if(S[0] == 'A') num[1]++;
		else if(S[0] == 'R') num[2]++;
		else if(S[0] == 'C') num[3]++;
		else if(S[0] == 'H') num[4]++;
	}
	for(i=0;i<5;i++){
		for(j=i+1;j<5;j++){
			buf = 1;
			for(l=0;l<5;l++){
				if(l!=i&&l!=j) buf *=num[l];
			}
			ans += buf;
		}
	}
	cout << ans <<endl;
	return 0;
}

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

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
  int n;
  cin >> n;
  vector<vector<int>> edges(n + 1, vector<int>());
  int st = 1;
  for (int i = 1; i < n; ++i) {
    int a, b;
    cin >> a >> b;
    edges[a].push_back(b);
    edges[b].push_back(a);
  }
  for (int i = 1; i <= n; ++i) {
    if (edges[i].size() == 1) {
      st = i;
      break;
    }
  }
  vector<bool> vis(n + 1);
  stack<pair<int, int>> s;
  s.push({st, 0});
  vis[st] = true;
  int maxD = 0;
  while (!s.empty()) {
    auto cur = s.top();
    s.pop();
    int v = cur.first, d = cur.second;
    if (d > maxD) {
      maxD = d;
      st = v;
    }
    for (int i = 0; i < edges[v].size(); ++i) {
      if (!vis[edges[v][i]]) {
        vis[edges[v][i]] = true;
        s.push({edges[v][i], d + 1});
      }
    }
  }
  s.push({st, 0});
  for (int i = 1; i <= n; ++i) {
    vis[i] = false;
  }
  vis[st] = true;
  maxD = 0;
  while (!s.empty()) {
    auto cur = s.top();
    s.pop();
    int v = cur.first, d = cur.second;
    if (d > maxD) {
      maxD = d;
    }
    for (int i = 0; i < edges[v].size(); ++i) {
      if (!vis[edges[v][i]]) {
        vis[edges[v][i]] = true;
        s.push({edges[v][i], d + 1});
      }
    }
  }
  if (maxD % 3 == 1) {
    cout << "Second" << endl;
  } else {
    cout << "First" << endl;
  }
  return 0;
}



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

using ll = long long int;

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

struct dist_cal {ll dist, cal;};

ll n, c;
dist_cal xv[MAX_N];
dist_cal xv_rev[MAX_N];

ll ans;

ll solve(dist_cal *dsv) {
  /****************************************************/
  ll score_a[MAX_N];
  ll score_b[MAX_N];
  ll score_g[MAX_N];

  ll tmp_a = 0;
  score_a[0] = 0;
  for (ll i = 1; i <= n; ++i) {
    tmp_a += dsv[i].cal;
    score_a[i] = tmp_a - dsv[i].dist;
  }

  ll tmp_b = 0;
  score_b[0] = 0;
  for (ll i = n; i >= 1; --i) {
    tmp_b += dsv[i].cal;
    score_b[i] = tmp_b - (c - dsv[i].dist);
  }

  score_g[0] = score_a[0];
  for (ll i = 1; i <= n; ++i) {
    score_g[i] = max(score_g[i - 1], score_a[i]);
  }

  ll last_max = score_g[n];
  for (ll i = n; i >= 1; --i) {
    ll cur_score = score_b[i] - (c - dsv[i].dist) + score_g[i - 1];
    last_max = max(last_max, cur_score);
  }
  /****************************************************/

  return last_max;
}

int main(void) {
  // Here your code !
	scanf("%lld %lld", &n, &c);
	for (ll i = 1; i <= n; ++i) {
    ll x, v;
    scanf("%lld %lld", &x, &v);
    dist_cal tmp;
    tmp.dist = x;
    tmp.cal = v;
    xv[i] = tmp;
  }

  for (int i = 1; i <= n; ++i) {
    dist_cal tmp;
    tmp.dist = c - xv[i].dist;
    tmp.cal = xv[i].cal;
    xv_rev[i] = tmp;
  }

  sort(xv, xv + n + 1, [](dist_cal a, dist_cal b) { return a.dist < b.dist; });
  sort(xv_rev, xv_rev + n + 1, [](dist_cal a, dist_cal b) { return a.dist < b.dist; });

  ans = max(solve(xv), solve(xv_rev));
  ans = max(ans, (ll)0);

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

	return 0;
}

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

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

    if(m >= 1800) { cout << 1 << endl; return 0;}
    else if(m >= 1600) { cout << 2 << endl; return 0;}
    else if(m >= 1400) { cout << 3 << endl; return 0;}
    else if(m >= 1200) { cout << 4 << endl; return 0;}
    else if(m >= 1000) { cout << 5 << endl; return 0;}
    else if(m >= 800) { cout << 6 << endl; return 0;}
    else if(m >= 600) { cout << 7 << endl; return 0;}
    else { cout << 8 << endl; return 0;}
    

}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<stack>
#include<algorithm>
#include<string>
#include<set>
#include<numeric>
using namespace std;


int main()
{
	int N;
	cin >> N;
	vector<long long> s(N);
	for (int i = 0; i < N; i++)
		cin >> s[i];

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

	long long sum = accumulate(s.begin(), s.end(), 0);

	if (sum % 10 != 0) {
		printf("%lld\n", sum);
	} else {
		bool flag = false;
		for (int i = 0; i < N; i++) {
			if (s[i] % 10 != 0) {
				printf("%lld\n", sum - s[i]);
				flag = true;
				break;
			}
		}
		if (flag == false)
			printf("0\n");
	}

}

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

template<typename T>
struct BinaryIndexedTree{
private:
  int n;
  T *data;

public:
  BinaryIndexedTree(int n = 0) : n(n){
    data = new T[n + 1];
    for(int i = 0; i <= n; i++) data[i] = 0;
  }

  bool add(int index, T x = 1){
    if(index < 0 || n <= index) return false;
    for(index++; index <= n; index += index & -index){
      data[index] += x;
    }
    return true;
  }

  T sum(int index){
    if(index < 0) index = 0;
    else if(index >= n) index = n - 1;

    T x = 0;
    for(index++; index; index -= index & -index){
      x += data[index];
    }
    return x;
  }

  ~BinaryIndexedTree(){
    delete [] data;
  }
};

using namespace std;

int main(){
  int N;
  long long K;
  cin >> N >> K;
  
  vector<long long> a(N);
  for(int i = 0; i < N; i++) cin >> a[i];
  
  vector<long long> s(N + 1);
  s[0] = 0;
  for(int i = 0; i < N; i++) s[i + 1] += s[i] + a[i];
  for(int i = 1; i <= N; i++) s[i] -= K * i;
  
  vector<long long> t = s;
  sort(t.begin(), t.end());
  t.erase(unique(t.begin(), t.end()), t.end());
  
  map<long long, int> zip;
  for(int i = 0; i <= N; i++) zip[t[i]] = i;
  
  BinaryIndexedTree<long long> bit(N + 3);
  
  long long ans = 0;
  for(int i = 0; i <= N; i++){
    ans += bit.sum(zip[s[i]]);
    bit.add(zip[s[i]]);
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 22004
# first input
a_1, a_2, a_3 = map(int, input().split())
a_4, a_5, a_6 = map(int, input().split())
a_7, a_8, a_9 = map(int, input().split())

a_list = []

a_list.append([a_1, a_2, a_3])
a_list.append([a_4, a_5, a_6])
a_list.append([a_7, a_8, a_9])
a_list.append([a_1, a_4, a_7])
a_list.append([a_2, a_5, a_8])
a_list.append([a_3, a_6, a_9])
a_list.append([a_1, a_5, a_9])
a_list.append([a_3, a_5, a_7])

N = int(input())
for i in range(N):
    b = int(input())
    for a in a_list:
        if b in a:
            a.pop(a.index(b))

ans = False
for a in a_list:
    if len(a)==0:
        ans = True
        break

if ans:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 38256
N = int(input())
*w, = map(int,input().split())

ans = 10**5
for i in range(N-1):
    s1 = 0
    s2 = 0
    tmp = 0
    for j in range(N):
        if j <= i:
            s1 += w[j]
        else:
            s2 += w[j]
    tmp = abs(s1-s2)
    if ans > tmp:
        ans = tmp

print(ans)

Measured memory_bytes: 3060
//
//  main.cpp
//  1234
//
//  Created by Moha Jain on 14/04/20.
//  Copyright © 2020 Moha Jain. All rights reserved.
//

#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<stack>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;

int main()
{
   long long int r;cin>>r;
    long double ans;
    ans=2*3.1415926*r;
    cout<<ans<<endl;
}


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

#if 0
所用時間:0.5h

感想:

#endif

int solve(string X, string Y){
  int cost;
  int rows = Y.size();
  int cols = X.size();
  int L[1001][1001] = {}; //L[y][x]の初期化

  for(int r = 0; r <= rows; ++r)  L[r][0] = r;
  for(int c = 0; c <= cols; ++c)  L[0][c] = c;

  for(int r = 1; r <= rows; ++r){
    for(int c = 1; c <= cols; ++c){
      if(X[c-1] == Y[r-1]) cost = 0;
      else cost = 1; 
      
      L[r][c] = min(L[r-1][c-1]+cost, min(L[r][c-1]+1, L[r-1][c]+1));
    }
  }

  //テーブルの表示
  // cout << "Ltable:" << endl;
  // for(int row=0; row <= rows; ++row){
  //   for(int col = 0; col <= cols; ++col){
  //     cout << L[row][col];
  //   }
  //   cout << endl;
  // }

  return L[rows][cols];
}

int main(){
  string S1, S2;

  cin >> S1 >> S2;

  int ans = solve(S1, S2);

  cout << ans << endl;
}



Measured memory_bytes: 7124
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#ifdef LOCAL_
void debug_out() {cerr << endl;}
template<typename Head,typename... Tail> void debug_out(Head H,Tail... T){cerr << ' ' << H; debug_out(T...);}
#define debug(...) cerr << 'L' << __LINE__ << " [" << #__VA_ARGS__ << "]:",debug_out(__VA_ARGS__)
#define dump(x) cerr << 'L' << __LINE__ << " " << #x << " = " << (x) << endl;
#else
#define debug(...) (void(0))
#define dump(x) (void(0))
#endif
#define rep(i,n) for (int i = 0; i < (int)(n); i ++)
#define irep(i,n) for (int i = (int)(n) - 1;i >= 0;--i)
using ll = long long;
using PL = pair<ll,ll>;
using P = pair<int,int>;
constexpr int INF = 1000000000;
constexpr long long HINF = 1000000000000000;
constexpr long long MOD = 1000000007;// = 998244353;
constexpr double EPS = 1e-4;
constexpr double PI = 3.14159265358979;



template<int Modulus> 
struct ModInt {
    long long x;
    ModInt(long long x = 0) :x((x%Modulus + Modulus)%Modulus) {}
    constexpr ModInt &operator+=(const ModInt a) {if ((x += a.x) >= Modulus) x -= Modulus; return *this;}
    constexpr ModInt &operator-=(const ModInt a) {if ((x += Modulus - a.x) >= Modulus) x -= Modulus; return *this;}
    constexpr ModInt &operator*=(const ModInt a) {(x *= a.x) %= Modulus; return *this;}
    constexpr ModInt &operator/=(const ModInt a) {return *this *= a.inverse();}

    constexpr ModInt operator+(const ModInt a) const {return ModInt(*this) += a.x;}
    constexpr ModInt operator-(const ModInt a) const {return ModInt(*this) -= a.x;}
    constexpr ModInt operator*(const ModInt a) const {return ModInt(*this) *= a.x;}
    constexpr ModInt operator/(const ModInt a) const {return ModInt(*this) /= a.x;}
    
    friend constexpr ostream& operator<<(ostream& os,const ModInt<Modulus>& a) {return os << a.x;}
    friend constexpr istream& operator>>(istream& is,ModInt<Modulus>& a) {return is >> a.x;}
    
    ModInt inverse() const {// x ^ (-1) 
        long long a = x,b = Modulus,p = 1,q = 0;
        while (b) {long long d = a/b; a -= d*b; swap(a,b); p -= d*q; swap(p,q);}
        return ModInt(p);
    }
    ModInt pow(long long N) {// x ^ N 
        ModInt a = 1;
        while (N) {
            if (N&1) a *= *this;
            *this *= *this;
            N >>= 1;
        }
        return a;
    }
};

using mint = ModInt<998244353>;

// operate from left !!
using S = pair<mint,mint>;
using F = int;
S op(S a,S b) {
    return S{a.first + b.first,a.second + b.second};
}
S e() {return S{0,0};}
S mapping(F a,S b){
    if (a == 10) return b;
    return S{mint(a)*b.second,b.second};
}
F composition(F a,F b){
    if (a == 10) return b;
    return a;
}
F id() {return 10;}

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

    int N,Q; cin >> N >> Q;
    vector<S> A(N);
    mint now = 1;
    irep(i,N) {
        A[i] = S{now,now};
        now *= mint(10);
    }
    lazy_segtree<S,op,e,F,mapping,composition,id> st(A);
    rep(i,Q) {
        int l,r,d; cin >> l >> r >> d;
        --l;
        st.apply(l,r,d);
        cout << st.all_prod().first << '\n';
    }
    return 0;
}

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

/*============================ DEBUGGING =============================*/

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

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

/*============================= DEFINES ==============================*/

#define eps 1e-9
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define B begin()
#define E end()
#define F first
#define S second
#define tostr(x) to_string(x)
#define SZ(x) ((int)x.size())
#define ins insert
#define rep(i,x,y) for(int i=x;i<y;i++)
#define per(i,x,y) for(int i=x;i>y;i--)
#define repi(i,x,y) for(int i=x;i<=y;i++)
#define peri(i,x,y) for(int i=x;i>=y;i--)
#define inf (ll)LLONG_MAX
#define ds1(i,x) for(auto i=x.begin();i!=x.end();i++)
#define ds2(i,x) for(auto i:x)
#define fib(n) ceil(pow((1+sqrt(5),n)-pow((1-sqrt(5),n)/(float)(pow(2,n)*sqrt(5)
#define FIO {ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);}
#define dig(n) (int)(log10(n)+1)
#define ss(x,k) substr(x,k)  // x is the start pos and k is the length of substr.
#define set(x,k) memset(x,k,sizeof x)

/*============================== TYPEDEFS ============================*/

typedef long long ll;
typedef long l;
typedef string str;
typedef vector<int> vi;
typedef vector<ll> vlli;
typedef vector<bool> vb;
typedef queue<int> qi;
typedef vector<pair<int,int> > vpii;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;

/*============================ START FROM HERE =======================*/
ll np(ll n){
	int c=0;
	for(ll i=2;i*i<=n;i++){
		if(!(n%i)){
			c++;
			while(!(n%i))n/=i;
		}
	}
	if(n>1)c++;
	return c;
}
int main(){
	FIO
	
	ll a,b;cin>>a>>b;
	cout<<np(__gcd(a,b))+1;
	return 0;
}


Measured memory_bytes: 256
import re


def li():
    return list(map(int, input().split()))


if __name__ == "__main__":
    s = input()
    p = re.compile("R+L+")
    rl_list = p.findall(s)

    ans_list = []
    for rl in rl_list:
        len_rl = len(rl)
        ans_elm = [0] * len_rl
        index = rl.find("L")
        if len_rl % 2 == 0:
            ans_elm[index - 1] = len_rl // 2
            ans_elm[index] = len_rl // 2
        elif index % 2 == 0:
            ans_elm[index - 1] = len_rl // 2
            ans_elm[index] = len_rl // 2 + 1
        else:
            ans_elm[index - 1] = len_rl // 2 + 1
            ans_elm[index] = len_rl // 2
        ans_list.append(ans_elm)
    for index, ans_elm in enumerate(ans_list):
        end_char = " " if index != len(ans_list) - 1 else ""
        print(" ".join(list(map(str, ans_elm))), end=end_char)
    print()

    # print(rl_list)

# R+L+のかたまりで分割して、それぞれを計算すればいい
# RLの切り替わり部分にまとまることになる　10**100は偶数なので、偶数回移動でたどり着ける方にいる
# 奇数番目の方が１つ多くなる


Measured memory_bytes: 55388
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int M = 2e5 + 5;
int n, a[M];
 
int32_t main() 
{
	ios_base::sync_with_stdio(0);	cin.tie(0);	cout.tie(0);
	cin >> n;
	unordered_map <int, int> add, sub;
	for(int i = 1; i <= n; i++)	
	{
		cin >> a[i];
		sub[i - a[i]]++;
		add[a[i] + i]++;
	}
	int ans = 0;
	for(int i = 1; i <= n; i++)
	{
		ans += add[i - a[i]];
		ans += sub[a[i] + i];
	}
	cout << ans / 2;
    	return 0;
}

Measured memory_bytes: 35572
#include <iostream>

using namespace std;

int main()
{
    int A, B;
    cin >> A >> B;
    if(A >= 13){
        cout << B;
    }
    else if(A <= 5){
        cout << 0;
    }
    else{
        cout << B / 2;
    }
    cout << endl;
}

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

    typedef long long int ll;

    #define MOD (ll)(1e9+7)
    #define endl "\n"
    #define pb push_back
    #define TEST_CASES  ll t;cin>>t;while(t--)
    #define forn(i,a,n) for (int i = a; i < n; ++i)
    #define f first
    #define s second
    #define all(x) x.begin(), x.end()
    
    ll powD(ll x,ll y){
      ll res = 1;
      while(y > 0){
        if(y & 1)
          res = (res*x)%MOD;
        x = (x*x)%MOD;
        y = y>>1;
      }
      return res;
    }

    int main()
    {
      ios_base::sync_with_stdio(false);
      cin.tie(NULL);
      int n;
      cin>>n;
      map<string,int> mp;
      forn(i,0,n){
        string s;
        cin>>s;
        mp[s]++;
      }
      cout<<"AC x "<<mp["AC"]<<endl;
      cout<<"WA x "<<mp["WA"]<<endl;
      cout<<"TLE x "<<mp["TLE"]<<endl;
      cout<<"RE x "<<mp["RE"]<<endl;
    } 
    

Measured memory_bytes: 3664
s = gets.chomp.split("")

mid = (s.length-1) / 2

front = Array.new(mid)
back = Array.new(mid)

for i in 0..mid do
    front[i] = s[i]
end

for i in mid+1..s.length-1 do
    back[s.length - 1 - i] = s[i]
end

if(front.length != back.length)
    front.pop
end

tigau = 0

for i in 0..front.length-1 do
    if(front[i] != back[i])
        tigau += 1
    end
end

puts tigau

Measured memory_bytes: 1788
import sys
readline = sys.stdin.readline
from operator import itemgetter
class UnionFind:
    def __init__(self, n):
        self.p = list(range(n))
        self.rank = [0] * n
    def find_root(self, x):
        if x != self.p[x]:
            self.p[x] = self.find_root(self.p[x])
        return self.p[x]
    def same(self, x, y):
        return self.find_root(x) == self.find_root(y)
    def unite(self, x, y):
        u = self.find_root(x)
        v = self.find_root(y)
        if u == v: return
        if self.rank[u] < self.rank[v]:
            self.p[u] = v
        else:
            self.p[v] = u
            if self.rank[u] == self.rank[v]:
                self.rank[u] += 1
n, m = map(int, readline().split())
edges = [None] * m
for i in range(m):
    s, t, w = map(int, readline().split())
    edges[i] = (s, t, w)
edges.sort(key=itemgetter(2), reverse=True)
uf = UnionFind(n)
ans = 0
for _ in [0] * (n - 1):
    while edges:
        s, t, w = edges.pop()
        if not uf.same(s, t):
            uf.unite(s, t)
            break
    ans += w
print(ans)

Measured memory_bytes: 26356
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;

ll rep_power(ll m, ll n){
    if(n==1) return m % MOD;
    if(n%2==1) return m * rep_power(m,n-1) % MOD;
    ll t = rep_power(m, n/2);
    return (t*t) % MOD;
}

ll Combination(ll n, ll r){
    ll bunshi=1,bunbo=1;
    for (int i = 0; i < r; ++i) {
        bunbo = bunbo*(i+1) % MOD;
        bunshi = bunshi*(n-i) % MOD;
    }

    return bunshi * rep_power(bunbo,MOD-2) % MOD;

}

int main(void) {

    ll n,a,b; cin>>n>>a>>b;

    ll ans = rep_power(2,n);
    ans -= Combination(n,a);
    ans -= Combination(n,b);
    ans--;
    cout<<(ans%MOD+MOD)%MOD<<endl;
}

Measured memory_bytes: 256
use std::io::stdin;
use std::str::FromStr;

fn main(){
    let abs: Vec<(usize, usize)> = {
        let mut abs_builder = Vec::new();
        for _ in 0..3 {
            abs_builder.push(get_pair());
        }
        abs_builder
    };
    let mut cnts = vec![0; 5];
    for (a, b) in abs {
        cnts[a] += 1;
        cnts[b] += 1;
    }
    let mut meta_cnts = vec![0; 7];
    for i in 1..5 {
        meta_cnts[cnts[i]] += 1;
    }

    if meta_cnts[2]==2 && meta_cnts[1]==2 {
        println!("YES");
    } else {
        println!("NO");
    }
}

#[allow(dead_code)]
fn get_line() -> String {
    let mut s = String::new();
    match stdin().read_line(&mut s){
        Ok(_) => {s.trim().to_string()}
        Err(_) => String::new()
    }
}

#[allow(dead_code)]
fn get_vec<T: std::str::FromStr>() -> Vec<T> {
    let line = get_line();
    line.split_whitespace().filter_map(|x| x.parse().ok()).collect()
}

#[allow(dead_code)]
fn get_one<T: FromStr + Copy>() -> T {
    let v = get_vec();
    v[0]
}

#[allow(dead_code)]
fn get_pair<T: FromStr + Copy>() -> (T, T) {
    let v = get_vec();
    (v[0], v[1])
}

#[allow(dead_code)]
fn get_triple<T: FromStr + Copy>() -> (T, T, T) {
    let v = get_vec();
    (v[0], v[1], v[2])
}

#[allow(dead_code)]
fn get_chars() -> Vec<char> {
    get_line().chars().collect()
}


Measured memory_bytes: 4352