akhauriyash/Code-Regression huggingface dataset:
/* 
	今日も一日がんばるぞい
*/
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<< '\n'

int main(){
    int n;
    cin >> n;
    int x[n],y[n];
    REP(i,n) cin >> x[i] >> y[i];
    
    double ans = 0;
    vector<int> v(n);
    REP(i,n) v[i] = i;
    do{
        double dis = 0;
        for(int i=0;i<n-1;i++){
            double dx = x[v[i]] - x[v[i+1]];
            double dy = y[v[i]] - y[v[i+1]];
            dis += sqrt(dx*dx + dy*dy);
        }
        ans += dis;
    }while(next_permutation(v.begin(),v.end()));
    FOR(i,1,n+1) ans /= i;
    cout << fixed << setprecision(15) << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //GCC5.4.1で配列の範囲外アクセスをエラーにする

//cmdで g++ test.cpp とするとコンパイルできる
//制限1秒なら10^6は余裕 10^7は多分間に合う 10^8はよほど単純でないと厳しい

#define ALL(x) x.begin(),x.end()
typedef long long ll; //long long
typedef pair<int,int> pii; //pair<int,int>
typedef vector<int> vi; //vector<int>
typedef vector<vector<int>> vvi; //vector<vector<int>>
typedef vector<ll> vll; //vector<long long>
typedef vector<vector<ll>> vvll; //vector<vector<long long>>

//const int MOD=998244353;
const int MOD=1000000007; //10^9+7
const double PI=3.1415926535;

int main(){
    int N,K;
    cin>>N>>K;
    vi D;
    vi Lsum(N+1); //Lsum[i]はV1からViの合計 Lsum[0]=0
    vi Rsum(N+1); //Rsum[i]は右からN個の合計 Rsum[0]=0
    Lsum[0]=0;Rsum[0]=0;
    for(int i=0;i<N;i++){
        int v;
        cin>>v;
        D.push_back(v);
        Lsum[i+1]=Lsum[i]+v;
    }
    for(int i=1;i<=N;i++){
        Rsum[i]=Rsum[i-1]+D[N-i];
    }
    int ans=0;
    for(int i=1;i<=min(N,K);i++){//iは取り出し操作回数
        for(int j=0;j<=i;j++){ //jは左から出す数
            for(int k=0;k<=i-j;k++){ //kは右から出す数
                //cout<<i<<" "<<j<<" "<<k<<" -> ";
                int v=Lsum[j]+Rsum[k];
                //cout<<"(v="<<v<<") ";
                int d=K-j-k; //筒に戻せる数
                priority_queue<int, vector<int>, greater<int>> Q; //逆順queue
                for(int cj=0;cj<j;cj++){
                    Q.push(D[cj]);
                }
                for(int ck=0;ck<k;ck++){
                    Q.push(D[N-1-ck]);
                }
                for(int cd=0;cd<d;cd++){
                    if(Q.empty())break;
                    int qt=Q.top();
                    if(qt>0)break;
                    v-=qt;
                    Q.pop();
                }
                //cout<<v<<endl;
                ans=max(ans,v);
            }
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll mn=3007;
const ll mod=1e9+7;
ll dp[mn][mn][2];

void modAdd(ll &a,ll b){
	a+=b;
	if(a>=mod)a%=mod;
}

int main(){
	ll N,M;cin>>N>>M;
	for(ll a=0;a<=N;++a)dp[0][a][a==0]=1;
	for(ll a=0;a<M;++a){
		for(ll b=0;b<=N;++b){
			for(ll c=0;c<2;++c){
				if(dp[a][b][c]<1)continue;
				ll d=dp[a][b][c];
				if(b>0)modAdd(dp[a+1][b][c|b==1],d);
				if(b>0)modAdd(dp[a+1][b-1][c|b==1],d);
				if(b<N)modAdd(dp[a+1][b][c],d);
				if(b<N)modAdd(dp[a+1][b+1][c],d);
			}
		}
	}
	ll ret;
	for(ll a=0;a<=N;++a)modAdd(ret,dp[M][a][1]);
	cout<<ret<<endl;
}


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

using namespace std;

int main(){
    string a;
    cin>>a;
    for(int i=0; i <= ((a.size()+1)/2); i++){
        if(a[2*i]=='L'){
            cout<<"No"; return 0;
        }
        if(i!=(a.size()+1)/2-1){
            if(a[2*i+1]=='R'){
                cout<<"No"; return 0;
            }
        }
    }
    cout<<"Yes";
    return 0;
}

Measured memory_bytes: 256
def run_code(N, K, ds):

    dislike_digits_set = set(i for i in ds)
    avail_digits = [i for i in range(10) if i not in dislike_digits_set]
    avail_min = avail_digits[0]

    def get_next_digit(d):
        last = 10
        for ad in (avail_digits + [last]):
            if ad >= d:
                if ad == last:
                    return (1, avail_min)
                else:
                    return (0, ad)

    def fill_last_kth_digits(n_digits, d, k):
        n = len(n_digits)
        for i in range(k):
            n_digits[n - i - 1] = d
        return n_digits

    def to_num(n_digits):
        num = 0
        n = len(n_digits)
        for i in range(n):
            num += n_digits[i] * 10**(n-i-1)
        return num

    def to_digits(num):
        return [int(i) for i in str(num)]

    def search_nearest_larger(num):
        n_digits = to_digits(num)
        n = len(n_digits)

        for i in range(n):
            d_in = n_digits[i]
            inc, d_out = get_next_digit(d_in)
            if inc == 0 and d_in == d_out:
                continue
            if inc > 0:
                num += 10**(n-i)
                n_digits = fill_last_kth_digits(to_digits(num), avail_min, n-i)
                return search_nearest_larger(to_num(n_digits))
            else:
                n_digits[i] = d_out
                return to_num(fill_last_kth_digits(n_digits, avail_min, n-i-1))

        return to_num(n_digits)

    return search_nearest_larger(N)


N, K = [int(i) for i in input().split()]
ds = [int(i) for i in input().split()]
res = run_code(N, K, ds)
print(res)


Measured memory_bytes: 3192
#include <stdio.h>
#include <cmath>
#include <algorithm>

int main(){
	double a,current,sum;
	while(scanf("%lf",&a)!=EOF){
		current = a;
		sum = a;
		for(int i = 2; i <= 10; i++){
			if(i %2 == 0){
				current = current*2.0;
				sum += current;
			}else{
				current = current/3.0;
				sum += current;
			}
		}
		printf("%.8lf\n",sum);

	}

	return 0;
}

Measured memory_bytes: 2560
#include <stdio.h>
int main(void){
    int i,j,ver,hori,han;
    while(1){
        scanf("%d %d",&ver,&hori);
        if(ver == 0)break;
        for(i=0;i<ver;i++){
            for(j=0;j<hori;j++){
                han = (i + j) % 2;
                if(han == 0)printf("#");
                else printf(".");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


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

int main(){

    // omajinai
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    // omajinai

    int k,s;
    cin >> k >> s;

    int ans = 0;

    for(int x = 0;x < k+1;x ++){

        if(s-x > 2*k){
            continue;
        }

        for(int y = x;y < k+1;y ++){

            if(s-x-y > k){
                continue;
            }

            int z = s-x-y;
            if(z < y){
                continue;
            }

            if(x == y && y == z){
                ans ++;
            }else if(x == y || y == z){
                ans += 3;
            }else{
                ans += 6;
            }
            
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
s = input()

for i in range(len(s)):
    cut = s[i : i + 1]
    if cut.isalpha() and cut.isupper():
        s = s[:i] + cut.lower() + s[i + 1 :]
    elif cut.isalpha() and cut.islower():
        s = s[:i] + cut.upper() + s[i + 1 :]

print(s)



Measured memory_bytes: 5560
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N, M;
    cin >> N >> M;
    vector<pair<int, int>> p(M);
    for(int i = 0; i < M; ++i) {
        int a, b;
        cin >> a >> b;
        p.at(i) = make_pair(b, a);
    }

    sort(p.begin(), p.end());
    
    int count = 1;
    int ans = p.at(0).first;
    for(int i = 0; i < M; ++i) {
        if(ans <= p.at(i).second) {
            count++;
            ans = p.at(i).first;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 1024
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1]*n
    
    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x
    
    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


N, M = map(int, input().split())


bridge = []
for i in range(M):
    a, b = map(int, input().split())
    bridge.append((a-1,b-1))

ans = 0
for i in range(M):
    uf = UnionFind(N)
    for j, (a, b) in enumerate(bridge):
        if i == j:
            continue
        uf.union(a,b)
    if uf.group_count() == 2:
        ans += 1


print(ans)






Measured memory_bytes: 40944
#include<bits/stdc++.h>
#define test int t; cin>>t; while(t--)
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define pb push_back
#define sz 200000
typedef long long ll;
using namespace std;
int main()
{
     ll n,sum;
     cin>>n;
     ll a[n];
     for(int i=0;i<n;i++)
        cin>>a[i];
        ll tk=1000,stock=0;
    int cnt=a[0];
     for(int i=1;i<n;i++)
     {
         if(cnt<a[i])
            {
               ll temp=tk/cnt;
               //stock+=temp;
               tk=tk-cnt*temp;
               tk+=a[i]*temp;
               cnt=a[i];
             // cout<<tk<<endl;

            }
            else
                cnt=a[i];

     }
     cout<<tk<<endl;



return 0;

}



Measured memory_bytes: 3616
import math
import sys
import numpy as np
import collections

#n, a, b= map(int, input().split())
#w, h, n  = map(int, input().split())
#s = list(str(input()))
n = int(input())
s = [""]*n
for i in range(n):
  s[i] = str(input())
m = int(input())
t = [""]*m
for i in range(m):
  t[i] = str(input())
#a = list(map(int, input().split()))

c1 = collections.Counter(s)
c2 = collections.Counter(t)
score = [0]*len(s)
counter = 0

for i in c1.keys():
  score[counter] = c1[i] - c2[i]
  counter = counter + 1

if(max(score) >= 0):
  print(max(score))
else:
  print(0)

Measured memory_bytes: 12500
#include <iostream>

using namespace std;

void f(int a, int b, int c) {

    if (a + b >= c) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
}

int main() {

    int a, b, c;
    cin >> a >> b >> c;

    f(a, b, c);

    return 0;
}


Measured memory_bytes: 256
n=int(input())
abc=[]
for _ in range(n):
    a,b=map(int,input().split())
    c=a+b
    abc.append((a,b,c))
abc=sorted(abc,key=lambda x:x[2],reverse=True)
t=abc[::2]
a=abc[1::2]
ans=0
for i in t:
    ans+=i[0]
for i in a:
    ans-=i[1]
print(ans)

Measured memory_bytes: 22908
n, x = map(int,input().split())
assert n >= 2
if x==1 or x==2*n-1:
    print('No')
else:
    a = [x-1,x,x+1]
    b = list(range(1,x-1))+list(range(x+2,2*n))
    ans = b[n-2:]+a +b[:n-2]
    print('Yes')
    print(*ans,sep='\n')

Measured memory_bytes: 18492
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        while (sc.hasNext()) {
            int a = sc.nextInt();
            int b = sc.nextInt();
            int GCD = GCD(a, b);
            int LCM = a / GCD * b;
            System.out.println(GCD + " " + LCM);
        }
        sc.close();
    }

    static int GCD(int a, int b) {
        if (a < b) {
            if (b % a == 0) {
                return a;
            } else {
                return GCD(a, b % a);
            }
        } else {
            if (a % b == 0) {
                return b;
            } else {
                return GCD(a % b, b);
            }
        }
    }
}


Measured memory_bytes: 25864
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second

 vector<string>v;
string  a[100001];
 string b[100001];
 
int main()
{
     long long c1,c2,c=0,g=1,h=0,z=0,ans=1000000005,k=0,maxi=0,p=2,msize,sum=0,sum2=0,sumi=0,sumf=0;
     ll n,m,e,count=0;
     string s;
     cin>>n;
     n%2 ? cout<<n*2:cout<<n;
}
  

Measured memory_bytes: 1792
import scala.io.StdIn

object Main {
  def main(args: Array[String]) = {
    val array = StdIn.readLine.split(" ").map(_.toInt)
    val (n, a, b) = (array(0), array(1), array(2))
    var count = 0
   
    for(x <- 1 to n){
      if((a to b).contains(x.toString.map(_.asDigit).sum)) count += x 
    }
    println(count)
  }
  
}

Measured memory_bytes: 32564
#include <bits/stdc++.h>
 
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef pair<ll, ll> pii;
 
#define REP(a,b,c) for(ll (a)=(b);(a)<(c);(a)++)
#define PER(a,b,c) for(ll (a)=(b);(a)>=(c);(a)--)
 
void ii(ll &x){ cin >> x; }
void is(string &x){ cin >> x; }
void oi(ll &x){ cout << x; }
void os(string &x){ cout << x; }
void oie(ll &x){ cout << x << endl; }
void oss(string &x){ cout << x << endl; }
 
int main(){
    ll N; ii(N);
    ll P; ii(P);
    string S; is(S);

    ll T[N];
    REP(i,0,N){
        T[i]=S[i]-'0';
    }

    ll ret = 0;
    if(P==2){
        REP(i,0,N){
            if(T[i]%2==0){
                ret+=i+1;
            }
        }
        oie(ret);
        return 0;
    }

    if(P==5){
        REP(i,0,N){
            if(T[i]%5==0){
                ret+=i+1;
            }
        }
        oie(ret);
        return 0;
    }

    ll M[P]; REP(i,0,P){M[i]=0;}
    M[0]++;
    ll a=0;
    ll tm=1;
    PER(i,N-1,0){
        a+=T[i]*tm;
        a%=P;
        tm*=10;
        tm%=P;
        M[a]++;
    }
    REP(i,0,P) ret+=M[i]*(M[i]-1)/2; 
    oie(ret);
    return 0;
}

Measured memory_bytes: 2180
#include <cstdio>
#include <cstring>
using namespace std;
typedef long long ll;
const int N=200005;
int n,up,nex[N],type;
char str[N];
int pre[N][26];
ll l,r,cut,len[100],ans[26];
ll f[100][26];
void readData(){
    scanf("%s%lld%lld",str+1,&l,&r);
    n=strlen(str+1);
    n>>=1;
    for(int i=1;i<=n;i++){
        for(int j=0;j<26;j++) pre[i][j]=pre[i-1][j];
        pre[i][str[i]-'a']++;
    }
}
void getNex(){
    nex[1]=0;
    for(int i=2,j;i<=n;i++){
        j=nex[i-1];
        while(j&&str[j+1]!=str[i]) j=nex[j];
        nex[i]=(str[j+1]==str[i])?j+1:0;
    }
}
void preWork(){
    len[1]=n;
    for(int i=1;i<=n;i++){
        f[1][str[i]-'a']++;
        f[2][str[i]-'a']++;
    }
    len[2]=n+cut;
    for(int i=0;i<26;i++) 
        f[2][i]+=pre[cut][i];
    for(int i=3;;i++){
        for(int j=0;j<26;j++) f[i][j]=f[i-2][j]+f[i-1][j];
        len[i]=len[i-2]+len[i-1];
        if(len[i]>1e18){
            up=i;
            break;
        }
    }
}
void calc1(ll m,ll a){
    if(m<=0) return;
    ll t=m/cut;
    for(int i=0;i<26;i++) ans[i]+=a*t*pre[cut][i];
    t=m%cut;        
    for(int i=0;i<26;i++) ans[i]+=a*pre[t][i];
}
void calc2(ll m,ll a){
    for(int i=up;i>=1;i--)
        if(len[i]<=m){
            m-=len[i];
            for(int j=0;j<26;j++) ans[j]+=a*f[i][j];
        }
    for(int j=0;j<26;j++) ans[j]+=a*pre[m][j];
}
int main(){
    readData();
    getNex();
    cut=n-nex[n];
    if(n%cut==0){
        calc1(r,1);
        calc1(l-1,-1);
    }
    else{
        preWork();
        calc2(r,1);
        calc2(l-1,-1);
    }
    for(int i=0;i<26;i++) printf("%lld ",ans[i]);
    return 0;
}

Measured memory_bytes: 12492
# -*- coding: utf-8 -*-
# モジュールのインポート
import math
import itertools

# 標準入力を取得
N = int(input())

# メイン処理


def g(x: int, y: int, z: int) -> int:
    return x**2 + y**2 + z**2 + x*y + y*z + z*x


l = [0 for n in range(N)]
for x, y, z in itertools.product(range(1, int(math.sqrt(N)) + 1), repeat=3):
    v = g(x, y, z)
    if v <= N:
        l[v - 1] += 1

# 結果出力
for ans in l:
    print(ans)


Measured memory_bytes: 9220
#include <cstdio>
#include <iostream>
#include <string>
#include <algorithm>
#include <cstring>
#include <queue>
#include <utility>
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <deque>

using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
const int MAXN = 123456;
const int INF = (int)1e9;
int a[MAXN], neg[MAXN], pos[MAXN];

int main() {
    int N, K;
    while (~scanf("%d %d", &N, &K)) {
          for (int i = 1; i <= N; i++) {
              neg[i] = pos[i] = INF;
          }
          int lst = -1, pos_cnt = 0, neg_cnt = 0;
          for (int i = 0; i < N; i++) {
              scanf("%d", &a[i]);
              if (a[i] < 0) lst = i;
              else pos[++pos_cnt] = a[i];
          }
          for (int i = lst; i >= 0; i--) {
              neg[++neg_cnt] = -a[i];
          }
          int ans = min(pos[K], neg[K]);
          for (int i = 1; i < K; i++) {
              ans = min(ans, pos[i] * 2 + neg[K - i]);
              ans = min(ans, neg[i] * 2 + pos[K - i]);
          }
          printf("%d\n", ans);
    }
    return 0;
}


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

using namespace std;
#define int long long
pair <int,int> perec(pair <int,int> a,pair <int,int> b)
{
    return {max(a.first,b.first),min(a.second,b.second)};
}
int le(pair <int,int> a)
{
    return max(0LL,a.second-a.first+1);
}
int32_t main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    pair <int,int> a[n];
    vector <int> lef;vector <int> ri;
    for(int i=0;i<n;++i) {cin>>a[i].first>>a[i].second;lef.push_back(a[i].first);ri.push_back(a[i].second);}
    sort(lef.begin(),lef.end());sort(ri.begin(),ri.end());
    int ans=0;
    for(int i=0;i<n;++i)
    {
        int l=lef.back();int r=ri[0];
        if(a[i].first==l)
        {
            l=lef[lef.size()-2];
        }
        if(a[i].second==r)
        {
            r=ri[1];
        }
        ans=max(ans,le(a[i])+le({l,r}));
    }
    sort(a,a+n);
    pair <int,int> b[n+1];
    pair <int,int> c[n+1];
    b[0]={0,1e18};
    for(int i=0;i<n;++i)
    {
        b[i+1]=perec(b[i],a[i]);
    }
    c[n]={0,1e18};
    for(int i=(n-1);i>=0;i--)
    {
        c[i]=perec(c[i+1],a[i]);
    }
    for(int i=0;i<(n-1);++i)
    {
       ans=max(ans,le(b[i+1])+le(c[i+1]));
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 9568
def DP():
  H,N,*T = map(int,open(0).read().split())
  
  #dpテーブルの設定と初期化
  dp = [0] + [10 ** 9] * H
  
  #各魔法について
  for d,c in zip(*[iter(T)] * 2):
    #d,cはそれぞれ魔法ダメージと魔法のコスト
    #dpテーブルの各HPについて
    for j in range(H + 1):
      k = j - d
      if k < 0:
        k = 0
      #ダメージjを与える時のコストについて、
      #魔法iを新たに使った場合と、既存の最小コストを比較し更新する
      l = dp[k] + c
      if l < dp[j]:
        dp[j] = l
      
  print(dp[-1])
  
DP()

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); ++i)
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
const ll INF = 1LL << 60;

int main(){
	int a, b, c, d;
	cin >> a >> b >> c >> d;
	cout << min(a, b) + min(c, d) << endl;
}


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

ll gcd(ll a, ll b){
  if(b == 0){
    return a;
  }
  else{
    return gcd(b,(a%b));
  }
}
ll lcm(ll a,ll b){
  return a/gcd(a,b)*b;
}
int Ineq(int a,int b){
  if(a>b){
    return 0;
  }
  if(a<b){
    return 1;
  }
  if(a==b){
    return 2;
  }
}

int main(){
  int n;
  cin>>n;
  if(n<3){
    cout<<1<<endl;
    return 0;
  }
  int vec[n];
  for(int i=0;i<n;i++){
    cin>>vec[i];
  }
  int ans=1;
  int p=Ineq(vec[0],vec[1]),q;
  for(int i=0;i<n-1;i++){
    q=Ineq(vec[i],vec[i+1]);
    if(p==5){
      p=q;
      continue;
    }
    if(q==2){
      continue;
    }
    if(q==0){
      if(p==2){
        p=q;
        continue;
      }
      if(p==1){
        ans++;
        p=5;
        continue;
      }
    }
    if(q==1){
      if(p==2){
        p=q;
        continue;
      }
      if(p==0){
        ans++;
        p=5;
        continue;
      }
    }
  }
  cout<<ans<<endl;
}

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

int main()
{
  int i , N , X = 0;
  cin >> N ;
  int A[8] ;
  int B[8] ;
  
  for(i=7;i>=0;i--){
	A[i] = N * ( pow(0.1, 1+i) ) * 10 ; 
  }
  
  	B[7] = A[7] ;
  
   for(i=6;i>=0;i--){
	B[i] = A[i] - (A[i+1] * 10) ;
  }
  
  for(i=0;i<8;i++){
    X += B[i];
  }
    
  if(N % X == 0)
    cout << "Yes" ;
  else
  	cout << "No" ;
  
    
return 0;
}

Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
  input = input.split("\n")
  tmp0 = input[0].split(" ")

  N = Number(tmp0[0])
  M = Number(tmp0[1])

  var ansArr=[];
  for(var i=0; i < M; i++){
    ansArr.push(0)
  }

  for(var i=1; i <= N; i++)
  {
    var tmp1 = input[i].split(" ")
    for(var j = 1; j < tmp1.length; j++){
      ansArr[tmp1[j]-1]++
    }
  }

  var ans=0
  for(var i=0; i < ansArr.length;i++)
  {
    if(ansArr[i] === N){
      ans++
    }
  }
  console.log(ans)

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

Measured memory_bytes: 7372
#define _CRT_SECURE_NO_WARNINGS
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 0x3f3f3f3f
#define INFL 0x3f3f3f3f3f3f3f3fLL
using namespace std;
typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii;
typedef long long ll; typedef vector<long long> vl; typedef pair<long long,long long> pll; typedef vector<pair<long long,long long> > vpll;
typedef vector<string> vs; typedef long double ld;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }

char A[1001], B[1001];
int main() {
	scanf("%s", A);
	scanf("%s", B);
	int n = strlen(A), m = strlen(B);
	bool ans = false;
	rer(i, 0, n) {
		bool ok = true;
		rep(j, m)
			ok &= B[j] == '_' || A[i+j] == B[j];
		ans |= ok;
	}
	puts(ans ? "Yes" : "No");
    return 0;
}


Measured memory_bytes: 1112
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;
int a[1000];

bool isvaild(int d){
    int left,right=10;
    while(d){
        left=d%10;
        if(left!=right-1&&right!=10){
            return false;
        }else{
            right=left;
            d/=10;
        }
    }
    return true;
}

int main(){

    int N;
    cin>>N;

    for(int i=0;i<N;i++){
        cin>>a[i];
    }
    int ans=-1;
    for(int i=0;i<N;i++){
        for(int j=i+1;j<N;j++){
            if(a[i]*a[j]>ans&&isvaild(a[i]*a[j])) ans=a[i]*a[j];
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3092
import numpy as np 
N, M = map(int,input().split())
h_list = np.array(list(map(int,input().split())))
max_neighbor_hight = np.zeros(N) 
for _ in range(M):
    a,b = map(int,input().split())
    a-=1
    b-=1
    max_neighbor_hight[a] = max(max_neighbor_hight[a],h_list[b])
    max_neighbor_hight[b] = max(max_neighbor_hight[b],h_list[a])
diff = h_list - max_neighbor_hight
ans = np.sum(diff>0)
print(ans)

Measured memory_bytes: 38452
n, k = list(map(int, input().split()))
a = list(input().split())
a_unique = list(set(a))
d = {}
for i in range(len(a_unique)):
	d.setdefault(a_unique[i],0)
for i in range(n):
	d[a[i]] += 1
if len(d) <= k:
	print(0)
else:
	diff = len(d) - k
	d_value = list(d.values())
	d_value.sort()
	print(sum(d_value[:len(d)-k]))


Measured memory_bytes: 41756
from collections import*
(h,w),(s,t),(f,g)=eval('map(int,input().split()),'*3)
m,d=zip(*eval('(input(),[-1]*w),'*h))
q=deque([(s-1,t-1,0)])
while q:
 y,x,c=q.pop()
 if d[y][x]<0:
  for a in range(25):a,b=a//5-2,a%5-2;i=a+y;j=b+x;d[y][x]=c;h>i>-1<j<w!=m[i][j]>'#'!=(abs(a)+abs(b)<2!=q.append((i,j,c)),q.appendleft((i,j,c+1)))
print(d[f-1][g-1])

Measured memory_bytes: 257860
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <vector>


#define EPSILON 1e-9


class vector_t {
public:
  double x;
  double y;
  double z;

public:
  vector_t(double x = 0, double y = 0, double z = 0) : x(x), y(y), z(z) {};

public:
  double operator*(const vector_t& v) const {
    return x * v.x + y * v.y + z * v.z;
  };

  vector_t operator^(const vector_t& v) const {
    return vector_t(y * v.z - z * v.y,
                    z * v.x - x * v.z,
                    x * v.y - y * v.x);
  };

public:
  double length() const {
    return sqrt(*this * *this);
  };
};


class point_t {
public:
  double x;
  double y;
  double z;
  double w;

public:
  point_t(double x = 0, double y = 0, double z = 0, double w = 1) : x(x), y(y), z(z), w(w) {};
  
public:
  vector_t operator-(const point_t& p) const {
    return vector_t(x - p.x, y - p.y, z - p.z);
  };
};


int main(int argc, char** argv)
{
  std::vector<point_t> points;

  double x, y;

  while (fscanf(stdin, "%lf,%lf", &x, &y) == 2)
    points.push_back(point_t(x, y));

  double s = 0;

  for (int i = 1, size = points.size(); i < size - 1; i ++) {
    vector_t v1(points[i] - points[0]), v2(points[i+1] - points[0]);

    s += std::abs((v1 ^ v2).z);
  }

  s /= 2;
  
  std::cout << std::setprecision(16) << s << std::endl;
  
  return 0;
}

Measured memory_bytes: 1292
fun main(args: Array<String>) {
    agc003a()
}

fun agc003a() {
    val s = readLine()!!

    val ns = (s.count { it == 'N' } == 0) == (s.count { it == 'S' } == 0)
    val we = (s.count { it == 'W' } == 0) == (s.count { it == 'E' } == 0)

    val answer = if (ns && we) "Yes" else "No"

    println(answer)
}


Measured memory_bytes: 33716
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author lynmisakura
 */

#include <iostream>
#include <fstream>

/*
 *  author : lynmisakura
 *  Seriousness is the last refuge of the shallow.(Oscar Wilde)
 */
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>

#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>
#include <unordered_map>
#include <unordered_set>

using namespace std;
typedef long long ll;

class AABCSwap {
public:
	void solve(std::istream& cin, std::ostream& cout) {
        int a,b,c;cin >> a >> b >> c;
        cout << c << ' ' << a << ' ' << b << '\n';
	}
};


int main() {
	AABCSwap solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, a, b) for(int i = (a); i <= (b); i++)
#define PER(i, a, b) for(int i = (a); i >= (b); i--)
#define rep(i, a, b) for(int i = (a); i < (b); i++)
#define all(S) (S).begin(), (S).end()
#define pf push_front
#define pb push_back
#define mk make_pair
#define S second
#define F first
typedef long long ll;
typedef long double lf;
typedef pair<int, int> ii;
char s[110];
int mp[30];

int main(int argc, char ** argv) {
	scanf("%s", s);
	rep(i, 0, strlen(s)) mp[s[i]-'a']++;
	rep(i, 0, 30) if(mp[i]&1) mp[27] = 1;
	printf("%s\n", mp[27] ? "No" : "Yes");
	return 0;
}


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

int main () {
    // string a, b, c;
    string a;
    cin >> a;
    int sum = 0;
    for (int i = 0; i < a.size(); i++) {
        sum += a[i] - '0';                                                      
    }   
    if (stoi(a) % sum == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }   
}




Measured memory_bytes: 256
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int x = Integer.parseInt(sc.next());
		int y = Integer.parseInt(sc.next());

		while(x != 0 || y != 0){
			
			if(x < y){
				System.out.println(x + " " + y);
			} else {
				System.out.println(y + " " + x);
			}
			
			x = Integer.parseInt(sc.next());
			y = Integer.parseInt(sc.next());
		}
	}
}

Measured memory_bytes: 25164
#include <cstdio>
#include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <string>
#include <cmath>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#define rep(i,n) for (int i=0;i<n;i++)
using ll = long long;
using namespace std;

void solve(){

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

    int n,k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i,n){
        a[i]=0;
    }
    rep(i,n){
        int m;
        cin >> m;
        a[m-1]+=1;
    }
    sort(a.begin(),a.end(),greater<int>());

    int cnt=0;
    rep(i,k){
        cnt+=a[i];
    }
    cout << n-cnt << endl;

    return 0;
}

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

typedef ostringstream OSS; typedef istringstream ISS;
typedef long long LL;
typedef pair<int, int> PII;  typedef pair<LL, LL> PLL;
typedef vector<int>    VI;   typedef vector<VI>   VVI;   typedef vector<VVI>   VVVI;
typedef vector<LL>     VLL;  typedef vector<VLL>  VVLL;  typedef vector<VVLL>  VVVLL;
typedef vector<double> VD;   typedef vector<VD>   VVD;   typedef vector<VVD>   VVVD;
typedef vector<string> VS;   typedef vector<VS>   VVS;   typedef vector<VVS>   VVVS;
typedef vector<bool>   VB;   typedef vector<VB>   VVB;   typedef vector<VVB>   VVVB;
typedef vector<PII>    VPII; typedef vector<VPII> VVPII; typedef vector<VVPII> VVVPII;
typedef vector<PLL>    VPLL; typedef vector<VPLL> VVPLL; typedef vector<VVPLL> VVVPLL;

#define fst first
#define snd second
// #define Y first
// #define X second
#define MP make_pair
#define PB push_back
#define EB emplace_back 
#define ALL(x)  (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define RANGEBOX(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
#define RANGE(x, l, r) ((l) <= (x) && (x) <= (r))
#define rep(i, N)  for (int i = 0; i < (int)(N); i++)
#define rrep(i, N) for (int i = N - 1; i >= 0; i--)
#define REP(i, init, N)  for (int i = (init); i < (int)(N); i++)
#define RREP(i, N, last) for (int i = (init - 1); i >= last; i--)
#define MAXUD(orig, target) orig = max(orig, target)
#define MINUD(orig, target) orig = min(orig, target)
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

template < typename T > inline T fromString(const string &s) { T res; ISS iss(s); iss >> res; return res; };
template < typename T > inline string toString(const T &a)   { OSS oss; oss << a; return oss.str(); };

const int    INF  = 0x3f3f3f3f;
const LL     INFL = 0x3f3f3f3f3f3f3f3fLL;
const double DINF = 0x3f3f3f3f;
const int    DX[] = {1,  0, -1, 0};
const int    DY[] = {0, -1,  0, 1};
const double EPS  = 1e-12;
// const double PI   = acos(-1.0);
// lambda: [](T1 x)->T2{return y;}
// simple lambda: [](T x){return x;}

int main(void) {
    int L, N;
    cin >> L >> N;
    VI zs(N), ws(N);
    rep(i, N) {
        cin >> zs[i] >> ws[i];
    }

    cout << N << endl;
    rep(i, N) {
        cout << -zs[i] << " " << ws[i] << endl;
    }

	return 0;
}

Measured memory_bytes: 3104
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace abc171_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string input = Console.ReadLine();

            if (input.Equals(input.ToUpper()))
            {
                Console.WriteLine("A");
            }
            else
            {
                Console.WriteLine("a");
            }

            Console.Read();

        }
    }
}


Measured memory_bytes: 26176
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

ll modpow(ll x, ll b){
  ll res = 1;
  while(b){
    if(b&1)res = res * x % MOD;
    x = x * x % MOD;
    b>>=1;
  }
  return res;
}

ll modinv(ll x){
  return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
  if(was_output)cout << " ";
  cout << a;
  was_output = true;
}
void outendl(){
  was_output = false;
  cout << endl;
}
ll in(){
  ll res;
  scanf("%lld", &res);
  return res;
}

template<class t>
istream& operator>>(istream&is, vector<t>&x){
  for(auto &i:x)is >> i;
  return is;
}

template<class t, class u>
istream& operator>>(istream&is, pair<t, u>&x){
  is >> x.first >> x.second;
  return is;
}

template<class t>
void in(t&x){
  cin >> x;
}


int main(){

  ll a = in();
  ll b = in();
  ll c = in();
  //sa + sb < sc
  //a + b + 2 sab < c
  //2 sab < c - a - b
  //4 ab < 
  if(c-a-b>=0&&4*a*b<a*a+b*b+c*c+2*(a*b-c*(a+b))){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }


  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int a[100100],i,j,k,n,m;
    while(scanf("%d",&n)!=EOF)
    {
        memset(a,0,sizeof(a));
        a[n]++;
        for(i=2;;i++)
        {
            if(n%2==0)
            {
                a[n/2]++;
                n=n/2;
                if(a[n]==2)
                {
                    printf("%d\n",i);
                    break;
                }
            }
            else
            {
                a[3*n+1]++;
                n=3*n+1;
                if(a[n]==2)
                {
                    printf("%d\n",i);
                    break;
                }

            }
        }
    }
    return 0;
}



Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1LL << 30;

int main(){
  ll N, M;
  cin >> N >> M;
  vvll dp(N, vll(N, INF));
  vector<vector<bool>> flag(N, vector<bool>(N, false));
  for(int i = 0; i < M; i++){
    ll a, b, c;
    cin >> a >> b >> c;
    a--; b--;
    dp.at(a).at(b) = c;
    dp.at(b).at(a) = c;
    flag.at(a).at(b) = true;
    flag.at(b).at(a) = true;
  }
  for(int i = 0; i < N; i++){
    dp.at(i).at(i) = 0;
  }
  set<P> se;
  for(int k = 0; k < N; k++){
    for(int i = 0; i < N; i++){
      for(int j = 0; j < N; j++){
        if(dp.at(i).at(j) > dp.at(i).at(k) + dp.at(k).at(j)){
          if(flag.at(i).at(j)){
            int ii = i, jj = j;
            if(ii > jj) swap(ii, jj);
            se.insert(P(ii, jj));
          }
          dp.at(i).at(j) = dp.at(i).at(k) + dp.at(k).at(j);
        }
      }
    }
  }
  cout << se.size() << endl;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <utility>

using namespace std;
typedef long long ll;
const int LEN = 100000;

struct fastio{
  int it,len;
  char s[LEN + 5];
  fastio(){
    it = len = 0;
  }
  char get(){
    if(it < len) return s[it++];
    it = 0, len = fread(s,1,LEN,stdin);
    return len ? s[it++] : EOF;
  }
  bool notend(){
    char c;
    for(c = get();c == ' ' || c == '\n';c = get());
    if(it) it--;
    return c != EOF;
  }
  void put(char c){
    if(it == LEN) fwrite(s,1,LEN,stdout), it = 0;
    s[it++] = c;
  }
  void flush(){
    fwrite(s,1,it,stdout);
  }
}buff,bufo;
inline int getint(){
  char c; int res = 0, sig = 1;
  for(c = buff.get();c < '0' || c > '9';c = buff.get()) if(c == '-') sig = -1;
  for(;c >= '0' && c <= '9';c = buff.get()) res = res * 10 + (c - '0');
  return sig * res;
}
inline ll getll(){
  char c; ll res = 0, sig = 1;
  for(c = buff.get();c < '0' || c > '9';c = buff.get()) if(c == '-') sig = -1;
  for(;c >= '0' && c <= '9';c = buff.get()) res = res * 10 + (c - '0');
  return sig * res;
}
inline void putint(int x,char suf){
  if(!x) bufo.put('0');
  else{
    if(x < 0) bufo.put('-'), x = -x;
    int k = 0; char s[15];
    while(x){
      s[++k] = x % 10 + '0';
      x /= 10;
    }
    for(;k;k--) bufo.put(s[k]);
  }
  bufo.put(suf);
}
inline void putll(ll x,char suf){
  if(!x) bufo.put('0');
  else{
    if(x < 0) bufo.put('-'), x = -x;
    int k = 0; char s[25];
    while(x){
      s[++k] = x % 10 + '0';
      x /= 10;
    }
    for(;k;k--) bufo.put(s[k]);
  }
  bufo.put(suf);
}
inline char get_char(){
  char c;
  for(c = buff.get();c == ' ' || c == '\n';c = buff.get());
  return c;
}
#define maxn 200005
const ll mod = 1000000007;
const ll inv_2 = 500000004;
int n,siz[maxn];
vector <int> adj[maxn];
ll ans;
ll modpow(ll x,ll y){
  ll res = 1;
  while(y){
    if(y & 1) res = res * x % mod;
    y >>= 1;
    x = x * x % mod;
  }
  return res;
}
void dfs(int u,int f){
  siz[u] = 1;
  ll res = 1;
  for(int i = 0;i < (int)adj[u].size();i++){
    int v = adj[u][i];
    if(v == f) continue;
    dfs(v,u);
    siz[u] += siz[v];
    (res += modpow(2,siz[v]) - 1 + mod) %= mod;
  }
  (res += modpow(2,n - siz[u]) - 1 + mod) %= mod;
  res = (modpow(2,n - 1) - res + mod) % mod;
  (ans += res) %= mod;
}
int main(){
  n = getint();
  for(int i = 1;i < n;i++){
    int u = getint(), v = getint();
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  dfs(1,-1);
  ans = ans * modpow(inv_2,n) % mod;
  putll(ans,'\n');
  bufo.flush();
  return 0;
}


Measured memory_bytes: 25472
function Main(input) {
	var str = input;
	var data= [];
	var c = 0;
	const a = str.split('\n');
	var config  =a[0].split(" ");
	var p = config[0];//人数	
	var q = config[1];//お菓子
	for(var i = 1; i <= q; i++){
		arr = a[2*i].split(" ")
	data = data.concat(arr);
	}
// 	console.log(data);
	for(var j = 1; j <= p; j++){
		for(var k = 0;k<data.length;k++){
			if (data[k] == j){
				break;
			}
			if(k === data.length-1){
				c++;	
			}
		}
	}
 console.log(c);
 }
 
 
//*おまじない
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 33000
#include<bits/stdc++.h>
using namespace std;
int main(){
string s;
cin>>s;
long long  cnt=0,sum=0;
for(int i=0;i<s.size();i++){
    if(s[i]=='W'){
        sum+=(i-cnt);
        cnt++;
    }
}
cout<<sum;
}

Measured memory_bytes: 3756
#include <iostream>
#include <string>
#include <vector>
#include <set>

using namespace std;

using ll = long long;

template <class T>
using grid = vector<vector<T>>;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

#define input(...) __VA_ARGS__; in(__VA_ARGS__)

void print() {
  std::cout << std::endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
  std::cout << head << " ";
  print(std::forward<Tail>(tail)...);
}

void in() { }

template <class Head, class... Tail>
void in(Head&& head, Tail&&... tail) {
  cin >> head;
  in(std::forward<Tail>(tail)...);
}

int main() {
  ll input(n);
  string input(s);
  vector<ll> si(n);
  REP(i, n) si[i] = s[i] - '0';

  int ans = 0;
  REP(i, 10) REP(j, 10) REP(k, 10) {
    // int number = i * 100 + j * 10 + k;
    int number = i + j * 10 + k * 100;
    int cnt = 0;
    for (auto v: si) {
      if (number % 10 == v) {
        number /= 10;
        cnt++;
      }
      if (cnt == 3) {
        ans++;
        break;
      }
    }
  }
  print(ans);
}


Measured memory_bytes: 512
#include<iostream>
#include<string.h>
#define int long long
using namespace std;
const int N=5e3+2;
const int inf=1e18+2;
int dp[N],ar[N],lef[N],rig[N],pos[N],bit[N];
void upd(int pos){
	while(pos<N){
		bit[pos]++;
		pos+=(pos&-pos);
	}
}
int get(int idx){
	int sum=0;
	while(idx){
		sum+=bit[idx];
		idx-=(idx&-idx);
	}
	return sum;
}
int getsum(int l,int r){
	return get(r)-get(l-1);
}
signed main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	int n,i,j,k,l,a,b,ans=inf,idxans;
	cin>>n>>a>>b;
	for(i=1;i<=n;i++){
		cin>>ar[i];
		pos[ar[i]]=i;
	}
	for(i=1;i<=n;i++){
		for(j=1;j<i;j++){
			if(ar[j]>ar[i]){
				lef[ar[i]]++;
			}
		}
		for(j=i+1;j<=n;j++){
			if(ar[j]>ar[i]){
				rig[ar[i]]++;
			}
		}
	}
	for(i=1;i<=n;i++){
		dp[i]=(i-1)*b;
		for(j=1;j<=n;j++){
			bit[j]=0;
		}
		for(j=i-1;j>=1;j--){
			if(pos[j]<pos[i]&&getsum(pos[j],pos[i])==0){
//				if(dp[j]+getsum(1,pos[j]-1)*a+getsum(pos[i]+1,n)*b<dp[i]){
//					trace[i]=j;
//				}
				dp[i]=min(dp[i],dp[j]+getsum(1,pos[j]-1)*a+getsum(pos[i]+1,n)*b);
			}
			upd(pos[j]);
		}
		if(rig[i]==0){
//			if(dp[i]+lef[i]*a<ans){
//				idxans=i;
//			}
			ans=min(ans,dp[i]+lef[i]*a);
		}
		//cout<<dp[i]+lef[i]*a<<' '<<dp[i]<<' '<<i<<' '<<rig[i]<<endl;
	}
//	while(idxans){
//		cout<<idxans<<' ';
//		idxans=trace[idxans];
//	}
	cout<<ans;
}

Measured memory_bytes: 512
program main
      implicit none
      integer :: a, b, c

      read *, a, b, c

      if ( (a == b) .and. (b /= c)) then
        print *, 'Yes'
      else if ( (b == c) .and. (a /= c)) then
        print *, 'Yes'
      else if ( (a == c) .and. (b /= c)) then
        print *, 'Yes'
      else
        print *, 'No'
      end if

end program main



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
#include<complex>
#include<cassert>
using namespace std;

#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 4000001;
const long double eps = 1E-14;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll fr;
	ll to;
	ll d;
};

class mint {
	long long x;
public:
	mint(long long x = 0) : x((x% MOD + MOD) % MOD) {}
	mint operator-() const {
		return mint(-x);
	}
	mint& operator+=(const mint& a) {
		if ((x += a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator-=(const mint& a) {
		if ((x += MOD - a.x) >= MOD) x -= MOD;
		return *this;
	}
	mint& operator*=(const  mint& a) {
		(x *= a.x) %= MOD;
		return *this;
	}
	mint operator+(const mint& a) const {
		mint res(*this);
		return res += a;
	}
	mint operator-(const mint& a) const {
		mint res(*this);
		return res -= a;
	}
	mint operator*(const mint& a) const {
		mint res(*this);
		return res *= a;
	}

	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime MOD
	mint inv() const {
		return pow(MOD - 2);
	}
	mint& operator/=(const mint& a) {
		return (*this) *= a.inv();
	}
	mint operator/(const mint& a) const {
		mint res(*this);
		return res /= a;
	}

	friend ostream& operator<<(ostream& os, const mint& m) {
		os << m.x;
		return os;
	}
};

mint pw(mint a, ll b) {
	if (b == 0) { return 1; }
	mint ret = pw(a, b >> 1);
	ret *= ret;
	if (b & 1) { ret *= a; }
	return ret;
}

typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef vector<vector<vector<ll>>> vvvll;

typedef vector<mint> vmint;
typedef vector<vector<mint>> vvmint;
typedef vector<vector<vector<mint>>> vvvmint;

/////////////////////////////////////



int main() {
	ll d, t, s;
	cin >> d >> t >> s;
	if (s * t >= d) { cout << "Yes" << endl; }
	else { cout << "No" << endl; }
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e16;
const ll mod = 1000000007;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

template<class T> inline bool chmax(T& a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}
template<class T> inline bool chmin(T& a, T b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (b == 0) return a;
  return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}
bool is_prime(ll n) {
  for (ll i = 2; i*i <= n; i++) {
    if (n%i == 0) return false;
  }
  return n != 1;
}
ll mod_pow(ll x, ll n, ll mod) {
  if (n == 0) return 1;
  ll res = mod_pow(x*x%mod, n/2, mod);
  if (n & 1) res = res * x % mod;
  return res;
}

int main() {
  ll n, m;
  cin >> n >> m;
  ll tmp = n%m;
  cout << min(tmp, m-tmp) << endl;
}

Measured memory_bytes: 256
//hinagata.cpp
//作成日
//更新日
//目的
//手段
/*includes*/
#include <bits/stdc++.h>
/*namespace*/
using namespace std;
using ll= long long;
/*define macro*/
#define REP(i,n) for(ll i=0;i<(n);i++)
#define REPi(i,a,b) for(ll i=(a);i<(b);i++)
#define REPRi(i,a,b) for(ll i=(a);i>(b);i--)
#define ALL(x) (x).begin(),(x).end()

int main(){
    int N;
    cin>>N;
    vector<int> X(N);
    REP(i,N){
        cin>>X[i];
    }
    //inputend;
    ll min_num=LLONG_MAX;
    ll min_pos=-1;
    REPi(i,1,101){
        ll now=0;
        REP(j,N){
            now+=pow(abs(X[j]-i),2);
        }
        if(min_num>now){
            min_num=now;
            min_pos=i;
        }
    }
    cout<<min_num<<endl;
}

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

int main()
{
  map<string, int> mp = {{"1", 0}, {"9", 0}, {"7", 0}, {"4", 0}};
  string N;
  bool ans = true;
  
  for(int i = 0; i < 4; i++)
  {
    cin >> N;
    auto itr = mp.find(N);
    if(itr != mp.end())
      mp.at(N)++;
  }
  
  map<string, int>::iterator it;
  for(it = mp.begin(); it != mp.end(); it++)
  {
    if(it->second != 1)
    {
      ans = false;
      break;
    }
  }
  
  if(ans)
    cout << "YES" <<endl;
  else
    cout << "NO" << endl;
}

Measured memory_bytes: 256