akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define dbg(x) cout << #x << '=' << x << '\n';
#define ll long long
#define pi pair<int,int>
#define pl pair<long long,long long>
#define lg length()
#define pb push_back
ifstream in("file.in");
ofstream out("file.out");
#define MAXN 100005
#define INF 1e9+5
#define int long long
#define LINF 1000000000000000005

int a[3],cnt,x,y,z;

map <pair<int,int>,int> v;

int32_t main(){
    ios_base :: sync_with_stdio(0);
    cin >> a[0] >> a[1] >> a[2];
    sort(a,a+3);
    while(!v[{a[0],a[1]}]){
        v[{a[0],a[1]}]=1;
        if(a[0]%2 || a[1]%2 || a[2]%2){
            cout << cnt;
            return 0;
        }
        x=(a[0]+a[1])/2;
        y=(a[0]+a[2])/2;
        z=(a[1]+a[2])/2;
        a[0]=x; a[1]=y; a[2]=z;
        cnt++;
    }
    cout << -1;

}


Measured memory_bytes: 256
unittest
{
	assert( [ "3 3", "1 2 1", "2 3 1", "1 3 2" ].parse.expand.solve == "Yes" );
	assert( [ "3 3", "1 2 1", "2 3 1", "1 3 5" ].parse.expand.solve == "No" );
	assert( [ "4 3", "2 1 1", "2 3 5", "3 4 2" ].parse.expand.solve == "Yes" );
	assert( [ "10 3", "8 7 100", "7 9 100", "9 8 100" ].parse.expand.solve == "No" );
	assert( [ "100 0" ].parse.expand.solve == "Yes" );
	
	assert( [ "5 4", "1 2 1", "3 4 2", "3 5 1", "4 5 1" ].parse.expand.solve == "No" );		// 追加ケース
}



import std.container;
import std.conv;
import std.range;
import std.stdio;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto nm = input.front.split.to!( long[] );
	auto lrds = new long[][]( nm[ 1 ], 3 );
	foreach( ref lrd; lrds )
	{
		input.popFront;
		lrd = input.front.split.to!( long[] );
	}
	return tuple( nm[ 0 ], lrds );
}

auto solve( long n, long[][] lrds )
{
	// 辺配列を頂点基準に変換
	Tuple!( long, long )[][ long ] ess;
	foreach( lrd; lrds )
	{
		ess[ lrd[ 0 ] ] ~= tuple( lrd[ 1 ], +lrd[ 2 ] );
		ess[ lrd[ 1 ] ] ~= tuple( lrd[ 0 ], -lrd[ 2 ] );
	}
	
	// 島が複数ある可能性があるので全頂点対象でループ
	auto ps = new long[]( 1 + n );
	ps[] = long.max;
	DList!long queue;
	foreach( k; ess.keys )
	{
		if( ps[ k ] != long.max ) continue;
		
		// bfsで島一つ分の辺情報を整合性チェック
		ps[ k ] = 0;
		queue.insertBack( k );
		while( !queue.empty )
		{
			auto i = queue.front;
			queue.removeFront;
			foreach( e; ess[ i ] )
			{
				if( ps[ e[ 0 ] ] == long.max )
				{
					ps[ e[ 0 ] ] = ps[ i ] + e[ 1 ];
					queue.insertBack( e[ 0 ] );
				}
				else
				{
					if( ps[ e[ 0 ] ] != ps[ i ] + e[ 1 ] ) return "No";
				}
			}
		}
	}
	return "Yes";
}


Measured memory_bytes: 50300
/*~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=
*$* WRITER:kakitamasziru/OxOmisosiru *$*
~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=~=*/
#ifdef LOCAL_JUDGE
#define _GLIBCXX_DEBUG
#endif
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <iomanip>
#include <limits>//setprecision
//#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
//#include <unordered_set> //unordered_set
#include <stack> // stack
#include <deque> // deque
#include <math.h>//pow,,,
#include <cmath>//abs,,,
#include <bitset> // bitset
#define endl "\n";
using namespace std;

const long long INF = 4000000000000000001;
const int inf = 1001001001;
const int MOD = 1000000007;
typedef pair<long long,long long> P;

//Solve N^M. This, mod_pow use Iterative Square Method.
long long mod_pow(long long N, long long M) {
    if (M == 0) return 1;
    long long res = mod_pow((N * N) % MOD, M / 2);
    //When end-of-a bit is 1, times simple N.
    if (M & 1) res = (res * N) % MOD;
    return res %= MOD;
}
long long gcd(long long a, long long b) {
    if (b == 0) return a;
    else return gcd(b, a % b);
}
long long lcm(long long a, long long b) {
    return a / gcd(a, b) * b ;
}

//fac[]はn! inv[]はMODにおける逆元 finv[]はinv[]とfinv[]の累積積
const long long MAX = 510000;
long long fac[MAX], finv[MAX], inv[MAX];

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

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

int main() {
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    
    COMinit();
    long long N;cin >> N;
    long long K;cin >> K;
    if(K >= N-1){
        //どんな状態にでもできる
        cout << COM(N+N-1,N-1) << endl;
    }
    else{
        //cout << "u shi ta pu ni ki a ku nn wara" << endl;
        //i回目の操作毎に空き部屋が1増える場合が生じる
        long long ans = 1;
        for(long long i = 1;i<=K;i++){
            //cout << ans << endl;
            ans += COM(N,i)*COM(N-1,N-i-1);
            ans %= MOD;
        }
        cout << ans << endl;
    }

}

Measured memory_bytes: 15584
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <algorithm>
#include <iostream>
#include <map>
#include <set>
#include <bitset>
#include <string>
#include <vector>
#include <queue>
#include <functional>

using std::endl;

#define ll long long int
#define loop(a, n) for(int a = 0; a < n; ++a)
#define INF 1145141919810
#define OUT std::cout
#define IN std::cin
#define itn int
#define fro for
#define sdt std

int A, B;

int main()
{
	IN >> A >> B;
	if (A % 2 == 1 && B % 2 == 1) OUT << "Odd" << endl;
	else OUT << "Even" << endl;

	return 0;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i,m,n) for(int i = m - 1; i >= n; i--)
#define ALL(v) v.begin(), v.end()
#define itn int
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define YES() cout << "YES" << endl
#define NO() cout << "NO" << endl
template<typename T, typename U>
inline bool CMAX(T &m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U>
inline bool CMIN(T &m, U x) { if (m > x) { m = x; return true; } return false; }

typedef long long lint;
typedef long double ldouble;
const int INF = 1e9;
const lint LINF = 1e18;
const int MOD = 1e9+7;

int cnt = 0;
int g = 1;
vector<int> gru;
void dfs(int m,vector<vector<int>> &fri){
    if(gru[m] != 0)return;
    gru[m] = g;
    REP(i,fri[m].size())
        dfs(fri[m][i],fri);
}
int main(){
    int n,m,k;
    cin >> n >> m >> k;
    vector<vector<int>> fri(n,vector<int>());
    vector<vector<int>> blo(n,vector<int>());
    vector<int>his(n,0);
    gru = vector<int>(n + 5);
    vector<int>gcnt(n);
    REP(i,m){
        int a,b;
        cin >> a >> b;
        a--;b--;
        fri[a].push_back(b);
        fri[b].push_back(a);
    }
    REP(i,k){
        int a,b;
        cin >> a >>b;
        a--;b--;
        blo[a].push_back(b);
        blo[b].push_back(a);
    }
    REP(i,n){
        dfs(i,fri);
        g++;
    }
    REP(i,n){gcnt[gru[i]]++;}
    REP(i,n){
        int ans = gcnt[gru[i]] - 1;
        REP(j,fri[i].size()){
            if(gru[i] == gru[fri[i][j]])ans--;
        }
        REP(j,blo[i].size()){
            if(gru[i] == gru[blo[i][j]])ans--;
        }
        cout << max(ans,0) << " ";
    }
    cout << endl;
    return 0;
}

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

using namespace std;

int main(){
  int n,k;
  cin>>n>>k;
  vector<int> v;
  for(int i=0;i<n;i++){
    int x;
    scanf("%d",&x);
    //cin>>x;
    v.push_back(x);
  }
  int dp[200010];
  dp[0]=0;
  dp[1]=0;
  for(int i=2;i<=n;i++){
    dp[i]=dp[i-1] + abs(v[i-1] - v[i-2]);
    for(int j=2;j<=k;j++){
    if((i-j)>0)
      dp[i]=min(dp[i],dp[i-j] + abs(v[i-1]-v[i-j-1]));
    }
  }
  cout<<dp[n];
  
  return 0;
}

Measured memory_bytes: 1144
#include<iostream>
using namespace std;
int main(){
  string s;
  int ans = 0;
  while(cin >>s){
    for(int i=0; i<s.size(); i++){
      if(s[i] != s[s.size()-1-i]) break;
      if(i == s.size()-1) ans++;
    }
  }
  cout <<ans<<endl;
  return 0;
}

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

// Begin {{{
using namespace std;

#define all(x) x.begin(), x.end()
#define rep(i, n) for (i64 i = 0; i < (n); ++i)
#define reps(i, s, n) for (i64 i = (s); i <= (n); ++i)
#define VAR(Type, ...) Type __VA_ARGS__; IN(__VA_ARGS__)
#define Float(x) OUTN(fixed, setprecision(x));

using i64 = int_fast64_t;
using pii = pair<i64, i64>;

template <class A, class B>
inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }

template <class A, class B>
inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD = int(1e9) + 7;

// IN
void IN() {}
template <class Head, class... Tail>
void IN(Head&& head, Tail&&... tail) {
  cin >> head;
  IN(forward<Tail>(tail)...);
}

// OUTS
void OUTS() {}
template <class Head, class... Tail>
void OUTS(Head&& head, Tail&&... tail) {
  cout << head << " \n"[sizeof...(tail)==0];
  OUTS(forward<Tail>(tail)...);
}

template <class T>
void OUTS(vector<T> &vec) { for (auto &e : vec) cout << e << " \n"[&e==&vec.back()]; }

template <class T>
void OUTS(vector<vector<T>> &df) { for (auto &vec : df) OUTS(vec); }

// OUTL
void OUTL() {}
template <class Head, class... Tail>
void OUTL(Head&& head, Tail&&... tail) {
  cout << head << "\n";
  OUTL(forward<Tail>(tail)...);
}

template <class T>
void OUTL(vector<T> &vec) { for (auto &e : vec) cout << e << "\n"; }

// OUTN
void OUTN() {}
template <class Head, class... Tail>
void OUTN(Head&& head, Tail&&... tail) {
  cout << head;
  OUTN(forward<Tail>(tail)...);
}

template <class T>
void OUTN(vector<T> &vec) { for (auto &e : vec) cout << e; }
// }}} End

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

  VAR(i64, x, y);

  i64 res;

  if (x >= 0 && y <= 0) res = 1 + abs(x - abs(y));
  else if (x < 0 && y > 0) res = 1 + abs(y - abs(x));

  else if (x >= 0 && y > 0) {
    if (x < y) res = y - x;
    else res = 1 + (x - y) + 1;
  }

  else if (x < 0 && y <= 0) {
    if (x < y) res = y - x;
    else res = 1 + (x - y) + 1;
  }

  OUTL(res);

  return 0;
}


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

using namespace std;

using ll = long long;

struct Edge {
    int src, dst;
    Edge(int f, int t) :
        src(f), dst(t) {}
};

using Edges = vector<Edge>;
using Graph =  vector<Edges>;

bool Augment(const Graph& g, int u,
             vector<int>& matchTo, vector<bool>& visited) {
    if (u < 0)
        return true;

    for (auto e : g[u])
        if (!visited[e.dst]) {
            visited[e.dst] = true;
            if (Augment(g, matchTo[e.dst], matchTo, visited)) {
                matchTo[e.src] = e.dst;
                matchTo[e.dst] = e.src;
                return true;
            }
        }

    return false;
}

// 二部グラフG=(A;B, E)の最大マッチングを求める
// A:[0,L-1], B:[L,g.size()-1]
int BipartiteMaximumMatching(const Graph& g, int L) {
    const int n = g.size();
    Edges matching;
    vector<int> matchTo(n, -1);
    int match = 0;

    for (int u = 0; u < L; ++u) {
        vector<bool> visited(n);
        if (Augment(g, u, matchTo, visited))
            ++match;
    }

    for (int u = 0; u < L; ++u)
        if (matchTo[u] >= 0) // make explicit matching
            matching.emplace_back(Edge(u, matchTo[u]));

    return match;
}

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

    int n;

    cin >> n;
    vector<pair<int, int>> red(n), blue(n);
    for (int i = 0; i < n; ++i) cin >> red[i].first >> red[i].second;
    for (int i = 0; i < n; ++i) cin >> blue[i].first >> blue[i].second;

    Graph g(2 * n);
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            if (red[i].first < blue[j].first && red[i].second < blue[j].second) {
                g[i].emplace_back(Edge(i, n + j));
            }
        }
    }

    cout << BipartiteMaximumMatching(g, n) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int i,j,k,m,n;
    int a,b,c;
    cin>>a>>b>>c;
    for(i=1;i<=200;i++)
    {
        if(i*a%b==c)
        {
            cout<<"YES"<<endl;
            return 0;
        }
    }
    cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 256
dx = [1, 0, -1, 0]
dy = [0, 1, 0, -1]

INF = float('inf')
MOD = 1000000000 + 7

def LI(): return [int(x) for x in input().split(" ")]
def LS(): return [str(x) for x in input().split(" ")]
def ItoS(L): return [str(x) for x in L]
def StoI(L): return [int(c) for c in L]


def solve():
    while 1:
        try:
            n, y = LI()
            for i in range(n + 1):
                for j in range(n + 1):
                    if 9 * i + 4 * j + n == y // 1000 and n - i - j >= 0:
                        print(i, j, n - i - j)
                        raise EndLoop

            print(-1, -1, -1)
            break
        except:
            break
solve()

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <queue>
 
using namespace std;
 
typedef long long ll;
 
const ll INF = 1e9, MOD = 924844033;
 
ll n, k, cnt;
string s;

ll d[4000][4001][2], a[4000], f[4000];
int main ()
{
	cin >> n >> k;

	for (int i = 0; i < k; i++)
	{
		for (int j = i; j < n; j += k)
			a[cnt++] = (j != i);

		for (int j = i; j < n; j += k)
			a[cnt++] = (j != i);
	}

	d[0][0][0] = 1;
	d[0][0][1] = 1;

	for (ll i = 1; i < cnt; i++)
		for (ll j = 0; j <= cnt; j++)
		{
			d[i][j][0] = d[i-1][j][0];
			if (a[i] && j) d[i][j][0] += d[i-1][j-1][1];
			if (d[i][j][0] >= MOD) d[i][j][0] -= MOD;

			d[i][j][1] = d[i-1][j][0];
		}

	f[0] = 1;

	for (ll i = 1; i <= n; i++)
		f[i] = (i * f[i-1]) % MOD;

	ll ans = 0;

	for (ll i = 0; i <= n; i++)
	{
		ll t = f[n-i] * d[cnt-1][i][0] % MOD;
		if (i & 1) t = -t;
		ans += MOD + t;
		ans %= MOD;
	}

	cout << ans;

}

Measured memory_bytes: 250240
import java.io.*;
public class Main {
    public static void main(String[] args) throws IOException{
        BufferedReader buf=new BufferedReader(new InputStreamReader(System.in));
        StringBuilder sb=new StringBuilder();
        int x,y,tmp;
        while(true){
        String str=buf.readLine();
        String[] yuu=str.split(" ");
        
        x=Integer.parseInt(yuu[0]);
        y=Integer.parseInt(yuu[1]);
        
        if(x==0 && y==0){
            break;
        }else if(x>y){
            tmp=x;
            x=y;
            y=tmp;
            }
        sb.append(x).append(" ").append(y).append("\n");
        }
        System.out.print(sb);
    }
}

Measured memory_bytes: 26444
#include "bits/stdc++.h"
using namespace std;


/* macro */
#define rep(i,a,b) for(int i=a;i<b;i++)
#define revrep(i,a,b) for(int i = a; i > b; i--)
#define int long long
#define exist(s,e) ((s).find(e)!=(s).end())
#define all(v) (v).begin(), (v).end()
#define each(s,itr) for(auto (itr) = s.begin(); (itr) != s.end(); (itr)++)
#define sum(v) accumulate(all(v), (0LL))
#define sec second
#define fir first
#define pb push_back



/* alias */
template<class T> using vec = vector<T>;
typedef vector<int> vi;
typedef pair<int, int> pi;


/* constant */
//const int inf = pow(2, 62);
//const int mod = 1e9 + 7;
const int mod = 100000;
int dx[8]={1,0,-1,0,-1,1,-1,1};
int dy[8]={0,1,0,-1,-1,-1,1,1};



/* io_method */
int input(){int tmp;cin >> tmp;return tmp;}
string raw_input(){string tmp;cin >> tmp;return tmp;}
string readline(){string s;getline(cin, s);return s;}
template<class T> void printx(T n){cout << n;}
template<class T, class U> void printx(pair<T, U> p){cout << "(" << p.first << "," << p.second << ")";}
template<class T> void printx(vector<T> v){cout << "{";rep(i,0,v.size()){printx(v[i]);if(i != v.size()-1)printx(",");}cout << "}";}
template<class T> void print(T n){printx(n);cout << endl;}
template<class T> void print(set<T> s){cout << "{";each(s, e){if(e != s.begin()) printx(",");printx(*e);}cout << "}" << endl;}
template<class T, class U> void print(map<T, U> mp){cout << "{";each(mp, e){cout << "(" << e -> first << "," << e -> second << ")";}cout << "}" << endl;}


/* general_method */
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }




/* main */
int ceil(int a, int b){
    if(a % b == 0) return a /b;
    else return a /b + 1;
}


signed main(){

    cin.tie(0);
    ios::sync_with_stdio(false);

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

    if(a <= c && c <= b){
        print("Yes");
    }else{
        print("No");
    }




    
    



    
    

    







   




    

    

    




    



    



    

 
    
    


    

    
   
    













}






    










    




    










Measured memory_bytes: 384
def main():
    # 下、右、上、左
    dy = (1, 0, -1, 0)
    dx = (0, 1, 0, -1)
    H, W = map(int, input().split())
    s = ["." * (W + 2)]
    s += ["." + input() + "." for i in range(H)]
    s.append("." * (W + 2))
    for y in range(1, H + 1):
        for x in range(1, W + 1):
            if "." == s[y][x]:
                continue
            if "#" == s[y + dy[0]][x + dx[0]]:
                continue
            if "#" == s[y + dy[1]][x + dx[1]]:
                continue
            if "#" == s[y + dy[2]][x + dx[2]]:
                continue
            if "#" == s[y + dy[3]][x + dx[3]]:
                continue
            print("No")
            return
    print("Yes")
    return


main()


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

vector<int> divs[101010];

int main() {
    for (int i = 1; i < 101010; i++) {
        for (int j = 1; i * j < 101010; j++) {
            divs[i * j].push_back(i);
        }
    }

    vector<int> cnt(101010);
    for (int i = 1; i < 101010; i++) {
        if (divs[i].size() > 4) {
            cnt[i] = 1;
        }
        cnt[i] += cnt[i - 1];
    }


    int q;
    cin >> q;
    while (q--) {
        int n;
        cin >> n;
        cout << cnt[n] << endl;
    }
}


Measured memory_bytes: 13524
#include <bits/stdc++.h>
 
using namespace std;
#define ll long long
#define db long double
#define all(a) a.begin(),a.end()
#define pb push_back
#define f(i,l,u) for(ll i=l;i<u;i++)
#define lb lower_bound
#define ub upper_bound
#define pii pair<ll,ll> 
ll fac[200001];
void powe(ll p)
{
     fac[0] = 1; 
    for (int i = 1; i <= 2000001; i++) 
        fac[i] = (fac[i - 1] * i) % p; 
  
}
 
 
        
      long long power( long long x, 
                         ll y, ll p) 
{ 
   long long res = 1; // Initialize result 
  
    x = x % p; 
    while (y > 0) { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res * x) % p; 
  
        // y must be even now 
        y = y >> 1; // y = y/2 
        x = (x * x) % p; 
    } 
    return res; 
} 
  
// Returns n^(-1) mod p 
 long long modInverse( long long n, ll p) 
{ 
    return power(n, p - 2, p); 
} 
  
// Returns nCr % p using Fermat's little 
// theorem. 
 long long nCrModPFermat( long long n, 
                                 ll r, ll p) 
{ 
    // Base case 
    if (r == 0) 
        return 1; 
  
       return (fac[n] * modInverse(fac[r], p) % p * modInverse(fac[n - r], p) % p) % p; 
} 
  
int main() {
    char c; cin>>c; if(c=='a'||c=='e'||c=='i'||c=='o'||c=='u') cout<<"vowel"; else cout<<"consonant";
  

    
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
#define endl '\n'
int main(int argc, char const *argv[])
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(0);
    int a,b;
    cin>>a>>b;
    int socket=1,ans=0;
    while(socket<b)
    {
        socket--;
        socket+=a;
        ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <queue>
using namespace std;

typedef long long ll;

string s;

ll f(int i, ll j, ll k) {
    int val = s[i] - '0';

    ll temp = j*10 + val;

    if (i == s.length() - 1) {
        return temp + k;
    }
    ll sum = 0;
    
    sum += f(i +1, temp, k) + f(i + 1, 0, temp + k);

    return  sum;
}

int main() {

    cin >> s;

    cout << f(0, 0, 0);

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <algorithm>
#include <sstream>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <numeric>
#include <cmath>
#include <climits>
#include <limits>
#include <cfloat>
#include <fstream>
using namespace std;
#define MARU 1
#define BATU -1
int main()
{
//	cut here before submit 
//	freopen("testcase.ttt", "r", stdin);
	
	string str = "";
	while (getline (cin, str ) ){
		if (str.empty() ){
			break;
		} // end if
		vector <vector<int> > b(3, vector <int> (3, 0 ) );
		int i,j; 
		stringstream ss(str);
		for (i = 0; i < 3; ++i){
			for (j = 0; j < 3; ++j){
				char c;
				ss >> c;
				if (c == 'x'){
					b[i][j] = BATU;
				}else if (c == 'o'){
					b[i][j] = MARU;
				} // end if
			} // end for
		} // end for
		int vd = 0;
		int player[2] = {MARU, BATU };

		for (j = 0; j < 2; ++j){
			for (i = 0; i < 3; ++i){
				if ( ( b[i][0] == player[j] && b[i][1] == player[j] && b[i][2] == player[j] )
				||    ( b[0][i] == player[j] && b[1][i] == player[j] && b[2][i] == player[j] )
				||    ( b[i][i] == player[j] && b[(i+1)%3][(i+1)%3] == player[j] && b[(i+2)%3][(i+2)%3] == player[j])
				||    ( b[i][2-i] == player[j] && b[(i+1)%3][2 - ((i+1)%3)] == player[j] && b[(i+2)%3][2 - ((i+2)%3)] == player[j] ) ){
					vd = player[j];
					break;
				} // end if
			} // end for
		} // end for

		switch (vd){
			case MARU:
				cout << 'o' << endl; break;
			case BATU:
				cout << 'x' << endl; break;
			default:
				cout << 'd' << endl; break;
		} // end switch

	} // end loop
		
	return 0;
}

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

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


Measured memory_bytes: 3616
class Combination:
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        self.modinv = self.make_modinv_list(n_max)
        self.fac, self.facinv = self.make_factorial_list(n_max)

    def __call__(self, n, r):
        return self.fac[n] * self.facinv[r] % self.mod * self.facinv[n-r] % self.mod

    def make_factorial_list(self, n):
        # 階乗のリストと階乗のmod逆元のリストを返す O(n)
        # self.make_modinv_list()が先に実行されている必要がある
        fac = [1]
        facinv = [1]
        for i in range(1, n+1):
            fac.append(fac[i-1] * i % self.mod)
            facinv.append(facinv[i-1] * self.modinv[i] % self.mod)
        return fac, facinv

    def make_modinv_list(self, n):
        # 0からnまでのmod逆元のリストを返す O(n)
        modinv = [0] * (n+1)
        modinv[1] = 1
        for i in range(2, n+1):
            modinv[i] = self.mod - self.mod//i * modinv[self.mod%i] % self.mod
        return modinv


x,y = map(int, input().split())

mod = 10**9+7
ans_list = []

x_list = []

for i in range(0, x//2+1):
    x_list.append([i, x-2*i])

for g,l in x_list:
    if (g+2*l)==y:
    	ans_list.append([g,l])

ans=0
A = Combination(10**6, mod)
for g,l in ans_list:
    ans += A(g+l,l)

print(ans)

Measured memory_bytes: 204796
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define LB(c, x) lower_bound(c.begin(), c.end(), x)
#define UB(c, x) upper_bound(c.begin(), c.end(), x)
#define LI(c, x) distance(c.begin(), LB(c, x))
#define UI(c, x) distance(c.begin(), UB(c, x))

// functions
template <class T> T ceil(T a, T b) {
    return (a + b - 1) / b;
}
template <class T> T round(T a, T b) {
    return (a + b / 2) / b;
}
template <class T> T gcd(T a, T b) {
    return b ? gcd(b, a % b) : a;
}
template <class T> T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}
template <class T> bool amax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
ll modpow(ll a, ll b, ll m) {
    if (b == 0) {
        return 1;
    } else if (b % 2 == 0) {
        ll h = modpow(a, b / 2, m);
        return h * h % m;
    } else {
        return a * modpow(a, b - 1, m) % m;
    }
}
ll comb(ll a, ll b, ll m) {
    if (b > a - b) {
        return comb(a, a - b, m);
    }
    ll c = 1, d = 1;
    REP(i, b) {
        c *= (a - i);
        d *= (b - i);
        c %= m;
        d %= m;
    }
    return c * modpow(d, m - 2, m) % m;
}

// main
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<ll> A(N);
    ll sum = 0;
    REP(i, N) {
        cin >> A[i];
        if (i % 2 == 0) {
            sum += A[i];
        } else {
            sum -= A[i];
        }
    }
    vector<ll> res(N, 0);
    res[0] = sum;
    A[0] -= sum / 2;
    A[N - 1] -= sum / 2;
    FOR(i, 1, N, 1) {
        res[i] += A[i - 1] * 2;
        A[i] -= A[i - 1];
    }
    REP(i, N) {
        cout << res[i];
        if (i != N - 1) {
            cout << " ";
        } else {
            cout << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 2944
N = int(input())
time = 0
place = [0, 0]
for i in range(N):
    t, x, y = map(int, input().split())
    dt = t - time
    distance = abs(x-place[0]) + abs(y-place[1])
    if (distance > dt) or ((distance%2) != (dt%2)):
        print('No')
        break
    place = [x, y]
    time = t
else:
    print('Yes')

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

int main () {
  int N, L;
  cin >> N >> L;
  int total = 0;
  for (int i = 0; i < N; i++){
    total += L+i;
  }
  int d_min = 0;
  int i2 = 0;
  for (int i = 0; i < N; i++){
    int d = L+i;
    if (d < 0) d = -d;
    if (i == 0) d_min = d;
    else if (d_min > d) {
      d_min = d;
      i2 = i;
    }
  }
  cout << total-L-i2 << endl; 
}

Measured memory_bytes: 256
N,M=map(int,input().split())
A=[input() for _ in range(N)]
B=[input() for _ in range(M)]
for i in range(N-M+1):
  for j in range(N-M+1):
    flag=1
    for k in range(M):
      if A[i+k][j:j+M]!=B[k]:
        flag=0
    if flag:
      print("Yes")
      exit()
print("No")

Measured memory_bytes: 9228
r, c = map(int,input().split())
a = []
for i in range(r):
    b = list(map(int,input().split()))
    a.append(b)
    a[i].append(sum(a[i]))
a.append([])
    
for j in range(c+1):
    d = 0
    for k in range(r):
        d += a[k][j]
    a[r].append(d)
for i in range(r+1):
    print(' '.join(map(str,a[i])))


Measured memory_bytes: 5704
#include <iostream>
#include<math.h>
#include <algorithm>
#include<string>
using namespace std;

int main() {
        int n;
        int a;
        long long int Ans=0;
        cin>>n;
        for(int i=0; i<n; ++i){
                cin>>a;
                Ans+=a-1;
        }

        cout<<Ans<<endl;
        return 0;
}


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

typedef long long ll;
typedef int64_t in;
using namespace std;
#define INF 1000000007
#define rep(i,n) for(int i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)


int main() {
    int n,x; cin >> n >> x;
    int l[n];
    rep(i,n){
        cin >> l[i];
    }
    int count=1;
    int d=0;
    rep(i,n){
        if(x >= d + l[i]){
            d = d + l[i];
            count++;
        }else{
            break;
        }
    }
    cout << count << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner scn=new Scanner(System.in);
		char ch=scn.next().charAt(0);
		if(ch=='A')System.out.println("T");
		else if(ch=='T')System.out.println("A");
		else if(ch=='C')System.out.println("G");
		else if(ch=='G')System.out.println("C");
	}

}


Measured memory_bytes: 20564
fun main(args: Array<String>) {
    val N = nextInt()
    val S = next()
    val ALPHABET = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
    var ans = ""
    for (c in S) {
        val ch = c - 'A'
        ans += ALPHABET[(ch + N) % 26]
    }
    println("${ans}")
}
fun next() = readLine()!!
fun nextInt(delta: Int = 0) = Integer.parseInt(next()) + delta

Measured memory_bytes: 114324
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll memo[401][401];
vector<ll> a;
vector<ll> sum;
int n;

ll dp(int l,int r){
    if (l == r) return memo[l][r] = 0;
    ll &ans = memo[l][r];
    if (ans != -1) return ans;
    ans = (ll)(1e18);
    for (int k = l; k < r; k++)
        ans = min(ans,dp(l,k) + dp(k + 1,r));
    ans += sum[r] - sum[l - 1];
    return ans;
}

int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin >> n;
    a.resize(n + 1);
    sum.resize(n + 1);
    for (int i = 1; i <= n; i++) cin >> a[i];

    for (int i = 1; i <= n; i++) sum[i] = sum[i - 1] + a[i];
    memset(memo,-1,sizeof(memo));
    cout << dp(1,n);
    return 0;
}

Measured memory_bytes: 1536
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <cstring>
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <list>  
#include <cassert>
#include <ctime>
#include <climits>
using namespace std;  

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
typedef long long ll;
typedef unsigned long long ull;
ll gcd(ll a,ll b) { return b==0?a:gcd(b,a%b); }

const ll LIM=1000000000000000LL;
const int MAXDIG=20;

int d[MAXDIG],nd;

ll make(int sum) {
	int pref=0; REP(i,nd) pref+=d[i];
	for(int i=nd-1;i>=0;--i) {
		pref-=d[i];
		int rem=sum-pref;
		if(d[i]==9||rem<=d[i]||rem>(nd-i)*9) continue;
		int nafter=nd-i-1;
		int x=d[i]+1; rem-=x; while(rem>nafter*9) ++x,--rem;
		ll ret=0; REP(j,i) ret=ret*10+d[j]; ret=ret*10+x; REP(j,nafter) { int cur=max(0,rem-(nafter-j-1)*9); ret=ret*10+cur; rem-=cur; } assert(rem==0);
		return ret;
	}
	for(int dig=nd+1;;++dig) {
		if(dig*9<sum) continue;
		int rem=sum;
		ll ret=0; REP(j,dig) { int cur=max(j==0?1:0,rem-(dig-j-1)*9); ret=ret*10+cur; rem-=cur; } assert(rem==0);
		return ret;
	}
}

ll calc(ll x) {
	nd=0; for(ll i=x;i!=0;i/=10) d[nd++]=i%10; reverse(d,d+nd);
	int sum=0; REP(i,nd) sum+=d[i];
	
	ll ret=LLONG_MAX; int retsum=0;
	FORE(cursum,1,sum+20) {
		ll cur=make(cursum);
		//if(x==1) printf("  %d -> %lld\n",cursum,cur);
		if(ret==LLONG_MAX||1.0*cur*retsum<1.0*ret*cursum||cur*retsum==ret*cursum&&cur<ret) ret=cur,retsum=cursum;
	}
	return ret;
}

void run() {
	ll x=1;
	vector<ll> ans;
	while(x<=LIM) {
		ans.PB(x);
		ll nxt=calc(x);
		//printf("%lld -> %lld\n",x,nxt);
		x=nxt;
	}
	int n; scanf("%d",&n); assert(n<=SZ(ans));
	REP(i,n) printf("%lld\n",ans[i]);
}

void search() {
	double mn=1e200;
	for(int i=100000000;i>=1;--i) {
		ll num=i; int den=0; for(int x=i;x!=0;x/=10) den+=x%10;
		double cur=1.0*num/den; if(cur<=mn) mn=cur,printf("%d (%d)\n",i,den);
	}
}

int main() {
	run();
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a,b;
int main() {
    cin>>a>>b;
    if(a==b) return puts("1"),0;
    swap(a,b);
    int d=0;
    for(int i=59;~i;i--) {
        if((a>>i&1)&&!(b>>i&1)) {
            d=i;
            break;
        }
        if(a>>i&1)
            a^=1ll<<i,b^=1ll<<i;
    }
    int k=-1;
    for(int i=d-1;~i;i--)
        if(a>>i&1) {
            k=i;
            break;
        }
    ll l=b,r=(1ll<<d)+(1ll<<(k+1))-1,ans=r-l+1;
    ll x=(1ll<<d)+b,y=(1ll<<(d+1))-1;
    if(x>r) ans+=y-x+1;
    else if(y>r) ans+=y-r;
    printf("%lld\n",ans);
    return 0;
}


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

#define rep(i,n) for(int i=0; i<n ; ++i)
#define REP(i,a,b) for(int i=a; i<b; ++i)
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using pii = pair<int , int>;
using pll = pair<long long , long long>;

//プロトタイプ宣言
void faster(void);
template <class T>
T gcd(T , T);
template <class T>
T get_digent(T);
template <class T>
T POW(T , T);



int main(){
  faster();
  string s,t,u;
  int a,b;
  cin >> s >> t >> a >> b >> u;
  if(u==s) cout << a-1 << " "<< b << endl;
  else cout << a << " " <<  b-1 << endl; 
}



























//同期解除
void faster(void){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
}

//ユークリッドの互除法
template <class T>
T gcd(T a, T b) {
  return (b ? gcd(b, a%b) : a);
} 

//桁数取得
template <class T>
T get_digent(auto x){
  string s;
  s = to_string(x);
  ll digent = s.size();
  return digent;
} 

//べき乗計算
template <class T>
T POW(T x, T y){
  if(y==0) return 1;
  if(y%2 == 1){
    ll temp = POW(x,y-1);
    return (temp*x);
  }
  else{
    ll temp = POW(x,y/2);
    return temp*temp;
  }
} 



Measured memory_bytes: 256
#include <iostream>
#include <string>

bool is_good_num(int a) {
  int b = a % 10;
  a /= 10;
  int c = a % 10;
  a /= 10;
  int d = a % 10;
  a /= 10;
  int e = a % 10;
  return (c == d and (d == e || b == c));
}

int main(void) {
  int a;
  std::cin >> a;
  std::string out = "No";
  if(is_good_num(a)) {
    out = "Yes";
  }

  std::cout << out << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cstring>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <cmath>
#include <locale>
#include <random>
#include <cassert>
#include <sstream>
using namespace std;
#define F first
#define S second
#define pb push_back
#define MP make_pair
#define ALL(x) begin(x), end(x)
#define SZ(x) (int)(x).size()
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
#define ln(i, n) " \n"[i == n]
typedef long long LL;
typedef long double LDB;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
//////////////////////
const long double eps = 1e-13;
const long double PI = acos(-1);
const int INF = (int)1e9;
const LL  INFF = (LL)1e15;
const int mod = 998244353;
const int MXN = (int)1e6 + 7;
struct node{
	int u, v, c;
	node(){};
	node (int _u, int _v, int _c) :
		u(_u), v(_v), c(_c) {}
	const bool operator <(const node &p2) const{
		return c < p2.c;
	}
};
vector<int> mem[MXN];
int siz[MXN], gp[MXN];
LL sum[MXN];
int fd(int v){ return gp[v] == v ? v : gp[v] = fd(gp[v]); }
void uni(int u, int v) {
	u = fd(u);
	v = fd(v);
	if (u == v) return ;
	if (siz[u] > siz[v]) swap(u, v);
	for (int x : mem[u]) {
		gp[x] = v;
		mem[v].pb(x);
	}
	siz[v] += siz[u];
	sum[v] += sum[u];
}
bool ck[MXN];
PII rec[MXN];
node edge[MXN];
int main(){
	int n, m; scanf("%d %d", &n, &m);
	for (int i = 1; i <= n; i++) {
		scanf("%lld", sum + i);
		siz[i] = 1, gp[i] = i;
		mem[i].pb(i);
	}
	for (int i = 1; i <= m; i++) {
		int u, v, c;
		scanf("%d %d %d", &u, &v, &c);
		edge[i] = node(u, v, c);
	}
	sort(edge + 1, edge + m + 1);
	for (int i = 1; i <= m; i++) {
		int u = edge[i].u, v = edge[i].v;
		if (fd(u) == fd(v)) continue;
		rec[i] = MP(fd(u), fd(v));
		uni(u, v);
		ck[i] = 1;
	}
	int ans = 0;
	for (int i = m; i >= 1; i--) {
		int u = edge[i].u, v = edge[i].v;
		assert( fd(u) == fd(v) );
		if (sum[ fd(u) ] >= edge[i].c) continue;
		ans++;
		if (!ck[i]) continue;
		tie(u, v) = rec[i];
		if (sum[u] > sum[v]) swap(u, v);
		sum[v] -= sum[u];
		siz[v] -= siz[u];
		mem[v].resize(siz[v]);
		for (int x : mem[u])
			gp[x] = u;
	}
	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 46720
using System;
class Program
{    static void Main(String[] args){
  
    string[] str = Console.ReadLine().Split(' ');
    int a = int.Parse(str[0]);
    int b = int.Parse(str[1]);
    if (a%b==0){
        Console.WriteLine("0");
        }else {
            Console.WriteLine("1");
        }
    }
}


Measured memory_bytes: 13140
INF = float('inf')
from collections import defaultdict
from heapq import heappop, heappush

class Graph(object):

    def __init__(self):
        self.graph = defaultdict(list)

    def __len__(self):
        return len(self.graph)

    def add_edge(self, From, To, cost=1):
        self.graph[From].append((To,cost))

    def get_nodes(self):
        return self.graph.keys()

class Dijkstra(object):

    def __init__(self, graph, start):
        self.g = graph.graph
        self.dist = defaultdict(lambda:INF)
        self.dist[start] = 0
        self.prev = defaultdict(lambda: None)
        self.Q = []
        heappush(self.Q,(self.dist[start], start))

        while  self.Q:
            dist_u, u = heappop(self.Q)
            if self.dist[u] < dist_u:
                continue
            for v, cost in self.g[u]:
                alt = dist_u + cost
                if self.dist[v] > alt:
                    self.dist[v] = alt
                    self.prev[v] = u
                    heappush(self.Q,(alt, v))

    def shortest_distance(self, goal):
        return self.dist[goal]

    def shortest_path(self, goal):
        path = []
        node = goal
        while node is not None:
            path.append(node)
            node = self.prev[node]

        return path[::-1]

N, M = map(int,input().split())
g = Graph()

for i in range(M):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    g.add_edge(a,b)
    g.add_edge(a,b+N)
    g.add_edge(a+N,b)

ans = INF
j = -1

for i in range(N):
    d = Dijkstra(g,i).dist
    if d[i+N] < ans:
        ans = int(d[i+N])
        j = i

if ans != INF:
    path = Dijkstra(g,j).shortest_path(j+N)[:-1]
    print(ans)
    for node in path:
        print(node+1)
else:
    print(-1)

Measured memory_bytes: 140552
#include<bits/stdc++.h>
#define L long long
using namespace std;
const int q=1000000007;
int n,x,y,a[200010],b[200010],w[200010],u,v,r,f[200010],g,c[200010],d[200010],p;
int main()
{
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	int i;
	scanf("%d%d%d",&n,&x,&y);
	c[0]=1;
	u=2e9;
	for(i=1;i<=n;i++)
	  {
	   c[i]=(L)c[i-1]*i%q;
	   w[i]=2e9;
      }
    d[0]=d[1]=1;
    for(i=2;i<=n;i++)
      d[i]=q-(L)q/i*d[q%i]%q;
    for(i=2;i<=n;i++)
      d[i]=(L)d[i]*d[i-1]%q;
	for(i=1;i<=n;i++)
	  {
	   scanf("%d%d",&a[i],&b[i]);
	   if(b[i]<u)
	     r=u,u=b[i],v=a[i];
	   else
	     r=min(r,b[i]);
	   w[a[i]]=min(w[a[i]],b[i]);
      }
    for(i=1;i<=n;i++)
      if(b[i]+w[a[i]]<=x && w[a[i]]+u<=y || a[i]!=v && b[i]+u<=y || b[i]+r<=y)
        {
         f[a[i]]++;
         g++;
        }
    p=c[g];
    for(i=1;i<=n;i++)
      p=(L)p*d[f[i]]%q;
    printf("%d\n",p);
	return 0;
}


Measured memory_bytes: 4992
#include<iostream>
using namespace std;
char map1[55][55];
int c=0,n,w,h,k[11],map2[55][55]={};
 
void t(int,int,int);
void e(int,int,int);
void dfs(int,int);
  
int main(){
  int d,x1,y1,cnt=0;
  cin>>h>>w>>d>>n;
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      cin>>map1[i][j];
      if(map1[i][j]=='D')x1=j,y1=i;
    }
  }
  for(int i=0;i<d;i++)cin>>k[i];
  for(int i=0;i<n;i++){
    int x,y,s;
    cin>>x>>y>>s;
    if(s==0)t(x,y,k[s]);
    else if(s==d){
      for(int j=0;j<h;j++)
        for(int l=0;l<w;l++)
          map2[j][l]++;
      e(x,y,k[s-1]);
    }else t(x,y,k[s]),e(x,y,k[s-1]);
  }
  for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
      if(map2[i][j]==n&&map1[i][j]!='#')cnt++;
    }
  }
  if(cnt>=1){
    cnt=0;
    dfs(x1,y1);
    if(c>0){
      for(int i=0;i<h;i++){
	for(int j=0;j<w;j++){
	  if(map2[i][j]==n&&map1[i][j]!='#')cnt++;
	}
      }
      if(cnt==0)cout<<"Yes"<<endl;
      else cout<<"Unknown"<<endl;
    }
    else cout<<"No"<<endl;
  }else cout<<"Broken"<<endl;
  return 0;
}

void t(int x,int y,int k){
  for(int i=0;i<=2*k;i++){
    for(int j=0;j<=2*k;j++){
      int a=y-k+i,b=x-k+j;
      if(a>=0&&a<h&&b>=0&&b<w)
        map2[a][b]++;
    }
  }
}
 
void e(int x,int y,int k){
  for(int i=0;i<=2*k;i++){
    for(int j=0;j<=2*k;j++){
      int a=y-k+i,b=x-k+j;
      if(a>=0&&a<h&&b>=0&&b<w)
        map2[a][b]--;
    }
  }
}
 
void dfs(int x,int y){
  if(x<0||x>=w||y<0||y>=h||map1[y][x]=='#'||map2[y][x]==-1)return;
  if(map2[y][x]==n)c++;
  map2[y][x]=-1;
  dfs(x+1,y),dfs(x-1,y),dfs(x,y-1),dfs(x,y+1);
}
 

Measured memory_bytes: 3148
import java.util.*;

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

    char[][] A = new char[N][N];
    for (int i = 0; i < N; i++) {
      String s = sc.next();
      for (int j = 0; j < N; j++) {
        A[i][j] = s.charAt(j);
      }
    }
    
    char[][] B = new char[M][M];
    for (int i = 0; i < M; i++) {
      String s = sc.next();
      for (int j = 0; j < M; j++) {
        B[i][j] = s.charAt(j);
      }
    }
    
    boolean ans = false;
    for (int i = 0; i <= N-M; i++) {
      for (int j = 0; j <= N-M; j++) {
        if (match(A, B, i, j)) {
          ans = true;
          break;
        }
      }
    }
    
    System.out.println(ans ? "Yes" : "No");
  }
  
  private static boolean match(char[][] A, char[][] B, int i, int j) {
    for (int m = 0; m < B.length; m++) {
      for (int n = 0; n < B[m].length; n++) {
        if (A[i+m][j+n] != B[m][n]) {
          return false;
        }
      }
    }
    return true;
  }
}

Measured memory_bytes: 21844
n,k=map(int,input('').split(' '))
a=input('')
a=a.split(' ')
o=[]
l=[]
for p in range(n):
    a[p]=int(a[p])
    o.append(0)
    l.append('n')

p=1
h=[]
h.append(1)
j=k
aj=0
while j>0:
    p=a[p-1]
    o[p-1]+=1
    if o[p-1]>=2:
        j=j-1
        c=len(h)-l[p-1]#h.index(p)
        j=j%c

    else:
        h.append(p)
        j=j-1
    
        aj+=1
    
    l[p-1]=aj

print(p)

Measured memory_bytes: 29668
void main() {
  problem();
}

void problem() {
  auto S = scan;
  auto T = scan;

  long solve() {
    long ans;
    foreach(i; 0..S.length) {
      if (S[i] != T[i]) ans++;
    }
    return ans;
  }

  solve().writeln;
}

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

import std.stdio, std.conv, std.array, std.string, std.algorithm, std.container, std.range, core.stdc.stdlib, std.math, std.typecons, std.numeric;
T[][] combinations(T)(T[] s, in int m) {   if (!m) return [[]];   if (s.empty) return [];   return s[1 .. $].combinations(m - 1).map!(x => s[0] ~ x).array ~ s[1 .. $].combinations(m); }
string scan(){ static string[] ss; while(!ss.length) ss = readln.chomp.split; string res = ss[0]; ss.popFront; return res; }
T scan(T)(){ return scan.to!T; }
T[] scan(T)(int n){ return n.iota.map!(i => scan!T()).array; }
void deb(T ...)(T t){ debug writeln(t); }
alias Point = Tuple!(long, "x", long, "y");

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


Measured memory_bytes: 3324
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctime>
#include <cmath>
#include <string>
#include <stdlib.h>
#include <fstream>
#include <set>
#include <map>
#include <stack>
#include <deque>
#include <iterator>
using namespace std;


int main(){
    long long n, p;
    cin >> n >> p;
    cout << (n >= 10? p: p + 100 * (10 - n));
}

Measured memory_bytes: 256
while True:
    n,x = map(int, input().split())
    if n == 0 and x == 0:
        break
    if x <= 2:
        print(0)
    else:
        ans = 0
        for i in range(1, n-1):
            for j in range(i+1, n):
                if j < x-(i+j) <= n:
                    ans += 1
        print(ans)


Measured memory_bytes: 5588
N = int(input())
D = [list(map(int, input().split())) for _ in range(N)]

flag = 0
for i in range(N-2):
    if D[i][0] == D[i][1] and D[i+1][0] == D[i+1][1] and D[i+2][0] == D[i+2][1]:
        flag = 1
if flag:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9192
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#define int long long
#define mod 1000000007
#define for0(i, n) for(int i = 0; i < (n); i++)
#define for1(i, n) for(int i = 1; i <= (n);i++)
using namespace std;
int d, n, m, ans=0;
int p[123456];
signed main() {
	while(cin>>d, d){
		cin>>n>>m;
		p[0]=0;ans=0;
		for1(i,n-1)cin>>p[i];
		sort(p,p+n);
		p[n]=d;
		for0(i,m){
			int k;cin>>k;
			int l=0,r=n;
			while(r-l>1){
				int mid=(r+l)/2;
				if(p[mid]<k)l=mid;
				else r=mid;
			}
			ans+=min(p[r]-k,k-p[l]);
		}
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 3832
#include<bits/stdc++.h>
using namespace std;
const int mod = 1000000007;
#define rep(i, n) for(int i = 0; i < (n); i++)

int int_len(int n) {
  int s=0;
  while(n!=0) s++, n/=10;
  return s;
}

int int_sum(int n) {
  int m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(int i=s-1;i>=0;i--) m+=n/((int)pow(10,i))-(n/((int)pow(10,i+1)))*10;
  return m;
}






int gcd(int a,int b)
{
 
  int r, tmp;
 
  
 
  /* 自然数 a > b を確認・入替 */
  if(a<b){
    tmp = a;
    a = b;
    b = tmp;
  }
 
  /* ユークリッドの互除法 */
  r = a % b;
  while(r!=0){
    a = b;
    b = r;
    r = a % b;
  }
 
 
 
  return b;
}







int fac(int n){
  int m=1;
  while(n>=1) m*=n,n--;
  return m;
}

int vec_sum(vector<int> v){
  int n=0;
  for(int i=0;i<v.size();i++) n+=v[i];
  return n;
}
///////////////////////////
int main() {
  int x,y,z,i=0,ans,ans1;
  cin>>x>>y>>z;
  while(ans<=x){
    ans1=i;
    ans=i*y+(i+1)*z;
    i++;
  }
  cout<<ans1-1<<endl;
}
///////////////////////////





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

int E;

void solve(){
    while(cin >> E && E > 0){
        int x,y,z;
        int X,Y,Z;
        int min = 100000;
        for (z = 0; z*z*z <= E; z++){
            for (y = 0; y*y + z*z*z <= E;y++){
                x = E - y*y - z*z*z;
                if (min > x + y + z){
                    min = x + y + z;
                }
            }
        }
        cout << min << endl;
    }
}

int main(){
    solve();
}



Measured memory_bytes: 3000
#include <iostream>
using std::cin;
using std::cout;
using std::endl;

int main()
{
	int h, w, i, j;
	while (true)
	{
		cin >> h >> w;
		if (h == 0 && w == 0) break;
		for (i = 0; i < h; i++ )
		{
			for (j = 0; j < w; j++)
				cout << "#";
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 1152
# coding: utf-8

import sys
input = sys.stdin.readline

def f2(N, s):
    MOD = int(1e9 + 7)
    dp = [1] * N
    for i in range(1, N):
        csum = list(dp)
        for j in range(1, N - i + 1):
            csum[j] += csum[j - 1]
            csum[j] %= MOD
        csum_ = csum[N - i]
        i_ = i - 1
        for j in range(N - i):  # N-(i+1)+1 = N-i
            dp[j] = csum[j] if s[i_] == ">" else \
                (csum_ - csum[j] + MOD) % MOD
    return(dp[0])

N = int(input()) # 2 <= N <= 30000
s = input().rstrip() # len(s) = N - 1
print(f2(N, s))


Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define ALL(c) (c).begin(), (c).end()
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    int k,x;
    cin >> k >> x;
    if (500 * k >= x) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    
}




Measured memory_bytes: 256