akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll=long long;
const ll MOD=1000000007;

ll countd(ll N){//Nの正の約数の個数
    ll ans=0;
    for(ll i=1;i*i<=N;i++){
        if(N%i==0){
            ans++;
            if(N/i != i){
                ans++;
            }
        }
    }
    return ans;
}

int main() {
    ll N;
    cin>>N;
    ll count=countd(N-1);
    for(ll i=2;i*i<=N;i++){
        if(N%i==0 && (N-1)%i!=0){
            ll N2=N;
            while(N2%i==0){
                N2/=i;
            }
            if(N2%i==1){count++;}
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        final int T = 0;
        final int X = 1;
        final int Y = 2;
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[][] travel = new int[n][3];
        for(int i=0;i<n;i++){
            for(int j=0;j<3;j++){
                travel[i][j] = Integer.parseInt(sc.next());
            }
        }
        boolean can = true;
        int pt=0, px=0, py=0;
        for(int i=0;i<n;i++){
            int d = length(px, py, travel[i][X], travel[i][Y]);
            int t = travel[i][T] - pt;
            if(d>t){
                can = false;
                break;
            }else if((t-d)%2==1){
                can = false;
                break;
            }
            px = travel[i][X]; py=travel[i][Y]; pt=travel[i][T];
        }
        if(can){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
    static int length(int px, int py, int cx, int cy){
        return(Math.abs(cx-px)+Math.abs(cy-py));
    }
}

Measured memory_bytes: 67836
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;

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

    if(M == 1){
        cout << 0 << endl;
        return 0;
    }

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

    vector<long long> Y(M-1);
    for(int i=0; i<M-1; i++)
        Y[i] = X[i+1]-X[i];
    sort(Y.rbegin(), Y.rend());
    long long ans = 0;
    for(int i=0; i<min(M-1, N-1); i++)
        ans += Y[i];

    cout << X.back() - X.front() - ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define mset(arr,val) memset(arr,val,sizeof(arr))
#define loop(i,a,b) for(ll i=a;i<b;++i)
#define dloop(i,a,b) for(ll i=a;i>=b;--i)
#define all(a) a.begin(),a.end()
#define lar 1000000007
#define pq priority_queue
#define pll pair<ll,ll>
#define ss second
#define ff first
#define pb push_back
#define ppb pop_back
#define umap unordered_map
#define ub upper_bound
#define lb lower_bound
#define br "\n"
#define sp " "
const int N=2e5+1;

void primefactors(ll n,vector<ll> &v)
{
    ll f=1;
    while (n % 2 == 0)
    {
        if(f) v.pb(2), f=0;
        n = n/2;
    }
    for (ll i = 3; i <= sqrt(n); i = i + 2)
    {
        f=1;
        while (n % i == 0)
        {

            if(f) v.pb(i),f=0;
            n = n/i;
        }
    }
    if (n > 2)
        v.pb(n);
}

void solve(){
	ll n;
	cin>>n;
	ll a[n];
	loop(i,0,n) cin>>a[i];
	vector<ll> v[n];
	loop(i,0,n) primefactors(a[i],v[i]);
	map<ll,ll> m;
	loop(i,0,n)
	{
	    for(ll j:v[i])
        {
            m[j]++;
        }
	}
	ll f=1;
	for(auto i:m)
    {
        if(i.ss>1)
            {f=0; break;}
    }
    if(f){
        cout<<"pairwise coprime"<<endl;
        return;
    }
    f=1;
    for(auto i:m)
    {
        if(i.ss>=n)
            {f=0; break;}
    }
    if(f){
            cout<<"setwise coprime"<<endl;
    }
    else cout<<"not coprime"<<endl;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 109696
#include<stdio.h>
int main() {
  char str[1000];
  char ara[7] = {'I', 'V', 'X', 'L', 'C', 'D', 'M'};
  int n[7] = {1, 5, 10, 50, 100, 500, 1000};
  int i, j, m, k;
  while (scanf("%s", str) != EOF) {
    m = 0; k = 0;
    for(i = 0; str[i] != 0; i ++);
    i --;
    for(; i > -1; i --) {
      for (j = 0; str[i] != ara[j]; j ++);
      if (j >= k) {
	m += n[j]; k = j;
      } else m -= n[j];
    }
    printf("%d\n", m);
  }
  return 0;
}

Measured memory_bytes: 540
#include <iostream>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;

int main()
{
	int n;
	cin>>n;
	while (n--)
	{
		int a[3];
		cin>>a[0]>>a[1]>>a[2];
		sort(a,a+3);
		if (a[0]*a[0]+a[1]*a[1]== a[2]*a[2]) cout<<"YES"<<endl;
		else cout<<"NO"<<endl;

	}

}

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

def cal(x,i,answer):
    if x >0:
        x//=10
        if x%10==3:
            answer.append(i)
        else:
            cal(x,i,answer)

def main():
    number = int(input())
    answer=[""]
    for i in range(1,number+1):
        x=i
        if x%3 ==0:
            answer.append(i)
        elif x%10==3:
            answer.append(i)
        else:
            cal(x,i,answer)
    print(*answer)

if __name__=="__main__":
    main()


Measured memory_bytes: 6132
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <functional>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <cassert>
#include <exception>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<P> vp;
#define rep(i,a,n) for(ll i = (a);i < (n);i++)
#define per(i,a,n) for(ll i = (a);i > (n);i--)
#define lep(i,a,n) for(ll i = (a);i <= (n);i++)
#define pel(i,a,n) for(ll i = (a);i >= (n);i--)
#define clr(a,b) memset((a),(b),sizeof(a))
#define pb push_back
#define mp make_pair
#define all(c) (c).begin(),(c).end()
#define sz size()
#define print(X) cout << (X) << endl
const ll INF = 1e+9+7;
ll n,m,l;
string s,t;
ll d[200010],dp[500][500];

int main(){
  cin >> n;
  clr(dp,0);
  rep(i,0,n){
    cin >> s;
    rep(j,0,s.sz)dp[i][s[j]-'a']++;
  }
  t = "";
  rep(i,0,26){
    m = INF;
    rep(j,0,n)m = min(m,dp[j][i]);
    rep(j,0,m)t += i+'a';
  }
  print(t);
  return 0;
}

Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cassert>
#define bogo_sort   std::sort
#define bozo_sort   std::stable_sort
#define alles(obj)  obj.begin(), obj.end()
#define elif        else if
#define unless(flg) if(!(flg))
#define elless(flg) else if(!(flg))
#define echo        std::cout <<
#define read        std::cin >>
#define endl        std::endl
#define fin         << '\n'
#define bash        push_back
#define makePair    std::make_pair
#define _           << ' ' <<
// type-define
#define Stack       std::stack
#define Queue       std::queue
#define Set         std::set
#define PQueue      std::priority_queue
#define Vector      std::vector
#define Pair        std::pair
#define Map         std::map
#define HashMap     std::unordered_map
#define Greater     std::greater
using String  =     std::string;
using llong   =     long long;
using boolean =     bool;
using Pii     =     Pair<int, int>;
using Vi      =     Vector<int>;
using Vii     =     Vector<Pii>;
// utils
constexpr int   dx[] = {1, 0, -1, 0, 1, 1, -1, -1};
constexpr int   dy[] = {0, 1, 0, -1, 1, -1, 1, -1};
constexpr int   INF  = 0x3f3f3f3f;
constexpr llong LINF = 0x3f3f3f3f3f3f3f3fLL;

namespace {
    template<class A, class B> A power ( llong x, llong n, llong mod ) {
        llong ans = 1;
        while ( n > 0 ) {
            if ( n & 1 ) ans = ( ans * x ) % mod;
            x = ( x * x ) % mod;
            n >>= 1;
        }
        return ans;
    }
    template<class A, class B> A power ( A x, B n ) { return power( x, n, 1000000007 ); }
    template<class A> A gcd ( A x, A y ) { return x % y ? gcd( y, x % y ) : y; }
    template<class A, class B> A lcm   ( A x,  B y ) { return ( x / gcd(x, y) * y ); }
    template<class A> inline A abs ( A n ) { return ( n < 0 ) ? -n : n; }
    template<class A, class B> inline bool chmax ( A &a, const B &b ) { return b > a ? a = b, true : false; }
    template<class A, class B> inline bool chmin ( A &a, const B &b ) { return b < a ? a = b, true : false; }
    boolean isMovable ( int x, int y, int w, int h ) {
        return ( x >= 0 && y >= 0 && x < w && y < h );
    }
}

namespace Rlyeh {

    int cnt;

    signed call_of_Cthulhu( signed datum ) {

        int n, k;
        read n >> k;
        for ( int i = 1; i <= n; i+=2 ){
            cnt++;
        }
        if ( cnt >= k ) echo "YES" fin;
        else echo "NO" fin;

        return 0;
    }
}

signed main(){std::cin.tie(0); std::ios::sync_with_stdio(false); int main_result = Rlyeh::call_of_Cthulhu(114514); return 0;}


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

const int MAXN = 100010;
int a[MAXN];
vector<int> pos, neg;
int main() {
	int n;
	cin>>n;
	for (int i=0; i<n; i++)
		cin>>a[i];
	sort(a, a+n);

	int ans = 0;
	pos.push_back(a[n-1]);
	neg.push_back(a[0]);
	ans = a[n-1] - a[0];
	for (int i=1; i<n-1; i++)
		if (a[i] < 0)
			neg.push_back(a[i]), ans -= a[i];
		else
			pos.push_back(a[i]), ans += a[i];
	cout<<ans<<endl;

	int tmp = neg.back();
	neg.pop_back();
	while(pos.size() > 1) {
		cout<<tmp<<" "<<pos.back()<<endl;
		tmp = tmp - pos.back();
		pos.pop_back();
	}
	cout<<pos[0]<<" "<<tmp<<endl;
	tmp = pos[0] - tmp;
	while(neg.size()) {
		cout<<tmp<<" "<<neg.back()<<endl;
		tmp = tmp - neg.back();
		neg.pop_back();
	}
	return 0;
}

Measured memory_bytes: 2808
#include <iostream>

using namespace std;

int main(){
    string s;
    string t;
    cin >> s >> t;
    int result = 0;
    if(s[0] == t[0]){
        result++;
    }
    if(s[1] == t[1]){
        result++;
    }
    if(s[2] == t[2]){
        result++;
    }
    cout << result << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
using namespace std;
int main()
{
int N,M;
cin >>N;
M=N%10;
if(M==2 || M==4 ||M==5 ||M==7 ||M==9){
std::cout<<"hon"<<std::endl;
}
if(M==0 || M==1 || M==6 ||M==8){
std::cout<<"pon"<<std::endl;
}
if(M==3){
std::cout<<"bon"<<std::endl;
}
return 0;
}

Measured memory_bytes: 3644
#define _USE_MAT_DEFINES
#include<iostream>
#include <iomanip>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
#include <stack>
#include <deque>
#include <numeric>
#include <functional>
using namespace std;

#define INF 1e9
#define MOD 1000000007;//1e9+7

void solve() {
    string S, T;
    cin >> S >> T;
    cout << (S[0] == T[0]) + (S[1] == T[1]) + (S[2] == T[2]);
}

int main() {
    solve();
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mit map<int,int>::iterator
#define sit set<int>::iterator
#define itrm(g,x) for(mit g=x.begin();g!=x.end();g++)
#define itrs(g,x) for(sit g=x.begin();g!=x.end();g++)
#define ltype int
#define rep(i,j,k) for(ltype(i)=(j);(i)<=(k);(i)++)
#define rap(i,j,k) for(ltype(i)=(j);(i)<(k);(i)++)
#define per(i,j,k) for(ltype(i)=(j);(i)>=(k);(i)--)
#define pii pair<int,int>
#define fi first
#define se second
#define mpr make_pair
#define pb push_back
#define fastio ios::sync_with_stdio(false)
const int inf=0x3f3f3f3f,mod=1000000007;
const double pi=3.1415926535897932,eps=1e-6;
int n,v[100005],b[32777],dp[32777],fin,cn[17],ans;bool ok[32777];
int main()
{
    scanf("%d",&n);
    rap(i,1,n){
        int x,y,w;
        scanf("%d%d%d",&x,&y,&w);
        v[x]^=w;v[y]^=w;
    }
    int lim=1<<15;
    rap(i,0,n) cn[v[i]]++;
    rap(i,0,lim) b[i]=__builtin_popcount(i);
    rap(i,0,15) {
        ans+=cn[i+1]/2;
        if(cn[i+1]&1) fin|=(1<<i);
    }
    rap(i,0,lim){
        int xr=0;
        rap(j,0,15) if(i&(1<<j)) xr^=(j+1);
        ok[i]=!xr;
    }
    rap(i,0,lim) dp[i]=inf;
    dp[0]=0;
    rap(i,0,lim){
        int u=(lim-1)^i;
        for(int ii=u;ii;ii=(ii-1)&u){
            if(ok[ii])
            dp[i^ii]=min(dp[i^ii],dp[i]+b[ii]-1);
        }
    }
    printf("%d\n",ans+dp[fin]);
    return 0;
}

Measured memory_bytes: 896
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
#include<tuple>
#include<queue>
#include<map>
#include <cstdint>
#include <boost/multiprecision/cpp_int.hpp>


#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define Endl endl
#define F first
#define S second

namespace mp = boost::multiprecision;

using cpp_int = mp::cpp_int;
using ll = long long;
using namespace std;

int main() {
	int n;
	cin >> n;
	vector<int>color(8);
	int all = 0;
	rep(i, n) {
		int co;
		cin >> co;
		int j = 0;
		while (1) {
			j++;
			if (j * 400 > co) {
				color[j-1]++;
				break;
			}
			else if (j * 400 >= 3200) {
				all++;
				break;
			}
		}

		
	}
	int count = 0;
	rep(i, 8) {
		if (color[i] > 0) {
			count++;
		}
	}
	int Min = count;
	if (count == 0 && all > 0) {
		Min++;
	}
	int Max =  count + all;
	cout << Min << " " << Max << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
int a, b, c, x, y;
scanf("%d %d %d",&a ,&b, &c);
if(a > b){
  x = a;
  a = b;
  b = x;
}
if(b > c){
  y = b;
  b = c;
  c = y;
}
if(a > b){
  x = a;
  a = b;
  b = x;
}
printf("%d %d %d\n",a, b, c);
return 0;
}


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

//const long double PIL = 3.141592653589793238462643383279502884L;
//const double PI = 3.14159265358979323846;

#define sz(a) int((a).size())
#define all(c) (c).begin(), (c).end()
#define debug(v) {for (auto z : v) {cerr << z << ' ';} cerr << endl;}

using ll = long long;
using ii = pair<int,int>;
using vi = vector<int>;
using vll = vector<long long>;
using vii = vector<pair<int,int>>;

int main() {
	//~ ios::sync_with_stdio(0);
	//~ cin.tie(0);
	//~ cout.tie(0);
	string s, t, u;
	int a, b;
	cin >> s >> t >> a >> b >> u;
	if (u == s) --a;
	if (u == t) --b;
	cout << a << ' ' << b << endl;
}


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

int32_t main()
{
#ifndef ONLINE_JUDGE
	freopen("codefi.txt", "r", stdin);
	freopen("codefo.txt", "w", stdout);
#endif


	string s1, s2;
	cin >> s1 >> s2;

	int x = stoi(s1 + s2);
	long double sr = sqrt(x);
	//cout << sr << endl;
	int fr = floor(sr);
	//cout << floor(sr) << endl;
	if (sr - fr == 0)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;

}

Measured memory_bytes: 3648
n=int(input())
c=[chr(i) for i in range(97, 97+26)]
l=[]
for i in range(1,20):
  l.append(26**i)
L=[0]
for i in range(len(l)):
  L.append(L[-1]+l[i])

for i in range(len(L)):
  if n<=L[i]:
    x=i
    break
y=n-L[x-1]
ans=[]
for i in range(x-1,0,-1):
  ans.append(c[(y-1+26**i)//(26**i)-1])
  y=y%(26**i)
ans.append(c[(y-1+26)%26])
print(''.join(ans))

Measured memory_bytes: 61888
#include<bits/stdc++.h>
using namespace std;
int dsum(int N){
  if(N/10==0){
    return N%10;
  }
  return N%10+dsum(N/10);
}
int main(){
  int n;
  cin >> n;
  int ans=1e9;
  for(int i=1;i<=n-1;i++){
    ans=min(ans,dsum(i)+dsum(n-i));
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
//AtCoder 
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
ll lcm(ll num1,ll num2){
    return num1 / __gcd(num1,num2) * num2; //gcc拡張
}
int main() {
    ll N; cin>>N;
    ll ans=lcm(2,N);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll n;
  cin>>n;
  ll a[n],b[n];
  for(ll i=0;i<n;i++) cin>>a[i];
  ll sum,mi=n*(n+1)/2;
  for(ll i=0;i<n;i++) sum+=a[i];
  if(sum%mi){
    cout<<"NO"<<endl;
    return 0;
  }
  bool ch=0;
  for(ll i=0;i<n;i++) ch|=!(sum/mi<=a[i]&&a[i]<=sum/mi*n);
  if(ch){
    cout<<"NO"<<endl;
    return 0;
  }
  ll cnt=0;
  bool ff=1;
  for(ll i=0;i<n;i++){
    b[i]=a[(i+1)%n]-a[i];
    if((sum/mi-b[i])%n){
      ff=0;break;
    }
    cnt+=(sum/mi-b[i])/n;
  }
  cout<<(ff&&cnt==sum/mi?"YES":"NO")<<endl;
  return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <math.h>
#include<string.h>

int main(){
	int a[4], i, num;
	for(i = 0; i < 4; i++) a[i] = 0;
	char str[2] = "kk";
	while(scanf("%d,%s", &num, str) != EOF){
		if(str[0] == 'A'){
			if(str[1] == 'B') a[2]++;
			else a[0]++;
		}
		if(str[0] == 'B') a[1]++;
		if(str[0] == 'O') a[3]++;
		str[1] = 'k';
	}
	for(i = 0; i < 4; i++) printf("%d\n", a[i]);
	return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rrep(i,n) for(int i=(int)(n)-1; i>=0; i--)
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin(); it!=(c).end(); it++)
#define pb(a) push_back(a)
#define pr(a) cout << (a) << endl
#define PR(a,b) cout << (a) << " " << (b) << endl
#define F first
#define S second
typedef long long ll;
typedef pair<int,int> P;
const int MAX=1000000001;
const ll MAXL=1000000000000000001LL;
const ll mod=1000000007;
int dx[4]={-1,0,1,0},dy[4]={0,-1,0,1};

int main() {
  int n;
  while(cin >> n && n) {
    int a[n];
    rep(i,n) cin >> a[i];
    if(n==1) pr(0);
    else {
      int ans=0;
      for(int i=1; i<n; i++) {
	rrep(j,i) {
	  if(a[j]>a[j+1]) swap(a[j],a[j+1]);
	  else break;
	  ans++;
	}
      }
      pr(ans);
    }
  }
  return 0;
}


Measured memory_bytes: 1164
#include<bits/stdc++.h>
using namespace std;
long long n,a,b;
int main()
{
	scanf("%lld%lld%lld",&n,&a,&b);
	if (n==1) putchar(a==b?'1':'0');
	else printf("%lld",b>=a?(n-2)*(b-a)+1:0);
	return 0;
}

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

int main() {
    int n,x,temp,ans=0;
    cin>>n;
    map<int,int> mp;
    rep(i,n) {
        cin>>temp;
        mp[temp]++;
        mp[temp-1]++;
        mp[temp+1]++;
    }
    for (auto v:mp) ans=max(ans,v.second);
    cout<<ans<<endl;
}


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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll;  typedef pair<ll,ll> pii;
typedef vector<int> VI; typedef vector<ll> VL;
const int MD = (int)1e9 + 7;
void dbg(){ cerr << "\n"; }  template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main(){
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	string s1, s2;
	cin >>n >>s1 >>s2;
	ll ans =0;
	for(int i=0; i<n; i++){
		if(i==0){
			if(s1[0] == s2[0]) ans =3;
			else {ans = 3*2; i++;}
			continue;
		}
		if(s1[i-1] == s2[i-1]){
			if(s1[i] == s2[i]) ans *=2;
			else { ans *=2; i++; }
		}else{
			if(s1[i] != s2[i]){ans *=3; i++;}
		}
		ans %= MD;
	}
	cout << ans <<"\n";
	return 0;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

x, y, z, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c=sorted(int(i) for i in input().split())

a.sort(reverse=True)
b.sort(reverse=True)
#c.sort(reverse=True)

ab = sorted(i+j for i in a for j in b)[:-k-1:-1]
c = c[:k]
abc = sorted(i+j for i in ab for j in c)[:-k-1:-1]

print(*abc[:k], sep="\n")

Measured memory_bytes: 162588
function Main(input) {
  input=input.split("\n");
  if(input[input.length-1]===''){
    input.pop();
  }
  const N=input[0].split(' ')[0]-0;
  var v=input[1].split(' ').map(e=>{
    return e-0;
  }).sort((a,b)=>{
    return a-b;
  });
  var pointer;
  while(v.length>1){
    v.splice(2,0,(v[0]+v[1])/2);
    v.shift();
    v.shift();
  }
  console.log(v[0]);
}

//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

int main() {
  int n, c, k; cin >> n >> c >> k;
  priority_queue<int, vector<int>, greater<int>> arrival;
  priority_queue<int, vector<int>, greater<int>> limit;
  int ans = 0;
  rep(i,n) {
    int t; cin >> t;
    arrival.push(t);
    limit.push(t+k);
  }
  int now = 0;
  queue<int> train;
  while(!arrival.empty()) {
    now++;
    while (now == arrival.top() && !arrival.empty()) {
      train.push(arrival.top());
      arrival.pop();
      if ((int)train.size() == c) {
        ans++;
        while(!train.empty()) {
          train.pop();
          limit.pop();
        }
      }
    }
    if (!train.empty()) {
      if (now == limit.top() || arrival.empty()) {
        ans++;
        while(!train.empty()) {
          train.pop();
          limit.pop();
        }
      }
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4184
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main
{
	static long count(String s, int start, int end)
	{
		long res = 0;
		long na = 0;
		for(int i = start; i < end; i++)
		{
			if(s.charAt(i) == 'A' )
				na++;
			else
				res += na;
		}
		
		return res;
	}
	
	public static void main (String[] args) throws java.lang.Exception
	{
		Scanner e = new Scanner(System.in);
		
		String s = e.next();
		s = s.replace("BC", "D");
		long res = 0;
		for(int i = 0; i < s.length(); )
		{
			if(s.charAt(i) == 'A' )
			{
				int j = i;
				while(j < s.length() && (s.charAt(j) == 'A' || s.charAt(j) == 'D') )
					j++;
				res += count(s, i, j);
				i = j;
			}
			else
			{
				i++;
			}
		}
		
		System.out.println(res);
	}
}

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

int main(){
  string s;
  cin >> s;
  
  bool flag1 = 0;
  bool flag2 = 0;
  for(int i = 0; i < s.size(); i++){
    if(s.at(i) == 'C') flag1 = 1;
    if(s.at(i) == 'F' && flag1 == 1) flag2 = 1;
  }
  if(flag1 == 1 && flag2 == 1) cout << "Yes" <<endl;
  else cout << "No" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<string>
#include<cstdlib>
#include<map>
#include<iomanip>
#include<sstream>
#include<vector>
#include<stack>
#include<math.h>
#include<queue>
#include<complex>
using namespace std;

int main() {
	long long int n,m,a,b,c,d,e;
	string str;
	char ch;
	long long int x[130]={};
	cout << fixed << setprecision(10);
	cin>>a>>b>>c>>d;
	cout<<(a-c)*(b-d);



	cout<<endl;
} 


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
template < typename T > string tost( const T& n ) { ostringstream stm; stm << n; return stm.str();}
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;}
int const INF = 1001001001;


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

string S;
cin >> S;
int ans = 700;
rep(i,3) if(S[i] == 'o') ans += 100;
cout << ans << endl;
return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int d;
    cin >> d;
    if (d == 25) puts("Christmas");
    if (d == 24) puts("Christmas Eve");
    if (d == 23) puts("Christmas Eve Eve");
    if (d == 22) puts("Christmas Eve Eve Eve");
    return 0;
}

Measured memory_bytes: 256
import sys
def input():
	return sys.stdin.readline()[:-1]

MOD = 1000003
q = int(input())
cumprod = [1]
for i in range(1, MOD):
	cumprod.append((cumprod[-1] * i) % MOD)

def calc(l, r):
	return (cumprod[r] * pow(cumprod[l-1], MOD-2, MOD)) % MOD

def solve(x, d, n):
	if x == 0:
		return 0
	elif d == 0:
		return pow(x, n, MOD)
	else:
		l = (x * pow(d, MOD-2, MOD)) % MOD
		if l+n-1 >= MOD:
			return 0
		else:
			return (calc(l, l+n-1) * pow(d, n, MOD)) % MOD

for _ in range(q):
	x, d, n = map(int, input().split())
	print(solve(x, d, n))

Measured memory_bytes: 45060
from math import gcd

MOD = 10**9+7
N = int(input())
d = {}
zero = 0
for i in range(N):
    a, b = map(int, input().split())
    if a == 0 and b == 0:
        zero += 1
        continue

    flip = 0
    while not (a > 0 and b >= 0):
        a, b = -b, a
        flip ^= 1

    g = gcd(a, b)
    a //= g
    b //= g
    if not (a, b) in d:
        d[(a, b)] = [0, 0]
    d[(a, b)][flip] += 1

ans = 1
for (v1, v2) in d.values():
    ans *= pow(2, v1, MOD) + pow(2, v2, MOD)-1
    ans %= MOD
ans -= 1
ans += zero
ans %= MOD
print(ans)


Measured memory_bytes: 134168
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int a,b,s;
	scanf("%d %d",&a,&b);
	s=a*b;
	if(s%2==0)
	{
		printf("Even");
	}
	else
	{
		printf("Odd");
	}
	return 0;
}

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

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

    int i,j,k;
    vector<int>  ans(N+1);
    int A;
    for( i = 1; i <= 100; i++ ){
        //if( i*i + i + 4 > N ) break;
        for( j = i; j <= 100; j++ ){
            //if( i*i + j*j + i*j + i + j + 1 > N ) break;
            for( k = j; k <= 100; k++ ){
                A = i*i + j*j + k*k + i*j + j*k + k*i;
                if( A <= N ){
                    if( i == j && j == k && k == i ) ans[A] += 1;
                    else if( i != j && j != k && k != i ) ans[A] += 6;
                    else ans[A] += 3;
                }
            }
        }
    }

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

}


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

using namespace std;

long long niz[61];
vector<pair<int,int> >potez;

int poz(int x,int n)
{
    for(int i=0;i<=n;i++)
        if(niz[i]==x)return i;
    return -1;
}

bool neopadajuci(int n)
{
    for(int i=1;i<n;i++)
    {
        if(niz[i+1]<niz[i])return false;
    }
    return true;
}

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

    long long n;
    cin>>n;
   // int maxi=INT_MIN;
  //  int mini=INT_MAX;
    for(int i=1;i<=n;i++)
    {
        int x;
        cin>>niz[i];
       // if(niz[i]>maxi)maxi=niz[i];
      //  if(niz[i]<mini)mini=niz[i];
    }
    if(neopadajuci(n))
    {
        cout<<0;
        return 0;
    }
    long long mini=*min_element(niz,niz+n+1);
    long long maxi=*max_element(niz,niz+n+1);
    if(abs(mini)>abs(maxi))
    {
        int p=poz(mini,n);
        for(int i=1;i<=n;i++)
        {
            if(i==p)continue;
            niz[i]+=mini;
            potez.push_back(make_pair(p,i));
        }
        for(int i=n-1;i>=1;i--)
        {
            niz[i]+=niz[i+1];
            potez.push_back(make_pair(i+1,i));
        }
    }
    else
    {
        int p=poz(maxi,n);
        for(int i=1;i<=n;i++)
        {
            if(i==p)continue;
            niz[i]+=maxi;
            potez.push_back(make_pair(p,i));
        }
        for(int i=2;i<=n;i++)
        {
             niz[i]+=niz[i-1];
             potez.push_back(make_pair(i-1,i));
        }
    }
    cout<<potez.size()<<endl;
    for(int i=0;i<potez.size();i++)
        cout<<potez[i].first<<" "<<potez[i].second<<endl;
  // for(int i=1;i<=n;i++)
  //     cout<<niz[i]<<" ";
    return 0;
}


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

int main() {
	list<int>L; int n, x; char s[15];
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> s;
		if (s[0] == 'i')cin >> x,  L.push_front(x);
		else if (s[6] == 'F')L.pop_front();
		else if (s[6] == 'L')L.pop_back();
		else {
			cin >> x;
			for (list<int>::iterator it = L.begin(); it != L.end(); it++)
				if (*it == x) {
					L.erase(it); break;
				}
		}
		
	}
	n = 0;
	for (list<int>::iterator it = L.begin(); it != L.end(); it++) {
		if (n++)cout << " ";
		cout << *it;
	}
	cout << endl;
	return 0;
}



Measured memory_bytes: 34244
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<cstring>
#include<cstdio>
#include<stack>
using namespace std;
int n;
int a[100001];
vector<int>e[100001];
int dfs(int u,int fa)
{
	int res=0;
	for(int i=0;i<e[u].size();i++)
	{
		int to=e[u][i];
		if(to!=fa&&a[to]<a[u])
		{
			if(dfs(to,u)==0)
				return 1;
		}
	}
	return 0;
}
signed main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<n;i++)
	{
		int u,v;
		scanf("%d%d",&u,&v);
		e[u].push_back(v);
		e[v].push_back(u);
	}
	for(int i=1;i<=n;i++)
	{
		if(dfs(i,0))
			printf("%d ",i);
	}
	return 0;
}

Measured memory_bytes: 2688
#include<iostream>
#include <algorithm>

using namespace std;

int main(void) {

	int N,T; cin >> N >> T;

	int c[1005], t[1005];

	for (int i = 1; i <= N; i++) {
		cin >> c[i] >> t[i];
	}

	int ans = 1999;

	for (int i = 1; i <= N; i++) {
		if (t[i] <= T) { ans = min(ans, c[i]); }
	}

	if (ans > 1000) {
		cout << "TLE" << endl;
	}
	else {
		cout << ans << endl;
	}
	//system("pause");
	return 0;
}

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

using namespace std;

#define forn(i, s, f) for(int i = (s); i <= (f); ++i)
#define for1(i, f, s) for(int i = (f); i >= (s); --i)
#define fora(i, x) for (auto i : x)
#define show(x) cout << #x << " = " << x << " ";
#define skip continue;
#define pb push_back
#define _1 first
#define _2 second

typedef long long ll;

const int N3 = 1e3 + 5;
const int N4 = 1e4 + 5;
const int N5 = 1e5 + 5;
const int N6 = 1e6 + 5;
const int N7 = 1e7 + 5;
const int N8 = 1e8 + 5;
const int N9 = 1e9 + 5;

int n, c, k, l, r, ct, bus;

pair < int, int > a[N5];

int main()
{
    cin >> n >> c >> k;
    forn (i, 1, n)
    {
        cin >> a[i]._1;
        a[i]._2 = a[i]._1 + k;
    }
    sort(a + 1, a + n + 1);
    forn (i, 1, n)
    {
        if (i == 1)
        {
            r = a[i]._2;
            ct = 1;
        }
        else
        {
            l = a[i]._1;
            if (ct + 1 <= c && l <= r)
            {
                ++ct;
            }
            else
            {
                ct = 1;
                ++bus;
                r = a[i]._2;
            }
        }
    }
    cout << bus + (ct > 0);
}


Measured memory_bytes: 1024
#include<stdio.h>
#define N 100000
#define NOT_FOUND 0

int binarySearch(int);
int S[N],n;

int main(){
  int count=0;
  int T[N],i,j,q;

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

  for(j=0;j<q;j++){

    if(binarySearch(T[j]) != 0){
        count++;

    }
  }

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

  return 0;
}

int binarySearch(int key){
 int l=0;
 int r,mid;

 r=n;

 while(l < r){
   mid = (l+r)/2;

   if(key == S[mid]) return 1;

  else if(key < S[mid]) {
     r = mid;

   }
     else {
       l = mid + 1;

     }

}
 return NOT_FOUND;


}




Measured memory_bytes: 2288
#include<iostream>
#include<string>
#include<ctype.h>
using namespace std;
int main(){
	string a;
	char check;
	getline(cin,a);
	for(int i=0;i<a.size();i++){
		if(isalpha(a[i])!=0){
			check=a[i];
			a[i]=tolower(a[i]);
			if(check==a[i])
				a[i]=toupper(a[i]);
		}
		cout<<a[i];
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 1176
MOD = 10**9 + 7
n = gets.to_i
aa = gets.split.map(&:to_i)
sum = aa.inject(&:+) % MOD

ans = 0
0.upto(n-1) do |i|
  sum -= aa[i]
  sum += MOD if sum < 0
  ans += aa[i] * sum
  ans %= MOD
end

puts ans


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

int main() {

  string S,T;
  cin >> S >>T ;

  int N,aaa=0;

  N = S.size();

  for(int i=0; i<N;i++){
    if(!(S.at(i)==T.at(i))){
      aaa++;
    }
  }

    
  cout << aaa << endl;

  

  
}


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

int main() {
	int N, K, sum = 0;
	cin >> N >> K;
	for (int i = 0; i < N; i++) {
		int x;
		cin >> x;
		sum += min(x, abs(K - x)) * 2;
	}
	cout << sum << endl;
}



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

using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

#define ull unsigned long long
#define ld long double

template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;

#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) rep2(i, 0, n)
#define rep1(i, n) rep1(i, 1, n + 1)

// #define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
// #define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()  //

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

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

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

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(15);
    //    cout << std::setfill('0') << std::setw(2);

    long long N;
    std::cin >> N;

    V<ll> memo(N + 1, -1);
    auto dfs = [&](auto self, int i) {
        if (memo[i] > 0) return memo[i];
        if (i == 0) return memo[i] = 2;
        if (i == 1) return memo[i] = 1;
        return memo[i] = self(self, i - 1) + self(self, i - 2);
    };
    ll ans = dfs(dfs, N);
    cout << ans << endl;
    return 0;
}


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

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

    for (int i = k; i < n; i++) {
        if (a[i] > a[i-k]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 3972
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

string str;

int main(void){
    ll ans=0;
    cin >> str;
    ll cnt=0;
    int n=str.size();
    for(int i=n-1;i>=0;i--){
        if(str[i]=='W'){
            cnt++;
        }else{
            ans+=cnt;
        }
    }
    printf("%lld\n",ans);
    return 0;
}

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

const uint32_t MOD = 1e9+7;
uint64_t f[100001];

uint64_t fact(uint64_t n){
    if(f[n]) return f[n];
    return f[n] = (n*fact(n-1))%MOD;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    f[0] = 1LL;
    uint64_t n, m;
    cin >> n >> m;
    if(n<m) swap(n,m);
    if(n-m > 1LL){
        cout << 0 << "\n";
    }
    else{
        uint64_t ans = 1LL;
        ans += (n==m);
        ans = (ans*fact(n)*fact(m))%MOD;
        cout << ans << "\n";
    }
}

Measured memory_bytes: 2560
//2018-1-15
//miaomiao
//
#include <bits/stdc++.h>
using namespace std;

#define For(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define N (400+5)

bool dead[N], vis[N][N];

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

	scanf("%d%d", &n, &m);
	For(ti, 1, m){
		scanf("%d%d", &x, &y);

		if(vis[x][y]) dead[x] = dead[y] = true;
		if(dead[x]) dead[y] = true; if(dead[y]) dead[x] = true;
		vis[x][y] = vis[y][x] = true;
		
		For(i, 1, n) if(i != x && i != y){
			if(vis[i][x]) vis[i][y] = vis[y][i] = true;
			if(vis[i][y]) vis[i][x] = vis[x][i] = true;
		}
	}

	int ans = 0;
	For(i, 1, n) if(!dead[i]) For(j, i+1, n)
		if(!dead[j]) ans += !vis[i][j];
	printf("%d\n", ans);

	return 0;
}

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

const int MAXN = 5005;
int arr[MAXN], ans[MAXN], n, m;
int main() {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++) scanf("%d", arr + i);
	int tot = 0;
	for (int i = 0, ban = -1; i <= m; i++) {
		int mn = -1;
		for (int j = 1; j <= n; j++)
			if (j != ban && (mn < 0 || arr[j] < arr[mn])) mn = j;
		if (arr[mn] == 0) return puts("-1") * 0;
		--arr[mn];
		for (int j = 1; j <= n; j++) if (j != ban && j != mn) {
			ans[++tot] = j, --arr[j];
			if (arr[j] < 0) return puts("-1") * 0;
		}
		ban = mn;
		ans[++tot] = mn;
	}
	printf("%d\n", tot);
	for (int i = 1; i <= tot; i++) printf("%d ", ans[i]);
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define repp(i,n) for(int (i) = 1; (i) <= (n); ++(i))
#define ALL(v) v.begin(),v.end()
#define _Pi 3.1415926535
#define _MOD = 1e9+7;
using namespace std;
using ll = long long;
using pint = pair<int,int>;
template<class T> inline bool chmax(T& a, T b){if(a<b){a = b; return true;} return false;}
template<class T> inline bool chmin(T& a, T b){if(a>b){a = b; return true;} return false;}
template<class T> inline T GCD(T a, T b){return b?GCD(b,a%b):a;}
template<class T> inline T LCM(T a, T b){return a*b/GCD(a,b);}

bool IsCons(int bit, int n, vector<vector<pint>> t){
    rep(i,n){
        if(!(bit&(1<<i))) continue;
        else for(pint xy : t[i]){
            if(xy.second==1 && !(bit&(1<<xy.first))) return false;
            else if(xy.second==0 && bit&(1<<xy.first)) return false;
        }
    }
    return true;
}

int main(){
    int n; cin >> n;
    vector<int> a(n);
    vector<vector<pint>> t(n,vector<pint>(0));
    rep(i,n){
        cin >> a[i];
        rep(j,a[i]){
            int x,y; cin >> x >> y;
            --x;
            t[i].push_back(make_pair(x,y));
        }
    }

    int ans = 0;
    rep(bit,1<<n){
        if(IsCons(bit,n,t)){
            chmax(ans,__builtin_popcount(bit));
        }
    }

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


Measured memory_bytes: 256
//Radhe Radhe
#include<bits/stdc++.h>
#define godspeed  ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);

#define ll long long
#define ld long double
#define fi first
#define se second
#define mp make_pair
#define rep1(i,a,b)    for(ll i=a; i<=b; i++)
#define repVect(i,n)    for(ll i=0; i<sum.size(); i++)
#define fixed cout.setf(ios::fixed);
#define Precise cout.precision(7);
#define yes cout<<"YES"<<'\n';
#define no cout<<"NO"<<'\n';
using namespace std;

int main()
{
    godspeed
    ll  i,j,k,l,n;
    string a,b;
    cin>>n;
    n=sqrt(n);
    cout<<n*n<<endl;
       return 0;
}





Measured memory_bytes: 3660
def typical_stairs():
    n, m = map(int, input().split())
    dangerous = set(int(input()) for _ in range(m))
    mod = 1000000007
    dp = [0] * (n + 1)
    dp[0] = 1
    if 1 not in dangerous:
        dp[1] = 1
    for i in range(2, n + 1):
        if i not in dangerous:
            dp[i] = dp[i - 2] + dp[i - 1]
    print(dp[-1] % mod)


if __name__ == '__main__':
    typical_stairs()


Measured memory_bytes: 460148
public class Main{
  static int N = 1000001;
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    int[] p;
    int pn, i, j, n, count, l, m, r;

    p = new int[N / 6];
    pn = getprime(p);

    for(;;){
      n = sc.nextInt();
      if(n == 0)break;
      count = 0;
      for(i = 0;i < pn && p[i] <= n / 2;i++){
        l = 0; r = pn - 1;
        for(;l <= r;){
          m = (l + r) / 2;
          if(p[i] + p[m] < n)l = m + 1;
          else if(p[i] + p[m] > n)r = m - 1;
          else{ count++; break; }
        }
      }
      out.println(count);
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
  private static int getprime(int[] p){
    int i, j, count = 0;
    boolean[] e;
    e = new boolean[N];
    e[0] = true; e[1] = true;
    for(i = 2;i < N;i++)if(!e[i]){
      p[count++] = i;
      for(j = i * 2;j < N;j+=i)e[j] = true;
    }
    return count;
  }
}

Measured memory_bytes: 23416
#include <iostream>

using namespace std;

int main(){
    int r, c, val[101][101];
    
    // input
    cin >> r >> c;
    
    for(int i = 0; i < r; i++){
        for(int j = 0; j < c; j++){
            cin >> val[i][j];
        }
    }
    
    // output
    // row
    for(int i = 0; i < r; i++){
        int sum = 0;
        for(int j = 0; j < c; j++){
            cout << val[i][j] <<" ";
            sum += val[i][j];
        }
        cout << sum << endl;
    }
    
    // column
    int final = 0;
    for(int i = 0; i < c; i++){
        int sum = 0;
        for(int j = 0; j < r; j++){
            sum += val[j][i];
        }
        cout << sum << " ";
        final += sum;
    }
    cout << final << endl;
    
    return 0;
    
}


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

int main()
{
	int i, N, T[101], M, P[101], X[101];
	scanf("%d", &N);
	for (i = 1; i <= N; i++) scanf("%d", &(T[i]));
	scanf("%d", &M);
	for (i = 1; i <= M; i++) scanf("%d %d", &(P[i]), &(X[i]));
	
	int sum = 0;
	for (i = 1; i <= N; i++) sum += T[i];
	for (i = 1; i <= M; i++) printf("%d\n", sum - T[P[i]] + X[i]);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 128
N = int(input())
S = input()
# import numpy as np
# flagbox = np.zeros(1000).reshape(10,10,10)
# flagtable = np.zeros(100).reshape(10,10)
# flaglist = np.zeros(10)
flagbox = [[[0]*10 for _ in range(10)] for _ in range(10)]
flagtable = [[0]*10 for _ in range(10)]
flaglist = [0]*10
for s in S:
    ss = int(s)
    for i in range(10):
        for j in range(10):
            if flagtable[i][j] == 1:
                flagbox[i][j][ss] = 1

    for i in range(10):
        if flaglist[i] == 1:
            flagtable[i][ss] = 1

    if flaglist[ss] == 0:
        flaglist[ss] = 1

# print sum of flagbox
#print(int(np.sum(flagbox)))
ans = 0

for i in range(10):
    for j in range(10):
        for k in range(10):
            if flagbox[i][j][k] == 1:
                ans += 1
print(ans)

Measured memory_bytes: 43884
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
using pint = pair<int, int>;
using pll = pair<ll, ll>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(ll i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(ll i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)

int main() {
    ll n;
    vector<ll> a;
    
    ll amax0 = 0;
    ll amax1 = 0;
    
    cin >> n;
    ll tmp;
    REP(i, n) {
        cin >> tmp;
        a.emplace_back(tmp);
        if (amax0 < tmp) {
            amax1 = amax0;
            amax0 = tmp;
        } else if (amax1 < tmp) {
            amax1 = tmp;
        }
    }
    
    REP(i, n) {
        if (a[i] == amax0) {
            cout << amax1 << endl;
        } else {
            cout << amax0 << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 3312
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define md 1000000007
#define ld long double
using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long n, i = 0, j= 0, k = 0, l = 0, m = 0, a = 0, b = 0, sum = 0, x = 0, y = 0, z = 0, c, p;
    cin >> n;
    ll arr[n+1], brr[n+1];
    for(i = 1; i <= n; i++){
        cin >> arr[i];
    }
    m = arr[1];
    sum++;
    for(i = 2; i <= n; i++){
        m = min(m,arr[i]);
        if(arr[i] <= m){
            sum++;
        }
    }
    cout << sum;

    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, s, n) for (int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  int n;
  double d;
  cin >> n >> d;
  int count = 0;
  rep(i, n) {
    ll x, y;
    cin >> x >> y;
    double di = sqrt(x * x + y * y);
    if (di <= d) count++;
  }
  cout << count << endl;
  return 0;
}

Measured memory_bytes: 3840
import java.math.*;
import java.util.*;

public class Main {
    static int gcd(int a, int b) {
        if (b == 0)
            return a;
        return gcd(b, a % b);
    }

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a[] = new int[n];
        for(int i=0;i<n;i++)
            a[i] = sc.nextInt();
        Arrays.sort(a);
        System.out.println(a[a.length - 1] - a[0]);
    }
}


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

typedef long long LL;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(x) (x).begin(),(x).end()
const int IINF = 1e9;
const LL LINF = 1e18;
const LL MOD = 1e9+7;

int main() {
    int a, b;
    cin >> a >> b;
    int c = a*b;
    if(c%2 == 0) {
        cout << "Even" << endl;
    }else{
        cout << "Odd" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int q,temp,i,j,n,a[100000],x;

  scanf("%d",&n);

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

  x=a[n];
  i=0;
  for(j=1;j<=n-1;j++){
    if(a[j]<=x){
      ++i;
      temp=a[i];
      a[i]=a[j];
      a[j]=temp;
    }
  }
  temp=a[i+1];
  a[i+1]=a[n];
  a[n]=temp;
  q=i+1;

  for(i=1;i<=n;i++){
    if(i-1)printf(" ");
    if(i==q)printf("[");
    printf("%d",a[i]);
    if(i==q)printf("]");
  }
  printf("\n");

  return 0;
}
  



Measured memory_bytes: 2108