akhauriyash/Code-Regression huggingface dataset:
n,m=map(int,input().split())
G=[[10**18]*n for i in range(n)]
e=[]
for _ in range(m):
    a,b,c=map(int,input().split())
    G[a-1][b-1]=c
    G[b-1][a-1]=c
    e.append([a-1,b-1,c])
for i in range(n):
  G[i][i]=0
for k in range(n):
  for i in range(n):
    for j in range(n):
      if G[i][j]>G[i][k]+G[k][j]:
        G[i][j]=G[i][k]+G[k][j]

print(sum(c>G[a][b] for a,b,c in e))

Measured memory_bytes: 3440
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e6 + 5;
int head[maxn], tot;
struct Edge {
	int u, v, next;
}edge[maxn];
ll a[maxn], dp[maxn];

void init() {
	memset(head, -1, sizeof(head)); tot = 1;
}

void add(int u, int v) {
	edge[++tot].u = u; edge[tot].v = v; 
	edge[tot].next = head[u]; head[u] = tot;
}

void dfs(int u, int fa) {
	for (int i = head[u]; i != -1; i = edge[i].next) {
		int to = edge[i].v;
		if (to == fa) continue;
		dp[to] += dp[u];
		dfs(to, u);
	}
}

int main() {
	int n, m; 
	int u, v;
	init();
	cin >> n >> m;
	for (int i = 1; i <= n - 1; i++) {
		cin >> u >> v;
		add(u, v); add(v, u);
	}
	int w;
	while (m--) {
		cin >> u >> w;
		dp[u] += w;
	}
	dfs(1, 0);
	for (int i = 1; i <= n; i++) {
		cout << dp[i] << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 24064
n=int(input())
h=[int(x) for x in input().split()]
dp=[0]*n
dp[0]=0
dp[1]=abs(h[1]-h[0])
for i in range(2,n):
    dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]),dp[i-2]+abs(h[i]-h[i-2]))
print(dp[n-1])


Measured memory_bytes: 52208
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val x :: xs = List.fill(5)(sc.nextInt()).sortBy(i => (i - 1) % 10)
  val f = (i: Int) => i + (if (i % 10 == 0) 0 else 10 - i % 10)
  println(xs.map(f).sum + x)
}


Measured memory_bytes: 55664
#include <bits/stdc++.h>
using namespace std;
#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define all(x) (x).begin(),(x).end()
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; }
typedef long long ll;
const long long INF = 1LL << 60;
typedef pair<int, int> P;

const long long MOD = 1000000007;
const int MAX = 1000001;
long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main()
{
    ll N, K;
    cin >> N >> K;
    COMinit();

    repd(i, 1, K + 1) {
        ll ans = COM(N - K + 1, i) * COM(K - 1, i - 1);
        ans %= MOD;
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 23680
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;

static ll p = 1e9+7;

int main(){
  ll n,m;
  cin >> n >> m;
  ll s[n];
  REP(i,n) cin >> s[i];
  ll t[m];
  REP(j,m) cin >> t[j];
  ll dp[n+1][m+1];
  ll s_dp[n+1][m+1];
  REP(j,m+1){
    REP(i,n+1){
      if(i==0&&j==0){
        dp[i][j] = 1;
        s_dp[i][j] = 1;
        continue;
      }else if(i==0||j==0){
        dp[i][j] = 0;
        s_dp[i][j] = 1;
        continue;
      }
      if(s[i-1]==t[j-1]){
        dp[i][j] = s_dp[i-1][j-1];
      }else{
        dp[i][j] = 0;
      }
      dp[i][j]%=p;
      s_dp[i][j] = ((s_dp[i-1][j]+s_dp[i][j-1])%p-s_dp[i-1][j-1]+p)%p+dp[i][j];
      s_dp[i][j]%=p;
    }
  }
  cout << s_dp[n][m] << endl;
  return 0;
}


Measured memory_bytes: 62848
import bisect
n,p=map(int,input().split())
arr=[]
arr1=[[] for i in range(100001)]
for i in range(p):
    arr.append(list(map(int,input().split())))
    arr1[arr[i][0]].append(arr[i][1])
for i in range(100001):
    if(len(arr1[i])>1):
        arr1[i].sort()
for i in range(p):
    print("%06d%06d"%(arr[i][0],bisect.bisect_right(arr1[arr[i][0]],arr[i][1])))
    #print("%06d%06d"%(arr[i][0],arr1[arr[i][0]].index(arr[i][1])+1))

Measured memory_bytes: 36680
import sys

def main():
    input = sys.stdin.readline
    n = int(input())
    p = list(map(int, input().split()))
    ans = 1

    if len(p) <= 1:
        print(ans)
        return
    
    min_so_far = p[0]

    for i in range(1, len(p)):
        if p[i] > min_so_far:
            continue
        else:
            min_so_far = p[i]
            ans += 1
    
    print(ans)
    



if __name__ == '__main__':
    main()

Measured memory_bytes: 70352
def main(N, H):
    for i in reversed(range(1, N)):
        if H[i-1] - H[i] > 1:
            return 'No'
        elif H[i-1] - H[i] == 1:
            H[i-1] -= 1
    else:
        return 'Yes'


if __name__ == '__main__':
    N = int(input())
    H = [int(x) for x in input().split()]
    print(main(N, H))


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

int main() {
  string s;
  cin>>s;
  bool c_found = false;
  for (char c: s) {
    if (c == 'C') {
      c_found = true;
      continue;
    }
    if (c_found && c == 'F') {
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
struct Edge
{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w) {}
};
using Graph = vector<vector<Edge>>;
// using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
// int dx[8] = {-1, -1, -1, 0, 0, 1, 1, 1}, dy[8] = {-1, 0, 1, 1, -1, 1, 0, -1};

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  vector<int> a(3);
  for (auto &it : a)
    cin >> it;
  sort(a.begin(), a.end(), greater<int>());
  int ans = a[0] * 10 + a[1] + a[2];
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3656
import java.util.*;

public class Main {

    public static void main(String args[]) {


        Scanner scan = new Scanner(System.in);

        int n = scan.nextInt();
        int k = scan.nextInt();
        int sum =0;
        List<Integer> list = new ArrayList<>();

        for (int i=0; i<n; i++) {
            int p = scan.nextInt();
            list.add(i, p);
        }

        Collections.sort(list);

        for (int j =0; j<k; j++) {
            sum += list.get(j);
        }

        System.out.println(sum);

    }

}

Measured memory_bytes: 38804
#include <iostream>
#include<vector>
#define ma 1000000000
int mod(int a){
if(a>=0)
    return a;
else return -a;
}



using namespace std;
int main(){
int n,k;
cin>>n>>k;
vector<int> a;
a.resize(n);
for(int i=0;i<n;i++)
    cin>>a[i];
int b[n];
b[0]=0;
b[1]=mod(a[1]-a[0]);
for(int i=2;i<=k&&i<n;i++)
    b[i]=mod(a[i]-a[0]);
for(int i=k+1;i<n;i++){
    int t=ma;
for(int k1=1;k1<=k;k1++){
    if(t>b[i-k1]+mod(a[i]-a[i-k1]))
        t=b[i-k1]+mod(a[i]-a[i-k1]);
}
  b[i]=t;
}
cout<<b[n-1];
}


Measured memory_bytes: 1024
/* ***********************************************
Author        :Tisuama
Created Time  :2017年09月16日 星期六 20时00分00秒
File Name     :A.cpp
************************************************ */
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdlib>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
#define REPF( i , a , b ) for ( int i = a ; i <= b ; ++ i )
#define CLEAR( a , x ) memset ( a , x , sizeof a )  
const int INF=0x3f3f3f3f;
typedef long long LL; 
const int maxn=1e5+100;

int n,k;
int main()
{
    while(cin>>n>>k)
        cout<<n*n-k<<endl;
}


Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int d = sc.nextInt();
    int kansi = 0;
    while(n>0){
      kansi++;
      n -= 1 + 2*d;
    }
    System.out.println(kansi);
  }
}


Measured memory_bytes: 35740
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            var a = cin.ArrayLong(3);

            var c = (a[1] + a[0] - 1) / a[1];
            
            Console.WriteLine(c*a[2]);
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 27452
#include<string>
#include<string.h>
#include<map>
#include<set>
#include<vector>
#include<stdio.h>
#include<math.h>
#include<iostream>
#include<algorithm>
#include<queue>
#include<stdio.h>

using namespace std;



int main()
{
    int a,b,c,d,ans=0,cnt=0,sum=0;
    cin>>a>>b>>c>>d;
    if(abs(a-c)<=d || (abs(a-b)<=d && abs(b-c)<=d))
    cout<<"Yes";
    else
    cout<<"No";
   // system("pause");
    return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int n,rem,result;
    cin>>n;
    if(n%1000==0)
        cout<<"0"<<endl;

    else{
            rem = n%1000;
     while(rem>1000){
            rem = rem%1000;
     }
        result = 1000-rem;
        cout<<result<<endl;

    }
    return 0;
}


Measured memory_bytes: 3500
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define F first
#define S second
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define vlli vector<ll>
#define vi vector<int>
#define vs vector<string>
#define vplli vector< pair< ll,ll> >
#define plli pair< ll,ll >
#define vps vector< pair< string, string> >
#define vpi vector< pair< int, int> >
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fast ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define forn(i,a,n) for(ll i=a;i<n;i++)
#define forr(i,n,a) for(ll i=n-1;i>=a;i--)
#define scan(arr,a,n) for(ll i=(a);i<(n);i++)cin>>(arr)[i];
#define print(arr,a,n) for(ll i=(a);i<(n);i++)cout<<(arr)[i]<<" ";

const ll inf = 1e18;

ll add(ll x, ll y) {ll res = x + y; return (res >= mod ? res - mod : res);}
ll mul(ll x, ll y) {ll res = x * y; return (res >= mod ? res % mod : res);}
ll sub(ll x, ll y) {ll res = x - y; return (res < 0 ? res + mod : res);}
ll power(ll x, ll y) {ll res = 1; x %= mod; while (y) {if (y & 1)res = mul(res, x); y >>= 1; x = mul(x, x);} return res;}
ll mod_inv(ll x) {return power(x, mod - 2);}


int main(){
    fast;
    #ifndef ONLINE_JUDGE
    freopen("input1.txt","r",stdin);
    freopen("output1.txt","w",stdout);
    #endif
    string s;

    cin>>s;
    string out[2];
    out[1] = "First", out[0] = "Second";
    vector<char> ss;
    ll ans = 0;
    forn(i, 0, s.size()-1){
        if(!(ll)ss.size()){
            ss.pb(s[i]);
            continue;
        } else {
            ss.pb(s[i]);
            while((ll)ss.size()>=2 && s[i+1]!=ss[ss.size() - 2]){
                ss.pop_back();
                ans++;
            }
        }
    }
    cout<<out[ans%2]<<endl;
}

Measured memory_bytes: 3792
program main
 implicit none
   character*3::word

   read*,word

   if(word(1:1)=='S' .and. word(2:2)=='S' .and. word(3:3)=='S') print*,0
   if(word(1:1)=='R' .and. word(2:2)=='S' .and. word(3:3)=='S') print*,1
   if(word(1:1)=='S' .and. word(2:2)=='R' .and. word(3:3)=='S') print*,1
   if(word(1:1)=='S' .and. word(2:2)=='S' .and. word(3:3)=='R') print*,1
   if(word(1:1)=='R' .and. word(2:2)=='S' .and. word(3:3)=='R') print*,1
   if(word(1:1)=='R' .and. word(2:2)=='R' .and. word(3:3)=='S') print*,2
   if(word(1:1)=='S' .and. word(2:2)=='R' .and. word(3:3)=='R') print*,2
   if(word(1:1)=='R' .and. word(2:2)=='R' .and. word(3:3)=='R') print*,3

end program main

Measured memory_bytes: 2820
//============================================================================
// Name        : f.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include<vector>
using namespace std;

void distance(vector<int> &d,vector<vector<int>> e,int u){
	vector<int> s;
	d[u]=0;
	s.push_back(u);
	while(s.size()){
		int tempn=s.back();
		s.pop_back();
		for(int i=0;i<e[tempn].size();i++){
			if(d[tempn]<d[e[tempn][i]]){
				s.push_back(e[tempn][i]);
				d[e[tempn][i]]=d[tempn]+1;
			}
		}
	}
}

int main() {
	int n,u,v;cin>>n>>u>>v;u--;v--;
	if(u==v){
		cout<<0<<endl;
		return 0;
	}
	vector<int> a(n-1),b(n-1);
	vector<vector<int>> e(n);
	for(int i=0;i<n-1;i++){
		cin>>a[i]>>b[i];a[i]--;b[i]--;
		e[a[i]].push_back(b[i]);
		e[b[i]].push_back(a[i]);
	}
	vector<int> du(n,n),dv(n,n);
	distance(du,e,u);
	distance(dv,e,v);
	int ans=0;
	for(int i=0;i<n;i++){
		if(du[i]+1<=dv[i]){
			ans=max(ans,dv[i]-1);
		}
	}
//	for(int i=0;i<n;i++){
//		cout<<du[i]<<' ';
//	}cout<<endl;
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

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

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int n;
char s[125252];
typedef unsigned int Hash;
const Hash base = 10007ll;
Hash hsh[125252];
Hash bpow[125252];
typedef short Hash2;
const Hash2 base2 = 29;
const Hash2 mod2 = 251;
Hash2 hsh2[125252];
Hash2 bpow2[125252];
Hash2 mdmp[65536];

typedef pair<Hash,Hash2> yo;
struct yosh {
  size_t operator()(const yo &yey) const {
    hash<int> hasher;
    return hasher((int)yey.first);
  }
};

int calc(int x){
  unordered_set<yo,yosh> S;
  REP(i,n-x+1){
    // substr
    int l = i;
    int r = l+x;
    Hash h = hsh[r] - hsh[l]*bpow[x];
    Hash hh = mdmp[hsh2[r] - mdmp[hsh2[l]*bpow2[x]] + mod2];
    S.insert(yo(h,hh));
  }
  return S.size();
}

int main(){
  scanf("%s",s);
  n = strlen(s);
  REP(i,65536)mdmp[i] = i%mod2;
  // create hash
  REP(i,n)hsh[i+1] = hsh[i]*base + (Hash)s[i];
  bpow[0] = 1ll;
  REP(i,n)bpow[i+1] = bpow[i]*base;
  // create hash 2
  REP(i,n)hsh2[i+1] = mdmp[ mdmp[hsh2[i]*base2] + (Hash2)(s[i]-'a') ];
  bpow2[0] = 1;
  REP(i,n)bpow2[i+1] = mdmp[ bpow2[i]*base2 ];
  // go
  int low = 1, high = n;
  while(low+2<high){
    int ml = (low+high)/2;
    int mh = ml+1;
    if(calc(ml)<calc(mh)){
      low = ml;
    }else{
      high = mh;
    }
  }
  int ans = 0;
  FOR(i,low,high+1)CHMAX(ans,calc(i));
  printf("%d\n",ans);
  return 0;
}


Measured memory_bytes: 5844
package main

import (
	"fmt"
)

func main() {
	var k int
	fmt.Scan(&k)

	var s string
	fmt.Scan(&s)

	if len(s) <= k {
		fmt.Println(s)
	} else {
		s = s[0:k] + "..."
		fmt.Println(s)
	}

}


Measured memory_bytes: 1760
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#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 all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef ll Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
//typedef tuple<pii,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	int n;
	cin>>n;
	vvi in(n,vi(10)),a(n,vi(11));
	rep(i,n)rep(j,10)cin>>in[i][j];
	rep(i,n)rep(j,11)cin>>a[i][j];
	
	int out=-inf;
	loop(i,1,1<<10){
		int sum=0;
		rep(j,n){
			int co=0;
			rep(k,10)if(in[j][k]&&i&1<<k)co++;
			sum+=a[j][co];
		}
		out=max(out,sum);
	}
	cout<<out<<endl;
}








Measured memory_bytes: 256
h, w = map(int, input().split())

def check(x, y, board, h, w):
  if x > 0:
    if board[x-1][y] == '#':
      return True

  if y > 0:
    if board[x][y-1] == '#':
      return True

  if y != w-1:
    if board[x][y+1] == '#':
      return True

  if x != h-1:
    if board[x+1][y] == '#':
      return True

  return False

board = []
answer = 'Yes'

for i in range(h):
  board.append(list(input()))

for i in range(h):
  for j in range(w):
    if board[i][j] == '#':
      if check(i, j, board, h, w) == False:
        answer = 'No'

print(answer)

Measured memory_bytes: 39536
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            var line_origin = Console.ReadLine();

            if (string.IsNullOrEmpty(line_origin))
            {
                return;
            }

            int week_num = int.Parse(line_origin);
            double money = 100000; //１０万円

            for (int i = 0; i < week_num; i++)
            {
                money *= 1.05;
                //1000未満の切り上げ
                money = Math.Ceiling((money / 1000)) * 1000;
            }
            Console.WriteLine("{0}", (int)money);
        }
    }
}

Measured memory_bytes: 5632
#include <bits/stdc++.h>
using namespace std;
int main() {
    int a, b;
    cin >> a >> b;
    if ((a + b) % 3 && a % 3 && b % 3) {
        puts("Impossible");
    } else {
        puts("Possible");
    }
	return 0;
} 

Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
print(2*n-1)
if min(a)+max(a)>0:
    s=a.index(max(a))
    for i in range(n):
        print(s+1,i+1)
    for i in range(1,n):
        print(i,i+1)
else:
    s=a.index(min(a))
    for i in range(n):
        print(s+1,i+1)
    for i in range(n,1,-1):
        print(i,i-1)

Measured memory_bytes: 3064
#include <cstdio>
#include <cstring>
using namespace std;
int n,m,k;
main()
{
	char s[4]={'R','Y','G','B'};
	scanf("%d%d%d",&n,&m,&k);
	for (int i=1;i<=n;i++,puts(""))
		for (int j=1;j<=m;j++)
		{
			int pos=0;
			pos|=(i+j)/k%2;
			pos|=(n-i+j-1)/k%2*2;
			printf("%c",s[pos]);
		}
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;
typedef  long long ll;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
typedef vector<vector<int> > vvi;
#define clr(a, b) memset(a, b, sizeof(a))
#define pb push_back
#define mkp make_pair
#define forn(i, n) for(int i=0; i<(int)n; ++i)

const int inf = (int)1e6+5;
const int nax = (int)3e5+5;

void compute(){
    int n; cin>>n;
    char c; cin>>c;
    int m; cin>>m;
    cin>>c;
    int d; cin>>d;
    if(n < 2019){
        cout<<"Heisei\n";
        return;
    }
    else if(n == 2019){
        if(m < 4){
            cout<<"Heisei\n";
            return;
        }
        else if( m == 4){
            if(d <= 30){
                cout<<"Heisei\n";
                return;
            }
            cout<<"TBD\n";
            return;
        }
        cout<<"TBD\n";
        return;
    }
    cout<<"TBD\n";
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //    int t;
    //    cin>>t;
    //    while(t--)
    compute();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define f first
#define s second
#define fastio ios_base::sync_with_stdio(false); cin.tie(0)
typedef long long int lli;
typedef pair<lli, lli> pii;
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
vector<vector<int> > S;
vector<int> vis;
vector<vector<int> > dist;
bool is_bipartite(int s, int c)
{
	vis[s] = c;
	bool flag = true;
	for(int i=0; i<S[s].size(); i++)
	{
		if(vis[S[s][i]] == c)
			return false;
		else if(vis[S[s][i]] == 1-c)
			continue;
		flag = is_bipartite(S[s][i], 1-c);
		if(flag == false)
			return false;
		else
			continue;
	}
	return flag;
}
int floyd_warshall()
{
	int ans = 0;
	int n = dist.size();
	for(int k = 0; k < n; k++)
	{
	    for(int i = 0; i < n; i++)
		{
	        for(int j = 0; j < n; j++)
			{
	            dist[i][j] = min( dist[i][j], dist[i][k] + dist[k][j] );
	        }
	    }
	}
	for(int i=0; i<n; i++)
	{
		for(int j=0; j<n; j++)
		{
//			cout<<dist[i][j]<<" ";
			if(dist[i][j] < 1e+6 && i != j)
				ans = max(ans, dist[i][j]);
		}
		cout<<"\n";
	}
	return ans+1;
}
int main()
{
	fastio;
	int n;
	cin>>n;
	S.resize(n);
	dist.resize(n, vector<int> (n, 1e+6));
	for(int i=0; i<n; i++)
	{
		string a;
		cin>>a;
		for(int j=0; j<n; j++)
		{
			if(a[j] == '1')
			{
				S[i].push_back(j);
				dist[i][j] = 1;
			}
		}
	}
	vis.resize(n, -1);
	bool flag = is_bipartite(0, 0);
	if(flag == false)
	{
		cout<<-1<<"\n";
		return 0;
	}
	cout<<floyd_warshall()<<"\n";
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<int(n);i++)
#define rep1(i,n) for(int i=1;i<=int(n);i++)
#define per(i,n) for(int i=int(n)-1;i>=0;i--)
#define per1(i,n) for(int i=int(n);i>0;i--)
#define foreach(i,n) for(auto &&i:n)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define GSORT(x) sort(all(x), greater<int>())
#define REV(x) reverse(all(x))
#define MAX(x) *max_element(all(x))
#define MIN(x) *min_element(all(x))
#define LOWitr(x, n) lower_bound(all(x), n)
#define UPRitr(x, n) upper_bound(all(x), n)
#define cii(x) int x;cin >> x
#define cill(x) LL x;cin >> x
#define cis(x) string x;cin >> x
#define co(x) cout << x << endl
#define dump(x)  cout << #x << " = " << (x) << endl
#define truecheck assert
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define fastcin() cin.tie(0);ios::sync_with_stdio(false)
using namespace std;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef long long int64;
template<class T,class U>bool chmax(T &a, const U &b) { if (a<b) { a=b; return true; } return false; }
template<class T,class U>bool chmin(T &a, const U &b) { if (b<a) { a=b; return true; } return false; }
const int INF = 1e9, MOD = 1e9 + 7;
const LL LLINF = 1e16;

int main() {
    fastcin();
    cout << fixed << setprecision(10);
    cii(n);
    cii(k);
    cis(s);
    s[k-1]=s[k-1]+32;
    string ans = s;
    co(ans);
    return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		String b  = keyboard.next();
		String ans = "";
		
		if(b.equals("A")){
			ans = "T";
			}else if(b.equals("T")){
			ans = "A";
			}else if(b.equals("G")){
			ans = "C";
			}else{
			ans = "G";
			}

		System.out.println(ans);
		keyboard.close();	
	}
}

Measured memory_bytes: 21716
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <map>
#include <iomanip>	
#include <deque>
#include <set>
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
#define fore(i,a) for(auto &i:a)
#define INF INT_MAX/2;
typedef long long ll;
using namespace std;
using vi = vector<int>;
using vll = vector<ll>;
ll mod = 1e9 + 7;
//ll llmax = 10000000000000000000ll;
using namespace std;
using Graph = vector<vector<int>>;


int cnt_digit(ll N)
{
	int digit = 0;

	while (N > 0)
	{
		N /= 10;
		digit++;
	}
	return digit;
}


 // 最大公約数計算
 
ll gcd(ll a, ll b)
{
	if (b == 0) {
		return a;
	}
	else {
		return gcd(b, a % b);
	}
}
// 最小公倍数の計算

ll lcm(ll a, ll b)
{
	ll g = gcd(a, b);

	return a / g * b;
}

struct union_find
{
	vector<int> par, r;
	union_find(int n)
	{
		par.resize(n);
		r.resize(n);
		init(n);
	}


	void init(int n)
	{
		for (int i = 0; i < n; i++) par[i] = i;
		for (int i = 0; i < n; i++) r[i] = 0;
	}

	int find(int x)
	{
		if (par[x] == x)return x;
		else return find(par[x]);
	}

	void unite(int x, int y)
	{
		x = find(x);
		y = find(y);

		if (r[x] < r[y])
		{
			par[x] = y;
		}
		else
		{
			par[y] = x;
			if (r[x] == r[y])
			{
				r[x]++;
			}
		}
	}
};



int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	int a;
	cin >> a;
	vector<bool> ans(a + 1);

	ans[1] = 1;
	int MAX = 0;
	rep(i, 2, a + 1) {
		
		int x = i * i;
		while (x <= a) {
			ans[x] = 1;
			x *= i;
		}
	}
	rrep(i, a,1) {
		if (ans[i])
		{
			cout << i << endl;
			return 0;
		}
	}
		
	
	
	
	
}
	

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <complex>
#include <string>
#include <sstream>
#include <limits>
#include <numeric>
#include <algorithm>
#include <functional>

#include <vector>

using namespace std;

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

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

	vector<int> value_list({ a, b, c });
	sort(value_list.begin(), value_list.end());

	cout << value_list[0] + value_list[1];

	return 0;
}


Measured memory_bytes: 3620
#include<iostream>
#include<string>
#include<cstring>
using namespace std;

int main(){
	string S;
	int T[100],sum,e;
	while(true){
		cin>>S;
		if(S=="#"){
			break;
		}
		sum=0;
		memset(T,0,sizeof(T));
		for(int i=0;i<S.size();i++){
			e=S[i]-'a'+1;
			if((((e==17 || e==23) || (e==5 || e==18)) || ((e==20 || e==1) || (e==19 || e==4))) || (((e==6 || e==7) || (e==26 || e==24)) || ((e==3 || e==22) || e==2)))
			{
				T[i]=1;
			}
			if(i==0){

			}
			else if(T[i]!=T[i-1]){
				sum++;
			}
		}
		cout<<sum<<endl;
	}
	return 0;
}

Measured memory_bytes: 1184
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <math.h>
#include <stdlib.h>
#include <map>
#include <deque>
#include <sys/timeb.h>
#include <fstream>

using namespace std;

#define repr(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repr(i,0,n)
#define reprrev(i,a,b) for(int i=(int)(b)-1;i>=(int)(a);i--)
#define reprev(i,n) reprrev(i,0,n)
#define repi(itr,ds) for(auto itr=ds.begin();itr!=ds.end();itr++)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define mp make_pair
#define mt make_tuple
#define INF 1050000000
#define INFL 1100000000000000000LL
#define EPS (1e-10)
#define MOD 1000000007
#define PI 3.1415926536
#define RMAX 4294967295

typedef long long ll;
typedef pair<int, int> Pi;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<Pi> vPi;
typedef vector<vector<int> > vvi;
typedef vector<vector<bool> > vvb;
typedef vector<vector<ll> > vvll;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<double> > vvd;
typedef vector<vector<Pi> > vvPi;
typedef priority_queue<int, vector<int>, greater<int> > pqli;
typedef priority_queue<ll, vector<ll>, greater<ll> > pqlll;
typedef priority_queue<Pi, vector<Pi>, greater<Pi> > pqlP;
struct Edge {
	int from, to, cost;
	bool operator<(Edge e) {
		return cost < e.cost;
	}
};
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
template <class T>
using vec = vector<T>;
template<class T>
using pql = priority_queue<T, vector<T>, greater<T>>;
string debug_show(Pi a) {
	return "(" + to_string(a.first) + "," + to_string(a.second) + ")";
}

template<class T>
struct augEdge {
	T from, to;
	int cost;
	bool operator<(augEdge e) { return cost < e.cost; }
	bool operator>(augEdge e) { return cost > e.cost; }
};
template<class T>
using augGraph = vector<augEdge<T>>;



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

	ll n, m;
	cin >> n >> m;
	if (n == 1 && m == 1) {
		cout << 1 << endl;
		return 0;
	}
	if (n == 1 || m == 1) {
		if (n == 1) {
			cout << m - 2 << endl;
		}
		else {
			cout << n - 2 << endl;
		}
		return 0;
	}
	ll ans = (n - 2) * (m - 2);

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
N, X = map(int, input().split())


def solve(edge, width, ans):
	a, b = divmod(width, edge)
	if b == 0:
		return ans+edge*(2*a-1)
	return solve(width-edge*a, edge, ans + edge*2*a)

print(solve(min(X,N-X), max(X, N-X), N))





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

int main(){
  vector<int> n(3);
  for(int i=0;i<3;i++){
    cin>>n.at(i);
  }
  
  sort(n.begin(), n.end());
  reverse(n.begin(), n.end());
  
  cout<<n.at(0)*10+n.at(1)+n.at(2)<<endl;
}
  

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <unordered_map>
#include <cmath>
#include <stdlib.h>

using namespace std;
typedef long long ll;
#define MOD 1000000007

int main()
{
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  char c;
  cin >> c;
  printf("%c\n", c + 1);

  return 0;
}


Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using uint = unsigned int;
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif

struct Buffer{
    int idx;
    char buf[1025];
    Buffer(){ init(); }
    void init(){ idx = 0; cin.read(buf, 1024); }
    void check(){ if(idx == 1024){ init(); } }
    int next(){
        static char notDigits[256] = {1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,1,1, 0,0,0,0,0,0,0,0,0,0,};
        int ret = 0, sign = 1;
        while(check(), notDigits[(int)buf[idx]]){ idx++; }
        if(check(), buf[idx] == '-'){ sign = -1; idx++; }
        while(check(), !notDigits[(int)buf[idx]]){ ret = ret * 10 + buf[idx++] - '0'; }
        return sign * ret;
    }
};

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    Buffer buf;
    int h = buf.next(), w = buf.next();
    vector<vector<short>> cs(10, vector<short>(10));
    for(int i = 0; i < 10; i++){
        for(int j = 0; j < 10; j++){
            cs[i][j] = buf.next();
        }
    }
    for(int i = 0; i < 10; i++){
        for(int j = 0; j < 10; j++){
            for(int k = 0; k < 10; k++){
                cs[j][k] = min((int)cs[j][k], cs[j][i] + cs[i][k]);
            }
        }
    }
    int ans = 0;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            int a = buf.next();
            prints(a);
            if(a != -1){
                ans += cs[a][1];
            }
        }
    }
    cout << ans << '\n';
}


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

#define FOR(k,m,n) for(int (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define ll long long
#define CLR(a) memset((a),0,sizeof(a))
#define SZ(x) (int((x).size()))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<<str<<endl
using namespace std;

const ll MOD = 1000000007;// 10^9+7
const int INF = (1ll << 30);


//変数
int N, Ma, Mb;
vector<vector<int>> l, r;
int suma = 0;




//サブ関数
//入力
void input()
{
	cin >> N >> Ma >> Mb;
	int rcnt = N / 2;
	l.resize(N-rcnt, vector<int>(3));
	r.resize(rcnt, vector<int>(3));
	REP(i, N - rcnt) REP(j, 3)cin >> l[i][j];
	REP(i, rcnt) REP(j, 3)cin >> r[i][j];

	/*
	if (Ma < Mb) {
		swap(Ma, Mb);
		for (auto& row : l)swap(row[0], row[1]);
		for (auto& row : r)swap(row[0], row[1]);
	}
	*/

	for (const auto& row : l)suma += row[0];
	for (const auto& row : r)suma += row[0];
}

vector<int> bit2value(const vector<vector<int>>& obj, const int i)
{
	const int N = obj.size();
	int a = 0;
	int b = 0;
	int c = 0;

	REP(j, N) if (i&(1 << j)) {
		a += obj[j][0];
		b += obj[j][1];
		c += obj[j][2];
	}
	return { a,b,c };
}

map<int, map<int, int>> make_half(const vector<vector<int>>& obj)
{
	const int N = obj.size();
	map<int, map<int, int>> res;

	REP(i, 1 << N) {
		auto sum = bit2value(obj, i);
		int a = sum[0];
		int b = sum[1];
		int c = sum[2];

		if (res[a].find(b) == res[a].end()) {
			res[a][b] = c;
		}
		else {
			res[a][b] = min(res[a][b], c);
		}
	}
	return res;
}


int find_pair(map<int, map<int, int>>& other, const vector<int>& sum)
{
	int cost = INF;
	int a = sum[0];
	int b = sum[1];
	int c = sum[2];
	FOR(times, 1, suma / Ma + 1)
	{
		ll obja = Ma * times;
		ll objb = Mb * times;
		ll resta = obja - a;
		ll restb = objb - b;
		if (resta < 0)continue;
		if (restb < 0)continue;

		//if (other.find(resta) == other.end())continue;
		if (other[resta].find(restb) == other[resta].end())continue;
		cost = min(cost, other[resta][restb]);
	}
	return cost + c;
}


//計算
void calc()
{
	int cost = INF;
	int rsiz = r.size();
	auto lhalf = make_half(l);
	
	REP(i, 1 << rsiz)
	{
		auto sum = bit2value(r, i);
		if (sum[2] > cost)continue;
		auto bestCost = find_pair(lhalf, sum);
		cost = min(cost, bestCost);
	}

	cout << (cost == INF ? -1 : cost) << endl;
}


//出力
void output()
{

}


//デバッグ
void debug()
{
	int N;
	cin>>N;
}


//メイン関数
int main()
{
	input();
	calc();
	output();
	debug();
	
	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
namespace FAST_IO
{
	template<typename T> void read(T &a)
	{
		a=0;
		int f=1;
		char c=getchar();
		while(!isdigit(c))
		{
			if(c=='-')
			{
				f=-1;
			}
			c=getchar();
		}
		while(isdigit(c))
		{
			a=a*10+c-'0';
			c=getchar();
		}
		a=a*f;
	}
	template <typename T> void write(T a)
	{
		if(a<0)
		{
			a=-a;
			putchar('-');
		}
		if(a>9)
		{
			write(a/10);
		}
		putchar(a%10+'0');
	}
	template <typename T> void writeln(T a)
	{
		write(a);
		puts("");
	}
}
int s0,s1;
int main()
{
	string q;
	cin>>q;
	for(int i=0;i<q.size();i++)
	{
		if(q[i]=='0')
		{
			s0++;
		}
		else
		{
			s1++;
		}
	}
	cout<<min(s0,s1)*2;
}

Measured memory_bytes: 512
import itertools
n = int(input())
#
# lst = []
# for v in itertools.permutations(range(1,n+1),n):
#     tmp = 0
#     for i in range(n):
#         tmp += (i+1) % v[i]
#     lst.append(tmp)
# print(max(lst))
ans = 0
for i in range(1,n):
    ans += i
print(ans)

Measured memory_bytes: 62780
from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations # (string,3) 3回
from collections import deque
from collections import defaultdict
import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#

import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
# 累積和
n,q = readInts()
Cum = [0] * (n+1)
S = input()
# 左にAがあるC
for i in range(1,n):
    if S[i-1] == 'A' and S[i] == 'C':
        Cum[i] += 1
for i in range(n):
    Cum[i+1] += Cum[i]
#print(Cum)
for k in range(q):
    l,r = readInts()
    l -= 1
    r -= 1
    print(Cum[r] - Cum[l])


Measured memory_bytes: 10004
#include <bits/stdc++.h>
using  namespace std;
typedef long long ll;
#define RAP(i, n) for(ll i=0;i<(n);i++)
#define FOR(i, a, b) for(ll i=(a);i<(b);i++)

#include <iostream>
#include <vector>
using namespace std;

//重複順列
vector<ll> buf;
void permutation(ll i, const ll size, const ll range_start, const ll range_end)
{
    if (i == size) {
      // ここで所望の作業を行う
      for(ll itr:buf){
        cout << itr;
      }
    }
    else{
        for(ll j = range_start; j <= range_end; ++j){
            buf[i] = j;
            permutation(i + 1, size, range_start, range_end);
        }
    }
}
int main(void)
{
  ll n, ans=0;
  bool flag = true;
  string S;
  cin >> n >> S;
  RAP(i, 1000){
    ostringstream sout;
    sout << std::setfill('0') << std::setw(3) << i;
    string s = sout.str();
    flag = true;
    ll j=0;
    RAP(k, 3){
      while(S[j]!=s[k]){
        j++;
        if(j>=S.size()){
          flag = false;
          break;
        }
      }
      j++;
      if(flag==false){
        break;
      }
    }
    if(flag){
      //cout << s << endl;
      ans++;
    }
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3692
using System;
using System.Linq;
public class Hello{
    public static void Main(){
        var input = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
        var n = input[0];
        var W = input[1];
        
        var dp = new long[100001];
        for(var i = 0;i < 100001;i++){
                dp[i] = long.MaxValue;
        }
        dp[0] = 0;
        for(var i = 0;i < n;i++){
            var a = Console.ReadLine().Split(' ').Select(long.Parse).ToArray();
            var w = a[0];
            var v = a[1];
            for(var j = 100000;j >= v;j--){
                if(dp[j - v] <= W){
                    dp[j] = Math.Min(dp[j],dp[j - v] + w);
                }
            }
        }
        
        for(var i = 100000;i >= 0;i--){
            if(dp[i] <= W){
                Console.WriteLine(i);
                return;
            }
        }
        
    }
}


Measured memory_bytes: 13920
#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(int i=0, i##_len=(n); i<i##_len; ++i)
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
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; }

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



ll n, k;

struct sushi{
	ll t;
	ll d;
};

int main(){
	cin >> n >> k;
	vector<sushi> v(n);
	set<int> types;
	rep(i,n){
		int t, d;
		cin >> t >> d;
		v[i].t = t;
		v[i].d = d;
		types.insert(t);
	}
	
	sort(v.begin(),v.end(),[](const sushi &l, const sushi &r){
		return l.d > r.d;
	});
	
	vector<sushi> v1, v2; // v1: そのタイプの中で最も大きいもの v2: それ以外
	rep(i,n){
		if ( types.count(v[i].t) ){
			types.erase(v[i].t);
			v1.push_back(v[i]);
		}
		else{
			v2.push_back(v[i]);
		}
	}
	
	
	ll from_v1 = min( (int)k, SZ(v1) );
	ll from_v2 = k - from_v1;
	
	ll score = 0;
	rep(i,from_v1)
		score += v1[i].d;
	rep(i,from_v2)
		score += v2[i].d;
	ll max_score = score + from_v1*from_v1;
	eprintf( "v1:%lld v2:%lld max=%lld %lld\n", from_v1, from_v2, max_score, score + from_v1*from_v1 );
	
	while ( from_v1 > 0 && from_v2 < SZ(v2) ){
		from_v1--;
		score -= v1[from_v1].d;
		score += v2[from_v2].d;
		from_v2++;
		eprintf( "v1:%lld v2:%lld max=%lld %lld\n", from_v1, from_v2, max_score, score + from_v1*from_v1 );
		chmax( max_score, score + from_v1*from_v1 );
	}
	
	cout << max_score << endl;
	
	
	return 0;
}




Measured memory_bytes: 11544
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.util.stream.IntStream;

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final int n = scanner.nextInt();
        final int answer = IntStream.range(1, n)
            .map(i -> {
                int sum = 0;
                for (int j = 1; j * i < n; j++) {
                    sum++;
                }
                return sum;
            }).sum();
        System.out.println(answer);
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }
    }
}
    

Measured memory_bytes: 34360
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+9;
string s;
int n;
int ans[N];
int main(){
    ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    cin>>s;n=s.size();
    for(int i=0;i<n;){
        int nr=0,nl=0,xr,xl;
        while(s[i]=='R')xr=i,nr++,i++;
        xl=i;
        while(s[i]=='L'&&i<n)i++,nl++;
       // cout<<xr<<" "<<xl<<endl;
       // cout<<nr<<" "<<nl<<endl;
       // cout<<"----------\n";
        ans[xr]+=(nr+1)/2;ans[xl]+=nr/2;
        ans[xl]+=(nl+1)/2;ans[xr]+=nl/2;
    }
    for(int i=0;i<n;i++)cout<<ans[i]<<" ";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 1104
#include<bits/stdc++.h>
using namespace std;
int main(){
	string st;
	cin>>st;
	int s=0;
	for(int i=0;i<st.length();i++){
		if(st[i]=='+') s+=1;
		else s-=1; 
	}
	cout<<s<<endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{

    char[] in;
    int p;

    void solve(){
	Scanner sc = new Scanner(System.in);

	while(sc.hasNext()){
	    String s = sc.next();

	    in = s.toCharArray();

	    int ans = -1;
	    for(int num = 0; num <= 9; num++){
		for(int i=0; i<in.length; i++){
		    if(s.charAt(i)=='X'){
			in[i] = (char)(num + '0');
		    }
		}
		p = 0;
		String a = digit();
		p++;
		String b = digit();
		p++;
		String c = digit();
		if(a.length()!=1 && a.charAt(0)=='0') continue;
		if(b.length()!=1 && b.charAt(0)=='0') continue;
		if(a.length()!=1 && c.charAt(0)=='0') continue;

		String left = sum(a, b);
		if(left.equals(c)){
		    ans = num;
		    break;
		}
	    }

	    if(ans==-1) System.out.println("NA");
	    else System.out.println(ans);
	}
    }

    String sum(String a, String b){
	int n1 = a.length();
	int n2 = b.length();
	if(n1<n2){
	    String tmp = a;
	    a = b;
	    b = tmp;
	}

	String[] line = new String[Math.max(a.length(), b.length())+1];
	for(int i=0; i<a.length(); i++) line[i] = String.valueOf(a.charAt(a.length()-i-1));
	for(int i=0; i<b.length(); i++){
	    int num = Integer.valueOf(line[i]);
	    int num2 = b.charAt(b.length()-i-1) - '0';
	    num += num2;
	    if(num<10) line[i] = String.valueOf(num);
	    else{
		line[i] = String.valueOf(num % 10);
		int num3 = 0;
		if(line[i+1]!=null) num3 = Integer.parseInt(line[i+1]);
		line[i+1] = String.valueOf(num3 + num/10);
	    }
	}

	String res = "";
	for(int i=line.length-1; i>=0; i--){
	    if(line[i]==null) continue;
	    res += line[i];
	}
	return res;
    }

    String digit(){
	String res = "";
	while(p<in.length && Character.isDigit(in[p])) res += in[p++];
	return res;
    }

    public static void main(String[] args){
	new Main().solve();
    }
}

Measured memory_bytes: 22912
S = list(input())
if S.count('R') == 3:
	print('3')
elif S.count('S') == 3:
	print('0')
elif S.count('S') == 2:
	print('1')
elif S.count('S') == 1 and S[1] == 'R':
	print('2')
else:
	print('1')


Measured memory_bytes: 9112
#include<bits/stdc++.h>
using namespace std;
#define sz 300005
#define faster_io ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef long long ll;


int main()
{
    faster_io;
    ll a,b,c,d,cnt;
    cin>>a>>b>>c>>d;

    cnt = b-a+1;
    cnt -= (b/c)-((a-1)/c) + (b/d)-((a-1)/d);

//    cout<<b/(c*d/__gcd(d,c))<<" "<<a/(c*d/__gcd(c,d))<<endl;

    cnt+=(b/(c*d/__gcd(d,c)) - (a-1)/(c*d/__gcd(c,d)));
    cout<<cnt<<endl;

    return 0;
}






Measured memory_bytes: 256