akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;


int main(){
    int a,b,m ;
    cin >> a >> b >> m ;
    vector<int> ap(a) ;
    vector<int> bp(b) ;
    for (size_t i = 0; i < a; i++)
    {
        cin >> ap.at(i) ;
    }
    for (size_t i = 0; i < b; i++)
    {
        cin >> bp.at(i) ;
    }
    int min = 1000000 ;
    int x,y,c ;
    int temp = 0 ;
    for (size_t i = 0; i < m; i++)
    {
        cin >> x >> y >> c ;
        temp = ap.at(x-1) + bp.at(y-1) - c ;
        if (temp < min)
        {
            min = temp ;
        }
    }
    sort(ap.begin(), ap.end()) ;
    sort(bp.begin(), bp.end()) ;
    if (ap.at(0) + bp.at(0) < min)
    {
        min = ap.at(0) + bp.at(0) ;
    }
    
    cout << min << endl ;
}

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

int main(){
    int n;
    cin >> n;
    vector<int> v;
    for(int i = 0; i < n; i++){
        int a;
        cin >> a;
        v.push_back(a);
    }
    sort(v.begin(), v.end());
    int ans = 0;
    int r = 0;
    for(int l = 0; l < v.size(); l++){
        while(r < v.size() && v[r] <= v[l] + 2){
            r++;
        }
        ans = max(ans, r-l);
        if(l == r){
            r++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 892
#include<bits/stdc++.h>
using namespace std;
#define LEN 100005


typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail, n;

void initialize()
{
  head = tail = 0;
}

int isempty()
{
return head == tail;
}

int isfull()
{
  return head == (tail + 1) % LEN;
}

void enqueue(P x){
  if (isfull())
  cerr << "queue overflow" << endl;
  Q[tail] = x;
  if (tail + 1 == LEN)
  tail = 0;
  else
  {
    tail++;
  } 
}

P dequeue(){
  if (isempty())
  cerr << "queue underflow" << endl;
  P x;
  x = Q[head];
  if(head + 1 == LEN)
  head = 0;
  else
  {
    head++;
  }
  return x;
}
int main(){
  int elaps = 0, c;
  int i, q;
  P u;
   cin >> n >> q;
  for ( i = 1; i <= n; i++){
    cin >> Q[i].name >> Q[i].t;
  }
  head = 1; tail = n+1;

  while( head != tail ){
    //    trace();
    u = dequeue();
    c = min(q, u.t);
    u.t -= c;
    elaps += c;
    if ( u.t > 0 ) enqueue(u);
    else {
      cout << u.name << " " << elaps << endl;
    }
  }
  

  return 0;
}



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

 int main() {
   double a, b, x, pi;
   cin >> a >> b >> x;
   pi = acos(-1);

   if (x >= a * a * b / 2) cout << fixed << setprecision(10) << atan((2.0 * a * a * b - 2.0 * x) / (a * a * a)) * 180.0 / pi << endl;
   else cout << fixed << setprecision(10) << atan(a * b * b / (2 * x)) * 180.0 / pi << endl;
 }


Measured memory_bytes: 384
#include "bits/stdc++.h"
#include <cassert>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define vi vector<int>
#define pb push_back
#define INF 999999999
//#define INF (1LL<<59)

#define MAX_V 100000

struct edge{int to,cost;};
vector<edge> G[MAX_V];
int d[MAX_V];

void dijkstra(int s){
    priority_queue< pii,vector<pii>,greater<pii> > que;
    rep(i,MAX_V)d[i]=INF;
    d[s]=0;
    que.push(pii(0,s));
    
    while(que.size()){
        pii p=que.top();
        que.pop();
        
        int v=p.second;
        if(d[v]<p.first)continue;
        
        rep(i,G[v].size()){
            edge e=G[v][i];
            if(d[e.to]>d[v]+e.cost){
                d[e.to]=d[v]+e.cost;
                que.push(pii(d[e.to],e.to));
            }
        }
    }
}



int main(){
    int v,e,s;
    cin>>v>>e>>s;
    rep(i,e){
        int a,b,c;
        cin>>a>>b>>c;
        G[a].pb(edge{b,c});
    }
    
    dijkstra(s);
    
    rep(i,v){
        if(d[i]==INF)cout<<"INF"<<endl;
        else cout<<d[i]<<endl;
    }
}

Measured memory_bytes: 13092
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
	int a,b,v,w,t;
	cin>>a>>v>>b>>w>>t;
	if(labs(a-b)<=t*(v-w))
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i,l,r) for(int i=l; i<(int)(r); i++)
#define rep_eq(i,l,r) for(int i=l; i<=(int)(r); i++)
#define all(vec) vec.begin(),vec.end()
#define allr(vec) vec.rbegin(),vec.rend()
using namespace std;

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

using ll=int64_t;

using vb=vector<bool>;
using vc=vector<char>;
using vs=vector<string>;
using vi=vector<int>;
using vll=vector<ll>;
using vvi=vector<vi>;

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

  string S,T; cin >>S >>T;
  bool flag=true;
  map<char,char> a,b;
  rep(i,0,S.size()) {
    char s=S[i],t=T[i];
    if (a.count(s)) {
      if (a[s]!=t) {
        flag=false;
      }
    }
    if (b.count(t)) {
      if (b[t]!=s) {
        flag=false;
      }
    }
    a[s]=t;
    b[t]=s;
  }

  cout <<(flag ? "Yes":"No") <<'\n';
  return 0;
}


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

#define ll long long
#define vi vector<int>
#define vl vector<long long>
#define pr(a, b) pair<a, b>
#define si set<int>
#define sl set<long long>
#define pq prioirty_queue
#define all(v) v.begin(),v.end()
#define left (2*idx)+1
#define right (2*idx)+2
#define frt(i,a,b) for(ll i=a; i<b; i++)
#define rew(i,a,b) for(ll i=a; i>=b; i--)
#define fre(i,a,b) for(ll i=a; i<=b; i++)
#define pb push_back

#define test if(!true)
#define N 100007
#define MOD (ll)(1e9 + 7)

ll get_divisors(ll a, ll b, ll c)
{
    ll l = a/c;
    if(a%c == 0)
    {
        l-=1;
    }
    ll r = b/c;
    return r - l;
}

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

    ll total = b - a + 1;
    ll nw = (c * d) / __gcd(c, d); 
    cout << total - get_divisors(a, b, c) - get_divisors(a, b, d) + get_divisors(a, b, nw) << "\n";
    return 0;
}

Measured memory_bytes: 256
n, m = map(int, input().split())

submit = []
results = [0] * n

for i in range(m):
  p, s = input().split()
  p = int(p)
  if type(results[p-1]) is int:
    results[p-1]=[s]
  else:
    results[p-1].append(s)

ok = 0
penalty = 0
for result in results:
  if type(result) == int:
    pass
  elif 'AC' in result: 
    for r in result:
      if r == 'AC':
        ok = ok + 1
        break
      else:
        penalty = penalty + 1
      
print(ok, penalty) 


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

    string s;
    cin >> s;

    for (int i = 0;i < s.size();i++){
        if(s[i] != s[s.size()-1-i]){
            cout << "No" << endl;
            return 0;
        }
    }

    for (int i = 0;i < (s.size()-1)/2;i++){
        if(s[i] != s[(s.size()-1)/2-1-i]){
            cout << "No" << endl;
            return 0;
        }
        int j = i+(s.size()+3)/2-1;
        if(s[j] != s[s.size()-1-i]){
            cout << "No" << endl;
            return 0;
        }

    }

    cout << "Yes" << endl;

    return 0;

}

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<ctype.h>
 
 
int main(){
 
  char s[200], t[200];
  int m, h, i, j;
 
  while(1){
    scanf("%s", s);
    if(s[0]=='-') break;
 
    scanf("%d", &m);
    for(i=0;i<m;i++){
      scanf("%d", &h);
      for(j=0;j<h;j++) t[j]=s[j];
      for(j=h;j<strlen(s);j++) s[j-h]=s[j];
      for(j=0;j<h;j++) s[strlen(s)-h+j]=t[j];
    }
    printf("%s\n", s);
  }
  return 0;
}


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


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

    ll n;

    cin >> n;

    ll arr[n];

    ll arr1[n];

    ll mod = 1e9+7;

    for(ll i=0; i<n; i++)
    {
        cin >> arr[i];
        arr1[i] = arr[i];
    }

    for(ll i=1; i<n; i++)
    {
        arr1[i] = (arr1[i] + arr1[i-1]) % mod;

    }

    ll z = arr1[n-1];

    ll sum = 0;



    for(ll i=0; i<n-1; i++)
    {
        ll temp = (z - arr1[i]) % mod;

        if(temp < 0)
        {
            temp += mod;
        }

        temp = (temp * arr[i]) % mod;

        sum = (sum + temp) % mod;
    }

    cout << sum % mod;



}



Measured memory_bytes: 6736
#include <bits/stdc++.h>
//#pragma GCC optimize(2)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define rep(i,a,b) for(int i = (a);i <= (b);i++)
#define pii pair<int,int>
#define pll pair<long long, long long>
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int inf = 0x3f3f3f3f;
const int maxn = 1e5 + 10;
const double eps = 1e-8;
const double pi = acos(-1.0);
ll gcd(ll a,ll b){return !b?a:gcd(b,a%b);}
ll lcm(ll a,ll b){return a * b / gcd(a,b);}
ll poww(ll x,ll y,ll p){ll ans = 1;while(y){if(y & 1) ans = ans * x % p;x = x * x % p;y >>= 1;}return ans % p;}
bool isp(ll x){if(x < 2) return 0; for(ll i = 2;i * i <= x;i++){if(x % i == 0) return 0;}return 1;}
ll n;
void solve(){
	ll ans = n - 1;
	for(ll i = 2;i * i <= n;i++){
		if(n % i == 0){
			ll k = n / i;
			ans = min(ans,i + k - 2);
		}
	}
	cout << ans << endl;	
}
int main(){
	ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	cin >> n;
	solve();
}
//do smt instead of nothing! never give up!


Measured memory_bytes: 384
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cmath>
#include<map>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
using namespace std;

#define pa pair<int,int>
#define sc(n) scanf("%d",&n)
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define mem(a,b) memset(a,b,sizeof a)
#define uint unsigned int

const  int N = 1e6 + 10;
const int mod = 1e9 + 7;
const int inf = 0x3f3f3f3f;

typedef long long ll;
typedef long double ld;




int main()
{
	int r;
	cin>>r;
	cout<<3*r*r<<endl;
	return 0;
}

Measured memory_bytes: 256
n = gets.to_i
a = gets.split.map(&:to_i)

a_4n = a.select {|x| (x % 4).zero?}
a_2n = a.select {|x| x.even? && !(x % 4).zero?}
a_1n = a.select(&:odd?)

if a_2n.empty?
  puts a_4n.size >= a_1n.size - 1 ? 'Yes' : 'No'
else
  puts a_4n.size >= a_1n.size ? 'Yes' : 'No'
end

Measured memory_bytes: 9220
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author acesine
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        C solver = new C();
        solver.solve(1, in, out);
        out.close();
    }

    static class C {
        private long maxOfThree(long A, long B, long C) {
            return Math.max(Math.max(A, B), C);
        }

        private long minOfThree(long A, long B, long C) {
            return Math.min(Math.min(A, B), C);
        }

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            long H = in.nextInt(), W = in.nextInt();
            long minDiff = H * W;
            for (long h = 0; h <= H; h++) {
                long A = h * W;
                long B = ((H - h) / 2) * W;
                long C = H * W - A - B;
                minDiff = Math.min(minDiff, maxOfThree(A, B, C) - minOfThree(A, B, C));
                B = (H - h) * (W / 2);
                C = H * W - A - B;
                minDiff = Math.min(minDiff, maxOfThree(A, B, C) - minOfThree(A, B, C));
            }
            for (int w = 0; w < W; w++) {
                long A = w * H;
                long B = ((W - w) / 2) * H;
                long C = H * W - A - B;
                minDiff = Math.min(minDiff, maxOfThree(A, B, C) - minOfThree(A, B, C));
                B = (W - w) * (H / 2);
                C = H * W - A - B;
                minDiff = Math.min(minDiff, maxOfThree(A, B, C) - minOfThree(A, B, C));
            }
            out.println(minDiff);
        }

    }
}



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

typedef  long long ll;



int main(){

    string n;
    int t;
    cin>>n;
    t = n[n.size()-1]-'0';
    if(t==2||t==4||t==5||t==7||t==9){
        cout<<"hon"<<endl;
    }
    else if(t==0||t==1||t==6||t==8){
        cout<<"pon"<<endl;
    }
    else{
        cout<<"bon"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3568
//
//  main.cpp
//  Atcoder1
//
//  Created by Hamske on 2020/09/17.
//  Copyright © 2020 Author. All rights reserved.
//

#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <string>

using namespace std;

//#define pb push_back
//#define mp make_pair
//
//#define F first
//#define S second

typedef long long ll;

#define rept(_i,iv,n,type) for(type _i=(type)(iv);_i<(type)(n);++_i)
//#define repi(_i,iv,n) rept(_i,iv,n,int)
//#define repl(_i,iv,n) rept(_i,iv,n,ll)

#define rept0(_i,n,type) rept(_i,0,n,type)
#define repi0(_i,n) rept(_i,0,n,int)
#define repl0(_i,n) rept(_i,0,n,ll)

//#define repst(_i,iv,n,type) for(type _i=iv;_i<=(type)(n);++_i)
//#define repsi1(_i,n) repst(_i,1,n,int)

#define REPT(_i,iv,_l,n,type) for(type _i=(type)(iv),_l=(type)(n);_i<_l;++_i)
//#define REPI(_i,iv,_l,n) REPT(_i,iv,_l,n,int)
//#define REPL(_i,iv,_l,n) REPT(_i,iv,_l,n,ll)
//
#define REPT0(_i,_l,n,type) REPT(_i,0,_l,n,type)
#define REPI0(_i,_l,n) REPT(_i,0,_l,n,int)
#define REPL0(_i,_l,n) REPT(_i,0,_l,n,ll)


//#define rrept(_i,x,e,type) for(type _i=((type)(x)-1);_i>=e;--_i)
//
//#define rrept0(_i,x,type) rrept(_i,x,0,type)
//
//#define RREPT(_i,x,_e,e,type) for(type _i=((type)(x)-1),_e=(type)(e);_i>=_e;--_i)
//
//#define RREPT0(_i,x,_e,type) RREPT(_i,x,_e,0,type)
//
//#define RREPS(i,x) for(int i=((int)(x));i>0;i--)

//#define all(x) (x).begin(),(x).end()
#define REPV(v,_itr,_end) for(auto _itr=(v).begin(),_end=(v).end();_itr!=_end;++_itr)
#define REPVC(v,_itr,_end) for(auto _itr=(v).cbegin(),_end=(v).cend();_itr!=_end;++_itr)

#define td typedef
//#define tds(stl,type,name) typedef stl<type > name;
#define tdv(type,name) typedef vector<type > name;


//typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<vb > vvb;
typedef vector<int> vi;
typedef vector<vi > vvi;
//typedef vector<ll> vll;
//typedef vector<vll > vvll;

int main(int argc, const char * argv[]) {
    int N;
    cin>>N;
    ll sum=0;
    for(int a=1;a<N;++a){
        int mod=N%a;
        if(mod==0){
            sum+=(N-mod)/a-1;
        }else{
            sum+=(N-mod)/a;
        }
    }
    cout<<sum<<endl;
    
    return 0;
}


Measured memory_bytes: 3192
#include <iostream>
#include <string>
#include <algorithm>
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
#include <cctype>
using namespace std;
long long a[100010], co[100010] = { 0 };
int main() {
#define int long long
	int n;
	cin >> n;
	int m = 0;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] > m) {
			m = a[i];
		}
		co[a[i]]++;
	}
	if (a[0] != 0) {
		cout << "0" << endl;
		return 0;
	}
	for (int i = 1; i < n; i++) {
		if (a[i] == 0) {
			cout << "0" << endl;
			return 0;
		}
	}
	sort(a, a + n);
	long long ans = 1;
	for (int i = 1; i < m + 1; i++) {
		long long co1 = co[i - 1];
		for (int j = 1; j < co[i]; j++) {
			co[i - 1] = co[i - 1] * co1 % 998244353;
		}
		ans = ans * co[i - 1] % 998244353;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1792
n = int(input())
d = list(map(int, input().split()))
m = int(input())
t = list(map(int, input().split()))
D = {}
for i in range(n):
    if d[i] not in D:
        D[d[i]] = 1
    else:
        D[d[i]] += 1
T = {}
for j in range(m):
    if t[j] not in T:
        T[t[j]] = 1
    else:
        T[t[j]] += 1
for k in T:
    try:
        if T[k] <= D[k]:
            continue
        else:
            print('NO')
            break
    except:
        print('NO')
        break
else:
    print('YES')


Measured memory_bytes: 56672
#include <iostream>
#include <bitset>
#include <cmath>
using namespace std;
#define ll long long
ll x,x1,n,i,yy,y2,y,dif1,dif2;
bitset <200> f;
int main ()
{
   cin>>x>>n;
   for (i=1;i<=n;++i)
   {
       cin>>x1;
       f[x1]=1;
   }
   y=x;
   while (f[y])  y--;
   dif1=abs(x-y);
   yy=y;
   y=x;
   while (f[y]) y++;
   dif2=abs(x-y);
   y2=y;
   if (dif1<=dif2) cout<<yy<<"\n";
   else cout<<y2<<"\n";
}



Measured memory_bytes: 3632
N = int(input())
S = list(input())
S_l = len(S)
R = 0
G = 0
B = 0
for s in S:
  if s=='R':
    R+=1
  elif s=='G':
    G+=1
  else:
    B+=1

ans=R*G*B
for i in range(N):
  for j in range(i+1,N):
    k = 2*j-i
    if k>=S_l:
      continue
    else:
      if (S[i]!=S[j])and(S[i]!=S[k])and(S[j]!=S[k]):
        ans-=1
print(ans)

Measured memory_bytes: 9212
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <sstream>
#include <math.h>
#include <queue>
#include <map>
#include <set>
#include <ios>     // std::left, std::right
#include <iomanip> // std::setw(int), std::setfill(char)
using namespace std;


int main(){
long long N,K,C;
cin>>N>>K>>C;
std::string s;
cin>>s;
vector<long long>  fw;
vector<long long>  Rev;
long long max_w=0;
long long last_work=-10000000;
long long previous_work=10000000;
for(long long i=0;i<N;++i){
    if(fw.size()==K){
        break;
    }
    if(s[i]=='o' && last_work+C<i){
        fw.push_back(i);
        last_work=i;
    }
}

for(long long i=N-1;i>=0;--i){
        if(Rev.size()==K){
        break;
    }
    if(s[i]=='o' && previous_work>i+C){
        Rev.push_back(i);
        previous_work=i;
    }
}

std::sort(Rev.begin(),Rev.end());

for(long long i=0;i<K;++i){
    if(fw[i]==Rev[i]){
        cout<<fw[i]+1<<"\n";
    }
}


return 0;
}


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

const double PI = acos(-1);
using ll = long long;
using ull = unsigned long long;
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;
typedef pair<ll,pair<int,int>> P;

#define REP(i,n) for (int i = 0; i < (n); i++)
#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second

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

    map<char,char> mp;
    mp['A'] = 'T';
    mp['T'] = 'A';
    mp['C'] = 'G';
    mp['G'] = 'C';

    char d;
    cin >> d;
    cout << mp[d] << endl;


    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <map>

using namespace std;

typedef long long LL;

#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))
#define ALL(a)  (a).begin(),(a).end()
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define dump(x)  cerr << #x << " = " << (x) << endl;

LL mod = 1e9 + 7;

// mod. m での a の逆元 a^{-1} を計算する
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}

LL fact(LL a) {
  if (a == 0) return 1;
  return a * fact(a-1) % mod;
}

LL pattern(LL num, LL div) {
  LL inv_1 = modinv(fact(num), mod);
  LL inv_2 = modinv(fact(div-1), mod);

  return fact(num+div-1) % mod * inv_1 % mod * inv_2 % mod;
}

map<int, int> get_primes(int num) {
  map<int, int> res;
  for (int i = 2; i*i <= num; ++i) {
    if (num % i == 0) {
      int count = 0;
      while (num % i == 0) {
        num /= i;
        count++;
      }
      res[i] = count;
    }
  }
  if (num > 1) res[num] = 1;
  return res;
}

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

  auto primes = get_primes(M);
  LL res = 1;
  for (auto e : primes) {
    res = res * pattern(e.second, N) % mod;
  }

  cout << res << endl;

  return 0;
}

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

using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int ingredients[51];
    int n;
    cin >> n;

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

    sort(ingredients, ingredients+n);
    double answer = ingredients[0];
    for(int i=1;i<n;i++){
        answer += ingredients[i];
        answer /= 2;
    }
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <stdio.h>

using namespace std;

int main(){
  long long N;
  cin >> N;
  long long A[N];
  for (long i=0;i<N;i++){
    cin >> A[i];
  }
  
  long long ans = 0; 
  long long count[N+1];
  for(long i=0;i<N+1;i++){
    count[i] = 0;
  }
  for(long i=0;i<N;i++){
    count[A[i]]++;
  }
  for(long i=1;i<=N;i++){
    ans += count[i]*(count[i]-1)/2;
  }
  long long ans2;
  for(long i=0;i<N;i++){
    ans2 = ans-(count[A[i]]*(count[A[i]]-1)/2)+((count[A[i]]-1)*(count[A[i]]-2)/2);
  	cout << ans2 << endl;
  }
}

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

int main(void)
{
	int N;
	cin >> N;
	if (3 < N < 10) {
		int min, max, i, x;
		cin >> x;
		if (1 < x < 100) {
			min = x;
			int sum;
			max = x;
			sum = x;
			for (i = 0; i < N - 1; i++) {
				cin >> x;
				sum += x;
				if (x > max) {
					max = x;
				}
				else if (x < min) {
					min = x;
				}
			}
			if (max < sum - max) {
				cout << "Yes" << endl;
			}
			else {
				cout << "No" << endl;
			}
		}
	}
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  for (int i = 0; i < N; i++) {
    cin >> d.at(i);
  }
  sort(d.begin(), d.end());
  int ans = 0, prev = 0;
  for (int i = 0; i < N; i++) {
    if (d.at(i) != prev) {
      ans++;
      prev = d.at(i);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
LOCAL = len(sys.argv) > 1 and sys.argv[1] == 'LOCAL'


def dprint(*args):
  if LOCAL:
    print(*args)


n = int(input())
p = list(map(int, input().split()))

min_p = 2 * 10**5 + 1
cnt = 0
for x in p:
  if min_p >= x:
    cnt += 1
    dprint(x)
  min_p = min(min_p, x)

print(cnt)


Measured memory_bytes: 25456
using System;
using System.Collections.Generic;
using System.Linq;

namespace test1
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());

            var pay = 0;
            if ((N % 1000) != 0)
            {
                pay = ((N / 1000) + 1) * 1000;
            }
            else
            {
                pay = N;
            }
            var rest = pay - N;
            Console.WriteLine(rest);

            return;
        }
    }
}


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

int main() {
	int a, b; cin >> a >> b;
	string s; cin >> s;

	string ans = "Yes";
	rep(i, 0, a + b + 1) {
		if (i == a) {
			if (s[i] != '-') ans = "No";
		}
		else {
			if (s[i] == '-') ans = "No";
		}
	}

	cout << ans << endl;

	return 0;
}

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

using namespace std;

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

typedef long long int ll;


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

	string str1,str2;
	cin >> str1 >> str2;

	int n = str1.size();
	for(int i=1 ; i<=n ; i++)
	{
		string temp = str1;
		for(int j=0 ; j<str1.size() ; j++)
		{
			temp[(j+i)%str1.size()] = str1[j]; 
		}

		if(temp == str2)
		{
			cout << "Yes";
			return 0;
		}
	}

	cout << "No";
	return 0;
}

Measured memory_bytes: 256
import math
import bisect

inputs = []
while True:
    n = int(input())
    if n == 0:
        break
    inputs.append(n)
    
max_n = max(inputs)

primes = [True for i in range(2 * max_n + 1)]
primes[0] = False
primes[1] = False
for i in range(2, int(math.sqrt(2 * max_n)) + 1):
    tmp = 2 * i
    while tmp <= 2 * max_n:
        primes[tmp] = False
        tmp += i

primes_lst = []
for i in range(2 * max_n + 1):
    if primes[i]:
        primes_lst.append(i)
        
for n in inputs:
    if n == 1:
        print(1)
    else:
        print(bisect.bisect_left(primes_lst, 2 * n) - bisect.bisect_right(primes_lst, n))


Measured memory_bytes: 8512
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.IOException;

public class Main {

    public static void main(String args[]) throws IOException {
        InputStreamReader ir = new InputStreamReader(System.in, "ISO-8859-1");
        OutputStreamWriter ow = new OutputStreamWriter(System.out, "ISO-8859-1");
        BufferedWriter bw = new BufferedWriter(ow);
        BufferedReader br = new BufferedReader(ir);
        int[] count = new int[26];
        String input;
        while ((input = br.readLine()) != null) {
            for (char c : input.toCharArray()) {
                if (c >= 'a' && c <= 'z') {
                    count[c - 'a']++;
                } else if (c >= 'A' && c <= 'Z') {
                    count[c - 'A']++;
                }
            }
        }
        for (int i = 'a'; i <= 'z'; i++) {
            bw.append((char) i + " : " + count[i - 'a'] + "\n");
        }
        bw.flush();
    }

}


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

int A[100007][3];
int dp[100007][3];
int main(){
  int N;
  cin >> N;
  for(int i=0;i<N;i++){
    cin >> A[i][0] >> A[i][1] >> A[i][2];
  }
  memset(dp,0,sizeof(dp));
  for(int i=0;i<3;i++) dp[0][i]=A[0][i];
  for(int i=1;i<N;i++){
    dp[i][0] = A[i][0]+max(dp[i-1][1],dp[i-1][2]);
    dp[i][1] = A[i][1]+max(dp[i-1][2],dp[i-1][0]);
    dp[i][2] = A[i][2]+max(dp[i-1][1],dp[i-1][0]);
  }
  cout<<max(dp[N-1][0],max(dp[N-1][1],dp[N-1][2]))<<endl;
}


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

using namespace std;
#define INF (1<<20)

double dp[32][1<<9];
int x, y, z;
double dist[32][32];
int n, m, p, a, b;
int t[32];

bool solve(){
	double res = INF;
	cin >> n >> m >> p >> a >> b;a--,b--;
	if(n == 0)return false;
	for(int i = 0;i < n;i++)cin >> t[i];
	for(int i = 0;i < m;i++){
		for(int j = 0;j < m;j++){
			dist[i][j] = INF;
		}
	}
	for(int i = 0;i < p;i++){
		cin >> x >> y >> z;x--,y--;
		dist[x][y] = dist[y][x] = z;
	}

	for(int i = 0;i < m;i++){
		for(int j = 0;j < (1<<n);j++){
			dp[i][j] = INF;
		}
	}

	dp[a][0] = 0;
	for(int used = 0;used < (1<<n);used++){
		for(int now = 0;now < m;now++){
			if(dp[now][used] == INF)continue;
			//			cout << now << " " << used << " "<< dp[now][used] << endl;
			if(now == b)res = min(res, dp[now][used]);
			for(int to = 0;to < m;to++){
				if(dist[now][to] == INF)continue;
				for(int i = 0;i < n;i++){
					if((used) & (1 << i))continue;
					dp[to][used | (1<<i)] = min(dp[to][used | (1<<i)], dp[now][used] + dist[now][to] / t[i]);
				}
			}
		}
	}
	if(res == INF)cout << "Impossible" << endl;
	else cout << res << endl;
	return true;
}

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


Measured memory_bytes: 3316
# import sys
# import math #sqrt,gcd,pi
# import decimal
# import queue # queue
# import bisect
# import heapq # priolity-queue
# from time import time
# from itertools import product,permutations,\
    # combinations,combinations_with_replacement
# 重複あり順列、順列、組み合わせ、重複あり組み合わせ
# import collections # deque
# from operator import itemgetter,mul
# from fractions import Fraction
# from functools import reduce

mod = int(1e9+7)
# mod = 998244353
INF = 1<<50

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

def main():
    x = int(input())
    print(abs(x-1))
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 9036
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define INF         1e9
#define EPS         1e-9
#define REP(i,n)    for(lint i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)   for(lint i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)   for(lint i=(n)-1;i>=0;--i)
#define REPR1(i,n)  for(lint i=(n);i>0;--i)
#define REPC(i,obj) for(auto i:obj)
#define R_UP(a,b)   (((a)+(b)-1)/(b))
#define ALL(obj)    (obj).begin(),(obj).end()
#define SETP        cout << fixed << setprecision(8)
using namespace std;
using lint = long long;
template<typename T = lint>inline T in() { T x; cin >> x; return x; }

signed main() {
	bitset<32>a(in());
	bitset<32>b(in());
	cout << (a & b) << endl;
	cout << (a | b) << endl;
	cout << (a ^ b) << endl;
}


Measured memory_bytes: 3124
#include<iostream>
#include<string>
#include<vector>
#include<unordered_map>
#include<algorithm>
#include<cmath>

using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)

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

	for (long long i = floor(sqrt(n)); i > 0; i--) {
		if (n % i == 0) {
			cout << i + n / i - 2 << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
N = int(input())
A = [int(i) for i in input().split()]
B = [abs(i) for i in A]
for i in range(N-1):
    if(A[i]<0):
        A[i] = -A[i]
        A[i+1] = -A[i+1]
if(A[N-1]<0):
    flag = False
else:
    flag = True

if(flag):
    print(sum(A))
else:
    m = min(B)
    print(sum(B)-2*m)

Measured memory_bytes: 14252
using System;
using System.Linq;
using System.Collections.Generic;

static class Program{
    static void Main() {
        int[]nk=Console.ReadLine().Split().Select(int.Parse).ToArray();
        int n=nk[0];
        int k=nk[1];
        String s=Console.ReadLine();
        List<int>list=new List<int>();
        if(s[0]!='1')list.Add(0);
        list.Add(0);
        for(int i=1;i<n;i++){
            if(s[i-1]!=s[i])list.Add(i);
        }
        for(int i=0;i<2*k+1;i++)list.Add(n);

        n=list.Count;
        int ans=0;
        for(int i=0;i+2*k+1<n;i+=2){
            ans=Math.Max(ans, list[i+2*k+1]-list[i]);
        }
        Console.WriteLine(ans);
    }
}

/*
0 個の 1 を付け加えて 101010101 型に帰着します。
偶数番目から 2*k+1 個の和です。
rle のようなことをしますが、累積和です。
番兵を 2*k 個入れておきましょう。
*/

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */



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

	string s; cin >> s;
	LL ans = s.find("9")!=string::npos;
	cout << (ans?"Yes":"No") << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(int i=0; i<(n); ++i)
#define FOR(i, a, b) for(int i=(a); i<(b); ++i)
#define FORR(i, a, b) for(int i=(b)-1; i>=(a); --i)
const ll MOD=998244353ll;
const int MAX=510000;

ll fact[MAX], fact_inv[MAX];

ll power(ll a, ll b){
	ll res=1;
	while(b>0){
		if(b&1) res=res*a%MOD;
		a=a*a%MOD;
		b>>=1;
	}
	return res;
}

ll comb(ll n, ll r){
	return (fact[n]*fact_inv[r])%MOD*fact_inv[n-r]%MOD;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
    ll k,a,b;
    cin>>k>>a>>b;
    if(b-a <=2 || k<= a) cout << k+1 << endl;
    else{
        ll ret = 0;
        k -= a+1;
        ret += b;
        ret += (k/2)*(b-a) + k%2;
        cout << ret << endl;
    }
    return 0;
}





Measured memory_bytes: 256
N = int(input())
def n(s):
    if int(s) > N:
        return 0
    if '7' in s and '5' in s and '3' in s:
        p = 1
    else:
        p = 0
    p += n(s+'7')
    p += n(s+'5')
    p += n(s+'3')
    return p
print(n('0'))


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

int main() {
    int N,M;
    cin>>N>>M;
    vector<ll> A(N);
    for(int i=0;i<N;i++) cin>>A[i];
    map<int,int> m;
    vector<int> SUM(N+1);
    SUM[0]=0;
    for(int i=0;i<N;i++) SUM[i+1]=(SUM[i]+A[i])%M;
    
    ll ans=0;
    for(int i=0;i<SUM.size();i++){
        ans+=m[SUM[i]];
        m[SUM[i]]++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 4352
#include <iostream> 
#include<vector>
#include<algorithm>
#include<map>
#include<iomanip>
#include<set>
#include<queue>
#include<deque>
#include<iomanip>
#include<sstream>
#include<cmath>
#include<bitset>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define req(i,n) for(int i = 1;i <=  n; i++)
#define rrep(i,n) for(ll i = n-1;i >= 0;i--)
#define ALL(obj) begin(obj), end(obj)
#define RALL(a) rbegin(a),rend(a)
typedef long long int ll;
int main(void) {
    ll n, l,t,cnt = 0; cin >> n >> l>>t;
    vector<ll> x(n), w(n),dis(n);
    rep(i, n) cin >> x[i] >> w[i];
    rep(i, n) {
        if (w[i] ==1) {
            dis[i] = (x[i] + t) % l;
            cnt -= (t - (l - x[i]) + l) / l;
        }
        else {
            dis[i] = ((x[i] - t) % l + l) % l;
            cnt += (t - (x[i] + 1) + l) / l;
        }
    }
    cnt = (cnt % n + n) % n;
    sort(ALL(dis));
    vector<ll> ans(n);
    rep(i, n) ans[(i + cnt) % n] = dis[i];
    for (int i : ans) cout << i << endl;
}

Measured memory_bytes: 6428
fun main(args:Array<String>) {
	val n = readLine()!!.toInt()
	val s = readLine()!!
	
	
	(1 until n).map { i->
		val a=s.take(i).toList().distinct()
		val b=s.drop(i).toList().distinct()
		return@map a.count{it in b}
	}.max()!!.let {
		println(it)
	}
}

Measured memory_bytes: 35780
using System;
using System.Linq;
using System.Collections.Generic;

class Program
{

    static void Main(string[] args)
    {
        var inputs = Console.ReadLine().Split(' ');
        var A = int.Parse(inputs[0]);
        var B = int.Parse(inputs[1]);
        var T = int.Parse(inputs[2]);

        var scale = T / A;
        var sum = B * scale;
        Console.WriteLine(sum);

    }

}



Measured memory_bytes: 11092
def solve():
    sum = 0 # 求める合計値

    n = input()
    op_cnt = len(n) - 1 # 隙間の個数 op:operator
    for i in range(2 ** op_cnt): # iは2進数で000, 001, 010, 011...,111と遷移する
        op = [""] * op_cnt # あらかじめ["", "", ""]というリストを作っておく
        for j in range(op_cnt):
            if ((i >> j) & 1): # 5 = 0b101の場合["+", "", "+"]となる
                op[op_cnt - 1 - j] = "+"

        formula = "" # formula:式
        # 演算子の数はn-1個なので個数を合わせる
        # p_n: part_of_n?
        for p_n, p_o in zip(n, op + [""]):
            formula += (p_n + p_o)
        sum += eval(formula)
    print(sum)
solve()

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
#define MAX 100000
int parent(int i){return i/2;}
int left(int i){return 2*i;}
int right(int i){return 2*i+1;}

int main(){
  int H,i,A[MAX+1];
  cin>>H;
  for(i=1;i<=H;i++) cin >> A[i];
  for(i=1;i<=H;i++){
    cout<<"node "<<i<<": key = "<<A[i]<<", ";
    if(parent(i)>=1) cout << "parent key = "<<A[parent(i)]<<", ";
    if(left(i)<=H) cout << "left key = "<<A[left(i)]<<", ";
    if(right(i)<=H) cout << "right key = "<<A[right(i)]<<", ";
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 3068
def main():
    n = int(input())
    ans = 1
    A = list(map(int,input().split()))
    A.sort()
    for a in A:
        ans *= a
        if 1e18 < ans:
            print(-1)
            return 
    print(ans)

if  __name__ == "__main__":
    main()

Measured memory_bytes: 88984
from collections import defaultdict
n = int(input())
arr = list(map(int,input().split()))
arr.sort()
maxn = 1000005
d = [0 for i in range(maxn)]
prime = [True for i in range(maxn)]
for i  in range(n):
	cur = arr[i]
	d[cur]+=1
	if prime[cur]==True and d[cur]==1:
		for j in range(2*cur,len(prime),cur):
			prime[j] = False
ans = 0
for i in arr:
	if prime[i]==True and d[i]==1:
		ans+=1
print(ans)

Measured memory_bytes: 166724
import scala.io.StdIn

object Main extends App {
  val n = StdIn.readLine.toInt
  val s = StdIn.readLine
  val res = for {
    i <- 1 until n
  } yield {
    (s.substring(0,i) intersect s.substring(i,n))
    .distinct.length
  }
  println(res.max)
}

Measured memory_bytes: 27292
import java.util.*;

public class Main {
    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);
        while (true) {
            int x = sc.nextInt();
            int y = sc.nextInt();
            if (x == 0 && y == 0)
                break;
            if (x < y) {
                System.out.print(x);
                System.out.print(' ');
                System.out.println(y);
            } else {
                System.out.print(y);
                System.out.print(' ');
                System.out.println(x);
            }
        }
    }
}

Measured memory_bytes: 35176
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>
#include <math.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_sz_desc(const void* a, const void* b) {
    return *((size_t*)a) > * ((size_t*)b) ? -1 : 1;
}

int compare_f(const void* a, const void* b) {
    return *((int64_t*)a) < *((int64_t*)b) ? -1 : 1;
}

int compare_f2(const void* a, const void* b) {
    return *((uint64_t*)a) > * ((uint64_t*)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
    size_t result = 1;

    for (size_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t combU64(const uint64_t n, const uint64_t r) {
    uint64_t result = 1;

    for (uint64_t i = 0; i < r; i++) {
        result *= n - i;
        result /= i + 1;
    }

    return result;
}

static uint64_t gcdU64(uint64_t m, uint64_t n)
{
    uint64_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

static size_t gcdZu(size_t m, size_t n) {
    size_t temp;

    while (m % n != 0) {
        temp = n;
        n = m % n;
        m = temp;
    }

    return n;
}

int main(void) {
    size_t A, B;

    scanf("%zu %zu", &A, &B);

    if (13 <= A) {
        printf("%zu\n", B);
    }
    else if (6 <= A) {
        printf("%zu\n", B / 2);
    }
    else {
        puts("0");
    }

    return 0;
}


Measured memory_bytes: 128
object Main {
  def main(args: Array[String]) {
    val str = io.StdIn.readLine()
    val s1 = str.take(3)
    val s2 = str.drop(1)
    def veri(s: String) = s.head == s(1) && s.head == s(2)
    println(if (veri(s1) || veri(s2)) "Yes" else "No")
  }
}

Measured memory_bytes: 25512
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define INF 1000000000000000
#define MOD 1000000007

int main(){
  ll N;
  cin>>N;
  vector<ll> a(N);
  for(ll i=0;i<N;i++){
    cin>>a.at(i);
  }

  bool flag=true;
  for(ll i=0;i<N;i++){
    if(a.at(i)>=N){
      flag=false;
    }
  }
  if(flag){
    cout<<0<<endl;
    return 0;
  }
  ll ans=0;
  while(true){
    ll sum=0;
    vector<ll> count(N,0);
    for(ll i=0;i<N;i++){
      if(a.at(i)>=N){
        count.at(i)=(a.at(i)-N)/N+1;
        sum+=count.at(i);
        ans+=count.at(i);
        a.at(i)-=count.at(i)*N;
      }
    }
    for(ll i=0;i<N;i++){
      a.at(i)+=sum-count.at(i);
    }
    bool flag=true;
    for(ll i=0;i<N;i++){
      if(a.at(i)>=N){
        flag=false;
      }
    }
    if(flag){
      cout<<ans<<endl;
      break;
    }
  }
}


Measured memory_bytes: 256
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <numeric>
#include <functional>

using namespace std;
#define ALL(x)              (x).begin(),(x).end()
typedef long long           ll;
#define REP(i, n)           for (ll i = 0 ; i < (ll)n ; ++i)
#define REPN(i, m, n)       for (ll i = m ; i < (ll)n ; ++i)
#define INF                 (ll)2e9
#define MOD                 (1000 * 1000 * 1000 + 7)
#define Ceil(x, n)          (((((x))+((n)-1))/n))
#define CeilN(x, n)         (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)        ((x)-(x)%(n))
#define IsOdd(x)            (((x)&0x01UL) == 0x01UL)
#define IsEven(x)           (!IsOdd((x)))
#define M_PI                3.14159265358979323846
typedef pair<ll, ll>	    P;

/*-----------------------------------------------------------------------------
　処理
 -----------------------------------------------------------------------------*/
int main()
{
	string S;
	cin >> S;
	reverse(ALL(S));

	ll keta = 1;
	ll amari = 0;
	map<ll, ll> mp;
	REP(i, S.size()) {
		amari = (amari + (S[i] - '0') * keta) % 2019;
		keta *= 10;
		keta %= 2019;
		mp[amari]++;
	}

	ll ans = mp[0];
	for (auto one : mp) {
		ans += one.second * (one.second - 1) / 2;
	}

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


Measured memory_bytes: 3736
N = gets.to_i
S = gets.chomp.split('').map{|c| c == 'x' ? 1 : 0}

['00', '10', '01', '11'].each do |cand|
    s2 = cand.split('').map(&:to_i)
    (2..(N+1)).each do |i|
        s2[i] = s2[i-1] ^ s2[i-2] ^ S[(i-1)%N]
    end
    if s2[0] == s2[N] && s2[1] == s2[N+1]
        puts s2[0, N].map{|i| i == 1 ? 'W' : 'S'}.join
        exit
    end
end

puts -1

Measured memory_bytes: 14004
/***********************************************************
 *This code By @1353055672(Ligen)                          *
 *[Warning]You're not excepted to understand this code!    *
 *NOIP 2019 RP++                                           *
 ***********************************************************/
//#pragma GCC optimize(3)
#define ADD_STACK int size = 512 << 20;\
	char *pp = (char*)malloc(size) + size;  \
	__asm__("movl %0, %%esp\n" :: "r"(pp))
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<fstream>
#include<queue>
#include<map>
#include<stack>
#include<set>
#include<bitset>
#include<ctime>
#include<vector>
#define ll long long
#define ull unsigned long long
#define mn 200020
#define Max(x,y) (((x)>(y))?(x):(y))
#define Min(x,y) (((x)<(y))?(x):(y))
#define Abs(x) (((x)<(0))?(-(x)):(x))
#define infll (ll)(1e18)
#define infint (1<<30)
#define mod (int)(1e9+7)
#define FOR(a,b,c) for (register int a=b;a<=c;++a)
#define FORD(a,b,c) for (register int a=b;a>=c;--a)
using namespace std;
//char buf[1<<20],*p1=buf,*p2=buf;
//#define getchar() (p1==p2&&(p2=(p1=buf)+fread(buf,1,1<<20,stdin),p1==p2)?EOF:*p1++)
inline ll read(){
	ll x=0,f=1;char c;
	for(c=getchar();c<'0'||c>'9';f=((c=='-')?-1:f),c=getchar());
	for(;c>='0'&&c<='9';x=x*10+c-'0',c=getchar());return x*f;
}
template<typename T>
inline void write(T a){
	if(a==0){putchar('0');return;}if(a<0)putchar('-'),a=-a;char c1[120];int h=0;
	while(a)c1[++h]=a%10+'0',a/=10;FORD(i,h,1)putchar(c1[i]);
}
inline void write_(){return;}
template<typename T,typename... Args>
inline void write_(T a,Args... b){write(a);putchar(' ');write_(b...);}
inline void writeln(){putchar('\n');return;}
template<typename T,typename... Args>
inline void writeln(T a,Args... b){write(a);putchar(' ');writeln(b...);}
//need c++11

//inline void write(ll a){
//    if(a==0){putchar('0');return;}if(a<0)putchar('-'),a=-a;char c1[120];int h=0;
//    while(a)c1[++h]=a%10+'0',a/=10;FORD(i,h,1)putchar(c1[i]);
//}
//inline void write_(ll a){write(a);putchar(' ');}
//inline void writeln(ll a){write(a);putchar('\n');}
inline ll gcd(ll a,ll b){return a==0?b:gcd(b%a,a);}
inline ll lcm(ll a,ll b){return 1ll*a/gcd(a,b)*b;}
inline ll Pow(ll n,ll a){ll b=1;while(a){if(a&1)b=1ll*b*n%mod;n=1ll*n*n%mod;a>>=1;}return b;}
//---------------------Head Files--------------------------//

signed main(){
	#ifdef _WIN32
		// freopen("0.in","r",stdin);
		// freopen("0.out","w",stdout);
		long double be=clock();
	#endif
	int n=read(),ans=0;
	for(int i=1,w=1;i<=n;i=i*10,++w)if(w&1){
		ans+=Min(n-i+1,i*10-i);
	}
	writeln(ans);
	#ifdef _WIN32
		long double en=clock();
		printf("Time: %.0Lfms\n",en-be);
		fclose(stdin);fclose(stdout);
	#endif
	return 0;
}

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


using namespace std;


#define ll long long
#define mk make_pair
#define pb push_back
#define ff first
#define sc second
#define all(x) x.begin(), x.end()
#define sz(x) (x).size()

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

ll sum(int n){
   if(n == 0){
      return n;
   }else{
      return sum(n/10) + n%10;
   }
}

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

   int  k; cin >> k;
   string s; cin >> s;
   
   string ans = s;
   if(sz(s) > k)
   {
      ans = "";
      for(int i = 0; i < k; i++)
      {
         ans += s[i];
      }
      ans += "...";
   }

   cout << ans;

   return 0;
}


Measured memory_bytes: 3648
a = [int(input()) for i in range(5)]
b = []
for i in range(5):
	x = a[i]%10
	if x != 0:
	    b.append(10 - x)
ans = 0
for u in a:
    ans += u // 10 * 10
ans += len(b) * 10
if len(b) != 0:
	ans -= max(b)
print(ans)

Measured memory_bytes: 3060
n,m = map(int,input().split())
prbs = [ [0] for _ in range(1,n+1)]
#print(prbs)
for _ in range(m):
    i,j = map(str,input().split())
    i = int(i)
    i -= 1
    if prbs[i][-1] != "AC":
        prbs[i].append(j)
pen = 0
for i in range(n):
    if prbs[i][-1] == "AC":
        pen += prbs[i].count("WA")
ans = 0
for i in range(n):
    ans += prbs[i].count("AC")
#print(prbs)
print(ans,pen)

Measured memory_bytes: 21456
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
int a,p;
  cin>>a>>p;
  cout<<(3*a+p)/2<<endl;
}





Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#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 <string.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,a,b) for(int i=a;i<=b;i++)
#define INF 2147483647
#define LLINF 9223372036854775807
using namespace std;
//ָ��+1�����
long long cnt[1010];
void doo(int p){
	while(p){
		for(int i=2;i<=p;i++){
			if(p%i==0){
				p/=i;
				cnt[i]++;
				break;
			}
			if(i==p){
				cnt[p]++;
				p=0;
				break;
			}
		}
		if(p==1)break;
	}
}
int main(){
	int n;
	cin>>n;
	long long ans=1;
	for(int i=1;i<=n;i++){
		doo(i);
	}
	for(int i=1;i<=n;i++){
		ans*=(cnt[i]+1);
		ans%=1000000007;
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
str_lis = [''.join(sorted(list(input()))) for _ in range(n)]

d = {}
ans = 0

for j in str_lis:
    if j in d.keys():
        ans += d[j]
        d[j] += 1
    else:
        d[j] = 1
        
print(ans)

Measured memory_bytes: 19504