akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;


/* エイリアス */
#define ll long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vpi vector<pii>
#define vpll vector<pll>
#define endl '\n'

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define em emplace
#define mp make_pair


/* 関数マクロ */
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep2(i, n, m) for (ll i = n; i <= m; ++i)
#define rep3(i, n, m) for (ll i = n; i >= m; --i)
#define all(v) v.begin(), v.end()
#define si(v) int(v.size())
#define UNIQUE(v) sort(all(v)), v.erase(unique(all(v)),v.end())


/* 定数 */
const ll mod = 1e9 + 7;
const ll infll = (1LL << 62) - 1;
const ll inf = (1LL << 30) - 1;


/* その他 */
template<class S, class T> inline bool chmax(S &a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class S, class T> inline bool chmin(S &a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T> using pq = priority_queue<T>;
template<class T> using pqg = priority_queue<T, vector<T>, greater<T>>;


signed main() {
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  int n; cin >> n;
  int c[100001] = {};

  rep2(i, 1, 100) rep2(j, 1, 100) rep2(k, 1, 100) {
    int v = i*i + j*j + k*k + i*j + j*k + i*k;
    ++c[v];
  }

  rep2(i, 1, n) cout << c[i] << endl;
}


Measured memory_bytes: 3936
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)n; ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cout<<*i<<" "; cout<<endl; }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int N, C;
int grid[10][10];
bool valid(int x, int y){
  return (y >= 0 && x >= 0 && y < N && x <= y);
}
int dx[6] = {1, 1, 0, -1, -1, 0};
int dy[6] = {0, 1, 1, 0, -1, -1};
int calc(){
  int res = 0;
  bool used[10][10] = {};
  REP(y, N)REP(x, y + 1){
    if(grid[y][x] != 0 && !used[y][x]){
      int cnt = 1;
      queue<int> qx, qy;
      qx.push(x); qy.push(y);
      used[y][x] = true;
      bool removed = true;
      while(!qx.empty()){
        int xx = qx.front(), yy = qy.front();
        qx.pop(), qy.pop();
        REP(r, 6){
          int nx = xx + dx[r];
          int ny = yy + dy[r];
          if(valid(nx, ny) && grid[ny][nx] == 0) removed = false;
          if(valid(nx, ny) && grid[ny][nx] == grid[yy][xx] && !used[ny][nx]){
            cnt ++;
            used[ny][nx] = true;
            qx.push(nx), qy.push(ny);
          }
        }
      }
      if(removed){
        if(C == grid[y][x]) cnt *= -1;
        res += cnt;
      }
    }
  }
  return res;
}

int main(){
  int cnt = 0;
  while(cin>>N>>C && N){
    //printf("Case %d:\n", ++cnt);
    int board[10][10] = {};
    REP(i, N)REP(j, i + 1){
      cin>>board[i][j];
    }
    int ans = -INF;
    REP(y, N)REP(x, y + 1)if(board[y][x] == 0){
      memcpy(grid, board, sizeof(grid));
      grid[y][x] = C;
      ans = max(ans, calc());
    }
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 1200
#include <bits/stdc++.h>
using namespace std;
#define all(c) (c).begin(),(c).end()
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define iter(c) __typeof((c).begin())
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
#define mem(a) memset(a,0,sizeof(a))
#define pd(a) printf("%.10f\n",a)
#define pb(a) push_back(a)
#define in(a) insert(a)
#define pi M_PI
#define R cin>>
#define F first
#define S second
#define C class
#define ll long long
#define ln cout<<'\n'
#define _(_1,_2,_3,N,...)N
#define pr(...) _(__VA_ARGS__,pr3,pr2,pr1)(__VA_ARGS__)
template<C T>void pr1(T a){cout<<a;ln;}
template<C T,C T2>void pr2(T a,T2 b){cout<<a<<' '<<b;ln;}
template<C T,C T2,C T3>void pr3(T a,T2 b,T3 c){cout<<a<<' '<<b<<' '<<c;ln;}
template<C T>void PR(T a,int n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
bool check(int n,int m,int x,int y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<60,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

int a[21][21],ans,n,m,sx,sy;

void dfs(int xx, int yy, int k) {
  if(k==11) return;
  rep(i,4) {
    int nx=xx,ny=yy,x,y,d=0;
    while(1) {
      x=nx+dx[i],y=ny+dy[i];
      if(!check(n,m,x,y)||a[x][y]%2) break;
      nx=x,ny=y;
      d++;
    }
    if(!check(n,m,x,y)) continue;
    if(a[x][y]==1&&d) {
      a[x][y]=0;
      dfs(nx,ny,k+1);
      a[x][y]=1;
    }
    if(a[x][y]==3) ans=min(ans,k);
  }
}
void Main() {
  while(cin >> m >> n&&n) {
    rep(i,n)rep(j,m) {
      R a[i][j];
      if(a[i][j]==2) sx=i,sy=j;
    }
    ans=MAX;
    dfs(sx,sy,1);
    if(ans==MAX) ans=-1;
    pr(ans);
  }
}

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


Measured memory_bytes: 1200
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <stack>
#include <bitset>
#include <utility>
// #include <numeric>
using namespace std;



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector<vector<ll>> vvint;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define INT_MAX 2147483647
#define LLONG_MAX 9223372036854775807
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())
#define vsortgr(vec) sort(vec.begin(), vec.end(), greater<ll>())


typedef struct{
  ll pos;
  ll depth;
} data;
//
// struct Node{
//
// }



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

// ll X,Y,Z,K;
// ll pmax = 30000000000;
// vint A,B,C;




// int binary_search(int key){
//  //isOKを満たす要素のうち最小のインデックスを返す。（要ソート）
//   int left = -1;
//   int right = N;
//
//   while(right - left > 1){
//     int mid = left + (right - left)/2;
//
//     if(isOK(mid, key)) right=mid;
//     else left=mid;
//   }
//
//   return right;
// }

// ll gcd(ll m, ll n){
//   if(m<n) swap(m,n);
//   if(n==0) return m;
//   return gcd(n, m%n);
// }





int main() {

  ll N,W;
  cin>>N>>W;
  vint w(N),v(N);
  rep(i,N)cin>>w[i]>>v[i];



  ll V = 100000;
  vvint dp(N+1, vint(V+1, W+1));

  dp[0][0] = 0ll;

  rep(i, N){
    rep(j, V+1){
      if(j-v[i]>=0){
        dp[i+1][j] = min(dp[i][j-v[i]]+w[i], dp[i][j]);
      }else{
        dp[i+1][j] = dp[i][j];
      }
    }
  }



  // ll ans = 1;
  ll ans = 0ll;
  rep(j, V+1){
    if(dp[N][j]<=W){
      ans = j;
    }
  }

  cout << ans << endl;




}

















//


Measured memory_bytes: 80256
def compress_array_to_hash(array)
  hash = {}
  array.map { |e|
    if hash[e].nil?
      hash[e] = 1
    else
      hash[e] += 1
    end
  }
  hash
end

n = gets.to_i
hash = compress_array_to_hash(readlines.map(&:to_i))
count = 0
hash.each do |key, value|
  count += 1 if value.odd?
end
puts count


Measured memory_bytes: 15612
#include <iostream>
#include <memory.h>
#include <string>
using namespace std;
const int MAXN = 15;
string mat[MAXN];
int couple[MAXN], cnt[26];
bool used1, used2, vis[MAXN];
int n, m;

bool check (int i) {
    if (vis[i]) return check(i+1);
    if (i == m) return true;
    for (int j = i+1; j < m; j++) {
        if (vis[j]) continue;
        bool flag = true;
        for (int k = 0; k < n && flag; k++) {
            if (mat[k][i] != mat[couple[k]][j]) flag = false;
        }
        if (flag) {
            vis[i] = true;
            vis[j] = true;
            return check(i+1);
        }

    }
    if (m % 2 == 1 && !used2) {
        used2 = true;
        vis[i] = true;
        return check(i+1);
    }
    return false;
}

bool cmp(int i, int j) {
    memset(cnt, 0, sizeof(cnt));
    for (int k = 0; k < m; k++) {
        cnt[mat[i][k]-'a']++;
        cnt[mat[j][k]-'a']--;
    }
    for (int k = 0; k < 26; k++) {
        if (cnt[k] != 0) return false;
    }
    return true;

}

bool solve (int i) {
    if (couple[i] != -1) return solve(i+1);
    if (i == n) {
        memset(vis, false, sizeof(vis));
        used2 = false;
        return check(0);
    }
    if (n % 2 == 1 && !used1) {
        couple[i] = i;
        used1 = true;
        if (solve(i+1)) return true;
        used1 = false;
        couple[i] = -1;
    }
    for (int j = i+1; j < n; j++) {
        if (couple[j] != -1) continue;
        if (!cmp(i, j)) continue;
        couple[i] = j;
        couple[j] = i;
        if (solve(i+1)) return true;
        couple[i] = -1;
        couple[j] = -1;
    }
    return false;

}

int main() {
//    freopen("test.txt", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cin >> n >> m;
    for (int i = 0; i < n; i++) {
        cin >> mat[i];
    }
    memset(couple, -1, sizeof(couple));
    if (solve(0)) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int f = 0;
    int[] a = new int[n];
    for(int i = 0;i<n;i++){
      a[i]=sc.nextInt();
    }
    for(int i = 0; i<n; i++){
      if(a[a[i]-1]==i+1){
        f++;
        //System.out.println(a[a[i]-1]);
      }
    }
    System.out.println(f/2);
  }
}


Measured memory_bytes: 58900
/* template.cpp {{{ */
#include <bits/stdc++.h>
using namespace std;
#define get_macro(a, b, c, d, name, ...) name
#define rep(...) get_macro(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep(...) get_macro(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
#define rep1(n) rep2(i_, n)
#define rep2(i, n) rep3(i, 0, n)
#define rep3(i, a, b) rep4(i, a, b, 1)
#define rep4(i, a, b, s) for (ll i = (a); i < (ll)(b); i += (ll)(s))
#define rrep1(n) rrep2(i_, n)
#define rrep2(i, n) rrep3(i, 0, n)
#define rrep3(i, a, b) rrep4(i, a, b, 1)
#define rrep4(i, a, b, s) for (ll i = (ll)(b) - 1; i >= (ll)(a); i -= (ll)(s))
#define each(x, c) for (auto &&x : c)
#define fs first
#define sc second
#define all(c) begin(c), end(c)
using ui = unsigned;
using ll = long long;
using ul = unsigned long long;
using ld = long double;
const int inf = 1e9 + 10;
const ll inf_ll = 1e18 + 10;
const ll mod = 1e9 + 7;
const ll mod9 = 1e9 + 9;
const int dx[]{-1, 0, 1, 0, -1, 1, 1, -1};
const int dy[]{0, -1, 0, 1, -1, -1, 1, 1};
template<class T, class U> void chmin(T &x, const U &y){ x = min<T>(x, y); }
template<class T, class U> void chmax(T &x, const U &y){ x = max<T>(x, y); }
struct prepare_ { prepare_(){ cin.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(12); } } prepare__;
/* }}} */

int n;
string s;

int main(){
  cin >> n;
  rep(n){
    string t;
    cin >> t;
    s += t;
  }
  rep(i, inf){
    string t = to_string(i);
    bool f = false;
    rep(j, n - t.size() + 1){
      f |= s.substr(j, t.size()) == t;
    }
    if (!f) cout << i << endl, exit(0);
  }
}

Measured memory_bytes: 3272
#include<bits/stdc++.h>
//#include<tr1/unordered_map>
#pragma GCC optimize ("Ofast")
#define ll long long
#define pll pair<long long,long long>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define F first
#define S second
#define forn(i, n) for(int i=0; i<int(n); i++)
#define Forn(i, n) for(int i=1; i<=int(n); i++)

using namespace std;

/*#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> rbtree;*/

int n, m;
vector<int> a[200010];
bool vis[200010];
int anc[200010];
queue<pii> q;

int main()
{
    cin.tie(0);ios_base::sync_with_stdio(false);
    cin >> n >> m;
    forn(i, m)
    {
        int x, y;
        cin >> x >> y;
        a[x].pb(y);
        a[y].pb(x);
    }
    q.push({1, 1});
    while(!q.empty())
    {
        int now = q.front().F;
        if(vis[now])
        {
            q.pop();
            continue;
        }
        vis[now] = 1;
        anc[now] = q.front().S;
        forn(i, a[now].size())
        {
            if(!vis[a[now][i]]) q.push({a[now][i], now});
        }
        q.pop();
    }
    cout << "Yes" << endl;
    for(int i=2; i<=n; i++)
    {
        cout << anc[i] << endl;
    }

}



Measured memory_bytes: 13364
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n;
  cin >> n;
  vl a(n),b(n);

  rep(i,n) cin >> a[i];
  rep(i,n) cin >> b[i];

  ll sa=0, sb = 0;
  rep(i,n){
    sa += a[i];
    sb += b[i];
    ll v = 0;
    if(a[i] < b[i])v = (b[i]-a[i]+1)/2;
    sb += v;
    sa += 2*v;
  }
  //show(sa);
  if(sb-sa < 0){
    cout<<"No"<<endl;
  }
  else cout<< "Yes"<<endl;
  return 0;
}

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


int main(){
   int A,B,H,M;
   cin >> A >> B >> H >> M;
   long double hr = 30 * H + M / 2.0;
   long double mr = 6.0 * M;
   long double dr = abs(hr - mr);
   if(dr >= 180) dr = 360 - dr;
   dr = dr * (M_PI / 180.0);
   long double dist = sqrt(A*A + B*B  -  2* A * B * cosl(dr));
   cout << fixed << setprecision(15) << dist << endl; 
}

Measured memory_bytes: 4136
# use transpose by zip
h, w = map(int, input().split())

grid = [list(input()) for _ in range(h)]

for _ in range(2):
    grid = list(filter(lambda x: any(map(lambda x1: x1 == '#', x)), grid))
    grid = [list(x) for x in zip(*grid)]

for i in range(len(grid)):
    print(''.join(grid[i]))


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

class Dice
{
public:
	int n[6];
	
	void Input()
	{
		cin >> n[0] >> n[1] >> n[2] >> n[3] >> n[4] >> n[5];
	}
	
	void Set(int a, int b, int c, int d, int e, int f)
	{
		n[0] = a;
		n[1] = b;
		n[2] = c;
		n[3] = d;
		n[4] = e;
		n[5] = f;
	}
	
	void Roll(char c)
	{
		switch(c)
		{
			case 'N':
				Set(n[1], n[5], n[2], n[3], n[0], n[4]);
				break;
			case 'W':
				Set(n[2], n[1], n[5], n[0], n[4], n[3]);
				break;
			case 'S':
				Set(n[4], n[0], n[2], n[3], n[5], n[1]);
				break;
			case 'E': 
				Set(n[3], n[1], n[0], n[5], n[4], n[2]);
				break;
		};
	}
	
	bool operator==(Dice d)
	{
		for(int i = 0; i < 6; ++i)
		{
			if(n[i] != d.n[i])
			{
				return false;
			}
		}
		
		return true;
	}
	
	bool Equal(Dice d)
	{
		string cmd = "NNNNWNNNWNNNENNNENNNWNNN";
		for(int i = 0; i < cmd.length(); ++i)
		{
			d.Roll(cmd[i]);
			if(*this == d)
			{
				return true;
			}
		}
		
		return false;
	}
};

int main()
{
	Dice d;
	d.Input();
	
	string cmd;
	cin >> cmd;
	for(int i = 0; i < cmd.length(); ++i)
	{
		d.Roll(cmd[i]);
	}
	
	cout << d.n[0] << endl;
	
	return 0;
} 


Measured memory_bytes: 3188
var lines = [];
var readline = require('readline');

var rl = readline.createInterface({
    input: process.stdin,
    output: process.stdout,
});

rl.on('line', function (x) {
    lines.push(x);
});

rl.on('close', function () {
    var N = Number(lines[0].split(" ")[0]);
    var M = Number(lines[0].split(" ")[1]);

    // 最大公約数をkとする
    // k + k + k + ... + k + (k * m) = M = k * n となれば良い

    var ans = 1;
    for (var k = 1; k * k < M; k++) {

        // Mがkの倍数でない場合，コンテニュー
        if (M % k !== 0) { continue }
        else {
            var n = M / k;

            // kの出現個数(N)がnよりも少なくないといけない
            // k * N = k * n
            if (N <= n) ans = Math.max(ans, k)
            // n * N = k * n
            if (N <= k) ans = Math.max(ans, n)

        }
    }
    console.log(ans)
});

Measured memory_bytes: 11596
import java.io.*
import java.util.*

fun solve(A: Int, B: Int, C: Int){
    val abc = listOf(A, B, C).sorted()
    val d1 = abc[2] - abc[0]
    val d2 = abc[2] - abc[1]
    val ans = d1/2 + d2/2 + when{
        d1 % 2 == 0 && d2 % 2 == 0 -> 0
        d1 % 2 == 1 && d2 % 2 == 1 -> 1
        else -> 2
    }
    println(ans)
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val A = sc.next().toInt()
    val B = sc.next().toInt()
    val C = sc.next().toInt()
    solve(A, B, C)
}



Measured memory_bytes: 33712
#include "bits/stdc++.h"
using namespace std;
#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
typedef long long ll;

const int INF = 1e9 + 7;
const long long LLINF = 1e18;

ll n;
bool isPrime[300001];
void get_prime(){
    isPrime[0]=isPrime[1]=false;
    REP(i, 2, 300001) isPrime[i]=true;
    for(int i=2; i*i<300001; i++){
        for(int j=2*i; j<300001; j+=i){
            isPrime[j]=false;
        }
    }
    return;
}
int main() {
    get_prime();

    while(cin>>n, n!=0){
        ll ans=0;
        REP(i, n+1, 2*n+1){
            if(isPrime[i]) ans++;
        }
        cout<<ans<<endl;
    }
    return 0;
}


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

#define rep(i,N) for(int i=0;i<N;i++)
#define rep2(i,N) for(int i=1;i<=N;i++)
using namespace std;
long long  INF=1e18;
long long mod=1e9+7;

//status unsolved

int main(){
    int n;
    cin>>n;
    vector<vector<int>>pos(200010);
    int col[200010];
    rep(i,n){
        
        cin>>col[i];
        pos[col[i]].push_back(i);
    }
    vector<long long> dp(200010,0);
    dp[0]=1;

    for(int i=0;i<n;i++){

        int color=col[i];
        dp[i+1]+=dp[i];

        int it=lower_bound(pos[color].begin(),pos[color].end(),i)-pos[color].begin();

        //if(it>=pos[color].size())continue;
        if(it>0){
            int p=pos[color][it-1];
            if(i-p>1){
            dp[i+1]+=dp[p+1];
            if(dp[i+1]>mod)dp[i+1]%=mod;
            }
        }
    }
    cout<<dp[n]<<endl;
    return 0;

}
/*


*/


Measured memory_bytes: 13568
from collections import defaultdict, deque

N, M = map(int, input().split())
G = defaultdict(list)
V = defaultdict(int)

for i in range(M):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    G[x].append(y)
    V[y] += 1

q = deque(v for v in range(N) if V[v] == 0)

dp = [0]*(N)
while q:
    From = q.popleft()
    for to in G[From]:
        dp[to] = max(dp[From]+1, dp[to])
        V[to] -= 1
        if V[to] == 0:
            q.append(to)
print(max(dp))

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

int main(){
    int x = 15;
    rep(i,5){
        int y; cin >> y;
        x -= y;
    }
    cout << x << endl;
}

Measured memory_bytes: 3596
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {

    Scanner sc = new Scanner(System.in);

    int n = Integer.parseInt(sc.next());
    Integer[] a = new Integer[n];

    for (int i = 0; i < n; i++) {
      a[i] = Integer.parseInt(sc.next());
    }
    Arrays.sort(a, Collections.reverseOrder());

    int count = 0;
    long sq = 1;

    for (int i = 1; i < n; i++) {
      if (a[i].equals(a[i - 1])) {
        sq *= a[i];
        i++;
        count++;
        if (count >= 2) {
          break;
        }
      }
    }

    if (count < 2) {
      System.out.println(0);
    } else {
      System.out.println(sq);
    }
    sc.close();
  }
}

Measured memory_bytes: 48628
N,M=map(int,input().split())
T=list(map(int,input().split()))
#N=9999 
#M=1
#T=[1,3,4,5,6,7,8,9]
#T=[]
L=[]
for i in range(10):
    if(not T.count(i)):
        L.append(i)

l=len(str(N))+1
MIN=10**10

def calc(st):
    global MIN
    st=str(st)
    if(len(st)>l):return 0
    for num in L:
        t=calc(st+str(num))
        if(int(t)>=N):
            MIN=min(MIN,int(t))
    if(st!=""):
        if(int(st)>=N):
            MIN=min(int(st),MIN)
    return (MIN)

print(calc(str()))







Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
try{
        int a,b,c;
        a = scanner.nextInt();
        b = scanner.nextInt();
        c = scanner.nextInt();

        if(a<b&&b<c){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }

}catch(Exception e){
    System.out.println(e);
}finally{
    scanner.close();
}

    }
    
}


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

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int t;
    int st[100];
    int sn=0;
    while(cin>>t){
        if(t==0) cout<<st[--sn]<<'\n';
        else st[sn++]=t;
    }
    return 0;
}

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

bool compare(string);

int main(){
	string s;

	cin >> s;

	for(;;){
		s.pop_back();
		if(s.length() % 2 == 0){
			if(compare(s)){
				break;
			}
		}
	}

	cout << s.length() << endl;

	return 0;
}

bool compare(string s){

	for(unsigned int j = 0; j < s.length() / 2; ++j){
		if(s[j] != s[s.length() / 2 + j]){
			return false;
		}
	}
	return true;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,i,b[300006],c[300006]={0};
    scanf("%d",&a);
    for(i=0;i<a-1;i++)
    {
        scanf("%d",&b[i]);

    }
    for(i=0;i<a;i++)
    {
        c[b[i]]++;
    }
    for(i=1;i<=a;i++)
    {
        printf("%d\n",c[i]);
    }
}


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

int main(){
	int N;
	long long int x;
	cin >> N;
	
	x=1;
	for(int i=2; i<=N; ++i){
		x*=i;
		if(x > 1000000007) x%=(1000000007);
	}
	
	x%=(1000000007);
	
	cout << x << endl;
	return 0;
}

Measured memory_bytes: 256
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int n, m;
  while (cin >> n >> m, n) {
    vi a(n), b(m);
    rep(i, n) cin >> a[i];
    rep(i, m) cin >> b[i];
    int as = accumulate(all(a), 0), bs = accumulate(all(b), 0);
    int d = INF, ai, bj;
    rep(i, n) rep(j, m) {
      if (as - a[i] + b[j] == bs - b[j] + a[i]) {
        if (cmin(d, a[i] + b[j])) {
          ai = a[i];
          bj = b[j];
        }
      }
    }
    if (d == INF) {
      cout << -1 << endl;
    } else {
      cout << ai << ' ' << bj << endl;
    }
  }
}

Measured memory_bytes: 3052
#include<bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
using namespace std;
#define pb push_back
int dy[]={0, 0, 1, -1, 1, 1, -1, -1};
int dx[]={1, -1, 0, 0, 1, -1, -1, 1};

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define mp make_pair
#define fi first
#define sc second
#define INF 1000000000

struct edge {ll from,to,D,E;};

ll n,m,l;
edge es[200000];
ll dp[200][200];

int main() {
	while(true) {
		cin >> n >> m >> l;

		if(n == 0)
			break;

		REP(i,m) {
			ll a,b,d,e;
			cin >> a >> b >> d >> e;
			a--;b--;

			es[i*2] = (edge) {a,b,d,e};
			es[i*2+1] = (edge) {b,a,d,e};
		}

		REP(i,n)REP(j,l+1)dp[i][j] = INF;

		REP(i,l+1)dp[n-1][i] = 0;

		while(true) {
			bool f = true;

			REP(i,m*2) {
				edge e = es[i];

				REP(j,l+1) {
					if(dp[e.from][j] > dp[e.to][j] + e.E){
						f = false;
						dp[e.from][j] = dp[e.to][j] + e.E;
					}
					if(j + e.D <= l && dp[e.from][j] > dp[e.to][j + e.D]) {
						f = false;
						dp[e.from][j] = dp[e.to][j + e.D];
					}
				}
			}

			if(f)
				break;

		}
		cout << dp[0][0] << endl;
	}
	return 0;
}



Measured memory_bytes: 3536
n = int(input())
res_list = []
for i in range(n):
    a,b=input().split()
    res_list.append((a,int(b)))
psorted_res_list = sorted(res_list, key=lambda x: x[1], reverse=True)
sorted_res_list = sorted(psorted_res_list, key=lambda x: x[0])
for i in range(n):
    print(res_list.index(sorted_res_list[i]) + 1)

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

using namespace std;


int main() {
    int n;
    cin >> n;
    vector<int> a(n),b(n),c(n-1);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for(int i = 0; i < n; i++) {
        cin >> b[i];
    }
    for(int i = 0; i < n-1; i++) {
        cin >> c[i];
    }
    int ans = accumulate(b.begin(),b.end(),0);
    for(int i = 0; i < n-1; i++) {
        if(a[i] + 1 == a[i+1]) {
            ans += c[a[i]-1];
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
from sys import stdin


def main():
    H, W = [int(x) for x in stdin.readline().rstrip().split()]
    mtx = [list(stdin.readline().rstrip()) for _ in range(H)]
    mtx = [x for x in mtx if len([y for y in x if y == '#']) != 0]
    mtx = [x for x in zip(*mtx)]
    mtx = [x for x in mtx if len([y for y in x if y == '#']) != 0]
    mtx = [x for x in zip(*mtx)]
    for x in mtx:
        print(''.join(x))


if __name__ == '__main__':
    main()


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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> PII;
typedef pair<ll, int> PILL;
typedef pair<ll, ll> PLL;

const int MAX_N = 1e5+5;
const int M = 1e6;
const ll INF = (ll)(1e18);
const int inf = 1e9;
const ll MOD = 1000000007LL;

void solve() {

}

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

    string s,t,u;
    cin >> s >> t;
    int a, b;
    cin >> a >> b;
    cin >> u;
    if (u == s) a--;
    else b--;

    cout << a << " " << b;









    return 0;
}


Measured memory_bytes: 892
import math 

a, b, C = map(int, input().split())

if C == 90 or C == 270:
    h = b
    S = a * h * 0.5
    L = a + b + math.sqrt(a ** 2 + b ** 2)
    
else:
    C = math.radians(C)
    h = b * math.sin(C)
    S = a * h * 0.5
    L = a + b + math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(C))

print(f"{S:.4f}\n{L:.4f}\n{h:.4f}")


Measured memory_bytes: 5716
#include "stdio.h"
#include "stdlib.h"
#include "iostream"
#include "math.h"
#include <string.h>


using namespace std;



int main() {
	int n, x,a[200000];
	long long int d = 0,dd, in[200000];
	int i, j=2, k=0;
	cin >> n ;
	a[0] = 0;
	
	for (i = 1;i <= n;i++) {
		cin >> a[i];
		in[i] = (long long int)(fabs(a[i] - a[i - 1]));
		d +=in[i];

	}
	a[n + 1] = 0;
	in[n + 1] = (long long int)(fabs(a[n]));
	d += in[n+1];

	for (i = 1;i <= n;i++) {
		dd = d - in[i] - in[i + 1] + (long long int)(fabs(a[i + 1] - a[i - 1]));

		printf("%lld\n", dd);
	}
	
	

	return 0;
}

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

void print(vector<vector<int>> arr) {
	for (int i = 0; i < (int)arr.size(); ++i) {
		for (int j = 0; j < (int)arr[0].size(); ++j) {
			cout << arr[i][j] << " ";
		}
		cout << endl;
	}
	cout << endl;
}


int main() {
	int n, m;
	cin >> n >> m;
	vector<string> s(n);
	for (int i = 0; i < n; ++i) {
		cin >> s[i];
	}
	vector<vector<int>> up(n, vector<int> (m, -1));
	vector<vector<int>> down(n, vector<int> (m, n));
	vector<vector<int>> left(n, vector<int> (m, -1));
	vector<vector<int>> right(n, vector<int> (m, m));
	
	for (int i = 0; i < n; ++i) {
		if (s[i][0] == '#')left[i][0] = 0;
		for (int j = 1; j < m; ++j) {
			left[i][j] = left[i][j - 1];
			if (s[i][j] == '#')left[i][j] = j;
		}
	}
	
	for (int i = 0; i < n; ++i) {
		if (s[i][m - 1] == '#')right[i][m - 1] = m - 1;
		for (int j = m - 2; j >= 0; --j) {
			right[i][j] = right[i][j + 1];
			if (s[i][j] == '#')right[i][j] = j;
		}
	}
	for (int i = 0; i < m; ++i) {
		if (s[0][i] == '#')up[0][i] = 0;
		for (int j = 1; j < n; ++j) {
			up[j][i] = up[j - 1][i];
			if (s[j][i] == '#')up[j][i] = j;
		}
	}
	
	for (int i = 0; i < m; ++i) {
		if (s[n - 1][i] == '#')down[n - 1][i] = n - 1;
		for (int j = n - 2; j >= 0; --j) {
			down[j][i] = down[j + 1][i];
			if (s[j][i] == '#')down[j][i] = j;
		}
	}
	int ans = 0;
	for (int i = 0; i < n; ++i) {
		for (int j = 0; j < m; ++j) {
			if (s[i][j] == '.') {
				int x = 1;
				x += max(0, i - up[i][j] - 1);
				x += max(0, down[i][j] - i - 1);
				x += max(0, j - left[i][j] - 1);
				x += max(0, right[i][j] - j - 1);
				ans = max(ans, x);
			}
		}
	}
	
	cout << ans;
}


Measured memory_bytes: 73660
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}

int main(){
    ll N,M;
    cin >> N >> M;
    vector<pair<Pll,ll>> v(M);
    vector<Pll> a(M);
    rep(i,M){
        ll p,y;
        cin >> v[i].first.first >> v[i].first.second;
        v[i].second = i;  
    }
    sort(v.begin(), v.end());
    ll prev = -1;
    ll ind = 0;
    rep(i,M){
        if(prev == v[i].first.first){
            ind++;
        }else{
            ind = 1;
        }
        a[v[i].second] = Pll(v[i].first.first,ind);
        prev = v[i].first.first;
    }
    rep(i,M){
        cout << setfill('0') << right << setw(6) << a[i].first;
        cout << setfill('0') << right << setw(6) << a[i].second;
        cout << endl;
    }
    //cout << cnt << endl;
}

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

typedef long long ll;
typedef long double ld;

#define imx INT_MAX
#define imn INT_MIN
#define llmx LLONG_MAX
#define llmn LLONG_MIN

#define fi first
#define se second
#define pb push_back
#define f_s(a) sort(a.begin(), a.end())
#define b_s(a) sort(a.rbegin(), a.rend())
#define p(a) cout<<a<<"\n"
// #define l(i, )
// #define rl(i, a, b) for(int i = a; i < b; i++)

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


////////////////////SIEVE OF ERATOSTHENES//////////////////////
vector<int> sieveoferatosthenes(int n)
{
	vector<bool> prime(n+1, true);
	for(int i = 2; i <= sqrt(n); i++)
	{
		if(prime[i])
		{
			for(int j = i*i; j<=n; j+=i)
			{
				prime[j]=false;
			}
		}
	}
	vector<int> all_primes;
	for(int i = 2; i <=n; i++)
	{
		if(prime[i]) all_primes.pb(i);
	}
	return all_primes;
}



int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	vector<ll> pos, neg;
	ll curr = 0, i = 0, x;
	cin>>x;
	while(curr <= 100000000000)
	{
		pos.pb(curr);
		i++;
		curr= pow(i, 5);
	}
	int s = pos.size();
	for(int i = 1; i < s; i++)
		neg.pb(pos[i]);
	int s2 = neg.size();
	for(int i = 0; i < s; i++)
	{
		for(int j = 0; j < s; j++)
		{
			if(pos[i]-pos[j]==x)
			{
				cout<<i<<" "<<j;
				return 0;
			}
			if(pos[i]+pos[j]==x)
			{
				cout<<i<<" "<<-j;
				return 0;
			}
		}
	}

	// for(int i = 0; i < s; i++)
	// {
	// 	for(int j = 0; j < s2; j++)
	// 	{
	// 		if(pos[i]+neg[j]==x or pos)
	// 		{
	// 			cout<<i<<" "<<"-"<<j+1;
	// 			return 0;
	// 		}
	// 	}
	// }

}

Measured memory_bytes: 4020
#include <bits/stdc++.h>
#include<cmath>
#include<iomanip>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int arr[6];
    int ans;
    for(int j=1;j<=5;j++)
    {
    	cin>>arr[j];
    	if(arr[j]==0)
    	{
         ans=j;
    	}}
    	cout<<ans;
    }

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

int main(){
  int l;
  cin >> l;
  
  double s = (double)l/3;
  
  cout << fixed << setprecision(15) << s*s*s << endl;
  
  return 0;
}

Measured memory_bytes: 3796
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<math.h>
#include<string>
#include <iomanip>
#include<deque>
#include<queue>
#include<stack>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
const ll LINF = 1e18;
const int INF = 1e8;

//マクロ定義
#define vvint(vec,n,m,l) vector<vector<int>> vec(n, vector<int>(m,l));	// lで初期化
#define vvll(vec,n,m,l) vector<vector<ll>> vec(n,vector<ll>(m,l));
#define vint vector<int>
#define pint pair<int,int>
#define rep(i,a) for(int i=0;i<(a);i++)
#define all(x) (x).begin(),(x).end()
#define debug system("pause")				//デバッグ用

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

	int n;
	cin >> n;
	vector<pair<string, pair<int,int>>> s(n);
	rep(i, n)
	{
		cin >> s[i].first >> s[i].second.first;
		s[i].second.second = i+1;
	}

	sort(s.begin(), s.end());
	rep(i, n-1)
	{
		for (int j = i; j < n; j++)
		{
			if (s[i].second.first < s[j].second.first && s[i].first==s[j].first)
			{
				pair<string, pair<int, int>> tmp = s[i];
				s[i] = s[j];
				s[j] = tmp;
			}
		}
	}
	rep(i, n)
	{
		cout << s[i].second.second << endl;
	}

}

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

#define f(i,a,b) for (int i = a; i < b; i++)

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n,m;
	cin>>n>>m;
	int cnt[n];
	bool red[n];
	f(i,0,n) cnt[i]=1,red[i]=0;
	red[0]=1;	
	f(i,0,m) {
		int x,y; cin>>x>>y;	x--; y--;
		cnt[x]--; cnt[y]++;
		red[y] |= red[x];
		if (!cnt[x]) red[x]=0;
	}
	int ans = 0;
	f(i,0,n) ans += red[i];
	cout << ans << endl;

	return 0;
}


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

int n;
vector <int> b, rlt;

int main()
{
    scanf("%d", &n);
    b.resize(n);
    for (int i = 0; i < n; i ++) scanf("%d", &b[i]);
    while (n --)
    {
        int k = n;
        while (k >= 0 && b[k] != k + 1) k --;
        if (k < 0) return printf("-1"), 0;
        rlt.push_back(k + 1), b.erase(b.begin() + k);
    }
    reverse(rlt.begin(), rlt.end());
    for (int i = 0; i < rlt.size(); i ++) printf("%d\n", rlt[i]);
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <math.h>
#include <string>
#include <algorithm>
#include <ctype.h>
#include <vector>
#include <numeric>
#include <map>
using namespace std;

#define ll long long int
#define rep(i, a, n) for (int i = a; i < n; i++)
#define INF 1e9
#define LINF 1e17
#define MOD (int)(1e9 + 7)
#define pi 3.141592653589
#define pii pair<int, int>
#define pll pair<ll, ll>
#define vi vector<int>
#define vll vector<ll>
#define ALL(a) (a).begin(), (a).end()
#define sort_v(a) sort(a.begin(), a.end())
#define fi first
#define se second

void print(bool c)
{
    if (c)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

ll gcdll(ll a, ll b)
{
    while (1)
    {
        if (a < b)
            swap(a, b);
        if (b == 0)
            break;
        a %= b;
    }
    return a;
}

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

bool cmp(const pii &a, const pii &b)
{
    if (a.second != b.second)
        return a.second < b.second;
    return a.first < b.first;
}

int main()
{
    int n;
    cin >> n;
    vi a(n), ans(n);
    rep(i, 0, n) cin >> a[i];
    int cnt = 0;
    for (int i = n; i > 0; i--)
    {
        int sum = 0;
        rep(j, 1, n / i)
        {
            if (ans[i * (j + 1) - 1] == 1)
            {
                sum ^= 1;
            }
        }
        //cout << i << " " << sum << endl;
        if (sum == a[i - 1])
            ans[i - 1] = 0;
        else
        {
            ans[i - 1] = 1;
            cnt++;
        }
    }
    /* rep(i, 0, n)
    {
        cout << ans[i] << " ";
    }
    cout << endl;*/

    cout << cnt << endl;
    int out = 0;
    rep(i, 0, n)
    {
        if (ans[i] == 1)
        {
            if (out != cnt - 1)
            {
                cout << i + 1 << " ";
                out++;
            }
            else
            {
                cout << i + 1 << endl;
            }
        }
    }
}


Measured memory_bytes: 2432
// g++ macro.cpp -std=c++14
#include <bits/stdc++.h> //STL include
typedef long long ll;// long long int
const ll INF = 10000000000;//INFinity
using namespace std;//namespace

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}//transform
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//#define int long long // yabai

#define dump(x)  cout << #x << " = " << (x) << endl;// debug cout

#define FOR(i,a,b) for(int i=(a);i<(b);++i)// for macro
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define ALL(obj) (obj).begin(),(obj).end()// iterator

#define pb(a) push_back(a)//push_back
#define mp make_pair// make_pair


int main(){

    string s;
    cin>>s;
    s.at(3)='8';
    cout<<s<<endl;

    return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <climits>
#include <ctime>
#include <cassert>
using namespace std;

#define rep(i,a,n) for(int i=a; i<n; i++)
#define repq(i,a,n) for(int i=a; i<=n; i++)
#define repr(i,a,n) for(int i=a; i>=n; i--)
#define pb(a) push_back(a)
#define fr first
#define sc second
#define INF 2000000000

#define X real()
#define Y imag()
#define EPS (1e-10)
#define EQ(a,b) (abs((a) - (b)) < EPS)
#define EQV(a,b) ( EQ((a).X, (b).X) && EQ((a).Y, (b).Y) )
#define LE(n, m) ((n) < (m) + EPS)
#define LEQ(n, m) ((n) <= (m) + EPS)
#define GE(n, m) ((n) + EPS > (m))
#define GEQ(n, m) ((n) + EPS >= (m))

typedef vector<int> VI;
typedef vector<VI> MAT;
typedef pair<int, int> pii;
typedef long long int ll;

typedef complex<double> P;
typedef pair<P, P> L;
typedef pair<P, double> C;

int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
int const MOD = 1000000007;

namespace std {
    bool operator<(const P& a, const P& b) {
        return a.X != b.X ? a.X < b.X : a.Y < b.Y;
    }
}

int main() {
    string s1, s2; cin >> s1;
    s2 = "CODEFESTIVAL2016";
    int cnt = 0;
    rep(i,0,16) {
        if(s1[i] != s2[i]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

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

int main() {
  int A, B;
  cin >> A >> B;
  if((A != 1)&&(B != 1)){
    cout << 1 << endl;
  }
  if((A != 2)&&(B != 2)){
    cout << 2 << endl;
  }
  if((A != 3)&&(B != 3)){
    cout << 3 << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const int nmax = 8;
bool graph[nmax][nmax];
const int INF = 1e9;
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll dp[110][100100] = {0};
void solve(long long N, long long W, std::vector<long long> w, std::vector<long long> v)
{
    for (int i = 0; i < N; i++)
    {
        for (int j = 0; j <= W; j++)
        {
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
            if (j - w[i] >= 0)
            {
                dp[i + 1][j] = max(dp[i + 1][j], dp[i][j-w[i]] + v[i]);
            }
        }
    }

    cout << dp[N][W] << endl;
}

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


Measured memory_bytes: 79360
package main

import (
  "fmt"
)

func main() {
  var N int
  fmt.Scan(&N)
  a := make([]int, N)
  for i:= range(a){
    fmt.Scan(&a[i])
  }
  // fmt.Println(a)
  m := map[int]int{}
  for i:= range(a){
    m[a[i]] +=1
  }
  // fmt.Println(m)

  result := 0
  for k, v := range(m){
    if k < v{
      result += v-k
    }else if k == v{
      continue
    }else{
      result += v
    }
  }
  fmt.Println(result)
}


Measured memory_bytes: 8576
X,N = map(int,input().split())
P = list(map(int,input().split()))

result = 0
if N == 0:
    result = X
else:
    list = [i for i in range(201)]
    for i in P:
        list.remove(i)
    if len(list) == 0:
        result = 0
    else:
        min = 100
        for i in list:
            if min > abs(X-i):
                min = abs(X - i)
                result = i
print(result)

Measured memory_bytes: 9204
def tps(n,inCnt,out)
	s = []
	ret = []
	n.times do |i|
		s << i if inCnt[i] == 0
	end
	while v = s.shift
		ret << v
		#tの出力辺とその先のノードmを見て、辺を削除
		#mが入力辺を持っていない=mの最後の入力がtならm追加
		out[v].each do |m|
			inCnt[m] -= 1
			s << m if inCnt[m] == 0
		end
	end
	return ret
end

N,M = gets.split.map(&:to_i)
dp = [0]*(N+1)
cnt= [0]*(N+1)
cnt[0] = -1

vin = (N+1).times.map{[]}
vout = (N+1).times.map{[]}

M.times do
	x,y = gets.split.map(&:to_i)
	cnt[y] += 1
	vin[y] << x
	vout[x] << y
end

list = tps(N+1,cnt,vout)

list.each do |t|
	max = -1
	vin[t].each do |j|
		max = dp[j] if max < dp[j]
	end
	dp[t] = max+1
	#p [t,vin[t],dp[t]]
end
p dp.max

Measured memory_bytes: 27772
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

def resolve():
    S=list(input())
    print(len(S[S.index('A'):[i for i ,x in enumerate(S) if x == 'Z'][-1]+1]))


resolve()

Measured memory_bytes: 61552
N = int(input())
S1 = input()
S2 = input()

s = sorted(set(S1) | set(S2))

c = [[None, None]] * N
"""
rrB
ggB

r2
r2

"""
cnt = 1
if S1[0] == S2[0]:
    # x
    # x
    cnt = 3 
    i = 1
else:
    # 012
    # xx
    # yy
    cnt = 6
    i = 2

while i < N:
    m = 0
    if S1[i] == S2[i]:
        if S1[i-1] == S2[i-1]:
            # xA
            # xA
            m= 2
        else:
            # xA
            # yA
            m= 1
        i+=1
    else:
        if S1[i-1] == S2[i-1]:
            # xAA
            # xBB
            m= 2
        else:
            # rrAA r,r,r,g,g,g,b,b,b
            # ggBB r,g,b,r,g,b,r,g,b
            #            o   o o    
            m= 3
        i+=2
    cnt = (cnt * m) % 1000000007
    #print(S1[:i])
    #print(S2[:i])
    #print(m, cnt)
    #print()
print(cnt)


Measured memory_bytes: 3064
//Artie WANG
//io
#include <iostream>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <sstream>

//data structure
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
//#include <unordered_map>
//#include <unordered_set>
#include <utility>
#include <bitset>
#include <complex>


#include <cassert>

using namespace std;

const char newline = '\n';
typedef pair<int, int> ii;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l4;

const int maxn = 1e5+10;
int n, a[maxn], cnt[maxn];
const int mod = 1e9+7;
ll f[maxn], inv[maxn];
void gcd(ll a, ll b, ll &x, ll &y)
{
  if (b == 0)
    {
      x = 1, y = 0;
    }
  else
    {
      gcd(b, a%b, y, x);
      y -= a/b*x;
    }
}
ll inverse(ll base)
{
  ll x, y;
  gcd(base, mod, x, y);
  return (x%mod+mod)%mod;
}

void init()
{
  f[0] = 1;
  for (ll i = 1; i < maxn; ++i)
    {
      f[i] = f[i-1]*i%mod;
    }
  inv[maxn-1] = inverse(f[maxn-1]);
  for (ll i = maxn-1; i >= 1; --i)
    {
      inv[i-1] = inv[i] * i % mod;
    }
  assert(inv[0] == 1);
}

ll cb(ll n, ll k)
{
  if (k > n) return 0;
  return f[n] * inv[k] % mod * inv[n-k] % mod;
}
int main()
{
  init();
  scanf("%d", &n);
  n = n+1;
  fill(cnt+1, cnt+1+n, 0);
  for (int i = 1; i <= n; ++i)
    {
      scanf("%d", a+i);
      cnt[a[i]] += 1;
    }
  vector<int> occur;
  for (int i = 1; i <= n; ++i)
    {
      if (cnt[a[i]] == 2)
	{
	  occur.push_back(i);
	}
    }
  assert(occur.size() == 2);
  ll left = occur[0]-1 + n-occur[1];
  int repeat = a[occur[0]];
  for (int i = 1; i <= n; ++i)
    {
      ll ans = cb(n, i);
      ans -= cb(left, i-1);
      ans = (ans%mod+mod)%mod;
      printf("%lld\n", ans);
    }
}


Measured memory_bytes: 3584