akhauriyash/Code-Regression huggingface dataset:
//verma_ankit484

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

#define int long long
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define pb push_back
const int mod = (int) 1e9+7;

using namespace std;
//using namespace __gnu_pbds;

//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>


int32_t main() {
  IOS
  #ifdef AV
  freopen("input.txt", "r", stdin);
  #endif
  int n, m, k;
  cin >> n >> m >> k;
  vector<int> a(n);
  vector<int> b(m);
  for (int i = 0; i < n; i++) cin >> a[i];
  for (int i = 0; i < m; i++) cin >> b[i];
  for (int i = 1; i < n; i++) a[i] += a[i - 1];
  for (int i = 1; i < m; i++) b[i] += b[i - 1];
  int ans = 0;
  for (int i = 0; i <= n; i++) {
    int left = k;
    int cc = 0;
    if (i > 0 and a[i - 1] <= left) {
      left -= a[i - 1];
      cc += i;
    }
    int p = upper_bound(b.begin(), b.end(), left) - b.begin();
    cc += p;
    ans = max(ans, cc);
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

#define int long long
const int N = 2e5 + 10;

int n , ans;
int a[N] , res[N];

signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> n;
	for(int i = 1 ; i <= n ; ++ i)
		cin >> a[i];
	a[0] = -1;
	for(int i = 1 ; i <= n ; ++ i)
		if(a[i - 1] + 1 < a[i]){
			cout <<"-1";
			return 0;
		}
	for(int i = 1 ; i <= n ; ++ i){
		int pos = i - a[i] + 1;
		res[pos] = a[i];
	}
	for(int i = 1 ; i <= N ; ++ i) ans += res[i];
	cout << ans <<endl;
}

Measured memory_bytes: 3328
#include <iostream>

using namespace std;

int main() {

    int W, H, x, y, r;
    
    cin >> W >> H >> x >> y >> r;
    
    if (r > W + H || x + r > W || x - r < 0 || y + r > H || y - r < 0){
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    
    return 0;
}

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

int main() {
  ll a, b, c, k;
  cin >> a >> b >> c >> k;
  if(a>=k) cout << k << endl;
  else if(a+b>=k) cout << a << endl;
  else cout << a-(k-a-b) << endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<class F>auto recursive(F f){return[f](auto...a){return f(f,a...);};}
template<class I,class V=typename I::value_type>V sum_up(const I&l,const I&r){V v;for(I i=l;i!=r;i++)v=i==l?*i:v+*i;return v;}
template<class I,class T=iterator_traits<I>>I operator+(I it,int n){for(int i=0;i<n;i++)it++;return it;}
template<class I,class T=iterator_traits<I>>I operator-(I it,int n){for(int i=0;i<n;i++)it--;return it;}
template<class T>using rev_priority_queue=priority_queue<T,vector<T>,greater<T>>;
template<class T>using vector2d=vector<vector<T>>;
struct fixprec{int p;fixprec(int p):p(p){}};
ostream&operator<<(ostream&o,fixprec f){return o<<fixed<<setprecision(f.p);}
void R_YESNO(bool p){cout<<(p?"YES":"NO")<<endl;}
void R_YesNo(bool p){cout<<(p?"Yes":"No")<<endl;}

struct Edge {
    int to;
    int a;
    i64 b;
};

/*!* [dijkstra] *!*/
/*+* ダイクストラ法
     点sから全ての点への距離をO((E+V)logV)で求める *+*/
template<typename Edge, typename T>
void Dijkstra(const vector2d<Edge> &edge, int s, vector<T> &d) {
    using P = pair<T, int>;
    rev_priority_queue<P> q;
    q.push({0, s});
    while(q.size()) {
        T dist;
        int v;
        tie(dist, v) = q.top(); q.pop();
        if(d[v] < dist) continue;
        for(auto&& e : edge[v]) {
            if(d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                q.push({d[e.to], e.to});
            }
        }
    }
}

using P = pair<int, int>;

int main() {
    // DP(配る)
    int N, M, S;
    cin >> N >> M >> S;
    const int NA = 2500;
    const i64 INF = 1e15;
    vector2d<i64> dp(N, vector<i64>(NA + 1, INF));
    vector2d<Edge> edge(N);
    for(int i = 0; i < M; i++) {
        int u, v, a;
        i64 b;
        cin >> u >> v >> a >> b;
        u--, v--;
        edge[u].push_back({v, a, b});
        edge[v].push_back({u, a, b});
    }
    vector<i64> C(N), D(N);
    for(int i = 0; i < N; i++) {
        cin >> C[i] >> D[i];
    }
    queue<P> q;
    dp[0][min(S, NA)] = 0;
    q.push({min(S, NA), 0});
    while(q.size()) {
        int m, i;
        tie(m, i) = q.front(); q.pop();
        for(int j = 1; m + j * C[i] <= NA; j++) {
            int m_ = m + j * C[i];
            if (dp[i][m_] > dp[i][m] + j * D[i]) {
                dp[i][m_] = dp[i][m] + j * D[i];
                q.push({m_, i});
            } else {
                break;
            }
        }
        for (auto&& e : edge[i]) {
            if(m - e.a < 0) continue;
            if (dp[e.to][m - e.a] > dp[i][m] + e.b) {
                dp[e.to][m - e.a] = dp[i][m] + e.b;
                q.push({m - e.a, e.to});
            }
        }
    }
    for(int i = 1; i < N; i++) {
        i64 ans = INF;
        for(int j = 0; j <= NA; j++) {
            ans = min(ans, dp[i][j]);
        }
        cout << ans << endl;
    }
    return 0;
}



Measured memory_bytes: 7140
import math
from functools import reduce
import collections
import itertools
a = list(map(int,input().split()))
n = a[0]
x = a[1]
li = [list(map(int,input().split())) for i in range(n)]
aa = []#cost
for i in range(n):
    if li[i][1] <= x:
        aa.append(li[i][0])
if len(aa) == 0:
    print("TLE")
else:
    print(min(aa))


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

int main() {
  int N, m;
  int c[2048];
  int d[2048];
  int imos[2048] = {};

  std::cin >> N >> m;
  for(int i = 0; i < m; ++i) {
    std::cin >> c[i] >> d[i];
  }

  for(int i = 0; i < m; ++i) {
    imos[c[i]] += 1;
    imos[d[i]] -= 1;
  }

  int t = 0;
  for(int i = 0; i <= N; ++i) {
    t += imos[i];
    imos[i] = t;
  }  

  int res = 0;
  for(int i = 0; i < N + 1; ++i) {
    if( imos[i] != 0 ) {
      res += 3;
    }
    else {
      res += 1;
    }
  }

  std::cout << res << std::endl;

  return 0;
}

Measured memory_bytes: 1184
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <ctime>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <memory.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
using namespace std;
typedef long double LD;
typedef long long LL;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;
#ifdef LOCAL
#define DEBUG(x) { cerr << "# " << #x << ": " << x << endl;}
#else
#define DEBUG(x)
#endif
mt19937_64 mt(time(0));
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i
　　　　／　　　＼　 　  |　|
　　　 /　　 /￣￣￣￣/　　|
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿
　 　　　＼/＿＿＿＿/　（u　⊃
---------------------------------------------------------------------------------------------------*/
const int MAXN = 1e4 + 10;
int ret[MAXN];





int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  cout.precision(10); cout << fixed;
#ifdef LOCAL
  freopen("../test.txt", "r", stdin);
    // freopen("../output.txt", "w", stdout);
#endif
  int n; cin >> n;
  for (int i = 1; i*i < n; i++) {
    int ii = i*i;
    for (int j = 1; j*j+ii < n; j++) {
      int ij = ii + j*j;
      for (int k = 1; k*k + ij < n; k++) {
        int tmp = ij + k*k + i*j + i*k + j*k;
        if (tmp <= n) ret[tmp]++;
      }
    }
  }
  for (int i = 1; i <= n; i++) {
    cout << ret[i] << '\n';
  }





/*---------------------------------------Coding Space End------------------------------------------*/
#ifdef LOCAL
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." << endl;
#endif
  return 0;
}
/* author:  txingml */
/* picture is from hamayanhamayan(CF handle) */


Measured memory_bytes: 3060
def main():
    N = int(input())
    h = list(map(int, input().split()))
    dp = [0] * N
    dp[1] = abs(h[0] - h[1])
    for i in range(2, N):
        dp[i] = min(
            abs(h[i] - h[i - 2]) + dp[i - 2],
            abs(h[i] - h[i - 1]) + dp[i - 1]
        )
    print(dp[-1])


main()


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

int main(){
  string s;
  cin>>s;
  int a=0,b=0,c=0;
  for(int i=0;i<3;i++){
    if(s[i]=='a') a++;
    if(s[i]=='b') b++;
    if(s[i]=='c') c++;
  }
  if(a==b&&b==c&&c==1){
    cout<<"Yes"<<endl;
  }else{
    cout<<"No"<<endl;
  }
  return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

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

    // start
    int x, a;
    cin >> x >> a;
    cout << (x < a ? 0 : 10) << endl;
    // end

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
int main(){
    int n,m;
    cin >> n;
    vector<int> x(n);
    rep(i,n)cin >> x[i];
    cin >> m;
    rep(_,m){
        int d;
        cin >> d;
        d--;
        if(x[d] == 2019)continue;
        bool c = true;
        rep(i,n)if(x[i] == x[d]+1)c = false;
        if(c)x[d]++;
    }
    rep(i,n)cout << x[i] << endl;
}



Measured memory_bytes: 3120
#include<bits/stdc++.h>
using namespace std;
 
const int N=200010;
int a[N],b[N],n;
 
int main(){
	scanf("%d",&n);
	int x;
	for(int i=1;i<=n;i++) scanf("%d",&a[i]);
	for(int i=1;i<=n;i++) scanf("%d",&b[i]);
	reverse(b+1,b+1+n);
	int l=0,r=0,t=0,L=0,R=0;
	for(int i=1;i<=n;i++) if(a[i]==b[i]) {
		if(!l) l=i,r=i,t=a[i];
		else r++;
	}
	if(!l){
		printf("Yes\n");
		for(int i=1;i<=n;i++) printf("%d ",b[i]);
		return 0;
	}
	for(int i=1;i<=n;i++) if(a[i]==t || b[i]==t) {L=i-1;break;}
	for(int i=n;i>=1;i--) if(a[i]==t || b[i]==t) {R=i+1;break;}
	if(L+n-R+1<(r-l+1)) printf("No\n");
	else{
		for(int i=1;i<=min(L,r-l+1);i++) swap(b[i],b[l+i-1]);
		for(int i=1;i<=r-l+1-min(r-l+1,L);i++) swap(b[n-i+1],b[r-i+1]);
		printf("Yes\n");
		for(int i=1;i<=n;i++) printf("%d ",b[i]);
	}
}

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

int main() {
    int w, h, n;
    cin >> w >> h >> n;

    int x, y, a;
    int w0 = 0, h0 = 0;

    for (int i = 0; i < n; i++) {
        cin >> x >> y >> a;

        switch (a) {
            case 1:
                w0 = max(w0, x);
                break;
            case 2:
                w = min(w, x);
                break;
            case 3:
                h0 = max(h0, y);
                break;
            case 4:
                h = min(h, y);
                break;
        }
    }

    cout << max(0, w - w0) * max(0, h - h0) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#define LL long long
#define maxn 3010
#define mod 998244353
LL dp[maxn];
int main(){
	int n,s,x,i,j,inv2;
	scanf("%d%d",&n,&s);
	inv2=mod-mod/2,dp[0]=1;
	for(i=1;i<=n;i++)dp[0]=dp[0]*2%mod;
	for(i=1;i<=n;i++){
		scanf("%d",&x);
		for(j=s;j>=x;j--)
			dp[j]=(dp[j]+dp[j-x]*inv2)%mod;
	}
	printf("%lld\n",dp[s]);
	return 0;
}

Measured memory_bytes: 1736
num_list = input()
key = 'keyence'
i = 0
l = len(num_list)

n = 0

while num_list[i]==key[i]:
    i+=1
    n +=1
    if n==7:
        print('YES')
        exit()

i = -1
while num_list[i]==key[i]:
    n += 1
    i -= 1
    if n==7:
        print('YES')
        exit()
print('NO')

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

#define ii pair<int, int>
#define lli long long int
#define ll pair<lli, lli>
#define pb push_back
#define mp make_pair
#define fi first
#define se second

using namespace std;

int main() {
	int n, ans = 0;
	char s[100];
	scanf("%d %s", &n, s);
	for (int i = 0; i < n - 2; i++)
		if ((s[i] == 'A') && (s[i + 1] == 'B') && (s[i + 2] == 'C'))
			ans++;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}
string YN(bool v) { return v ? "Yes":"No"; }

#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll H,W,A,B;
	while(cin>>H>>W>>A>>B) {
		vector<string> m(H, string(W, ' '));
		string s(W, ' ');
		REP(x, W) s[x]=x+1<=A?'0':'1';
		REP(y, H) {
			if(y==B) REP(x, W) s[x]=s[x]=='0'?'1':'0';
			m[y] = s;
		}
		
		REP(y, H) cout<<m[y]<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 2304
#include <iostream>
#include <cstring>

using namespace std;

const int dxo[]={0,1,1,1,0,-1};
const int dxe[]={-1,0,1,0,-1,-1};
const int dy[]={-1,-1,0,1,1,0};

int mp[102][102]={0};
bool visit[102][102];
int w,h;

int dfs(int x,int y){
    int res=0;
    for(int i=0;i<6;++i){
        int dx = y%2?dxo[i]:dxe[i];
        int tx = x+dx;
        int ty = y+dy[i];
        if(tx>=0&&ty>=0&&tx<=w+1&&ty<=h+1){
            if(mp[ty][tx]==1){++res;continue;}
            if(!visit[ty][tx]){
                visit[ty][tx]=1;
                res +=dfs(tx,ty);
            }
        }
    }
    return res;
}

int main(){
    cin>>w>>h;
    for(int i=1;i<=h;++i){
        for(int j=1;j<=w;++j) cin>>mp[i][j];
    }
    memset(visit,0,sizeof(visit));
    visit[0][0]=1;
    int ans =dfs(0,0);
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3428
import scala.io.StdIn.readInt
 
object Main {
  val r = Array(2,3,5,7)
 
  def twoPow(d:Int,s:Int):(Int,Int) = {
    if(d%2 == 1) (d,s)
    else twoPow(d>>1,s+1)
  }
 
  def maybePrime(i:Int,d:Int,s:Int, n:Int):Boolean = {
    if(i>3) true
    else {
      val a = r(i)
      val x = BigInt(a).modPow(d,n).toLong
 
      if(x==1 || x==n-1) maybePrime(i+1,d,s,n)
      else repeat(s-1,x*x%n, i, d, s, n)
    }
  }
 
  def repeat(j:Int, x:Long, i:Int, d:Int, s:Int, n:Int):Boolean = {
    if(j==0) false
    else if(x==1) false
    else if(x==n-1) maybePrime(i+1,d,s,n)
    else repeat(j-1,x*x%n,i,d,s,n)
  }
 
  def isPrime(n:Int):Boolean = {
    if(n<5000) (2 to Math.sqrt(n).toInt).forall(n%_ != 0)
    else if(n%2==0) false
    else {
      val (d,s) = twoPow(n-1,0)
      maybePrime(0,d,s,n)
    }
  }
 
  def main(args:Array[String]) = {
    val n = readInt
    println((0 until n).count{ _=> isPrime(readInt) })
  }
}

Measured memory_bytes: 57924
#include <iostream>
#include <fstream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <map>
#include <cmath>
#include <queue>

#define DEBUG 0

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;
static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;

//最初に大きいやつを注文する必要がある
//最初の注文からT−0.5分後以降に注文することはできない

// T-1秒のときに、 i 番目を注文する
// 残りでT-1で完食するdp

//DP1[i][j] = 1～i 番目の料理で j 分以内に完食できる美味しさの合計の最大値 
//DP2[i][j] = i～N 番目の料理で j 分以内に完食できる美味しさの合計の最大値

struct Food {
  int minute;
  int taste;
};

bool cmp(const Food &a, const Food &b)
{
    if(a.minute == b.minute)
    {
        return a.taste < b.taste;
    }
    return a.minute < b.minute;
}

Food make_Food(int m, int t) {
    Food myfood = {m, t};
    return myfood;
}

int main(){
  ll N,T;
  cin >> N >> T;

  vector <Food> food(N);

  REP(i,N)
  {
    cin >> food[i].minute >> food[i].taste;
  }

  ll dp1[N+2][T];
  ll dp2[N+2][T];

  REP(i,N+2)
  {
    REP(j, T)
    {
      dp1[i][j] = 0;
      dp2[i][j] = 0;
    }
  }

  //DP1[i][j] = 1～i 番目の料理で j 分以内に完食できる美味しさの合計の最大値 
  for(int i = 0; i < N; ++i)
  {
    for(int j = 0; j < T; ++j)
    {
      if(food[i].minute <= j)
      {
        dp1[i+1][j] = max(dp1[i][j], dp1[i][j-food[i].minute] + food[i].taste);
      }
      else
      {
        dp1[i+1][j] = dp1[i][j];
      }
    }
  }

  //DP2[i][j] = i～N 番目の料理で j 分以内に完食できる美味しさの合計の最大値
  for(int i = N; i >= 1; --i)
  {
    for(int j = 0; j < T; ++j)
    {
      dp2[i][j] = dp2[i+1][j];
      if(food[i-1].minute <= j)
      {
        dp2[i][j] = max(dp2[i+1][j], dp2[i+1][j-food[i-1].minute] + food[i-1].taste);
      }
      else
      {
        dp2[i][j] = dp2[i+1][j];
      }
    }
  }

  ll res = 0;
  //各iをT-1秒に食べたときをシミュレーション
  for(int i = 1; i <= N; ++i)
  {
    for(int j = 0; j <= T-1; ++j)
    {    
      ll tmp = food[i-1].taste;
      tmp += dp1[i-1][j];
      tmp += dp2[i+1][T - 1 - j];

      res = max(res, tmp);
    }
  }

#if DEBUG
  REP(j,T)
  {
    cout << dp1[N][j] << endl;
  }
#endif

  cout << res << endl;

  return 0;    
}



Measured memory_bytes: 140928
#include <iostream>
#include <vector>

#define int long long int
#define MAX_VAL 1000000007

using namespace std;

int getExistingPathsCount(vector<vector<int>> routeVector, int row, int col)
{
    routeVector[0][0] = 1;
    for(int i = 0 ; i < row ; i++)
    {
        for(int j = 0 ; j < col ; j++)
        {
            if(!i && !j)
            {
                continue;
            }
            if(routeVector[i][j] != -1)
            {
                int leftElement   = (j-1 < 0 || routeVector[i][j-1] == -1) ? 0 : (routeVector[i][j-1] % MAX_VAL);
                int rightElement  = (i-1 < 0 || routeVector[i-1][j] == -1) ? 0 : (routeVector[i-1][j] % MAX_VAL);
                routeVector[i][j] = (leftElement + rightElement) % MAX_VAL;
            }
        }
    }
    return routeVector[row-1][col-1];
}

int32_t main()
{
    int                 row;
    int                 col;
    cin>>row>>col;
    vector<vector<int>> routeVector;
    for(int i = 0 ; i < row ; i++)
    {
        vector<int> innerVector;
        for(int j = 0 ; j < col ; j++)
        {
            char element;
            cin>>element;
            innerVector.push_back(element == '.' ? 0 : -1);
        }
        routeVector.push_back(innerVector);
    }
    cout<<getExistingPathsCount(routeVector, row, col)<<endl;
    return 0;
}


Measured memory_bytes: 16000
#include<iostream>
#include<cstdlib>

using namespace std;

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

int INF = 10e8;
int n;
int p[40];
int t[40];
int dp[40][3];
bool allinf;

int main(){
    while(1){
        cin >> n;
        if(n==0) break;

        REP(i, n){
            cin >> p[i];
            cin >> t[i];
        }

        REP(i, n){
            REP(j, 3){
                dp[i][j] = INF;
            }
        }

        if(t[0]>=p[0]){
            dp[0][0] = p[0];
        } else {
            cout << "NG 1" << endl;
            continue;
        }

        REP(i, n-1){
            REP(j, 3){
                if(j==0){
                    REP(k, 3){
                        int time = t[i];
                        time += p[i]*(k+2) + p[i+1];
                        if(time<=t[i+1]){
                            dp[i+1][0] = min(dp[i+1][0], dp[i][k]+p[i]+p[i+1]);
                        }
                    }
                } else {
                    int time = t[i];
                    time += abs(p[i]-p[i+1])*(j+1);
                    if(time<=t[i+1]){
                        dp[i+1][j] = min(dp[i+1][j], dp[i][j-1]+abs(p[i]-p[i+1]));
                    }
                }
            }

            allinf = true;
            REP(j, 3){
                if(dp[i+1][j]<INF){
                    allinf = false;
                }
            }
            if(allinf){
                cout << "NG " << i+2 << endl;
                break;
            }
        }

        if(!allinf){
            int output = INF;
            REP(i, 3){
                output = min(dp[n-1][i], output);
            }
            output += p[n-1];
            cout << "OK " << output << endl;
        }
    }
}

Measured memory_bytes: 3080
#include <bits/stdc++.h>
using namespace std;
typedef  long long ll;
int main(){
    int n;
    int k;
    cin>>n>>k;
    vector <ll> v;
    for (int i=0;i<n;i++)
    {
        ll a;
        cin>>a;
        v.push_back(a);
    }
    sort(v.rbegin(),v.rend());
    ll sum=0;
    for (int i=k;i<n;i++){
    sum+=v[i];
    }
    cout<<sum;
    
    
    
}

Measured memory_bytes: 2420
#include <algorithm>
#include <cassert>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

using namespace std;

#define int long long int
#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(), (x).end()
#define capi(x) int x;cin>>x
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

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;}

signed main() {
    capi(n);
    int v[10][10] = {0};

    int d = 1;
    int r = 1;
    rep(i, n) {
        if (i + 1 >= r * 10) {
            r *= 10;
            ++d;
        }
        ++v[(i + 1) / r][(i + 1) % 10];
    }

    int ans = 0;
    rep(i, 10) {
        rep(j, 10) {
            ans += v[i][j] * v[j][i];
        }
    }

    cout << ans;

    return 0;
}

Measured memory_bytes: 3136
#include <bits/stdc++.h>
#define ll long long
#define INF 0x3f3f3f3f
using namespace std;
const int maxn = 1e3;
int n, k;
int ans;

void read()
{
    cin >> n >> k;
}

void solve()
{
    int h;
    for(int i = 0; i < n; ++i)
    {
        cin >> h;
        if(h >= k)
            ++ans;
    }
    cout << ans << endl;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    read();
    solve();
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;

int main() {
	int h, w;
	cin >> h >> w;
	int cnt = 0;
	char c[55][55];
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			cin >> c[i][j];
		}
	}
	for (int i = 1; i <= h; i++) {
		for (int j = 1; j <= w; j++) {
			if (c[i][j] == '#' && c[i][j - 1] != '#' && c[i - 1][j] != '#' && c[i][j + 1] != '#' && c[i + 1][j] != '#') cnt++;
		}
	}
	if (cnt == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using P=pair<ll,ll>;
#define MOD 1000000007ll
#define INF 1000000000ll
#define EPS 1e-10
#define FOR(i,n,m) for(ll i=n;i<(ll)m;i++)
#define REP(i,n) FOR(i,0,n)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ALL(v) v.begin(),v.end()
#define UNIQUE(v) sort(v.begin(),v.end());v.erase(unique(v.begin(),v.end()),v.end());
#define pb push_back

const P idnt=P(-1,-1);

class segtree {
public:
	segtree (int n) {
		_n=1;
		while(_n<n) _n*=2;
		_dat.resize(2*_n-1);
		for(int i=0;i<2*_n-1;++i) _dat[i]=idnt;
	}
	int size() {
		return _n;
	}
	void update(int k,P a) {
		k+=_n-1;
		_dat[k]=a;
		while(k>0) {
			k=(k-1)/2;
			_dat[k]=max(_dat[k*2+1],_dat[k*2+2]);
		}
	}
	// return the minimum number in [a,b)
	// external call should be written like query(a,b,0,0,_n)
	P query(int a,int b,int k=0,int l=0,int r=-1) {
		if(r==-1) r=_n;
		if(r<=a||b<=l) return idnt;
		if(a<=l&&r<=b) return _dat[k];
		else {
			P vl=query(a,b,k*2+1,l,(l+r)/2);
			P vr=query(a,b,k*2+2,(l+r)/2,r);
			return max(vl,vr);
		}
	}
private:
	int _n;
	vector<P> _dat;
};

vector<ll> marked;
vector<vector<ll>> queried;
vector<ll> dpt;
vector<vector<ll>> adj;
ll n,q;

void dpt_fill(ll pos, ll par, ll d) {
	dpt[pos]=d;
	REP(i,(ll)adj[pos].size()) {
		if(adj[pos][i]==par) continue;
		dpt_fill(adj[pos][i],pos,d+1);
	}
}

ll dfs(ll pos, ll par, segtree& segt) {
	if(marked[pos]!=-1) segt.update(marked[pos],P(dpt[pos],pos));
	ll ret=0;
	REP(i,(ll)queried[pos].size()) {
		P tmp=segt.query(0,queried[pos][i]);
		if(tmp==idnt) ret++;
		else ret+=tmp.second+1;
	}
	REP(i,(ll)adj[pos].size()) {
		if(adj[pos][i]==par) continue;
		ret+=dfs(adj[pos][i],pos,segt);
	}
	if(marked[pos]!=-1) segt.update(marked[pos],idnt);
	return ret;
}

ll solve() {
	marked.assign(n,-1);
	queried.assign(n,vector<ll>(0));
	dpt.assign(n,0);
	adj.assign(n,vector<ll>(0));
	segtree segt(q);
	FOR(i,1,n) {
		ll p;
		cin>>p;
		p--;
		adj[i].pb(p);
		adj[p].pb(i);
	}
	REP(i,q) {
		char ty;
		ll p;
		cin>>ty>>p;
		p--;
		if(ty=='M') if(marked[p]==-1) marked[p]=i;
		if(ty=='Q') queried[p].pb(i);
	}
	dpt_fill(0,-1,0);
	return dfs(0,-1,segt);
}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	while(1) {
		cin>>n>>q;
		if(n==0&&q==0) break;
		cout<<solve()<<endl;
	}
}




Measured memory_bytes: 51628
object Main extends App {
  val n: Int = io.StdIn.readInt()
  val tr: Treap = Empty

  (0 until n).foldLeft[Treap](tr){(t, _) =>
    val op: Array[String] = io.StdIn.readLine().split(" ")
    op(0) match {
      case "print" => t.show; t
      case "insert" => t.insert(op(1).toInt, op(2).toInt)
      case "find" => {
        val key: Int = op(1).toInt
        println(if (t.find(key)) "yes" else "no")
        t
      }
      case "delete" => {
        val key: Int = op(1).toInt
        t.delete(key)
      }
      case _ => throw new Error("Unknown operation")
    }
  }

  trait Treap {
    def priority: Int
    def leftRotate: Treap
    def rightRotate: Treap
    def insert(k: Int, p: Int): Treap
    def delete(k: Int): Treap
    def find(k: Int): Boolean
    def preorder: List[Int]
    def inorder: List[Int]
    def show: Unit = {
      println(" " + this.inorder.mkString(" "))
      println(" " + this.preorder.mkString(" "))
    }
  }
  case object Empty extends Treap {
    def priority: Int = throw new Error
    def leftRotate: Treap = throw new Error
    def rightRotate: Treap = throw new Error
    def insert(k: Int, p: Int): Node = Node(k, p, Empty, Empty)
    def delete(k: Int): Treap = this
    def find(k: Int): Boolean = false
    def preorder: List[Int] = Nil
    def inorder: List[Int] = Nil
  }

  case class Node(key: Int, priority: Int, left: Treap, right: Treap) extends Treap {
    def leftRotate: Treap = right match {
      case Empty => throw new Error
      case Node(k, p, l, r) =>
        Node(k, p, Node(key, priority, left, l), r)
    }
    def rightRotate: Node = left match {
      case Empty => throw new Error
      case Node(k, p, l, r) =>
        Node(k, p, l, Node(key, priority, r, right))
    }
    def insert(k: Int, p: Int): Treap = {
      if (key == k) this
      else if (k < key) {
        val l: Treap = left.insert(k, p)
        val updated: Node = Node(key, priority, l, right)
        if (priority < l.priority) updated.rightRotate
        else updated
      } else {
        val r: Treap = right.insert(k, p)
        val updated: Node = Node(key, priority, left, r)
        if (priority < r.priority) updated.leftRotate
        else updated
      }
    }
    def delete(k: Int): Treap = {
      if (k < key) Node(key, priority, left.delete(k), right)
      else if (k > key) Node(key, priority, left, right.delete(k))
      else (this match {
        case Node(_, _, Empty, Empty) => Empty
        case Node(_, _, Empty, _) => this.leftRotate
        case Node(_, _, _, Empty) => this.rightRotate
        case _ =>
          if (left.priority > right.priority) this.rightRotate
          else this.leftRotate
      }).delete(k)
    }
    def find(k: Int): Boolean = {
      if (k == key) true
      else if (k < key) left.find(k)
      else right.find(k)
    }
    def preorder: List[Int] = key :: (left.preorder ::: right.preorder)
    def inorder: List[Int]  = left.inorder ::: (key :: right.inorder)
  }
}


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
#define ld long double
#define ll long long
#define mod 1000000007
#define IINF INT_MAX
#define INF 1LL << 30


int main() {
    int n, d; cin >> n >> d;
    V<V<int> > v(n, V<int>(d));
    for(int i = 0; i < n; i++){
        for(int j = 0; j < d; j++){
            cin >> v[i][j];
        }
    }

    int ans = 0;
    for(int i = 0; i < n; i++){
        for(int j = i + 1; j < n; j++){
            int sq = 0;
            for(int k = 0; k < d; k++){
                int s = v[i][k] - v[j][k];
                sq += s * s;
            }
            // 小数点切り捨てで1.99999...が2なのに1になる対策
            int s = sqrt(sq) + 0.5;
            if(s * s == sq) ans++;
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3732
#include <iostream>
#include <cmath>
#include <string>

int main(int argc, char *argv[])
{
    int val;
    int count = 0;
    while(std::cin >> val){
        if(val == 0)break;
        std::cout << "Case " << ++count << ": " << val << std::endl;
    }
    return 0;
}

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

int main() {
  char i;
  cin >> i;
  if ( isupper(i) ) {
       cout << "A" << endl;
    } else {
        cout << "a" << endl;
    }
  return 0;

}

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



using namespace std;

typedef long long ll;

ll n, a, b;

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> a >> b;
    if((a - b) & 1)
    {
        ll d = min(a - 1, n - b);
        cout << d + (b - a + 1) / 2;
    }
    else
        cout << (b - a) / 2;
    return 0;
}



Measured memory_bytes: 256
n,w = [int(x) for x in input().split()]
wts = []
vals = []
for i in range(n):
    wi,vi = [int(x) for x in input().split()]
    wts.append(wi)
    vals.append(vi)

dp = []
for i in range(n):
    dp.append([0]*(w+1))

for j in range(w+1):
    if j>=wts[0]:
        dp[0][j] = vals[0]

for i in range(1,n):
    for j in range(w+1):
        if j>=wts[i]:
            dp[i][j] = max(dp[i-1][j],dp[i-1][j-wts[i]]+vals[i])
        else:
            dp[i][j] = dp[i-1][j]

print(dp[n-1][w])


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

int main(){
    int r; cin >> r;
    cout << 3 * r * r << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include <cmath>
using namespace std;
int main()
{
long long int c,a,b,i;
cin>>a>>b;

for(i=0;i<1000000000;i++){
    if((abs(a-i))==(abs(b-i))){
        c++;
        break;
    }
    else{
        c=0;
    }
}
if(c==1){
    cout<<""<<i<<endl;
}
else{cout<<"IMPOSSIBLE"<<endl;}



}


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

int main() {
  int input,rest,h,m,s;
  
  
  cin >> input;
  rest = input % 3600;
  s = rest % 60;
  h = (input - rest) / 3600;
  m = (rest - s) / 60;
  
  printf("%d:%d:%d\n",h, m, s);
  return 0;
}



Measured memory_bytes: 3208
fun main(args: Array<String>) {
    val n = readInt()
    val a = readIntList()

    var ans = 0
    for (i in 0 until n) {
        if ((i + 1) % 2 != 0) {
            if (a[i] % 2 != 0) ans++
        }
    }
    println(ans)
}

// Tools
fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readStringList() = readLine()!!.split(" ")
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)

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

int main(){
	string day[] = {"Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"};
	int month[] = {31,29,31,30,31,30,31,31,30,31,30,31};
	int m, d;
	while(cin>>m>>d){
		if(!m&&!d) break;
		int dsum = 0;
		for(int i=0; i<m-1; i++){
			dsum += month[i];
		}
		dsum += d - 1;
		cout<<day[(dsum+3)%7]<<endl;
	}
	return 0;
}

Measured memory_bytes: 0
import sys

def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

S = LS2()
s = len(S)

dp1 = [0]*s
dp2 = [0]*s
# dp1[i] = 左からi番目までの文字列に対する'K'(但し最後は1文字で分割) 0-index
# dp2[i] = 左からi番目までの文字列に対する'K'(但し最後は2文字で分割) 0-index

for i in range(s):
    if i == 0:
        dp1[i] = 1
        dp2[i] = 0
    elif i == 1:
        if S[i] == S[i-1]:
            dp1[i] = 0
            dp2[i] = 1
        else:
            dp1[i] = 2
            dp2[i] = 0
    else:
        if i >= 3 and S[i-3] == S[i-1] and S[i-2] == S[i]:
            dp2[i] = dp1[i-2]+1
        else:
            dp2[i] = max(dp1[i-2],dp2[i-2])+1

        if S[i] == S[i-1]:
            dp1[i] = dp2[i-1]+1
        else:
            dp1[i] = max(dp1[i-1],dp2[i-1])+1


print(max(dp1[s-1],dp2[s-1]))

Measured memory_bytes: 65136
#!/usr/bin/env python3
import sys
from bisect import bisect_right


def solve(A: int, B: int, Q: int, s: "List[int]", t: "List[int]", x: "List[int]"):
    b, d = bisect_right(s, x), bisect_right(t, x)
    ret = 10e18

    for S in [s[b - 1], s[b]]:
        for T in [t[d - 1], t[d]]:
            d1, d2 = abs(S - x) + abs(T - S), abs(T - x) + abs(S - T)
            ret = min(ret, d1, d2)
    print(ret)


# Generated by 1.1.3 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word

    tokens = iterate_tokens()
    INF = 10e18
    A = int(next(tokens))  # type: int
    B = int(next(tokens))  # type: int
    Q = int(next(tokens))  # type: int
    s = [-INF] + [int(next(tokens)) for _ in range(A)] + [INF]  # type: "List[int]"
    t = [-INF] + [int(next(tokens)) for _ in range(B)] + [INF]  # type: "List[int]"

    for x in range(Q):
        x = int(input())
        solve(A, B, Q, s, t, x)


if __name__ == "__main__":
    main()


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

int main(void){
    int n;
    int b,f,r,v;
    cin >> n;
    int a[4][3][10] = {};

    for(int i=0; i<n; i++){
        cin >> b >> f >> r >> v;
        a[b-1][f-1][r-1] += v;
    }

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


Measured memory_bytes: 3084
#include<iostream>
using namespace std;
const int MAX = 30000;
bool A[10], B[10][10], C[10][10][10];
int main(){
    int n, s, sum = 0;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        char c;
        cin >> c;
        int x = c-'0';
        for (int i = 0; i < 10; i++)
        {
            if (A[i])
            {
                for (int j = 0; j < 10; j++)
                {
                    if (B[i][j])
                    {
                        C[i][j][x] = true;
                    }
                    
                }
                B[i][x] = true;
            }
        }
        A[x] = true;
    }
    for (int i = 0; i < 10; i++)
    {
        for (int j = 0; j < 10; j++)
        {
            for (int k = 0; k < 10; k++)
            {
                sum += C[i][j][k];
            }
            
        }
        
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(iinclude<snt i=sta;i<=n;i++)
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;

int n;
void solve() {
	cin >> n;
	vector<int> a(n);
	rep(i, n)cin >> a[i];
	int chk = -1;
	rep(i, n) {
		if (a[i] == -1) {
			chk = i; break;
		}
	}
	if (chk >= 0) {

		vector<int> ans;
		vector<int> re;
		rep(i, n) {
			if (a[i] == 2) {
				ans.push_back(i);
			}
			if (a[i] == -2) {
				re.push_back(i);
			}
		}
		if (re.size() % 2)ans.push_back(chk);
		rep(i, re.size())ans.push_back(re[i]);
		sort(ans.begin(), ans.end());

		cout << ans.size() << endl;
		rep(i, ans.size()) {
			cout << ans[i]+1 << endl;
		}
	}
	else {
		vector<int> ans;
		vector<int> re;
		rep(i, n) {
			if (a[i] == 2) {
				ans.push_back(i);
			}
			if (a[i] == -2) {
				re.push_back(i);
			}
		}
		if (re.size() % 2)re.pop_back();
		rep(i, re.size())ans.push_back(re[i]);
		sort(ans.begin(), ans.end());
		cout << ans.size() << endl;
		rep(i, ans.size()) {
			cout << ans[i]+1 << endl;
		}
		
	}
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	//stop
		return 0;
}


Measured memory_bytes: 3216
//b.c B-754
#include<stdio.h>
#include<string.h>
#include<stdlib.h>

long iabs(long x){
    if(x<0){
        return -x;
    }
    return x;
}

int main(void){
    long x;
    scanf("%ld",&x);

    long diff = 1000;
    while(x/100!=0){
        if(diff>iabs(753-(x%1000))){
            diff = iabs(753-(x%1000));
        }
        x /= 10;
    }
    printf("%ld\n",diff);
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <math.h>
#include <cmath>

using namespace std;
using ll =long long;
using vi = vector<int>; 
using vvi = vector<vi>; 
using vl = vector<ll>; 
using vvl = vector<vl>; 
using vs = vector<string>;
using vvs = vector<vs>; 
using vc = vector<char>;
using vvc = vector<vc>; 
using vb = vector<bool>;
using vvb = vector<vb>; 

#define rep(i,n) ;for( int i =0; i < n ; i ++)
#define all(a) a.begin(),a.end()
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define f(i,a,b) for(int i=a;i<b;i++)
#define pri(a)  printf("%.14lf\n",a);
#define sz(a) ((int)a.size())
#define MOD 1000000007
bool is_int_lround(double x){
  return std::lround(x)==x;
}
ll keta(ll x){
  ll n=0;
  while(x>0){
    x /=10 ;
    n ++;
  }
  return n;
}

ll conbi(int n,int m){
  
  cin>>n>>m;
  vector<ll> a(100);
  a[0] =1;
  for(int i=0;i<14;i++){
    a[i+1]=a[i]*(i+1);
  }
  return a[n] /(a[m] *a[n-m]);
}

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;//繰り返し二乗法
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
ll kaijoMOD(ll x){
  ll z=1;
  if(x==0){
    return 1;
  }
  while(x>0){
    z *=x;
    z %=MOD;
    x--;
  }
  return z;
}
ll div_num(ll n){
  vl div(n+1,1);
  for(ll i=2;i*i<=n;i++){ 
    while(n%i==0){
      n /=i;
      div[i]++;
    }
  }
  if(n!=1)div[n]++;
  ll num=1;
  for(ll i=0;i<=n;i++){
    num*=div[i];
  }
  return num;
}
vector<ll> divisor(ll n) {
  vector<ll> ret;
  for(ll i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}


int keta_wa(int x){
  int tot=0;
  while(x>0){
    tot +=x%10;
    x/=10;
  }
  return tot;
}
vl a(51),p(51);
ll dfs(ll n, ll x){
  if(n==0&& x==1)return 1;
  if(x==0)return 0;
  if(n!=0&&x==1)return 0;
  
  if(x<=a[n]/2) return dfs(n-1,x-1);
  else if(x==a[n]/2+1)return p[n-1]+1;
  else if(x>a[n]/2+1&&x<a[n]) return dfs(n-1,x-a[n]/2-1)+1+p[n-1];
  else if(x==a[n])return p[n];
}


//vc alp ={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
//vc Alp ={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
//cout<<""<<endl;
int main(){
  ll N,X;cin>>N>>X;
  
  a[0]=1;p[0]=1;
  rep(i,N){
    a[i+1]=2*a[i]+3;
    p[i+1]=2*p[i]+1;
  }
  cout<<dfs(N,X)<<endl;
  
  
}







Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define ll long long
#define x first
#define y second

int main()
{
	ios_base::sync_with_stdio(0);
	string s;
	cin >> s;
	cout << ((s[3] == s[2] && s[4] == s[5]) ? "Yes" : "No");
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long ll;
using namespace std;

vector<int> to[200005];
vector<int> ans;

void dfs(int v,int p=-1){
  for(int b : to[v]){
    if(b==p)continue;
    ans[b] += ans[v];
    dfs(b,v);
  }
}

int main(){
  int n,q;
  cin >> n >> q;
  rep(i,n-1){
    int a,b;
    cin >> a >> b;
    a--; b--;
    to[a].push_back(b);
    to[b].push_back(a);
  }
  ans.resize(n);
  rep(i,q){
    int p,x;
    cin >> p >> x;
    p--;
    ans[p] += x;
  }
  dfs(0);
  rep(i,n) cout << ans[i] << endl;
}


Measured memory_bytes: 23424
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int numM = scan.nextInt();
		int numD = scan.nextInt();

		int result = 0;
		for (int i = 4; i <= numM; i++) {
			for (int j = 22; j <= numD; j++) {
				int k = j % 10;
				int l = j / 10;
				if (k > 1 && i == k * l) {
					result++;
				}
			}
		}

		System.out.println(result);
	}
}


Measured memory_bytes: 21844
import java.io.*;
import java.util.NoSuchElementException;

public class Main {

    public static void main(String[] args) {
        FastScanner fs = new FastScanner();
        int a = fs.nextInt();
        int b = fs.nextInt();
        if( 10 <= a || 10 <= b ){
            System.out.println( -1 );
            return;
        }
        System.out.println( a * b );
    }

    static class FastScanner {
        private final InputStream in = System.in;
        private final byte[] buffer = new byte[1024];
        private int ptr = 0;
        private int buflen = 0;

        private boolean hasNextByte() {
            if (ptr < buflen) {
                return true;
            } else {
                ptr = 0;
                try {
                    buflen = in.read(buffer);
                } catch (IOException e) {
                    e.printStackTrace();
                }
                if (buflen <= 0) {
                    return false;
                }
            }
            return true;
        }

        private int readByte() {
            if (hasNextByte()) {
                return buffer[ptr++];
            } else {
                return -1;
            }
        }

        private static boolean isPrintableChar(int c) {
            return 33 <= c && c <= 126;
        }

        public boolean hasNext() {
            while (hasNextByte() && !isPrintableChar(buffer[ptr])) {
                ptr++;
            }
            return hasNextByte();
        }

        public String next() {
            if (!hasNext()) {
                throw new NoSuchElementException();
            }
            StringBuilder sb = new StringBuilder();
            int b = readByte();
            while (isPrintableChar(b)) {
                sb.appendCodePoint(b);
                b = readByte();
            }
            return sb.toString();
        }

        public long nextLong() {
            if (!hasNext()) {
                throw new NoSuchElementException();
            }
            long n = 0;
            boolean minus = false;
            int b = readByte();
            if (b == '-') {
                minus = true;
                b = readByte();
            }
            if (b < '0' || '9' < b) {
                throw new NumberFormatException();
            }
            while (true) {
                if ('0' <= b && b <= '9') {
                    n *= 10;
                    n += b - '0';
                } else if (b == -1 || !isPrintableChar(b)) {
                    return minus ? -n : n;
                } else {
                    throw new NumberFormatException();
                }
                b = readByte();
            }
        }

        public int nextInt() {
            long nl = nextLong();
            if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE) {
                throw new NumberFormatException();
            }
            return (int) nl;
        }

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


Measured memory_bytes: 21204
"      ",
  " abcde",
  " fghij",
  " klmno",
  " pqrst",
  " uvwxy",
  " z.?! "
};

main(f,i,j){
  char s[201],z[101];
  for(;~scanf("%s",s);){
    if(strlen(s)&1){puts("NA");goto l;}
    for(i=0;i<strlen(s)/2;i++){
      if(!('1'<=s[2*i]&&s[2*i]<='6'&&'1'<=s[2*i+1]&&s[2*i+1]<='5')){puts("NA");goto l;}
      z[i]=m[s[2*i]-'0'][s[2*i+1]-'0'];
    }
    z[i]=0;
    puts(z);
    l:;
  }
  return 0;
}

Measured memory_bytes: 0
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();
    let n: usize = iter.next().unwrap().parse().unwrap();
    let r: usize = iter.next().unwrap().parse().unwrap();

    let mut ans = r;

    if n < 10 {
        ans += 100 * (10 - n);
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
#define W(x) cout << #x << " = " << x << endl;
#define pii pair<int, int>
#define ff first
#define ss second
#define ll long long
#define sort(x) sort(x.begin(), x.end())
using namespace std;



int main(){
	vector<pii> in(3);
	vector<int> vet(4, 0);
	for(auto&p:in){
		cin >> p.ff >> p.ss;
		vet[p.ff-1]++;
		vet[p.ss-1]++;
	}
	sort(vet);
	if(
	  vet[0] == 1 &&
	  vet[1] == 1 &&
	  vet[2] == 2 &&
	  vet[3] == 2
	){
		cout << "YES\n";
	} else{
		cout << "NO\n";
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
typedef long long ll;
using namespace std;

int main(){
	ll N,A,B;
	cin >> N >> A >> B;
	ll D = abs(A-B);
	if(D%2){
		cout << "Borys\n";
	}
	else cout << "Alice\n";
}


Measured memory_bytes: 256