akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include<math.h>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include <algorithm>
#include<string.h>
#define ll long long
#define ull unsigned long long
using namespace std;
/* 
struct edge{
	int to, nxt;
}e[100005];
int head[100005], tot = 1, x, num[100005];
void add(int v, int u)
{
	e[tot].to = u, e[tot].nxt = head[v], head[v] = tot++;
}*/ 
int ans;
int n, k, r, s, p, gt[] = {2, 0, 1}, sc[3];
int a[100005][3];
char tr[100005]; 
signed main() 
{
	while (~scanf("%d%d%d%d%d", &n, &k, &sc[0], &sc[1], &sc[2]))
	{
		scanf("%s", tr);
		for (int i = 0; i < n; i++)
			if (tr[i] == 'r')	tr[i] = 0;
			else if (tr[i] == 's') tr[i] = 1;
			else tr[i] = 2;
		ans = 0;
		for (int i = 0; i < n; i++)
		{
				for (int j = 0; j < 3; j++)
				{
					int tp = 0;
					if (i >= k)
					for (int l = 0; l < 3; l++)
					{
						if (j != l)
						{
							tp = max(a[i - k][l], tp);
						}
					}
					if (j == tr[i])
						a[i][j] = 0;
					else if (j == gt[tr[i]])
						a[i][j] = sc[j];
					else
						a[i][j] = 0;
					a[i][j] += tp;
				}
			}
		for (int i = n - 1; i > n - 1 - k; i--)
		{
			int tp = 0;
			for (int j = 0; j < 3; j++)
				tp = max(a[i][j], tp);
			ans += tp;
		}
		printf("%d\n", ans);
	}
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
#define itn int
#define gI gi
#define int long long

using namespace std;

typedef long long ll;

inline int gi()
{
	int f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

inline ll gl()
{
	ll f = 1, x = 0; char c = getchar();
	while (c < '0' || c > '9') {if (c == '-') f = -1; c = getchar();}
	while (c >= '0' && c <= '9') x = x * 10 + c - '0', c = getchar();
	return f * x;
}

int sum, cnt;

signed main()
{
	//freopen(".in", "r", stdin);
	//freopen(".out", "w", stdout);
	int n = gi(), m = n;
	while (m)
	{
		m /= 2;
		++cnt;
	}
	sum = pow(2, cnt - 1) * 2 - 1;
	cout << sum << endl;
	return 0;
}



Measured memory_bytes: 256
using System;

namespace _0009
{
    class Program
    {
        static void Main(string[] args)
        {
            bool[] prime = new bool[1000010];
            for (int i = 2; i < 1000010; i++)
            {
                prime[i] = true;
            }
            for (int i = 2; i <= Math.Sqrt(1000010); i++)
            {
                if (prime[i])
                {
                    for (int j = i * 2; j < 1000010; j += i)
                    {
                        prime[j] = false;
                    }
                }
            }
            while (true)
            {
                string s = Console.ReadLine();
                if (string.IsNullOrEmpty(s))
                {
                    break;
                }
                int n = int.Parse(s);
                int ret = 0;
                for (int i = 2; i <= n; i++)
                {
                    if (prime[i])
                    {
                        ret++;
                    }
                }
                Console.WriteLine(ret);
            }
        }
    }
}

Measured memory_bytes: 10056
n, m, x = gets.split.map(&:to_i)
books = n.times.map {gets.split.map(&:to_i)}

min = 1200001

(1..n).each do |i|
  books.combination(i) do |selected|
    cost = 0
    f = selected.map {|price, *up|
      cost += price
      up
    }.transpose.map(&:sum).all? {_1 >= x}
    if f
      min = cost if cost < min
    end
  end
end

puts (min == 1200001) ? -1 : min

Measured memory_bytes: 14684
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <stdio.h>

using namespace std;

int main(){
  string S;
  cin >> S;
  int ans=1000;
  for(int i=0; i<S.size()-2; i++){
    string tmp;
   	int nums=(S[i]-'0')*100+(S[i+1]-'0')*10+(S[i+2]-'0');
    ans=min(ans,abs(nums-753));
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<algorithm>
#include <vector>
#include<string>
#include<cmath>
#include<cstdio>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define max(x,y) (((x)>(y)) ? x:y)
#define min(x,y) (((x)<(y)) ? x:y)
#define FOR(a) for(int i=0;i<a;i++)
#define ender {return 0;}
#define tosasuretu(a) (a*(a+1)/2)
inline ll kaizyo(ll);
ll gcd(ll, ll);
ll combination(ll, ll);
int main() {
	int n;
	cin >> n;
	int in, Max = 0, total = 0;
	FOR(n) {
		cin >> in;
		total += in;
		Max = max(Max, in);
	}
	total -= (Max / 2);
	cout << total;
	return 0;
}


inline ll kaizyo(ll x) {
	long ans = 1;
	for (int z = 0; z < x; z++) {
		ans *= (x - z);
	}
	return ans;
}
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	return gcd(b, a%b);
}

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

int main(){
  int n;
  cin >> n;
  vector<long long> a(n);
  for(int i = 0; i < n; i++){
    cin >> a.at(i);
    a.at(i) -= i - 1;
  }
  
  sort(a.begin(), a.end());
  int l = a.size();
  long long b;
  if(l == 1) b = a.at(0);
  else if(l%2) b = a.at(l/2);
  else b = a.at(l/2-1) + (a.at(l/2) - a.at(l/2-1))/2;
  
  long long ans = 0;
  for(int i = 0; i < l; i++){
    ans += abs(a.at(i) - b);
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define mod 1000000007
#define MAX 100000
void inarray(int a[], int n){
    for(int i = 0; i < n; i++) cin >> a[i];
}

int main(){
    int a[3][3];
    bool f[3][3];
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            cin >> a[i][j];
            f[i][j] = false;
        }
    }
    int n; cin >> n;
    for(int i = 0; i < n; i++){
        int A; cin >> A;
        for(int i = 0; i < 3; i++){
            for(int j = 0; j < 3; j++){
                if(A == a[i][j]) f[i][j] = true;
            }
        }
    }
    bool fl = false;
    if((f[0][0] && f[0][1] && f[0][2]) || (f[1][0] && f[1][1] && f[1][2]) || (f[2][0] && f[2][1] && f[2][2])) fl = true;
    if((f[0][0] && f[1][0] && f[2][0]) || (f[0][1] && f[1][1] && f[2][1]) || (f[0][2] && f[1][2] && f[2][2])) fl = true;
    if((f[0][2] && f[1][1] && f[2][0]) || (f[0][0] && f[1][1] && f[2][2])) fl = true;
    if(fl) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
//
//  main.c
//  Xtest
//
//  Created by 山口修史 on 2018/02/21.
//  Copyright © 2018年 山口修史. All rights reserved.
//

#include <stdio.h>

int main(void) {
    int a[3], b[3];
    int i, j;
    int c[3][3];
    int x;
    
    for(i=0;i<3;i++){
        for(j=0;j<3;j++){
            scanf("%d", &c[i][j]);
        }
    }
    
    
    for(i=0; i<3; i++){
        a[i]=0;
        b[i]=0;
        
    }
    
    //a[0]=0
    for(j=0;j<3;j++){
        b[j]=c[0][j];
    }
    for(i=1;i<3;i++){
        a[i]=c[i][1]-b[1];
    }
    
    x = 1;
    for(i=0;i<3;i++){
        for(j=0;j<3;j++){
            if(a[i]+b[j] != c[i][j])
                x=0;
        }
    }
    
    if(x == 0){
        printf("No");
    }else{
      printf("Yes");
    }
    
    return 0;
}


Measured memory_bytes: 128
/*
Loading:{
        https://codeforces.com/problemset/problem/1234/F
}
*/
#include <bits/stdc++.h>

using namespace std;

#define ll int // optimize with int
#define endl '\n'
const int N = 1e6 + 5;
ll a[305];
ll dp[305][305][305]; // id, used to donate, used to receive;
ll mod = 998244353; // fucking mod 1e9 + 7
ll n, k, cnt = 0;
ll add(ll x, ll y){ // optimize with add func
        ll res = x + y;
        if (res >= mod) res -= mod;
        return res;
}
int main(){
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        if (fopen("GUARDS.INP", "r")){
                freopen("GUARDS.INP", "r", stdin);
                freopen("GUARDS.OUT", "w", stdout);
        }
        string s;
        cin >> s;
        n = s.length();
        cin >> k;
        ll cur = 0;
        ll cnt1 = 0;
        for (int i = s.length() - 1; i >= 0; i--){
                if (s[i] == '1') {
                        cur++;
                        cnt1++;
                }
                else {
                        cnt++;
                        a[cnt] = cur;
                        cur = 0;
                }
        }
        cnt++;
        a[cnt] = cur;
        //memset(dp, -1, sizeof(dp));
        k = min(k, cnt1);
        for (int i = a[1]; i >= max(0, a[1] - k); i--){
                dp[1][a[1] - i][0] = 1;
        }
        ll sum = a[1];
        for (int i = 1; i < cnt; i++){
                for (int j = 0; j <= sum; j++){
                        for (int t = 0; t <= j; t++){
                                dp[i + 1][j][t] = add(dp[i + 1][j][t], dp[i][j][t]);
                                for (int x = a[i + 1] - 1; x >= max(0, (a[i + 1] - (k - j))); x--){
                                        dp[i + 1][j + a[i + 1] - x][t] = add(dp[i + 1][j + a[i + 1] - x][t], dp[i][j][t]);
                                }
                                for (int x = a[i + 1] + 1; x <= a[i + 1] + (j - t); x++){
                                        dp[i + 1][j][t + x - a[i + 1]] = add(dp[i + 1][j][t + x - a[i + 1]], dp[i][j][t]);
                                }
                        }
                }
                sum += a[i + 1];
        }
        ll ans = 0;
        for (int i = 0; i <= k; i++) {
                ans = add(ans, dp[cnt][i][i]);
                //cout << dp[cnt][i][i] << " ";
        }
        cout << ans;
}


Measured memory_bytes: 30516
#include<iostream>
#include<string>
#include<sstream>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<cmath>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<numeric>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

int main()
{

    int a,b,x;
    cin >> a >> b >> x;
    if(x>=a && x<=a+b) cout << "YES" << endl;
    else cout << "NO" << endl;


    return 0;
}

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

#define ll                  long long int
#define llu                 long long unsigned
#define ld                  long double
#define fast                ios_base::sync_with_stdio(0);cin.tie(0);
#define endl                "\n"
#define pb                  push_back
#define bp                  pop_back
#define pf                  push_front
#define fp                  pop_front
#define mp                  make_pair
#define ms(a,b)             memset((a),(b),sizeof(a))
#define min3(a,b,c)         min(a,min(b,c))
#define max3(a,b,c)         max(a,max(b,c))
#define min4(a,b,c,d)       min(min(a,b),min(c,d))
#define max4(a,b,c,d)       max(max(a,b),max(c,d))
#define max5(a,b,c,d,e)     max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e)     min(min3(a,b,c),min(d,e))
#define NUM                 1000000
#define PI		            2*acos(0.0)
#define maximum             (-1*INF)
#define READ(f) 	        freopen("f", "r", stdin)
#define WRITE(f) 	        freopen("f", "w", stdout)
const int INF = 1e5 + 10 ;

int main()
{
  ll n;
  cin>>n;
  cout<<fixed<<setprecision(2);
  cout<<2*PI*n;
  return 0;
}


Measured memory_bytes: 3780
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n,k;
	int h[200200];
	long long ans=0;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>h[i];
	}
	sort(h,h+n);
	for(int j=n-1;j>=0;j--){
		if(k>0){
			k--;
			continue;
		}
		else{
			ans+=h[j];
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <queue>
#include <stack>
#include <tuple>
#include <cmath>
#include <iomanip>
#include <map>
#include <cstring> //memset(dp,0,sizeof(dp))
#include <functional>
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)
#define repp(i,n) for(int i=n-1;i>=0;i--)
#define fi first
#define se second
#define pb push_back
#define ppb pop_back()
#define ALL(a) (a).begin(),(a).end()
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;

signed main(){
    int n,m; cin >> n >> m;
    vector<int> to[n];
    rep(i,m){
        int a,b; cin >> a >> b;
        a--; b--;
        to[a].pb(b);
    }
    bool ok=0;
    vector<int> sta;
    rep(i,n){
        bool bl=0;
        vector<bool> vis(n,0);
        vis[i]=1;
        queue<int> q; q.push(i);
        while(!q.empty()){
            if(bl) break;
            int v=q.front(); q.pop();
            for(int u:to[v]){
                if(u==i){
                    //exist loop
                    sta.pb(i);
                    ok=1; bl=1;
                    break;
                }
                if(vis[u]) continue;
                q.push(u); vis[u]=1;
            }
        }
    }
    if(!ok){
        cout << -1 << endl;
        return 0;
    }
    vector<P> vp;
    vector<int> v[n];
    for(int st:sta){
        //st->stの最短経路を持って復元
        int d[n];
        rep(i,n) d[i]=1001001;
        priority_queue<P,vector<P>,greater<P>> que;
        d[st]=0;
        int okk=0;
        que.push(P(0,st));
        int prev[n];
        while (!que.empty()){
            if(okk==1){
                d[st]=100100;
            }
            okk++;
            P p = que.top();
            que.pop();
            int v = p.second;
            if (d[v]<p.first) continue;
            for (int i=0; i<to[v].size(); ++i) {
                int e = to[v][i];
                if (d[e] > d[v] + 1) {
                    d[e] = d[v] + 1;
                    prev[e]=v;
                    que.push(P(d[e],e));
                }
            }
        }
        vp.pb({d[st],st});
        int stt=st;
        int cnt=d[st];
        rep(i,cnt){
            v[stt].pb(prev[st]);
            st=prev[st];
        }
        reverse(ALL(v[stt]));
    }
    sort(ALL(vp));
    P p=vp[0];
    cout << p.fi << endl;
    for(int u:v[p.se]){
        cout << ++u << endl;
    }
    return 0;
}



Measured memory_bytes: 4352
<?php
  
  list($s) = explode(" ", trim(fgets(STDIN)));
  list($t) = explode(" ", trim(fgets(STDIN)));

  $ans = 0;

  for($i=0; $i<3; $i++){
    if($s[$i] === $t[$i]){
      $ans++;
    }
  }
  echo $ans;

Measured memory_bytes: 4604
#include<stdio.h>

int main()
{
int me,to,p,a;
scanf("%d",&me);
if(me<=15){
to=me*800;
printf("%d",to);
}
else{
to=me*800;
a=me/15;
a=a*200;
p=to-a;
printf("%d\n",p);
}

return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>
#include<map>
#include<cstdlib>
#include<stack>
#include<queue>
#include<algorithm>
#include<set>
#include<vector>
#include<cmath>
#include<string>
#include<deque>
#define lmid l,mid,rt<<1
#define rmid mid+1,r,rt<<1|1
using namespace std;
int s[205];
int main() {
     int n;
     scanf("%d", &n);
     for (int i = 0; i < n; i++)
          scanf("%d", &s[i]);
     int sum = 0;
     while (1) {
          bool flag = false;
          for (int i = 0; i < n; i++) {
               if (s[i] % 2) {
                    flag = true;
                    break;
               }
               s[i] /= 2;
          }
          if (flag)break;
          sum++;
     }
     printf("%d\n", sum);
     return 0;
}


Measured memory_bytes: 256
def ketanowa(p):
    ans=0
    p=str(p)
    for i in p:
        ans+=int(i)
    return ans

def main():
    temp=input()
    a,b,c=list(temp.split(" "))
    if int(a)+int(b)>=int(c):
        print("Yes")
    else:
        print("No")


    

if __name__ == '__main__':
    main()


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

using namespace std;

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

typedef long long ll;

int constexpr MaxE = 20;
int constexpr MaxL = 2*100010;
int E, x;
ll d[MaxE], c[MaxE];
ll dist[MaxL+10];
priority_queue<pair<ll, ll>> pq;

ll const INF = 1e15;

int main() {

  cin >> E >> x;
  rep(i, E) {
    cin >> d[i] >> c[i];
  }

  rep(i, MaxL) {
    dist[i] = INF;
  }
  
  pq.emplace(0, 0);
  dist[0] = 0;
  while(!pq.empty()) {
    auto tar = pq.top(); pq.pop();
    if(tar.second == x) { break; }
    rep(i, E) {
      {
        auto next_x = tar.second + d[i];
        auto next_c = -tar.first + c[i];
        if(next_x < MaxL && dist[next_x] > next_c) {
          dist[next_x] = next_c; pq.emplace(-next_c, next_x);
        }
      }
      {
        auto next_x = tar.second - d[i];
        auto next_c = -tar.first + c[i];
        if(next_x >= 0 && dist[next_x] > next_c) {
          dist[next_x] = next_c; pq.emplace(-next_c, next_x);
        }
      }
    }
  }
  
  std::cout << (dist[x] == INF ? -1 : dist[x]) << std::endl;
  
  return 0;
}


Measured memory_bytes: 6932
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;

const int MOD = 1000000007;

// res[i][c] := i 文字目以降で最初に文字 c が登場する index (存在しないときは n)
vector<vector<int> > calcNext(const string &S) {
	int n = (int)S.size();
	vector<vector<int> > res(n + 1, vector<int>(26, n));
	for (int i = n - 1; i >= 0; --i) {
		for (int j = 0; j < 26; ++j) res[i][j] = res[i + 1][j];
		res[i][S[i] - 'a'] = i;
	}
	return res;
}

void add(long long &a, long long b) {
	a += b;
	if (a >= MOD) a -= MOD;
}

int main() {
	string S; cin >> S;
	int n = (int)S.size();
	string T = S;
	reverse(T.begin(), T.end());
	
	auto ns = calcNext(S);
	auto nt = calcNext(T);
	vector<vector<long long> > dp(n + 1, vector<long long>(n + 1, 0));
	dp[0][0] = 1;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < n; ++j) {
			for (int k = 0; k < 26; ++k) {
				int ni = ns[i][k];
				int nj = nt[j][k];
				if (ni + nj + 2 > n) continue;
				add(dp[ni + 1][nj + 1], dp[i][j]);
			}
		}
	}
	long long res = 0;
	for (int i = 0; i <= n; ++i) {
		for (int j = 0; i + j <= n; ++j) {
			int num = 1;
			for (int k = 0; k < 26; ++k) if (ns[i][k] + 1 + j <= n) ++num;
			

			//cout << i << ", " << j << ": " << dp[i][j] << ";;; " << num << endl;

			res = (res + dp[i][j] * num % MOD) % MOD;
		}
	}
	cout << res - 1 << endl;
}


Measured memory_bytes: 34896
/*
  Motto - try hard to become an expert
*/
#include <bits/stdc++.h>
#include <map>
#include <algorithm>
#include <vector>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <chrono>
#include <thread>
#include <iomanip>
 
//define
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define INF (int)INT_MAX
#define all(v)  v.begin(), v.end()
#define endl "\n"
 
//typedef
typedef long long int ll;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, int > > vpp;
 
const int N = 3*1e5 +5 ;
const long long MOD = 998244353;
const long long inf = 1e18;
 
using namespace std;
 
ll MAXN=100001;
ll spf[100001]; 
 
ll modpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}
 
ll modFact(ll n, ll p) 
{ 
    if (n >= p) 
        return 0; 
  
    ll result = 1; 
    for (ll i = 1; i <= n; i++) 
        result = (result * i) % p; 
  
    return result;  
} 
 
bool isPrime(int x)
{
    if(x%2==0)
        return 0;
    for(int i=3;i<=sqrt(x);i+=2)
    {
        if(x%i==0)
            return 0;
    }
    return 1;
}
 

 
void solve()
{
    string s ;
    cin>>s ;
    cout<<s[0]<<s[1]<<s[2];
}
 
int main() {
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int t = 1;
    //cin>>t;
    while(t--)
    {
        solve();
    } 
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 3820
Option Strict On
Imports System.Collections.Generic
Module problemD

    Sub Main()
        Dim n As Integer = Integer.Parse(Console.ReadLine) - 1
        Dim sc() As Char = Console.ReadLine.ToCharArray()
        Dim s(n) As Integer        
        Dim ih, jh As New Dictionary(Of Integer, HashSet(Of Integer))
        Dim kh As New HashSet(Of Integer)
        Dim wi, wj, wk As Integer
        Dim i, j, k As Integer

        For i = 0 To n
    		s(i) = Convert.ToInt32(sc(i))
        Next

        For i = 0 To n - 2
            wi = s(i)
            If Not ih.ContainsKey(wi) Then ih.Add(wi, New HashSet(Of Integer))
            If ih(wi).Contains(-1) Then Continue For

            For j = i + 1 To n - 1
                wj = s(i) * 10 + s(j)
                If Not jh.ContainsKey(wj) Then jh.Add(wj, New HashSet(Of Integer))
                If jh(wj).Contains(-1) Then Continue For

                For k = j + 1 To n
                    wk = s(i) * 100 + s(j) * 10 + s(k)
                    If kh.Contains(wk) Then Continue For
                    kh.Add(wk)

                    jh(wj).Add(s(k))
                    If jh(wj).Count > 9 Then Exit For
                Next

                jh(wj).Add(-1)
                ih(wi).Add(s(j))
                If ih(wi).Count > 9 Then Exit For
            Next

            ih(wi).Add(-1)
            If ih.Count > 9 Then Exit For
        Next

        Console.Write(kh.Count.ToString)
    End Sub

End Module


Measured memory_bytes: 13664
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
#define pvec(vec) {for (auto v: vec) cout << v << ' '; cout << endl;}
#define pivec(vec) {rep(i, 0, vec.size()) cout << i << ':' << vec[i] << ' '; cout << endl;}

using namespace std;
using ll = long long;

int main()
{
    int N;
    cin >> N;
    int cnt = 0;
    vector<int> cnts(4, 0);
    rep(i, 0, N)
    {
        string s;
        cin >> s;
        if (s == "AC")
            ++cnts[0];
        else if(s == "WA")
            ++cnts[1];
        else if(s == "TLE")
            ++cnts[2];
        else if(s == "RE")
            ++cnts[3];
    }
    cout << "AC x " << cnts[0] << endl;
    cout << "WA x " << cnts[1] << endl;
    cout << "TLE x " << cnts[2] << endl;
    cout << "RE x " << cnts[3] << endl;
    
    return 0;
}


Measured memory_bytes: 3632
<?php
list($a, $b, $c) = explode(" ", trim(fgets(STDIN)));
$c *= pi() / 180;

$s = 0.5 * $a * $b * sin($c);
$l = $a + $b + sqrt(pow($a, 2) + pow($b, 2) - 2 * $a * $b * cos($c));
$h = $b * sin($c);

echo sprintf("%.10f\n%.10f\n%.10f\n", $s, $l, $h);



Measured memory_bytes: 9296
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    static long dp[][];
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        String input[] = br.readLine().split(" ");
        int n = Integer.parseInt(input[0]);
        int W = Integer.parseInt(input[1]);
        dp = new long[n + 1][W + 1];
        int[] we = new int[n];
        int[] val = new int[n];
        for (int i = 0; i < n; i++) {
            input = br.readLine().split(" ");
            we[i] = Integer.parseInt(input[0]);
            val[i] = Integer.parseInt(input[1]);
        }
        System.out.println(function(W, n, we, val));
    }
    static long function(int W, int n, int[] w, int[] v) {
        if (n == 0) {
            return 0;
        }
        if (dp[n][W] != 0) return dp[n][W];
        if (W - w[n- 1] >= 0) {
            dp[n][W] = Math.max(function(W - w[n - 1], n - 1, w, v) + v[n - 1], function(W, n - 1, w, v));
        }
        else dp[n][W] = function(W, n - 1, w, v);
        return dp[n][W];
    }

}


Measured memory_bytes: 133980
using static System.Console;

class Program
{
    enum State
    {
        A,
        B,
        C,
    }

    static void Main(string[] args)
    {
        var strA = ReadLine();
        var strB = ReadLine();
        var strC = ReadLine();
        var state = State.A;
        var result = "";
        while (true)
        {
            switch (state)
            {
                case State.A:
                    if (strA.Length == 0) { result = "A";break; }
                    ChangeState(ref state, strA.Substring(0, 1));
                    strA = strA.Substring(1);
                    break;
                case State.B:
                    if (strB.Length == 0) { result = "B";break; }
                    ChangeState(ref state, strB.Substring(0, 1));
                    strB = strB.Substring(1);
                    break;
                case State.C:
                    if (strC.Length == 0) { result = "C";break; }
                    ChangeState(ref state, strC.Substring(0, 1));
                    strC = strC.Substring(1);
                    break;
            }
            if (result != "") break;
        }

        WriteLine(result);
    }

    private static void ChangeState(ref State state,string chara)
    {
        switch (chara)
        {
            case "a":
                state = State.A;
                break;
            case "b":
                state = State.B;
                break;
            case "c":
                state = State.C;
                break;
        }
    }
}



Measured memory_bytes: 11092
#pragma GCC optimize("Ofast")
#pragma GCC optimization("unroll-loops")
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//using boost::multiprecision::cpp_int;
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0)
#define ll long long int
#define ld long double
#define ull unsigned long long int
#define reptArIn(i,a,b,ar) for( i=a; i<b; ++i) cin>>ar[i];
#define fo(i,a,b) for(i=a; i<b; ++i)
#define foe(i,a,b) for(i=a; i<=b; ++i)
#define rep(i,n) for(i=1;i<=n;i++)
#define all(a) a.begin(), a.end()
#define pb push_back
#define ins insert
#define mk make_pair
#define f first
#define s second
#define mod 1000000007
#define vi vector<int>
#define vll	vector<ll>
#define vvi	vector<vi>
#define pii	pair<int,int> //typedef pair<int,int> pii;
#define pll	pair<ll , ll>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>  new_data_set;
//mp.reserve(4096);
//mp.max_load_factor(0.25);

void dfs(int p,vector<int>adj[],int dp[],bool vis[])
{
    vis[p]=true;
    for(auto v:adj[p])
    {
        if(!vis[v])
            dfs(v,adj,dp,vis);
            
        dp[p]=max(1+dp[v],dp[p]);
    }
}
int main()
{
	int n,m,i,x,y;
	cin>>n>>m;
	vector<int>adj[n+1];
	int dp[n+1];
	bool vis[n+1];
	memset(vis,false,sizeof(vis));
	memset(dp,0,sizeof(dp));
	foe(i,1,m)
	{
		cin>>x>>y;
		adj[x].pb(y);
	}
	foe(i,1,n)
	{
	 if(!vis[i])
	 dfs(i,adj,dp,vis);
	}
	int mx=INT_MIN;
	foe(i,1,n)
	{
	  mx=max(mx,dp[i]);	
	}
	cout<<mx<<endl;
	return 0;
}

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

typedef long long int ll;

int main(){
  int N,M;
  cin >> N >> M;
  int NMAX = 50;
  vector<int> A(NMAX), B(NMAX), C(NMAX), D(NMAX);
  for(int i = 0; i < N; i++){
    cin >> A.at(i) >> B.at(i);
  }
  for(int j = 0; j < M; j++){
    cin >> C.at(j) >> D.at(j);
  }
  int dist, ans;
  for(int i = 0; i < N; i++){
    ll k = 1000000000;
    for(int j = 0; j < M; j++){
      dist = abs(A.at(i)-C.at(j)) + abs(B.at(i)-D.at(j));
      if(k > dist){
        k = dist;
        ans = j + 1;
      }
    }
    cout << ans << endl;
  }
  
}
      
      

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f first
#define s second
#define Fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fo(a,b,c) for(int i=a;i<b;i+=c)  
typedef pair<ll , pair<ll, ll> > pi;
int pow(int x,int y){
    int res=1;
    while(y){
        if(y&1) res*=x;
        y>>=1;
        x*=x;
    }
    return res;
}   
struct Compare {
    constexpr bool operator()(pi const & a,
                              pi const & b) const noexcept
    { return a.first < b.first || (a.first == b.first && a.second.first > b.second.first); }
 
};
void prefix_function( string s,ll arr[] )
{
     long long border=0; arr[0]=0;
    for(long long i=1;i<s.size();i++)
    {
      while(border>0 && s[i]!=s[border])
        border=arr[border-1];
     
     if(s[i]==s[border])
         border++;
      else
       border=0;
      
      arr[i]=border;
    }
}
ll mod=998244353;
ll add( ll a , ll b)
{
    return (((a%mod)+(b%mod))%mod);
}
ll mul(ll a,ll b)
{
  return (((a%mod)*(b%mod))%mod);
}
//send mod-2 for a^-1 if mod is a prime number
ll binpow(ll a, ll b) {
    ll res = 1;
    while (b) {
        if (b & 1) res = mul(res, a);
        a = mul(a, a);
        b >>= 1;
    }
    return res;
}
ll dsu_arr[100000];
ll dsu_sz[100000];
void dsu(ll n)
{
    for(ll i=0;i<=n;i++)
    {
        dsu_arr[i]=i;
        dsu_sz[i]=1;
    }
}
ll find(ll x)
{
     ll root=x;
    while (root!=dsu_arr[root])
    {
        root=dsu_arr[root];
    }
    while(x!=dsu_arr[x])
    {
        dsu_arr[x]=root;
        x=dsu_arr[x];
    }
    return root;
}
ll merge(ll x,ll y)
{
    ll root1=find(x);
    ll root2=find(y);
    
    if(root1==root2)
    return 0ll;
 
    if(dsu_sz[x]>dsu_sz[y]){
    dsu_arr[root2]=root1;
    dsu_sz[x]+=dsu_sz[y];
    }
    else
    {
         dsu_sz[y]+=dsu_sz[x];
        dsu_arr[root1]=root2;
    }
    return 1ll;
}


int main()
{
ll x,y;
cin>>x>>y;
for(ll i=0;i<=x;i++)
{
    if((4*x-2*i)==y)
    {
        cout<<"Yes"<<endl;
        return 0;
    }
}
cout<<"No"<<endl;


}



   
      
    
        



Measured memory_bytes: 3532
/*
貪欲
後ろから見る
DP
順位表をチェック
二分探索
不変なもの・偶奇に注目

*/
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<iostream>
#include<queue>
#include<vector>
#include <bitset>
#include <cmath>
#include <limits>
#include <iostream>
#include <map>
#include<tuple>
#include<set>
using namespace std;
#define INF 1LL<<60
#define MAX 100000
#define MOD 1000000007
typedef long long ll;
typedef pair<int,int> P;
//typedef pair< pair<int,int>,pair<int,int> > p;
//#define int ll int main->signed main
#define bit(n,k) ((n>>k)&1) /*nのk bit目*/
#define rad_to_deg(rad) (((rad)/2/M_PI)*360)
struct edge{ll to,cost,val;};
template<class T,class U>bool chmin(T&a,const U&b){if(a<=b)return false;a=b;return true;}
template<class T,class U>bool chmax(T&a,const U&b){if(a>=b)return false;a=b;return true;}
//__builtin_popcount(S);
//C.erase(unique(C.begin(),C.end()),C.end());

int main(){
    int X;
    cin>>X;
    int sum=0;
    int count=0;
    while(sum<X){
        sum+=105;
        count++;
    }
    if(sum==X){
        cout<<1<<endl;
        return 0;
    }
    if(sum-count*5<=X) cout<<1<<endl;
    else cout<<0<<endl;


}


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

signed main(){
  lint N; cin >> N;
  vector<lint> x(N), y(N), h(N);
  lint px, py, ph;
  for(lint i = 0; i < N; i++){
    cin >> x[i] >> y[i] >> h[i];
    if(h[i] != 0){
      px = x[i]; py = y[i]; ph = h[i];
    } 
  }
  for(lint i = 0; i <= 100; i++){
    for(lint j = 0; j <= 100; j++){
      lint height = ph + abs(px - i) + abs(py - j);
      bool ok = true;
      for(lint k = 0; k < N; k++){
        if(max(height - abs(x[k] - i) - abs(y[k] - j), lint(0)) != h[k]) ok = false;
      }
      if(ok){
        cout << i << " " << j << " " << height << endl;
        return 0;
      }
    }
  }
}


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

// clang-format off
template <typename T> T gcd(T a, T b) { return b == 0 ? a : gcd(b, a % b); }
template <typename T> T lcm(T a, T b) { return a * b / gcd(a, b); }
template <typename T> T clamp(T val, T min, T max) { return val < min ? min : (max < val ? max : val); }
char capitalize(char c) { return static_cast<char>(std::toupper(static_cast<unsigned char>(c))); }
// template <typename T> size_t max_index(T begin, T end) { return distance(begin, max_element(begin, end)); }
// template <typename T> size_t min_index(T begin, T end) { return distance(begin, min_element(begin, end)); }
// clang-format on

#define int long long
#define YES "YES"
#define NO "NO"
#define MOD 1000000000 + 7
#define forit(v) for (auto it = v.begin(); it != v.end(); ++it)

using namespace std;

signed main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);

  int num = 0;
  // num = numeric_limits<int>::max();
  // num = numeric_limits<int>::min();
  bool flag = false;
  // flag = true;

  int n; cin >> n;
  int k; cin >> k;

  num = 1;
  for (int i = 0; i < n; ++i) {
    if (num + k > 2 * num)
      num *= 2;
    else
      num += k;
  }
  
  cout << num << endl;
  // cout << (flag ? YES : NO) << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static int ceil(int a, int b){
		int x = (a + (b - 1))/b;
		return x;
	}

	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		int ans = ceil(b-1, a-1);
		// 出力
		System.out.println(ans);
	}
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> pll;
typedef vector<ld> vd;
typedef vector<ll> vll;
typedef vector<string> vstr;
typedef vector<vector<ll>> vvll;
typedef vector<pair<ll, ll>> vpll;
typedef priority_queue<ll, vector<ll>, greater<ll>> spqll;  // 小さい順に取り出し
typedef priority_queue<ll, vector<ll>, less<ll>> bpqll;     // 大きい順に取り出し

#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define FOR(i, a, b) for (ll i = (ll)a; i < (ll)b; i++)
#define IREP(i, v) for (auto i = (v).begin(); i != (v).end(); i++)
#define FI first
#define SE second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define TS to_string
#define NP next_permutation
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) (ll) x.size()
#define SP(x) setprecision((ll)x)


ll INF = 1e9;
ll NIL = -1;
ll MOD = 1000000007;
ll LINF = 1e18;
ld EPS = 1e-9;
ld PI = M_PI;
vll dx = {1, 0, -1, 0, 1, -1, -1, 1};
vll dy = {0, 1, 0, -1, 1, 1, -1, -1};
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) { return a / gcd(a, b) * b;}     //最小公倍数

void yes(){ cout << "Yes" << endl;}
void no(){ cout << "No" << endl;}

//-----------------------------------------

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

    ll n, k;
    string s;
    cin >> n >> k >> s;

    ll ans = 0;

    ll lef = 0;
    ll rig = 0;

    ll sum = 0;
    ll tmp = k;
    while(lef<n){
        if(rig<n && tmp>0 && s[rig]=='0'){
            tmp--;
            while(rig<n && s[rig]=='0'){
                sum++;
                rig++;
                ans = max(ans,sum);
            }
        }
        else if(rig<n && s[rig]=='1'){
            rig++;
            sum++;
            ans = max(ans,sum);
        }
        else if(s[lef]=='0'){
            tmp++;
            while(lef<n && s[lef]=='0'){
                lef++;
                sum--;
            }
        }
        else if(s[lef]=='1'){
            lef++;
            sum--;
        }
        else{
            yes();
        }

        if(lef==rig){
            lef++;
            rig++;
            sum = 0;
            tmp = k;
        }
    }

    cout << ans <<endl;


    
    return 0;
}



Measured memory_bytes: 3708
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int X = sc.nextInt();
		int con =0;
		for (int i = 0; i <= A; i++) {
			for (int j = 0; j <= B; j++) {
				for (int k = 0; k <= C; k++) {
					if (X-(i*500+j*100+k*50)==0) {
						con++;
					}
				}
			}
		}
		System.out.println(con);
	}
}




Measured memory_bytes: 35880
# include <iostream>
# include <sstream>
# include <cstdio>
# include <cstdlib>
# include <algorithm>
# include <string>
# include <cstring>
# include <cmath>
# include <stack>
# include <queue>
# include <vector>
# include <list>
# include <map>
# include <set>
# include <deque>
# include <iterator>
# include <functional>
# include <bitset>
# include <climits>
# include <ctime>
using namespace std;
#define max(a,b) ((a)>(b)?(a):(b))
#define min(a,b) ((a)<(b)?(a):(b))
#define odd(x) ((x)&1)
#define sqr(x) ((x)*(x))
#define mp make_pair
#define pb push_back
#define fir first
#define sec second
#define all(x) (x).begin(),(x).end()
#define mem(a,x) memset(a,x,sizeof(a))
#define rep(i,a,b) for (int i=(a); i<=(b); ++i)
#define per(i,a,b) for (int i=(a); i>=(b); --i)
#define rep_it(it,x) for (__typeof((x).begin()) it=(x).begin(); it!=(x).end(); it++)
#define ____ puts("\n_______________\n\n")
#define debug(x) ____; cout<< #x << " => " << (x) << endl
#define debug_pair(x) cout<<"\n{ "<<(x).fir<<" , "<<(x).sec<<" }\n"
#define debug_arr(x,n) ____; cout<<#x<<":\n"; rep(i,0,n) cout<<#x<<"["<<(i)<<"] => "<<x[i]<<endl
#define debug_arr2(x,n,m) ____; cout<<#x<<":\n"; rep(i,0,n) rep(j,0,m) cout<<#x<<"["<<(i)<<"]["<<(j)<<"]= "<<x[i][j]<<((j==m)?"\n\n":"    ")
#define debug_set(x) ____; cout<<#x<<": \n"; rep_it(it,x) cout<<(*it)<<" "; cout<<endl
#define debug_map(x) ____; cout<<#x<<": \n"; rep_it(it,x) debug_pair(*it)
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> vi;
const int oo = /*2 * 1000 * 1000 * 1000*/0x3f3f3f3f;
const ll ooo=9223372036854775807ll;
const int _cnt = 1000 * 1000 + 7;
const int _p = 1000 * 1000 * 1000 + 7;
const int N=1000105;
const double PI=acos(-1.0);
const double eps=1e-6;
int o(int x) { return x%_p; }
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
int lcm(int a, int b) { return a / gcd(a, b)*b; }

void file_put() {
    freopen("filename.in", "r", stdin);
    freopen("filename.out", "w", stdout);
}

ll a,b; 
int k=0;

int main() {
    //file_put();
    
    scanf("%lld%lld",&a,&b);
    while (a<=b){
    	k++;
    	a*=2;
    	if (a>b || a<0) break;
	}
	printf("%d\n",k);

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<cstdlib>
#include<ctime>
#include<queue>
using namespace std;
int a,b,c;
char shuchu[30];
int main()
{
	cin>>a>>b>>c;
	if(c>=a&&c<=b)cout<<"Yes";
	else cout<<"No";
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>



main(){
        long n;
        int a;
        long b,c;

        long long int sum[4000]={0,};
        int jun[4000]={0,};

        int i,ii,j;
        int f;

        while(1){
                j=0;//初期化
                for(i=0;i<4000;i++){
                        jun[i]=0;
                        sum[i]=0;
                }

                scanf("%ld",&n);

                if(!n)
                        return 0;

                for(i=0;i<n;i++){ //入力
                        f=0;//初期化

                        scanf("%d %ld %ld",&a,&b,&c);
                        sum[a]+=b*c;

                        for(ii=0;ii<j;ii++){ //順番を格納(検索)
                                if(jun[ii]==a){
                                        f=1;
                                        break;
                                }
                        }
                        if(!f)
                                jun[j++]=a; //順番を格納
                }

                f=0;//初期化

                for(i=0;i<j;i++){
                        if(sum[jun[i]]>=1000000){
                                f=1;
                                printf("%d\n",jun[i]);
                        }
                }

                if(!f)
                        puts("NA");
        }
}

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

int n;

struct Info{
	short cost;
	short currentIndex; // <- index to itteruga jissai soeji nanode kokoha id
	short prevIndex;
	short prevId;
	Info(short cost,short currentIndex,short prevIndex,short prevId) : cost(cost) , currentIndex(currentIndex) , prevIndex(prevIndex) , prevId(prevId) {}
	Info(){cost=-11111;currentIndex=prevIndex=prevId=-1;}
};

bool operator < (const Info &a,const Info &b){
	return a.cost < b.cost;
}

long long A[4444];
vector<Info> dp[4444];
vector<long long> sum[4444];
long long psum[4444];


void Add(vector<Info> &table,int i,Info v ){
	i++;
	for( ; i < table.size() ; i += i&-i ){
		if( table[i] < v ){
			table[i] = v;
		}
	} 
}

Info Get(vector<Info> &table,int i){
	i++;
	Info ans;
	for( ; i > 0 ; i -= i&-i ){
	
		if( ans < table[i] ){
			ans = table[i];
		}
	}
	return ans;
}

int main(){
	cin >> n;
	for(int i = 0 ; i < n ; i++) cin >> A[i];
	
	for(int i = 0 ; i < n ; i++){
		long long s = 0;
		psum[i] = (i ? psum[i-1] : 0) + A[i];
		for(int j = 0 ; j < i ; j++){
			s += A[j];
			sum[i].push_back(psum[i]-s);
		}
		sum[i].push_back(psum[i]);
		dp[i].resize(sum[i].size()+1);
		sort(sum[i].begin(),sum[i].end());
		sum[i].erase(unique(sum[i].begin(),sum[i].end()),sum[i].end());
	}
	
	
	for(int i = 0 ; i < n ; i++){
		long long c = psum[i];
		int id2 = lower_bound(sum[i].begin(),sum[i].end(),c) - sum[i].begin();
		Add(dp[i],id2,Info(1,id2,i,-1));
	}
	
	for(int i = 0 ; i < n ; i++){
		
		for(int j = 0 ; j < i ; j++){
			long long c = psum[i] - psum[j];
			int id = lower_bound(sum[j].begin(),sum[j].end(),c) - sum[j].begin() - 1;
			int id2 = lower_bound(sum[i].begin(),sum[i].end(),c) - sum[i].begin();
			
			if( id < 0 ) continue;
			Info res = Get(dp[j],id);
			//cout << i << " " << j << " " << c << " | " << " " << sum[j][id] << " < " << sum[i][id2] << " [" << res.cost << " " << res.currentIndex << "]" << id2 << endl;
			//cout << i << ":" << j << " " << res.cost << " " << sum[j][id] << " " << sum[i][id2] << endl;
			Add(dp[i],id2,Info(res.cost+1,id2,j,res.currentIndex));
		}
	}
	
	Info ans = Get(dp[n-1],sum[n-1].size()-1);
	//cout << ans.cost << " " << ans.prevIndex << " " << ans.prevId << endl;
	vector<int> output;
	while(ans.prevId != -1){
		//cout << ans.currentIndex << ":" << ans.prevIndex << " " << "(" << sum[ans.prevIndex][ans.prevId] << ")" << endl;
		output.push_back(ans.prevIndex);
	
		ans = Get(dp[ans.prevIndex],ans.prevId);
		//cout << 
	}
	reverse(output.begin(),output.end());
	cout << output.size() + 1 << endl;
	for(int i = 0 ; i < output.size() ; i++){
		if( i ) cout << " ";
		cout << output[i] + 1;
	}
	cout << endl;
	
}

Measured memory_bytes: 138104
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int n;
vector<bitset<26>> seg(10000100);
string s;

void init(int n_)
{
    n = 1;

    while (n < n_)
    {
        n *= 2;
    }
}

void update(int i, char x)
{
    seg[i + n - 1].reset(s[i] - 'a');
    s[i] = x;
    seg[i + n - 1].set(s[i] - 'a');

    i += n - 1;

    while (i > 0)
    {
        i = (i - 1) / 2;
        seg[i] = seg[2 * i + 1] | seg[2 * i + 2];
    }
}

bitset<26> query(int a, int b, int k, int l, int r)
{
    if (r <= a || b <= l)
    {
        bitset<26> bit(0ll);
        return bit;
    }

    if (a <= l && r <= b)
    {
        return seg[k];
    }
    else
    {
        bitset<26> bit1 = query(a, b, 2 * k + 1, l, (l + r) / 2);
        bitset<26> bit2 = query(a, b, 2 * k + 2, (l + r) / 2, r);

        return bit1 | bit2;
    }
}

int main(void)
{
    int q;
    int i, j;
    int n_;
    vector<int> ans;

    cin >> n_ >> s >> q;

    init(n_);

    rep(i, 0, n_)
    {
        update(i, s[i]);
    }

    init(n_);

    rep(i, 0, q)
    {
        int x;

        cin >> x;

        if (x == 1)
        {
            int iq;
            char c;

            cin >> iq >> c;
            iq--;

            update(iq, c);
        }
        else
        {
            int l, r;
            int an = 0;

            cin >> l >> r;
            l--;

            bitset<26> bit = query(l, r, 0, 0, n);

            an = bit.count();

            ans.push_back(an);
        }
    }

    for (auto &z : ans)
    {
        cout << z << endl;
    }
}

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

using namespace std;

using Int = long long;
using P = pair<int, int>;

const long long MOD = 1e9 + 7;
const int INF = 1e9;
const double EPS = 1e-9;

int main() {
  string S;
  cin >> S;
  int ans = 0;
  int N = S.size();
  for (int i = 1; i < N; ++i) if (S[i - 1] != S[i]) ++ans;
  cout << ans << endl;
}

Measured memory_bytes: 512
n = int(raw_input())
a = [int(x) for x in raw_input().split()]
q = int(raw_input())
op = []
for _ in xrange(q):
    v = raw_input().split()
    op.append([int(x) for x in v])

d = {}
total = 0
for v in a:
    d[v] = d.get(v, 0) + 1
    total += v

for src, dest in op:
    c = d.pop(src, 0)
    d[dest] = d.get(dest, 0) + c
    total += c * (dest - src)
    print total

Measured memory_bytes: 106528
const abc = "abcdefghij";

function func(len, str){
  if(len === str.length){
    console.log(str);
    return;
  }
  var usedMax = str.split("").sort().reverse()[0];
  var index = abc.split("").findIndex(c => c === usedMax);

  for(var i=0; i <= index+1 && i < len; i++){
    func(len, str+abc[i]);
  }
}

function Main(input) {
        input = input.split("\n");
        tmp = input[1].split(" ");
        var k = parseInt(input[0], 10);
        func(k, "a");
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 12428
import sys
def input(): return sys.stdin.readline().rstrip()
from collections import defaultdict

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        self.all_group_member=defaultdict(list)
        for i in range(self.n):
            self.all_group_member[self.find(i)].append(i)
        return self.all_group_member

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots()) 
 
def main():
    n,m=map(int, input().split())
    uf = UnionFind(n+1)
    for _ in range(m):
        a,b=map(int, input().split())
        uf.union(a, b)  # aとbをマージ
    print(uf.group_count()-2)
    #for group in uf.to_sets():  # すべてのグループのリストを返す
        #print(group)
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 13268
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {


		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		int tmpa = 0;
		int tmpb = 0;
		int tmpc = 0;
		tmpa = b;
		tmpb = a;
		a = tmpa;
		b = tmpb;
		tmpa = c;
		tmpc = a;
		a = tmpa;
		c = tmpc;

		System.out.println(a +" "+b + " " +c);

	}
}

Measured memory_bytes: 21844