akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
typedef pair<int, P> E;
#define MOD (1000000007ll)
#define l_ength size

void mul_mod(ll& a, ll b){
	a *= b;
	a %= MOD;
}

void add_mod(ll& a, ll b){
	b += MOD;
	a += b;
	a %= MOD;
}

int main(void){
	ll n,m,i,ans=1ll;
	cin >> n >> m;
	if(abs(n-m)>1){
		ans = 0ll;
	}else if(n == m){
		for(i=1ll; i<=n; ++i){
			mul_mod(ans,i);
		}
		mul_mod(ans,ans);
		mul_mod(ans,2ll);
	}else{
		for(i=min(n,m); i>=1ll; --i){
			mul_mod(ans,i);
		}
		mul_mod(ans,ans);
		mul_mod(ans,max(n,m));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <queue>
using namespace std;
typedef long long ll;

int main() {
    int x, a, b, n;
    cin >> x >> a >> b;
    cin >> n;
    for (int i = 0; i < n; i++) {
        string s;
        cin >> s;
        if (s == "nobiro") x += a;
        else if (s == "tidime") x += b;
        else x = 0;
        if (x < 0) x = 0;
    }
    cout << x << endl;
}


Measured memory_bytes: 3204
#include<bits/stdc++.h>
using namespace std;
int m,n;
int main()
{
    cin>>m>>n;
    for(int i=0;i<=m;i++)
     for(int j=0;j<=m;j++)
      for(int k=0;k<=m,i+j+k<=m;k++)
       {
            if(i+j+k==m && i*1000+j*5000+k*10000==n)
            {
                printf("%d %d %d",k,j,i);
                return 0;   
            }
       }
    printf("-1 -1 -1");
    return 0;
}

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int N;
    cin >> N;
    int mx = 0, sum = 0;
    for (int i = 0; i < N; i++)
    {
        int L;
        cin >> L;
        sum += L;
        if (L > mx) mx = L;
    }
    if (2 * mx < sum) cout << "Yes\n";
    else cout << "No\n";
    return(0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n, m;
pair<int, int> c[100001];
vector<int> v[100001];
map<pair<int, int>, string> mp;
string go(int i) {
        int c  = 0;
        string s = "", s1 = to_string(i);
        while (i) { c++; i /= 10; }
        while (c < 6) { s += "0"; c++; }
        s += s1;
        return s;
}
int main() {
        cin >> n>> m;
        for (int i = 0; i < m; i++) {
                int a, b;
                cin >> a>> b;
                c[i] = {a, b};
                v[a].push_back(b);
        }
        for (int i = 1; i <= n; i++)
                sort(v[i].begin(), v[i].end());
        for (int i = 1; i <= n; i++) {
                if (v[i].size()) {
                        for (int j = 0; j < (int)v[i].size(); j++) {
                                string str = go(i);
                                str += go(j+1);
                                mp[{i, v[i][j]}] = str;
                        }
                }
        }
        for (int i =0; i < m; i++) {
                cout << mp[make_pair(c[i].first, c[i].second)]<< endl;
        }
        return 0;
}


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

const long long inf=1ll<<50;
int main(){
    int n,m;
    scanf("%d %d",&n,&m);
    const int nmax=1000;
    const int mmax=2000;
    int a[mmax],b[mmax];
    long long c[mmax];

    for (int i=0;i<m;++i) {
        scanf("%d %d %lld",&a[i],&b[i],&c[i]);
        c[i]=-c[i];
    }

    long long dist[nmax];

    for (int i=0;i<n;++i) dist[i]=inf;
    dist[0]=0;

    for (int loop=0;loop<n-1;++loop) {
        for (int i=0;i<m;++i) {
            if (dist[a[i]-1]==inf) continue;

            if (dist[b[i]-1]>dist[a[i]-1]+c[i]) {
                dist[b[i]-1]=dist[a[i]-1]+c[i];
            }
        }
    }
    long long ans=dist[n-1];

    bool nega[nmax];
    for (int i=0;i<n;++i) nega[i]=false;

    for (int loop=0;loop<n;++loop) {
        for (int i=0;i<m;++i) {
            if (dist[a[i]-1]==inf) continue;

            if (dist[b[i]-1]>dist[a[i]-1]+c[i]) {
                dist[b[i]-1]=dist[a[i]-1]+c[i];
                nega[b[i]-1]=true;
            }
            if (nega[a[i]-1]==true) {
                nega[b[i]-1]=true;
            }
        }
    }

    if (nega[n-1]) printf("inf\n");
    else printf("%lld\n",-ans);

    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

int N, M;	
int a, b, c;
int i;
int sum, max;

int main()
{	
	scanf("%d %d", &N, &M);

	for (i = 0; i < M; i++) {
		scanf("%d %d", &a, &b);
		c = N - a;
		if (c>0) {
			sum += c;
		}
		if(c>=max){
			max = c;
		}
	}
	printf("%d\n", sum - max);

	return 0;
}

Measured memory_bytes: 1804
n=int(input())
List=list(input() for i in range(n))
for i in range(n-1):
      if List[i][-1]!=List[i+1][0]:
            x=1
            break
      else:
            x=0



print('Yes' if x==0 and len(list(set(List)))==len(List) else 'No')


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

int gcount = 0;
int pcount, qcount;
void search(vector<int>& memo, vector<bool>& usedlist, vector<int>& p, vector<int>& q, int n, int level){
    if(n == level){
        bool ispmatch = true;
        for(int i = 0; i < n; i++){
            if(memo[i] != p[i]) ispmatch = false;
        }
        if(ispmatch) pcount = gcount;
        bool isqmatch = true;
        for(int i = 0; i < n; i++){
            if(memo[i] != q[i]) isqmatch = false;
        }
        if(isqmatch) qcount = gcount;
        gcount++;
    }else{
        for(int i = 0; i < n; i++){
            if(!usedlist[i]){
                memo[level] = i+1;
                usedlist[i] = true;
                search(memo, usedlist, p, q, n, level+1);
                usedlist[i] = false;
            }
        }
    }
    return;
}
int main(){
    int n;
    cin >> n;
    vector<int> p(n), q(n);
    for(int i = 0; i < n; i++) cin >> p[i];
    for(int i = 0; i < n; i++) cin >> q[i];
    vector<int> memo(n);
    vector<bool> usedlist(n, false);
    search(memo, usedlist, p, q, n, 0);
    cout << max(pcount-qcount, qcount-pcount) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>


int top,S[10000];
void push(int x){
    //topを加算してからその位置に挿入
    S[++top] = x;
}

int pop(){
    top--;

    return S[top + 1];  //topが差していた中身を返す 
}

int main()
{
    int a,b;
    top = 0;
    char s[100];


    while(scanf("%s",s) != EOF)
    {
        if( s[0] == '+')
        {
            a = pop();
            b = pop();
            push(a + b);

        }

        else if (s[0] == '-')
        {
            b = pop();
            a = pop();
            push(a - b);

        }

        else if(s[0] == '*')
        {
            a = pop();
            b = pop();
            push(a * b);

        }
        else
        {
        
            push(atoi(s));

        }

    }   

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

    return 0;
}






Measured memory_bytes: 2120
#include<cstdio>
#include<algorithm>
#include<functional>
#include<cmath>
using namespace std;
int main(void)
{
	int n,i,x[100],y[100];
	double p1,p2,p3,pp,w;
	scanf("%d",&n);
	for(i=0;i<n;i++)	scanf("%d",&x[i]);
	for(i=0;i<n;i++)	scanf("%d",&y[i]);
	p1=0.0;
	for(i=0;i<n;i++)	{
		w=x[i]-y[i];
		if(w<0)	w=-w;
		p1+=w;
	}
	p2=0.0;
	for(i=0;i<n;i++)	{
		p2+=(x[i]-y[i])*(x[i]-y[i]);
	}
	p2=sqrt(p2);
	p3=0.0;
	for(i=0;i<n;i++)	{
		w=(x[i]-y[i])*(x[i]-y[i])*(x[i]-y[i]);
		if(w<0)	w=-w;
		p3+=w;
	}
	p3=pow(p3,1.0/3.0);
	pp=-1.0;
	for(i=0;i<n;i++)	{
		w=x[i]-y[i];
		if(w<0)	w=-w;
		pp=max(pp,w);
	}
	printf("%lf\n%lf\n%lf\n%lf\n",p1,p2,p3,pp);
	return 0;
}


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

int N,K;

bool G[300][300];


void solve(){
  cout<<1<<endl;
  string str;
  cin>>str;
  if(str=="Yes")return;

  vector<int> tmp;
  int last = -1;
  int pos=1;
  while(pos*2<=N){
    
    cout<<pos*2<<endl;
    
    string str;
    cin>>str;
    if(str=="Yes")return;
    
    if(str=="Near"){
      pos=pos*2;
    }else{

      last=pos;
      
      tmp.push_back(pos*2+1);
      pos=pos*2+1;
    }
  }

  cout<<pos<<endl;
  cin>>str;
  if(str=="Yes")return;

  cout<<last*2+1<<endl;
  cin>>str;
   
}
void dfs(int pos,int root){
  if( pos > N )return;
  G[root][pos]=G[pos][root]=true;
  dfs( pos*2 , root );
  dfs( pos*2+1 , root );
}

int main(){
  cin>>N>>K;
  for(int i=1;i<=N;i++)dfs(i,i);
  vector<int> from,to;
  for(int i=1;i<=N;i++){
    for(int j=i+1;j<=N;j++){
      if(G[i][j]){
        from.push_back(i);
        to.push_back(j);
      }
    }
  }
  cout<<from.size()<<endl;
  for(int i=0;i<(int)from.size();i++){
    cout<<from[i]<<' '<<to[i]<<endl;
  }


  while(K--){

    solve();

  }
  return 0;
}



Measured memory_bytes: 3344
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> w(n);
  for(int i=0;i<n;i++)cin>>w[i];
  int sum1,sum2;
  int MIN=1000000;
  if(n==2){
    cout<<abs(w[0]-w[1])<<endl;
    return 0;
  }
  if(n==3){
    cout<<min(abs(w[0]-w[1]-w[2]),abs(w[0]+w[1]-w[2]))<<endl;
              return 0;
              }
  for(int i=1;i<n-1;i++){
    sum1=sum2=0;
    for(int j=0;j<i;j++){
      sum1+=w[j];
    }
    for(int j=i;j<n;j++){
      sum2+=w[j];
    }
    MIN=min(MIN,abs(sum1-sum2));
  }
  cout<<MIN<<endl;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
dp=[[0]*n for i in range(n)]
for i in range(n):
    if n%2==0:
        dp[i][i]=-a[i]
    else:
        dp[i][i]=a[i]
for l in range(1,n):
    if n%2==l%2:
        for right in range(l,n):
            left=right-l
            dp[left][right]=min(dp[left+1][right]-a[left],dp[left][right-1]-a[right])
    else:
        for right in range(l,n):
            left=right-l
            dp[left][right]=max(dp[left+1][right]+a[left],dp[left][right-1]+a[right])
print(dp[0][n-1])

Measured memory_bytes: 113628
#include <iostream>

using namespace std;

int main() {
    int a[3];
    cin >> a[0] >> a[1] >> a[2];

    int i, c5=0, c7=0;
    for(i=0; i<3; i++) {
        if(a[i]==5) c5 += 1;
        else if(a[i]==7) c7 += 1;
    }

    if((c5==2)&&(c7==1)) cout << "YES" << endl;
    else cout << "NO" << endl;


    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LOOP(val, times)   for(val = 0; val < (times); val++)
int main(){
  int a,s;
  cin>>a>>s;
  int y=max(a,s);
  int f=min(a,s);
  int h=max(y-1,f);
  cout<<y+h<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <queue>
#include <numeric>
#include <bitset>
#include <cmath>

using namespace std;
using ll = long long;
// const ll mod =  998244353 ;
const ll mod =  1000000007 ;
const ll inf = 1e18;

#define REP(i, n) for (ll i = 0; i < (n); ++i)
#define REP_FROM(i, j, n) for (ll i = (j); i < (n); ++i)
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())

template<typename T> void print_vec(vector<T> a) {int n = a.size();REP(i, n) {cout >> a[i]; if(i!=n-1) cout << " "; else cout << endl;}}
ll power(ll base, ll exponent){ if(exponent % 2){ return power(base, exponent - 1) * base % mod; }else if(exponent){ ll root_ans = power(base, exponent / 2); return root_ans * root_ans % mod; }else{ return 1; }}
ll inverse(ll x){ return power(x, mod - 2);}
ll gcd(ll a, ll b) {if(a < b) gcd(b, a);ll r;while(r=a%b) {a=b;b=r;}return b;}
template<typename T> ll sum(T begin, T end) {return accumulate(begin, end, 0ll);}
struct combination{ vector<ll> fact, inv; combination(int sz) : fact(sz + 1), inv(sz + 1){ fact[0] = 1; for(int i = 1; i <= sz; i++){ fact[i] = fact[i - 1] * i % mod; } inv[sz] = power(fact[sz], mod - 2); for(int i = sz - 1; i >= 0; i--){ inv[i] = inv[i + 1] * (i + 1) % mod; } } ll C(int p, int q) const{ if(q < 0 || p < q) return 0; return (fact[p] * inv[q] % mod * inv[p - q] % mod); } };

struct Node {
  int a;
  int b;
  Node *child;
  Node(int _a, int _b) : a(_a), b(_b) {
    child = nullptr;
  }
    Node(int _a, int _b, Node *_child) : a(_a), b(_b), child(_child) {
  }
};

bool check(int x, const vector<ll> & a) {
  vector<unordered_set<int>> dp(sz(a) + 1);
  dp[0].insert(0);
  REP(i, sz(a)) {
    for(const int k : dp[i]) {
      dp[i+1].insert(k+a[i]);
      dp[i+1].insert(k-a[i]);
    }
  }
  return dp[sz(a)].count(x) > 0;
}
signed main() {
  ios::sync_with_stdio(false);
  string s;
  int x, y;
  cin >> s >> x >> y;
  vector<ll> a, b;
  int start = 0;
  REP(i, sz(s)) {
    if(s[i] == 'F') start++;
    else break;
  }
  x -= start;
  int cnt = 0;
  int rgt = 1;
  REP_FROM(i, start, sz(s)) {
    if(s[i] == 'F') {
      cnt++;
      continue;
    }
    if(cnt) {
      if(rgt) {
        a.push_back(cnt);
      }
      else {
        b.push_back(cnt);
      }
      cnt = 0;
    }
    rgt ^= 1;
  }
  if(cnt) {
    if(rgt) {
      a.push_back(cnt);
    }
    else {
      b.push_back(cnt);
    }
  }
  if(check(x, a) && check(y, b)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 155008
n, m = map(int, input().split())
dp = [-1] * (n + 1)
a = []
for i in range(m):
    aa = int(input())
    dp[aa] = 0
    a.append(aa)
for i in range(m - 1):
    if a[i] + 1 == a[i + 1]:
        print(0)
        exit()
mod = 10 ** 9 + 7

dp[0] = 1
if 1 in a:
    dp[1] = 0
else:
    dp[1] = 1
for i in range(1, n):
    if dp[i + 1] == 0:
        continue
    else:
        dp[i + 1] = (dp[i] + dp[i - 1]) % mod
print(dp[n])

Measured memory_bytes: 50008
#include "bits/stdc++.h"
using namespace std;
typedef long long li;

const li mod = 1e9 + 7;

int main() {
    li n, m;
    cin >> n >> m;
    vector<li> degs(n);
    vector<vector<li>> nexts(n);
    for (int i = 0; i < m; ++i) {
        li a, b;
        cin >> a >> b;
        a--; b--;
        degs[a]++;
        degs[b]++;
        nexts[a].push_back(b);
        nexts[b].push_back(a);
    }
    for (int i = 0; i < n; ++i) {
        if (degs[i] % 2 != 0) {
            cout << "No" << endl;
            return 0;
        }
    }
    vector<li> crosses;
    for (int i = 0; i < n; ++i) {
        if (degs[i] == 4) {
            crosses.push_back(i);
        } else if (degs[i] >= 6) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    if (crosses.size() >= 3) {
        cout << "Yes" << endl;
        return 0;
    } else if (crosses.size() <= 1) {
        cout << "No" << endl;
        return 0;
    }

    // special case
    li fr = crosses[0];
    li to = crosses[1];

    for (auto &&adj  : nexts[fr]) {
        li pos = adj;
        li prev = fr;

        while (pos != fr && pos != to) {
            for (auto &&nadj : nexts[pos]) {
                if (nadj != prev) {
                    prev = pos;
                    pos = nadj;
                    break;
                }
            }
        }

        if (pos == fr) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 6528
N, Y = map(int, input().split())

flag = False

for z in range(N + 1)[::-1]:
    rem1 = N - z + 1
    for y in range(rem1)[::-1]:
        x = N - z - y
        val = 10000*x + 5000*y + 1000*z
        if val == Y:
            flag = True
            break
    if flag:
        break

if not flag:
    x = -1
    y = -1
    z = -1
    
print(x, y, z)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int cnt[8];
int main()
{
    int n;
    cin >> n;
    int alot = 0;
    for(int i = 1; i <= n; i++)
    {
        int x;
        cin >> x;
        if(x >= 3200) alot++;
        else cnt[x/400]++;
    }
    int c = 0;
    for(int i = 0; i < 8; i++) if(cnt[i] > 0) c++;
    int mn = c + alot;
    int mx;
    if(c == 0) mx = 1;
    else mx = c;
    printf("%d %d\n", mx, mn);
    return 0;
}


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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

const llong inf = 1'000'000'000'000'007ll;
const llong mod = 1e9+7;

int main() {
	llong N, K;
	vector<llong> A, F;

	cin >> N >> K;
	A.resize(N);
	F.resize(N);
	for (auto &a: A)
		cin >> a;
	for (auto &f: F)
		cin >> f;

	sort(ALL(A));
	sort(ALL(F), greater<>());

	llong ng = -1, ok = inf, mid;
	while (ok - ng > 1) {
		mid = (ng + ok) / 2;
		llong check = 0;
		for (int &&i = 0; i < N; ++i) {
			if (A[i] * F[i] <= mid) continue;
			check += A[i] - mid / F[i];
		}

		if (check > K) {
			ng = mid;
		} else {
			ok = mid;
		}
	}

	cout << ok << endl;

	return 0;
}

Measured memory_bytes: 3328
#include <stdio.h>
#include <math.h>
int main()
{
	int x,a,b;
	scanf ("%d %d %d",&x,&a,&b);
	if (pow(x-a,2)>pow(x-b,2))
	{
		printf ("B");
	}
	else printf ("A");
	return 0;
}
	

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()

ll gcd(ll a,ll b){
    if(b>a) swap(a,b);
    if(b==0) return a;
    return gcd(b,a%b);
}
ll lcm(ll a,ll b){
    ll g=gcd(a,b);
    return a/g*b;
}
ll rep_jijo(ll n,ll x){
    if(x==0) return 1;
    if(x%2==0){
        ll t=rep_jijo(n,x/2);
        return t*t;
    }
    return n*rep_jijo(n,x-1);
}

int main(){
    ll n,d;
    ll ans = 0;
    cin >> n >> d;
    rep(i,n){
        ll x,y;
        cin >> x >> y;
        ll dis = x*x+y*y;
        if(dis <= d*d) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   //0-origin昇順
#define rep1(i,n) for(int i = 1; i <= ((int)(n)); i++) //1-origin昇順
#define rrep(i,n) for(int i = ((int)(n)-1); i >= 0; i--)  //0-origin降順
#define rrep1(i,n) for(int i = ((int)(n)); i >= 1; i--)   //1-origin降順
//rep2 -> 第二引数 m から n 回繰り返し ex) m=5 n=3 なら i=5,i=6,i=7 まで
#define rep2(i,m,n) for(int i = ((int)(m)); i < ((int)(n))+((int)(m)); i++)
#define SIZE(x) ((int)((x).size()))
#define all(x) (x).begin(),(x).end()
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<vi> vii; //2次元配列
typedef vector<ll> vll;
typedef vector<string> vs;
template<typename T> bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1;} return 0;}
template<typename T> bool chmin(T &a, const T &b){ if(a>b){ a=b; return 1;} return 0;}


/*FUNCs=================================================*/


/*MAIN==================================================*/
int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);   //cin cout 高速化

    string s; cin >> s;
    int cnt = 0;
    rep(i, s.size()){
        if(i%2==0){
            if(s[i] != s[0]) cnt++;
        }
        else {
            if(s[i] == s[0]) cnt++;
        }     
    }
    cout << cnt << '\n';
}

Measured memory_bytes: 512
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	iv, _ := strconv.Atoi(sc.Text())
	return iv
}

func init() {
	sc.Split(bufio.ScanWords)
}

func main() {
	n := scanInt()
	a := make([]int, n)
	for i := range a {
		a[i] = scanInt()
	}
	sort.Sort(sort.Reverse(sort.IntSlice(a)))

	ans := a[0]
	cnt := 1
	for i := 1; i < len(a); i++ {
		if cnt >= len(a)-1 {
			break
		}
		ans += a[i]
		cnt++
		if cnt >= len(a)-1 {
			break
		}
		ans += a[i]
		cnt++
	}
	fmt.Println(ans)
}


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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << ", " << a.second << ")";return os;}

const char newl = '\n';

int main() {
    int n;
    cin >> n;
    vector<vector<int>> cnt(21,vector<int>(21,0));
    ll ans = 0;
    for (int i = 0;i < n;++i) {
        string s;
        cin >> s;
        int m = s.size(),a = -1;
        ll x = 0;
        for (int j = 0;j < m;++j) if (s[j] == '.') a = j;
        if (a < 0) x = stoi(s)*1000000000LL;
        else {
            x = stoi(s.substr(0,a))*1000000000LL;
            ll y = stoi(s.substr(a+1,m-a-1));
            for (int j = 0;j < 9-(m-a-1);++j) y *= 10;
            x += y;
        }
        int t = -9,f = -9;
        while (x%2 == 0) x /= 2,t++;
        while (x%5 == 0) x /= 5,f++;
        t = min(t,10);
        f = min(f,10);
        for (int j = -t+10;j < 21;++j) for (int k = -f+10;k < 21;++k) ans += cnt[j][k];
        cnt[t+10][f+10]++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
N = input()
K = int(input())
L = len(N)
dp = [[[0]*4 for _ in range(2)] for _ in range(L+1)]
dp[0][0][0] = 1

for i in range(L):
    D = int(N[i])
    
    for j in range(2):
        for d in range(10 if j else D+1):
            for k in range(4):
                if d==0:
                    dp[i+1][j|(d<D)][k] += dp[i][j][k]
                else:
                    if k+1<=3:
                        dp[i+1][j|(d<D)][k+1] += dp[i][j][k]
    
print(dp[L][0][K]+dp[L][1][K])

Measured memory_bytes: 41072
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<math.h>
#include<numeric>
#include<iomanip>

using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;
typedef long long ll;
typedef vector<long long> vll;
typedef pair<long long, long long> pll;

const ll INF = 1e15;
const ll MOD = 1e9 + 7;

int main(){
	int H, W;
	cin >> H >> W;
	int i, j;
	int count = 0;
	for (i = 0; i < H; i++){
		string a;
		cin >> a;
		for (j = 0; j < W; j++){
			if (a[j] == '#'){
				count++;
			}
		}
	}
	if (count == H + W - 1){
		cout << "Possible" << endl;
	}
	else{
		cout << "Impossible" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define loop(n) for(ll i = 0; i<n; i++)
#define sort(a) sort(a.begin(), a.end())
using namespace std;

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

    ll n, W, weight, value, M; cin>>n>>W;
    M = n*1000 + 1;
    vector<ll> dp(M, 1e12);//dp[i] = min weight with value's sum i
    dp[0] = 0;
    loop(n){
        cin>>weight>>value;
        for(ll from = M - value; from>=0; from--){
            dp[from+value] = min(dp[from+value], dp[from]+weight);
        }
    }

    ll ans = 0;
    loop(M){
        if(dp[i]<=W) ans = max(ans, i);
    }
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
const ll INF=1e18L+5;
void min_self(ll& a,ll b){
    a=min(a,b);
}

int main()
{
     int n,w;
     cin>>n>>w;
     vector<ll> values(n),weight(n);
     int total_value=0;
     for(int i=0;i<n;i++){
        cin>>weight[i]>>values[i];
        total_value+=values[i];
     }
     vector<ll> dp(total_value+1,INF);
     dp[0]=0;
     for(int i=0;i<n;i++){
        for(int value_total=total_value-values[i];value_total>=0;value_total--)
            min_self(dp[value_total+values[i]],dp[value_total]+weight[i]);
     }
    ll ans=0;
    for(int i=0;i<=total_value;i++){
           // cout<<dp[i]<<"\n";
        if(dp[i]<=w) ans=i;
    }
    cout<<ans;
}


Measured memory_bytes: 4052
#include<bits/stdc++.h>
using namespace std;
int main(){
		while(true){
			char ch[10000];
			if(cin >> ch){}
			else{
				break;
			}
			int joi=0;
			int ioi=0;
			int m=strlen(ch);
			for(int n=0;n<m-2;++n){
				if(ch[n]=='J'&&ch[n+1]=='O'&&ch[n+2]=='I'){
					joi+=1;
				}
				else if(ch[n]=='I'&&ch[n+1]=='O'&&ch[n+2]=='I'){
					ioi+=1;
				}
			}
			printf("%d\n",joi);
			printf("%d\n",ioi);
	}
}
	


Measured memory_bytes: 3152
#include<iostream>
using namespace std;
int a[21],n,q,b[210];

int solve(int i,int m)
{
	if(m==0)return 1;
	else if(i>=n)return 0;
	int res=solve(i+1,m)||solve(i+1,m-a[i]);
	return res;
}


int main(){
	cin>>n;
	for(int i=0;i<n;cin>>a[i++]);
	cin>>q;
	for(int i=0;i<q;cin>>b[i++]);
	for(int i=0;i<q;i++)
	{
		if(solve(0,b[i])==1)cout<<"yes"<<endl;
		else cout<<"no"<<endl;
	}
	return 0;
}

Measured memory_bytes: 3072
S=input()
A=int(S[0])
B=int(S[1])
C=int(S[2])
D=int(S[3])

if A+B+C+D==7:
    print(S[0]+'+'+S[1]+'+'+S[2]+'+'+S[3]+'='+'7')
elif A+B+C-D==7:
    print(S[0]+'+'+S[1]+'+'+S[2]+'-'+S[3]+'='+'7')    
elif A+B-C+D==7:
    print(S[0]+'+'+S[1]+'-'+S[2]+'+'+S[3]+'='+'7')
elif A+B-C-D==7:
    print(S[0]+'+'+S[1]+'-'+S[2]+'-'+S[3]+'='+'7')
elif A-B+C+D==7:
    print(S[0]+'-'+S[1]+'+'+S[2]+'+'+S[3]+'='+'7')
elif A-B+C-D==7:
    print(S[0]+'-'+S[1]+'+'+S[2]+'-'+S[3]+'='+'7')
elif A-B-C+D==7:
    print(S[0]+'-'+S[1]+'-'+S[2]+'+'+S[3]+'='+'7')
elif A-B-C-D==7:
    print(S[0]+'-'+S[1]+'-'+S[2]+'-'+S[3]+'='+'7')

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

int main(){
    int n, k;
    cin >> n >> k;
    vector<int> x(n), y(n);
    vector<int> xary, yary;
    for(int i = 0; i < n; i++){
        cin >> x[i] >> y[i];
        xary.push_back(x[i]);
        yary.push_back(y[i]);
    }
    sort(xary.begin(), xary.end());
    sort(yary.begin(), yary.end());
    ll ans = 1LL * (xary[n-1] - xary[0]) * (yary[n-1] - yary[0]);
    for(int xi = 0; xi < n; xi++){
        for(int xj = xi+1; xj < n; xj++){
            for(int yi = 0; yi < n; yi++){
                for(int yj = yi+1; yj < n; yj++){
                    int lx = xary[xi];
                    int rx = xary[xj];
                    int ly = yary[yi];
                    int ry = yary[yj];
                    int cnt = 0;
                    for(int i = 0; i < n; i++){
                        if(lx <= x[i] && x[i] <= rx
                            && ly <= y[i] && y[i] <= ry){
                            cnt++;
                        }
                    }
                    if(cnt >= k)
                        ans = min(ans, 1LL * (rx - lx) * (ry - ly));
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3596
def ABC106_B():
    def make_divisors(n):
        divisors = []
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                divisors.append(i)
                if i != n // i:
                    divisors.append(n // i)
        # divisors.sort()
        return divisors
    N = I()
    ans = 0
    for i in range((N+1)//2):
        cur = i*2+1
        if len(make_divisors(cur))==8:
            ans += 1
    print(ans)
    return

def ABC122_B():
    S = SI()
    ans = 0
    cur = 0
    d = {"A","C","G","T"}
    for s in S:
        if s in d:
            cur += 1
        else:
            ans = max(ans,cur)
            cur = 0
    ans = max(ans,cur)
    print(ans)
    return

def paken2019_C():
    N, M = LI()
    A = [LI()for _ in range(N)]
    T = [i for i in range(M)]
    ans = 0
    for t1,t2 in itertools.permutations(T,2):
        cur = 0
        for i in range(N):
            cur += max(A[i][t1],A[i][t2])
        ans = max(ans,cur)
    print(ans)
    return

def ABC95_C():
    A, B, C, X, Y = LI()
    if A+B<=C*2:
        ans = A*X+B*Y
    else:
        if X>Y:
            ans = Y*C*2 + min(A,C*2)*(X-Y)
        else:
            ans = X*C*2 + min(B,C*2)*(Y-X)
    print(ans)
    return

def SMTB_D():
    def flag(n,s):
        for l in range(n,N):
            if S[l]==str(s):
                return l
        return N
    N = I()
    S = SI()
    ans = 0
    for i in range(10):
        L1 = flag(0,i)
        for j in range(10):
            L2 = flag(L1+1,j)
            for k in range(10):
                L3 = flag(L2+1,k)
                if L3<N:
                    ans += 1
                    #print(i,j,k)
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math,random
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

if __name__ == '__main__':
    SMTB_D()

"""

"""

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

int main() {
  int64_t A;
  int64_t B;
  int64_t C;
  int64_t K;
  cin >> A >> B >> C >> K;
  
  if (A > K){
    cout << K << endl;
  }
  else if (A+B > K){
    cout << A << endl;
  }
  else {
    cout << 2*A + B - K << endl;
  }
}



Measured memory_bytes: 3636
N, K = list(map(int, input().split()))

# a number counter that can appear on a number line.
n_counter = [0 for _ in range(10**5 + 1)]
for i in range(N):
  a, b = map(int, input().split())
  n_counter[a] += b

# ask for K.
n_sum = 0
for i, n in enumerate(n_counter):
  n_sum += n
  if n_sum >= K:
    print(i)
    break


Measured memory_bytes: 5896
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using ll = long long;
using P = pair<ll, ll>;
const long double PI = acos(-1.0L);
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

string s, t;

int main() {
    cin >> s >> t;
    int slen = s.length();
    int tlen = t.length();
    int mlen = 0;
    for(int i = 0; i < slen; ++i) {
        int len = 0;
        if(i+tlen-1 < slen) {
            for(int j = 0; j < tlen; ++j) {
                if(t[j] == s[i+j]) len++;
            }
            chmax(mlen, len);
        }
    }

    cout << tlen-mlen << endl;
}

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

ll n;
char M[101010][13]={};
ll dp[101010][1010]={};
ll cnt=LLONG_MAX;
ll B=1000000007;




int main(){
   string s;
   cin>>s;
   
   dp[0][0]=1;
   rep(i,s.size()){
      if(s[i]=='?'){
         rep(j,10){
            rep(k,13){
               int a=(k*10+j)%13;
               
               dp[i+1][a]+=dp[i][k];
               dp[i+1][a]%=B;
            }
         }
      }else{
         s[i]-='0';
         rep(k,13){
               
               int a=(k*10+s[i])%13;
               
               dp[i+1][a]+=dp[i][k];
               dp[i+1][a]%=B;
         }
      }
      
   }
   
   cout<<dp[s.size()][5]<<endl;

}



Measured memory_bytes: 790016
using System;

namespace C_sharp
{
    class Program
    {
        static void Main(string[] args)
        {
            var items = Console.ReadLine().Split(' ');

            var a = int.Parse(items[0]);
            var b = int.Parse(items[1]);
            var c = int.Parse(items[2]);

            var cnt = 0;
            for (var i = a; i <= b; i++)
            {
                if (c % i == 0)
                {
                    cnt++;
                }
            }
            Console.WriteLine(cnt);
        }
    }
}



Measured memory_bytes: 17976
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cfloat>
#include <ctime>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>

using namespace std;

#ifdef _MSC_VER
#define __typeof__ decltype

template <class T>
int __builtin_popcount(T n) { return n ? 1 + __builtin_popcount(n & (n - 1)) : 0; }
#endif

#define foreach(it, c) for (__typeof__((c).begin()) it=(c).begin(); it != (c).end(); ++it)
#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define popcount __builtin_popcount

const double EPS = 1e-10;
typedef long long ll;
typedef pair<int, int> pint;


struct node
{
	int cost, x, y, o, hori;
	node(int cost, int x, int y, int o, int hori)
		: cost(cost), x(x), y(y), o(o), hori(hori) {}
};
bool operator<(const node& a, const node& b)
{
	return a.cost > b.cost;
}
int main()
{
	int W, H, f, m, o, c[10][10];
	while (scanf("%d%d", &W, &H), W|H)
	{
		scanf("%d%d%d", &f, &m, &o);
		for (int i = 0; i < H; ++i)
			for (int j = 0; j < W; ++j)
				scanf("%d", &c[i][j]);

		static int visit[10][10][1<<10][51];
		for (int i = 0; i < H; ++i)
			for (int j = 0; j < W; ++j)
				for (int k = 0; k < 1 << W; ++k)
					for (int l = 0; l <= m; ++l)
					visit[i][j][k][l] = false;

		int res = -1;
		priority_queue<node> q;
		for (int i = 0; i < W; ++i)
			q.push(node(0, i, 0, o, 0));
		while (!q.empty())
		{
			node e = q.top(); q.pop();
			if (e.cost > f)
				break;
			else if (e.x < 0 || e.x >= W
				|| (e.y != H &&
					(e.o <= 1 || visit[e.y][e.x][e.hori][e.o])))
				continue;
			else if (e.y == H)
			{
				res = e.cost;
				break;
			}

			visit[e.y][e.x][e.hori][e.o] = true;
			--e.o;
			if (!(e.hori & (1 << e.x)))
			{
				e.hori |= 1 << e.x;
				if (c[e.y][e.x] < 0)
					e.cost -= c[e.y][e.x];
				else
					e.o = min(m, e.o + c[e.y][e.x]);
			}

			q.push(node(e.cost, e.x, e.y+1, e.o, 0));
			q.push(node(e.cost, e.x-1, e.y, e.o, e.hori));
			q.push(node(e.cost, e.x+1, e.y, e.o, e.hori));
		}

		if (res != -1)
			printf("%d\n", res);
		else
			puts("NA");
	}

	return 0;
}

Measured memory_bytes: 20000
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scanner = new Scanner(System.in);
	    int A = scanner.nextInt();
	    int B = scanner.nextInt();
	    int C = scanner.nextInt();
	    
	    if(A==B&&B!=C||A==C&&B!=C||C==B&&A!=C) {
    		System.out.println("Yes");
	    }else {
    		System.out.println("No");
	    }
  		scanner.close();

	}

}

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

#define ll long long
#define mod 1000000007
#define inf 1000000000000000000
#define fr first
#define sc second
#define pb push_back
#define pf push_front
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define per(i,a,n) for(ll i=n-1;i>=a;i--)
#define pll pair<ll,ll>
#define vll vector<ll>
#define umap unordered_map<ll,ll>
#define lpq priority_queue<ll,vector<ll>,greater<ll>>
ll powe(ll n,ll r){if(!r)return 1;else if(r%2==0)return powe(n*n,r/2);else return n*powe(n*n,(r-1)/2);}

int main(){
	/*
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif*/

	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);

	ll t=1;
	//cin>>t;
	while(t--){
		ll n,k;
		cin>>n>>k;
		vector<ll> h(n);
		vector<ll> dp(n,inf);
		for(ll i=0;i<n;i++)
			cin>>h[i];
		dp[0]=0;
		dp[1]=abs(h[1]-h[0]);
		for(ll i=2;i<n;i++){
			for(ll j=i-1;j>=0&&j>=i-k;j--){
				dp[i]=min(dp[i],dp[j]+abs(h[i]-h[j]));
			}
		}
		cout<<dp[n-1]<<endl;
	}

	return 0;

}

Measured memory_bytes: 1792
#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(){
ll n,m,k;
  cin>>n>>m>>k;
  vll a(n),b(m);
  rep(i,0,n)cin>>a[i];rep(i,0,m) cin>>b[i];
  vll sa(n),sb(m);
  sa[0]=a[0];sb[0]=b[0];
  rep(i,1,n){
    sa[i]=sa[i-1]+a[i];}
  rep(i,1,m){
    sb[i]=sb[i-1]+b[i];
    //cout<<sb[i]<<endl;
  }
  //cout<<sb[3]<<endl;
  ll ans=0;
  rep(i,0,n){
    ll c=k-sa[i];
    if(c<0)continue;
    
    ll cnt=0;
    ll f=distance(sb.begin(),upper_bound(sb.begin(),sb.end(),c));
    cnt=i+1+f;
   // cout<<i<<" "<<sa[i]<<" "<<c<<" "<<cnt<<" "<<f<<" "<<sb[f]<<endl;
    ans=max(ans,cnt);
  }
  rep(i,0,m){
    ll c=k-sb[i];
    if(c<0)continue;
    
    ll cnt=0;
    ll f=distance(sa.begin(),upper_bound(sa.begin(),sa.end(),c));
    cnt=i+1+f;
   // cout<<i<<" "<<sb[i]<<" "<<c<<" "<<cnt<<" "<<f<<" "<<sa[f]<<endl;
    ans=max(ans,cnt);
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 9588
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <deque>

//using namespace std;
using std::cin, std::cout, std::endl, std::string;
using ll = long long;

#define rep(countName, left, right, up) for (auto countName = left; countName < right; countName += up)
#define REP(countName, end) for (auto countName = 0; countName < end; countName++)
#define rev(countName, right, left, down) for (auto countName = right; countName >= left; countName -= down)
#define REV(countName, end) for (auto countName = end; countName >= 0; countName--)

auto solve1(int n, int k)
{
    std::vector<int> snuke(n);
    REP(i, k)
    {
        int v;
        cin >> v;
        REP(s, v)
        {
            int d;
            cin >> d;
            snuke[--d]++;
        }
    }
    std::sort(snuke.begin(), snuke.end());
    int ans = 0;
    REP(i, n)
    {
        if (snuke[i] == 0)
        {
            ans++;
        }
        else
        {
            break;
        }
    }
    return ans;
}

int main(void)
{
    int n, k;
    cin >> n >> k;
    std::cout << solve1(n, k) << std::endl;

    return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define sz(arr) (int)arr.size()

using namespace std;

int main() {
  int A;
  char op;
  int B;

  cin >> A >> op >> B;

  if (op == '+') {
    cout << A + B << endl;
  } else {
    cout << A - B << endl;
  }

  return 0;
}

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

int N; vector<int> X,Xsort;
void input()
{
    cin >> N;
    X.resize(N); Xsort.resize(N);
    for (int i = 0; i < N; ++i) {
        cin >> X[i];
        Xsort[i] = X[i];
    }
    sort(Xsort.begin(),Xsort.end());
}

void solve()
{
    int cen1 = Xsort[N/2-1], cen2 = Xsort[N/2];
    for (int i = 0; i < N; ++i){
        if (X[i] <= cen1) cout << cen2 << endl;
        else cout << cen1 << endl;
    }
}

int main()
{
    cin.tie();
    ios::sync_with_stdio(false);
    input();
    solve();
    return 0;
}

Measured memory_bytes: 4776
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pi 2*acos(0.0)
#define f first
#define s second
#define pb push_back
#define gap ' '
#define fastio {ios_base::sync_with_stdio(false);cin.tie(NULL);}
#define mod 1000000007

int main()
{
    int n,m;
    cin>>n;
    int ara[n+5]={0};
    for(int i=0;i<n-1;i++)
    {
        int x;
        cin>>x;
        ara[x]++;
    }
    for(int i=1;i<=n;i++) cout<<ara[i]<<endl;
}


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

using namespace std;
const int mx = 1e5+10;
const long long INF = 1e18+3;

long long tab[2][mx];
long long dp[mx], ans;
int main(){
   int n, w;
   scanf("%d %d",&n, &w);

   for(int i=0; i<n; i++){
      scanf("%lld %lld",&tab[0][i], &tab[1][i]);
   }
   for(int i=1; i<=w; i++) dp[i] = -1;
   for(int p=0; p<n; p++){
      for(int i=w; i>=1; i--){
         if(i-tab[0][p] >= 0 && dp[i-tab[0][p]] >= 0){
            dp[i] = max(dp[i], dp[i-tab[0][p]] + tab[1][p]);
         }
         //printf(">%d %lld\n",i,dp[i]);
      }
   }
   for(int i=1; i<=w; i++) ans = max(ans, dp[i]);
   printf("%lld\n",ans);
   return 0;
}


Measured memory_bytes: 1024
import Data.List

main = interact $ unlines . map keitai . tail . lines

keitai = decode . group

decode [] = []
decode ((x:xs):xss)
 | x == '0' = decode xss
 | otherwise = return ((word key) !! mod (length xs) (length (word key))) ++ decode xss
 where
  key = read (return x)
  word k = [".,!? ","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"] !! (k-1)

Measured memory_bytes: 5484
n = int(input())
dic = {}
ans = 0
for i in range(n):
  temp = input()
  if not temp in dic:
    dic[temp]=1
    ans += 1
  elif dic[temp]==0:
    dic[temp]=1
    ans+=1
  elif dic[temp]==1:
    dic[temp]=0
    ans-=1
print(ans)

Measured memory_bytes: 17892
def insertion_sort(A):
    for i in range(1,len(A)):
        print(*A)
        key = A[i]
        #/* insert A[i] into the sorted sequence A[0,...,j-1] */
        j = i - 1
        while j >= 0 and A[j] > key:
            A[j+1] = A[j]
            j-=1
        A[j+1] = key
 
if __name__=='__main__':
   n=int(input()) 
   A=list(map(int,input().split()))
   insertion_sort(A)
   print(*A)


Measured memory_bytes: 5980
#include<iostream>
using namespace std;
int s[]={0,0,31,60,91,121,152,182,213,244,274,305,335},a,b;
string t[]={"Wednesday","Thursday","Friday","Saturday","Sunday","Monday","Tuesday"};
main()
{
	while(cin>>a>>b,a)cout<<t[(s[a]+b)%7]<<endl;
}


Measured memory_bytes: 3168
# 桁DP

n, k = gets.split.map(&:to_i)
nums = gets.split.map(&:to_i)
# 下から数えて何桁目に 1 が何回出現したか
count_memo = Hash.new(0)
nums.each do |num|
  num.to_s(2).reverse.each_char.with_index do |b, i|
    count_memo[i] += 1 if b == "1"
  end
end
length = 45
binary_k = k.to_s(2).rjust(length, "0")
# dp[上から i 桁まで][smaller]の最大値
dp = (length + 1).times.map { Array.new(2, -1) }
# 初期化
# dp[0 桁目まで][桁は不自由]の最大値は 0
dp[0][0] = 0

# 桁数分ループする（i は遷移元の桁）
length.times do |i|
  dp_current = dp[i]
  # 最適化のため、事前に 1 行分だけ参照渡しをする
  # dp_next と dp[i + 1] の object_id は同じ
  dp_next = dp[i + 1]
  # smaller == 1 の場合、以下の桁は自由
  next_digit = binary_k[i].to_i
  2.times do |smaller|
    next if dp_current[smaller] == -1
    # smaller が 1、もしくは次の桁が 1 の場合は 0 と 1 を試す
    if smaller == 1 || next_digit == 1
      limit = 2
    else
      limit = 1
    end
    limit.times do |digit|
      # smaller == 0 且つ digit == next_digit（上限）の時のみ、0 のまま遷移する
      next_smaller = smaller == 0 && digit == next_digit ? 0 : 1
      count = count_memo[length - i - 1]
      count = n - count if count < n - count && digit == 1
      addition = count * (2 ** (length - i - 1))
      # 次の桁に遷移する
      dp_next[next_smaller] = dp_current[smaller] + addition if dp_next[next_smaller] < dp_current[smaller] + addition
    end
  end
end

puts dp.last.max


Measured memory_bytes: 13588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<string> ves;
typedef vector<vector<int>> ve_vei;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define fs first
#define sc second
#define all(a) a.begin(),a.end()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
 
int main() {
	//cout.precision(10);
	cin.tie(0);
	ios::sync_with_stdio(false);

    int A,B,C,D; cin >> A >> B >> C >> D;
    int ans;
    if(B <= C or D <= A) ans = 0;
    if(A <= C and C<= B and B<= D) ans = B - C;
    if(A <= C and D <= B) ans = D - C;
    if(C <= A and B <= D) ans = B - A;
    if(C <= A and A<= D and D<= B) ans = D - A;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include <queue>
#include <utility>
#include <map>
#include <set>
using namespace std;

int main() {
    int ans = 0;
    for (int i = 0; i < 4; i++) {
        char s;
        cin >> s;
        if (s == '+')ans++;
        else ans--;
    }

    cout << ans << endl;

    return 0;

}

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

int main() {
  int A, B, K;

  cin >> A >> B >> K;

  int num = min(A, B) + 1;
  int count = 0;
  while (count < K) {
    --num;
    if (!(A % num || B % num)) ++count;
  }

  cout << num << endl;

  return 0;
}


Measured memory_bytes: 256
import sys
n=int(input())
a=[]
for i in range(n):
    a.append(int(input()))
count =1 #ボタンを押した回数用 
s=0 #スタートするボタン　これを操作ボタンにしていく
while True:
    if a[s]==2:
        print(count)
        sys.exit()
    elif count>n:
        print(-1)
        sys.exit()
    else:
        count+=1
        s=a[s]-1



Measured memory_bytes: 7084
# print('input >>')
N = int(input())

rest = N
i = 0
ans_l = []

while not rest == 0:
    if rest % (-2)**(i+1) == 0:
        ans_l.append('0')
    else:
        ans_l.append('1')
        rest -= (-2)**i
    i += 1

# print('----------output----------')
ans = ''.join(ans_l[::-1])
if N == 0:
    ans = 0

print(ans)

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

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


Measured memory_bytes: 256
#include <stdio.h>
int main(){
    int n, i, s, g;
    for(i=1, g=1; i <10;i++){
             printf("%dx%d=%d\n", g,i, g*i);
             if(i==9){
             i=0;
             g++;         
             }
             if(g==10)
             break;
             }
    return 0;
    }

Measured memory_bytes: 924
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>
#include <queue>

#define MAXN 300005

using namespace std;

char line[MAXN];

int main()
{
    //freopen("a.txt", "r", stdin);
    int w;
    while (scanf("%s%d", line, &w) != EOF) {
        int pos = 0;
        int n = strlen(line);
        while (pos < n) {
            printf("%c", line[pos]);
            pos += w;
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 256
import Foundation

let number = readLine(stripNewline: true)
let numbers_arr_str = readLine(stripNewline: true)

let numbers_arr = numbers_arr_str!.componentsSeparatedByString(" ")
var no_pair = 0

for (i, value) in numbers_arr.enumerate() {
    let value_int = Int(value)! - 1
    if let index = Int(numbers_arr[value_int]) where index - 1 == i {
        no_pair += 1
    }
 }

no_pair = no_pair / 2

print(no_pair)

Measured memory_bytes: 7780
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
#define ll long long int
#define MOD 1000000007
#define oo 1000000000000000000
#define forr(i,n) for(ll i=0;i<n;i++)
#define fastio ios_base::sync_with_stdio(false); cin.tie(0) ; cout.tie(0);
#define all(x) x.begin(),x.end()
#define eb emplace_back
#define pb push_back
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
 
using namespace __gnu_pbds; 
using namespace std;

ll valueOfIndex(ordered_set&s , ll i){ return *(s.find_by_order(i)); }
ll indexOfValue(ordered_set&s , ll x){ return s.order_of_key(x); }
ll add(ll a, ll b,ll p=MOD) { a%=p; b%=p; return (a+b + p)%p;}
ll mul(ll a, ll b,ll p=MOD) { a%=p; b%=p; return (a*b + p)%p;} // __int128
ll power(ll x,ll n,ll p=MOD){ if(x==0) return 0; if(n==0 || x==1) return 1LL;
    ll r = (power(x,n/2,p))%p; if(n&1) return mul(mul(r,r,p) , x,p); else return mul(r,r,p);
}
ll inv(ll x){return power(x,MOD-2);}


void __sol(){
    int n,m; cin >> n >> m;
    int h[n+2];
    map<int,set<int>> mp;
    forr(i,n) cin >> h[i+1];
    forr(i,m){
        int u,v; cin >> u >> v;
        mp[u].insert(h[v]);
        mp[v].insert(h[u]);
    }
    int ans = 0;
    for(int i=1;i<=n;i++){
        if( mp[i].size()==0 ) ans++;
        else if( *(prev(mp[i].end())) < h[i] ) ans++;
    }
    cout << ans;
}


int main(){
    fastio
    ll tc=1; //cin >> tc;
    while(tc--) __sol();
    return 0;
}

Measured memory_bytes: 22788
using System;

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

			long sum = 1;
			for (int lp = 2; lp <= inputNum; lp++)
			{
				sum *= lp;
			}
			
			Console.WriteLine (sum);
		}
	}
}

Measured memory_bytes: 9100