akhauriyash/Code-Regression huggingface dataset:
def factorization(n):
  """
  引数の値を素因数分解したリストを返す

  Parameters
  ----------
  n : int
      素因数分解したい自然数

  Returns
  -------
  retlist : list
      2以上の整数n => [[素因数, 指数], ...]の2次元リスト
  """
  retlist = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0:
        cnt+=1
        temp //= i
      retlist.append([i, cnt])

  if temp!=1:
    retlist.append([temp, 1])

  if retlist==[]:
    retlist.append([n, 1])

  return retlist

n=int(input())
mod=10**9+7
from collections import Counter
c=Counter()
ans=1
for i in range(2,n+1):
  d=factorization(i)
  for k,v in d:
    c[k]+=v
for v in c.values():
  ans*=v+1
  ans%=mod
print(ans)




Measured memory_bytes: 3316
#include <iostream>
#include<unordered_set>
using namespace std;
int main()
{
	string s;
	cin >> s;
	unordered_multiset<char> ms;
	for(const auto& i : s) ms.insert(i);
	for(const auto& i : ms) 
	  if(ms.count(i) > 1) {
	  	cout << "no";
	  	return 0;
	  }
	  cout << "yes";
	return 0;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
//Decomposition of Strongly Connected Components
//KYOURENKETSU SEIBUN BUNKAI
class SCC{
    using VI=vector<int>;
    using VVI=vector<VI>;
    using EDGE=VVI;
private:
    EDGE e,r_e;
    VI vs;
public:
    int size;
    VI comp,D;
    VVI nodeset;
    EDGE newedge;
private:
    void dfs(int v){
	comp[v]=0;
	for(auto& u : e[v])if(comp[u]==-1)dfs(u);
	vs.push_back(v);
    }
    void rdfs(int v,int k){
	comp[v]=k;
	for(auto& u : r_e[v])if(comp[u]==-1)rdfs(u,k);
    }
    void decomposition(){
	comp.resize(size);
	fill(comp.begin(),comp.end(),-1);
	vs.clear();
	for(int v = 0; v < size; v++)
	    if(comp[v]==-1)dfs(v);
	reverse(vs.begin(),vs.end());
	fill(comp.begin(),comp.end(),-1);
	int k=0;
	for(auto& v : vs)if(comp[v]==-1)rdfs(v,k++);
	nodeset.resize(k);
	newedge.resize(k);
	D.resize(k);
	fill(D.begin(),D.end(),0);
	for(int v = 0; v < size; v++){
	    nodeset[comp[v]].push_back(v);
	    for(auto& u : e[v])
		if(!isSameComponents(v,u)){
		    newedge[comp[v]].push_back(comp[u]);
		    D[comp[u]]++;
		}
	}
	size=k;
    }
public:
    bool isSameComponents(int a,int b){
	return comp[a]==comp[b];
    }
    SCC(int N,EDGE& edge):size(N){
	e=edge;
	r_e.resize(size);
	for(int v = 0; v < size; v++)
	    for(auto& u : e[v])
		r_e[u].push_back(v);
	decomposition();
    }
    SCC(EDGE& edge):SCC(edge.size(),edge){}
};


struct CWW{CWW(){ios::sync_with_stdio(false);cin.tie(0);}}cww;


typedef vector<int> V;
typedef vector<V> Graph;
typedef long long LL;
const LL MOD=1e9+7;
LL dfs(int v,Graph& tree){
    LL child=1;
    for(auto &u:tree[v]){
	(child*=dfs(u,tree))%=MOD;
    }
    return (child+1)%MOD;

}
int main(){
    int N,M;cin>>N>>M;
    Graph g(N);
    while(M--){
	int a,b;
	cin>>a>>b;
	a--,b--;
	g[b].push_back(a);
    }
    SCC scc(g);
    int m=scc.D.size();
    LL res=1;
    for(int i=0;i<m;i++)if(scc.D[i]==0)(res*=dfs(i,scc.newedge))%=MOD;
    cout<<res<<endl;
}

Measured memory_bytes: 3480
#include<iostream>
#include<vector>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<algorithm>
using std::cout;
using std::cin;
using std::endl;

int main(void){
    int N;
    cin >> N;
    if(N<=999)
        cout << "ABC" << endl;
    else
        cout << "ABD" << endl;

    return 0;
}


Measured memory_bytes: 256
import collections

N = int(input())
l = list(map(int, input().split()))

a = []
b = []
a_f = 0
b_f = 0
a_s = 0
b_s = 0
for i in range(N):
    if i%2 == 0:
        a.append(l[i])
    else:
        b.append(l[i])
        
c_a = collections.Counter(a)
c_b = collections.Counter(b)

a_f = c_a.most_common()[0]
b_f = c_b.most_common()[0]

if a_f[0] != b_f[0]:
    print(N - a_f[1] - b_f[1])

elif len(set(a)) == 1 and len(set(b)) == 1:
    print(int(N/2))
elif len(set(a)) == 1:
    print(int(N/2 - c_b.most_common()[1][1]))
elif len(set(b)) == 1:
    print(int(N/2 - c_a.most_common()[1][1]))
elif a_f[1] == b_f[1]:
    second_a = c_a.most_common()[1][1]
    second_b = c_b.most_common()[1][1]
    if second_a >= second_b:
        print(int(N - b_f[1] - second_a))
    else:
        print(int(N - a_f[1] - second_b))
elif a_f[1] > b_f[1]:
    print(int(N - a_f[1] - c_b.most_common()[1][1]))
else:
    print(int(N - b_f[1] - c_a.most_common()[1][1]))

Measured memory_bytes: 20576
#include <stdio.h>

int EyeTest(double sight)
{
	     if(sight>= 1.1)return 0;
	else if(sight>= 0.6)return 1;
	else if(sight>= 0.2)return 2;
	return 3;
}

int main(void)
{
	int i;
	int lN[4]={0}, rN[4]={0};
	double l, r;
	while(scanf("%lf %lf", &l, &r)!=EOF)
	{
		lN[ EyeTest(l) ]++;
		rN[ EyeTest(r) ]++;
	}
	for(i=0; i<4; i++)
		printf("%d %d\n", lN[i], rN[i]);
	return 0;
}

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

al = "abcdefghijklmnopqrstuwvxyz"

_max = 0
for i in range(1, N-1):
    s_1 = S[:i]
    s_2 = S[i:]
    count = 0
    for a in al:
        if a in s_1 and a in s_2:
            count += 1
    if count > _max:
        _max = count

print(_max)


Measured memory_bytes: 64600
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); ++i)
#define outl(x) cout<< (x) << '\n'
#define fi first
#define se second
using pii = pair<int,int>;
using ll = long long;
using vi = vector<int>;

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

    ll a, b;
    cin>> a >> b;
    if (a+b == 15) outl("+");
    else if (a * b == 15) outl("*");
    else outl("x");
}



Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include <string>
#include <numeric>

using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
map<int, int> mp;
map<int, int>mm;
#define ll long long
#define ld long double
#define PI 3.14159265358979l

unsigned gcd(unsigned a, unsigned b) {
	if (a < b) gcd(b, a);
	unsigned r;
	while ((r = a % b)) {
		a = b;
		b = r;
	}
	return b;
}
char tolower(char c) {
	return (c + 0x20);
}


int main() {
	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	rep(i, k-1) {
		cout << s[i];
	}
	cout << tolower(s[k - 1]);
	for (int i = k; i < n; i++) {
		cout << s[i];
	}
	cout << endl;
	cin >> s;
}


Measured memory_bytes: 256
import java.util.*;

import java.util.*;
import java.io.*;

class Main{
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      int n = sc.nextInt();
      int k = sc.nextInt();
      char[] s = sc.next().toCharArray();
      
      StringBuilder res = new StringBuilder();
      for(int i = 0;i<s.length;i++){
        if(i+1==k){
          res.append(Character.toLowerCase(s[i]));
        }
        else{
          res.append(s[i]);
        }
      }
      
      System.out.println(res.toString());
      	
    }
}

Measured memory_bytes: 21588
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<complex>
#include<tuple>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
typedef pair<ll,ll> pll;
typedef long double D;
typedef complex<D> P;
#define F first
#define S second
const ll E=1e18+7;
const ll MOD=1000000007;

template<typename T,typename U>istream & operator >> (istream &i,pair<T,U> &A){i>>A.F>>A.S; return i;}
template<typename T>istream & operator >> (istream &i,vector<T> &A){for(auto &I:A){i>>I;} return i;}
template<typename T,typename U>ostream & operator << (ostream &o,const pair<T,U> &A){o<<A.F<<" "<<A.S; return o;}
template<typename T>ostream & operator << (ostream &o,const vector<T> &A){ll i=A.size(); for(auto &I:A){o<<I<<(--i?" ":"");} return o;}
template<typename T>vector<T> & cset(vector<T> &A,T e=T()){for(auto &I:A){I=e;} return A;}




int main(){
    ll n,k;
    cin>>n>>k;
    const ll MX=n*n*2+10;
    vector<vector<ll>> dp(n+1,vector<ll>(MX*2+1,0));
    vector<vector<ll>> nx(n+1,vector<ll>(MX*2+1,0));
    dp[0][MX]=1;
    for(ll i=0;i<n;i++){
        for(auto &I:nx){cset(I,0LL);}
        for(ll j=0;j<=n;j++){
            for(ll l=0;l<=MX*2;l++){
                const ll N=dp[j][l];
                if(N==0){continue;}
                
                auto add=[&](ll a,ll b,ll c)->void{
                    if(a>=0 && a<=n && b>=0 && b<=MX*2){
                        nx[a][b]+=c;
                        nx[a][b]%=MOD;
                    }
                };
                //sonomama
                add(j,l,N);
                //ue,aki
                add(j+1,l-2*i,N);
                //ue,ire
                add(j,l+i-i,N*j%MOD);
                //sita,aki
                add(j,l+i-i,N*j%MOD);
                //sita,ire
                add(j-1,l+2*i,N*j%MOD*j%MOD);
            }
        }
        swap(dp,nx);
    }
    ll ans=dp[0][MX+k];
    ans%=MOD;
    if(ans<0){ans+=MOD;}
    cout<<ans<<endl;
    
    
    return 0;
}


Measured memory_bytes: 8320
/****************************************************************
*	Author: huhao
*	Email: 826538400@qq.com
*	Create time: 2020-01-21 18:55:57
****************************************************************/
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#define fr(i,a,b) for(int i=(a),end_##i=(b);i<=end_##i;i++)
#define fd(i,a,b) for(int i=(a),end_##i=(b);i>=end_##i;i--)
int read()
{
	int r=0,t=1,c=getchar();
	while(c<'0'||c>'9')
	{
		t=c=='-'?-1:1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		r=(r<<3)+(r<<1)+(c^48);
		c=getchar();
	}
	return r*t;
}
#define i64 long long
const int N=(1<<18)|10,mod=998244353;
i64 power(i64 a,i64 b,i64 p)
{
	i64 r=1; a%=p;
	while(b)
	{
		if(b&1) r=r*a%p;
		a=a*a%p; b>>=1;
	}
	return r;
}
i64 inv(i64 a){ return power(a,mod-2,mod); }
i64 n,f[N],g[N],s;
void fwt(i64 *a,i64 n,i64 opt)
{
	fr(i,0,n-1) for(int j=0;j<(1<<n);j+=(1<<(i+1))) fr(k,0,(1<<i)-1)
	{
		i64 x=a[j+k],y=a[j+k+(1<<i)];
		a[j+k]=(x+y)%mod; a[j+k+(1<<i)]=(x-y+mod)%mod;
	}
	if(opt==-1)
	{
		i64 I=inv(1<<n);
		fr(i,0,(1<<n)-1) a[i]=a[i]*I%mod;
	}
}
int main()
{
	n=read();
	fr(i,0,(1<<n)-1) s=(s+(g[i]=read()))%mod;
	fr(i,0,(1<<n)-1) g[i]=g[i]*inv(s)%mod;
	g[0]=g[0]?g[0]-1:mod-1;
	fwt(g,n,1);
/*	fr(i,0,(1<<n)-1) f[i]=read();
//	fr(i,0,(1<<n)-1) printf("%d%c",int(f[i]),i==end_i?'\n':' '); // 0 4 4 4
	fwt(f,n,1);
	fr(i,0,(1<<n)-1) printf("%d%c",int(f[i]),i==end_i?'\n':' '); // 12 -4 -4 -4
	fr(i,0,(1<<n)-1) f[i]=f[i]*g[i]%mod;
//	fwt(f,n,-1);
//	fr(i,0,(1<<n)-1) printf("%d%c",int(f[i]),i==end_i?'\n':' '); // 0 4 4 4
	return 0;*/
	fr(i,1,(1<<n)-1) f[0]=(f[0]-(f[i]=(1<<n)*inv(g[i])%mod)+mod)%mod;
	fwt(f,n,-1);
	fr(i,0,(1<<n)-1) printf("%d\n",int(f[i]));
	return 0;
}

Measured memory_bytes: 6784
// 7/25 リアルタイム参加
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
using ll = long long;
using P = pair<int, int>;

int main() {
    int N, K;
    cin >> N >> K;
    vector<int> A(N);
    rep(i, N) cin >> A[i];

    for (int i = K; i < N; i++) {
        if (A[i] > A[i-K]) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 4048
def main():
    N, X, M = map(int, input().split())
    ans = X
    pre = X
    cand = [X]
    cnt = 1
    for i in range(N-1):
        now = pre ** 2 % M
        if now in cand:
            cnt += 1
            index = cand.index(now)
            loop = cand[index:]
            L = len(loop)
            amari = (N - cnt + 1) % L
            syou = (N - cnt + 1) // L
            ans += syou * sum(loop)
            ans += sum(loop[:amari])
            break
        else:
            ans += now
            pre = now
            cand.append(now)
            cnt += 1
    print(ans)


if __name__ == "__main__":
    main()

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

int main(){
    int firstNum, secondNum;
    cin >> firstNum >> secondNum;
    if ( (firstNum + secondNum) % 2 == 0){
        cout << (firstNum + secondNum) / 2 << endl;
    } else {
        cout << ((firstNum + secondNum) / 2) + 1 << endl;
    }
}

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

typedef pair<int,int> P;

const int inf = 1 << 28;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
int n, m;
vector<vector<int> > d;
vector<string> vs;

void bfs(int x, int y) {
    queue<P> que;
    que.push(P(x,y));

    while (que.size()) {
        P p = que.front(); que.pop();
        x = p.first;
        y = p.second;

        for (int i = 0; i < 4; i++) {
            int nx = x + dx[i];
            int ny = y + dy[i];

            if (0 <= nx && nx < n && 0 <= ny && ny < m && vs[nx][ny] != '#' && d[nx][ny] > d[x][y] + 1) {
                d[nx][ny] = d[x][y] + 1;
                que.push(P(nx,ny));
            }
        }
    }
}

int main() {
    int sx, sy, gx, gy;
    vector<int> sr, sc;
    cin >> n >> m;
    vs.resize(n);
    for (auto& i : vs) cin >> i;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (vs[i][j] == '@') sx = i, sy = j;
            if (vs[i][j] == '$') sr.push_back(i), sc.push_back(j);
            if (vs[i][j] == '%') gx = i, gy = j;
        }
    }
    d.resize(n);
    for (auto& i : d) i.resize(m, inf);

    for (int i = 0; i < sr.size(); i++) {
        d[sr[i]][sc[i]] = 0;
        bfs(sr[i], sc[i]);
    }

    queue<P> que;
    que.push(P(sx,sy));
    vector<vector<int> > dist(n, vector<int>(m,inf));
    dist[sx][sy] = 0;

    while (que.size()) {
        P p = que.front(); que.pop();
        int x = p.first;
        int y = p.second;

        for (int i = 0; i < 4; i++) {
            int nx = x + dx[i];
            int ny = y + dy[i];

            if (0 <= nx && nx < n && 0 <= ny && ny < m && vs[nx][ny] != '#' 
                && dist[nx][ny] > dist[x][y] + 1 && dist[x][y] + 1 < d[nx][ny]) {
                dist[nx][ny] = dist[x][y] + 1;
                que.push(P(nx,ny));
            }
        }
    }

    cout << (dist[gx][gy] != inf ? "Yes" : "No") << endl;
    
    return 0;
}

Measured memory_bytes: 3612
n,m=[int(i) for i in input().split()]
k=[]
s=[]
for i in range(m):
    Input=[int(i) for i in input().split()]
    k.append(Input[0])
    s.append(Input[1:])
p=[int(i) for i in input().split()]

ans=2**n
for i in range(2**n):
    for ind,light in enumerate(s):
        SwitchOn=0
        for ConnectedSwitch in light:
            if(i >> (ConnectedSwitch - 1) & 1):
                SwitchOn += 1
        if(SwitchOn % 2 != p[ind]):#ライトがoffなら
            ans-=1
            break
print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#define a 100
#define n 100

int selectionSort(int A[], int N){
    int i = 0;
    int j = 0;
    int minj = 0;
    int count = 0;
    int tmp = 0;
    int t = 0;
    
    for(i = 0; i < N; i++){
        minj = i;
        for(j = i; j < N; j++){
            if(A[j] < A[minj]){
                minj = j;
            }
        }
        if(minj != i){
            tmp = A[i];
            A[i] = A[minj];
            A[minj] = tmp;
            count++;
        }
    }
    
    for(t = 0; t < N; t++){
        if(t == N-1){
            printf("%d\n", A[t]);
        }else{
            printf("%d ", A[t]);
        }
    }
    printf("%d\n", count);
}

int main(void){
    int A[a] = {};
    int N = 0;
    int i = 0;
    
    scanf("%d", &N);
    for(i = 0; i < N; i++){
        scanf("%d", &A[i]);
    }
    
    selectionSort(A, N);
    
    return 0;
}

Measured memory_bytes: 600
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <math.h>
#include <numeric>
#include <deque>
using namespace std;

int main() {
    int N, A, B;
    cin >> N >> A >> B;
    cout << min(N * A, B);
}


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

int main(){

    int n; cin >> n;
    vector<long long> A(n);
    vector<long long> B(n);
    for(int i = 0; i < n; i++) cin >> A[i] >> B[i];
    if(A == B){
        cout << 0 << endl;
        return 0;
    }
    long long ans = 0;
    
    long long mi = 1000000007;
    for(int i = 0; i < n; i++){
        ans += A[i];
        if(A[i] > B[i]) mi = min(mi, B[i]);
    }

    ans -= mi;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 512
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<queue>
using namespace std;
#define MAX 100100
#define ll long long
inline int read()
{
	int x=0;bool t=false;char ch=getchar();
	while((ch<'0'||ch>'9')&&ch!='-')ch=getchar();
	if(ch=='-')t=true,ch=getchar();
	while(ch<='9'&&ch>='0')x=x*10+ch-48,ch=getchar();
	return t?-x:x;
}
struct Line{int v,next;}e[MAX<<1];
int h[MAX],cnt=1;
inline void Add(int u,int v){e[cnt]=(Line){v,h[u]};h[u]=cnt++;}
int n,m,col[MAX],dis[MAX];
int Q,U[MAX],D[MAX],C[MAX];
void BFS(int S,int d,int c)
{
	if(dis[S]>=d)return;dis[S]=d;
	queue<int> Q;Q.push(S);
	while(!Q.empty())
	{
		int u=Q.front();Q.pop();
		if(!col[u])col[u]=c;
		if(!dis[u])continue;
		for(int i=h[u];i;i=e[i].next)
			if(dis[e[i].v]<dis[u]-1)
			{
				dis[e[i].v]=dis[u]-1;
				Q.push(e[i].v);
			}
	}
}
int main()
{
	n=read();m=read();
	for(int i=1;i<=m;++i)
	{
		int u=read(),v=read();
		Add(u,v);Add(v,u);
	}
	Q=read();memset(dis,-1,sizeof(dis));
	for(int i=1;i<=Q;++i)U[i]=read(),D[i]=read(),C[i]=read();
	for(int i=Q;i;--i)
		BFS(U[i],D[i],C[i]);
	for(int i=1;i<=n;++i)printf("%d\n",col[i]);
	return 0;
}


Measured memory_bytes: 4736
#include <bits/stdc++.h>
using namespace std;
 
#define lglg long long
#define FOR(i, a, b) for (int i=(a); i<(b); ++i)
#define ROF(i, b, a) for (int i=(b); i>(a); --i)
#define CASET int _T; cin >> _T; REP(caset, 0, _T)
#define vi vector<int>
#define vb vector<bool>
#define vs vector<string>
#define vvi vector<vi>
#define vvb vector<vb>
#define pii pair<int,int>
#define t3i tuple<int,int,int>
#define mii map<int,int>
#define vpii vector<pii>
#define vt3i vector<t3i>
#define sq(x) (x)*(x)
#define inv(x) powa(x, MOD-2)

long long INF = 1LL<<60;
long long MOD = 998244353;

template <typename A, typename B> istream &operator>>(istream &is, pair<A, B> &pr) {is >> pr.first >> pr.second; return is;}
template <typename A> istream &operator>>(istream &is, vector<A> &v) {for (auto &x : v) is >> x; return is;}
ostream &operator<<(ostream &os, char &c) {os << (char)c; return os;}
ostream &operator<<(ostream &os, const char s[]) {os << (string)s; return os;}
ostream &operator<<(ostream &os, string &s) {for (char &c : s) os << (char)c; return os;}
template <typename A, typename B> ostream &operator<<(ostream &os, pair<A, B> &pr) {os << '(' << pr.first << ", " << pr.second << ')'; return os;}
ostream &operator<<(ostream &os, vb &v) {
    bool first = true;
    os << '[';
    for (const bool &x : v) {
        if (!first) os << ", ";
        first = false;
        os << x;
    }
    os << ']';
    return os;
}
template <class C> ostream &operator<<(ostream &os, C &v) {
    bool first = true;
    os << '[';
    for (auto &x : v) {
        if (!first) os << ", ";
        first = false;
        os << x;
    }
    os << ']';
    return os;
}
string bin_string(int x) {
    const int d = 32;
    string res(d, ' ');
    FOR(i, 0, d) res[d-1-i] = '0'+(x>>i & 1LL);
    return res;
}
int powa(int base, int exp) {
    int res = 1;
    while (exp) {
        if (exp&1) res = res*base % MOD;
        base = base*base % MOD;
        exp >>= 1;
    }
    return res;
}

main() {
    ios::sync_with_stdio(0), cin.tie(0);
    
    map<string, int> trans;
    string s, t, u;
    int a, b;
    cin >> s >> t >> a >> b >> u;
    trans[s] = a;
    trans[t] = b;
    --trans[u];
    cout << trans[s] << ' ' << trans[t];
}

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

class Dice{
public:
	int d[6];
	void MoveN();
	void MoveS();
	void MoveE();
	void MoveW();
};

void Dice::MoveN(){
	swap(d[0],d[1]);
	swap(d[1],d[4]);
	swap(d[1],d[5]);
}
void Dice::MoveS(){
	swap(d[0],d[1]);
	swap(d[0],d[4]);
	swap(d[4],d[5]);
}
void Dice::MoveE(){
	swap(d[0],d[3]);
	swap(d[2],d[3]);
	swap(d[3],d[5]);
}
void Dice::MoveW(){
	swap(d[0],d[2]);
	swap(d[2],d[3]);
	swap(d[2],d[5]);
}

int main(){
	Dice dc;
	string m;
	for(int i=0;i<6;i++) cin>>dc.d[i];
	cin>>m;
	for(int i=0;i<m.size();i++){
		switch(m[i]){
			case 'N':
				dc.MoveN();
				break;
			case 'S':
				dc.MoveS();
				break;
			case 'E':
				dc.MoveE();
				break;
			case 'W':
				dc.MoveW();
		}
	}
	cout<<dc.d[0]<<endl;
	return 0;
}


Measured memory_bytes: 3140
import sys
while True:
    (n, x) = [int(i) for i in sys.stdin.readline().split()]
    if n == x == 0:
        break
    count = 0
    for i in range(1, n + 1):
        if i >= x: break
        for j in range(i + 1, n + 1):
            if i + j >= x: break
            for k in range(j + 1, n + 1):
                if i + j + k == x: count += 1
                elif i + j + k > x: break
    print(count)

Measured memory_bytes: 6728
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

string S;

int main() {

	cin >> S;

	bool f = true;

	rep(i, S.size()) {
		if (S[i] != S[S.size() - 1 - i]) f = false;
	}

	rep(i, S.size() / 2) {
		if (S[i] != S[S.size() / 2 - 1 - i]) f = false;
	}

	if (f) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


Measured memory_bytes: 256
#define KAKUSUKO
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <cstring>
#include <utility>
#include <vector>
#include <complex>
#include <valarray>
#include <fstream>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <numeric>
#include <climits>
#include <random>

#define _overload(a, b, c, d, ...) d
#define _rep1(X, A, Y) for (int (X) = (A);(X) <= (Y);++(X))
#define _rep2(X, Y) for (int (X) = 0;(X) < (Y);++(X))
#define rep(...) _overload(__VA_ARGS__, _rep1, _rep2)(__VA_ARGS__)
#define rrep(X,Y) for (int (X) = Y-1;(X) >= 0;--(X))
#define all(X) (X).begin(),(X).end()
#define len(X) ((int)(X).size())
#define mod(n, m) (((n)%(m)+(m))%(m))
#define fi first
#define sc second
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
const int INFINT = 1 << 30;                          // 1.07x10^ 9
const ll INFLL = 1LL << 60;                          // 1.15x10^18
const double EPS = 1e-10;
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int N;

int main() {
    cin >> N;

    cout << (N-1)/2 << endl;


    return 0;
}



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

using namespace std;
typedef long long ll;

int main()
{
    ll n, a, b, c;
    cin >> n;
    cin >> a >> b >> c;
    vector<char> move;
    map<char, ll> data;
    data['A'] = a;
    data['B'] = b;
    data['C'] = c;
    string choices[n];
    for(int i = 0;i < n;i++){
        cin >> choices[i];
    }
    if(a == 0 && b == 0 && c == 0){
        cout << "No" << endl;
        return 0;
    }

    for(int i = 0;i < n - 1;i++){
        char ch_1 = choices[i][0];
        char ch_2 = choices[i][1];
        if(data[ch_1] == 0){
            data[ch_1] += 1;
            move.push_back(ch_1);
            data[ch_2] -= 1;
        }
        else if(data[ch_2] == 0){
            data[ch_2] += 1;
            move.push_back(ch_2);
            data[ch_1] -= 1;
        }
        else{
            if(ch_1 == choices[i+1][0] || ch_1 == choices[i+1][1]){
                data[ch_1] += 1;
                data[ch_2] -= 1;
                move.push_back(ch_1);
            }
            else{
                data[ch_1] -= 1;
                data[ch_2] += 1;
                move.push_back(ch_2);
            }
        }
        if(data['A'] < 0 || data['B'] < 0 || data['C'] < 0){
            cout<<"No"<<endl;
            return 0;
        }
    }
    char ch_1 = choices[n-1][0];
    char ch_2 = choices[n-1][1];
    if(data[ch_1] == 0){
        data[ch_1] += 1;
        move.push_back(ch_1);
        data[ch_2] -= 1;
    }
    else{
        data[ch_2] += 1;
        move.push_back(ch_2);
        data[ch_1] -= 1;
    }
    if(data['A'] < 0 || data['B'] < 0 || data['C'] < 0){
        cout<< "No" << endl;
        return 0;
    }
    cout<< "Yes" << endl;
    for(auto x: move){
        cout << x << endl;
    }
    return 0;
}

Measured memory_bytes: 6904
#include <iostream>
#include <stdio.h>
#include <cmath>

using namespace std;

int main() {
    double r, a, l;
    cin >> r;
    a = r * r * M_PI;
    l = 2 * r * M_PI;
    printf("%.6f %.6f\n", a, l);
    return 0;
}

Measured memory_bytes: 1240
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let a: usize = iterator.next().unwrap().parse().unwrap();
    let b: usize = iterator.next().unwrap().parse().unwrap();

    let ans = (a + b) % 24;
    return ans.to_string();
}


Measured memory_bytes: 2152
//https://onlinejudge.u-aizu.ac.jp/courses/lesson/1/ALDS1/1/ALDS1_1_A
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <map> // sort

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

int insertionSort(vector<int>& A,int n)
{
    for(int i = 1; i < n; ++i)
    {
        for(int k = 0; k < n; ++k)
        {
            cout << A.at(k);
            if(k != n-1)
            {
                cout << " ";
            }
        }

        cout << endl;
        int v = A.at(i);
        int j = i - 1;
        while(j >= 0 && A.at(j) > v)
        {
            A.at(j+1) = A.at(j);
            --j;
        }
        A.at(j+1) = v;
    }
    for(int k = 0; k < n; ++k)
    {
        cout << A.at(k);
        if(k != n-1)
        {
            cout << " ";
        }
    }
    cout << endl;

    return 0;
}


int main(){
    int n;
    cin >> n;
    vector <int> a(n);
    REP(i,n)
    {
        cin >> a.at(i);
    }

    insertionSort(a,n);

    return 0;    
}



Measured memory_bytes: 3104
#include "bits/stdc++.h"
using namespace std;
const int maxn=1e5+100;
struct node{
	int x,y;
}p[maxn];
int n;
long long num;
bool cmp(node a,node b){
	return a.y>b.y;
}
int main()
{
	cin>>n>>num;
	int ans=0,pos;
	for(int i=1;i<=n;i++){
		scanf("%d%d",&p[i].x,&p[i].y);
		if(p[i].x>ans){
			ans=p[i].x;
			pos=i;
		}
	}
	int pos1;
	sort(p+1,p+1+n,cmp);
	for(int i=1;i<=n;i++){
		if(p[i].y<ans){
			pos1=i; break;
		}
		num-=p[i].y;
		if(num<=0){
			cout<<i<<endl; return 0;
		}
	}
	int tt=num/ans;
	tt+=(pos1-1);
	if(num%ans==0) cout<<tt<<endl;
	else cout<<tt+1<<endl; 
}

Measured memory_bytes: 1024
if __name__ == "__main__":
    x = int(input())

    if x>=400 and x<= 599:
        print("8")
    elif x>=600 and x<=799:
        print("7")
    elif x>=800 and x<=999:
        print("6")
    elif x>=1000 and x<=1199:
        print("5")
    elif x>=1200 and x<=1399:
        print("4")
    elif x>=1400 and x<=1599:
        print("3")
    elif x>=1600 and x<=1799:
        print("2")
    elif x>=1600 and x<=1999:
        print("1")

Measured memory_bytes: 9196
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}




int main(){
    
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    string S;
    cin >> S;
    //int ti = clock();
    
   
    //vvi dp(200001,vi(2020,0));
    vi A(2020,0),B(2020,0);
    
    
    int ans = 0;
    int N = int(S.length());
    rep(i,N){
        int a = int(S[i]-'0');
        //dp[i+1][a]++;
        A[a]++;
        rep(j,2019){
            //if(dp[i][j] == 0) continue;
            //dp[i+1][(j*10+a)%2019] += dp[i][j];
            //if((j*10+a)%2019 == 0) ans += dp[i][j];
            if(B[j] == 0) continue;
            A[(j*10+a)%2019] += B[j];
            if((j*10+a)%2019 == 0) ans += B[j];
            
        }
        
        
        B = A;
        A = vi(2020,0);
    }

    cout << ans << endl;
    
    
    
    //printf("Execution Time: %.4lf sec\n", 1.0 * (clock() - ti) / CLOCKS_PER_SEC);
       
    
    

    return 0;
}


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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << std::fixed << std::setprecision(10);

    int n; string s; cin >> n >> s;
    int ans = 0;
    REP(i, 1000) {
        int a = 0;
        REP(j, s.size()) {
            if(s[j] - '0' == (i / (int)pow(10, 2 - a) % 10) ) a++;
            if(a == 3) break;
        }
        if(a == 3) ans++;
    }
    cout<< ans << endl;

    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;

int gcd(int a, int b){
  if (a%b == 0){
    return(b);
  }else{
    return(gcd(b, a%b));
  }
}
int lcm(int a, int b){
  return a * b / gcd(a, b);
}


int main()
{
  ll N,K;
  cin >> N >> K;
  vector<int> A(N);
  REP(i, N) cin >> A[i];
  
  sort(ALL(A));

  ll GCD;
  if(N>=2){
    GCD=gcd(A[0],A[1]);
    FOR(i,2,N){
      GCD=gcd(GCD,A[i]);
    }
  }else{
    GCD=A[0];
  }

  if(K%GCD==0&&A[N-1]>=K){
    cout << "POSSIBLE" << endl;
  }else{
    cout << "IMPOSSIBLE" << endl;
  }
}

Measured memory_bytes: 640
// {{{
#include <iostream>
#include <iomanip>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <complex>
#include <vector>
#include <list>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <string>
#include <algorithm>
#include <numeric>
using namespace std;

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define FOR(i, a, b) for(ll i = static_cast<ll>(a); i < static_cast<ll>(b); i++)
#define FORR(i, a, b) for(ll i = static_cast<ll>(a); i >= static_cast<ll>(b); i--)
#define REP(i, n) for(ll i = 0ll; i < static_cast<ll>(n); i++)
#define REPR(i, n) for(ll i = static_cast<ll>(n); i >= 0ll; i--)
#define ALL(x) (x).begin(), (x).end()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> IP;
typedef pair<ll, LP> LLP;

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

constexpr int INF = 100000000;
constexpr ll LINF = 10000000000000000ll;
constexpr int MOD = static_cast<int>(1e9 + 7);
constexpr double EPS = 1e-9;

static inline ll mod(ll x, ll m)
{
    ll y = x % m;
    return (y >= 0 ? y : y+m);
}

// }}}

struct key {
    int a, b;
    unsigned int c;
};

int N, M;
key k[1000];
ll dp[12][1<<12];

ll rec(int i, int *h, int m)
{
    if(i >= N) return m;
    ll b = 0;
    REP(j, N){
        if(h[j] > 0) b |= (1<<j);
    }
    if(dp[i][b] != 0) return dp[i][b];
    if(h[i] > 0) return rec(i+1, h, m);
    ll ans = LINF;
    REP(j, M){
        if(k[j].c & (1 << i)){
            REP(l, N){
                if(k[j].c & (1 << l)) h[l]++;
            }
            ans = min(ans, rec(i+1, h, m) + k[j].a);
            REP(l, N){
                if(k[j].c & (1 << l)) h[l]--;
            }
        }
    }
    return dp[i][b] = ans;
}


void solve()
{
    int ans = 0;
    int h[12] = {0};
    cout << rec(0, h, 0) << endl;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> M;
    int ac = 0;
    REP(i, M){
        cin >> k[i].a >> k[i].b;
        REP(j, k[i].b){
            int n;
            cin >> n;
            n--;
            k[i].c |= (1<<n);
            ac |= (1<<n);
        }
    }
    bool ok = true;
    REP(i, N){
        if((ac & (1<<i)) == 0){
            ok = false;
            break;
        }
    }
    if(ok) solve();
    else cout << -1 << endl;
    return 0;
}

// vim:set foldmethod=marker:


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

using ll = long long;
using vi = vector<ll>;
using vii = vector<vi>;
using pii = pair<ll, ll>;

template <typename T1, typename T2>
ostream& operator<<(ostream& os, const pair<T1, T2>& p) {
  os << '(' << p.first << ", " << p.second << ')';
  return os;
}
int main() {
  ll n;
  cin >> n;
  vi a(n);
  vi b(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i] >> b[i];
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());
  if (n % 2) {
    cout << b[n / 2] - a[n / 2] + 1 << endl;
  } else {
    cout << ((b[n / 2] + b[n / 2 - 1]) - (a[n / 2] + a[n / 2 - 1])) + 1
         << endl;
  }

  return 0;
}


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

#define INF 1 << 29
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)

using namespace std;

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

void gen_sosuu(int sosuu[]){
  REP(i,100010){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(100000)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<=100000;j++){
      //printf("%d %d %d\n",i*j,i,j);
      sosuu[i*j] =false;
    }
  }
}

int n,m;
ll fact[100010];
int mod = 1000000000+7;

int main(){
  scanf("%d %d",&n,&m);
  fact[0] = 1;
  for(int i = 1;i<=max(n,m);i++){
    fact[i] = fact[i-1]*i%mod;
  }
  if(abs(n-m)>=2){
    printf("0\n");
    return 0;
  }
  if(abs(n-m)==1){
    printf("%d\n",fact[m]*fact[n]%mod);
    return 0;
  }
  printf("%d\n", fact[m]*fact[n]*2%mod);
}


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

#define int long long
#define pb emplace_back
#define mp make_pair
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define F first
#define S second
#define fast ios:: sync_with_stdio(false),cin.tie(0);

int32_t main(){
	fast;
	string s;
	cin >> s;
	
	string ans ;
	for(auto x : s)
	{
		if(x == 'B' && ans.length())    ans.erase(ans.begin() + ans.length() - 1);
		else if(x != 'B')    ans += x;
		
	}
	cout << ans;
}







Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(10);
    ll Q,H,S,D;
    cin >> Q >> H >> S >> D;
    vector<ll> two = {Q*8,H*4,S*2,D};
    vector<ll> one = {Q*4,H*2,S};
    sort(ALL(two));
    sort(ALL(one));
    ll N;
    cin >> N;
    cout << (N/2)*two[0] + (N%2)*one[0] << "\n";
}

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

n,m,s,t = map(int,input().split())


links_e = [[] for _ in range(n+1)]
links_s = [[] for _ in range(n+1)]
for _ in range(m):
    u,v,a,b = map(int, input().split())
    links_e[u].append((a,v))
    links_e[v].append((a,u))
    links_s[u].append((b,v))
    links_s[v].append((b,u))

# dijkstra
import heapq
def dijkstra(links, start, n):
    inf = 10**10
    d = [inf] * (n+1)
    d[start] = 0
    hq = []
    used = set()
    used.add(start)
    for i in links[start]:
        heapq.heappush(hq, i)
    while(hq):
        cost,i = heapq.heappop(hq)
        if( i in used):
            continue
        d[i] = cost
        used.add(i)
        for tmp in links[i]:
            cost_next, j = tmp
            if(not j in used):
                heapq.heappush(hq, (cost+cost_next, j))
    return d

d_e = dijkstra(links_e, s, n)
d_s = dijkstra(links_s, t, n)

ans = [0] * (n+1)
min_cost = 10**15
for i in range(n,0,-1):
    min_cost = min(min_cost, d_e[i]+d_s[i])
    ans[i] = min_cost

for i in range(1,n+1):
    print(10**15 - ans[i])

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


int main(){
    while(true){
        int a, b;
        char op;
        cin >> a >> op >> b;
        switch(op){
            case '+':
            cout << a + b << endl;
            break;
            case '-':
            cout << a - b << endl;
            break;
            case '*':
            cout << a * b << endl;
            break;
            case '/':
            cout << a / b << endl;
            break;
            case '?':
            return 0;
            break;
        }
    }
    return 0;
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define LI list<int>
#define vct vector
#define D(a) (double)(a)
#define vi vct<int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vvi vct<vi>
#define vll vct<ll>
#define vvll vct<vll>
#define vpii vct<pii>
#define vpll vct<pll>
#define vb vct<bool>
#define vs vector<string>
#define all(a) a.begin(),a.end()
#define allr(a) a.rbegin(),a.rend()
#define mp(a,b) make_pair(a,b)
#define pb push_back
#define ff first
#define ss second
#define bg begin()
#define UNIQUE(X) (X).erase(unique(all(X)),(X).end())
#define ft cout<<"for test"<<endl;
#define read(v,a,n) for(int i=a; i<n; i++)cin>>v[i];
#define print(v) for(auto it:v)cout<<it<<' '; cout<<endl;
#define PI 2*acos(0.0)
#define yes cout<<"Yes"<<endl
#define no cout<<"No"<<endl
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define t_c int test,cs=1;cin>>test;while(test--)
#define rt return true
#define rf return false

///................function.....................///
#define siz(s) (int)(s.size())
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define dbg(a) cout << #a << " = " << a << " ";
///...........knight moves.....................///
///int dx[] = {+1,+1,-1,-1,+2,+2,-2,-2};
///int dy[] = {+2,-2,+2,-2,+1,-1,+1,-1};
const int N=1000005;
vb isprime(N);
vi primes;
void sieve()
{
    ll i,j;
    primes.pb(2);
    for(i=4; i<N; i+=2)isprime[i]=true;
    for(i=3; i<N; i+=2)
    {
        if(!isprime[i])
        {
            primes.pb(i);
            if(i*i<=N)
                for(j=i*i; j<N; j+=i*2)isprime[j]=true;
        }
    }
}
int main()
{
    FIO;
    sieve();
    vi cnt(N);
    int n,i,j;
    cin>>n;
    vi v(n);
    vvi div(N);
    for(i=0; i<n; i++)
    {
        cin>>v[i];
        j=v[i];
        int pt=0;
        while(isprime[j]&&pt<siz(primes))
        {
            if(j%primes[pt]==0)
            {
                cnt[primes[pt]]++;
                div[i].pb(primes[pt]);
                while(j%primes[pt]==0)
                    j/=primes[pt];
            }
            pt++;
        }
        if(j>1)
        {
            div[i].pb(j);
            cnt[j]++;
        }
    }
    int onee=0,nnn=0;
    for(i=0; i<n; i++)
    {
        int one=0,tot=0;
        int nn=1;
        for(auto it:div[i])
        {
            if(cnt[it]==1)one++;
            tot++;
            if(cnt[it]==n)nn=0;
        }
        if(nn)nnn++;
        if(one==tot)onee++;
    }
    if(onee==n)
        cout<<"pairwise coprime"<<endl;
    else if(nnn)
        cout<<"setwise coprime"<<endl;
    else
        cout<<"not coprime"<<endl;
}


Measured memory_bytes: 80080
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2582&lang=jp>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

int solve(int n){
    int res = 0;
    vector<string> f(n); for(auto& in:f) cin >> in;
    bool target = true;
    bool l = false,r = false;
    for(int i = 0; i < n;i++){
        if(f[i] == "lu"){
            l = true;
        }
        if(f[i] == "ru"){
            r = true;
        }
        if(f[i] == "ld"){
            l = false;
        }
        if(f[i] == "rd"){
            r = false;
        }
        if(target == l && target == r){
            target = !target;
            res++;
        }
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int n;
    while(cin >> n,n){
        cout << solve(n) << endl;
    }
    return 0;
}



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

int main()
{
    ll a;
    double b;
    cin >> a >> b;
    ll ib = b*100+0.5;
    a *= ib;
    a /= 100;
    printf("%lld\n", a);
    return 0;
}

Measured memory_bytes: 3792
def main():
    import sys
    input = sys.stdin.readline
    N = int(input())
    L = sorted([int(x) for x in input().strip().split()])
    ans = 0
    for i in range(N-2):
        for j in range(i+1, N-1):
            if L[i] == L[j]:
                continue
            for k in range(j+1, N):
                if L[k] != L[i] and L[k] != L[j] and L[i] + L[j] > L[k]:
                    ans += 1

    print(ans)

if __name__ == '__main__':
    main()

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


int main(){
  int N;
  cin >> N;
  int ans=0;
  for(int i=1;i<=N;i++){
    string s=to_string(i);
    if(s.size()%2==1){
      ans++;
    }
  }
  cout << ans << endl;
    
  
}
      


Measured memory_bytes: 764
#include <bits/stdc++.h>
#define ps push_back
#define LL long long
using namespace std;
const LL  maxn=5e5+5;
const int mod=1e9+7;
LL a[maxn+5];
long long pw(int a,int b)
{
    long long sum=1,base=a;
    while(b)
    {
        if(b&1)sum=(sum*base)%mod;
        base=(base*base)%mod;
        b>>=1;
    }
    return sum;
}


void init()
{
    LL i, j;
    a[0]=1;
    for(i=1; i<=maxn-3; i++)
    {
        a[i]=(a[i-1]*i)%mod;

    }

}
long long C(int n, int m)
{
    long long sum=a[n];
    sum=sum*pw(a[n-m],mod-2)%mod;
    sum=sum*pw(a[m],mod-2)%mod;
    return sum%mod;
}
LL n, m;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t;
    init();
//    cout<<C(4, 2)<<endl;
    cin>>n>>m;
    LL ans=((((C(m,n)%mod)*a[n])%mod)*(((C(m,n)%mod)*a[n])%mod)%mod)%mod;
//    cout<<ans<<endl;
//    cout<<(C(m,n)*a[n])%mod)
//    cout<<((((((C(m,n)%mod)*a[n])%mod)*((C(m,n)%mod)*a[n]%mod))%mod-(C(m,n)*a[n])%mod)%mod+mod)%mod<<endl;
    LL sign=-1;
    for(LL i=1; i<=n; i++)
    {
        LL item=((((((C(n,i)*C(m,i))%mod)*a[i])%mod)*((C(m-i, n-i)*a[n-i])%mod))%mod*((C(m-i, n-i)*a[n-i])%mod))%mod;
        ans=((ans+sign*item)%mod+mod)%mod;
//        cout<<ans<<endl;
        sign*=-1;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 7432
using System;
using System.Linq;
using System.Collections.Generic;
using System.Text;
using static System.Console;
using static System.Math;

class Program
{
    static void Main(string[] args)
    {
        int n = ReadLineParseInt();
        int[] d = ReadLineParseIntArray();
        Array.Sort(d);
        WriteLine(d[n / 2] - d[n / 2 - 1]);
    }

    static int ReadLineParseInt() => int.Parse(ReadLine());
    static int[] ReadLineParseIntArray() => ReadLine().Split(' ').Select(int.Parse).ToArray();
}

Measured memory_bytes: 18016
#include <iostream>
#include <fstream>
#include <vector>
#include <utility>
#include <map>
#include <set>
#include <list>
#include <deque>
#include <queue>
#include <stack>
#include <forward_list>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <string>
#include <bitset>
#include <memory>
#include <chrono>
#include <cmath>
#include <cstdio>
#include <ctime>
#include <cstring>
#include <cstdlib>
#include <cstdint>
#include <iomanip>
#include <tuple>
#include <random>

using namespace std;

typedef unsigned long long int ull;

ull inv_fac[300001], fac[300001], cmb_dp[300001];
ull mod = 998244353;

pair<ull,ull> f(pair<ull,ull> a) {
    bool sw = true;
    if(a.first == 0 || a.second == 0)
        return make_pair(1,1);
    if(a.first < a.second) {
        sw = !sw;
        ull s = a.second;
        a.second = a.first;
        a.first = s;
    }
    pair<ull,ull> c;
    c.first = a.second;
    c.second = a.first % a.second;
    pair<ull,ull> ret = f(c);
    ret.first -= ret.second * (ull)(a.first / a.second);
    if(sw) {
        ull s = ret.second;
        ret.second = ret.first;
        ret.first = s;
    }
    return ret;
}

int main(void) {
    ull N,A,B,K,retval = 0;
    cin >> N >> A >> B >> K;
    fac[0] = 1;
    inv_fac[0] = 1;
    for(int i = 1;i <= 300000;i++) {
        fac[i] = (i * fac[i-1]) % mod;
        auto r = f(make_pair(fac[i],mod));
        inv_fac[i] = (r.first + mod) % mod;
    }
    for(int i = 0; i <= N;i++) {
        cmb_dp[i] = (fac[N] * inv_fac[i] % mod) * inv_fac[N-i] % mod;
    }
    for(int i = 0;i <= N;i++) {
        if((K - (A*i)) % B == 0 && (K - (A*i)) / B <= N && K >= A*i) {
            retval += (cmb_dp[i] * cmb_dp[(K - (A*i)) / B]) % mod;
        }
    }
    retval = retval % mod;
    cout << retval << endl;
}


Measured memory_bytes: 7296