akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep_(i, a_, b_, a, b, ...) for (int i = (a), i##_len = (b); i < i##_len; ++i)
#define rep(i, ...) rep_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define reprev_(i, a_, b_, a, b, ...) for (int i = (b-1), i##_min = (a); i >= i##_min; --i)
#define reprev(i, ...) reprev_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <int,int> P;
typedef long double ld;

struct UnionFind {
  vector< int > data;
 
  UnionFind(int sz) {
    data.assign(sz, -1);
  }
 
  bool unite(int x, int y) {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }
 
  int find(int k) {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }
 
  int size(int k) {
    return (-data[find(k)]);
  }
};

int main (void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m; cin >> n >> m;
    UnionFind uf(n);
    rep (i, m) {
        int x, y, z; cin >> x >> y >> z;
        x--; y--;
        uf.unite(x, y);
    }
    
    map<int, int> mmm; rep (i, n) mmm[uf.find(i)]++;
    cout << mmm.size() << "\n";

    return 0;
}

Measured memory_bytes: 5376
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
using namespace std;
int a[500000];
int main()
{
    int n,i,j;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&j);
        a[i]=j-i;
    }
    sort(a,a+n);
    long long ans=0;
    if(n%2==0)
    {
        int zhong1=n/2-1,zhong2=n/2;
        zhong1=a[zhong1];
        zhong2=a[zhong2];
        int zhong3=(zhong1+zhong2)/2;
        long long ans1=0,ans2=0,ans3=0;
        for(i=0;i<n;i++)
        {
            ans1=ans1+fabs(a[i]-zhong1);
            ans2=ans2+fabs(a[i]-zhong2);
            ans3=ans3+fabs(a[i]-zhong3);
        }
        ans=ans1>ans2?ans2:ans1;
        ans=ans>ans3?ans3:ans;
    }
    else
    {
        int zhong=a[n/2];
        for(i=0;i<n;i++)
        {
            ans=ans+fabs(a[i]-zhong);
        }
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 1024
# 3 * 3 の配列ができる
bingoArr = [list(map(int, list(input().split()))) for i in range(3)]

# 試行回数
N = int(input())

# ターゲット
target = [int(input()) for i in range(N)]

# [84 97 66]
for i in range(0, len(bingoArr)):
    for y in range(0, len(bingoArr[i])):
        for t in target:
            if bingoArr[i][y] == t:
                bingoArr[i][y] = -1
res = 'No'
if bingoArr[0][0] == -1 and bingoArr[0][1] == -1 and bingoArr[0][2] == -1:
    res = 'Yes'

if bingoArr[1][0] == -1 and bingoArr[1][1] == -1 and bingoArr[1][2] == -1:
    res = 'Yes'

if bingoArr[2][0] == -1 and bingoArr[2][1] == -1 and bingoArr[2][2] == -1:
    res = 'Yes'

if bingoArr[0][0] == -1 and bingoArr[1][0] == -1 and bingoArr[2][0] == -1:
    res = 'Yes'

if bingoArr[0][1] == -1 and bingoArr[1][1] == -1 and bingoArr[2][1] == -1:
    res = 'Yes'

if bingoArr[0][2] == -1 and bingoArr[1][2] == -1 and bingoArr[2][2] == -1:
    res = 'Yes'

if bingoArr[0][0] == -1 and bingoArr[1][1] == -1 and bingoArr[2][2] == -1:
    res = 'Yes'

if bingoArr[0][2] == -1 and bingoArr[1][1] == -1 and bingoArr[2][0] == -1:
    res = 'Yes'

print(res)

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

int main() {
  int N,M,K;
  cin>>N>>M>>K;
  vector<vector<int>> G(N);
  for(int i=0;i<M;i++){
    int a,b;
    cin>>a>>b;
    a--,b--;
    G.at(a).push_back(b);
    G.at(b).push_back(a);
  }
  vector<int> p(N);
  vector<int> c(N);
  for(int i=0;i<N;i++){
    if(p.at(i)==0){
      queue<int> q;
      queue<int> qp;
      int A=0;
      q.push(i);
      qp.push(i);
      p.at(i)=i+1;
      while(!(q.empty())){
        int a=q.front();
        q.pop();
        A++;
        for(int x:G.at(a)){
          if(p.at(x)==0){
            p.at(x)=i+1;
            q.push(x);
            qp.push(x);
          }
        }
      }
      while(!(qp.empty())){
        c.at(qp.front())=A;
        qp.pop();
      }
    }
  }
  for(int i=0;i<K;i++){
    int a,b;
    cin>>a>>b;
    a--,b--;
    if(p.at(a)==p.at(b)){
      c.at(a)--;
      c.at(b)--;
    }
  }
  for(int i=0;i<N;i++){
    cout<<c.at(i)-1-G.at(i).size()<<" ";
  }
  cout<<endl;
}

Measured memory_bytes: 7672
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc =new Scanner(System.in);
    long x =sc.nextLong();
    long y=100;
    double z;
    for(long i=1;;i++){
      z=y*1.01;
      y=(long)z;
      if(y>=x){System.out.println(i);System.exit(0);}
    }
  }
}

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

#define NREP() for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 0; i < n; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define IPT(t, x) t ipt; cin >> ipt; x.push_back(ipt);
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
//ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;
string s;

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

    MSG(n * (n - 1) / 2)
}


Measured memory_bytes: 256
#pragma region
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <map>
#include <queue> 
#include <stack>
#include <set>
#include <list>

using namespace std;
typedef long long ll;
//#define rep(i, s, e) for (int(i) = (s); (i) < (e); ++(i))
#define rep(i, e) for (int(i) = 0; (i) < (e); ++(i))
#define rrep(i, s) for (int(i) = (s) - 1; (i) >= 0; --(i))
#define all(x) x.begin(),x.end()
#pragma endregion


int main()
{
	string s; cin >> s;
	if (s[0] == s[1] && s[1] == s[2])cout << "No" << endl;
	else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define pb push_back
#define mod 1000000007
using ll = long long;
using namespace std;

int main(){
  int N; cin >> N;
  string S, T; cin >> S >> T;
  rep(i,N){
    cout << S[i] << T[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<iostream>
#include<string>
#include<algorithm>
#include<vector> 
#include<limits>
#include<numeric>
#include<type_traits>
#include<math.h>
#include <cctype>
#include <cstdio>
using namespace std;
typedef long long ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = (int)(a); i < (int)(b); i++)
#define in(x) cin >> x
#define out(str) cout << str << endl

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

string S;

int main(){
    rep(i,3){
        cin>>S;
        transform(S.begin(),S.end(),S.begin(), ::toupper);
        cout << S[0];
    }
    out("");
}


Measured memory_bytes: 256
def main():
    N = int(input())
    w = list(map(int, input().split()))
    record = []
    t = 0
    for i in range(1, N):
        t = t + w[i-1]
        record.append(abs(t - sum(w[i:N])))
    record.sort()
    print(record[0])
main()  

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

using ll = long long;
#define countof(a) (sizeof(a)/sizeof((a)[0]))
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i < (n); i++)
#define all(a) begin(a),end(a)
template<class T> istream& operator >> (istream& s, vector<T>& v)
{ for (T& x: v) { s >> x; } return s;}
template<class T> void cout_v(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << endl; }
template<class T> void cout_h(const vector<T>& c)
{ for (int i = 0; i < c.size(); i++) cout << c[i] << (i==c.size()-1?"\n":" "); }
template<class T> inline bool chmin(T& a, T b) {return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b) {return a<b?a=b,true:false;}
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
// const int MOD = 1000000007;

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

    int a, b; cin >>a>>b;
    
    if (a <= 0 && 0 <= b) {
        cout << "Zero" << endl;
    } else if (a >= 1 || (b - a) % 2) {
        cout << "Positive" << endl;
    } else {
        cout << "Negative" << endl;
    }
}


Measured memory_bytes: 256
# coding: utf-8

import sys
import math
import collections
import itertools
import bisect
INF = 10 ** 13
MOD = 10 ** 9 + 7
def input() : return sys.stdin.readline().strip()
def gcd(x, y) : return x if y == 0 else gcd(y, x%y)
def lcm(x, y) : return (x * y) // gcd(x, y)
def I() : return int(input())
def LI() : return [int(x) for x in input().split()]
def RI(N) : return [int(input()) for _ in range(N)]
def LRI(N) : return [[int(x) for x in input().split()] for _ in range(N)]
def LS() : return input().split()
def RS(N) : return [input() for _ in range(N)]
def LRS(N) : return [input().split() for _ in range(N)]
def PL(L) : print(*L, sep="\n")
def YesNo(B) : print("Yes" if B else "No")
def YESNO(B) : print("YES" if B else "NO")

X, N = LI()
P = LI()

for i in range(1000):
    if not(X - i in P):
        print(X-i)
        break
    if not(X + i in P):
        print(X+i)
        break
    

Measured memory_bytes: 67236
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<(n);++i)
#define rep2(i,a,b) for (ll i=(a);i<(b);++i)
#define debug(x) cout << #x << '=' << x << endl
#define all(v) (v).begin(),(v).end()
const ll MOD=1e9+7;
//const ll MOD=998244353;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    vector<Pii> v(N);
    rep(i,N){
        int x; cin >> x;
        v[i]={--x,i+1};
    }
    sort(all(v));
    vector<int> ans,cnt(N,0);
    int now1=0,now2=0;
    bool round=false;
    rep(i,N*N){
        if (now1<N&&i==v[now1].first){
            int x=v[now1].second;
            if (cnt[x-1]!=x-1){
                cout << "No" << endl;
                return 0;
            }
            ans.push_back(x);
            ++cnt[x-1];
            ++now1;
        }
        else {
            if (!round&&v[now2].second==1){
                ++now2;
                if (now2==N) round=true,now2=0;
            }
            if (round&&v[now2].second==N){
                if (cnt[N-1]<N){
                    cout << "No" << endl;
                    return 0;
                }
                ++now2;
            }
            int x=v[now2].second;
            if (round&&cnt[x-1]<x){
                cout << "No" << endl;
                return 0;
            }
            ans.push_back(x);
            ++cnt[x-1];
            if (!round&&cnt[x-1]==x-1){
                ++now2;
                if (now2==N) round=true,now2=0;
            }
            if (round&&cnt[x-1]==N) ++now2;
        }
    }
    cout << "Yes" << endl;
    rep(i,N*N){
        cout << ans[i];
        if (i!=N*N-1) cout << ' ';
        else cout << endl;
    }
}

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

long long x,y,z;
int main()
{
	cin>>x>>y>>z;
	for(int i=0;i<=100000;i++)
	{
		if(y*i+(i+1)*z<=x)
		{
			if(y*(i+1)+(i+2)*z>x)
			cout<<i;
		}
    }
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <climits>
#include <cstdlib>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define DEBUG 1
using namespace std;
constexpr int kMod = 1000000007;
typedef long long LL;

int main() {
  deque<char> S;
  string s; cin >> s;
  for (char c : s) {
    S.push_back(c);
  }

  int N; cin >> N;
  bool reverse = false;
  for (int i = 0; i < N; ++i) {
    int T; cin >> T;
    if (T == 1) {
      reverse = !reverse;
    } else {
      int F; cin >> F;
      char C; cin >> C;
      if (F == 1) {
        if (!reverse) S.push_front(C);
        else          S.push_back(C);
      } else {
        if (!reverse) S.push_back(C);
        else          S.push_front(C);
      }
    }
  }

  if (!reverse) {
    while(!S.empty()) {
      cout << S.front();
      S.pop_front();
    }
    cout << endl;
  } else {
    while(!S.empty()) {
      cout << S.back();
      S.pop_back();
    }
    cout << endl;
  }
}


Measured memory_bytes: 896
#include <vector>
#include <list>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <cassert>
using namespace std;
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define EACH(t,i,c) for(t::iterator i=(c).begin(); i!=(c).end(); ++i)
const double EPS = 1e-10;
const double PI  = acos(-1.0);

double aa(int v,int c){
	return (double)c/v;
}

int main(){
	int n;
	cin>>n;
	int a,b,c;
	cin>>a>>b>>c;
	vi d(n);
	REP(i,n){
		cin>>d[i];
	}
	sort(RALL(d));
	int value=a,cal=c;
	REP(i,n){
		if(aa(value+b,cal+d[i])>aa(value,cal)){
			value+=b;
			cal+=d[i];
		}
	}
	cout<<(int)aa(value,cal)<<endl;
}

Measured memory_bytes: 1200
using System;
class Program
{
	static void Main(string[] args)
	{
		string[] input = Console.ReadLine().Split(' ');
		int l = int.Parse(input[0]);
		int r = int.Parse(input[1]);
		int d = int.Parse(input[2]);

		int count = 0;

		for(int i = l; i <= r; i++){
			if(i % d == 0){
				count++;
			}
		}

		Console.WriteLine(count);
	}
}


Measured memory_bytes: 27376
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>
#include <fstream>
#include <bitset>
#include <time.h>
#include <tuple>

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef complex<double> Point;

#define PI acos(-1.0)
#define EPS 1e-10
const ll INF = 1e12;
const ll MOD = 1e9 + 7;

#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,N) for(int i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define EQ(a,b) (abs((a)-(b))<EPS)
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
#define fi first
#define se second
#define N_SIZE (1LL << 20)
#define NIL -1
#define MAX_N 100100 * 3

ll n, m;
int x[100100];
int y[100100];
ll cntx[100100];
ll cnty[100100];

int main() {
	cin >> n >> m;
	rep(i, n)cin >> x[i];
	rep(i, m)cin >> y[i];
	bool f = 1;
	ll cnt = n - 1;
	rep(i, (n - 1) / 2 + 1) {
		cntx[i] = cnt;
		cntx[n - 2 - i] = cnt;
		cnt += ((n - 1) - 2 * (i + 1));
		cnt %= MOD;
	}
	cnt = m - 1;
	rep(i, (m - 1) / 2 + 1) {
		cnty[i] = cnt;
		cnty[m - 2 - i] = cnt;
		cnt += ((m - 1) - 2 * (i + 1));
		cnt %= MOD;
	}

	ll ansx = 0, ansy = 0;
	rep(i, n - 1) {
		ansx += (x[i + 1] - x[i])*cntx[i] % MOD;
		ansx %= MOD;
	}
	rep(i, m - 1) {
		ansy += (y[i + 1] - y[i])*cnty[i] % MOD;
		ansy %= MOD;
	}
	cout << ansx*ansy%MOD << endl;
}

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

int a, b;

void input() {
    cin >> a >> b;
}

void solve() {
    if(a < 10 && b < 10) {
        cout << a * b <<endl;
    } else {
        cout << "-1" << endl;
    }
}

int main() {
    input();
    solve();

}


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

int main(){
    int K, X;
    cin >> K >> X;
    vector<int> A(2*K-1);
    int p = X - (K-1);
    for(int i=0; i<2*K-1; i++){
        A.at(i) = p;
        cout << p << " ";
        p++;
    }
    cout << endl;
}

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

int main(){
    int n;
    scanf("%d",&n);
    if(n%10==3){
        printf("bon");
    }
    else if(n%10==0 || n%10==1 || n%10==6 || n%10==8 ){
        printf("pon");
    }
    else{
        printf("hon");
    }
    return 0;
}


Measured memory_bytes: 1728
#include <iostream>
#include <math.h>

using namespace std;

// 2^1 = 3 2^2 = 7 2^3 = 15
// 2^(n+1)-1
// 10^12 < 2^40
#define rep(i, a, n) for(int i = a; i < (n); ++i)

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

  long long pre = 1, next = 1;
  long long ans = 1;
  rep(i, 1, 41)
  {
    next = pow(2, i);
    if (next == h) {
      ans = pow(2, i+1) - 1;
      break;
    }
    if (pre < h && h < next)
    {
      ans = pow(2, i) - 1;  
      break;
    }
    pre = next;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
from collections import deque
N,M = map(int, input().split())
dic = [[] for i in range(N+1)]
for i in range(M):
  a,b = map(int, input().split())
  dic[a].append(b)
  dic[b].append(a)
ans = [-1]*(N+1)
ans[1] = 0
q = deque([1])
while q:
  p = q.popleft()
  for v in dic[p]:
    if ans[v]==-1:
      ans[v] = p
      q.append(v)
if all(-1!=c for c in ans[1:]):
  print('Yes')
  for i in range(2,N+1):
    print(ans[i])
else:
  print('No')

Measured memory_bytes: 34740
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn = new Scanner(System.in);
		String s = scn.next();
		if(res(s)){
			System.out.println("Yes");
		}else{
			System.out.println("No");
		}

	}
	public static boolean res(String s){
		
		if(s.length()%2!=0){
			return false;
		}
		for(int i=0;i<s.length();i+=2){
			if(s.charAt(i)=='h' && s.charAt(i+1)=='i'){
				
			}else{
				return false;
			}
		}
		
		
		return true;
	}

}

Measured memory_bytes: 23636
#include<iostream>
#include<string>
#include<vector>
using namespace std;
 
int main(){
    string S;
    cin >> S;
 
    vector<string> tokens = {"dream", "dreamer", "erase", "eraser"};
 
    while (S.size() > 0) {
        bool hit = false;
        for(int i=0; i<tokens.size(); i++) {
            string t = tokens[i];
            if (S.size() >= t.size() && S.substr(S.size() - t.size(), t.size()) == t) {
                S = S.substr(0, S.size() - t.size());
                hit = true;
                break;
            }
        }
        if (!hit) {
            cout << "NO" << endl;;
            return 0;
        }
    }
 
    cout << "YES" << endl;;
    return 0;
}


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

#define pb push_back
#define eb emplace_back
#define mk make_pair
#define fi first
#define se second

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

const int INF = 0x3f3f3f3f;
const int MAXN = 1e5 + 5;
const int MOD = 1e9 + 7;

inline int mul(int a, int b) {
	return (long long)(a) * b % MOD;
}

inline int add(int a, int b) {
	a += b;
	if (a >= MOD) a -= MOD;
	return a;
}

inline int inv(int a) {
	int b = MOD - 2, res = 1;
	while (b > 0) {
		if (b & 1) res = mul(res, a);
		a = mul(a, a);
		b >>= 1;
	}
	return res;
}

inline int lcm(int a, int b) {
	return mul(mul(a, b), __gcd(a, b));
}

int a[MAXN];
int main() {
	int n; scanf("%d", &n);
	for (int i = 1; i <= n; i++) scanf("%d", a+i);

	map<int, int> factors;
	for (int i = 1; i <= n; i++) {
		map<int, int> cur;

		int x = a[i];
		for (int j = 2; j * j <= x; j++) {
			while (x%j == 0) {
				x /= j;
				cur[j]++;
			}
		}
		cur[x]++;

		for (auto p : cur) {
			factors[p.fi] = max(factors[p.fi], p.se);
		}
	}

	int m = 1;
	for (auto p : factors) {
		while(p.se) {
			m = mul(m, p.fi);
			p.se--;
		}
	}

	int sum = 0;
	for (int i = 1; i <= n; i++) sum = add(sum, mul(m, inv(a[i])));
	printf("%d\n", sum);
}

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

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

  if (a >= 3200)
    cout << s << endl;
  else
    cout << "red" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  char a[3];
   for(int i=0;i<3;i++){
    cin>>a[i];
  }
  if((a[0]=='R') && (a[1]== 'R') && (a[2]=='R'))
  cout<<3<<endl;
  else if((a[0]=='R' && a[1]=='R') || (a[1]=='R' && a[2]=='R'))
    cout<<2<<endl;
  else if((a[0]=='R') ||(a[1]=='R')||(a[2]=='R'))
    cout<<1<<endl;
  else cout<<0<<endl;
  return 0;
}


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

#define rep(i, a) for (int i = 0; i < (a); i++ )

 
typedef pair<int,int> P;
typedef long long ll;
 
const int INF = 1001001001;
const int MOD = 1000000007;
const double PI=acos(-1);

int main(){
    int N;
    cin >> N;
    ll A[N];
    rep(i,N) {
        ll a;
        cin >> a;
        A[i] =  a;
    }
    ll m = 1000;
    ll p = 0;
    rep(i,N) {
        m += A[i]*p;
        p = 0;
        if (i<N-1) {
            if (A[i]<A[i+1]) {
                p = m/A[i];
                m = m%A[i];
            }
        }

    }
    cout << m << endl;
}


Measured memory_bytes: 3596
#include <iostream>
using namespace std;
int main()
{
	int a[5];
	for(int i=0;i<5;i++)
	{
		cin>>a[i];
	}
	for(int i=0;i<5;i++)
	{
		if(a[i]==0)
		{
			cout<<i+1<<endl;
			break;
		}
	}
}

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


int main(){
	char ch;
	set<char> se;
	int n;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> ch;
		se.insert(ch);
	}
	
	if(se.size()==4) cout << "Four" << endl;
	else cout << "Three" << endl;
	return 0;
}

Measured memory_bytes: 256
n, k = map(int, input().split())
mod = 10 ** 9 + 7
premin = 0
premax = 0
ans = 0
list = [i for i in range(n + 1)]
for x in range(n + 1):
    premin += list[x]
    premax += list[n - x]
    if x < k - 1: continue
    ans += (premax - premin + 1)
    if ans >= mod: ans %= mod
print(ans)


Measured memory_bytes: 17024
S = list(input())
X, A = [], []
NX = ""

for i in range(len(S)):
    if S[i] == "x": X.append(i)
    else: 
        NX += S[i]
        A.append(i)
    
for i in range(len(NX)//2):
    if NX[i] != NX[-1-i]:
        print(-1)
        break
else:
    if NX == "": print(0)
    else:
        l, r = 0, len(S)-1
        midl = A[(len(NX)-1)//2]
        midr = (A[(len(NX)-1)//2] if len(NX)%2==1 else A[(len(NX)-1)//2 + 1])
        Add = 0
        while l < midl or r > midr:
            if S[l] == S[r] == "x":
                l += 1
                r -= 1
            elif S[l] == "x":
                l += 1
                Add += 1
            elif S[r] == "x":
                r -= 1
                Add += 1
            else:
                l += 1
                r -= 1
        print(Add)

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

#define int         long long
#define pb          push_back
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define x           first
#define y           second
#define sz(x)       (int)x.size()
#define endl        '\n'
#define hell        1000000007
#define rep(i,a,b)  for(int i=a;i<b;i++)
using namespace std;
int n;
vi a[200005];
vi b[200005];
void solve(){
    int ans=0,aa=0,bb=0;
    cin>>n;
    rep(i,0,n+1) a[i].clear(),b[i].clear();
    rep(i,0,n){
        int k,l,r;
        cin>>k>>l>>r;
        if(l>r){
            a[k].pb(l-r);
            aa=max(aa,k);
            ans+=r;
        }
        else if(r>l){
            b[n-k].pb(r-l); 
            bb=max(bb,n-k);
            ans+=l;
        }
        else ans+=l;
    }
    priority_queue<int> pq;
    for(int i=aa;i>=1;i--){
        for(auto j:a[i]) pq.push(j);
        if(pq.empty()) continue;
        ans+=pq.top();
        pq.pop();
    }
    while(!pq.empty()) pq.pop();
    for(int i=bb;i>=1;i--){
        for(auto j:b[i]) pq.push(j);
        if(pq.empty()) continue;
        ans+=pq.top();
        pq.pop();
    }
    cout<<ans<<endl;
}

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 17588
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define FORR(i, m, n) for (int i = m; i >= n; i--)
#define ALL(x) (x).begin(), (x).end()
const long long INF = 1e18;
using namespace std;
typedef long long ll;

vector<ll> divisor(ll n) {
  vector<ll> ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}

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

  ll sum = 0;
  REP(i, N) sum += A[i];

  auto div = divisor(sum);

  ll ans = 1;
  for (auto x : div) {
    ll need = INF;
    ll r[N];
    REP(i, N) r[i] = A[i] % x;
    sort(r, r + N);
    ll A = 0, B = 0;
    REP(i, N) B += x - r[i];
    REP(i, N) {
      A += r[i];
      B -= x - r[i];
      need = min(need, max(A, B));
    }

    if (need <= K) ans = max(ans, x);
  }

  cout << ans;

  return 0;
}

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

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;

const int INF = 1 << 29;
const double EPS = 1e-9;
const ll MOD = 1000000007;

const int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};
int N;
vector<int> T,A;
vector<bool> Tb,Ab;
bool check(){
  int max_cho = -114514;
  int max_ao = -114514;
  for (int i = 0; i < N; i++){
    if (max_cho != T[i]){
      if (T[i] > A[i]){
        return false;
      }
    }
    max_cho = max(max_cho, T[i]);
  }
  for (int i = N - 1; i >= 0; i--){
    if (max_ao != A[i]){
      if (A[i] > T[i]){
        return false;
      }
    }
    max_ao = max(max_ao, A[i]);
  }
  return true;
}
int main() {
  cin >> N;
  T.resize(N);
  A.resize(N);
  Tb.resize(N, false);
  Ab.resize(N, false);

  for (auto &val : T){
    cin >> val;
  }
  for (auto &val : A){
    cin >> val;
  }
  if (not check()){
    cout << 0 << endl;
    return 0;
  }
  int prev = -1;
  for (int i = 0; i < N; i++){
    if (prev == T[i]){
      Tb[i] = true;
    }
    prev = T[i];
  }
  prev = -1;
  for (int i = N - 1; i >= 0; i--){
    if (prev == A[i]){
      Ab[i] = true;
    }
    prev = A[i];
  }
  ll ans = 1;

  for (int i = 0; i < N; i++){
    if (Tb[i] and Ab[i]){
      ans = ans * min(T[i], A[i]) % MOD;
    }
  }
  cout << ans << endl;




  return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#define ll long long
#define f(i, n) for (int i=1; i < n; i++)
// sort(bb, bb+n);

using namespace std;
int main()
{
    std::ios::sync_with_stdio(false);
    int a,b,c;
    cin >>a>>b>>c;
    cout<<c<<" "<<a<<" "<<b;
    return 0;
}

Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::{min,max};
#[allow(unused_imports)]
use std::collections::{BTreeMap,BTreeSet};
#[allow(unused_imports)]
use std::ops::*;
#[allow(unused_imports)]
use std::collections::BinaryHeap;

#[allow(unused_macros)]
macro_rules! tf {
    ($c:expr, $t:expr, $f:expr) => {{
        if $c { $t } else { $f }
    }};
}

struct BIT<T> {
    xs: Vec<T>,
    n: usize,
}

// 0-indexed
impl<T:Add<T,Output=T>+Sub<T,Output=T>+Default+Clone+Copy> BIT<T> {
    fn new(n: usize) -> BIT<T> {
        let mut m = 1;
        while m <= n {
            m *= 2;
        }
        let n = m;
        BIT::<T> {
            xs: vec![T::default(); n+1],
            n: n
        }
    }
    fn sum(&self, i: usize) -> T {
        let mut i = i + 1;
        let mut res = T::default();
        while i > 0 {
            res = res + self.xs[i];
            i = i - (1usize << i.trailing_zeros());
        }
        res
    }
    fn range_sum(&self, l: usize, r: usize) -> T {
        self.sum(r-1) - self.sum(l-1)
    }
    fn add(&mut self, i: usize, x: T) {
        let mut i = i + 1;
        while i <= self.n {
            self.xs[i] = self.xs[i] + x;
            i = i + (1usize << i.trailing_zeros())
        }
    }
}

fn main() {
    let (n,q) = {
        let xs = read_vec_i64();
        (xs[0] as usize, xs[1] as usize)
    };
    let mut bit: BIT<i64> = BIT::new(n);
    for i in 0..q {
        let (com,x,y) = {
            let xs = read_vec_i64();
            (xs[0] as usize, xs[1] as usize, xs[2] as usize)
        };
        if com == 0 {
            bit.add(x, y as i64);
        }
        if com == 1 {
            let res = bit.range_sum(x, y+1);
            println!("{}", res);
        }
    }
}

#[allow(dead_code)]
fn read_line() -> String {
    let mut ret = String::new();
    std::io::stdin().read_line(&mut ret).ok();
    ret.pop();
    //ret.pop();
    return ret;
}

#[allow(dead_code)]
fn read_i64() -> i64 {
    let ss = read_line();
    return ss.parse::<i64>().unwrap();
}

#[allow(dead_code)]
fn read_vec_i64() -> Vec<i64> {
    let mut res = vec![];
    let ss = read_line();
    for ts in ss.split_whitespace() {
        let x = ts.parse::<i64>().unwrap();
        res.push(x);
    }
    return res;
}

use std::fmt::Display;
#[allow(dead_code)]
fn write_vec<T: Display>(xs: &Vec<T>) {
    if xs.len() == 0 {
        println!("");
        return;
    }
    print!("{}", xs[0]);
    for i in 1..xs.len() {
        print!(" {}", xs[i]);
    }
    println!("");
}



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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) (((a)+(b)-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define MOD 1000000007
#define INF LLONG_MAX/2
#define PI acos(-1.0)
#define SUM(v) accumulate((v).begin(),(v).end(),0ll)
#define range(i,left,right) (left<=i && i<right)

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;
typedef priority_queue<int> PQi;

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;}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vout(Vs &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
void vvout(VVi &v){for(int i=0;i<(v).size();i++) vout(v[i]);}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
int mypow(int x, int n, int m){if(n==0)return 1;if(n%2==0)return mypow(x*x%m,n/2,m);else return x*mypow(x,n-1,m)%m;}
int digit(int k,int i){string s = to_string(k);return s[s.size()-i]-'0';}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());} //vectorの同じ要素消す
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
int leng(int n){string s=to_string(n); return s.size();} //intの桁数
int digitsum(int n){int ret=0; while(n>0){ret+=n%10;n/=10;}return ret;} //桁和
int lesscount(int x,Vi &a){return lower_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx未満の数の個数
int orlesscount(int x,Vi &a){return upper_bound(a.begin(),a.end(),x)-a.begin();} //vector aにおけるx以下の数の個数
int morecount(int x,Vi &a){return a.size()-orlesscount(x,a);} //vector aにおけるxより大きい数の個数
int ormorecount(int x,Vi &a){return a.size()-lesscount(x,a);} //vector aにおけるx以上の数の個数
int iscount(int x,Vi &a) {return upper_bound(ALL(a),x)-lower_bound(ALL(a),x);} //vector aにおけるxの個数
Vi accum(Vi &v){Vi ret((v).size()+1);REP(i,0,(v).size()) ret[i+1]=ret[i]+v[i];return ret;}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

signed main(){cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);
    string s;
    cin>>s;
    if(s=="ABC") cout<<"ARC"<<endl;
    else cout<<"ABC"<<endl;
    return 0;
}


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

typedef long long ll;

ll MOD = 1000000007;

int main(){
    int N;
    cin >> N;
    vector<vector<vector<vector<ll>>>> dp(N+1,vector<vector<vector<ll>>>(4,vector<vector<ll>>(4, vector<ll>(4,0))));
    int A=0,C=1,G=2,T=3;
    // AGC / GAC / ACG / AXGC / AGXC がダメ
    dp[0][3][3][3] = 1;
    for (int len = 0; len < N; len++){
        for (int i = 0; i < 4; i++){
            for (int j = 0; j < 4; j++){
                for (int k = 0; k < 4; k++){
                    if (dp[len][i][j][k] == 0) continue;
                    
                    for (int a = 0; a < 4; a++){
                        if (a == C && i == G && j == A) continue;
                        if (a == C && i == A && j == G) continue;
                        if (a == G && i == C && j == A) continue;
                        if (a == C && i == G && k == A) continue;
                        if (a == C && j == G && k == A) continue;
                        
                        dp[len + 1][a][i][j] += dp[len][i][j][k];
                        dp[len + 1][a][i][j] %= MOD;
                    }
                }
            }
        }
    }
    
    ll ans = 0;
    
    for (int i = 0; i < 4; i++){
        for (int j = 0; j < 4; j++){
            for (int k = 0; k < 4; k++){
                ans += dp[N][i][j][k];
                ans %= MOD;
            }
        }
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 384
import math
def sum_digit(num):
	ans = 0
	current = num
	while current > 0:
		a = current%10
		ans += a
		current = current//10
	print(int(ans))
	
while True:
	num = int(input())
	if int(num) == 0:
		break	
	else:
		sum_digit(num)


Measured memory_bytes: 5656
#include <bits/stdc++.h>
using namespace std;
#define popcnt(a) __builtin_popcount(a)
#define FastIO() ios::sync_with_stdio(false), cin.tie(0);
#define IO() freopen("palindrome.in","rw",stdin)
#define error(args...)                       \
{                                            \
    cerr<<"LINE "<<__LINE__;                 \
    string _s = #args;                       \
    replace(_s.begin(), _s.end(), ',', ' '); \
    stringstream _ss(_s);                    \
    istream_iterator<string> _it(_ss);       \
    err(_it, args);                          \
    cerr<<endl;                              \
}
void err(istream_iterator<string> it)
{
} 
template <typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args)
{
  cerr<<' '<< *it << " = " << a ;
  err(++it, args...);
} 
typedef long long LL;
const LL MOD = 1e9 + 7;
const int N = 1e6+9, M = (1<<31), OO = 0x3f3f3f3f;
priority_queue<double,vector<double>,greater<double>>pq;

int main()
{
  int n;
  scanf("%d",&n);
  for(int i=0;i<n;++i)
  {
    double x;
    scanf("%lf",&x);
    pq.push(x);
  }
  double res =0;
  while(!pq.empty())
  {
    double x,y;
    x = pq.top();
    pq.pop();
    y = pq.top();
    pq.pop();
    res = (x+y)/2;
    if(pq.empty()) break;
    pq.push(res);
  }
  printf("%.5lf",res);
  #ifdef _LOCAL_DEFINE
  cerr << (double)clock() * 1.0 / CLOCKS_PER_SEC << endl;
  #endif
  return 0; 
}

Measured memory_bytes: 256
# import sys
# input = sys.stdin.readline
n, a, b, c = map(int,input().split())
S = [input() for i in range(n)]
A = [a,b,c]

D = {"A":0, "B":1, "C":2}
E = ["A","B","C"]
ANS = []
ng = 0

for i in range(n):
    x = D[S[i][0]]
    y = D[S[i][1]]

    if A[x] > A[y]:
        A[x] -= 1
        A[y] += 1
        ANS.append(E[y])
    elif A[y] > A[x]:
        A[y] -= 1
        A[x] += 1
        ANS.append(E[x])
    else:
        if A[x] == 0 and A[y] == 0:
            ng = 1
            break
        elif A[x] == 1 and A[y] == 1 and i != n-1:
            xx = D[S[i+1][0]]
            yy = D[S[i+1][1]]
            if S[i] != S[i+1] and (xx == x or yy == x):
                A[x] += 1
                A[y] -= 1
                ANS.append(E[x])
            else:
                A[y] += 1
                A[x] -= 1
                ANS.append(E[y])
        else:
            A[y] += 1
            A[x] -= 1
            ANS.append(E[y])

if ng == 1:
    print("No")
else:
    print("Yes")
    for i in range(len(ANS)):
        print(ANS[i])

Measured memory_bytes: 84812
#include <iostream>
#include <vector>
#include <set>
#include <numeric>
using namespace std;
 
int main() {
    int n; cin >> n;
    vector<int> a(n);
    for (auto &e : a) cin >> e;

    set<int> primes;
    bool pairwise = true;

    for (int i = 0; i < n && pairwise; ++i) {
        int c = a[i];
        for (int j = 2; j * j <= c; ++j) {
            if (c % j) continue;
            while (c % j == 0) c /= j;
            pairwise = primes.find(j) == primes.end();
            primes.insert(j);
        }
        if (c != 1) {
            pairwise = primes.find(c) == primes.end();
            primes.insert(c);
        }
    }

    if (pairwise) {
        cout << "pairwise coprime" << endl;
        return 0;
    }

    int p = a[0];
    for (int i = 1; i < n; ++i) p = gcd(p, a[i]);

    if (p == 1) {
        cout << "setwise coprime" << endl;
        return 0;
    }

    cout << "not coprime" << endl;
}



Measured memory_bytes: 7280
unittest
{
	assert( [ "3", "2 5" ].parse.expand.solve == 9 );
	assert( [ "2", "3" ].parse.expand.solve == 6 );
	assert( [ "6", "0 153 10 10 23" ].parse.expand.solve == 53 );
}



import std.algorithm;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.to!( long );
	input.popFront;
	auto bs = input.front.split.to!( long[] );
	return tuple( n, bs );
}

auto solve( long n, long[] bs )
{
	bs ~= long.max;
	auto ans = bs.front;
	auto a = bs.front;
	for( auto i = 0L; i + 1 < bs.length; i++ )
	{
		a = min( bs[ i ], bs[ i + 1 ] );
		ans += a;
	}
	return ans;
}


Measured memory_bytes: 256
/*
Problem

Category
全探索・全列挙

URL:
https://atcoder.jp/contests/sumitrust2019/tasks/sumitb2019_d


考察:

Date: 2020/04/01
*/

#include <bits/stdc++.h>
// #include "../utils.cpp"
using namespace std;
// #define int long long

/* ==== declarations ====== */
// functions
void solve();
void getInput();

// global variables
int N;
string S;
std::vector<int> v;

/* ======================== */

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

void getInput() {
    cin>>N;
    cin>>S;
    for (auto c: S) {
        v.push_back(c - '0');
    }
}

void solve() {
    int res = 0;
    for(int i =0; i<10; ++i) {
        for (int j=0; j<10; ++j) {
            for (int k=0; k<10; ++k) {
                int phase = 0;
                for(auto n: v) {
                    int e = 0;
                    switch(phase) {
                        case 0: e = i; break;
                        case 1: e = j; break;
                        case 2: e = k; break;
                        case 3: break;
                    }
                    if(phase==3)break;
                    if (n==e) phase++;
                }
                if(phase==3) ++res;
                //    cout<<"phase of "<<i<<j<<k<<": "<<phase<<endl;
            }
        }
   }
   cout<<res<<endl;
}

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

int main()
{
    string a;
    cin >> a;
    int count = 0;
    for(int i = 0; i < a.size(); i++) {
        if(a.at(i) == '1') {
            count++;
        }
    }
    cout << count << endl;
    return 0;
}

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

using namespace std;

using int64 = long long;
const int64 INF = 1LL << 60;

int main() {
  int64 N, A[100000], B[100000], C[100000];
  cin >> N;
  vector< pair< int64, int > > more;
  vector< int > less;
  for(int i = 0; i < N; i++) {
    cin >> A[i];
    C[i] = A[i];
  }
  for(int i = 0; i < N; i++) {
    cin >> B[i];
    if(A[i] >= B[i]) more.emplace_back(A[i] - B[i], i);
    else less.emplace_back(i);
  }
  sort(more.begin(), more.end());
  for(auto p : less) {
    while(A[p] < B[p]) {
      if(more.empty()) {
        cout << -1 << endl;
        return 0;
      }
      int64 get = min(B[p] - A[p], more.back().first);
      A[p] += get;
      A[more.back().second] -= get;
      more.back().first -= get;
      if(more.back().first == 0) {
        more.pop_back();
      }
    }
  }

  int ret = 0;
  for(int i = 0; i < N; i++) {
    ret += A[i] != C[i];
  }
  cout << ret << endl;
}


Measured memory_bytes: 4468
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0; i<(n); i++)
int n;
ll k, a[2][200005], c[3], b, l = -1e18, r = 1e18;
int main(){
	scanf("%d%lld", &n, &k);
	rep(i,n){
		scanf("%lld", &b);
		if(b>0) a[0][c[0]++] = b;
		else if(b<0) a[1][c[1]++] = -b;
		else c[2]++;
	}
	rep(i,2) sort(a[i],a[i]+c[i]);
	while(l+1 < r){
		ll m = (l + r) / 2, cnt = 0;
		if(m > 0){
			cnt += c[0] * c[1] + c[2] * (c[0]+c[1]) + c[2] * (c[2]-1) / 2;
			rep(o,2) rep(i,c[o]) cnt += upper_bound(a[o]+i+1,a[o]+c[o],(m-1)/a[o][i]) - (a[o]+i+1);
		}else rep(i,c[0]) cnt += a[1]+c[1] - upper_bound(a[1],a[1]+c[1],(-m)/a[0][i]);
		(cnt < k ? l : r) = m;
	}
	printf("%lld\n", l);
}

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

#ifdef LOCAL
#include "/home/shahraaz/bin/debug.h"
#else
#define db(...)
#endif

using ll = long long;
#define f first
#define s second
#define pb push_back
#define all(v) v.begin(), v.end()

const int NAX = 2e5 + 5, MOD = 1000000007;

struct Solution
{
    Solution() {}
    void solveCase();
};

void Solution::solveCase()
{
    string s, t;
    cin >> s >> t;
    int res = MOD;
    for (size_t i = 0; i < s.size(); i++)
    {
        int cnt = 0;
        for (size_t j = 0; j < t.size(); j++)
        {
            if (i + j >= s.size())
            {
                cnt = MOD;
                break;
            }
            if (s[i + j] != t[j])
                cnt++;
        }
        res = min(res, cnt);
    }
    cout << res << '\n';
}

int32_t main()
{
#ifndef LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
    int t = 1;
    // cin >> t;
    Solution mySolver;
    for (int i = 1; i <= t; ++i)
    {
        mySolver.solveCase();
#ifdef LOCAL
        cerr << "Case #" << i << ": Time " << chrono::duration<double>(chrono::steady_clock::now() - TimeStart).count() << " s.\n";
        TimeStart = chrono::steady_clock::now();
#endif
    }
    return 0;
}


Measured memory_bytes: 3660
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;

namespace MyProject
{
    class Program
    {
        static void Main(string[] args)
        {
#if Local
            var sw = new Stopwatch();
            sw.Start();
            Console.SetIn(new StreamReader("input.in"));
#endif

            var solver = new Solver();
            solver.Solve();
#if Local
            Console.WriteLine($"{sw.ElapsedMilliseconds}ms");
#endif
        }
    }

    class Solver
    {
        public void Solve()
        {
            var input = Console.ReadLine().Split().Select(elem => int.Parse(elem)).ToArray();
            var N = input[0];
            var K = input[1];

            double kakuritsu = 0;
            for (int i = 1; i <= N; i++)
            {
                if (i < K)
                {
                    kakuritsu += ((double)1 / (double)N) * Math.Pow(0.5, GetFrontCount(i, K));
                }
                else
                {
                    kakuritsu += ((double)1 / (double)N);
                }
            }

            Console.WriteLine(kakuritsu.ToString());
        }

        private int GetFrontCount(int val, int goal)
        {
            int count = 0;
            int work = val;
            while(work < goal)
            {
                count++;
                work *= 2;
            }

            return count;
        }
    }
}


Measured memory_bytes: 11220