akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<string>
#include<string.h>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<vector>
#include<utility>
#include<stack>
#include<queue>
#include<list>
#include<bitset>

#define FOR(i, a, b) for(int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for(int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000

using namespace std;
bool dp[9][9];

int dfs(int st, int n, bool visited[]) {
	bool all_visited = false;
	int ret = 0;
	visited[st] = true;

	FOR(i, 1, n) {
		if (visited[i] == false) {
			break;
		}
		if (i == n) {
			all_visited = true;
		}
	}

	if (all_visited == true) {
		visited[st] = false;
		return 1;
	}

	FOR(i, 1, n) {
		if (visited[i] == false && dp[st][i] == true) {
			ret+=dfs(i, n, visited);
		}
	}

	if (all_visited == true) {
		ret++;
	}
	visited[st] = false;
	return ret;
	

	
}

int main(void) {
	int n, m;

	cin >> n >> m;

	FOR(i, 0, 8) {
		FOR(t, 0, 8) {
			dp[i][t] = false;
		}
	}
	FOR(i, 1, m) {
		int a, b;
		cin >> a >> b;
		dp[a][b] = dp[b][a] = true;
	}
	
	bool visited[9];
	FOR(i, 0, 8) {
		visited[i] = false;
	}


	cout << dfs(1, n, visited) << endl;

	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define _USE_MATH_DEFINES
#include <math.h>
#define rep(i,n) for(int i = 0;i < n;i++)
#define NIL = -1;

int digit(ll x) {
    if (x / 10 == 0) return 1;
    return digit(x / 10) + 1;
}

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

ll lcm(ll a,ll b){
    a / gcd(a,b) * b;
}
const ll mod = 1e9 + 7;
const ll INF = 1e9 + 7;

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


/////////////////////////////////////////////////////////////////////////////////////////

int main(){
    int a,b,m;
    cin >> a >> b >> m;
    vector<ll> A(a),B(b),x(m),y(m),c(m);
    ll ans = INF;
    for(int i = 0;i < a;i++) cin >> A[i];
    for (int i = 0;i < b;i++) cin >> B[i];
    for (int i = 0;i < m;i++) {
        cin >> x[i] >> y[i] >> c[i];
        x[i]--; y[i]--;
        ans = min(ans,A[x[i]] + B[y[i]] - c[i]);
    }

    sort(A.begin(),A.end());
    sort(B.begin(),B.end());

    ans = min(ans,A[0]+B[0]);

    cout << ans << endl;


}

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

int main(void){
    long a, b, c, x, y;
    cin >> a >> b >> c >> x >> y;
    long ymin = a*x+b*y;
    for(long i=0; i<=max(x,y); i++){
        long yen = a*max(x-i, 0l)+b*max(y-i, 0l)+c*2*i;
        ymin = min(ymin, yen);
    }
    cout << ymin << endl;
    return 0;
}


Measured memory_bytes: 256
import math
A,B,H,M = list(map(int,input().split()))
H_Angle = (H/12 + M/(12*60)) * 360
M_Angle = M/60 * 360
HM_Angle = abs(H_Angle - M_Angle)
Cos = math.cos(math.radians(HM_Angle))
LL = A**2 + B**2 - 2*A*B*Cos
L= math.sqrt(LL)
print(L)

Measured memory_bytes: 9504
import java.util.Arrays;
import java.util.Scanner;

public class Main{
		public static void main(String[] args) {
	                Scanner scanner = new Scanner(System.in);
	                int num = scanner.nextInt();
	                long sum = 0;
	                if (num > 0 && num <= 10000) {
	                        long array[] = new long[num];
	                        for (int i = 0; i < num; i++) {
	                                array[i] = scanner.nextLong();
	                                if (array[i] >= -1000000 && array[i] <= 1000000) {
	                                        sum += array[i];
	                                }
	                                }
	Arrays.sort(array);

	                        System.out.println(array[0] + " " + array[num - 1] + " " + sum);

	                }

		}
}

Measured memory_bytes: 41740
#include <bits/stdc++.h>
#include <vector>
#include <string>
using namespace std;
#define FL(i,a,b) for(int i = a;i<b;i++)
typedef vector<int> vi;

const int inf = numeric_limits<int>::max();


int main(){   
    int h,w;
    cin>>h>>w;
    char ip[h][w];
    unsigned long int ans[h+1][w+1] = { };
    unsigned long int m = 1000000007;
    FL(i,0,h){
        FL(j,0,w){
            cin>>ip[i][j];
        }
    }
    ans[1][1] = 1;
    FL(i,1,h+1){
        FL(j,1,w+1){
            if(ip[i-1][j-1]=='#'){
                ans[i][j] = 0;
            }
            else if(i==1 && j==1){
                continue;
            }
            else{
                ans[i][j] = (ans[i-1][j] + ans[i][j-1])%m;
            }
        }
    }
   /* FL(i,0,h+1){
        FL(j,0,w+1){
            cout<<ans[i][j]<<" ";
        }
        cout<<"\n";
    }*/
    cout<<(ans[h][w])%m;

}

















Measured memory_bytes: 9088
n, k = map(int, input().split())
s = input() + '#'

num = [0]
for i in range(1, n + 1):
    if s[i - 1] != s[i]:
        num.append(i)

ans, lennum = num[1], len(num)
for i in range((s[0] == '1') + 1, lennum, 2):
    r, l = max(i - 2, 0), min(i + 2 * k, lennum) - 1
    ans = max(ans, num[l] - num[r])
print(ans)


Measured memory_bytes: 78828
import numpy as np

ST=np.array(input().split(" "))
S=ST[0]
T=ST[1]
AB=np.array(input().split(" "),dtype=np.int32)
A=AB[0]
B=AB[1]
U=input()

if(S==U):
    A=A-1
elif(T==U):
    B=B-1

result="{} {}".format(A,B)
print(result)

Measured memory_bytes: 21400
#include <bits/stdc++.h>
using namespace std;
#define MOD 998244353
#define MAX 100000
#define INF 1000000000
using ll=long long;

int n=1;
vector<int> tree;

void update(int i,int x){
  tree[i+n-1]=max(x,tree[i+n-1]);
  int k=i+n-1;
  while(k>0){
    k=(k-1)/2;
    tree[k]=max(tree[2*k+1],tree[2*k+2]);
  }
}

int solve(int a,int b,int i,int left,int right){
  if(b<=left||right<=a){
    return 0;
  }
  if(a<=left&&right<=b){
    return tree[i];
  }
  int x=solve(a,b,2*i+1,left,(left+right)/2);
  int y=solve(a,b,2*i+2,(left+right)/2,right);
  return max(x,y);
}

int main(){
  int N,K;
  cin>>N>>K;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }

  while(n<300000+1){
    n<<=1;
  }
  tree.resize(2*n-1,0);


  vector<int> length(N,0);
  for(int i=0;i<N;i++){
    int x=solve(max(0,A[i]-K),min(A[i]+K,300000)+1,0,0,n);
    length[i]=x+1;
    update(A[i],length[i]);
  }

  int ans=0;
  for(int i=0;i<N;i++){
    ans=max(ans,length[i]);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 9596
#include <bits/stdc++.h>
using namespace std;
int main() {
 int n,m,counter,subcounter;
 string strn,strm;
 cin >> n;
 subcounter = 0;
 vector<string> vecn(0);
 vector<string> vecm(0);
 for (int i = 0; i < n; i++) {
   cin >> strn;
   vecn.push_back(strn);
 }
 cin >> m;
 for (int i = 0; i < m; i++) {
   cin >> strm;
   vecm.push_back(strm);
 }
 for (int i = 0; i < n; i++) {
   counter = 0;
   for (int j = 0; j < n; j++) {
     if  (vecn.at(i) == vecn.at(j)) {
       counter++;
     }
   }
   for (int j = 0; j < m; j++) {
     if (vecn.at(i) == vecm.at(j)) {
       counter = counter -1;
     }
   }
   if (counter > subcounter) {
     subcounter = counter;
   }
 }
 if (subcounter <= 0 ) {
   subcounter = 0;
 }
 
 cout << subcounter;
}


Measured memory_bytes: 3648
s = input()

MOD = 2019
#0を2019個のリスト
d = [0] * MOD
d[0]=1
r=0
t=1
#大きい順から
for i in reversed(s):
    r += int(i)*t
    r %= MOD
    t *= 10
    t %= MOD
    d[r] += 1

print(sum(i*(i-1)//2 for i in d))

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

int main()
{
  int A,B,C;
  cin>>A>>B>>C;
  cout<< min(C,B/A) <<endl;
}

Measured memory_bytes: 256
// @gaurav_512
#include<bits/stdc++.h>
using namespace std;
 
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<pii> vii;
typedef unordered_map<int,int> umii;
typedef unordered_map<ll,ll> umll;
 
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define bs(v,val) binary_search(v.begin(),v.end(),val)
#define mod 1e9+7
#define ff first
#define ss second
#define fi(n) for(int i=0;i<n;i++)
#define fj(n) for(int j=0;j<n;j++)
#define all(v) v.begin(),v.end()
#define pb push_back
#define m_p make_pair
#define endl '\n'
 
ll power(ll x, ll y, ll p)
{  
    ll res = 1;
    x = x % p;  
    if (x == 0) return 0;
    while (y > 0){  
        if (y & 1)  res = (res*x) % p;  
        y = y>>1;
        x = (x*x) % p;  
    }  
    return res;  
}
ll modInverse(ll n, ll p)
{
    return power(n, p-2, p); 
}
// ********** CODE STARTS HERE ****************//
 
 
void solve()
{
	int n, W;
	cin>>n>>W;
	vi w(n), v(n);
	fi(n)cin>>w[i]>>v[i];
	vector<vector<ll>>dp(n+1,vector<ll>(W+1,0));
	
	for(int i=1; i<=n; i++)
	{
		for(int j=1; j<=W; j++)
		{
			dp[i][j] = dp[i-1][j];
			if(w[i-1] > j)
				continue;
			dp[i][j] = max(dp[i][j], v[i-1] + dp[i-1][j-w[i-1]]);
		}
	}
//	for(int i=1;i<=n;i++)
//	{
//		for(int j=1;j<=W;j++)
//			cout<<dp[i][j]<<' ';
//		cout<<endl;
//	}
	cout<<dp[n][W];
}
 
int main()
{
	fastio;
    int T;
//    cin>>T;
//    while(T--)
        solve();
	return 0;
}

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

const long long int mod = 1000000007;
const long long int big = 2999999999999999999;
const long long int small = -2999999999999999999;
#define ll long long int 
#define pb(a) push_back(a)
#define vll vector<long long int>
#define loop(i, n) for(long long int i=1;i<=n;i++)
#define loop0(i, n) for(long long int i=0;i<n;i++)
#define in(i) scanf("%lld", &i);
#define out(i) printf("%lld", i)

ll n;
vll adjacencyList[100001];
ll dp[100001][2];

void in2(ll& a, ll& b)
{
  in(a);
  in(b);
}
void in3(ll& a, ll& b, ll& c)
{
  in(a);
  in(b);
  in(c);
}

ll solve(ll p, ll node, int color)
{
  if(node>n)
    return 0;
  if(dp[node][color]!=-1)
    return dp[node][color];
  ll ans=1;
  if(color)
  {
    for(ll elem:adjacencyList[node])
    {
      if(elem!=p)
        ans=(ans%mod*(solve(node, elem, 1)+solve(node, elem, 0))%mod)%mod;
    }
  }
  else
  {
    for(ll elem: adjacencyList[node])
    {
      if(elem!=p)
        ans=(ans%mod*solve(node, elem, 1)%mod)%mod;
    }
  }
  return dp[node][color]=ans%mod;
}
int main()
{
  memset(dp, -1, sizeof(dp));
  in(n);
  ll u, v;
  loop(i, n-1)
  {
    in2(u, v);
    adjacencyList[u].pb(v);
    adjacencyList[v].pb(u);
  }
  ll ans = (solve(0, 1, 0)%mod + solve(0, 1, 1)%mod)%mod;
  cout<<ans<<"\n";
}

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
   bool flg=false;
   vector<ll>d(5);
    for (int i = 0; i < 5; ++i) {
        cin >>d[i];
    }
    ll k;cin >>k;
    if(d[4]-d[0]>k)flg=true;
    if(flg)puts(":(");
    else puts("Yay!");
   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 REP2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(n) begin(n),end(n)
#define sz(x) int(x.size())
using ll = long long;
using P = pair<int,int>;
const ll LLINF = numeric_limits<long long>::max();
const int mod = 1000000007;
const int INF = 1001001001;

int main()
{
    
    char a;
    cin >> a;

    if(a>='A'&& a<='Z'){
       cout << "A"; 
    }
    else cout << "a";


    return 0;
}

Measured memory_bytes: 3628
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <climits>
#include <cstring>

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define all(c) begin(c),end(c)

template<typename T1, typename T2>
inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }

template<typename T1, typename T2>
inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }

//改造
typedef long long int ll;
using ll = long long int;
using ull = long long unsigned int;
using Int = long long int;
using namespace std;
#define INF (1 << 30) - 1
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007


//ここから編集する
class Solve {
public:

    int N, Q;

    vector<vector<int>> tree;
    vector<Int> val;

    void dfs(int v, Int a = 0, int p = -1) {
        val[v] += a;
        for (auto e : tree[v]) {
            if (e != p) {
                dfs(e, val[v], v);
            }
        }
    }

    void solve() {
        cin >> N >> Q;
        tree.resize(N);
        val.resize(N);

        for (int i = 0; i + 1 < N; ++i) {
            int a, b;
            cin >> a >> b;
            a--, b--;
            tree[a].push_back(b);
            tree[b].push_back(a);
        }

        for (int j = 0; j < Q; ++j) {
            int p;
            Int x;
            cin >> p >> x;
            p--;
            val[p] += x;
        }

        dfs(0);

        for (int i = 0; i < N; ++i) {
            cout << val[i] << " ";
        }
        cout << endl;

    }
};


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    Solve().solve();


    return 0;
}


Measured memory_bytes: 21120
//In the name of God

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

typedef long long ll;
typedef pair <int , int> pii;

const int N = 1e5+10 , mod = 1e9+7;

vector <int> g[N];
int n , m , dpd[N][2][2] , dpu[N][2][2];

void dfsd(int v , int p){
   dpd[v][1][1] = 1;
   for(int u : g[v]){
      if(u != p){
         dfsd(u , v);
         (dpd[v][1][0] += (dpd[u][1][1] + dpd[u][1][0]) % m) %= m;
         dpd[v][1][1] = 1ll * dpd[v][1][1] * (dpd[u][1][1] + 1) % m;
      }
   }
}

void dfsu(int v , int p){
   dpu[v][1][1]++;
   dpu[v][1][1] %= m;
   int nw = 1;
   for(int u : g[v])
      if(u != p)
         dpu[u][1][1] = dpu[v][1][1];
   for(int u : g[v]){
      if(u != p){
         dpu[u][1][1] = 1ll * dpu[u][1][1] * nw % m;
         nw = 1ll * nw * (dpd[u][1][1] + 1) % m;
      }
   }
   nw = 1;
   reverse(g[v].begin() , g[v].end());
   for(int u : g[v]){
      if(u != p){
         dpu[u][1][1] = 1ll * nw * dpu[u][1][1] % m;
         nw = 1ll * nw * (dpd[u][1][1] + 1) % m;
         dfsu(u , v);
      }
   }
}

int32_t main(){
   ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
   cin >> n >> m;
   for(int i = 0 ; i < n - 1 ; i++){
      int u , v;
      cin >> u >> v;
      u--; v--;
      g[u].push_back(v);
      g[v].push_back(u);
   }
   dfsd(0 , 0);
   dfsu(0 , 0);
   for(int i = 0 ; i < n ; i++){
      //cout << dpd[i][1][1] << " " << dpu[i][1][1] << endl;
      cout << 1ll * dpd[i][1][1] * dpu[i][1][1] % m << "\n";
   }
   return 0;
}


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


typedef long long ll;
int main() {
  string S;
  vector<int>count(4,0);
  cin>>S;
  for(int i=0;i<4;i++){
    char x=S.at(i);
    for(int j=0;j<4;j++){
        if(x==S.at(j))count.at(i)++;
    }
  }

  string ret="No";

  if(count.at(0)==2&&count.at(1)==2&&count.at(2)==2&&count.at(3)==2)ret="Yes";

  cout<<ret<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <string>
#include <iomanip>
#include <math.h>
#include <limits>

using namespace std;

typedef unsigned long long ullong;

class cgl
{
public:
	ullong gcd(ullong, ullong);
	ullong lcm(ullong, ullong, ullong);
};

ullong cgl::gcd(ullong a, ullong b)
{
	if (a % b == 0)
		return b;
	return gcd(b, a % b);
}

ullong cgl::lcm(ullong a, ullong b, ullong g)
{
	return a * b / g;
}

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

	cgl cg;
	ullong a, b, g;

	for (;;)
	{
		cin >> a >> b;
		if (cin.fail()) break;
		g = cg.gcd(a, b);
		cout << g << " " << cg.lcm(a, b, g) << endl;
	}

	return 0;
}

Measured memory_bytes: 3004
#include <bits/stdc++.h>
using namespace std;
#define D 1000000007
int main(void)
{
    //入力、定義
    int N;
    cin >> N;
    string S1;
    string S2;
    cin >> S1 >> S2;
    long long int ans;

    vector<int> A;

    //計算
    for( int i = 0; i < N; i++){
        if( S1[i] == S2[i] ){
            A.push_back(1);
        }else{
            A.push_back(2);
            i++;
        }
    }

    //最初の塗り分けパターン
    if( A[0] == 1 ){
        ans = 3;
    }else{
        ans = 6;
    }

    //それ以降の塗り分けパターン
    for ( int i = 1; i < A.size(); i++){
        if( A[i-1]  == 1 && A [i] == 1 ){
            ans = ans * 2 % D;
        }else if( A[i-1]  == 1 && A [i] == 2 ){
            ans = ans * 2 % D;
        }else if( A[i-1]  == 2 && A [i] == 1 ){
            ans = ans * 1 % D;
        }else if( A[i-1]  == 2 && A [i] == 2 ){
            ans = ans * 3 % D;
        }
    }

    //出力
    cout << ans;
    return 0;
}

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

int main()
{
  int a, b, ans;
  char op;
  
  for (int i = 0; i < 10000; i++) {
    cin >> a >> op >> b;

    if (op == '?') break;
    if (op == '+') ans = a + b;
    else if (op == '-') ans = a - b;
    else if (op == '*') ans = a * b;
    else if (op == '/') ans = a / b;

    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 3080
#include <iostream>
#include <string.h>
using namespace std;
int getV(int n){
	char N[10];
	sprintf(N,"%d",n);
	int len=strlen(N);
	int s=0;
	for (int i=0;i<len;i++){
		s+=N[i]-'0';
	}
	return s;

}
int main(int argc, char* argv[])
{
	int N;
	int A,B;
	cin>>N>>A>>B;
	int i;
	int aw=0;
	for (i=1;i<=N;i++){
		int x=getV(i);
		if (x>=A && x<=B){
			aw+=i;
		}
	}
	cout<<aw<<endl;

	return 0;
}

Measured memory_bytes: 256
using System;

namespace A___Remaining_Balls
{
    class Program
    {
        static void Main (string[] args)
        {
            var input = Console.ReadLine ().Split (' ');
            var s = input[0];
            var t = input[1];
            input = Console.ReadLine ().Split (' ');
            var a = int.Parse (input[0]);
            var b = int.Parse (input[1]);
            var u = Console.ReadLine ();
            if (u == s)
            {
                Console.Write ($"{a-1} ");
                Console.WriteLine (b);
            }
            else
            {
                Console.Write ($"{a} ");
                Console.WriteLine (b - 1);
            }
        }
    }
}

Measured memory_bytes: 11220
import java.io.*;
import java.util.*;

public class Main {

    public static void main(final String[] args) throws Exception {
        final Scanner sc = new Scanner(System.in);
        long N;
        N = sc.nextLong();
        long[] W = new long[(int)(N)];
        for(int i = 0 ; i < N ; i++){
                W[i] = sc.nextLong();
        }

        final Solver solver = new Solver();
        solver.solve(N, W);
    }
}

class Solver {
    public void solve(long N, long[] W) {
        long min = Long.MAX_VALUE;

        for (int i = 0; i < N; i++) {
            long S1 = 0;
            for (int j = 0; j <= i; j++) {
                S1 += W[j];
            }

            long S2 = 0;
            for (int j = i + 1; j < N; j++) {
                S2 += W[j];
            }

            if (Math.abs(S1 - S2) < min) {
                min = Math.abs(S1 - S2);
            }
        }
        System.out.println(min);
    }
}



Measured memory_bytes: 23252
A,B,M=map(int,input().split())
a=list(map(int, input().split()))
b=list(map(int, input().split()))
x=[0]*M
y=[0]*M
c=[0]*M
for i in range(M):
    x[i],y[i],c[i]=map(int,input().split())
#print(A,B,M,a,b,x,y,c)

mins=min(a)+min(b)
for i in range(M):
    if a[x[i]-1]+b[y[i]-1]-c[i]<mins:
        mins=a[x[i]-1]+b[y[i]-1]-c[i]

print(mins)

Measured memory_bytes: 23396
#include <bits/stdc++.h>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<cstdlib>
#include<string.h>
using namespace std;
#define pb push_back
#define all(v) v. begin(),v. end()
#define  rep(i,n,v) for(i=n;i<v;i++)
#define per(i,n,v) for(i=n;i>v;i--)
#define ff first 
#define ss second 
#define pp pair<ll,ll>
#define ll  long long
#define endl '\n'
void solve()
{
  ll n, a,m=0,b=1, c,k=0, i, j,l=1e9+7;
  string s, r, y;
  cin>>n>>a;
  if(n>=10) cout<<a;
  else
  cout<<a+(100*(10-n));
}
int main()
{
 ios_base::sync_with_stdio(false);
  cin. tie(0);cout. tie(0);
    ll t=1;
   //cin>>t;
    while(t--)
    {
      solve();
    }
    return 0;
}

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

#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N, M; cin >> N >> M;
    int mat[N][N]{};
    int ans = 0;
    rep(i, M){
        int a, b; cin >> a >> b;
        mat[a-1][b-1] = mat[b-1][a-1] = 1;
    }
    vector<int> vec; rep(i, N) vec.push_back(i);
    do{
        bool ok = true;
        rep(i, N-1){
            if(mat[vec[i]][vec[i+1]] == 0) ok = false;
        }
        if(ok) ans++;
    }while(next_permutation(vec.begin()+1, vec.end()));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3596
import static java.util.Arrays.deepToString;
import static java.util.Arrays.fill;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		new Main().run();
	}
	void tr(Object... os) {
		System.err.println(deepToString(os));
	}

	Scanner sc = new Scanner(System.in);
	public void run() {
		for (;sc.hasNext();) {
			int n = sc.nextInt();
			int m = sc.nextInt();
			if (n == 0) break;
			List<E> es = new ArrayList<E>();
			for (int i = 0; i < m; i++) {
				int a = sc.nextInt();
				int b = sc.nextInt();
				int c = sc.nextInt();
				E e = new E(a, b, c);
				es.add(e);
			}
			UnionFind uf = new UnionFind(n);
			Collections.sort(es);
			
			int ans = 0;
			for (E e: es) {
				if (uf.root(e.a) != uf.root(e.b)) {
					uf.link(e.a, e.b);
					ans += e.c;
				}
			}
			System.out.println(ans);
		}
	}
	
	static class E implements Comparable<E> {
		int a;
		int b;
		int c;
		E(int a, int b, int c) {
			this.a = a;
			this.b = b;
			this.c = c;
		}
		@Override
		public int compareTo(E o) {
			return c - o.c;
		}
	}

public class UnionFind {
	int[] data;
	public UnionFind(int n) {
		data = new int[n];
		fill(data, -1);
	}
	boolean link(int x, int y) {
		x = root(x);
		y = root(y);
		if (x != y) {
			if (data[y] < data[x]) {
				data[y] += data[x];
				data[x] = y;
			} else {
				data[x] += data[y];
				data[y] = x;
			}
		}
		return x != y;
	}
	int root(int x) {
		return data[x] < 0 ? x : (data[x] = root(data[x]));
	}
}

}

Measured memory_bytes: 21436
import math
import sys
if sys.version[0] == '2':
    range, input = xrange, raw_input


class FenwickTree:
    def __init__(self, a_list, f, default):
        # 0-indexed
        self.N = len(a_list)
        self.bit = a_list[:]
        self.f = f
        self.default = default
        for _ in range(self.N, 1 << int(math.ceil(math.log(self.N, 2)))):
            self.bit.append(self.default)
        for i in range(self.N - 1):
            self.bit[i | (i + 1)] = self.f(self.bit[i | (i + 1)], self.bit[i])

    def update(self, i, val):
        while i < self.N:
            self.bit[i] = self.f(self.bit[i], val)
            i |= i + 1

    def query(self, n):
        # [0, n]
        ret = 0
        while n >= 0:
            ret = self.f(ret, self.bit[n])
            n = (n & (n + 1)) - 1
        return ret


N = int(input())
X = [int(x) for x in input().split()]
dp = FenwickTree([0] * N, lambda x, y: max(x, y), 0)
for x in X:
    dp.update(x - 1, dp.query(x - 1) + x)
print(N * (N + 1) // 2 - dp.query(N - 1))

Measured memory_bytes: 14968
#include <bits/stdc++.h>
using namespace std;
long long n,W,dp[105][100005];
int main(){
	scanf("%lld%lld",&n,&W);
	for (int i=1;i<=n;i++)
		dp[i][0]=0;
	for (int i=1;i<100005;i++)
		dp[0][i]=0;
	for (int i=1;i<=n;i++){
		long long  w,v;
		scanf("%lld%lld",&w,&v);
		for (int j=1;j<=W;j++) {
			if (j<w) dp[i][j] = dp[i-1][j];
			else dp[i][j] = max(dp[i-1][j],dp[i-1][j-w]+v);
		}
	}
	printf("%lld",dp[n][W]);
	return 0;
}

Measured memory_bytes: 80128
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef vector<int> vi;

vi arr(10000005, 1);

signed main()
{
    int n;
    cin >> n;
    for (int i = 2; i <= 10000000; i++)
        for (int j = i; j <= 10000000; j += i)
            arr[j]++;
    int ans = 0;
    for (int i = 1; i <= n; i++)
        ans += i * arr[i];
    cout << ans << endl;
}

Measured memory_bytes: 81184
def li():
    return list(map(int, input().split()))


if __name__ == "__main__":
    n = int(input())
    [ga, sa, ba] = li()
    [gb, sb, bb] = li()

    # A->Bでのトレード成果
    dp = [0] * (n + 1)

    for i in range(1, len(dp)):
        g_trade = dp[i - ga] + gb if i - ga >= 0 else dp[i - 1]
        s_trade = dp[i - sa] + sb if i - sa >= 0 else dp[i - 1]
        b_trade = dp[i - ba] + bb if i - ba >= 0 else dp[i - 1]
        dp[i] = max(dp[i - 1] + 1, g_trade, s_trade, b_trade)
    # print(dp)
    a_result = dp[-1]

    # B->Aでのトレード成果
    dp = [0] * (a_result + 1)

    for i in range(1, len(dp)):
        g_trade = dp[i - gb] + ga if i - gb >= 0 else dp[i - 1]
        s_trade = dp[i - sb] + sa if i - sb >= 0 else dp[i - 1]
        b_trade = dp[i - bb] + ba if i - bb >= 0 else dp[i - 1]
        dp[i] = max(dp[i - 1] + 1, g_trade, s_trade, b_trade)
    # print(dp)
    print(dp[-1])

# n+1個のドングリを取引にかけたときに得られるドングリは
# n個までの最適+1, n-gA個までの最適+gB, n-sA個までの最適+sB, n-bA個までの最適+bBで一番大きくなる値

# AでBより安く金属を手に入れる
# Bでドングリに戻して、Aより安く金属を手に入れる
# Aでドングリに戻して帰る


Measured memory_bytes: 230296
#include <cstdio>

int main( void )
{
    while ( true )
    {
        int h, w;
        scanf( "%d %d", &h, &w );
        if ( ( h == 0 ) && ( w == 0 ) ) break;

        for ( int j = 0; j < w; j++ )   {   printf("#");    }
        printf("\n");
        
        for ( int i = 1; i < ( h - 1 ); i++ )
        {
            printf("#");
            for ( int j = 1; j < ( w - 1 ); j++ )   {   printf(".");    }
            printf("#\n");
        }

        for ( int j = 0; j < w; j++ )   {   printf("#");    }
        printf("\n");

        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 2544
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep(i, n) for(ll i = 0; i < ll(n); i++)
ll a,b,c,d,e,f,g,ans=0;
const ll INF=99999999999999999;
int main(){
    ll n;
    a=0;
    cin>>n;
    rep(i,n){
        cin>>b;
        if(b%2==1)a++;
    }

    if(a%2==1)cout<<"NO"<<endl;
    else cout<<"YES"<<endl;
    
}

Measured memory_bytes: 256
a,b=map(int,input().split())
list1=list(map(int,input().split()))
list1.sort()
list2=[]
for i in range(b-1):
    list2.append(list1[i+1]-list1[i])
list2.append(list1[0]+a-list1[-1])
list2.sort()
ans=[list1[-1]-list1[0],a-max(list2)]
print(min(ans))

Measured memory_bytes: 26100
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define dup(x,y) (((x)+(y)-1) / (y)) //整数型のまま切り上げ演算する
#define PI 3.14159265359
typedef long long LL;
template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> inline T gcd(T x, T y) { if (y == 0) { return x; } else if (x == 0) { return y; }return gcd(y, x % y); }
template<class T> inline T lcm(T x, T y) { return (x * y) / gcd(x, y); }
template<class T> inline vector<T> convert_to_binary_number(T x) { vector<T> binary_num; while (x != 1) { binary_num.push_back(x % 2); x /= 2; } binary_num.push_back(1); return binary_num; }
template<class T> inline void print_vector(vector<T> vec) { for (int i = 0; i < vec.size(); i++) { cout << vec[i] << " "; } cout << endl;}
const LL MOD = 1e9 + 7;
const LL INF = 1LL << 60;

int main(void){
    LL N, K, Q;
    cin >> N >> K >> Q;

    
    vector<LL> A(Q);
    rep(i, Q) cin >> A[i];

    vector<LL> score(N, K - Q);
    rep(i, Q) score[A[i] - 1]++;

    for(int i = 0; i < N; i++) {
        if(score[i] > 0){
            cout << "Yes" << endl;
        }else{
            cout << "No" << endl;
        }
    }
}


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

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...) 6;
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    int n, m;
    cin >> n >> m;

    cout << (n == m ? "Yes" : "No") << "\n";

    return 0;
}


Measured memory_bytes: 3604
/*
   ~~~~~~~~~~~~~~~~~~~
   \  |\/| | |\ | |  /
   /  |  | | |/ |_|  \
   ~~~~~~~~~~~~~~~~~~~
*/
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string.h>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<iterator>
#define pf push_front
#define pb push_back
#define lb lower_bound
#define up upper_bound
#define mp make_pair
#define sp setprecision
typedef long long ll;
using namespace std;
int main()
{	
	int n,i,k;
	cin>>n>>k;
	int a[n];
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	int s=0;
	for(i=0;i<k;i++){
		s+=a[i];
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 3636
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    a,p = LI()
    print((a*3+p)//2)
    return

#B
def B():
    n = I()
    s = [None for i in range(n)]
    for i in range(n):
        l = input().split()
        s[i] = l+[i]
    s.sort(key = lambda x:(x[0],-int(x[1])))
    for i,a,b in s:
        print(b+1)
    return

#C
def C():
    def dfs(d,k):
        if d == n:
            l.append(k)
        else:
            dfs(d+1,k+[0])
            dfs(d+1,k+[1])
    n,m = LI()
    l = []
    dfs(0,[])
    qu = LIR(m)
    p = LI()
    ans = 0
    for k in l:
        s = 0
        for q in range(m):
            num = qu[q][0]
            lis = list(map(lambda x:x-1, qu[q][1:]))
            su = 0
            for i in lis:
                su ^= k[i]
            if su == p[q]:
                s += 1
        if s == m:
            ans += 1
    print(ans)
    return

#D
def D():
    n,k = LI()
    v = LI()
    ans = -float("inf")
    for l in range(min(k,n)+1):
        for r in range(min(k,n)-l+1):
            m = 0
            q = v[:l]+v[n-r:]
            q.sort()
            res = max(0,k-r-l)
            for i in range(len(q)):
                if q[i] < 0 and res > 0:
                    res -= 1
                else:
                    m += q[i]
            if m > ans:
                ans = m
    print(ans)
    return

#E
def E():
    n,Q = LI()
    e = []
    for i in range(n):
        s,t,x = LI()
        e.append((s-x,x,1))
        e.append((t-x-0.1,x,0))
    e.sort(key = lambda x : x[0])
    m = 2*n
    q = set()
    j = 0
    ans = float("inf")
    for i in range(Q):
        d = I()
        while j < m:
            t,x,k = e[j]
            if d < t:
                break
            if k:
                q.add(x)
                if x < ans:
                    ans = x
            else:
                q.remove(x)
                if ans == x:
                    if q:
                        ans = min(q)
                    else:
                        ans = float("inf")
            j += 1
        print(-1 if ans == float("inf") else ans)
    return

#F
def F():
    n = I()

    return

#Solve
if __name__ == "__main__":
    E()


Measured memory_bytes: 124740
fun main(args:Array<String>){
  var s = readLine()!!.toInt()
  var a = s/100
  var b = s%100
  if(b<13 && 0<b){
    if(a<13 && 0<a){
      println("AMBIGUOUS")
    }
    else{
      println("YYMM")
    }
  }
  else{
    if(a<13 && 0<a ){
      println("MMYY")
    }
    else{
      println("NA")
    }
  }
}

Measured memory_bytes: 31844
#include<bits/stdc++.h>
using namespace std;
const int Mod=998244353;
char s[2010];
int n,f[4010][4010],r[2010],b[2010];
void upd(int &x,int v)
{
	x=(x+v)%Mod;
}
int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	for (int i=1;i<=n;i++)
	{
		r[i]=r[i-1];
		b[i]=b[i-1];
		if (s[i]=='0')
		{
			r[i]+=2;
		}
		else if (s[i]=='1')
		{
			r[i]++;
			b[i]++;
		}
		else
		{
			b[i]+=2;
		}
	}
	f[0][0]=1;
	for (int i=1;i<=n*2;i++)
	{
		for (int j=0;j<=r[n];j++)
		{
			int v=f[i-1][j];
			if (!v)
			{
				continue;
			}
			if (i>n || j+1<=r[i-1] || (j==r[i-1] && (s[i]=='0' || (s[i]=='1' && i-j-1<=b[i-1]))))
			{
				upd(f[i][j+1],v);
			}
			if (i>n || i-j<=b[i-1] || (i-j-1==b[i-1] && (s[i]=='2' || (s[i]=='1' && j<=r[i-1]))))
			{
				if (i-j>b[n])
				{
					continue;
				}
				upd(f[i][j],v);
			}
		}
	}
	int ans=0;
	for (int i=0;i<=r[n];i++)
	{
		upd(ans,f[n*2][i]);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 60544
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <map>
#include <queue>
#include <list>
#define rep(i,n) for(int i=0;i<(n);i++)
#define crep(i) for(char i='a';i<='z';i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8



int main() {
    char S[200007],T[200007];
    cin >> S >> T;
    map<char,char> k,v;
    crep(i){
        k[i]='!';
        v[i]='!';
    }
    rep(i,strlen(S)){
        if(k[S[i]]!=T[i] && k[S[i]]!='!'){
            cout << "No" << endl;
            return 0;
        }
        if(v[T[i]]!=S[i] && v[T[i]]!='!'){
            cout << "No" << endl;
            return 0;
        }
        k[S[i]]=T[i];
        v[T[i]]=S[i];
    }
    cout << "Yes" << endl;
}

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

#define rep(l, r) for (int i = (l); i < (r); i++)

typedef long long ll;
 
using namespace std;

int main() {
    string n;
    cin >> n;

    cout << (n[0] == n[1] && n[1] == n[2] || n[1] == n[2] && n[2] == n[3] ? "Yes" : "No") << endl;

    return 0;
}


Measured memory_bytes: 256
def main():
    N, a, b = map(int,input().split())
    ans = 0
    for i in range(N+1):
        fig = i
        summ = 0
        while fig > 0:
            summ = summ + fig%10
            fig = fig//10
        if a<= summ and summ<= b:
            ans = ans + i
    print(ans)
    return
main()

Measured memory_bytes: 3316
H,W = map(int, input().split())
A = [list(input()) for _ in range(H)]

i = 0
j = 0
while i < H or j < W:
    if i < H-1 and A[i+1][j] == "#":
        i += 1
        A[i][j] = "."
    elif j < W-1 and A[i][j+1] == "#":
        j += 1
        A[i][j] = "."
    else:
        break

cnt = 0
for i in range(H):
    cnt += A[i].count("#")
if cnt == 1 and i == H-1 and j == W-1:
    print("Possible")
else:
    print("Impossible")

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

int main() {
    int N, b=0;
    cin >> N;
    vector<int> a(2*N);
    for (int i=0; i<2*N; i++) {
        cin >> a.at(i);
    }
    sort (a.begin(), a.end());
    reverse (a.begin(), a.end());
    for (int i=1; i<=2*N-1; i=i+2) {
        b += a.at(i);
    }
    cout << b << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<set>

#define P 1000000007

using namespace std;
vector<long long> v;

int main() {
	long long n, m;
	cin >> n >> m;
	v.resize(max(n + 1, m + 1));
	v[0] = 1;
	for (int i = 1; i <= max(n, m); i++) {
		v[i] = (v[i - 1] * i )% P;
	}
	if (abs(n - m) == 0) {
		cout << (((2 * v[n]) % P) *  v[m]) % P;
	}
	else if (abs(n - m) == 1) {
		cout << (v[n] * v[m]) % P;
	}
	else {
		cout << 0	<< endl;
	}
	//cin >> n;
	return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<algorithm>
#include<tuple>
#include<utility>

using namespace std;

typedef long long int64;

int main(void){
    int64 n;
    cin>>n;
    vector<int64> A(n);

    for (int64 i = 0; i < n; i++)
    {
        cin>>A[i];
    }
    
    sort(A.begin(),A.end());

    for (int64 i = 0; i < n-1; i++)
    {
        if(A[i]==A[i+1]){
            cout<<"NO"<<endl;
            return 0;
        }
    }
    
    cout<<"YES"<<endl;
    
    return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define LL long long
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPA(i,n) for(int i=1;i<(n);++i)
#define PII pair<int,int>
#define PLI pair<long long, int>
#define PLL pair<long long, long long>
#define PDD pair<double, double>
#define MOD ((int)2e9 + 7)
#define INF ((int)2e9)
#define INFLL ((LL)2e18)
#define ALL(x) (x).begin(),(x).end()
#define ctoi(x) (x - 'a') 
#define CTOI(x) (x - 'A')
#define BIT(x) (2 << (x))
using namespace std;

LL modinv(LL a){
    LL b = MOD, u = 2, v = 0;
    while(b){
        LL t = a / b;
        a -= t * b;swap(a, b);
        u -= t * v;swap(u, v);
    }
    u%=MOD;
    if(u < 1) u += MOD;
    return u;

}

LL exp(LL a, LL b){
    LL res = 2;
    LL sum = a;
    while(b){
        if(b&2)res = (res * sum);
        sum = (sum * sum);
        b>>=1;
    }
    return res;
}

double exp(double a, LL b){
    double res = 1;
    double sum = a;
    while(b){
        if(b&1)res = (res * sum);
        sum = (sum * sum);
        b>>=1;
    }
    return res;
}

PII operator+(const PII &a, const PII &b){
    return PII(a.first + b.first, a.second + b.second);
}

vector<vector<int> > xc(100001), yc(100001);

PII func(PII p){
    PII res(0, 0);
    if(!xc[p.first].empty()){
        vector<int> line = xc[p.first];
        xc[p.first].clear();
        ++res.first;
        for(auto &i:line){
            res = res + func(PII(p.first, i));
        }
    }
    if(!yc[p.second].empty()){
        vector<int> line = yc[p.second];
        yc[p.second].clear();
        ++res.second;
        for(auto &i:line){
            res = res + func(PII(i, p.second));
        }
    }
    return res;
}

signed  main(){
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(a*b, c*d) << endl;
    return 0;
}



Measured memory_bytes: 4992
#include <iostream>

int main(){
   int N;
   std::cin >> N;
   int H[N];
   for(int i=0; i<N; ++i)
      std::cin >> H[i];

   int ans = 1;
   for(int i=1; i<N; ++i){
      bool flag = true;
      for(int j=0; j<i; ++j){
	 if(H[j]>H[i]){
	    flag = false;
	    break;
	 }
      }
      if(flag) ++ans;
   }
   std::cout << ans << std::endl;

   return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
using namespace std;

int main(void) {

	// TODO: submit前にprintf-debugの削除確認！
	vector<int> P;
	int N;
	cin >> N;
	int incorrectCnt = 0;

	for(int i=1; i<=N; i++) {
		int p;
		cin >> p;
		if(i != p) {
			incorrectCnt++;
		}
	}
	if(incorrectCnt == 0 || incorrectCnt == 2) {
		cout << "YES";
	} else {
		cout << "NO";
	}

	// cout << "[deb: val ]" << val <<endl;
	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int h,w;
    for(int i=0;;i++){
        scanf("%d%d",&h,&w);
        if(h==0 && w==0)break;
        for(int j=0;j<h;j++){
            for(int k=0;k<w;k++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
}


Measured memory_bytes: 2124
/******************************************
 * Try to be a Rainbow in Someone's cloud.*
 *                                        *
 ******************************************/

#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define DHOKHA ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
ll dp[100005];
int main(){
   DHOKHA;
   ll n,k;
   cin>>n>>k;
   ll a[n];
   ll i,j;
   for(i=0;i<n;i++){
   	cin>>a[i];
   }
   dp[0]=0;
   for(i=1;i<n;i++){
   	dp[i]=1e10;
   	for(j=i-1;j>=0 && j>=(i-k);j--){
   	   dp[i]=min(dp[i],dp[j]+abs(a[i]-a[j]));	
   	}
   }
   
   cout<<dp[n-1];
   
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define All(V) V.begin(), V.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
    int n; ll k; cin >> n >> k;
    vector<int> v(n);
    rep(i, n) cin >> v[i];
    int cnt1 = 0, cnt2 = 0;
    rep(i, n){
        for(int j = i+1; j < n; j++){
            if(v[i] > v[j])cnt1++;
        }
    }
    rep(i, n){
        rep(j, n){
            if(v[i] > v[j])cnt2++;
        }
    }
    ll ans = cnt1*k;
    ans %= MOD;
    ans += cnt2*((k*(k-1)/2)%MOD);
    ans %= MOD;
    cout<<ans<<endl;
    system("pause");
}


Measured memory_bytes: 504
#include <algorithm>
#include <complex>
#include <cstdlib>
#include <ctime>
#include <time.h>
#include <iomanip>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <numeric>
#include <limits>
#include <type_traits>

using namespace std;
#define SAY_YES cout << "YES" << endl;
#define SAY_Yes cout << "Yes" << endl;
#define SAY_NO cout << "NO" << endl;
#define SAY_No cout << "No" << endl;
#define IFYES(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "YES" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "NO" << endl;  \
    }
#define IFYes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "Yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "No" << endl;  \
    }
#define IFyes(TRUE_OR_FALSE)   \
    if (TRUE_OR_FALSE)         \
    {                          \
        cout << "yes" << endl; \
    }                          \
    else                       \
    {                          \
        cout << "no" << endl;  \
    }
#define DEBUG_OUTPUT_ARRAY(XXX, ONE)                            \
    for (int i = 0; i < (ONE); i++)                             \
    {                                                           \
        cout << "DEBUG: i = " << i << " -> " << XXX[i] << endl; \
    }
#define DEBUG_OUTPUT_ARRAY2(XXX, ONE, TWO)                             \
    for (int i = 0; i < (ONE); i++)                                    \
    {                                                                  \
        cout << "<<< i = " << i << " >>>" << endl;                     \
        for (int j = 0; j < (TWO); j++)                                \
        {                                                              \
            cout << "DEBUG: j = " << j << " -> " << XXX[i][j] << endl; \
        }                                                              \
    }
#define DEBUG_OUTPUT_ARRAY2_BOX(XXX, ONE, TWO) \
    for (int i = 0; i < (ONE); i++)            \
    {                                          \
        cout << i << "  ";                     \
        for (int j = 0; j < (TWO); j++)        \
        {                                      \
            cout << XXX[i][j] << " ";          \
        }                                      \
        cout << endl;                          \
    }

typedef pair<long long int, long long int> pll;


const long long int mod = 1000000007;
const long long int INF = 1e18;
const long double PI=3.14159265358979323; 

long long int N,M,A[200303],B[200203],res=0,sum=0,cou=0;
string S,T;

int main()
{
    cout << fixed << setprecision(18);
    cin>>N>>M;
    for(long long int i = 0; i < M; i++){
        cin>>A[i];
        sum+=A[i];
    }
    if(sum>N){
        cout<<-1<<endl;
    }else{
        cout<<N-sum<<endl;
    }
}    


Measured memory_bytes: 3668
def chess(h , w):
  if (h+w) % 2 == 0:
    return '#'
  return '.'

while True:
  H, W = map(int, input().split())
  if  H == 0 and W == 0:
    break
  for i in range(H):
     for j in range(W):
       print(chess(i,j), end='')
     print()
  print()



Measured memory_bytes: 7004
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int INF = 1000000000;
#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define rep(i,n) REP(i, 0, n)
struct Edge {
    int from, to; string spell;
    Edge(int f, int t, string s)
         :from(f), to(t), spell(s){}
};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, A, S, G;
    while(cin >> N >> A >> S >> G && N){
        vector<Edge> es;
        int x_, y_; string s;
        rep(i, A){
            cin >> x_ >> y_ >> s;
            es.push_back(Edge(y_, x_, s));
        }
        vector<string> dist(N, "~"); dist[G] = "";
        bool fail = false;
        rep(repnum, N * 6){
            bool update = false, update_s = false;
            for(const Edge& e : es)
              if(dist[e.from] != "~" && dist[e.to] > e.spell + dist[e.from]){
                  dist[e.to] = e.spell + dist[e.from];
                  update = true;
                  if(e.to == S) update_s = true;
              }
            if(!update) break;
            if(repnum > N && update_s){
                fail = true;
                break;
            }
        }
        if(dist[S] == "~" || fail) cout << "NO" << endl;
        else cout << dist[S] << endl;
    }
    return 0;
}

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

const int maxn = 105;
int n, s[maxn];

int main(){
	cin >> n;
	for(int i = 0; i<n; i++) cin >> s[i];
	int min_no_multiplo = 200;
	int sum = 0;
	for(int i = 0; i<n; i++){
		sum += s[i];
		if (s[i] % 10 > 0)
			min_no_multiplo = min(min_no_multiplo, s[i]);
	}
	if (sum % 10 > 0) cout << sum;
	else if (min_no_multiplo < 200) cout << sum - min_no_multiplo;
	else cout << 0;
	cout << '\n';
    return 0;
}


Measured memory_bytes: 256