akhauriyash/Code-Regression huggingface dataset:
#include <cassert>
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <cstdint>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
 
#define rep(i, a, b) for (long long i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if(b==0)return 1;
  if ((a == 0)||(mod!=-1&&(a+mod)%mod==0))return 0;
  long long x = 1;
  while (b > 0) {
    if (b & 1)x = (mod!=-1)?(x * a) % mod:x*a;
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}

const long long MOD = 998244353;
// const long long MOD = 1e9 + 7;

using ll = long long;
using P=std::pair<long long,long long>;

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

  using t=std::tuple<std::string,ll,ll>;

  ll n;
  std::cin>>n;

  std::set<t> set;

  rep(i,0,n){
    std::string s;
    ll p;
    std::cin>>s>>p;
    set.insert(t(s,-p,i));
  }

  for(auto e:set){
    std::cout<<std::get<2>(e)+1<<"\n";
  }

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main()
{
    int N;
    int M;
    cin >> N;
    cin >> M;
    std::vector<int> dnaLen;
    int sum=0;
    int tmp =0;
    for(int i=0; i<M ; i++){
        cin >> tmp;
        sum += tmp;
    }
    int ans = N - sum;
    if(ans >= 0 ){
    cout << ans << endl;
    }
    else cout << "-1" << endl;
}

Measured memory_bytes: 3636
class Main
{
    public static void main(String[] args)
    {
        for (int i = 1; i <= 9; i ++)
        {
            for (int j = 1; j <= 9; j ++)
            {
                System.out.println(i+"x"+j+"="+i*j);
            }
        }
    }
}

Measured memory_bytes: 24224
#include <bits/stdc++.h>
using namespace std;
#define MAX (int)2e5 + 100
long long st[4*MAX] , h[MAX] , val[MAX];
int n;
void update(int idx , long long v , int l = 0 , int r = n-1 , int p = 1)
{
    if(l == r){st[p] = v;return;}
    int mid = (l+r)>>1;
    if(idx <= mid)  update(idx,v,l,mid,2*p);
    else            update(idx,v,mid+1,r,2*p+1);
    st[p] = max(st[2*p],st[2*p+1]);
}
long long rmq(int a, int b , int l = 0 , int r = n-1 , int p = 1)
{
    if(a > b)return 0;
    if(b < l || r < a)return -1e15;
    if(a <= l && r <= b)return st[p];
    int mid = (l+r)>>1;
    return max(rmq(a,b,l,mid,2*p),rmq(a,b,mid+1,r,2*p+1));
}
int main()
{
    cin >> n;
    for(int i = 1 ; i <= n ; i++)   cin >> h[i];
    for(int i = 1 ; i <= n ; i++)   cin >> val[i];
    n++;

    for(int i = n-1 ; i >= 0 ; i--) update(h[i],rmq(h[i]+1,n-1)+val[i]);
    cout << rmq(0,0) << '\n';
    return 0;
}


Measured memory_bytes: 8448
//__th December 2016
#include <bits/stdc++.h>
using namespace std;
#define wl(n) while(n--)
#define fr(i,a,b) for(i=a;i<b;i++)
#define rev(i,a,b) for(i=b-1;i>=a;i--)

#define mem(a,i) memset(a,i,sizeof(a))
typedef pair<int,int> ii;
#define mp make_pair
#define ll long long
#define MOD 1000000007
#define pb push_back
#define psh push
#define nl printf("\n")
#define fi first
#define sec second

#define si(n) scanf("%d",&n);

#define ss(s) scanf("%s",s)
#define sc(c) scanf("%c",&c)
#define sf(f) scanf("%lf",&f)

#define pi(n) printf("%d\n", n)

#define ps(s) printf("%s\n", s)
#define pc(c) printf("%c\n", c)
#define pf(f) printf("%lf\n", f)
#define INF (1LL<<52)
map<int,string>CharMap;
void num2str()
{
	
	CharMap[0]="0";
	CharMap[1]="1";
	CharMap[2]="2";
	CharMap[3]="3";
	CharMap[4]="4";
	CharMap[5]="5";
	CharMap[6]="6";
	CharMap[7]="7";
	CharMap[8]="8";
	CharMap[9]="9";
}
string to_string(ll n)
{
	string s="";
	while(n>0)
	{
	   int x=n%10;
	   n/=10;
	   s=CharMap[x]+s;	
	}
	return s;
}
ll pow1(ll x,ll y)
{
    if(y==0)
    return 1;
    ll temp= pow1(x,y/2)%MOD;
    if(y%2==0)
    return (temp*temp)%MOD;
    else
    return (((temp*temp)%MOD)*x)%MOD;
}

ll gcd(ll a,ll b)
{
	if(b==0)
		return a;
	return gcd(b,a%b);
}
ll A[100005];
int main()
{
	int n,i;
	ll x,cnt=0;
	num2str();
	cin>>n>>x;
	fr(i,0,n)
	{
		cin>>A[i];
	}
	if(A[0] > x)
	{
		cnt+=(-x+A[0]);
		A[0]-=(-x+A[0]);
	}
	fr(i,1,n)
	{
		if(A[i]+A[i-1] > x)
		{
			int d=(A[i]+A[i-1])-x;
			A[i]-=d;
			cnt+=d;
		} 
	}
	cout<<cnt;
	nl;
	return 0;
}



Measured memory_bytes: 1024
#include<iostream>

using namespace std;

int main(){

	int n;
	int k[10000];
	int i=0;
	int j=0;
	int min=0;
	int missed=0;
	int result[10000];

	for(j=0;true;j++){
	
		min=0;
		missed=0;
	
		cin>>n;
		
		if(n==0){
			break;
		}

		for(i=0;i<n;i++){
			cin>>k[i];
		
			if(k[i]!=0){
				min+=1;
			}
			if((k[i]==1)or(k[i]==0)){
				missed+=1;
			}
		
			if(missed==n){
				result[j]=-1;
			}else{
				result[j]=min+1;
			}
		}
	}
	
	for(i=0;i<j;i++){
		if(result[i]==-1){
			cout<<"NA"<<endl;
		}else{
			cout<<result[i]<<endl;
	        }
	}
}

Measured memory_bytes: 1212
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_set>
#include <bitset>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define szz(x) (int)x.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
typedef tuple<int, int, int> t3;

const int MOD = 1e9 + 7;
int pw(int x, int y = MOD - 2) {
	int res = 1;
	while(y) {
		if(y & 1) res = (ll) res * x % MOD;
		x = (ll) x * x % MOD;
		y >>= 1;
	}
	return res;
}

ll F[200020];

ll C(int a, int b) {
	return F[a+b] * pw(F[a]) % MOD * pw(F[b]) % MOD;
}

int main() {
	F[0] = 1;
	for(int i=1;i<200020;i++) F[i] = i * F[i-1] % MOD;
	int h, w, a, b; scanf("%d%d%d%d", &h, &w, &a, &b);
	int x = min(h-a, w-b);
	ll ans = 0;
	for(int i=0;i<x;i++) {
		ans = (ans + C(h - a - 1 - i, b + i) * C(w - b - 1 - i, a + i)) % MOD;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>


using namespace std;
using ll = long long;
using ull = unsigned long long;

const ll INF = 1e16;
const ll MOD = 1e9 + 7;

#define REP(i, n) for(ll i = 0; i < n; i++)









int main() {
    ll n, k;
    cin >> n >> k;
    vector<pair<ll, ll>> v(n);
    REP(i, n){
        ll t, d;
        cin >> t >> d;
        t--;
        v[i] = {d, t};
    }
    sort(v.begin(), v.end(), greater<pair<ll, ll>>());
    priority_queue<ll, vector<ll>, greater<ll>> que;
    vector<ll> used(n);
    ll ans = 0, sum = 0, kind = 0;
    REP(i, k){
        if(used[v[i].second]){
            que.push(v[i].first);
            sum += v[i].first;
        }
        else{
            used[v[i].second]++;
            sum += v[i].first;
            kind++;
        }
    }
    ans = max(ans, sum + kind * kind);
    for(ll i = k; i < n; i++){
        if(!que.empty() && !used[v[i].second]){
            used[v[i].second]++;
            kind++;
            sum += v[i].first;
            sum -= que.top();
            que.pop();
        }
        ans = max(ans, sum + kind * kind);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3196
#include<bits/stdc++.h>
#include<iomanip>
using namespace std;
typedef long long ll;
typedef long  l;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<n;i++)
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
const int INF=1000000001;
const double PI=3.141592653589;


int main(){
  int n; cin>>n;
  vector<int> a(n);
  vector<int> b(n);
  vector<int> c(n);
  rep(i,n) cin>>a[i];
  rep(i,n) cin>>b[i];
  rep(i,n) cin>>c[i];

  sort(ALL(a));
  sort(ALL(c));

  ll ans=0;
  rep(i,n){
    ans+=(lower_bound(ALL(a),b[i])-a.begin())*(c.end()-upper_bound(ALL(c),b[i]));

    // cout<<ans<<endl;
  }
  cout<<ans<<endl;

  return 0;
}


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

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define seq vector
signed main(){
    int N,M,s,t,c;
    cin >> N >> M;

    vector< vector<int> > table(N,vector<int>(N,1e9));
    vector< vector<int> > edges(M,vector<int>(0));
    for(int i=0;i<N;i++){
        table[i][i] =0;
    }
    for(int i=0;i<M;i++){
        cin >> s >> t >> c;
        s--;t--;
        table[s][t] =c;
        table[t][s] =c;
        edges[i].push_back(s);
        edges[i].push_back(t);
        edges[i].push_back(c);
    }

    for(int k=0;k<N;k++){
        for(int i=0;i<N;i++){
            for(int j=0;j<N;j++ ){
                if(table[i][j] > table[i][k]+table[k][j])
                    table[i][j] = table[i][k]+table[k][j];
            }
        }
    }
    int count =0;
    for(auto i : edges){
        s=i[0];
        t=i[1];
        c=i[2];

        if (table[s][t] != c)
            count++;
    }
    cout << count << endl;


    
}

Measured memory_bytes: 384
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>

using ll = long long;

using namespace std;

using P = pair<long, int>;

#define MAX_N 1000010
// トポロジカルソートしつつ閉路検出 O(V+E)
vector<int> G[MAX_N], // 隣接行列
            torder;   // トポロジカル順序の格納先
int ins[MAX_N] = {0}, // 各ノードの入次数
    d[MAX_N]   = {0}; // 根ノードからの最大距離、これの最大値がDAGの最大距離

// DAG(ループなし)なら最大距離を、ループありなら-1を返す
// Gとinsを入力から作っておいて、torderとdにこの関数で書き込む
// nは頂点の数
int topological_sort(int n) {
    int cnt = 0, ans = 0;
    queue<int> zeros;
    for (int i=0; i<n; i++)
        if (ins[i] == 0) {
            zeros.push(i);
            cnt++;
        }
    while (!zeros.empty()) {
        int v = zeros.front(); zeros.pop();
        torder.push_back(v);
        for (auto g:G[v]) {
            ins[g]--; // v->gの辺を消す
            d[g] = max(d[g], d[v]+1);
            ans  = max(ans,  d[g]);
            if (ins[g] == 0) {
                zeros.push(g);
                cnt++; // 訪問した頂点をカウント、閉路がある場合訪れない点ができる
            }
        }
    }
    if (cnt < n) return -1;
    else return ans;
}

int main() {
    int n;
    cin >> n;
    int zip[n][n], cnt=0;
    for (int i=0; i<n; i++) {
        for (int j=i+1; j<n; j++) {
            zip[i][j] = zip[j][i] = cnt;
            cnt++;
        }
    }
    for (int i=0; i<n; i++) {
        int a;
        cin >> a;
        a--;
        int prev = zip[i][a];
        for (int j=0; j<n-2; j++) {
            cin >> a;
            a--;
            G[prev].push_back(zip[i][a]);
            prev = zip[i][a];
            ins[prev]++;
        }
    }
    fill(d, d+cnt, 1);
    cout << topological_sort(cnt) << '\n';
    return 0;
}

Measured memory_bytes: 53112
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;

/*
*/

ll a,b,t;

void init(){
	cin>>a>>b>>t;
}

int main(void){
	init();
	cout<<t/a*b<<endl;
	return 0;
}

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

#define int long long
#define double long double
#define ff first
#define ss second
#define endl '\n'
#define ii pair<int, int>
#define mp make_pair
#define mt make_tuple
#define DESYNC                      \
  ios_base::sync_with_stdio(false); \
  cin.tie(0);                       \
  cout.tie(0)
#define pb push_back
#define vi vector<int>
#define vii vector<ii>
#define all(x) x.begin(), x.end()
#define EPS 1e-9
#define INF 1e18
#define ROOT 1
#define M 1000000007
#define curtime chrono::steady_clock::now().time_since_epoch().count
#define rep(i, beg, n, s) for (int i = beg; i < n; i += s)
const double PI = acos(-1);

using namespace std;

inline int mod(int n, int m = M)
{
  int ret = n % m;
  if (ret < 0)
    ret += m;
  return ret;
}

int exp(int n, int k)
{
  if (k == 0)
    return 1;
  if (k == 1)
    return n;
  int ax = exp(n, k / 2);
  ax = mod(ax * ax);
  if (k % 2)
    ax = mod(ax * n);
  return ax;
}

int gcd(int a, int b)
{
  if (a == 0)
    return b;
  else
    return gcd(b % a, a);
}
//#define MULTIPLE_TEST_CASE
void solution()
{
  int x, k, d;
  cin >> x >> k >> d;
  x = abs(x);
  int moves = x / d;
  if (moves >= k)
  {
    cout << x - k * d << endl;
    return;
  }
  k -= moves;
  if (k % 2 == 0)
    cout << x - moves * d << endl;
  else
    cout << abs(x - moves * d - d) << endl;
}

int32_t main()
{
  DESYNC;
  mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
  int t = 1;
#ifdef MULTIPLE_TEST_CASE
  cin >> t;
#endif
  while (t--)
    solution();
}


Measured memory_bytes: 3648
using System;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
class Program
{
    static void Main()
    {
        //入力
        //int n = 100;
        /*
        long n = long.Parse(Console.ReadLine());
        long[] input = new long[5];
        for(int a = 0; a < 5; a++)
        {
            input[a]=long.Parse(Console.ReadLine());
        }
        */
        int[] input = Console.ReadLine().Split().Select(i =>int.Parse(i)).ToArray();
        Console.WriteLine(input.Sum()-Math.Max(input[0],Math.Max(input[1],input[2])));
        

        /*
        //処理速度計測
        var sw = new System.Diagnostics.Stopwatch();
        sw.Start();
        //解法

        //処理速度表示
        sw.Stop();
        TimeSpan ts = sw.Elapsed;
        Console.WriteLine((int)(Math.Floor((ts).TotalMilliseconds))+"ms");
        */
        Console.ReadLine();
        
    }
}

Measured memory_bytes: 13396
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	int a, b;

	cin >> a >> b;
	while(a != 0 && b != 0){
		if (a > b){
		  a %= b;
		}
		else b %= a;
	}
	cout << max(a, b) << endl;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct edge{
    ll to, cost;
};


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

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

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll n;
    cin>>n;
    vector<ll> a(n);
    ll sum = 0;
    for(ll i=0;i<n;++i){
        cin>>a[i];
        sum ^= a[i];
    }

    for(ll i=0;i<n;++i){
        ll ans = sum ^ a[i];
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 4768
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <climits>
#include <sstream>
#include <iterator>
#include <sstream>
#include <iomanip>
#include <istream>
#include <cstring>
#include <cstdio>
#include <cstdlib>
using namespace std;

int main()
{
   int n;
   vector<int> a;

   cin >> n;

   for(int i=0; i<n; i++) {
       int x;
       cin >> x;
       a.push_back(x);
   }
   
   int count = 0;
   for(int i =0; i<n; i++) {
       while(a[i]%2 == 0) {
           count++;
           a[i]/=2;
       }
   }

   cout << count << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <string.h>
#include <iomanip>
#include <stdio.h>
#include <set>
#include <vector>
#include <map>
#include <cmath>
#include <algorithm>
#include <memory.h>
#include <string>
#include <sstream>
#include <cstdlib>
#include <ctime>
#include <cassert>

using namespace std;

typedef long long LL;
typedef pair<int,int> PII;

#define MP make_pair
#define PB push_back
#define FF first
#define SS second

#define FORN(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD(i, n) for (int i = (int)(n) - 1; i >= 0; i--)

#define DEBUG(X) { cout << #X << " = " << (X) << endl; }
#define PR0(A,n) { cout << #A << " = "; FORN(_,n) cout << A[_] << ' '; cout << endl; }

// #define FL fflush(stdout)

#define MOD 1000000007
#define INF 2000000000

int GLL(LL& x) {
  return scanf("%lld", &x);
}

int GI(int& x) {
  return scanf("%d", &x);
}

string a, b, c;
int main() {
  cin >> a >> b >> c;
  char x, y, z;
  x = toupper(a[0]);
  y = toupper(b[0]);
  z = toupper(c[0]);
  cout << x << y << z << endl;
  return 0;
}


Measured memory_bytes: 256
import std.algorithm, std.container, std.conv, std.math, std.range, std.typecons, std.stdio, std.string;

auto rdsp(){return readln.splitter;}
void pick(R,T)(ref R r,ref T t){t=r.front.to!T;r.popFront;}
void readV(T...)(ref T t){auto r=rdsp;foreach(ref v;t)pick(r,v);}

void main()
{
  int a, b, c, d; readV(a, b, c, d);
  writeln(max(a*b, c*d));
}


Measured memory_bytes: 256
import java.util.*;

public class Main
{
	public static void main(String[] args)
	{
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int k = sc.nextInt();
		for (int i = Math.min(a, b); i >= 1; --i)
		{
			if (a % i == 0 && b % i == 0)
			{
				--k;
				if (k == 0) 
				{
					System.out.println(i);
				}
			}
		}
	}
}


Measured memory_bytes: 23892
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define RREP(i,n) for(int i = n - 1; i >= 0; i--)

#define ALL(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

#define UNIQUE(v) do{sort(v.begin(), v.end()); v.erase( unique(v.begin(), v.end()), v.end() );} while(0)


#define y0 y3487465
#define y1 y8687969

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

string s;
int x, y;

int main(){
  cin >> s >> x >> y;
  vi vx, vy;
  bool hori = true;
  s += 'T';
  int ct = 0;
  REP(i, s.size()) {
    if(s[i] == 'T') {
      if(hori) vx.pb(ct);
      else vy.pb(ct);
      hori = !hori;
      ct = 0;
    } else {
      ct++;
    }
  }
  
  int lx = vx.size(), ly = vy.size(), l = 16000, s = 8000;
  bool dpx[lx][l + 1], dpy[ly + 1][l + 1];
  REP(i, lx) REP(j, l + 1) dpx[i][j] = false;
  REP(i, ly + 1) REP(j, l + 1) dpy[i][j] = false;
  dpx[0][s + vx[0]] = true;
  REP(i, lx - 1) {
    REP(j, l + 1) {
      if(j >= vx[i + 1]) dpx[i + 1][j] = dpx[i + 1][j] || dpx[i][j - vx[i + 1]];
      if(j + vx[i + 1] < l + 1) dpx[i + 1][j] = dpx[i + 1][j] || dpx[i][j + vx[i + 1]];
    }
  }

  dpy[0][s] = true;
  REP(i, ly) {
    REP(j, l + 1) {
      if(j >= vy[i]) dpy[i + 1][j] = dpy[i + 1][j] || dpy[i][j - vy[i]];
      if(j + vy[i] < l + 1) dpy[i + 1][j] = dpy[i + 1][j] || dpy[i][j + vy[i]];
    }
  }

  if(dpx[lx - 1][s + x] && dpy[ly][s + y]) cout << "Yes" << endl;
  else cout << "No" << endl;

  return 0;
}


Measured memory_bytes: 124288
#!/usr/bin/env python3
import sys
sys.setrecursionlimit(10**7)

# 1 ✕ N
N, M = list(map(int, input().rstrip().split()))

H = list(map(int, input().rstrip().split()))

A = tuple(map(int, input().rstrip().split()) for _ in range(M))


items = dict((i + 1, []) for i in range(N))

for k, v in A:
    items[k].append(H[v - 1])
    items[v].append(H[k - 1])

# print(items)

ans = 0
for i in range(N):
    if len(items[i + 1]) == 0:
        ans += 1
        continue

    found = False
    for item in items[i + 1]:
        if item >= H[i]:
            found = True
            continue

    if not found:
        ans += 1
        continue

    # if len(list(filter(lambda hx: H[i] >= hx, items[i + 1]))) == 0:
    #     print(i + 1)
    #     ans += 1
    #     continue
        #     # if len(items[i + 1]) == 0:
        #     #     ans += 1
        #     #     continue

        #     print("------------")
        #     print(items[i + 1])
        #     tmp = list(filter(lambda x: H[i] >= H[x - 1], items[i + 1]))
        #     print(tmp)

        #     if len(list(filter(lambda x: H[i] >= H[x - 1], items[i + 1]))) == 0:
        #         ans += 1
        #         continue

print(ans)


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

using lint = long long int;
using pint = pair<int, int>;
using plint = pair<lint, lint>;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for (int i = (begin), i##_end_ = (end); i < i##_end_; i++)
#define IFOR(i, begin, end) for (int i = (end)-1, i##_begin_ = (begin); i >= i##_begin_; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)

int main()
{
    int n;cin >> n;
    vector<int> v(n);
    REP(i,n){
        cin >> v[i];
    }
    lint ans=0;
    REP(i,n){
        ans += v[i] - 1;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
using namespace std;

int main()
{
	int n;
	int h[4][3][10] = { {{}} };

	cin >> n;

	for (int i = 0; i < n; i++)
	{
		int b, f, r, v;
		cin >> b >> f >> r >> v;

		h[b - 1][f - 1][r - 1] += v;
	}

	for (int i = 0; i < 4; i++) {
		for (int j = 0; j < 3; j++) {
			for (int k = 0; k < 10; k++) {
				cout << " " << h[i][j][k];
			}
			cout << endl;
		}
		if (i == 3) continue;
		cout << "####################" << endl;
	}
	return 0;
}


Measured memory_bytes: 3104
#include <iostream>
#include <string>
#include <cstdlib>
#include <cstdio>
#include <queue>
#include <stack>
#include <list>
#include <utility>
#include <vector>
#include <set>
#include <algorithm>
#include <cmath>
#include <climits>
#include <map>
#include <unordered_map>
#include <string.h>
#include<iomanip>
#include <iterator>
#include <locale>

#define all(a) a.begin(),a.end()
#define VV(T) vector<vector< T > >
#define rep(i,N) for(int i = 0; i <N; i++)
#define repsg(i,s,g) for(int i = s; i <g; i++)
#define name(x) #x
using namespace std;

const int INF = 10000000;
const long long INFL = (1LL<<50);
const double PI = atan(1)*4;
const int MOD = pow(10,9)+7;
int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};

typedef long long ll,LL;
typedef vector<int> vint;
typedef vector<vector<int> > vvint;
typedef vector<long long> vll, vLL;
typedef vector<vector<long long> > vvll, vvLL;
typedef pair<int,int> pii;
typedef pair<LL, LL> pLL;


// vector入力
template<typename T>
istream& operator >> (istream& is, vector<T>& vec){
    for(T& x: vec) is >> x;
    return is;
}
// vector出力
template<typename T>
ostream& operator << (ostream& os, vector<T>& vec){
    for(int i=0; i<vec.size(); i++){
        os << vec[i] << ( i+1 == vec.size() ? "" : " " );
    }
    return os;
}


template< typename T >
struct edge{
    int src, to;T cost;
    edge(int to,T cost) :src(-1),to(to),cost(cost){}
    edge(int src, int to, T cost) :src(src),to(to),cost(cost){}edge
    &operator=(const int &x){
        to =x;
        return *this;
    }
    operator int() const{ return to;}
};

template< typename T >
using Edges =vector< edge<T> >;
template< typename T >
using WeightedGraph =vector< Edges<T> >;
using UnWeightedGraph =vector< vector<int> >;
template< typename T >
using Matrix =vector< vector<T> >;


template< typename T >
///与えられた隣接行列を用いてワーシャルフロイド法によりノード間最短距離を求める。閉路がある場合、ループ後にg[k][k] < 0なるノードkが存在
///gでエッジのない部分をINFにしておくことを忘れないように！
void warshall_floyd(Matrix< T > &g, T INF) {
    for(int k = 0; k < g.size(); k++) {
        for(int i = 0; i < g.size(); i++) {
            for(int j = 0; j < g.size(); j++) {
                if(g[i][k] == INF || g[k][j] == INF) continue;
                g[i][j] = min(g[i][j], g[i][k] + g[k][j]);
            }
        }
    }
}

vector<int> r;

int main() {
    int n;cin>>n;
    Matrix<ll> d(n,vector<ll>(n,INFL));
    rep(i,n){
        rep(j,n){
            int v;cin>>v;
            d[i][j]=v;
        }
    }
    
    Matrix<ll> original(d);
    warshall_floyd(d,INFL);
    if(original != d){cout<<-1<<endl;return 0;}
    
    ll ans = 0;
    
    rep(i,n)rep(j,n){
        bool flag = false;
        if(i==j) continue;
        rep(k,n){
            if(k==i || k==j) continue;
            if (d[i][j] == d[i][k]+d[k][j]) {
                flag = true;
                break;
            }
        }
        
        if(!flag) ans +=d[i][j];
        
    }
    
    
    cout<<ans/2<<endl;
    
    return 0;
}










Measured memory_bytes: 1664
/* ex 7_3
   KitamoriFumiya */
 
#include <stdio.h>
#include <stdlib.h>
 
int main(void){
	int i, j, row, column, *ptr_row, *ptr_column;
	char **ptr;
	scanf("%d %d\n", &row, &column);
	//各行の配列へのポインタ分のメモリ領域を確保
	ptr = (char**)calloc(row, sizeof(char*));
	if(ptr == NULL){
		fprintf(stderr, "calloc error.\n");
		exit(1);
	}
	
	//各行の要素分のメモリ領域を確保
	for(i = 0; i < row; i++){
		ptr[i] = (char*)calloc(column, sizeof(char));
		if(ptr[i] == NULL){
			fprintf(stderr, "calloc error.\n");
			exit(1);
		}
	}
	// 残る行を記録するためのメモリ領域を確保
	ptr_row = (int*)calloc(row, sizeof(int));
	if(ptr_row == NULL){
		fprintf(stderr, "calloc error.\n");
		exit(1);
	}
	// 残る行を記録するptr_rowを初期化
	for(i = 0; i < row; i++){
		ptr_row[i] = 0;
	}
	// 残る列を記録するためのメモリ領域を確保
	ptr_column = (int*)calloc(column, sizeof(int));
	if(ptr_column == NULL){
		fprintf(stderr, "calloc error.\n");
	    exit(1);
	}
	// 残る列を記録するptr_columnを初期化
	for(i = 0; i < column; i++){
		ptr_column[i] = 0;
	}
	// 元のマス目を入力し、黒を含む行と列は残すので残る列、行を記録する配列に1を格納
	for(i = 0; i < row; i++){
		for(j = 0; j < column; j++){
			scanf(" %c", &ptr[i][j]);
			if(ptr[i][j] == '#'){
				ptr_row[i] = 1;
				ptr_column[j] = 1;
			}
		}
	}
	// 黒のマスを含む行列を出力
	for(i = 0; i < row; i++){
		if(ptr_row[i] == 1){
			for(j = 0; j < column; j++){
				if(ptr_column[j] == 1){
					printf("%c", ptr[i][j]);
				}
			}
			printf("\n");
		}
	}
	
	// 残る行を記録するためのメモリ領域を開放
	free(ptr_row);
	// 残る列を記録するためのメモリ領域を開放
	free(ptr_column);
	
	//メモリ領域の解放，各行の要素分の領域を開放し，
	//各行の配列へのポインタの領域を解放
	//（メモリ領域の確保と逆順）
	for(i = 0; i < row; i++){
		free(ptr[i]);
	}
	free(ptr);
	
	return 0;
}

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

const ll INF = 1LL << 60;
ll n, s;

ll f(ll b, ll n) {
  ll res = 0;
  while (n) {
    res += n % b;
    n /= b;
  }
  return res;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> n >> s;
  if (s > n) {
    cout << -1 << endl;
    return 0;
  }
  if (s == n) {
    cout << n + 1 << endl;
    return 0;
  }
  for (ll i = 2; i * i <= n; i++) {
    if (f(i, n) == s) {
      cout << i << endl;
      return 0;
    }
  }  
  ll ans = INF;
  for (ll i = 1; i * i < n && s - i >= 0; i++) {
    if (n - s + i < 0) continue;
    ll b = (n - s + i) / i;
    if (i < b && s - i < b && b > n / b && n == i * b + s - i) {
      ans = min(ans, b);
    }
  }
  cout << (ans == INF ? -1 : ans) << endl;

  return 0;
}

Measured memory_bytes: 256
def ceil(a, b):
    return (a + b - 1) // b


N = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
n = sum(b) - sum(a)
cnt = 0
for _a, _b in zip(a, b):
    if _a < _b:
        cnt += ceil(_b - _a, 2)
if cnt <= n:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 4596
#include <cstdio>
#include <algorithm>
using namespace std;

const int MAXN = 100000;

bool cmp(int x, int y) {return x > y;}

int a[MAXN + 5], N;
int main() {
	scanf("%d", &N);
	for(int i=1;i<=N;i++)
		scanf("%d", &a[i]);
	sort(a + 1, a + N + 1, cmp);
	for(int i=1;i<=N;i++) {
		if( a[i + 1] < i + 1 ) {
			int p = (a[i] - i) % 2, q;
			for(int j=i;j<=N+1;j++)
				if( a[j] < i ) {
					q = (j - i - 1) % 2;
					break;
				}
			puts(p & 1 || q & 1 ? "First" : "Second");
			break;
		}
	}
}

Measured memory_bytes: 512
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <numeric>
#include <stdio.h>
#include <stack>
#include <queue>
#include <cstdio>
#include <cmath>
#include <iterator>
#include <map>
#include <fstream>
#include <list>
#include <iomanip>
#include <cctype>
#include <math.h>

using namespace std;

int main() {
    cin.tie(0); ios::sync_with_stdio(false);
    int n;
    cin >> n;
    
    vector<int> h(n);
    
    for (int i=0; i<n; i++){
        cin >> h[i];
    }
    
    for (int j = n-1; j>0; j--){
        if (h[j-1] > h[j]){
            h[j-1] -= 1;
            if (h[j-1] > h[j]){
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
}



Measured memory_bytes: 640
Xs,Ys,Xt,Yt = map(int,input().split())
n = int(input())
p = [(Xs,Ys,0),(Xt,Yt,0)]
for i in range(2,n+2):
    p.append(tuple(map(int,input().split())))
cost = [[0]*(n+2)for i in range(n+2)]

for i in range(n+2):
    for j in range(i,n+2):
        cost[i][j] = cost[j][i] =  max(((p[i][0]-p[j][0])**2+(p[i][1]-p[j][1])**2)**0.5 - p[i][2] - p[j][2],0)
cost = tuple(cost)
n += 2
s = 0
#始点sから各頂点への最短距離
#n:頂点数,　w:辺の数, cost[u][v] : 辺uvのコスト(存在しないときはinf)
d = [float("inf")] * n
used = [False] * n
d[s] = 0
    
while True:
    v = -1
    #まだ使われてない頂点の中から最小の距離のものを探す
    for i in range(n):
        if (not used[i]) and (v == -1):
           v = i
        elif (not used[i]) and d[i] < d[v]:
            v = i
    if v == -1:
           break
    used[v] = True
           
    for j in range(n):
           d[j] = min(d[j],d[v]+cost[v][j])
print(d[1])


Measured memory_bytes: 24824
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

ll mod(ll a){
  return a % 1000000007;
}

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


int main(){
  ll r,g,b,n; cin >> r >> g >> b >> n; ll count = 0;
  
  for(ll i=0; i <= n; i++){
    for(ll j=0; j <= n; j++){
      if((n-r*i-g*j) % b == 0 && n-r*i-g*j >= 0) count++;
    }
  }
  
  cout << count << endl;
}

Measured memory_bytes: 256
n,*pl=map(int,open(0).read().split())
l=[[pl[i],pl[i+1]] for i in range(0,n*2,2)]
l.sort(key=lambda x:x[1])
t=0#time
p=True
for i,j in l:
    t+=i
    if t>j:
        p=False
        print('No')
        break
if p:
    print('Yes')

Measured memory_bytes: 49116
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#include <climits>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RFOR(i,a,b) for (int i=(a)-1;i>=(b);i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 1e9;
const int MOD = 1e9 + 7;

using namespace std;

#include <vector>
#include <cmath>
#include <cstring>

const double EPS = 1e-10;
#define equals(a,b) (fabs((a) - (b)) < EPS)
struct Point{
	double x,y;
	Point(double x = 0.0,double y =0.0):x(x),y(y){}
	Point operator + (const Point& p){ return Point(x+p.x,y+p.y);	}
	Point operator - (const Point& p){ return Point(x-p.x,y-p.y); }
	Point operator * (double k){ return Point(x*k,y*k);	}
	Point operator / (double k){ return Point(x/k,y/k); }

	double norm(){return x*x+y*y;}
	double abs(){return sqrt(norm());}

	bool operator < (const Point& p) const {
		return x != p.x ? x < p.x : y < p.y;
	}
	bool operator == (const Point &p) const{
		return fabs(x-p.x) < EPS && fabs(y-p.y) < EPS;
	}
};
typedef Point Vector;

double dot(Vector a, Vector b){
	return a.x * b.x + a.y * b.y;
}

double cross(Vector a, Vector b){
	return a.x*b.y - a.y*b.x;
}


struct Segment{
	Point p1,p2;
	Segment(Point p1,Point p2):p1(p1),p2(p2){}
};

typedef Segment Line;
class Circle{
public:
	Point c;
	double r;
	Circle(Point c = Point(), double r = 0.0): c(c),r(r){}
};
typedef vector<Point> Polygon;

bool isOrthgonal(Vector a, Vector b){
	return equals(dot(a,b),0.0);
}

bool isOrthgonal(Point a1, Point a2, Point b1, Point b2){
	return isOrthgonal(a1-a2,b1-b2);
}

bool isOrthgonal(Segment s1, Segment s2){
	return equals(dot(s1.p2 - s1.p1, s2.p2 - s2.p1),0.0);
}

bool isParallel(Vector a,Vector b){
	return equals(cross(a,b),0.0);
}

bool isParallel(Point a1, Point a2, Point b1, Point b2){
	return isParallel(a1-a2,b1-b2);
}

bool isParallel(Segment s1, Segment s2){
	return equals(cross(s1.p2 - s1.p1,s2.p2-s2.p1),0.0);
}

Point project(Segment s,Point p){
	Vector base = s.p2 - s.p1;
	double r = dot(p-s.p1,base)/base.norm();
	return s.p1 + base * r;
}

Point reflect(Segment s, Point p){
	return p + (project(s,p) - p) * 2.0;
}


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	Segment s(Point(a,b),Point(c,d));
	int q;cin>>q;
	while(q--){
		int x,y;cin>>x>>y;
		Point ans = reflect(s,Point(x,y));
		cout << fixed << setprecision(8) << ans.x << ' ' << ans.y << endl;
	}
  return 0;
}

Measured memory_bytes: 3236
def main():
    examE()

def examA():
    S = SI()
    if S[-1]=="s":
        ans = S+"es"
    else:
        ans = S+"s"
    print(ans)
    return

def examB():
    N = I()
    D = [LI()for _ in range(N)]
    current = 0
    for d1,d2 in D:
        if d1==d2:
            current += 1
        else:
            current = 0
        if current==3:
            print("Yes")
            return
    print("No")
    return

def examC():
    N = I()
    cnt = 0
    for i in range(1,N):
        for j in range(1,1+N//i-(N%i==0)):
            cnt += 1
    ans = cnt
    print(ans)
    return

def examD():
    N, K = LI()
    LR = [LI()for _ in range(K)]
    dp = [0]*N
    S = [0]*N
    dp[0] = 1
    S[0] = 1
    for i in range(1,N):
        cur = 0
        for l,r in LR:
            if i<l:
                continue
            cur += S[i-l]
            if i<r+1:
                continue
            cur -= S[i-r-1]
            cur += mod2
            cur %= mod2

        dp[i] = cur
        S[i] = S[i-1] + cur
        S[i] %= mod2

    ans = dp[-1]
    print(ans)
    return

def examE():
    N, X, M = LI()
    cnt = 0
    L = []
    used = [-1]*(M+1)

    for i in range(N):
        used[X] = i
        L.append(X)
        cnt += X
        X = pow(X,2,M)
        if X==1 or X==0:
            cnt += (N-i-1)*X
            break
        if used[X]>=0:
            loop = i - used[X] + 1
            S = sum(L[used[X]:i+1])
            rest = N-i-1
            cnt += (rest//loop) * S + sum(L[used[X]:used[X]+rest%loop])
            break
    #print(L)
    #print(used)
    ans = cnt
    print(ans)
    return
def examF():
    ans = 0
    print(ans)
    return

from decimal import getcontext,Decimal as dec
import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def DI(): return dec(input())
def LDI(): return list(map(dec,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,alphabet_convert,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 1<<31
_ep = dec("0.000000000001")
alphabet = [chr(ord('a') + i) for i in range(26)]
alphabet_convert = {chr(ord('a') + i): i for i in range(26)}

getcontext().prec = 28

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    main()

"""
10 4 6 
"""

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

int main(){
    vector<int> x(5);
    int p;
    rep(i,0,5) {
        cin>>x[i];
        if(x[i]==0){
            p=i;
            break;
        }
    }
    cout<<p+1<<endl;
}

Measured memory_bytes: 3584
void main()
{
    long n, m, k;
    rdVals(n, m, k);

    foreach (i; 0 .. n+1)
    {
        foreach (j; 0 .. m+1)
        {
            long black = i * m + j * n -2 * i * j;
            if (black == k)
            {
                "Yes".writeln;
                return;
            }
        }
    }

    "No".writeln;
}

enum long mod = 10^^9 + 7;
enum long inf = 1L << 60;

T rdElem(T = long)()
if (!is(T == struct))
{
    return readln.chomp.to!T;
}

alias rdStr = rdElem!string;
alias rdDchar = rdElem!(dchar[]);

T rdElem(T)()
if (is(T == struct))
{
    T result;
    string[] input = rdRow!string;
    assert(T.tupleof.length == input.length);
    foreach (i, ref x; result.tupleof)
    {
        x = input[i].to!(typeof(x));
    }
    return result;
}

T[] rdRow(T = long)()
{
    return readln.split.to!(T[]);
}

T[] rdCol(T = long)(long col)
{
    return iota(col).map!(x => rdElem!T).array;
}

T[][] rdMat(T = long)(long col)
{
    return iota(col).map!(x => rdRow!T).array;
}

void rdVals(T...)(ref T data)
{
    string[] input = rdRow!string;
    assert(data.length == input.length);
    foreach (i, ref x; data)
    {
        x = input[i].to!(typeof(x));
    }
}

void wrMat(T = long)(T[][] mat)
{
    foreach (row; mat)
    {
        foreach (j, compo; row)
        {
            compo.write;
            if (j == row.length - 1) writeln;
            else " ".write;
        }
    }
}

import std.stdio;
import std.string;
import std.array;
import std.conv;
import std.algorithm;
import std.range;
import std.math;
import std.numeric;
import std.traits;
import std.container;
import std.functional;
import std.typecons;
import std.ascii;
import std.uni;

Measured memory_bytes: 256
#include <bits/stdc++.h>
/// TONI BO$$ was here
/// #MLC

using namespace std;

int main()
{
    int i,n,rez,cif,x;
    scanf("%d",&n);
    rez=0;
    for(i=1; i<=n; i++)
    {
        x=i;
        cif=0;
        while(x)
        {
            cif++;
            x/=10;
        }
        if(cif%2) rez++;
    }
    printf("%d",rez);

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include <string>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
map<int, int> mp;
map<int, int>mm;
#define ll long long

int main(void) {
    int n;
    cin >> n;
    vector<int> a(3 * n);
    rep(i, n*3) {
        cin >> a[i];
    }
    sort(a.begin(),a.end());
    ll ans = 0;
    for (int i = 0; i < n; i ++) {
        ans += a[3*n-2-2*i];
    }
    cout << ans << endl;
    return 0;
    
}

Measured memory_bytes: 1408
s = input()
t = input()
ans = len(t)
cnt = 0
for i in range(len(s)-len(t)+1):
    for j in range(len(t)):
        #print(s[i+j])
        #print(t[j])
        if s[i+j] == t[j]:
            cnt += 1
    #print(cnt)
    ans = min(ans,len(t)-cnt)
    cnt = 0

print(ans)

Measured memory_bytes: 67432
#include <iostream>
#include<vector>
#include<algorithm>
#include <queue>
#include <string>
#include <set>
#include <bitset>

using namespace std;
#define ff(i,n,m) for(int i=n;i<m;i++)
#define i64 int64_t
#define tos(x) to_string(x)


int main() {
	int h, w,k;
	cin >> h >> w>> k;
	vector<string> data(h);
	vector<string> ans(h);
	ff(i, 0, h) {
		cin >> data.at(i);
	}
	int y=-1;
	ff(i, 0, h) {//最初のイチゴ探し
		ff(j, 0, w) {
			if (data.at(i).at(j) == '#') {
				y = i;
				break;
			}
		}
		if (y != -1) {
			break;
		}
	}
	ff(i, 0, h) {
		ans.at(i) = "";
	}
	int c_group = 0;
	ff(i, y, h) {//あった列から色塗り
		c_group++;
		int stb = 0;
		ff(j, 0, w) {//いちごあるかどうか
			if (data.at(i).at(j) == '#') {
				stb++;
			}
		}
		if (stb == 0) {//無かったら前列と同じ
			ans.at(i) = ans.at(i - 1);
			c_group--;
			continue;
		}
		stb = 0;
		ff(j, 0, w) {//あるなら塗ってく
			if (data.at(i).at(j) == '#') {
				if (stb > 0) {
					c_group++;
				}
				stb++;
			}
			ans.at(i) += to_string(c_group);
			if (j < w - 1) {
				ans.at(i) += " ";
			}
		}
	}
	if (y > 0) {
		ff(i, 0, y) {
			ans.at(i) = ans.at(y);
		}
	}
	ff(i, 0, h) {
		cout << ans.at(i) << endl;
	}
	return 0;
}

Measured memory_bytes: 1664
#include <bits/stdc++.h>
//#include <atcoder/all>
#define ll long long int
#define MOD 1000000007
#define P pair<ll,ll>
#define INF 1000000000000000000

//using namespace atcoder;
using namespace std;
string s;

string hoge(string s, int i, int j){
  string t = "";
  for (int k = 0; k < j; k++){
    t += s[i+k];
  }
  return t;
}

bool ok(int j){
  if (j == 0)
    return true;

  if (j >= 5 && hoge(s, j-5, 5) == "dream"){
    return ok(j-5);
  }
  if (j >= 7 && hoge(s, j-7, 7) == "dreamer"){
    return ok(j-7);
  }
  if (j >= 5 && hoge(s, j-5, 5) == "erase"){
    return ok(j-5);
  }
  if (j >= 6 && hoge(s, j-6, 6) == "eraser"){
    return ok(j-6);
  }

  return false;
}

int main(void){
  cin >> s;
  
  
  if (ok(s.size()))
    cout << "YES" << endl;
  else
    cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 6400
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v).begin(), (v).end()
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define DEBUG
#define int long long
#define INF 1e9
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
template<class T>void show(vector<T>v){for (int i = 0; i < v.size(); i++){cerr<<v[i]<<" ";}cerr<<"\n";}
typedef long long ll;

signed main(){
    int n;
    string s;
    cin>>n>>s;
    int ans=0;
    for (int i = 0; i < n-1; i++)
    {
        if(s[i]!=s[i+1]) ans++;
    }
    cout<<ans+1<<endl;
   
   
    return 0;
}

Measured memory_bytes: 512
#include<cstdio>

using namespace std;

int a, b, cnt;

int main(){
	scanf("%d%d", &a, &b);
	for(int i = 1; i <= a; i++){
		if(i == a){
			for(int j = 1; j <= b; j++)
				if(i == j)
					cnt++;
		}
		else
			for(int j = 1; j <= i; j++)
				if(i == j)
					cnt++;
	}
	printf("%d\n", cnt);
	return 0;
}


Measured memory_bytes: 128
import java.util.*;

//update 2020/1/1 23:01

public class Main{

  static Scanner sc = new Scanner(System.in);
  static StringBuilder sb = new StringBuilder();

  public static void main(String[] args) {

    int n = nextInt();
    int m = nextInt();

    int[] ans = new int[n];
    for(int i=0;i<n;i++){
      ans[i] = -1;
    }

    boolean ok = true;

    int[] s = new int[m];
    int[] c = new int[m];
    for(int i=0;i<m;i++){
      s[i] = nextInt();
      c[i] = nextInt();
      if(ans[s[i]-1]!=-1 && ans[s[i]-1]!=c[i]){
        ok = false;
      }
      else{
        ans[s[i]-1] = c[i];
      }
    }

    if(n!=1 && ans[0]==0){
      ok = false;
    }

    for(int i=0;i<n;i++){
      if(ans[i]==-1){
        ans[i] = 0;
      }
      if(ans[0]==0 && n>1){
        ans[0] = 1;
      }
    }


    if(ok){
      for(int i=0;i<n;i++){
        System.out.print(ans[i]);
      }
    }
    else{
      System.out.print("-1");
    }



  }
  /*
    static String toSmall(String s){
      char c = s.charAt(0);
      //if(Character.isUpperCase(c)){
      if(c<=90){
        c += 32;
      }
      return String.valueOf(c);
    }
    static String toBig(String s){
      char c = s.charAt(0);
      //if(Character.isLowerCase(c)){
      if(c>=97){
        c -= 32;
      }
      return String.valueOf(c);
    }
  */

  static String toSmall(String s){
    return s.toLowerCase();
  }

  static String toBig(String s){
    return s.toUpperCase();
  }

  static String next(){
    return sc.next();
  }

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

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

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

  static String[] splitString(String s){
    return s.split("");
  }

  static char[] splitChar(String s){
    return s.toCharArray();
  }

  static int charToInt(char a){
    return a - 48;
  }

////////////////////////////////////////////
  public static int max(int[] a){
    int lng = a.length;
    int max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
  public static long max(long[] a){
    int lng = a.length;
    long max = a[0];
    for(int i=1;i<lng;i++){
      max = Math.max(max,a[i]);
    }
    return max;
  }
////////////////////////////////////////////

////////////////////////////////////////////
  public static int min(int[] a){
    int lng = a.length;
    int min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
  public static long min(long[] a){
    int lng = a.length;
    long min = a[0];
    for(int i=1;i<lng;i++){
      min = Math.min(min,a[i]);
    }
    return min;
  }
////////////////////////////////////////////

}


Measured memory_bytes: 22736