akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;

ll N, M;

int main() {
    cin >> N >> M;
    
    vector<ll> p(M);
    vector<string> S(M);

    rep(i, M) {
        cin >> p[i] >> S[i];
    }

    map<ll, ll> mp_ac;
    map<ll, ll> mp_wa_until_ac;
    rep(i, M) {
        if (S[i] == "AC")  {
            mp_ac[p[i]]++;
        }

        if (S[i] == "WA") {
            if (!mp_ac.count(p[i])) {
                // cout << i << endl;
                mp_wa_until_ac[p[i]]++;
            }
        }
    }

    ll wa = 0;
    for (auto iter = mp_ac.begin(); iter != mp_ac.end(); iter++) {
        wa += mp_wa_until_ac[iter->first];
    } 

    printf("%lld %lld\n", mp_ac.size(), wa);
}

Measured memory_bytes: 18944
#include "bits/stdc++.h"

using namespace std;
#ifdef _DEBUG
#define _GLIBCXX_DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define ll long long
#define ll1 1ll
#define ONE 1ll
#define DBG 1
#define rep(i, a, b) for (int i = (a); i < (b); i++)
#define rrep(i, a, b) for (int i = (b)-1; i >= (a); i--)
#define loop(n) rep(loop, (0), (n))
#define all(c) begin(c), end(c)
const int INF =
sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
using pii = pair<int, int>;
// template<class T> ostream &operator<<(ostream &os,T &t){dump(t);return os;}
template <typename T, typename S>
istream &operator>>(istream &is, pair<T, S> &p) {
	is >> p.first >> p.second;
	return is;
}
template <typename T, typename S>
ostream &operator<<(ostream &os, pair<T, S> &p) {
	os << p.first << " " << p.second;
	return os;
}

template <typename T> void printvv(const vector<vector<T>> &v) {
	cerr << endl;
	rep(i, 0, v.size()) rep(j, 0, v[i].size()) {
		if (typeid(v[i][j]).name() == typeid(INF).name() and v[i][j] == INF) {
			cerr << "INF";
		}
		else
			cerr << v[i][j];
		cerr << (j == v[i].size() - 1 ? '\n' : ' ');
	}
	cerr << endl;
}
/*
typedef __int128_t Int;
std::ostream &operator<<(std::ostream &dest, __int128_t value) {
std::ostream::sentry s(dest);
  if (s) {
	__uint128_t tmp = value < 0 ? -value : value;
	char buffer[128];
	char *d = std::end(buffer);
	do {
	  --d;
	  *d = "0123456789"[tmp % 10];
	  tmp /= 10;
	} while (tmp != 0);
	if (value < 0) {
	  --d;
	  *d = '-';
	}
	int len = std::end(buffer) - d;
	if (dest.rdbuf()->sputn(d, len) != len) {
	  dest.setstate(std::ios_base::badbit);
	}
  }
  return dest;
}

__int128 parse(string &s) {
  __int128 ret = 0;
  for (int i = 0; i < s.length(); i++)
	if ('0' <= s[i] && s[i] <= '9')
	  ret = 10 * ret + s[i] - '0';
  return ret;
}
*/

#ifndef _DEBUG
#define printvv(...)
#endif
void YES(bool f) { cout << (f ? "YES" : "NO") << endl; }
void Yes(bool f) { cout << (f ? "Yes" : "No") << endl; }
template <class T> bool chmax(T &a, const T &b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
template <class T> bool chmin(T &a, const T &b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}

signed main(signed argc, char *argv[]) {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(12);

	int N; cin >> N;
	vector<int>P(N), Q(N); rep(i, 0, N) { cin >> P[i]; P[i]--; Q[P[i]] = i; }
	int ans = 0;
	int i = 0;
	dump(Q);
	while (i < N) {
		int j = i;
		while (j + 1 < N and Q[j] < Q[j + 1])j++;
		chmax(ans, j - i + 1);
		i = j + 1;
	}
	cout << N-ans << endl;

	return 0;
}


Measured memory_bytes: 3456
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<math.h>
#include<set>
#include<map>
#include<time.h>
#include<list>
#include<iomanip>
#include<cstring>
#include<queue>
#define h 1000000007
#define lli long long int
#define pb push_back
#define pof pop_front
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
using namespace std;
int main() 
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	lli ans=10000000000000,cnt, i, j, l, flag;
	string x, y;
	cin>>x>>y;
	for(i=0;(i+y.size())<=x.size();i++) 
	{
		cnt=0;
		flag=0;
		for(j=0,l=i;j<y.size() && (i+y.size())<=x.size();j++,l++) 
		{
			if(y[j]!=x[l]) {cnt+=1;} 
			flag=1;
		} 
		if(flag) 
		ans=min(ans,cnt);
	} 
	cout<<ans<<endl;
  return 0;
} 



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

int main(){
  int a, L;
  while(cin >> a >>  L && (a + L) > 0){
    map<int, int> memo;
    int c = 0;
    while(memo.find(a) == memo.end()){
      memo[a] = c++;
      vector<int> ds;
      while(a > 0){
        ds.push_back(a % 10);
        a /= 10;
      }

      while((int)ds.size() < L) ds.push_back(0);
      sort(ds.begin(), ds.end());
      int M = 0;
      int m = 0;
      for(int i = 0; i < L; i++){
        m = m * 10 + ds[i];
        M = M * 10 + ds[L - i - 1];
      }
      a = M - m;
    }
    cout << memo[a] << " "<< a << " " << c - memo[a] << endl;
  }
}

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

#define ll long long
#define EPSION numeric_limits<double>::epsilon()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

using namespace std;

//ifstream f("input.in");
//ofstream g("output.out");

signed main(int argc, char **argv)
{
    IOS;
    ll n, a, b, m, ans = 0;

    cin>>n>>m;
    vector< pair <ll,ll> > vect;

    for (int i=0; i<n; i++)
    {
        cin>>a>>b;
        vect.push_back( make_pair(a,b) );
    }

    sort(vect.begin(), vect.end());

    int i  =0;
    while(m > 0)
    {
        if(m - vect[i].second >= 0)
        {
            ans += vect[i].second * vect[i].first;
            m -= vect[i].second;
        }
        else
        {
            ans += m * vect[i].first;
            break;
        }
        ++i;
    }

    cout<<ans;

    return 0;
}



Measured memory_bytes: 2420
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;
int main() {
	int n;
	cin >> n;
	map<char, int> Nums;
	string S;
	cin >> S;
	for (char c : S) Nums[c]++;
	for (int i = 1; i < n; i++) {
		map<char, int>StrNums;
		string S;
		cin >> S;
		for (char c : S) StrNums[c]++;
		for (auto& p : Nums) p.second = min(p.second, StrNums[p.first]);
	}
	for (const auto& p : Nums) for (int i = 0; i < p.second; i++) cout << p.first;
	cout << endl;

}


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

int main(){
    int N;
    cin >> N;
    if(N%10 == 9 || N/10 == 9){
        cout << "Yes" <<endl;
    } else{
        cout << "No" << endl;
    }
    
}

Measured memory_bytes: 504
n = gets.to_i
num = gets.split.map(&:to_i)

min, max, sum = num[0], num[0], 0

for i in 0..(n-1)
    if min > num[i]
        min = num[i]
    end
    if max < num[i]
        max = num[i]
    end
    sum += num[i]
end

puts "#{min} #{max} #{sum}"

Measured memory_bytes: 7180
import collections

n=int(input())
vs=list(map(int,input().split()))

vs_odd=vs[::2]
c_odd=collections.Counter(vs_odd) 
C1=c_odd.most_common()
C1.append((0,0))
common1=C1[0][1] #最頻値の個数
common1sec=C1[1][1] #第2頻値

vs_even=vs[1::2]
c_even=collections.Counter(vs_even) 
C2=c_even.most_common()
C2.append((0,0))
common2=C2[0][1] #最頻値の個数
common2sec=C2[1][1] #第2頻値

Ans1=len(vs_odd)-common1
Ans2=len(vs_even)-common2
Ans3=len(vs_odd)-common1sec
Ans4=len(vs_even)-common2sec

if c_odd.most_common()[0][0] == c_even.most_common()[0][0]:
    #最頻値が同じ場合
    print(min(Ans1+Ans4, Ans2+Ans3))
else:
    print(Ans1+Ans2)

Measured memory_bytes: 25528
#include<cstdio>
#include<cctype>
#include<queue>
#include<algorithm>
#include<cstring>
using namespace std;

#define REP(i, N) for(int i=0;i<(int)(N);++i)

int unit[20];
int need[20];

int nextInt() {int r = 0, ch; while( isspace(ch = getchar())); do {r = r * 10 + ch - '0';}while( isdigit( ch = getchar() ) ); return r;}

int best;
int N, U;
int tno;
int visited[1 << 20];
void dfs(int mask, int one, int have) {
  if( best <= one ) return;
  if( have >= U ) {
    best = one;
    return;
  }
  for(int i = 0; i < N; i++)
    if ( visited[mask | (1 << i)] != tno && (mask | need[i]) == mask )
      {
        visited[mask | (1 << i)] = tno;
        dfs( mask | (1 << i), one + 1, have + unit[i] );
      }
}

int main() {
  for(tno = 1;; tno++) {
    N = nextInt();
    U = nextInt();
    if( N == 0 && U == 0 ) break;
    REP(i, N) need[i] = 0;

    int all = 0;
    REP(i, N) {
      unit[i] = nextInt();
      all += unit[i];
      int K = nextInt();
      REP(k, K) {
        int x = nextInt();
        need[i] |= (1 << x);
      }
    }
    if( all == U ) {
      printf("%d\n", N);
      continue;
    }
    best = N;
    dfs(0, 0, 0);
    printf("%d\n", best);
  }
}

Measured memory_bytes: 4824
#include <iostream>

using namespace std;

int main(){
    int n,s[1000], i;
    while (cin >> n && n>0){
        int sum = 0, maximum =0, minimum = 10000;
        for (i = 0; i < n; i++){
            cin >> s[i];
            sum += s[i];
        }
        for (i = 0; i < n; i++){
            maximum = max(maximum, s[i]);
            minimum = min(minimum, s[i]);
        }
        cout << (sum - maximum - minimum)/(n -2) << endl;
    }
}

Measured memory_bytes: 1160
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int w = scan.nextInt();
		int h = scan.nextInt();
		int n = scan.nextInt();
		int[] x = new int[n];
		int[] y = new int[n];
		int[] a = new int[n];
		for (int i = 0; i < n; i++) {
			x[i] = scan.nextInt();
			y[i] = scan.nextInt();
			a[i] = scan.nextInt();
		}
		int xmax1 = 0;
		int xmax2 = 0;
		int ymax1 = 0;
		int ymax2 = 0;
		int answ = w;
		int ansh = h;
		for (int i = 0; i < n; i++) {
			switch (a[i]) {
			case 1:
				if (x[i] > xmax1) {
					answ = answ - (x[i]-xmax1);
					xmax1 = x[i];					
				}
				break;
			case 2:
				if (w-x[i] > xmax2) {					
					answ = answ - (w-x[i]-xmax2);
					xmax2 = w-x[i];
				}
				break;
			case 3:
				if (y[i] > ymax1) {
					ansh = ansh - (y[i]-ymax1);
					ymax1 = y[i];
				}
				break;
			case 4:
				if (h-y[i] > ymax2) {
					ansh = ansh - (h-y[i]-ymax2);
					ymax2 = h-y[i];
				}
				break;
			}
		}
		if (answ <  0 ) {
			answ = 0;
		}
		if (ansh <  0 ) {
			ansh = 0;
		}
		System.out.println(answ*ansh);
	}
}


Measured memory_bytes: 23380
#include <bits/stdc++.h>
using namespace std;
const int MAXN = 100005;

int n, g[MAXN], nxt[MAXN << 1], to[MAXN << 1], edgeSize;

void addEdge(int u, int v){
	nxt[++ edgeSize] = g[u];
	to[g[u] = edgeSize] = v;
}
int dfs(int x, int f){
	int p, s = 0;
	for(p = g[x]; p; p = nxt[p])
		if(to[p] != f)
			s ^= dfs(to[p], x) + 1;
	return s;
}
int main(){
	int i, u, v;
	scanf("%d", &n);
	for(i = 1; i < n; ++ i){
		scanf("%d%d", &u, &v);
		addEdge(u, v), addEdge(v, u);
	} printf("%s\n", dfs(1, -1) ? "Alice" : "Bob");
	return 0;
}

Measured memory_bytes: 6912
#include <iostream>
#include <algorithm>
#include <queue>
#include <vector>
#include <set>
#include <cmath>
#include <string>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define FI first
#define SE second
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PB push_back
#define PQ priority_queue<int>
#define PGQ priority_queue<int,vector<int>,greater<int> >
#define VE vector<int>
#define VP vector<PA>
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
using namespace std;
//
const int MOD=1e9+7;
const int INF=1e9+7;
const double PI=3.141592653589793238462643383279;
//
long long inf=1e15;
int main(){
  long long H,W;
  cin>>H>>W;
  if(H%3==0||W%3==0){
    cout<<0<<endl;
    return 0;
  }
  long long m=inf;
  FOR(i,1,H+1){
    long long S1,S2,S3;
    S1=i*W;
    S2=(W/2)*(H-i);
    S3=(W-(W/2))*(H-i);
    m=min(m,max(S1,max(S2,S3))-min(S1,min(S2,S3)));
    S2=((H-i)/2)*W;
    S3=((H-i)-(H-i)/2)*W;
    m=min(m,max(S1,max(S2,S3))-min(S1,min(S2,S3)));
  }
  FOR(i,1,W+1){
    long long S1,S2,S3;
    S1=i*H;
    S2=(H/2)*(W-i);
    S3=(H-(H/2))*(W-i);
    m=min(m,max(S1,max(S2,S3))-min(S1,min(S2,S3)));
    S2=((W-i)/2)*H;
    S3=((W-i)-(W-i)/2)*H;
    m=min(m,max(S1,max(S2,S3))-min(S1,min(S2,S3)));
  }
  cout<<m<<endl;
  return 0;
}


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

using namespace std;

const int BUFFER_SIZE = 1 << 20;
char rb[BUFFER_SIZE], *rp = rb, *rt = rb;
inline char read_char() {
    return rp == rt ? (rt = rb + fread(rb, 1, BUFFER_SIZE, stdin), rp = rb, *rp ++) : *rp ++;
}
inline int read_int() {
    int x = 0;
    char ch = read_char(), flag = 0;
    while (ch != '-' && (ch < '0' || ch > '9')) {
        ch = read_char();
    }
    if (ch == '-') {
        flag = 1;
        ch = read_char();
    }
    for (x = 0; ch >= '0' && ch <= '9'; ch = read_char()) {
        x = x * 10 + (ch - '0');
    }
    return flag ? -x : x;
}

const int MAX_N = 100000 + 5;
const int MAX_S = 1 << 15 | 5;
const int INF32 = 999;

int N, ans, a[MAX_N];
int c[20], n, b[20], fs[MAX_N], f[MAX_S];

int main() {
    N = read_int();
    for (int i = 1; i < N; i ++) {
        int x = read_int() + 1;
        int y = read_int() + 1;
        int z = read_int();
        a[x] ^= z;
        a[y] ^= z;
    }
    for (int i = 1; i <= N; i ++) {
        if (a[i]) {
            ans += c[a[i]];
            c[a[i]] ^= 1;
        }
    }
    for (int i = 1; i <= 15; i ++) {
        if (c[i]) {
            b[n ++] = i;
        }
    }
    for (int S = 1; S < 1 << n; S ++) {
        for (int i = 0; i < n; i ++) {
            if (S >> i & 1) {
                f[S] ++;
                fs[S] ^= b[i];
            }
        }
        if (fs[S]) {
            f[S] = INF32;
        } else {
            f[S] --;
            for (int T = S - 1 & S; T > S - T; T = T - 1 & S) {
                if (!fs[T] && f[S] > f[T] + f[S ^ T]) {
                    f[S] = f[T] + f[S ^ T];
                }
            }
        }
    }
    ans += f[(1 << n) - 1];
    printf("%d\n", ans);
    return 0;
}

Measured memory_bytes: 5196
#include <iostream>
#include <vector>

int insertionSort(int* A, int n, int g)
{
	int cnt = 0;
	for (int i=g; i<n; i++) {
		int key = A[i];
		int j = i-g;;
		//for (j=i-g; j>=0 && A[j] > key; j-=g) {
		//	A[j+g] = A[j]; cnt++;
		//}
		while (j>=0 && A[j] > key) {
			A[j+g] = A[j];
			j -= g;
			cnt++;
		}
		A[j+g] = key;
	}
	return cnt;
}

int shellSort(int* A, int n)
{
	int cnt = 0;
	
	std::vector<int> G;
	int k = 1;
	while (k<=n) {
		G.push_back(k);
		k <<= 2; // multiple by 4
	}
	std::cout << G.size() << std::endl;
	
	for (std::vector<int>::reverse_iterator rit = G.rbegin(); rit != G.rend(); rit++) {
		if (rit == G.rbegin()) std::cout << (*rit);
		else std::cout << " " << (*rit);
		cnt += insertionSort(A, n, (*rit));
	}
	std::cout << std::endl;

	return cnt;
}

int main()
{
	int n;
	std::cin >> n;
	
	int *A = new int[n];
	for (int i=0; i<n; i++) std::cin >> A[i];
	
	int cnt = shellSort(A, n);
	
	std::cout << cnt << std::endl;
	for (int i=0; i<n; i++) std::cout << A[i] << std::endl;
	
	delete[] A;
	
	return 0;
}




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

class Program {
    static void Main(string[] args) {
        //入力
        long N = long.Parse(Console.ReadLine());

        List<long> A = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToList();

        long cnt = A.Count(value => value < 0);
        int zeroCount = A.Count(value => value == 0);

        List<long> B = A.ConvertAll(x => Math.Abs(x)).FindAll(x => x > 0).OrderBy(x => x).ToList();

        //回答となる数値
        long ans = B.Sum();

        //奇数の時
        if (cnt % 2 == 1 && zeroCount == 0) {
            ans -= 2 * B[0];
        }

        //出力
        Console.WriteLine(ans);
    }
}

Measured memory_bytes: 32952
h,w,a,b = [int(x) for x in input().split()]
m = [["1"]*w for i in range(h)]
for i in range(h):
    for j in range(w):
        if i<=b-1 and j<=a-1:
            m[i][j] = "0"
        if i>b-1 and j>a-1:
            m[i][j] = "0"
        
for i in range(h):
    s = ""
    for j in range(w):
        s += m[i][j]
    print(s)

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

int main(){
 int n, t; cin >> n >> t;
 int arr[n + 1];
 for(int i =0; i < n; ++i) cin >> arr[i];
 ll ans = 0;
 for(int i = 1; i < n;++i){
   ans += (ll)min(arr[i] - arr[i -1],t);
 }
 cout << ans + (ll)t<< '\n';
}

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

bool isKai(int x){
  string s=to_string(x);
  int n=s.length();
  for(int i=0;i<n;i++){
    if(s[i]!=s[n-1-i]) return false;
  }
  return true;
}

int main(){
  int a,b; cin >> a >> b;
  int ans=0;
  for(int i=a;i<=b;i++){if(isKai(i)) ans++;}
  cout << ans << endl;
}

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

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
const int INF = int (1e9) + int (1e5);
const ll INFL = ll(2e18) + ll(1e10);
const ui MOD = 1E9 + 7;
const double EPS = 1e-9;
#define FOR(i,n) for (int i=0;i<(n);++i)
#define ROF(i,x) for(int i = (x) ; i >= 0 ; --i)
#define MP make_pair
#define ALL(a) (a).begin(),(a).end()
#define ODD(x) (((x)&1)==0?(0):(1))
#define sign(x) ((x > 0) - (x < 0))
std::mt19937_64  generator(std::chrono::system_clock::now().time_since_epoch().count());

inline ll powmod(ll a,ll b,ll mod) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a, ll b) { return a ? gcd(b%a, a): b; }
ll lcm(ll a, ll b) { return a / gcd(a,b) * b; }


void READ(){
    ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef _DEBUG
    freopen ("in.txt", "r", stdin);
#endif
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0);
  //  freopen ("in.txt", "r", stdin);

    int n;cin>>n;
    vvi c(n,vi(26,0));
    FOR(i,n){
        string s;cin>>s;
        FOR(j,10){
            c[i][s[j]-'a']++;
        }
    }
    sort(c.begin(),c.end());
    ll ret=0;
    int acum=1;
    for(int i=1;i<n;++i){
        if (c[i]==c[i-1]) ++acum;
        else{
            ret += (ll)acum*(acum-1)/2;
            acum=1;
        }
    }
    ret += (ll)acum*(acum-1)/2;
    cout << ret;
}



Measured memory_bytes: 13568
#include <cstdio>
using namespace std;
int main() {
    int K, S; scanf("%d %d", &K, &S);
    int cnt = 0;
    for(int x = 0; x <= K; x++) {
        for(int y = 0; y <= K; y++) {
            if(S-x-y>=0 && S-x-y<=K) cnt++;
        }
    }
    printf("%d\n", cnt);
}

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

int main(){
  set<int> S;
  int N;
  cin >> N;
  int a;
  for(int i = 0;i<N;i++){
    cin >> a;
    S.insert(a);
  }
  cout << S.size() << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(void)
{
        string s;
        cin >> s;
        sort(s.begin(),s.end());
        if(s[0]==s[1] and s[2]==s[3] and s[0] != s[2]){
                cout << "Yes" << endl;
        }
        else cout << "No" << endl;
        return 0;
}

Measured memory_bytes: 256
N = int(input())
S = [str(i) for i in input()]

search = [("00"+str(s))[-3:] for s in range(0,1000)]
ans = []
for num in search:
    tmp_S = S
    if num[0] in tmp_S:
        tmp_S = tmp_S[tmp_S.index(num[0])+1:] 
    else:
        continue
    if num[1] in tmp_S:
        tmp_S = tmp_S[tmp_S.index(num[1])+1:] 
    else:
        continue
    if num[2] in tmp_S:
        ans.append(num)

print(len(ans))

Measured memory_bytes: 9684
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
 
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int left = a + b;
  int right = c + d;
  if (left > right)
    cout << "Left" << endl;
  else if (left < right)
    cout << "Right" << endl;
  else
    cout << "Balanced" << endl;   
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define rep(i,n) for (int i=0; i < (n); i++)

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef VI  Vec;
typedef VVI Mat;

void debug(const Mat M) {
  int n = M.size();
  rep (i, n) {
    rep (j, n) {
      cout << M[i][j] << " ";
    }
    cout << endl;
  }
  cout << "---" << endl;
}

Mat mul(const Mat& A, const Mat& B) {
  int n = A.size();
  Mat res = Mat(n, Vec(n, 0));
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      for (int k = 0; k < n; k++) {
        res[i][j] += A[i][k] * B[k][j];
        if (res[i][j] > 1) res[i][j] = 1;
      }
    }
  }
  return res;
}

// x^k mod m を計算
Mat pow(Mat A, int k) {
  int n = A.size();
  Mat res = Mat(n, Vec(n, 0));
  rep(i, n) res[i][i] = 1;
  while(k > 0) {
    if (k & 1) {
      res = mul(res, A);
      // debug(res);
    }
    A = mul(A, A);
    k >>= 1;
  }
  return res;
}

struct Edge {
  int from, to;
  Edge(int from, int to) : from(from), to(to) {}
};

bool solve(int n, int m, int z) {
  vector<Edge> es;
  es.push_back(Edge(-1, 0));  // 初期値用のダミーのエッジ
  rep(i, m) {
    int s, d;
    cin >> s >> d;
    s--;
    d--;
    es.push_back(Edge(s, d));
    es.push_back(Edge(d, s));
  }
  // 各エッジをもとにグラフを構築
  int gn = es.size();
  Mat g(gn, Vec(gn, 0));
  rep(i, gn) {
    Edge& e1 = es[i];
    rep(j, gn) {
      Edge& e2 = es[j];
      if (e1.to == e2.from && e1.from != e2.to) {
        // 直前に戻る辺でなく辿れるので辺を張る
        g[i][j] = 1;
      }
    }
  }
  // debug(g);
  
  Mat trasimitted = pow(g, z);
  rep(i, gn) {
    if (trasimitted[0][i] > 0 && es[i].to == n - 1) return true;
  }
  return false;
}

int main() {
  int n, m, z;
  while (cin >> n >> m >> z, n||m||z) cout << (solve(n, m, z) ? "yes" : "no") << endl;
  
  return 0;
}

Measured memory_bytes: 1380
/*************************************************\
           In the name of almighty ALLAH
                 MD.Faysal Hasan
                Comilla Univesity
\*************************************************/

#include<bits/stdc++.h>
using namespace std;

#define     ikarus_101  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef     long long             ll;
typedef     long double           ld;
typedef     unsigned long long    ull;
typedef     vector<ll>            vll;
typedef     pair<ll,ll>           pll;
typedef     vector<pll>           vpl;
typedef     map<ll,ll>            mll;
typedef     multiset<ll>          msl;
typedef     multimap<ll,ll>       Mll;
using pqboro=priority_queue<ll,vll,less<ll>>;
using pqchoto=priority_queue<ll,vll,greater<ll>>;

#define    all(str)       str.begin(),str.end()
#define    sajo(str)      sort(str.begin(),str.end())
#define    rev(str)       reverse(str.begin(),str.end())
#define    usajo(str)     sort(str.rbegin(),str.rend())
#define    vin(a)         for(auto &it : a) cin>>it
#define    vout(a)        for(auto it:a) cout<<it<<' ';cout<<nn
#define    pb             push_back
#define    eb             emplace_back
#define    mkp(x,y)       make_pair(x,y)
#define    F              first
#define    S              second
#define    yes            cout<<"YES"<<nn
#define    no             cout<<"NO"<<nn
#define    nn             "\n" ///endl
#define    rep(i,n)       for (i=0;i<n;++i )
#define    rep1(i,n)      for (i=1;i<=n;++i )

#define    min3(a,b,c)    min(a,min(b,c))
#define    max3(a,b,c)    max(a,max(b,c))
#define    sqr(x)         ((x)*(x))
#define    pi             2*acos(0.0)
#define    gcd(a,b)       __gcd(a,b)
#define    lcm(a,b)       (a/gcd(a,b))*b
#define    mem(a,b)       memset(a,b,sizeof (a))
#define    dec(x)         cout<<fixed<<setprecision(x)
#define    none(n)         __builtin_popcountll(n)

template < typename T > string toString ( T Number ) { stringstream ss ; ss << Number ; return ss.str() ; }
template < typename T > ll toll ( T str ) { stringstream ss ; ss << str ; ll num ; ss >> num ; return num ; }
ll power(ll n , ll k) { if(k == 0) return 1 ; if(k&1) return n*sqr(power(n,k/2)) ; else return sqr(power(n,k/2)); }

const   int  N   =   2e5+7;
const   int  M   =   1e9+7;
const   ll  inf  =   0x7f7f7f7f7f7f7f7f;
const   int dx[] =   {+1,+2,+2,+1,-1,-2,-2,-1};
const   int dy[] =   {-2,-1,+1,+2,+2,+1,-1,-2};

int main() {//ikarus_101

    int n,m,i,j,k,x;

    string s;cin>>s;
    k=0;
    for(auto it:s) {
        k += (it=='R');
    }
    if(k!=2) {
        cout << k << endl;
    }
    else {
        if(s[1]=='R') {
            cout << 2 << endl;
        } else {
                cout << 1 << endl;
        }
    }





    return 0;
}


Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include<queue>
#include<math.h>
using namespace std;
#define mod (1000000000+7)
#define N (10007)
#define INF 1e16
typedef long long ll;
typedef pair<ll,ll> P;


int main(void){
	int n;
	while(true){
		cin>>n;
		if(n==0)break;
		int ans=0;
		for(int i=1;i<=n-1;i++){
			ll sum=i;
			for(int j=i+1;j<=n;j++){
				sum+=j;
				if(sum==n){
					ans++;
					break;
				}
				if(sum>n)break;
			}
		}
		cout<<ans<<endl;
	}
    return 0;
}


Measured memory_bytes: 3012
import fractions
N,M = map(int,input().split())
S = input()
T = input()
x = fractions.gcd(N,M)
a = []
b = []
for i in range(int(x)):
  a.append(S[int(i*N/x)])
for i in range(int(x)):
  b.append(T[int(i*M/x)])
if a==b:
  print (int(N*M/x))
else:
  print (-1)

Measured memory_bytes: 5816
/**
 *    author:  [itmo] enot.1.10
 *    created: 23.10.2016 14:58:09       
**/
#define __USE_MINGW_ANSI_STDIO 0
#include <bits/stdc++.h>

#define F first
#define S second
#define pb push_back
#define mp make_pair
#define forn(i, n) for(int i = 0 ; (i) < (n) ; ++i)
#define eprintf(...) fprintf(stderr, __VA_ARGS__),fflush(stderr)
#define sz(a) ((int)(a).size())
#define all(a) (a).begin(),a.end()
#define pw(x) (1LL<<(x))

using namespace std;

typedef long long ll;
typedef double dbl;
typedef vector<int> vi;
typedef pair<int, int> pi;

const int inf = 1.01e9;
const dbl eps = 1e-9;

/* --- main part --- */

char s[111];

int main()
{
    #ifdef home
        assert(freopen("1.in", "r", stdin));
        assert(freopen("1.out", "w", stdout));
    #endif
    scanf("%s", s);
    int w = 0;
    for (int i = 0; s[i]; ++i)
    {
        if (s[i] == 'C') w = 1;
        if (s[i] == 'F' && w) return 0 * printf("Yes\n");
    }
    printf("No\n");
    #ifdef home
        eprintf("time = %d ms\n", (int)(clock() * 1000. / CLOCKS_PER_SEC));
    #endif
    return 0;
}


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

#define all(a) a.begin(), a.end()
#define allr(a) a.rbegin(), a.rend()
#define rev(v) reverse(v.begin(), v.end());
#define io() ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); srand(time(NULL));
#define check cout<<"?\n";
 
using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

signed main(){
    io();
    int n, k; cin >> n >> k;
    vector<int> v(n);
    int ans = 0;
    for(auto &x : v){
        cin >> x;
        x >= k ? ++ans : ans;
    }
    return cout << ans << '\n', 0;
}

Measured memory_bytes: 3740
#include <iostream>
#include<bits/stdc++.h>
#include<vector>
#define for0(i,n) for(int i=0;i<n;i++)
#define sp <<" "<<
#define pb(v,i) v.push_back(i)
#define er(v,i) v.erase(v.begin()+i)
#define MOD 1000000007
using namespace std;

int main() 
{
	int n,k;
	cin >> n>>k;
	int h[n];
	for(int i=0;i<n;i++)
		cin >> h[i];
	int dp[100001]={0};
	dp[1]=abs(h[1]-h[0]);
	for(int i=2;i<n;i++)
	{
		int o;
		int min=abs(h[i]-h[i-1])+dp[i-1];
		for(int j=i-2;j>=i-k;j--)
		{
			if(j<0)break;
			if(abs(h[i]-h[j])+dp[j]<min)min=abs(h[i]-h[j])+dp[j];
		}
		dp[i]=min;
	}
	cout << dp[n-1];
}


Measured memory_bytes: 1024
#include <stdio.h>

int main (void){
  int i,j,N,n;
  int A[3][3];
  for(i=0;i<3;i++){
    for(j=0;j<3;j++){
      scanf("%d",&A[i][j]);
    }
  }
  
  scanf("%d",&N);
  
  int b[N];
  for(n=0;n<N;n++){
    scanf("%d",&b[n]);
  }
  
  int C[3][3]={0,0,0,0,0,0,0,0,0};
  for(n=0;n<N;n++){
    for(i=0;i<3;i++){
      for(j=0;j<3;j++){
	
	if(A[i][j]==b[n]){
	  C[i][j]=1;
	}
	
      }
    }
  }
  
  if(C[0][0]==1&&C[0][1]==1&&C[0][2]==1){
    printf("Yes");
  }else if(C[1][0]==1&&C[1][1]==1&&C[1][2]==1){
    printf("Yes");
  }else if(C[2][0]==1&&C[2][1]==1&&C[2][2]==1){
    printf("Yes");
  }else if(C[0][0]==1&&C[1][1]==1&&C[2][2]==1){
    printf("Yes");
  }else if(C[2][0]==1&&C[1][1]==1&&C[0][2]==1){
    printf("Yes");
  }else if(C[0][0]==1&&C[1][0]==1&&C[2][0]==1){
    printf("Yes");
  }else if(C[0][1]==1&&C[1][1]==1&&C[2][1]==1){
    printf("Yes");
  }else if(C[0][2]==1&&C[1][2]==1&&C[2][2]==1){
    printf("Yes");
  }else{
   printf("No");
  }
  return 0;
}


Measured memory_bytes: 128
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <set>
#include <unordered_set>

using namespace std;

const unsigned long long base = (unsigned long long) 1e9 + 7;

inline unsigned long long Hash( int x, int y ) {
	return base * x + y;
}

int main( void ) {
	int h, w, n;
	scanf("%i %i %i", &h, &w, &n);
	
	unordered_set<unsigned long long> Q;
	
	vector<int> X(n), Y(n);
	for( int i = 0; i < n; i++ ) {
		scanf("%i %i", &X[i], &Y[i]);
		Q.insert(Hash(X[i], Y[i]));
	}
	
	unordered_set<unsigned long long> seen;
	
	long long ans[10] = {0};
	for( int i = 0; i < n; i++ ) {
		for( int x = 0; x <= 2; x++ ) {
			for( int y = 0; y <= 2; y++ ) {
				int sx = X[i] - x, sy = Y[i] - y;
				if( (sx >= 1) && (sy >= 1) && (sx+2 <= h) && (sy+2 <= w) && !seen.count(Hash(sx, sy)) ) {
					seen.insert(Hash(sx, sy));
					
					
					int count = 0;
					for( int c = 0; c < 3; c++ ) {
						for( int k = 0; k < 3; k++ ) {
							count += Q.count(Hash(sx+c, sy+k));
						}
					}
										
					ans[count]++;
				}
 			}
		}
	}
	
	ans[0] = (long long) (h - 2) * (w - 2);
	for( int i = 1; i <= 9; i++ ) {
		ans[0] -= ans[i];
	}
	
	for( int i = 0; i <= 9; i++ ) {
		printf("%lld\n", ans[i]);
	}
	
	return 0;
}

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

#define int long long
int dp[5003][5003] , arr[5003] , A , B , N;
void chkmin(int &a , int b){a = a < b ? a : b;}

signed main(){
	cin >> N >> A >> B;
	for(int i = 1 ; i <= N ; ++i) cin >> arr[i];
	memset(dp , 0x3f , sizeof(dp)); dp[0][0] = 0;
	for(int i = 0 ; i < N ; ++i)
		for(int j = 0 ; j <= N ; ++j)
			if(j < arr[i + 1]){
				chkmin(dp[i + 1][arr[i + 1]] , dp[i][j]);
				chkmin(dp[i + 1][j] , dp[i][j] + A);
			}
			else chkmin(dp[i + 1][j] , dp[i][j] + B);
	int mn = 1e18; for(int i = 1 ; i <= N ; ++i) mn = min(mn , dp[N][i]);
	cout << mn; return 0;
}

Measured memory_bytes: 195968
//In the name of Allah
#include <bits/stdc++.h>
using namespace std;
#define MAX 100011
#define ll long long
#define endl '\n'
ll dp[2][MAX],w;
int v[MAX],c[MAX];
int main() {
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n;
	cin>>n>>w;
	for(int i =0 ; i < n  ;i ++)cin>>c[i]>>v[i];
	dp[0][c[0]] = v[0];
	for(int i = 1; i < n ; i++){
		dp[1][c[i]] = v[i];
		for(int j = 1 ; j + c[i] <= w ; j++){
			if(dp[0][j])
				dp[1][j + c[i]] = max(dp[0][j] + v[i] , dp[0][j + c[i]]);
		}
		for(int j = 1; j <= w; j ++)dp[0][j] = max(dp[0][j],dp[1][j]);
	}
	ll ans = 0;
	for(int j = 1; j <= w; j++)ans= max(ans,dp[0][j]);
	cout<<ans;
	return 0; 
} 

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

template <class M, class E, class F = std::function<M(M, M)>, class A = std::function<M(M, E)>, class G = std::function<E(E, E)>>
class LazySegmentTree {
private:
  M* data;
  E* lazy;
  F op;
  G cp;
  A act;
  M e;
  E id;
  int sz;

  void propagate(int index) {
    if (lazy[index] == id) return;
    lazy[index << 1] = cp(lazy[index << 1], lazy[index]);
    lazy[(index << 1) | 1] = cp(lazy[(index << 1) | 1], lazy[index]);
    data[index] = act(data[index], lazy[index]);
    lazy[index] = id;
  }

  void propagate_topdown(int index) {
    int h = 0;
    for (int i = 1; i < index; i <<= 1) ++h;
    for (int i = h; i; i--) propagate(index >> i); 
  }

  void recalc(int index) { while (index >>= 1) data[index] = op(act(data[index << 1], lazy[index << 1]), act(data[(index << 1) | 1], lazy[(index << 1) | 1])); }

public:
  LazySegmentTree(int sz, const F& op, const A& act, const G& cp, const M& e, const E& id) : op(op), act(act), cp(cp), e(e), id(id), sz(sz) {
    data = new M[sz << 1];
    lazy = new E[sz << 1];
    for (int i = 0; i < (sz << 1); i++) data[i] = e;
    for (int i = 0; i < (sz << 1); i++) lazy[i] = id;
  }

  void update(int left, int right, const E& x) {
    if (left < 0) left = 0;
    if (right > sz) right = sz;
    left += sz; right += sz;

    propagate_topdown(left);
    propagate_topdown(right - 1);

    for (int l = left, r = right; l < r; l >>= 1, r >>= 1) {
      if (l & 1) {
        lazy[l] = cp(lazy[l], x);
        ++l;
      }
      if (r & 1) {
        --r;
        lazy[r] = cp(lazy[r], x);
      }
    }

    recalc(left);
    recalc(right - 1);
  }

  M query(int left, int right) {
    if (left < 0) left = 0;
    if (right > sz) right = sz;
    left += sz; right += sz;

    propagate_topdown(left);
    propagate_topdown(right - 1);

    M l = e, r = e;

    for (; left < right; left >>= 1, right >>= 1) {
      if (left & 1) {
        l = op(l, act(data[left], lazy[left]));
        ++left;
      }
      if (right & 1) {
        --right;
        r = op(act(data[right], lazy[right]), r);
      }
    }

    return op(l, r);
  }

  ~LazySegmentTree() {
    delete[] data;
    delete[] lazy;
  }
};

const int MOD = 998244353;

using namespace std;

int main() {
  int N, K;
  cin >> N >> K;
  
  auto f = [](int a, int b) {
    a += b;
    if (a >= MOD) a -= MOD;
    return a;
  };
  
  LazySegmentTree<int, int, decltype(f), decltype(f), decltype(f)> segTree(N * 3 + 10, f, f, f, 0, 0);
  
  vector<pair<int, int>> s(K);
  for (int i = 0; i < K; i++) cin >> s[i].first >> s[i].second;
  
  segTree.update(1, 2, 1);
  for (int i = 1; i <= N; i++) {
    int cur = segTree.query(i, i + 1);
    for (int k = 0; k < K; k++) {
      segTree.update(i + s[k].first, i + s[k].second + 1, cur);
    }
  }
  
  cout << segTree.query(N, N + 1) << endl;
  
  return 0;
}

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

//~ const int MOD=1000000007;
const int MOD=998244353;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

int main(){
	int a,b;cin>>a>>b;
	cout<<a*b<<endl;
}

Measured memory_bytes: 3624
#define _CRT_SECURE_NO_WARNINGS
#include<iostream>
#include<sstream>
#include<vector>
#include<algorithm>
#include<string.h>
#include<set>
#include<fstream>
#include<map>
#include<string>
#include <stdio.h>
#include<bitset>
#include<queue>
#include<iomanip>
#include<cmath>
#include<stack>
#include<climits>
#include<functional>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll>vl;
typedef vector<int>vi;
typedef vector<bool>vb;
typedef vector<double>vd;
typedef vector<char>vc;
typedef vector<string>vs;
#define MP make_pair
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define EPS 1e-9
#define PI 3.14159265359
const ll mod = 1000000007;
const ll OO = (ll)1e9;
const int dx[] = { 0, 1, 0, -1, 1, -1, 1, -1 };
const int dy[] = { 1, 0, -1, 0, 1, -1, -1, 1 };
ll gcd(ll a, ll b){ if (b == 0){ return a; }return gcd(b, a % b); }
ll fast_power(ll base, ll power){
	if (power == 0)
		return 1;
	if (power == 1)
		return (base % mod);
	if (power % 2 == 0)
		return (fast_power(((base*base) % mod), power / 2LL) % mod);
	else return ((base*fast_power(((base*base) % mod) % mod, power / 2LL)) % mod);
}
//#pragma warning (disable : 4996)
void Qalbaz()
{

	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cout << fixed << setprecision(2);
}

int main(){

	Qalbaz();

	string str, s;
	cin >> str;
	int x;
	cin >> x;
	int j = 0;
	for (int i = 0; i < str.size(); i++)
	{
		j++;
		if (j == 1)
			s.push_back(str[i]);
		if (j == x)
			j = 0;
	}
	cout << s;

	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
	int Y,M,D,N,r,i;
	for(scanf("%d",&N);N--;)
	{
		scanf("%d%d%d",&Y,&M,&D);
		for(i=Y+1,r=0;i<1000;i++)
			r+=i%3?195:200;
		for(i=M+1;i<11;i++)
			r+=Y%3?(i%2?20:19):20;
		for(i=D;i<=(Y%3?(M%2?20:19):20);i++)
			r+=1;
		printf("%d\n",r);
	}
}

Measured memory_bytes: 596
import java.util.*;

public class Main{
    public static void main(String args[]){
        Scanner in = new Scanner(System.in);
        int s = in.nextInt();

        int h = s / 3600;
        s %= 3600;

        int m = s / 60;
        s %= 60;

        System.out.println(h + ":" + m + ":" + s);
    }
}


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

int judge(int n){
    if(n==1)return 0;
    if(n==2)return 1;
    if(n%2==0)return 0;
    
    int j= (int)sqrt(n) + 1 ;
    for(int i=3;i<j;i+=2){
        if(n%i==0)return 0;
    }
    return 1;
}

void run(){
    int n , x , c=0;
    cin >> n ;
    
    for(int i=0;i<n;i++){
        cin >> x ;
        if(judge(x))c++;
    }
    cout << c << endl;
}

int main(void){
    run();
}


Measured memory_bytes: 3040
#include <bits//stdc++.h>
using namespace std;
#define rep(i,n,k) for(int i=n;i<k;i++)
#define int unsigned long long
#define F first 
#define S second
#define P make_pair 
struct Runrun{
    vector<int> r;
};

signed main(void){
 
    
    int n,m,q,p,r,ans,t;
    string s;
    vector<int> v;
    ans=0;
    Runrun a[100][10];
    cin>>n;m=3;
    while(1){
        
        if(ans<9){
        a[1][ans+1].r.push_back(ans+1);
        ans++;
        if(ans==n){
        cout<<ans<<endl;
        return 0;
        }
        }
        else if(ans<35){
            ans++;
            a[2][(ans-10)/3+1].r.push_back(((ans-10)/3+1)*10+(ans-10)/3+(ans-10)%3);
            
            if(ans==n){
                cout<<((ans-10)/3+1)*10+(ans-10)/3+(ans-10)%3<<endl;
                return 0;
            }
        }
        else{     
            q=1;
                    rep(j,0,m-1){
                        q=q*10;
                    }//3桁以上
            rep(i,1,10){
                if(i==1){
                    
                    a[m][1].r.push_back(q);//100000etc
                    ans++;
                    if(ans==n){
                        cout<<q<<endl;
                        return 0;
                    }
                    rep(j,0,m-2){//10???
                        rep(k,0,a[j+1][1].r.size()){
                            ans++;
                            a[m][1].r.push_back(q+a[j+1][1].r[k]);
                            if(ans==n){
                                cout<<q+a[j+1][1].r[k]<<endl;
                                return 0;
                            }
                        }
                    }
                }
                if(i>1){
                    rep(j,0,a[m-1][i-1].r.size()){
                        ans++;
                        a[m][i].r.push_back(q*i+a[m-1][i-1].r[j]);
                        if(ans==n){
                            cout<<q*i+a[m-1][i-1].r[j]<<endl;
                            return 0;
                        }
                    }
                }
                rep(j,0,a[m-1][i].r.size()){
                        ans++;
                        a[m][i].r.push_back(q*i+a[m-1][i].r[j]);
                        if(ans==n){
                            cout<<q*i+a[m-1][i].r[j]<<endl;
                            return 0;
                        }
                }
                if(i<9){
                    rep(j,0,a[m-1][i+1].r.size()){
                        ans++;
                        a[m][i].r.push_back(q*i+a[m-1][i+1].r[j]);
                        if(ans==n){
                            cout<<q*i+a[m-1][i+1].r[j]<<endl;
                            return 0;
                        }
                    }
                }
                
            }
            m++;
        }
        
    }
  
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define ft first
#define sc second
#define lb lower_bound
#define ub upper_bound
#define pb push_back
#define pt(sth) cout << sth << "\n"
#define chmax(a, b) {if(a<b) a=b;}
#define chmin(a, b) {if(a>b) a=b;}
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
static const ll INF=1e18;
static const ll MAX=1e5+7;
static const ll MOD=1e9+7;
ll max(ll a, ll b) {return a>b?a:b;}
ll min(ll a, ll b) {return a<b?a:b;}



int main(void) {
  ll N, K;
  cin >> N >> K;
  ll i;
  vector<P> su(N);
  ll ty=0;
  ll cnt[MAX]={};
  
  for(i=0; i<N; i++) {
    cin >> su[i].sc >> su[i].ft;
    su[i].sc--;
  }
  sort(su.rbegin(), su.rend());
  
  ll ans=0;
  ll t=0;
  priority_queue<P> q;
  for(i=0; i<K; i++) {
    q.push({-su[i].ft, su[i].sc});
    t+=su[i].ft;
    cnt[su[i].sc]++;
    if(cnt[su[i].sc]==1) ty++;
  }
  ans=t;
  ans+=ty*ty;
  
  for(i=K; i<N; i++) {
    while(q.size()) {
      P f=q.top(); q.pop();
      if(cnt[f.sc]>1) {
        t-=-f.ft;
        cnt[f.sc]--;
        q.push({-su[i].ft, su[i].sc});
        t+=su[i].ft;
        cnt[su[i].sc]++;
        if(cnt[su[i].sc]==1) ty++;
        chmax(ans, t+ty*ty);
        break;
      }
    }
  }
  
  pt(ans);
}




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

using namespace std;

int main(){

string a,b;
bool check =false;

cin>>a>>b;
 if(a.length()>b.length())
    cout<<"GREATER";
 else
    if(a.length()<b.length())
    cout<<"LESS";
 else{
    for(int i=0;i<a.length();i++){
        if(a[i]<b[i]){
            cout<<"LESS";
            check= true;
            break;}
            else
                if(a[i]>b[i]){
                cout<<"GREATER";
                check=true;
                break;}


    }
    if(check==false)
        cout<<"EQUAL";
 }
}



Measured memory_bytes: 256
#ifndef BZ
#pragma GCC optimize "-O3"
#endif
#include <bits/stdc++.h>

#define ALL(v) (v).begin(), (v).end()
#define rep(i, l, r) for (int i = (l); i < (r); ++i)

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

using namespace std;


/*
ll pw(ll a, ll b) {
	ll ans = 1; while (b) {
		while (!(b & 1)) b >>= 1, a = (a * a) % MOD;
		ans = (ans * a) % MOD, --b;
	} return ans;
}
*/

int main() {
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	int n;
	string s;
	cin >> n;
	cin >> s;
	int cc = 0;
	for (char c: s) {
		if (c == 'R')
			++cc;
		else
			--cc;
	}
	if (cc > 0)
		cout << "Yes\n";
	else
		cout << "No\n";
	return 0;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = (int)(n); i > 0; i--)
#define FOR(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define INF 2e9
#define ALL(v) (v).begin(), (v).end()
template <typename Iter> std::string join(Iter begin, Iter end, std::string const& separator){ std::ostringstream result; if (begin != end){ result << *begin++; }; while (begin != end){ result << separator << *begin++; }; return result.str(); }
using namespace std;
typedef long long ll;
void solve() {
  ll x;
  cin >> x;
  vector<ll> prime_list;
  FOR(i, 2, x * 2) {
    bool is_prime = true;
    for(auto j: prime_list) {
      if(i % j == 0) {
        is_prime = false;
        break;
      }
    }
    if(is_prime) {
      if(x <= i) {
        cout << i << endl;
        return;
      }
      prime_list.push_back(i);
    }
  }
}
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  solve();
  return 0;
}


Measured memory_bytes: 512
//package com.company;

import java.io.*;
import java.util.*;

public class Main {
    static long TIME_START, TIME_END;

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
//        Scanner sc = new Scanner(new FileInputStream("Test.in"));
        PrintWriter pw = new PrintWriter(System.out);
//        PrintWriter pw = new PrintWriter(new FileOutputStream("Test.out"));

        Runtime runtime = Runtime.getRuntime();
        long usedMemoryBefore = runtime.totalMemory() - runtime.freeMemory();
        TIME_START = System.currentTimeMillis();
        Task t = new Task();
        t.solve(sc, pw);
        TIME_END = System.currentTimeMillis();
        long usedMemoryAfter = runtime.totalMemory() - runtime.freeMemory();
        pw.close();
        System.out.println("Memory increased:" + (usedMemoryAfter - usedMemoryBefore) / 1000000);
        System.out.println("Time used: " + (TIME_END - TIME_START) + ".");
    }

    public static class Task {

        public void solve(Scanner sc, PrintWriter pw) throws IOException {
            int n = sc.nextInt();
            int k = sc.nextInt();
            if (k % 2 == 1) {
                long t = n / k;
                long res = t * t * t;
                pw.println(res);
            } else {
                long t = n / k;
                long res = t * t * t;
                long r = t;
                if (t * k + k / 2 <= n) {
                    r++;
                }
                res += r * r * r;
                pw.println(res);

            }


        }


    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(FileReader s) throws FileNotFoundException {
            br = new BufferedReader(s);
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

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

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

        public String nextLine() throws IOException {
            return br.readLine();
        }

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

        public boolean ready() throws IOException {
            return br.ready();
        }
    }
}

Measured memory_bytes: 22612
#include <stdio.h>

int main(){
int x, a, b, d1=-1, d2=-2 ;
scanf("%d %d %d", &x, &a, &b);
d1=x-a ;
d2=x-b ;
if(d1<0){
    d1=a-x;
}
if(d2<0){
    d2=b-x;
}

d1<d2? printf("A") : printf("B");
return 0;
}


Measured memory_bytes: 1652
lists = []
lists2 = []
a = int(input())
if a %10 == 0:
    lists2.append(a)
else:
    lists.append(a)
n = int(input())
if n %10 == 0:
    lists2.append(n)
else:
    if len(lists) != 0:
        for i in range(len(lists)):
            if lists[i] % 10 <= n%10:
                lists.insert(i,n)
                break
            if len(lists)-1 == i:
                lists.append(n)
    else:
        lists.append(n)
n = int(input())
if n %10 == 0:
    lists2.append(n)
else:
    if len(lists) != 0:
        for i in range(len(lists)):
            if lists[i] % 10 <= n%10:
                lists.insert(i,n)
                break
            if len(lists)-1 == i:
                lists.append(n)
    else:
        lists.append(n)
n = int(input())
if n %10 == 0:
    lists2.append(n)
else:
    if len(lists) != 0:
        for i in range(len(lists)):
            if lists[i] % 10 <= n%10:
                lists.insert(i,n)
                break
            if len(lists)-1 == i:
                lists.append(n)
    else:
        lists.append(n)
n = int(input())
if n %10 == 0:
    lists2.append(n)
else:
    if len(lists) != 0:
        for i in range(len(lists)):
            if lists[i] % 10 <= n%10:
                lists.insert(i,n)
                break
            if len(lists)-1 == i:
                lists.append(n)
    else:
        lists.append(n)
time = 0
for t in lists2:
    time += t
for t in lists[0:len(lists)-1]:
    time += (10 - t%10) + t
if len(lists) >= 1:
    time +=lists[-1]
print(time)

Measured memory_bytes: 3188
##？
n,x,y = map(int,input().split( ))
x-=1;y-=1
cnt = [0]*n

for i in range(n):
    for j in range(i+1,n):
        dist = min(abs(j-i),abs(x-i)+1+abs(j-y))
        cnt[dist]+=1
for i in range(1,n):
    print(cnt[i])


Measured memory_bytes: 3444