akhauriyash/Code-Regression huggingface dataset:
#include<iostream>  
#include<cstring>  
#include<cstdio>  
#include<cmath>  
#include<algorithm>  
  
using namespace std;  
  
bool s[15][10005]= {0};  
  
int ans=0;  
int n, m;  
  
int dfs(int x)  
{  
    if(x==n+1)  
    {  
        int sum=0;  
        int term=0;  
        for(int j=1;j<=m;j++)  
        {  
            for(int i=1;i<=n;i++)  
                if(s[i][j]==1)term++;  
            sum += term > n-term ? term : n-term;  
            term=0;  
        }  
        ans=max(ans,sum);  
        return ans;  
    }  
    int a=dfs(x+1);  
    for(int i=1;i<=m;i++)  
        s[x][i]=!s[x][i];  
    int b=dfs(x+1);
    return a>b?a:b;  
}  

int main()  
{  
    //freopen("in.in","r",stdin);  
    while(scanf("%d%d",&n,&m)!=EOF)  
    {  
        if(n==0&&m==0)break;  
        ans=0;  
        for(int i=1; i<=n; i++)  
            for(int j=1; j<=m; j++)  
                scanf("%d",&s[i][j]);  
        cout<<dfs(1)<<endl;  
        //printf("%d\n",ans);  
    }  
    return 0;  
}  


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

long long N;
pair<long long, int> A[1 << 18];
long long dp[2009][2009];

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i].first;
		A[i].second = i + 1;
	}
	sort(A, A + N);

	for (int i = N - 1; i >= 0; i--) {
		for (int j = 1; j <= N - i; j++) {
			long long cl = j, cr = j + i;
			dp[cl + 1][cr] = max(dp[cl + 1][cr], dp[cl][cr] + A[i].first * (A[i].second - cl));
			dp[cl][cr - 1] = max(dp[cl][cr - 1], dp[cl][cr] + A[i].first * (cr - A[i].second));
		}
	}

	long long ret = 0;
	for (int i = 1; i <= N + 1; i++) ret = max(ret, dp[i][i - 1]);
	cout << ret << endl;
	return 0;
}

Measured memory_bytes: 26336
#include <stdio.h>

int main()
{ int n,al=0,ul=0,i,temp,tt=0;
  char s[3],z='0';
scanf("%d",&n);
 if(n%2==1){printf("NO\n"); return 0;}
for(i=0;i<n;i++)
{ scanf("%s",s);
   if(s[0]=='U' && i==0){tt=1;break;}
   if(i==n-1 && s[0]=='A'){tt=1;break;}
  
  if(s[0]=='U')ul++; else 
   if(s[0]=='A')al++;

  if(ul>al){tt=1;break;}
}
  
 if(ul==n/2 && al== n/2 && tt==0)printf("YES\n");
 else printf("NO\n");




return 0;
}


Measured memory_bytes: 2104
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
constexpr int MOD=1000000007;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

int main(void){
    lint N,K;
    cin >> N >> K;
    lint A[N];
    rep(i,N) cin >> A[i];
    rep(i,N) A[i]--;
    bool reach[N]={};
    int last[N]={};
    int now=0;
    int cnt=0;
    if(K<=1000000){
        while(K){
            now=A[now];
            K--;
        }
        cout << now+1 << endl;
        return 0;
    }
    while(reach[now]==false){
        last[now]=cnt;
        reach[now]=true;
        now=A[now];
        cnt++;
    }
    lint dis=cnt-last[now];
    K-=last[now];
    K%=dis;
    rep(i,N){
        if(K==last[i]-last[now]){
            cout << i+1 << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 6196
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;
using System.Numerics;

public class Program
{
    public static void Main(string[] args)
    {
        int n = int.Parse(Console.ReadLine());

        Console.WriteLine(n % 111 == 0 ? (n / 111) * 111 : (n / 111 + 1) * 111);
        Console.ReadLine();
    }
}

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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define pb push_back

int twoWariCount(int val) {
  if(val % 2 != 0) return 0;
  int count = 0;
  while(val % 2 == 0) {
    val /= 2;
    count++;
  }
  return count;
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<int> vec;
  int a;
  rep(i, n) {
    cin >> a;
    vec.pb(a);
  }

  int sum = 0;
  rep(i, n) {
    sum += twoWariCount(vec[i]);
  }

  cout << sum << endl;
}


Measured memory_bytes: 384
// template version 1.6
// {{{ define basic macro
using namespace std;
#include <iostream>
#include <bits/stdc++.h>
// varibable settings
#define int long long
#define INF 1000000000000000000LL
// #define INF 2147483647
#define MOD 1000000007LL
// #define MOD 998244353LL
#define infile "../test/sample-1.in"

#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(int)(a);i<(int)(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define _rrep(i,n) rrepi(i,0,n)
#define rrepi(i,a,b) for(int i=(int)(b-1);i>=(int)(a);--i)
#define rrep(...) _overload3(__VA_ARGS__,rrepi,_rrep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define uni(x) sort(all(x));x.erase(unique(all(x)),x.end())
#define ten(n) ((int)1e##n)
template<class T, size_t N> size_t sza(const T (&array)[N]) { return N; }
template<class T> inline void chmax(T &a, const T &b) { if(a < b) a = b; }
template<class T> inline void chmin(T &a, const T &b) { if(a > b) a = b; }
template<class T=int> T in() {T x; cin>>x; return (x);}
struct Fast { Fast(){ std::cin.tie(0); ios::sync_with_stdio(false); } } fast;

// dump macro
#ifdef PCM
  #include "dump.hpp"
#else
  #define dump(...) 42
  #define dump_1d(...) 42
  #define dump_2d(...) 42
#endif

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef long double ld;
typedef pair<int,int> pii;
typedef tuple<int,int,int> iii;
template<typename T> using PQ = priority_queue<T, vector<T>, greater<T>>;
int dx[]={1, -1, 0, 0};
int dy[]={0, 0, 1, -1};
#define fi first
#define se second

// }}}

int res;
int p[55];
int l[55];

// l_n = 2^(n+2)-3
int dfs(int n, int x){
  if (x<=0) return 0;
  if (x>=l[n]){
    res += p[n];
    return 0;
  }

  // left
  dfs(n-1, x-1);

  // center pati
  if (x >= 1+l[n-1]+1) res += 1;

  // left
  dfs(n-1, x-(1+l[n-1]+1));

  return 0;
}

int solve(){
  int N,X;cin>>N>>X;
  res = 0;
  l[0]=1;p[0]=1;
  rep(i, 1, 55) {
    l[i] = 2*l[i-1]+3;
    p[i] = 2*p[i-1]+1;
  }

  dfs(N, X);

  cout << res << endl;

  return 0;
}

signed main() { //{{{
#ifdef INPUT_FROM_FILE
  std::ifstream in(infile);
  std::cin.rdbuf(in.rdbuf());
#endif
  solve();
  return 0;
} //}}}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
ll mod=1e9+7;
bool visited[1000001];

ll dfs(vector<ll> v[],ll idx)
{
    visited[idx]=1;
    ll ans=1;
    for(auto a:v[idx])
        if(!visited[a]) ans+=dfs(v,a);
    return ans;
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    // cin>>t;
    while(t--)
    {
        ll n,m;cin>>n>>m;
        vector<ll> v[n+1];
        ll a,b;
        while(m--)
        {
            cin>>a>>b;
            v[a].pb(b); v[b].pb(a);
        }
        for(int i=0;i<=n;i++) visited[i]=false;
        ll max_=0;
        for(int i=1;i<=n;i++)
        {
            if(!visited[i])
                max_=max(max_,dfs(v,i));
        }
        cout<<max_;
    }
}

Measured memory_bytes: 24068
// https://atcoder.jp/contests/abc150/tasks/abc150_d

#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,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(_i, n) printf("%d%c", a[_i], _i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(_i, n) REP(_j, m) printf("%d%c", a[_i][_j], _j + 1 == m ? '\n' : ' '); puts("")

const int N_MAX = 1e5;
const int M_MAX = 1e9;
const int A_I_MAX = 1e9;

int N, M;
ll a[N_MAX];

//------------------------------------------------------------------------------
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a % b);
}

//------------------------------------------------------------------------------
void solve() {
  REP(i, N) a[i] /= 2;
  ll lcm = 1;
  REP(i, N) {
    lcm = lcm * a[i] / gcd(lcm, a[i]);
    if (lcm > M) {
      puts("0");
      return;
    }
  }
  REP(i, N) {
    if (lcm / a[i] % 2 == 0) {
      puts("0");
      return;
    }
  }
  // printf("%lld\n", lcm);
  printf("%lld\n", (M / lcm + 1) / 2);
}

void input() {
  scanf("%d%d", &N, &M);
  REP(i, N) scanf("%lld", a + i);
}

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


Measured memory_bytes: 1024
n=gets.to_i
p=gets.split.map(&:to_i)
q=gets.split.map(&:to_i)

a=0
b=0
[*1..n].permutation.to_a.each_with_index do |perm, i|
    if perm==p
        a=i
    end
    if perm==q
        b=i
    end
end

puts (a-b).abs


Measured memory_bytes: 20272
#include <iostream>
#include <map>
#include <cstdio>
#include <cstring>
#include <cmath>

using namespace std;

typedef unsigned long long ull;

const ull MOD = 1e9 + 7;

// <素因数, 指数>
map<int, int> mp;

void primeFactorization(int n)
{
    // 平方根を保存
    auto s = floor(sqrt(n));
    int r = 0;
    
    for (int i = 2; i <= s; i++)
    {
        // 割り切れる
        if ((n % i) == 0)
        {
            r = 0;
            
            do
            {
                r++;
                n = n / i;
            } while ((n % i) == 0);
            
            mp[i] += r;
        }
    }
    
    // 残った素数を追加
    if (n > s)
    {
        mp[n]++;
    }
}

int main()
{
    int N;
    
    cin >> N;
    
    // 1! のみ特別扱い
    if (N == 1)
    {
        printf("1\n");
        return 0;
    }
    
    for (int i = 1; i <= N; i++)
    {
        primeFactorization(i);
    }

#if 0
    // 素因数分解の結果を表示
    printf("%d!=", N);
    for (auto itr = mp.begin(); itr != mp.end(); ++itr)
    {
        printf("(%d^%d)", itr->first, itr->second);
        ++itr;
        if (itr != mp.end())
        {
            printf("x");
        }
        --itr;
    }
    printf("\n");
#endif
    
    // 指数部 + 1 を掛け合わせて解答を計算
    ull answer = 1;
    for (auto itr = mp.begin(); itr != mp.end(); ++itr)
    {
        answer *= itr->second + 1;
        answer %= MOD;
    }
    
    printf("%lld\n", answer);
    
    return 0;
}


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

int main(){
    int n, h;
    scanf("%d %d", &n, &h);
    vector<int> b;
    int m = 0;
    for(int i = 0; i < n; i++){
        int x, y;
        scanf("%d %d", &x, &y);
        m = max(m, x);
        b.push_back(y);
    }
    int ans = 0;
    sort( b.begin(), b.end() );
    reverse(b.begin(), b.end() );
    for(int x: b ){
        if( x>m and h > 0 ){
            h -= x;
            ans++;
        }
    }
    printf("%d\n", ans + (h>0?h/m + !!(h%m):0) );
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <ios>
#include <iomanip>
#include <algorithm>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define OUTPUT_PERMUTATION(n) do{VI v(n); iota(ALL(v), 1); do{REPx(x, v) cout << x << " "; ENDL} while(next_permutation(ALL(v)));} while(0);
#define MAKE_PERMUTATION(n) do{VVI a(fact(n), VI(n)); int idx = 0; VI v(n); iota(ALL(v), 1); do{REP(i, n) a[idx][i] = v[i]; idx++; PER = a;} while(next_permutation(ALL(v)));} while(0); // int fact(), VVI PERを宣言しておく
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
using VD = vector<double>;
const int INF = 1e9;
const LL MOD = 1e9 + 7;

template<class T> inline bool chmin(T &a, T b){if (a > b) {a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b){if (a < b) {a = b; return true;} return false;}

void END(){cout << 1 << endl; exit(0);}

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, y;
  cin >> n >> y;
  bool ans = false;
  REP(i, n+1) REP(j, n-i+1)
  {
    int k = n - i - j;
    if (10000*i + 5000*j + 1000*k == y)
    {
      ans = true;
      cout << i << " " << j << " " << k;
      return 0;
    }
  }
  if (!ans) cout << "-1 -1 -1";

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
const int Nmax = 5e5;
const ll P = 1e9+7;
int N;
int A[Nmax];

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

    vector<int> cum(N+1);
    // cout << 0 << endl;
    for(int i=0; i<N; i++){
        cum[i+1] = cum[i]^A[i];
        // cout << cum[i+1] << endl;
    }
    //cout << cum[N] << endl;

    vector<int> zero_cnt(N+1);
    map<int, vector<int> > pos;
    for(int i=0; i<N; i++) {
        zero_cnt[i+1] = zero_cnt[i]+(cum[i+1]==0?1:0);
        if(cum[i+1]!=0) pos[cum[i+1]].push_back(i);
    }

    vector<vector<ll> > dp(2, vector<ll>(N+1));
    if(cum[N]!=0){
        dp[0][0] = 1;
        for(int i=0; i<N; i++){
            dp[0][i+1] = dp[0][i];
            dp[1][i+1] = dp[1][i];
            if(cum[i+1]==0){
                dp[0][i+1] += dp[1][i];
            } else if(cum[i+1]==cum[N]) {
                dp[1][i+1] += dp[0][i];
            }
            dp[0][i+1] %= P;
            dp[1][i+1] %= P;
        }
        cout << dp[0][N-1] << endl;
    } else {
        ll ans = 0;
        for(auto p: pos) {
            auto m = p.second;
            dp[0][0] = 1;
            for(int i=0; i<2*m.size(); i++){
                dp[0][i+1] = dp[0][i];
                dp[1][i+1] = dp[1][i];
                if(i%2==0){
                    dp[1][i+1] += dp[0][i];
                } else {
                    int k=0;
                    if(i<2*m.size()-1){
                        k = zero_cnt[m[i/2+1]]-zero_cnt[m[i/2]];
                        //cout << i << ":" << zero_cnt[m[(i+1)/2]] << " " << zero_cnt[m[i/2]] << endl;
                    }
                    dp[0][i+1] += k * dp[1][i];
                }
                dp[0][i+1] %= P;
                dp[1][i+1] %= P;
                // cout << dp[0][i+1] << " " << dp[1][i+1] << endl;
            }
            // cout << p.first << " " << m.size() << " " << dp[1][2*m.size()-1] << endl;
            ans += dp[1][2*m.size()-1];
            ans %= P;
        }
        ll z = 1;
        for(int i=0; i<zero_cnt[N]-1; i++) z = (2*z)%P;
        // cout << zero_cnt[N] << " " << z << endl;
        ans += z;
        cout << ans%P << endl;
    }

	return 0;
}


Measured memory_bytes: 49280
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll>pi;
const int MAXN=200005;
const int MOD=1000000007;
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define DEC(i,a,b) for(int i=(a);i>=(b);i--)
#define fst first
#define snd second
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define sz(v) ((int)(v).size())
#define db(x) cerr<<#x<<" = "<<x<<"\n"
#define LOW(v,x) (lower_bound(all(v),(x))-(v).begin())

int N,M;
vector<int>vec[MAXN];
bool P[MAXN];

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	cin>>N>>M;
	FOR(i,1,M){
		int k;cin>>k;
		FOR(j,1,k){
			int x;cin>>x;--x;
			vec[i].pb(x);
		}
	}
	FOR(i,1,M)cin>>P[i];
	int ans=0;
	FOR(bm,0,(1<<N)-1){
		bool poss=true;
		FOR(i,1,M){
			bool cnt=0;
			for(auto k:vec[i]){
				if(bm&(1<<k))cnt^=1;
			}
			if(cnt!=P[i]){
				poss=false;
				break;
			}
		}
		if(poss)ans++;
	}
	cout<<ans<<"\n";
}
/*
*/


Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define DL double
#define MLL map<LL,LL>::iterator
#define MSL map<string,L>::iterator
#define MLS map<LL,string>::iterator
#define MSS map<string,string>::iterator
#define MCL map<char,LL>::iterator
#define SL set<LL>::iterator
#define SS set<string>::iterator
#define VL V<LL>::iterator
#define G getline
#define SZ size()
#define IN insert
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define MAX 1e18
#define MIN -1e18
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
V<LL>v;
map<LL,LL>u;
void Y()
{
    cout<<"Yes"<<endl;
}
void N()
{
    cout<<"No"<<endl;
}
int main()
{
    FAST;
    LL n,m,i,j,k,p,q,o,l,s,t,z=0,r;
    string a,b,c;
    DL x,y;
   cin>>n;
   for(i=0;i<n-1;i++)
   {
       cin>>o;
       u[o]++;
   }
   for(i=1;i<=n;i++)
   {
       cout<<u[i]<<endl;
   }

    return 0;
}


Measured memory_bytes: 16124
#include <bits/stdc++.h>
using namespace std;
struct Fast {
    Fast() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} fast;

long long mod = 1000000007;

long long div(long long a, long long b, long long c) { return b / c - (a - 1) / c; }

void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}
void yes() {
    cout << "Yes" << endl;
    exit(0);
}
void no() {
    cout << "No" << endl;
    exit(0);
}

int main() {
    long long r, d, ans = 0, n, sum = 0;
    string t;
    cin >> n;
    vector<string> s(n);
    vector<int> p(n);
    vector<pair<string, int>> cnt(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
        cin >> p[i];
        cnt[i].first = s[i];
        cnt[i].second = p[i];
    }
    sort(s.begin(), s.end());
    s.erase(unique(s.begin(), s.end()), s.end());
    for (int i = 0; i < s.size(); i++) {
        vector<int> so;
        for (int j = 0; j < n; j++) {
            if (s[i] == cnt[j].first) {
                t = cnt[j].first;
                so.push_back(cnt[j].second);
            }
        }
        sort(so.rbegin(), so.rend());
        for (int gg = 0; gg < so.size(); gg++) {
            for (int j = 0; j < n; j++) {
                // cout << t << " " << so[j] << endl;
                // cout << so[gg]
                //      << " "
                //         "gg"
                //      << endl;
                if (cnt[j].first == t && cnt[j].second == so[gg]) {
                    cout << j + 1 << endl;
                }
            }
        }
    }
}

Measured memory_bytes: 256
from collections import defaultdict
import itertools
d = defaultdict(list)
n = int(input())
for i in range(n):
  s = input()
  d[s[0]].append(s)
cnt = 0
for v in itertools.combinations(["M","A","R","C","H"], 3):
  cnt += len(d[v[0]])*len(d[v[1]])*len(d[v[2]])
print(cnt)

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

using namespace std;
typedef long long int lli;
lli n;
vector <vector <lli> > v(3);
lli dp[100005][3];
lli solve(lli i,lli k);

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	lli ans;
	cin>>n;
	for (int i=0;i<3;i++){
		v[i].resize(n);
	}
	for (int i=0;i<n;i++){
		cin>>v[0][i]>>v[1][i]>>v[2][i];
	}
	for (int i=0;i<n;i++){
		dp[i][0]=-1;
		dp[i][1]=-1;
		dp[i][2]=-1;
	}
	solve(0,0);
	solve(0,1);
	solve(0,2);
	ans=max(dp[0][0],max(dp[0][1],dp[0][2]));
	cout<<ans<<endl;
	
	return 0;
}

lli solve(lli i,lli k){
	if (i==n) return 0;
	if (dp[i][k]!=-1) return dp[i][k];
	dp[i][k]=max(solve(i+1,(k+1)%3)+v[k][i],solve(i+1,(k+2)%3)+v[k][i]);
	return dp[i][k];
}

Measured memory_bytes: 11264
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pii pair<ll, ll>
#define SZ(x) ((int)(x).size())
// #define endl "\n"
#define vvi vector<vector<int> >
#define vvl vector<vector<long long> >
ll mod = 1e9 + 7;
//const double pi = acos(-1.0);
/*
ll kmp(string x)
{
    ll n= x.length();
    //cout<<x<<endl;
    vector<ll> lcp(x.length(), 0);
    for(ll i=1;i<n;i++)
    {
        ll j=lcp[i-1];
        while(j>0 && x[j]!=x[i])
            j=lcp[j-1];
        if(x[i]==x[j])
            j++;
        lcp[i]=j;
    }
    return lcp[n-1];
}

int N = 1000002;
int ar[100002];
void sieve()
{
    for(int i=1;i<=N;i++)
        ar[i] = 1;
    ar[0] = 0;
    for(int i=2;i*i<=N;i++)
    {
        if(ar[i] && i*i<=N)
        {
            for(int j = i*i; j<=N;j+=i)
                ar[j] = 0;
        }
    }
}

ll modex(ll a,ll b){
    if(b<=0){
        return 1;
    }
    if(b%2==0)
    {
        ll x = modex(a, b/2);
        return ((x*x)%mod);
    }
    else
        return ((a%mod * modex(a, b-1))%mod);
}

ll c[1010][1010];

ll combina(ll i, ll j){
        for (int i=0;i<=1005;i++)
        for (int j=0;j<=i;j++)
        {
            if (j==i||j==0)
                c[i][j]=1;
            else
            c[i][j]=c[i-1][j-1]+c[i-1][j];
            c[i][j]%=mod;
        }
        return c[i][j];
}
void find_fac(int x){
    vector<ll> di;
    for(ll i = 2; i*i <= x; i++)
    {
        if(x%i==0){
            di.push_back(i);
            while(x%i==0)
                x/=i;
        }
    }
    if(x > 1)
        di.push_back(x);
}
*/



int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cout<<fixed;
    cout.precision(12);
    ll k;
    cin>>k;
    int l = 0;
    for(int i=0;i<=k;i++){
        l = (l*10 + 7)%k;
        if(l==0)
        {
            cout<<i+1;
            return 0;
        }
    }
    cout<<-1;
    return 0;
}


Measured memory_bytes: 3640
package main

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

var cnt int

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	n := nextInt(sc)
	ary := make([]int, n)
	for i := 0; i < n; i++ {
		ary[i] = nextInt(sc)
	}
	shellSort(ary, n)
}

func nextInt(sc *bufio.Scanner) int {
	sc.Scan()
	num, _ := strconv.Atoi(sc.Text())
	return num
}

func insertionSort(ary []int, n, g int) {
	for i := g; i < n; i++ {
		v := ary[i]
		j := i - g
		for 0 <= j && v < ary[j] {
			ary[j+g] = ary[j]
			j -= g
			cnt++
		}
		ary[j+g] = v
	}
}

func shellSort(ary []int, n int) {
	var g []int
	h := 1
	for h <= n {
		g = append(g, h)
		h = 3*h + 1
	}

	glen := len(g)
	fmt.Println(glen)

	var s string
	for i := glen - 1; 0 <= i; i-- {
		s += " " + strconv.Itoa(g[i])
		insertionSort(ary, n, g[i])
	}
	fmt.Println(strings.TrimSpace(s))

	fmt.Println(cnt)
	for _, v := range ary {
		fmt.Println(v)
	}
}



Measured memory_bytes: 17432
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int a, b, h;
    cin >> a >> b >> h;
    cout << (a + b) * h / 2 << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
typedef long long ll;
ll gcd(ll m, ll n){
	while(m!=n)m>n?m-=n:n-=m;
  		//if (m>n) m = m - n;
  		//else n = n - m;
	return m;
}
ll lcm(ll m,ll n){return ((m/gcd(m, n))*n);}
int main(){
	ll a,b;
	while(cin>>a>>b)cout<<gcd(a,b)<<' '<<lcm(a,b)<<endl;
}

Measured memory_bytes: 1156
s = int(input())

if s == 10 ** 18:
    x1, y1 = 10 ** 9, 0
    x2, y2 = 0, 10 ** 9
else:
    x1 = 10 ** 9
    y1 = 1
    div, mod = divmod(s, x1)
    x2 = x1 - mod
    y2 = div + y1

print(*[0, 0, 10**9, 1, x2, y2])


Measured memory_bytes: 3060
#include <stdio.h>

int main(){
    int S,h,m,s;
    scanf("%d",&S);
    h =  S / 3600;
    m = (S - h * 3600) / 60;
    s = S % 60;
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}


Measured memory_bytes: 1992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mp make_pair
#define pb push_back
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=(int)(n);i++)
struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  //木の根なら-(size of tree) それ以外は木の根のindexが入っている。      
  bool unite(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool same(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

int main() {
  int n,k,l;
  cin >> n >> k >> l;
  UnionFind t(n);
  UnionFind a(n);
  int p[k],q[k];
  rep(i,k){
    cin >> p[i] >> q[i];
    p[i]--;q[i]--;
    t.unite(p[i],q[i]);
  }
  int r[l],s[l];
  rep(i,l){
    cin >> r[i] >> s[i];
    r[i]--;s[i]--;
    a.unite(r[i],s[i]);
  }
  vector<tuple<int, int, int> > g;
  rep(i,n){
    g.pb(make_tuple(t.root(i), a.root(i), i));
    //        cout << t.root(i) << " " << a.root(i) << endl;
  }
  int ans[n];
  sort(g.begin(),g.end());
  int c=1;
  rep(i,n-1){
    int tr=get<0>(g[i]);
    int ai=get<1>(g[i]);
    int ntr=get<0>(g[i+1]);
    int	nai=get<1>(g[i+1]);
    if(tr==ntr && ai==nai){
      c++;
      if(i==n-2){
	rep(j,c){
	  int ind=get<2>(g[i+1-j]);
	  ans[ind]=c;
	}
      }
    }
    else{
      rep(j,c){
	int ind=get<2>(g[i-j]);
	ans[ind]=c;
      }
      c=1;
      if(i==n-2){
	int ind=get<2>(g[i+1]);
	ans[ind]=c;
      }
    }
  }
  rep(i,n){
    cout << ans[i] << endl;
  }


  return 0;
    

}


Measured memory_bytes: 7796
import math

MOD = 10**9+7

N, B = map(int, input().split())
R = N-B

for i in range(1,B+1):
  if B-i < 0 or R-i+1 < 0:
    print(0)
    continue
  Bc = (math.factorial(B-1) // (math.factorial(B-i) * math.factorial(i-1))) % MOD
  Rc = (math.factorial(R+1) // (math.factorial(R-i+1) * math.factorial(i))) % MOD
  print((Bc * Rc) % MOD)

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

int main() {
  int N,a,s,e;
  cin >> N;
  s = 9999;
  e = 0;
  for (int i=0; i<N; i++) {
    cin >> a;
    s = min(s,a);
    e = max(e,a);
  }
  cout << e-s << endl;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.List;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);

		List<Integer> list = new ArrayList<Integer>();
		for (int i = 0; i < 3; i++) {
			list.add(sc.nextInt());
		}

		final int k = sc.nextInt();

		for (int j = 0; j < k; j++) {
			final int max = Collections.max(list);
			final int maxIndex = list.indexOf(max);
			final int mul = max * 2;
			list.set(maxIndex, mul);
		}

		int result = 0;
		for (final int item : list) {
			result = result + item;
		}

		System.out.println(result);

	}

}


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


int main() {
	int a, b, c, d;

	cin >> a >> b >> c >> d;

	if (a + b < c + d) { cout << "Right" << endl; }
	else if (a + b > c + d) {
		cout << "Left" << endl;
	}
	else {
		cout << "Balanced" << endl;
	}
	



	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<vector<long long> > vvll;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
#define INF 1000000000
#define MOD 1000000007
#define EPSILON 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define p_q priority_queue
 
#define FOR(i, a, b) for (int i=(a); i<=(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define RFOR(i, a, b) for (int i=(a); i >= b; i--)
 
#define MN 200005


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

    int a, b, c;
    cin >> a >> b >> c;
    if(a == b && b == c){
        cout << "Yes\n";
    } else{
        cout << "No\n";
    }

    return 0;
}


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

int main()
{
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i, n) cin >> d.at(i);
    int m;
    cin >> m;
    vector<int> t(m);
    rep(i, m) cin >> t.at(i);

    map<int, int> problems;
    rep(i, n) problems[d.at(i)]++;

    string answer = "YES";
    rep(i, m)
    {
        // cout << t.at(i) << " " << problems[t.at(i)] << endl;
        if (problems[t.at(i)] <= 0)
        {
            answer = "NO";
            break;
        }
        else
        {
            // int t_count = problems[t.at(i)];
            // problems.erase(t.at(i));
            // problems[t.at(i)] = t_count - 1;
            problems[t.at(i)]--;
        }
    }

    cout << answer << endl;
}

Measured memory_bytes: 11136
import java.io.BufferedReader
import java.io.InputStreamReader
import java.io.PrintWriter

fun main(args: Array<String>) {

    // IO Templates
    val br = BufferedReader(InputStreamReader(System.`in`))
    val out = PrintWriter(System.out)

    val s = br.readLine()!!.toLong()

    if (s < 3) {
        println(0)
        return
    }

    var ans = 0L
    val comb = Combination()

    for (i in 1..(s / 3 + 10)) {
        val rem = s - 3 * i
        if (rem < 0) break

        ans += comb.calcCombination(rem + i - 1, i - 1)
        ans %= MyMod.MOD
    }

    out.println((ans + MyMod.MOD) % MyMod.MOD)

    out.flush()
}

/**
 * Calculation combination.
 * Deeply depends on MyMod class.
 *
 * @constructor
 * initialize the fac and finv which are used for combination calculation
 *
 * @param maxVal max value to calculation combination
 */
class Combination(maxVal: Int = 200_000) {

    private val fac = LongArray(maxVal + 10)
    private val finv = LongArray(maxVal + 10)

    init {
        fac[0] = 1
        fac[1] = 1
        finv[0] = 1
        finv[1] = 1
        for (i in 2 until maxVal + 10) {
            fac[i] = MyMod.times(fac[i - 1], i.toLong())
            finv[i] = MyMod.div(finv[i - 1], i.toLong())
        }
    }

    fun calcCombination(n: Long, r: Long): Long = calcCombination(n.toInt(), r.toInt())

    fun calcCombination(n: Int, r: Int): Long {
        if (n < r) return 0L
        if (n < 0 || r < 0) return 0L
        if (r == 0) return 1L
        return MyMod.times(fac[n], MyMod.times(finv[r], finv[(n - r)]))
    }

}

class MyMod(var value: Long = 0L) {
    operator fun plus(a: Long) {
        value = plus(value, a)
    }

    operator fun minus(a: Long) {
        value = minus(value, a)
    }

    operator fun times(a: Long) {
        value = times(value, a)
    }

    operator fun div(a: Long) {
        value = div(value, a)
    }

    operator override fun equals(other: Any?): Boolean {
        // FIXME: 2020/08/30 定義途中
        return super.equals(other)
    }

    companion object {
        const val MOD: Long = 1000000007L
        fun plus(a: Long, b: Long): Long {
            return (a % MOD + b % MOD) % MOD
        }

        fun minus(a: Long, b: Long): Long {
            return (a % MOD - b % MOD + MOD) % MOD
        }

        fun times(a: Long, b: Long): Long {
            return (a % MOD) * (b % MOD) % MOD
        }

        fun div(a: Long, b: Long): Long {
            return (a % MOD) * (pow(b, MOD - 2) % MOD) % MOD
        }

        // calc a^b
        // b <= 0 は1を返す
        fun pow(a: Long, b: Long): Long {
            var a = a
            var b = b
            var result = 1L
            a %= MOD
            while (b > 0) {
                if (b % 2 == 1L) result = result * a % MOD
                a = a * a % MOD
                b = b shr 1
            }
            return result
        }

        // calc inverse element
        fun invEle(a: Long): Long {
            return pow(a % MOD, MOD - 2) % MOD
        }
    }

}

Measured memory_bytes: 37544
#include <iostream>
#include <iomanip>
#include <vector>
#include <valarray>
#include <map>
#include <set>
#include <list>
#include <queue>
#include <stack>
#include <bitset>
#include <utility>
#include <numeric>
#include <algorithm>
#include <functional>
#include <complex>
#include <string>
#include <sstream>

#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cmath>

using namespace std;

#define all(c) c.begin(),c.end()
#define repeat(i,n) for(int i=0;i<static_cast<int>(n);i++)
#define debug(x) #x << "=" << (x)
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")"<< endl

typedef long long ll;
typedef vector<int> vi;

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

template<typename T>
T input(){
    T t;
    cin >> t;
    return t;
}

template<typename T>
vector<T> input(const int N){
    vector<T> v(N);
    repeat(i,N) cin >> v[i];
    return v;
}

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

long long lcm(long long a, long long b){
    return (a / gcd(a, b)) * b;
}

int main(){
    int N, K;
    cin >> N;
    cin >> K;
    ll value = 1;
    ll tmp1, tmp2;
    repeat(i, N) {
        tmp1 = value * 2;
        tmp2 = value + K;
        value = min(tmp1, tmp2);
    }
    cout << value << endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>

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

int main() {
	int X,Y,Z;
	int swap;
	cin >> X >> Y >> Z;
	swap = Y;
	Y = X;
	X = swap;
	swap = Z;
	Z = X;
	X = swap;
	cout << X << " " << Y << " " << Z;
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cassert>
#include <algorithm>
#include <string>
#include <vector>

std::vector<std::vector<int>> memo;

bool is_cat(const std::string &s, size_t il, size_t ir) {
  if (memo[il][ir] > -1) return memo[il][ir];

  // fprintf(stderr, "\"%s\"[%zu:%zu] (\"%s\")\n", s.c_str(), il, ir, s.substr(il, ir-il).c_str());
  int &res=memo[il][ir];
  if (il == ir) return (res = 1);
  if ((ir-il) % 3 > 0) return (res = 0);
  if (!(s[il] == 'm' && s[ir-1] == 'w')) return (res = 0);

  for (size_t i=il+1; i+1<ir; i+=3) {
    if (s[i] != 'e') continue;
    if (is_cat(s, il+1, i) && is_cat(s, i+1, ir-1)) return (res = 1);
  }
  return (res = 0);
}

int main() {
  char buf[512];
  scanf("%s", buf);
  std::string s=buf;

  if (s.length() % 3 > 0)
    return !printf("Rabbit\n");

  memo.assign(s.length()+1, std::vector<int>(s.length()+1, -1));
  printf("%s\n", is_cat(s, 0, s.length())? "Cat":"Rabbit");
}



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

/*** Template Begins ***/

typedef long long                   ll;
typedef pair<int,int>               PII;
typedef pair<ll, pair<int, int> >   PIII;
typedef vector<int>                 vi;
typedef vector<pair<int, int> >     vii;

#define endl         '\n'
#define pb           push_back
#define INF          INT_MAX/10
#define F            first
#define S            second
#define mp           make_pair
#define ios          ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define hell         1000000007
#define all(a)       (a).begin(),(a).end()
#define fr(i,a,b)    for(int i=a;i<=b;i++)
#define lp(i,a)      for(int i=0;i< a;i++)

// Debug //

#define trace(x)                 cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;

// Constants //

const int N = 1e5+7;
const int xinc[] = {0, 0, 1, -1};
const int yinc[] = {1, -1, 0, 0};
const long double PI = acos(-1.0);

/*** Template Ends ***/
ll n, k;


void solve() {
    
    cin >> n >> k;
    if (k == 1)	cout << 0 << endl;
    else cout << n-k << endl;

}

signed main() {
    
    ios;
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    int t;
    //cin >> t;
    t = 1;
    while(t--)
        solve();

    return 0;
}

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

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

  int64_t ans = 0;

  for (int64_t i = 1; i <= n; i++) {
    int64_t m = n / i;
    ans += m * (m + 1) / 2 * i;
  }

  cout << ans << endl;
}


Measured memory_bytes: 3624
#pragma GCC optimize("O3")

#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef pair<int, int> pi;
tree<int,int,greater<int>,rb_tree_tag,tree_order_statistics_node_update> map_t;
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) for(int i = 0; i < (a); ++i)
#define pb push_back
#define sz(x) (int)x.size()
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
#define REV(x) reverse(x.begin(),x.end())
int dx[]={-1,0,1,0};
int dy[]={0,-1,0,1};

int main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll n;
    cin >> n;
    ll a,b;
    cin >> a >> b;
    ll tot=n/(a+b) * a;
    ll rem=n%(a+b);
    tot+=min(a,rem);
    cout << tot;

    return 0;
}


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

int main () {
	int n, max = 0, ans = 0;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];

	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			ans = abs(a[j] - a[i]);
			if (max < ans) max = ans;
		}
	}
	cout << max << endl;

	return 0;
}

Measured memory_bytes: 256
import math
from functools import reduce

N = int(input())
A = list(map(int, input().split()))
MAX = 10**6 + 1

cut = [2 for _ in range(MAX)]
for i in range(3, MAX, 2):
    if cut[i] != 2:
        continue
    for j in range(i, MAX, i):
        cut[j] = i

if reduce(math.gcd, A) != 1:
    print('not coprime')
    exit()

already = set()
for a in A:
    now = set()
    while a != 1:
        if cut[a] in already:
            print('setwise coprime')
            exit()
        now.add(cut[a])
        a //= cut[a]
    already |= now

print('pairwise coprime')

Measured memory_bytes: 206264
N,M,X,Y = map(int,input().split())
x = list(map(int,input().split()))
y = list(map(int,input().split()))
tmp = list(range(X+1,Y+1))
tmp2 = list(range(max(x)+1,min(y)+1))
if list(set(tmp) & set(tmp2)) == []:
  print('War')
else:
  print('No War')


Measured memory_bytes: 3060
n,k = map(int,input().split())
s = input()
l = x = ans = 0
for r in range(n):
    if s[r] == '0' :
        if r == 0 or s[r-1] == '1':
            x += 1
    if x > k:
        while s[l] == '1':
            l += 1
        while s[l] == '0':
            l += 1
        x -= 1
    ans = max(ans,r-l+1)
print(ans)

Measured memory_bytes: 42096
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <tuple>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#include <iomanip>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;

int gcd(int a, int b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}

void solve() {
	double w; cin >> w;
	double h; cin >> h;
	int x; cin >> x;
	int y; cin >> y;
	cout << fixed << setprecision(9) << (w * h) / 2.0 << " ";
	//高さと幅が偶数であれば、直線x = w / 2、y = h / 2で分割する
	//長方形の内部が2つの三角形となるような直線で分割する
	//パターンが考えられるためその他の分割方法ありと判定する
	if (((int)w % 2 == 0 && (int)h % 2 == 0) && ((int)x == (w / 2) && (int)y == (h / 2))) {
		cout << 1 << endl;
	} else {
		cout << 0 << endl;
	}
    return;
}

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



Measured memory_bytes: 384
#include <bits/stdc++.h>
#define LOOP(n) for (int _i = 0; _i < (n); _i++)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define RREP(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, r, n) for (int i = (r); i < (n); ++i)
#define ALL(obj) begin(obj), end(obj)
using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

const int INF = 2100100100;
const int MOD = 1e9 + 7;

// 多次元 vector 生成
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

int N, M, K, Q, W, H, R, C;
string S;

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

    cin >> N >> K;
    int ans = 0;
    while (N > 0) {
        N /= K;
        ans++;
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> l(N), r(N);

  for(int i = 0 ; i < N; i++) {
    cin >> l[i] >> r[i];
  }
  int ans = 0;
  for(int i = 0; i < N; i++) {
    ans += (r[i] - l[i]) + 1;
  } 

  cout << ans;


  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string.h>
#include<cstdio>
#include<algorithm>
#include<stack>
#include<queue>
#include<vector>
#include<cmath>
#include<utility>
#define ll long long int
#define ld long double
#define INF 1000000000
#define EPS 0.0000000001
#define rep(i,n) for(i=0;i<n;i++)
using namespace std;
typedef pair<int, int> P;

char str[100];

int main()
{
  int n;
  int i;

  cin>>str;
  rep(i,4)
    cout<<str[i];
  cout<<" ";
  for(i=4;i<strlen(str);i++)
    cout<<str[i];
  cout<<endl;
}


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


int main() {

	int n;

	cin >> n;

	n = n % 10;

	if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9) {
		cout << "hon" << endl;
	}
	else if (n == 0 || n == 1 || n == 6 || n == 8) {
		cout << "pon" << endl;
	}
	else
	{
		cout << "bon" << endl;
	}
}

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

int main() {
    int n;
    string s, t;
    cin >> n >> s >> t;

    for (int i = n; i >= 0; i--) {
        if (s.substr(n - i) == t.substr(0, i)) {
            cout << (s + t.substr(i)).length() << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
// https://atcoder.jp/contests/nikkei2019-2-qual/tasks/nikkei2019_2_qual_a

#include "algorithm"
#include "functional"
#include "iostream"
#include "numeric"
#include "queue"
#include "set"
#include "vector"
#define rep(i, to) for (ll i = 0; i < (to); ++i)
#define repf(i, from, to) for (ll i = from; i < (to); ++i)
#define repr(i, from) for (ll i = from - 1; i >= 0; --i)
#define all(vec) vec.begin(), vec.end()
#define fi first
#define se second
using namespace std;
typedef long long ll;
template <typename T>
using V = vector<T>;
using VL = V<ll>;
using VVL = V<VL>;
template <typename T, typename U>
using P = pair<T, U>;
using PL = P<ll, ll>;
using VPL = V<PL>;
template <typename T>
inline bool chmax(T& a, T b);
template <typename T>
inline bool chmin(T& a, T b);
void print_ints(vector<ll> v);
template <typename T>
void drop(T a);

void solve() {
  ll N;
  cin >> N;

  ll res = N / 2;
  if (N % 2 == 0) res--;
  cout << res << endl;
}

struct exit_exception : public std::exception {
  const char* what() const throw() { return "Exited"; }
};

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

  try {
    solve();
  } catch (exit_exception& e) {
  }

  return 0;
}
#endif

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

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

void print_ints(vector<ll> v) {
  rep(i, v.size()) {
    if (i > 0) {
      cout << " ";
    }

    cout << v[i];
  }

  cout << endl;
}

template <typename T>
void drop(T res) {
  cout << res << endl;
  throw exit_exception();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数

//-------------------------------------------------
//コピペするとこ



//-------------------------------------------------


int main()
{
  int n ;
  cin >> n ;
  for(int i=1;i<=n;i++){
    double tmp = (double)i*1.08 ;
    int itmp = tmp ;
    if(itmp==n){
      cout << i <<endl ;
      return 0 ;
    }
  }
  cout <<":("<<endl ;
  return 0 ;
}


Measured memory_bytes: 256