akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int cnt[3];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    string s;
    int N;
    cin>>s;
    N=s.size();
    
    rep(i,N) cnt[(int)(s[i]-'a')]++;
    
    int mn=INF;
    rep(i,3) mn=min(mn,cnt[i]);
    
    string ans="YES";
    rep(i,3)if(cnt[i]-mn>1){
        ans="NO";
    }
    cout1(ans);
}

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

using namespace std;

int main() {
    int n, t, ans = 0, as;
    cin >> n >> t;
    for (int i = 0; i < t; ++ i) {
        cin >> as;
        ans += as;
    }
    if (ans >= n) cout << "Yes";
    else cout << "No";
}


Measured memory_bytes: 256
def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

N = int(input())
ans = 0
if N == 1:
    ans = 1
elif N % 2 == 0:
    ans = 0.5
else:
    ans = (N //2 + 1)/ N
print(ans)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> ii;
#define F first
#define S second
#define sqr(x) (x)*(x)
#define pb(x) push_back(x)
#define sz(x) (int)x.size()
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define rep(i,x,y) for(int i=x;i<(y);++i)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0)
/* start */

signed main(){
    IOS;
    int n; cin >> n;
    vector<int> a(n),ans;
    rep(i,0,n) cin >> a[i];
    rep(i,0,n){
        int chose=0,pos=0;
        for(int j = 0, cur = 0;j<n;++j){
            int at = j-cur+1;
            if(a[j]){
                if(a[j] == at){
                    chose=a[j];
                    pos = j;
                }
            }
            else cur++;
        }
        if(chose+pos){
            ans.pb(chose);
            a[pos]=0;
        }
        else{
            cout << "-1\n";
            return 0;
        }
    }
    reverse(all(ans));
    rep(i,0,n) cout << ans[i] << "\n";
}

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

using namespace std;

#define ll long long

void solve() {
	string s;
	cin >> s;
	int c = 0;
	if (s[0]=='1') c++;
	if (s[1]=='1') c++;
	if (s[2]=='1') c++;
	cout << c << "\n";
}

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

	int t = 1, i = 1;
	//cin >> t;
	while(t--) {
		//cout << "Case #" << i << ": ";
		solve();
		//i++;
	}
	return 0;
}



Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <string>
#define _USE_MATH_DEFINES
#include <cmath>
#include <algorithm>
#include <utility>
#include <queue>

#define inf  1000000007
#define ll long long
#define PA pair<int,int>
#define PPAP pair<int,pa>
#define  MP make_pair
#define  PB push_back

using namespace std;

int main(){
	int x1,y1,x2,y2,n;
	cin >> x1 >> y1 >> x2 >> y2;
	cin >> n;
	if(x2<x1){
		swap(x1,x2);
		swap(y1,y2);
	}
	vector<PA> v;
	int X,Y;
	if(y1<=y2){
		for(int i=0;i<n;i++){
			cin >> X >> Y;
			if(x1<=X&&X<=x2){
				if(y1<=Y&&Y<=y2){
					v.PB(MP(X,Y));
				}
			}
		}
	}else{
		for(int i=0;i<n;i++){
			cin >> X >> Y;
			if(x1<=X&&X<=x2){
				if(-y1<=-Y&&-Y<=-y2){
					v.PB(MP(X,-Y));
				}
			}
		}
	}
	if(v.size()==0){
		int s = abs(x1-x2)+abs(y1-y2);
		cout << 100*s << endl;
		return 0;
	}
	sort(v.begin(),v.end());
	vector<int> a;
	for(int i=0;i<v.size();i++){
		a.PB(v[i].second);
	}
	long long dp[200010];
	fill(dp,dp+200010,inf);
	for(int i=0;i<v.size();i++){
		*lower_bound(dp,dp+v.size(),a[i])=a[i];
	}
	int c = lower_bound(dp,dp+v.size(),inf)-dp;
	int mi = min(abs(x1-x2),abs(y1-y2))+1;
	int s = abs(x1-x2)+abs(y1-y2);
	double ans;
	if(c<mi){
		ans = 100.0*s-(20.0-5.0*M_PI)*c;
		cout.precision(20);
		cout << ans << endl;
	}else{
		ans = 100.0*s-(20.0-5.0*M_PI)*(c-1)+(10.0*M_PI-20.0);
		cout.precision(20);
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 5616
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;

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

        var x = long.Parse(line[0]);
        var k = long.Parse(line[1]);
        var d = long.Parse(line[2]);

        var firstMoveCount = Math.Abs(x) / d;

        var firstMovedPlace = Math.Abs(x) % d;
        if(x < 0)
        {
            firstMovedPlace *= -1;
        }

        var rem = k - firstMoveCount;


        if (rem > 0)
        {
            if (rem % 2 == 0)
            {
                Console.WriteLine(Math.Abs(firstMovedPlace));
            }
            else
            {
                Console.WriteLine(Math.Abs(firstMovedPlace - d) > Math.Abs(firstMovedPlace + d) ? Math.Abs(firstMovedPlace + d) : Math.Abs(firstMovedPlace - d));
            }
        }
        else
        {
            var ans = Math.Abs(x) - (k * d);
            if (x < 0)
            {
                ans *= -1;
            }

            Console.WriteLine(Math.Abs(ans));
        }

        Console.ReadLine();
    }


}


Measured memory_bytes: 17932
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef int64_t LL;
typedef uint64_t ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
template<class T, class... U> void DEBUG(const T &head, const U &... tail) { 
#ifdef HOME
    _W('#'); _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...);
#endif
}
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int id=1;
int nxt[SIZE][2];
LL L;
map<LL,int>H;
LL last_bit(LL x){
    return x&-x;
}
void dfs(int x,int lv=0){
    if(lv==L)return;
    REP(i,2){
        if(!nxt[x][i])H[last_bit(L-lv)]^=1;
        else dfs(nxt[x][i],lv+1);
    }
}
int main(){
    int N;
    R(N,L);
    REP(i,N){
        string s;
        cin>>s;
        int now=0;
        REP(j,SZ(s)){
            int v=s[j]-'0';
            if(!nxt[now][v]){
                nxt[now][v]=id++;
            }
            now=nxt[now][v];
        }
    }
    dfs(0);
    for(auto p: H){
        if(p.S)return 0*puts("Alice");
    }
    puts("Bob");
    return 0;
}


Measured memory_bytes: 8988
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <complex>
#include <regex>

using namespace std;

#define SHOW_VECTOR(v) {std::cerr << #v << "\t:";for(const auto& xxx : v){std::cerr << xxx << " ";}std::cerr << "\n";}
#define SHOW_MAP(v){std::cerr << #v << endl; for(const auto& xxx: v){std::cerr << xxx.first << " " << xxx.second << "\n";}}


int main() {

    int N;
    cin >> N;

    for (int i = 111; i <= 999; i += 111) {
        if (N <= i) {
            cout << i << endl;
            return 0;
        }
    }

    return 0;
}











































































Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>; 
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
constexpr long long LINF = 1001001001001001001;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(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 main(){
    int n; cin >> n;
    map<string, int> mp;
    rep(i, n){
        string s; cin >> s;
        mp[s]++;
    }
    int m; cin >> m;
    rep(i, m){
        string s; cin >> s;
        mp[s]--;
    }
    int res = -INF;
    for(auto m: mp){
        int score = m.second;
        chmax(res, score);
    }
    chmax(res, 0);
    cout << res << ln;
}
    


Measured memory_bytes: 3608
--{-# LANGUAGE StandaloneDeriving #-}
--{-# LANGUAGE BangPatterns #-}

module Main where

import Debug.Trace
--import Data.List
--import Data.Char
--import qualified Data.Set.Strict as Set
--import qualified Data.Map.Strict as Map

main :: IO ()
main = do
  a <- read <$> getLine
  --a `traceShow`
  print $ solve a

solve :: Int -> Int
solve a
  | a > 1000 = solve (a - 1000)
  | otherwise = 1000 - a


Measured memory_bytes: 3832
#include <bits/stdc++.h>
#define r(i,n) for(int i = 0; i<n; i++)
using namespace std;
 
int main() {
  int q;
  map<string,int>m;
  cin >> q;
  while(q--){
    int x, y;
    string key;
    cin >> x >> key;
    if(!x){
      cin >> y;
      m[key]=y;
    }
    else if(x==1){
      cout << m[key] << endl;
    }
    else{
      m.erase(key);
    }
  }
}


Measured memory_bytes: 27840
#include"cstdio"
int main(){
	int a,b,c,d,min,max;
	scanf("%d%d%d%d",&a,&b,&c,&d);
	if(a<c)	min=c;
	else min=a;
	if(b<d) max=b;
	else max=d;
	if(max>min)
		printf("%d\n",max-min);
	else	printf("0\n");
	return 0;
}

Measured memory_bytes: 128
import sys
from itertools import accumulate, combinations
from math import atan2
read = sys.stdin.read

N, *xy = map(int, read().split())
xy = sorted(zip(*[iter(xy)] * 2), key=lambda x: atan2(x[1], x[0]))
xy = [(0, 0)] + xy

xy *= 2
xy = list(zip(*map(list, map(accumulate, zip(*xy)))))
answer = 0

for i, j in combinations(range(2 * N + 2), 2):
    if j - i <= N:
        x1, y1 = xy[i]
        x2, y2 = xy[j]
        candidate = (x1 - x2) ** 2 + (y1 - y2) ** 2
        if candidate > answer:
            answer = candidate

print(answer ** 0.5)

Measured memory_bytes: 3188
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)

function main()
	n = readline() |> parseInt
	a = readline() |> split |> parseMap
	f = 0
	b = zeros(Int,n)
	for i in 0:n-1
		t = 0
		for j in 2*(n-i):n-i:n
			t += b[j]
		end
		if t%2 == a[n-i]
			b[n-i] = 0
		else
			b[n-i] = 1
		end
	end
	if f == 1
		println(-1)
	else
		c = Int[]
		for i in 1:n
			if b[i] == 1
				push!(c,i)
			end
		end
		l = length(c)
		println(l)
		if l >0
			for i in 1:l-1
				print(c[i], " ")
			end
			println(c[l])
		end
	end
end

main()

Measured memory_bytes: 137992
#include<iostream>
using namespace std;
#define RIGHT 0
#define UP 1
#define BOTH 2

int W, H, mem[100][100][3][2];

int dp(int x, int y, int dir, bool turn)
{
  if(x == W - 1 && y == H - 1)
    return 1;
  if(mem[x][y][dir][turn] != -1)
    return mem[x][y][dir][turn];
  int ans = 0;
  if((dir == UP || dir == BOTH || turn) && y < H - 1)
    ans += dp(x, y + 1, UP, dir == UP || dir == BOTH);
  if((dir == RIGHT || dir == BOTH || turn) && x < W - 1)
    ans += dp(x + 1, y, RIGHT, dir == RIGHT || dir == BOTH);
  mem[x][y][dir][turn] = ans % 100000;
  return ans % 100000;
}

int main()
{
  while(1)
  {
    for(int i = 0; i < 100; i++)
      for(int j = 0; j < 100; j++)
        for(int k = 0; k < 3; k++)
          for(int l = 0; l < 2; l++)
            mem[i][j][k][l] = -1;
    cin >> W >> H;
    if(!W && !H)
      break;
    cout << dp(0, 0, BOTH, true) << endl;
  }
}

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

#define loop(i,n) for(int i = 0;i < int(n);i++)
#define rloop(i,n) for(int i = int(n);i >= 0;i--)
#define range(i,a,b) for(int i = int(a);i <= int(b);i++)
#define SZ(c) int(c.size())
#define ALL(c) c.begin(), c.end()
#define RALL(c) c.rbegin(), c.rend()
#define PI acos(-1)
#define pb push_back
#define mp make_pair
#define fr first
#define sc second
#define sfi1(v) scanf("%d",&v)
#define sfi2(v1,v2) scanf("%d %d",&v1,&v2)
#define sfi3(v1,v2,v3) scanf("%d %d %d",&v1,&v2,&v3)
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
#define endl '\n'

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


int main()
{

#ifndef ONLINE_JUDGE
	//freopen("in.in", "r", stdin);
	//freopen("out.in", "w", stdout);
#endif
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

    int n;
    cin >> n;
    int lst = -1 , ans = 0 , x , cur = 0;
    loop(i,n){
        cin >> x;
        if(lst >= x){
            cur++;
        }else{
            cur = 0;
        }
        ans = max(ans , cur);
        lst = x;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n; cin >> n;
    long long name[5] = {0,0,0,0,0};
    for(int i = 0; i < n; i++){
        string s; cin >> s;
        if(s[0] == 'M') name[0]++;
        if(s[0] == 'A') name[1]++;
        if(s[0] == 'R') name[2]++;
        if(s[0] == 'C') name[3]++;
        if(s[0] == 'H') name[4]++;
    }
    long long s = 0;

    for(int i = 0; i < 5; i++){
        for(int j = i+1; j < 5; j++){
            for(int k = j+1; k < 5; k++){
                s += name[i] * name[j] * name[k];
            }
        }
    }
    cout << s << endl;
}

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

snk = [0]*n

for i in range(k):
    d = int(input())
    ai = [int(i) for i in input().split()]
    for j in range(d):
        snk[ai[j]-1] = 1

ans = 0

for i in range(n):
    if snk[i] == 0:
        ans += 1
        
print(ans)

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

int main(){
	int N, T, c, t;
	cin >> N >> T;
	int min_cost = 1001; // init
	for (int i=0; i<N; ++i){
		cin >> c >> t;
		if (t <= T){
			min_cost = min(min_cost, c);
		}
	}
	if(min_cost==1001){
		cout << "TLE" << endl;
	} else {
		cout << min_cost << endl;
	}
	
	return 0;
}


Measured memory_bytes: 384
//Utkarsh-raj

#include<bits/stdc++.h>

#define ll long long int
#define vc vector
#define mod 100000000007
#define mp make_pair
#define pb push_back
#define nl cout<<endl;
#define ff first
#define ss second

using namespace std;

const ll MAX = 1e9+5;

int main()
{
    ifstream myFile("task.in");
    if(!myFile.fail())
    {
        assert(freopen("task.in", "r", stdin));
    }

    ll n, w;
    cin>>n>>w;

    ll max_value = 100000;

    vector<ll> dp(max_value+1, MAX);
    dp[0] = 0;

    ll cost[n+1], weight[n+1];
    for(ll i=1; i<=n; i++){
        cin>>weight[i]>>cost[i];
    }

    for(ll i=1; i<=n; i++){
        vector<ll> v(max_value+1, MAX);
        v[0] = 0;

        for(ll j=1; j<=max_value; j++){
            if(cost[i] <= j){
                v[j] = dp[j - cost[i]] + weight[i];
            }

            v[j] = min(v[j], dp[j]);
        }
        dp = v;
    }

    ll ans = 0;
    for(ll i=1; i<=max_value; i++){
        if(dp[i] <= w){
            ans = max(ans, i);
        }
    }

    cout<<ans<<endl;

    return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
//typedef vector<vector<ll>> Graph;

const ll mod = 1e9 + 7;
//const ll mod = 998244353;

#define REP(i,n) for(ll i=0;i<(ll)n;i++)
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define spa << " " <<
#define fi first
#define se second

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 (a>b) { a=b; return 1; } return 0; }

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}

template<typename T> void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cerr<<v[i][0];for(ll j=1;j<w;j++)cerr spa v[i][j];cerr<<endl;}};
template<typename T> void debug(vector<T>&v,ll n){if(n!=0)cerr<<v[0];
for(ll i=1;i<n;i++)cerr spa v[i];
cerr<<endl;};

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

    ll N;
    cin >> N;
    vector<ll> A(N);
    REP(i, N) cin >> A[i];

    const ll MA = 4000010;
    bitset<MA> dp;
    dp[0] = 1;

    REP(i, N){
        dp |= (dp << A[i]);
    }

    ll S = 0;
    REP(i, N) S += A[i];
    REP(i, MA){
        if(i>=(S+1)/2 and dp[i]>0){
        cout << i << endl;
        return 0;
        }
    }

    return 0;
}

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

//計算量の工夫

int main(){
  string s,s1,s2;
  cin >> s;
  int q;
  int counter = 0;//反転させた数。
  cin >> q;
  for(int i = 0; i < q; i++){
    int t;
    cin >> t;
    if(t==1){
      counter++;
    }else{
      int f;
      char c;
      cin >> f >> c;
      int bore = counter%2;
      if(bore==0){//反転させない
        if(f==1){
          s1 = c + s1;
        }else{
          s2 = s2 + c;
        }
      }else{//反転している。
        if(f==1){
          s2 = s2 +  c;
        }else{
          s1 = c + s1;
        }       
      }
    }
  }
  if(counter%2==0){
    cout << s1 << s << s2 << endl;
  }else{
    reverse(s.begin(),s.end());
    reverse(s1.begin(),s1.end());
    reverse(s2.begin(),s2.end());
    cout << s2 << s << s1 << endl;
  }
  return 0;
}



Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define sync ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int main(){
	sync
	long long a,b;
	cin >> a >> b;
	if(a>0) a--;
	long long a1[4]={a,1,a+1,0};
	long long b1[4]={b,1,b+1,0};
	long long ans=a1[a%4]^b1[b%4];
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
from operator import mul
from functools import reduce
from fractions import gcd
import math
import bisect
import itertools
import sys
sys.setrecursionlimit(10**7)
input = sys.stdin.readline
INF = float("inf")


#O(ElogV)
import heapq
def dijkstra_heap(G, si, sj, h, w):
    #始点sから各頂点への最短距離
    d = [[INF] * w for _ in range(h)]
    used = [[False] * w for _ in range(h)]
    d[si][sj] = 0
    used[si][sj] = True

    edgelist = []
    for edge in G[si][sj]:
        cost, i, j = edge[0], edge[1], edge[2]
        heapq.heappush(edgelist, [cost, i, j])
    
    while len(edgelist):
        minedge = heapq.heappop(edgelist)
        cost, i, j = minedge[0], minedge[1], minedge[2]
        # print([cost, i, j])
        if used[i][j]:
            continue
        d[i][j] = cost
        used[i][j] = True

        for edge in G[i][j]:
            cost, ni, nj = edge[0], edge[1], edge[2]
            if used[ni][nj]:
                continue
            heapq.heappush(edgelist, [cost + d[i][j], ni, nj])
    return d


def main():
    N, M, S = map(int, input().split())

    U = [0] * M
    V = [0] * M
    A = [0] * M
    B = [0] * M
    for i in range(M):
        U[i], V[i], A[i], B[i] = map(int, input().split())
        U[i] -= 1; V[i] -= 1
    
    L = max(A) * N
    G = [[[] for _ in range(L+1)] for _ in range(N)]
    for i in range(M):
        u, v, a, b = U[i], V[i], A[i], B[i]
        for money in range(L):
            if money - a >= 0:
                G[u][money].append([b, v, money - a])
                G[v][money].append([b, u, money - a])
    
    for station in range(N):
        c, d = map(int, input().split())
        for money in range(L):
            nmoney = money + c
            if nmoney > L:
                nmoney = L
            G[station][money].append([d, station, nmoney])
            G[station][nmoney].append([0, station, money])
    
    if S > L:
        S = L
    ans = dijkstra_heap(G, 0, S, N, L+1)
    for i in range(1, N):
        print(min(ans[i]))
    

if __name__ == '__main__':
    main()

Measured memory_bytes: 195224
#include<stdio.h>
#include<ctype.h>
int main(){
  int cnt[150]={0};
  int i,c;
  while((c=getchar())!=EOF){
    if(isupper(c)){
      c=tolower(c);
    }
    cnt[c]++;
  }
  for(i=97;i<=122;i++){
    printf("%c : %d\n",i,cnt[i]);
  }
}

Measured memory_bytes: 2668
//
//  main.cpp
//

#include <algorithm>
#include <array>
#include <assert.h>
#include <iomanip>
#include <iostream>
#include <limits>
#include <math.h>
#include <memory>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

using ll = int64_t;
using ull = uint64_t;

template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
    return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
    auto inner = make_vec_nd(init, rest...);
    return vector<decltype(inner)>(size, inner);
}

int main() {
    ll N, W;
    cin >> N >> W;
    vector<ll> wis;
    vector<ll> vis;
    for (ll i = 0; i < N; i++) {
        ll wi, vi;
        cin >> wi >> vi;
        wis.push_back(wi);
        vis.push_back(vi);
    }
    auto dp = make_vec_nd(numeric_limits<ll>::min(), N+1, W+1);
    dp[0][0] = 0;
    for (ll i = 1; i <= N; i++) {
        for (ll w = 0; w <= W; w++) {
            dp[i][w] = dp[i-1][w];
            if (w >= wis[i-1]) {
                dp[i][w] = max(dp[i][w], dp[i-1][w-wis[i-1]] + vis[i-1]);
            }
        }
    }
    ll ans = numeric_limits<ll>::min();
    for (ll w = 0; w <= W; w++) {
        ans = max(ans, dp[N][w]);
    }
    cout << ans << endl;
}



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

void solve(long long N, std::vector<long long> a){
    ll cnt = 0;
    for(auto i: a){
        ll tmp = i;
        while(tmp % 2 == 0){
            cnt++;
            tmp = tmp / 2;
        }
    }
    cout << cnt << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> a(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&a[i]);
    }
    solve(N, std::move(a));
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define MAX 1e15
#define ull unsigned long long  
using namespace std;
 
int main()
{
  ull n;
  cin>>n;
  char *str=(char *)malloc(1024*sizeof(char));
  ull i=0;
  while(n>0)
  {
    ull rem=n%26;
    if(rem==0)
    {
      str[i++]='z';
      n=(n/26)-1;
    }
    else
    {
      str[i++]=(rem-1)+'a';
      n/=26;
    }
  }
  str[i]='\0';
  reverse(str,str+strlen(str));
  cout<<str<<endl;
  return 0;
}

Measured memory_bytes: 3600
var
	A,B,C,K:Longint;
begin
	read(A,B,C,K);
	while A>=B do begin
		dec(K);
		B:=B*2;
	end;
	while B>=C do begin
		dec(K);
		C:=C*2;
	end;
	if K<0 then writeln('No')else writeln('Yes');
end.

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

#define mp make_pair
#define eb emplace_back
#define ff first
#define ss second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#ifdef ONPC
mt19937 rnd(228);
#else
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#endif


const int MAXN = 100;
//#define int long long
const int INF = 1e9;

void solve(){
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) cin >> a[i];

  map<int, int> m;
  for (int i = 0; i < n; i++) m[a[i]] = i;

  int cnt = 0;
  int j = 0;
  for (auto i : m) {
    if (j % 2 != i.ss % 2) cnt++;
    j++;
  }

  cout << cnt / 2 << '\n';
}

signed main()
{
    #ifdef FILEIO
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    solve();

    return 0;
}


Measured memory_bytes: 8324
[n, m] = list(map(int, input().split(' ')))
a_mat = []
for _ in range(n):
    a_vec = list(map(int, input().split(' ')))
    a_vec.pop(0)
    a_mat.append(a_vec)

m = [0] * m
for a_vec in a_mat:
    for a_val in a_vec:
        m[a_val - 1] = m[a_val - 1] + 1

print(len(list(filter(lambda x: x == n, m))))


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.IO;

namespace SolutionCS
{
    class Program
    {
        class Entity : IComparable<Entity>
        {
            public int number;
            public int count;

            public int CompareTo(Entity e)
            {
                return number.CompareTo(e.number);
            }
        }


        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            int N = int.Parse(s[0]);
            long M = long.Parse(s[1]);

            List<Entity> l = new List<Entity>();
            for (int i = 0; i < N; i++)
            {
                s = Console.ReadLine().Split(' ');

                Entity e = new Entity();
                e.number = int.Parse(s[0]);
                e.count = int.Parse(s[1]);

                l.Add(e);
            }

            l.Sort();

            long total = 0;

            for (int i = 0; i < l.Count; i++)
            {
                total += l[i].count;

                if (M <= total)
                {
                    Console.WriteLine(l[i].number);
                    break;
                }

            }
        }
    }
}


Measured memory_bytes: 23236
def solve(n, a_list, q, bc_list):
    v_list = [0] * (10 ** 5 + 1)
    s = 0
    for i in range(n):
        a = a_list[i]
        v_list[a] += 1
        s += a
    res_list = []
    for i in range(q):
        b, c = bc_list[i]
        s += v_list[b] * (c - b)
        v_list[c] += v_list[b]
        v_list[b] = 0
        res_list.append(s)
    return res_list


def main():
    n = int(input())
    a_list = list(map(int, input().split()))
    q = int(input())
    bc_list = [list(map(int, input().split())) for _ in range(q)]
    res = solve(n, a_list, q, bc_list)
    for r in res:
        print(r)


def test():
    assert solve(4, [1, 2, 3, 4], 3, [[1, 2], [3, 4], [2, 4]]) == [11, 12, 16]
    assert solve(4, [1, 1, 1, 1], 3, [[1, 2], [2, 1], [3, 5]]) == [8, 4, 4]
    assert solve(2, [1, 2], 3, [[1, 100], [2, 100], [100, 1000]]) == [102, 200, 2000]


if __name__ == "__main__":
    test()
    main()


Measured memory_bytes: 38512
#include <iostream>
#include<math.h>
#include<list>
#include <algorithm>
#include<set>
#include<vector>
#include<math.h>
#include<map>
#include<string>
#include <numeric>
#include <queue>

using namespace std;
using ll = long long;
using vll = vector<long long>;
using sll = set<long long>;

template<typename T>
T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template<typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }

template<typename T>
map<T, T> primeFactor(T n) {
	map<T, T> res;
	for (T i = 2; i * i <= n; ++i) {
		while (n % i == 0) {
			res[i] ++;
			n /= i;
		}
	}
	if (n != 1) res[n] = 1;
	return res;
}

template<typename T>
bool IsPrimeNumber(T num)
{
	if (num <= 2) return true;
	else if (num % 2 == 0) return false;

	double sqrtNum = sqrt(num);
	for (int i = 3; i <= sqrtNum; i += 2)
	{
		if (num % i == 0)
		{
			return false;
		}
	}

	return true;
}


#define in(x) cin >> x
#define out(x) cout << x
#define outn(x) cout << x << '\n'
#define outs(x) cout << x << ' '
#define rep(i,s,e) for(long i=s;i<e;i++)
#define repeq(i,s,e) for(long i=s;i<=e;i++)



int main() {
	string s;
	ll tmp, ans=9999,c0='0';
	in(s);

	rep(i, 0, s.size() - 2) {
		tmp = abs(((s[i] - c0) * 100) + ((s[i + 1] - c0) * 10) + (s[i + 2] - c0) - 753);
		if (tmp < ans) {
			ans = tmp;
		}
	}

	outn(ans);

	return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
#define PI 3.141592653589
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "No" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl

signed main(void){
    int N,K,Q;
    int A[114514];
    int B[114514];
    cin >> N >> K >> Q;
    REP(i,Q){
        cin >> A[i];
        A[i]--;
    }
    
    REP(i,N){
        B[i]=K;
    }
    REP(i,Q){
        B[A[i]]++;
    }
    REP(i,N){
        B[i]-=Q;
    }
    
    REP(i,N){
        if(B[i]>0){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 2176
def f(x):
    k = int(x)
    return c[k], k


c = [0, 2, 5, 5, 4, 5, 6, 3, 7, 6]
N, M = list(map(int, input().split()))
A = list(map(f, input().split()))
A = sorted(A, key=lambda x: x[0] * 10 - x[1])

# 数字を作成するのに必要なマッチ数のリストを作成
b = []
dic = {}
n = 0
for d in A:
    if n != d[0]:
        b.append(d[0])
        n = d[0]
        dic[n] = d[1]

ans = [0] * b[0]
n = b[0]
while True:
    max_ = 0
    for d in b:
        if n - d == 0:
            if dic[d] > max_:
                max_ = dic[d]
        elif n - d > 0 and ans[n - d] > 0:
            t = ans[n - d] * 10 + dic[d]
            max_ = max(max_, t)

    if n == N:
        print(max_)
        break
    ans.append(max_)
    n += 1

Measured memory_bytes: 14436
import bisect

n = int(input())
a = list(map(int, input().split()))
A = sorted(a)
s = [0]*(n+1)
b = [0]*(n+1)
c = []
for i in range(1, n+1):
    x = a[i-1]
    s[i] = bisect.bisect_right(A, x) - bisect.bisect_left(A, x)
    if b[a[i-1]] == 0:
        c.append(s[i]*(s[i]-1)//2)
        b[a[i-1]] = 1
S = sum(c)
# print(c)
for i in range(1, n+1):
    print(S - s[i] + 1)

Measured memory_bytes: 93904
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
ll dp[100005][10];
int a[100005]; int b[100005];
int main(){
	int n;cin>>n;
	b[1] = 0;
	for(int i=0;i<2*n-1;i++){
		if(i%2==0) cin>>a[(i/2)+1];
		else{
			string s;cin>>s;
			b[(i+1)/2+1] = (s[0]=='-'?1:0);
		}
	}
	//cout<<a[1]<<a[2]<<a[3]<<b[1]<<b[2]<<b[3]<<endl;
	rep(i,100005) rep(j,10) dp[i][j]=-1e18;
	dp[0][0] = 0;
	for(int i=0;i<n;i++){
		for(int j=0;j<10;j++){
			if(dp[i][j]<-1e17) continue;
			if( (j+b[i+1])%2 == 0 ){
				for(int k=0;k<=j;k++) dp[i+1][k] = max(dp[i+1][k],dp[i][j]+a[i+1]);
				if(b[i+1]==1&&j!=9) dp[i+1][j+1] = max(dp[i+1][j+1],dp[i][j]+a[i+1]);
			}
			else{
			    //if(i==1&&j==0)cout<<"N"<<endl;
				for(int k=0;k<=j;k++) dp[i+1][k] = max(dp[i+1][k],dp[i][j]-a[i+1]);
				if(b[i+1]==1&&j!=9) dp[i+1][j+1] = max(dp[i+1][j+1],dp[i][j]-a[i+1]);
			}
		}
	}//cout<<dp[4][1]<<endl;
	ll res = -1e18;
	rep(j,10) res = max(res,dp[n][j]);
	cout<<res<<endl;
}

Measured memory_bytes: 8832
import math
a,b,x = map(int,input().split())
if x/(a*a) <= (b/2):
    ans = 2*x/(a*b*b)
    print(90-math.degrees(math.atan(ans)))
else:
    ans = (2*a*a*b-2*x)/(a*a*a)
    print(math.degrees(math.atan(ans)))

Measured memory_bytes: 38384
#include <algorithm>
#include <map>
#include <vector>
#include <iostream>
#include <stdio.h>
#include <set>
#include <string>
#include <stack>
#include <stdlib.h>
#include <math.h>
#include <iomanip>
#include <iterator>

using namespace std;

typedef unsigned long long ll;
typedef vector<ll> vll;
typedef vector<vector<ll> > vvll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<ll, ll> point;
typedef pair<int, int> pointI;

#define PI 3.1415926535897932384626433832795

const ll mod=1000000007LL;
pointI pos=pointI(1, 1);
char arr[]={'E', 'W', 'S', 'N'};

int magic1(string &str, int &i, int p) {
    int num[]={0, 0, 0, 0};

    while ((str[i]==arr[p])||(str[i]==arr[p+1]))
        if (str[i]==arr[p]) num[p]+=1, i++;
        else num[p+1]+=1, i++;
    if ((num[p]>0)&&(num[p+1]>0)) return 0;
    if (num[p]>0) return 1;
    if (num[p+1]>0) return -1;
}

int main() {
    iostream::sync_with_stdio(false);
    string str; cin>>str;

    int i=0;
    while (i<str.size())
        if ((str[i]==arr[0])||(str[i]==arr[1]))
            pos.first+=magic1(str, i, 0);
        else
            pos.second+=magic1(str, i, 2);
    if (pos==pointI(1, 1)) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
     int month, date, day;
     
     while(0<1){
	  scanf("%d", &month);
	  if(month==0) break;
	  
	  scanf("%d", &date);
	  
	  month = month - 1;
	  
	  while(month>0){
	       if(month<=7 && month!=2){
		    if(month%2==1) date = date + 31;
		    else if(month%2==0) date = date + 30;
	       }
	       else if(month==2) date = date + 29;
	       else if(month>7){
		    if(month%2==1) date = date + 30;
		    else if(month%2==0) date = date + 31;
	       }
  
	       month--;
	  }

	  day = date % 7;
	  
	  switch(day){
	  case 0: printf("Wednesday\n"); break;
	  case 1: printf("Thursday\n"); break;
	  case 2: printf("Friday\n"); break;
	  case 3: printf("Saturday\n"); break;
	  case 4: printf("Sunday\n"); break;
	  case 5: printf("Monday\n"); break;
	  case 6: printf("Tuesday\n"); break;
	  default: break;
		    }
     }

     return 0;
}

Measured memory_bytes: 584
n,m,x,y=map(int,input().split())

xs=list(map(int,input().split()))
ys=list(map(int,input().split()))

#print(x)
#print(y)

x_max=int(max(xs))
y_min=int(min(ys))

if x_max<y_min and y_min<y and y_min!=x:
    print("No War")

else:
    print("War")


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1000000007;
int main()
{
    int N, M; cin >> N >> M;
    vector<int> A(N*M+1);
    long long ans = 1, s = 0, t = 0;
    for (int i = 0; i < N; i++) {
        int a; cin >> a;
        if (A[a] & 1) goto ERROR;
        A[a] |= 1;
    }
    for (int i = 0; i < M; i++) {
        int a; cin >> a;
        if (A[a] & 2) goto ERROR;
        A[a] |= 2;
    }
    for (int i = N*M; i > 0; i--) {
        if (A[i] == 0) {
            ans = ans * (s * t - (N*M-i)) % MOD;
        } else if (A[i] == 1) {
            ans = ans * t % MOD;
        } else if (A[i] == 2) {
            ans = ans * s % MOD;
        } else {
            ans = ans;
        }
        if (A[i] & 1) s++;
        if (A[i] & 2) t++;
    }
    cout << ans << endl;
    return 0;
ERROR:
    cout << 0 << endl;
    return 0;
}

Measured memory_bytes: 4096
def LI():return list(map(int,input().split()))
def II():return int(input())
def yes():return print("Yes")
def no():return print("No")
INF=float("inf")
from collections import deque, defaultdict, Counter
# from heapq import heappop, heappush
# from itertools import product, combinations
# from functools import reduce, lru_cache
# from math import pi, gcd
# from decimal import Decimal

class Combination:
    """
    O(n)の前計算を1回行うことで，O(1)でnCr mod mを求められる
    n_max = 10**6のとき前処理は約950ms (PyPyなら約340ms, 10**7で約1800ms)
    使用例：
    comb = Combination(1000000)
    print(comb(5, 3))  # 10
    """
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv

comb=Combination(100000)
def nHk(n,k):
    return comb(n+k-1,k)%(10**9+7)
    
s=II()

q,m=s//3,s%3
# print(q,m)
mod=10**9+7
ans=0
for i in range(q,0,-1):
    j=s-i*3
    ans+=nHk(i,j)%mod
    
print(ans%mod)





Measured memory_bytes: 81400
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define getchar getchar_unlocked
#define putchar putchar_unlocked
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

//この問題まったくかすりもしないくらい分からなかったけど、なんでこんなに解かれてるのだろう

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


	string S;
	cin >> S;
	int N = S.size();
	int A[26] = {};
	rep(i, N) A[S[i] - 'a']++;
	ll kotae = 0;
	rep(i, 26) kotae += 1ll * A[i] * (N - A[i]);
	co(kotae / 2 + 1);

	Would you please return 0;
}

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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }



int main() {
    int n; cin >> n;
    string s; cin >> s;
    int ans = 0;
    rep(i, 1000) {
        string tmp = "";
        if(i < 10) {
            tmp += "00";
            tmp += to_string(i);
        } else if(i < 100) {
            tmp += "0";
            tmp += to_string(i);
        } else {
            tmp += to_string(i);
        }
        int now = 0;
        int j = 0;
        while(now < 3 && j < s.size()) {
            if(s[j] == tmp[now]) now++;
            j++;
        }
        if(now == 3) ans++;
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String w = sc.next();

		int alpha[] = new int[26];

		for(int i = 0; i < w.length(); i++){
			alpha[w.charAt(i) - 'a']++;
		}

		for(int i = 0; i < 26; i++){
			if(alpha[i] % 2 != 0){
				System.out.println("No");
				return;
			}
		}

		System.out.println("Yes");
	}
}

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

#define int long long

const int N = 1e2 + 10;
int n, ans = (int)1e18, ar[N];

int32_t main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> ar[i];
	
	for (int x = -100; x <= 100; x++) {
		int tmp = 0;
		for (int i = 0; i < n; i++)
			tmp += (ar[i] - x) * (ar[i] - x);
		ans = min(ans, tmp);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static Scanner sc = new Scanner(System.in);
	public static void main(String[] args){
		//A
		int K = sc.nextInt();
		int even = K/2;
		int odd = even + (K % 2);
		System.out.println(K*(K-1)/2-even*(even-1)/2-odd*(odd-1)/2);
	}
}


Measured memory_bytes: 23124
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1<<30;
//aoj 0536
int main(){
	int n;
	while(cin>>n,n){
		vp in(1);
		in[0]=pii(0,n);
		int m;
		cin>>m;
		int p,q,r;
		cin>>p>>q>>r;
		while(m--){
			int a,b;
			cin>>a>>b;
			vp t1,t2,tmp;
			int c=0;
			while(a){
				if(in[c].second<=a){
					a-=in[c].second;
					b-=in[c].second;
					t1.pb(in[c]);
					c++;
				}else{
					pii p(in[c].first,a);
					in[c].first+=a;
					in[c].second-=a;
					t1.pb(p);
					b-=a;
					break;
				}
			}
//			rep(i,t1.size())cout<<t1[i].first<<" "<<t1[i].second<<endl;
//			cout<<endl;
			while(b){
				if(in[c].second<=b){
					b-=in[c].second;
					t2.pb(in[c]);
					c++;
				}else{
					pii p(in[c].first,b);
					in[c].first+=b;
					in[c].second-=b;
					t2.pb(p);
					break;
				}
			}
			while(c!=in.size())tmp.pb(in[c++]);
			rep(i,t2.size())tmp.pb(t2[i]);
			rep(i,t1.size())tmp.pb(t1[i]);
			in=tmp;
		}
		int co=0;
		m=0;
		p--;
		rep(i,in.size()){
			if(m+in[i].second<p||q<m);
			else{
				int a=in[i].first+max(p,m)-m;
				int b=min(q,m+in[i].second)-max(p,m);
				co+=min(b,max(0,r-a));
			}
			m+=in[i].second;
		}
		cout<<co<<endl;
	}
}
//aoj 0534
/*vp tmp;
int r,l,co;
void f(){
	while(1){
		if(r<0||l>=tmp.size())return;
		int t=tmp[r].second+tmp[l].second;
		if(tmp[r].first==tmp[l].first&&t>=4){
			co+=t;
			r--;l++;
		}else break;
	}
}
int main(){
	int n;
	cin>>n;
	vi q(n);
	vp in;
	rep(i,n)cin>>q[i];
	q.pb(0);
	loop(i,1,n+1){
		if(q[i]!=q[i-1]){
			in.pb(pii(q[i-1],co));
			co=1;
		}else co++;
	}
	int out=0;
	rep(i,in.size())if(in[i].second==3){
		if(i){
			tmp=in;
			tmp[i-1].second--;
			r=i-1;l=i+1;
			co=4;
			if(tmp[i-1].second==0){
				r-=2;
				if(i>1)co+=tmp[i-2].second;
			}
			f();
			out=max(out,co);
		}
		if(i!=in.size()-1){
			tmp=in;
			tmp[i+1].second--;
			r=i-1;l=i+1;
			co=4;
			if(tmp[i+1].second==0){
				l+=2;
				if(i<in.size()-2)co+=tmp[i+2].second;
			}
			f();
			out=max(out,co);
		}
	}
	cout<<n-out<<endl;
}
*/

Measured memory_bytes: 1528
#include <bits/stdc++.h>
#include <ext/hash_map>
#include <ext/numeric>

using namespace std;
using namespace __gnu_cxx;

#define REP(i,n) for( (i)=0 ; (i)<(n) ; (i)++ )
#define rep(i,x,n) for( (i)=(x) ; (i)<(n) ; (i)++ )
#define REV(i,n) for( (i)=(n) ; (i)>=0 ; (i)-- )
#define FORIT(it,x) for( (it)=(x).begin() ; (it)!=(x).end() ; (it)++ )
#define foreach(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();++it)
#define rforeach(it,c) for(__typeof((c).rbegin()) it=(c).rbegin();it!=(c).rend();++it)
#define foreach2d(i, j, v) foreach(i,v) foreach(j,*i)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define SZ(x) ((int)(x).size())
#define MMS(x,n) memset(x,n,sizeof(x))
#define mms(x,n,s) memset(x,n,sizeof(x)*s)
#define pb push_back
#define mp make_pair
#define NX next_permutation
#define UN(x) sort(all(x)),x.erase(unique(all(x)),x.end())
#define CV(x,n) count(all(x),(n))
#define FIND(x,n) find(all(x),(n))-(x).begin()
#define ACC(x) accumulate(all(x),0)
#define PPC(x) __builtin_popcountll(x)
#define LZ(x) __builtin_clz(x)
#define TZ(x) __builtin_ctz(x)
#define mxe(x) *max_element(all(x))
#define mne(x) *min_element(all(x))
#define low(x,i) lower_bound(all(x),i)
#define upp(x,i) upper_bound(all(x),i)
#define NXPOW2(x) (1ll << ((int)log2(x)+1))
#define PR(x) cout << #x << " = " << (x) << endl ;

typedef unsigned long long ull;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
typedef pair<int, int> pii;

const int OO = (int) 2e9;
const double eps = 1e-9;

const int N = 100005;
const int mod = (int) 1e9 + 7;

int n;
vi adj[N];
int dp[N][2];

int dfs(int cur, bool blackPar, int par = -1) {
	int &ret = dp[cur][blackPar];
	if (ret != -1)
		return ret;
	ll res = 1;
	for (int to : adj[cur]) {
		if (to == par)
			continue;
		ll nxt = dfs(to, 0, cur);
		if (!blackPar)
			(nxt += dfs(to, 1, cur)) %= mod;
		(res *= nxt) %= mod;
	}
	return ret = res;
}

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
#ifndef ONLINE_JUDGE
//	freopen("in.txt", "rt", stdin);
//	freopen("out.txt", "wt", stdout);
#endif
	cin >> n;
	for (int i = 1; i < n; i++) {
		int u, v;
		cin >> u >> v;
		u--, v--;
		adj[u].pb(v);
		adj[v].pb(u);
	}
	MMS(dp, -1);
	ll res = (dfs(0, 0) + dfs(0, 1)) % mod;
	cout << res << endl;
	return 0;
}


Measured memory_bytes: 14848
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define res(n) resize(n)
#define rev(v) reverse(v.begin(),v.end())
#define so(v) sort(v.begin(),v.end())
#define cov(v) for(auto i : v) cout << i << " ";cout << endl
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define po(n) cout << (n) << endl
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<string> vs;
typedef vector<vector<int>> vvi;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<ll,ll>> vpl;
typedef vector<vector<pair<int,int>>> vvp;




int main()
{
    int N;cin>>N;
    vl D(N);
    in(N,D);
    map<ll,int> A;
    rep(i,N) A[D[i]]++;
    int M;cin>>M;
    vl F(M);
    in(M,F);
    bool yes = true;
    rep(i,M){
        if(A.count(F[i])){
            if(A[F[i]] > 0) A[F[i]]--;
            else {yes = false;break;}
        }else{
            yes = false;
            break;
        }
    }
    
    if(yes) po("YES");
    else po("NO");
    
    return 0;
}



Measured memory_bytes: 15872