akhauriyash/Code-Regression huggingface dataset:
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

template <typename T>
void print_vec(const vector<T>& v, bool is_reverse=false, ll num=0){
  if(num == 0) num = (ll)v.size();
  cout << endl; cout << "i=  ";for(ll i=0; i<num; i++) cout << i << "   ";cout << endl;  
  cout << "    ";
  if(is_reverse) for(ll i=num-1; i>=0; i--){ cout<<v[i]; if(i!=0) cout<<"   ";}
  else for(ll i=0; i<num; i++){ cout<<v[i]; if(i!=num-1) cout<<"   ";}
  cout << endl;
}

// template <typename T>
// void print_pairvec(const vector<T> &v, ll num=0){
//   if(num == 0) num = (ll)v.size();
//   cout << endl; for(ll i=0; i<num; i++){ cout << v[i].first << " " << v[i].second << endl;}
// }
template <typename T>
void print_pairvec(const T &_pair, ll num=0){
  cout << endl; for(pair<ll, int> x: _pair){ cout << x.first << " " << x.second << endl;}
}

template <typename T>
void print_vec2(const vector<vector<T>>& v){
  cout << endl; cout << "       ";
  for(ll i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(ll i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(ll j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}

struct Eratosthenes{
  vector<ll> sieve;// sieve[i]: 数字iがエラトステネスで篩落とされた時の素数

  Eratosthenes(ll n): sieve(n+1){
    for(int i=0; i<=n; i++) sieve[i] = i;
    for(ll i=2; i*i<=n; i++){
      if(sieve[i] < i) continue;
      for(ll j=i*i; j<=n; j+=i) sieve[j] = min(sieve[j], i);
    } 
  }

  vector<ll> prime_divisors(ll x, bool tmp=false){
    vector<ll> res(1,1);//back()のところで ひっかかるので1を入れとかないとダメ
    while(x > 1){
      if(res.back() != sieve[x]) res.push_back(sieve[x]);
      x /= sieve[x];
    }
    return res;
  }

  map<ll, int> prime_divisors(ll x, int tmp=0){
    map<ll, int> mp;
    while(x > 1){
      mp[sieve[x]]++;
      x /= sieve[x];
    }
    return mp;
  }
};


// GCD, LCM
// https://youtu.be/8lm8o8L9Bmw?t=2285
// https://youtu.be/XI8exXVxZ-Q?t=3595
// https://youtu.be/F2p_e6iKxnk?t=843
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
int main(){
  int N;
  cin >> N;
  vector<int> A(N);
  for(int i=0; i<N; i++) cin >> A[i];

  ll g = A[0];
  for(int i=0; i<N; i++) g = gcd(g, A[i]);
  if(g != 1){
    cout << "not coprime" << endl;
    return 0;
  }

  const ll INF = 1e6;
  Eratosthenes era(INF);
  map<ll, int> mp;
  for(int i=0; i<N; i++){
    vector<ll> vec = era.prime_divisors(A[i], false);
    for(int prime : vec){
      if(prime == 1) continue;
      if(mp[prime] == 0) mp[prime]++;
      else{
        cout << "setwise coprime" << endl;
        return 0;
      }
    }
  }
  cout << "pairwise coprime" << endl;
  return 0;
}


Measured memory_bytes: 16188
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 0x3f3f3f3f
const int N=102,M=10010,mod=998244353;
ll n,m,T,k,cnt,x,y,z,indx,t,ans;
int main()
{
	scanf("%lld",&n);
	n=n%1000;
	n=1000-n;
	if (n==1000) n=0;
	printf("%lld\n",n);
}

Measured memory_bytes: 3784
function gets(str){
  this._s = str.split("\n");
  this._y = 0;
};
gets.prototype = {
  a: function(f){
    var s = this._s, y = this._y, r;
    if(typeof s[y] === "string")s[y] = s[y].split(" ").reverse();
    r = s[y].pop();
    if(!s[y].length)this._y++;
    return f?r:+r;
  },
  l: function(f){
    var s = this._s[this._y++].split(" ");
    return f?s:s.map(a=>+a);
  },
  m: function(n,f){
    var s = this._s, y = this._y, r = [], i = 0;
    if(f)for(;i < n; i++)r[i] = s[y+i].split(" ");
    else for(;i < n; i++)r[i] = s[y+i].split(" ").map(a=>+a);
    this._y += n;
    return r;
  },
};
var o=new gets(require("fs").readFileSync("/dev/stdin","utf8"));

function inv(a){
  this._a = Array(a).fill(0);
}
inv.prototype = {
  u:function(x,w){for(;x<this._a.length;x+=x&-x)this._a[x]+=w;},
  q:function(x){for(var r=0;x;x-=x&-x)r+=this._a[x];return r;},
}

console.log(main());
function main(){
  var n = o.a();
  var a = o.l();
  if(n <= 2)return Math.max(...a);
  var p = Math.floor(n * (n+1) / 4 + 1);
  var l = 2, r = 1e9+1;
  while(l < r){
    var m = l + r >> 1;
    var b = n+1, k = 0, z = new inv(b*2);
    z.u(b,1);
    for(var i = 0; i < n; i++){
      k += z.q(a[i] < m ? --b : ++b);
      z.u(b,1);
    }
    k = n * (n+1) / 2 - k;
    if(k < p)l = m+1; else r = m;
  }
  return l-1;
}

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

int main()
{
    int n,tt,i;

    cin>>n>>tt;
    int c[n],t[n];
    vector< pair<int,int> >pa;
    for(i=0;i<n;i++){
        cin>>c[i]>>t[i];
        pa.push_back(make_pair(c[i],t[i]));
    }
    sort(pa.begin(),pa.end());
    bool ck=false;
    for(i=0;i<n;i++){
        if(pa[i].second<=tt){
            ck=true;
            cout<<pa[i].first<<endl;
            break;
        }
    }
    if(!ck){
        cout<<"TLE"<<endl;
    }

    return 0;
}


Measured memory_bytes: 256
// author:  Harsh Nema
#include <bits/stdc++.h>
#define ll long long int
#define F first
#define S second
const ll mod = 1e9 + 7;
const ll INF = 10000000000000;
#define pb push_back
#define deb(x) cout << '>' << #x << ':' << x << endl;
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;
int main()
{
    fastio;
    ll n=0,m=0;
    cin>>n>>m;
    ll ar[m]={0};
    ll s=0;
    for(ll i=0;i<m;++i) cin>>ar[i],s+=ar[i];
    if(s>   n)cout<<"-1";
    else cout<<n-s;
    return 0;
}


Measured memory_bytes: 3692
#include <bits/stdc++.h>
 using namespace std;
 #define REP(i, a, n) for(int i=a; i<n; i++) //(i, 0, n)でi=0~n-1までn回
 #define sortv(v) sort(v.begin(), v.end());
 #define sortg(v) sort(v.begin(), v.end(), greater<>());
 #define rev(v) reverse(v.begin(), v.end());
 
 int main() {
   int r, d;
   cin >> r >> d;
   if(r<6) cout << '0' << endl;
   if(r>5 && r<13) cout << d/2 << endl;
   if(r>12) cout << d <<endl;
 }


Measured memory_bytes: 256
N = int(input())

def func(s):

    if int(s) > N:
        return 0

    if all(s.count(c) > 0 for c in "753"):
        count = 1
    else:
        count = 0

    for c in "753":
        count += func(s+c)    

    return count

print(func("0"))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;

int main(){
    int n;
    cin >> n;
    double ans = 0;
    if (n % 2 == 0) cout << double(1)/2 << endl;
    else cout << double(n + 1)/ (2 * n) << endl;
    return 0;
}

Measured memory_bytes: 256
n,m,c = map(int,input().split(' '))

#print(n,m,c)
blist = list(map(int,input().split(' ')))
count_t = 0

for i in range(n):
  nlist=list(map(int,input().split(' ')))
  bn = 0
  for j in range(m):
    bn += blist[j]*nlist[j]
#    print("+", blist[j],"*",nlist[j],":", bn)
  if (bn + c) > 0:
    count_t += 1
print(count_t)

    


Measured memory_bytes: 3060
#include <stdio.h>

class Date{
public:
	int y;
	int m;
	int d;
	
	Date(int y, int m, int d){
		this->y =y; this->m = m; this->d = d;
	}
	int cmp(Date d2){
		if (this->y < d2.y) return -1;
		if (this->y > d2.y) return 1;
		if (this->m < d2.m) return -1;
		if (this->m > d2.m) return 1;
		if (this->d < d2.d) return -1;
		if (this->d > d2.d) return 1;
		return 0;
	}
	int cmp(int y, int m, int d){
		Date *tmp = new Date(y,m,d);
		return cmp(*tmp);
	}
};



int main(void){
	int y,m,d;
	
	while (scanf("%d%d%d",&y,&m,&d)!=EOF){
		Date *date = new Date(y,m,d);
		if (date->cmp(1868,9,8) == -1){
			puts("pre-meiji");
		} else if (date->cmp(1912,7,30) == -1){
			printf("meiji %d %d %d\n", y-1868+1, m, d);
		} else if (date->cmp(1926,12,25) == -1){
			printf("taisho %d %d %d\n", y-1912+1,m,d);
		} else if (date->cmp(1989,1,8) == -1){
			printf("showa %d %d %d\n", y-1926+1,m,d);
		} else {
			printf("heisei %d %d %d\n", y-1989+1,m,d);
		}
		delete date;
	}
	
	return 0;
}

Measured memory_bytes: 1040
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<cmath>
#include<iomanip>
#include<set>
#include<string>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
//const int inf = 1e9 + 7;

int main() {
    int n; cin >> n;
    int flg = 0;
    int bef = 0;
    int ans = 0;
    rep(i, n) {
        int a; cin >> a;
        if (a == bef) {
            if (flg == 0) {ans++; flg = 1;}
            else flg = 0;
        } else {
            flg = 0;
        }
        bef = a;
    }
    cout << ans << endl;
    
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>

int main()
{
	int N, K;
	static int p[1000];
	scanf("%d%d", &N, &K);
	for (int i = 0; i < N; i++) {
		scanf("%d", &p[i]);
	}
	std::sort(p, p + N);

	int ans = 0;
	for (int i = 0; i < K; i++) {
		ans += p[i];
	}
	printf("%d\n", ans);

	return 0;
}


Measured memory_bytes: 1732
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
#define all(x) (x).begin(), (x).end()
 
using namespace std;

int nxt() {
    int x;
    cin >> x;
    return x;
}

ll nxtl(){
    ll x;
    cin>>x;
    return x;
}
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n=nxtl(),x=nxtl();
    vector <ll> v(n);
    generate(all(v),nxt);
    ll test=0;
    for(int i=1;i<n;i++)
    {
        ll temp=min(max(v[i-1]+v[i]-x,0),v[i]);
        v[i]-=temp;
        test+=temp;
        temp=min(max(v[i-1]+v[i]-x,0),v[i-1]);
        v[i-1]-=temp;
        test+=temp;
    }
    cout<<test<<endl;
    return 0;   
}




 
 


Measured memory_bytes: 1024
from collections import defaultdict
N = int(input())
a = list(map(int,input().split()))
dic = defaultdict(int)
for x in a:
    dic[x] += 1
ans = 0
for x,c in dic.items():
    if c < x:
        ans += c
    elif c > x:
        ans += c-x
print(ans)

Measured memory_bytes: 22448
#include <stdio.h>

int main(void){
	int n,k,i;
	int p[100][2];
	double menseki=0.0;
	scanf("%d",&n);
	
	for(i=0;i<n;i++){
		scanf("%d %d",&p[i][0],&p[i][1]);
	}
	
	for(i=0;i<n;i++){
		menseki+=(double)((p[i][0]-p[(i+1)%n][0])*(p[i][1]+p[(i+1)%n][1]));
	}
	printf("%.1lf\n",menseki/2.0);
	return 0;
}

Measured memory_bytes: 640
N, M = map(int, input().split())

if N >= 3 and M >= 3:
    print((N - 2) * (M - 2))
elif N == 2 or M == 2:
    print(0)
elif N == 1 and M == 1:
    print(1)
elif N == 1 or M == 1:
    print(N*M - 2)

Measured memory_bytes: 3060
num=[]
while True:
    num.append(list(map(int,input().split(" "))))
    if num[-1]==[0,0]:
        num=num[:-1]
        break
def sample(lst):
    tmp=0
    for i in range(1,lst[0]+1):
        for j in range(i,lst[0]+1):
            for k in range(j,lst[0]+1):
                if i+j+k==lst[1] and i!=j and j!=k:
                    tmp+=1
    return tmp
ans=[sample(i)for i in num]
for i in ans:
    print(i)


Measured memory_bytes: 5604
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
# define ll int64_t
# define str string
# define rep(i,n) for(ll i=0;i<n;i++)
# define rrep(i,n) for(ll i=1;i<=n;i++)
# define ALL(x) (x).begin(), (x).end()
# define SZ(x) ((int)(x).size())
# define pb push_back
# define mod 1000000007
# define PI 3.141592653589793
# define vec vector
#define dump(x) cerr<<#x<<"="<<x<<endl
using namespace std;

#define INF 2000000000
#define MAX_V 10



bool compare_by_b(pair<string,ll> a,pair<string,ll> b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

bool my_compare(pair<string,ll> a,pair<string,ll> b){
    if(a.first != b.first) return a.first<b.first;
    if(a.second != b.second) return a.second>b.second;
    else return true;
}

ll modpow(ll a,ll n,ll mod1) {
    ll res=1;
    while(n>0){
        if(n&1) res=res*a%mod1;
        a = a*a%mod1;
        n >>= 1;
    }
    return res;
}

ll factorial(ll n){
    ll x=1;
    rrep(i,n) (x*=i)%=mod;
    return x;
}

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

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

using graph = vector<vector<ll>>;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    ll n;
    cin>>n;
    set<double> num;
    ll a=2;
    double m=n;
    while(m>=a*a){
        if(n%a==0){
            num.insert(a);
            n /= a;
        }else a++;
    }
    if(n!=1) num.insert(n);
    for(auto x:num){
        m *= (1 - 1/x);
    }
    cout<<fixed<<setprecision(0)<<m<<endl;
    return 0;
}



Measured memory_bytes: 3304
#include<bits/stdc++.h>
using namespace std;
using LL = int64_t;
const int maxn=1e5+5;
const int mod=1e9+7;
const int INF=0x3f3f3f3f;
const LL LLINF=1e14;
const double pi=acos(-1.0);
char node[100][100];
bool vis[105][105];
int cur[4][2]={1,0,-1,0,0,1,0,-1};
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);

    int n,m;cin>>n>>m;
    for(int i=1;i<=n;i++) {
        for(int j=1;j<=m;j++) {
            cin>>node[i][j];
        }
    }
    for(int i=1;i<=n;i++) {
        for(int j=1;j<=m;j++) {
            if(node[i][j]!='#') continue;
            for(int k=0;k<4;k++) {
                int tx=i+cur[k][0],ty=j+cur[k][1];
                if(node[tx][ty]=='#') break;
                if(node[tx][ty]!='#'&&k==3) {cout<<"No";return 0;}
            }
        }
    }
    cout<<"Yes";
    return 0;
}


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

typedef long long ll;
typedef unsigned long long ull;
//typedef long double ld;

typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<pair<int, int > > vii;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;

constexpr ll MOD = 1e9+7;
constexpr int INF = 1<<30;
constexpr ll  LINF = 1LL<<60;

#define Sort(x) sort(x.begin(),x.end())
#define Reverse(x) reverse(x.begin(),x.end())
#define ABS(a,b) ((a)<(b)?(b)-(a):(a)-(b))
#define nbit(n) (1ll<<(n))

// sort(begin(x), end(x), greater<ll>());
// lower_bound(a.begin(), a.end(), val): a[i] ≥ valである最左の位置
// upper_bound(a.begin(), a.end(), val): a[i] > valである最左の位置

// Returns minimum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}

// Returns maximum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}

// a = (a+b)%MOD;
void addmod(ll& a, ll b) {
  a = (a+b)%MOD;
}

template <typename T>
void dumpContents(const T& v, const string& msg)
{
  cerr << "### " << msg << " ###\n";
  for (const auto& x : v) {
    cerr << x << " ";
  }
  cerr << endl;
}

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
    #define endl "\n"
  }
} before_main_function;




// ========== end of template ==========
constexpr int N_MAX=300;
int N;

struct Edge {
  int u,v;
  ll cost;

  Edge(int u_, int v_, ll cost_)
    : u(u_), v(v_), cost(cost_)
  {}
};

vector<Edge> edges;

vvll A(N_MAX, vll(N_MAX));
vvll M(N_MAX, vll(N_MAX));

int main(int argc, char** argv) {
  cin >> N;

  for (int i=0; i<N; i++) {
    for (int j=0; j<N; j++) {
      cin >> A[i][j];
      M[i][j] = A[i][j];

      if (i>j) {
        edges.emplace_back(i, j, A[i][j]);
      }
    }
  }

  // Warshall-Froid
  for (int k=0; k<N; k++) {
    for (int i=0; i<N; i++) {
      for (int j=0; j<N; j++) {
        M[i][j] = min({M[i][j], M[i][k]+M[k][j]});
      }
    }
  }

  sort(begin(edges), end(edges),
       [](const Edge& lhs, const Edge& rhs) {
         return lhs.cost < rhs.cost;
       });

  ll ret = 0;

  for (auto e : edges) {
    int i = e.u;
    int j = e.v;

    assert(e.cost == A[i][j]);

    if (M[i][j] < A[i][j]) {
      cout << -1 << endl;
      return 0;
    }

    assert(M[i][j] == A[i][j]);

    // minimum path that does not use {i,j}
    ll walkaround = INF;
    for (int k=0; k<N; k++) {
      if (k==i || k ==j) {
        continue;
      }
      walkaround = min({walkaround, M[i][k] + M[k][j]});
    }

    if (walkaround > M[i][j]) {
      // required
      ret += M[i][j];
    }
  }


  // cerr << "*** ret " << ret << endl;
  // cerr << "***M***\n";
  // for (int i=0; i<N; i++) {
  //   for (int j=0; j<N; j++) {
  //     cerr << M[i][j] << " ";
  //   }
  //   cerr << endl;
  // }

  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 2936
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <sstream>
#include <algorithm>
#include <deque>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <list>
#include <cstdio>
#include <iostream>
#include <cmath>
#include <climits>
#include <bitset>
#include <functional>
#include <numeric>
#include <ctime>
#include <cassert>
#include <cstring>
#include <fstream>

#define FOR(i, a, b) for(int (i)=(a); (i)<(b); (i)++)
#define IFOR(i, a, b) for(int (i)=(a);(i)<=(b);(i)++)
#define RFOR(i, a, b) for(int (i)=(a);(i)>=(b);(i)--)

using namespace std;

const int MOD = 1e9 + 7;

int main() {
	int n;
	cin >> n;
	vector<int> t(n), a(n);
	FOR(i, 0, n) {
		cin >> t[i];
	}
	FOR(i, 0, n) {
		cin >> a[i];
	}
	a.push_back(-1);

	if (!is_sorted(t.begin(), t.end()) || !is_sorted(a.begin(), a.end(), greater<int>())) {
		cout << 0 << endl;
		return 0;
	}

	long long res = 1;
	int before = -1;
	bool valid = true;
	// from west to east scan
	FOR(i, 0, n) {
		if (t[i] > before) {
			valid = (a[i] > a[i + 1] && a[i] == t[i]) || (a[i] == a[i + 1] && a[i] >= t[i]);
			if (!valid)
				break;
			before = t[i];
		}
		else {
			valid = (a[i] > a[i + 1] && a[i] <= t[i]) || a[i] == a[i + 1];
			if (!valid)
				break;
			if (a[i] == a[i + 1]) {
				res = (res * min(a[i], t[i])) % MOD;
			}
			before = t[i];
		}
	}

	cout << (valid ? res : 0) << endl;
	
	return 0;
}

Measured memory_bytes: 1408
//コードフェスティバル予選A　C問題
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;

double EPS = 1e-10;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define int(x) int x; cin >> x;
#define lint(x) long long x; scanf("%lld",&x);
#define vint(v,n) vector<int> v(n); rep(i,n) scanf("%d", &v[i]);
#define vlint(v,n) vector<lint> v(n); rep(i,n) scanf("%lld", &v[i]);
#define double(x) double x; scanf("%lf",&x);
#define vdouble(v,n) vector<double> v(n); rep(i,n) scanf("%lf", &v[i]);
#define string(x) string x; cin >> x;

int main()
{
	string(s);
	int(K);
	int count = 0,tempCount;
	const int numOfalph = 26;

	REP(i, s.length())
	{
		tempCount = numOfalph - (int)(s[i] - 'a');
		if (s[i] == 'a' && (i + 1) != s.length())
		{
			continue;
		}
		else if (tempCount + count > K)
		{
			if ((i + 1) == s.length())
			{
				if ((s[i] + (K - count)) > 'z')
					s[i] = 'a' + ((K - count) - ('z' - s[i]));
				else
					s[i] = s[i] + (K - count);
				count += (K - count);
			}

			continue;
		}

		s[i] = 'a';
		count += tempCount;
	}

	if (count < K)
	{
		s[s.length() - 1] += (K - count) % numOfalph;
	}

	cout << s << endl;

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define RREP(i,b,e) for(int i=(b)-1;i>=e;--i)
#define rep(i,e) for(int i=0;i<(e);++i)

inline void print(void) { cout<<'\n'; }
template<class T> inline void print(const T &x) { cout<<x<<'\n'; }
template<class T, class... U> inline void print(const T &x, const U&... y) { cout<<x<<" "; print(y...); }

int main() {
  int n; cin>>n;
  vector<vector<int>> xyh(n, vector<int>(3));
  rep(i, n) cin>>xyh[i][0]>>xyh[i][1]>>xyh[i][2];
  rep(x, 101) rep(y, 101) {
    int h = -1;
    bool good = true;
    rep(i, n) if (xyh[i][2] != 0) {
      int ht = xyh[i][2] + abs(x - xyh[i][0]) + abs(y - xyh[i][1]);
      if (h != -1 and ht != h) good = false;
      h = ht;
    }
    if (good) {
      bool good2 = true;
      rep(i, n) {
        if (xyh[i][2] != max(h - abs(x - xyh[i][0]) - abs(y - xyh[i][1]), 0)) {
          good2 = false;
        }
      }
      if (good2) {
        print(x, y, h);
        return 0;
      }
    }
  }

  return 0;
}

Measured memory_bytes: 256
k = int(input())
#逆からシュミレートしていく
#これが、一番最後の形
array = [i for i in range(50)]
#50回単位で考えると、全ての要素が1増える操作となる
#つまり、k // 50を全てに足してあげるとほぼk回やった感じになる
plus = k // 50
rem = k % 50
for i in range(50):
    array[i] += plus
for i in range(rem):
    array[i] += 51
    for j in range(50):
        array[j] -= 1
print(50)
print(" ".join(map(str, array)))



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

using namespace std;

int main()
{
  int N;
  cin >> N;
  string S;
  cin >> S;
  int K;
  cin >> K;

  for (int i = 0; i < N; i++) {
	if (S[i] != S[K - 1])
	  cout << '*';
	else
	  cout << S[i];
  }
  cout << endl;
  
  return 0;
}


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

using namespace std;

template<typename T> 
void show(T a){
  for(auto i : a){ cout << i << " "; }
  cout << endl;
}


int main(int argc, char *argv[]){
  ios::sync_with_stdio(false);
  cin.tie(NULL);
  
  string str;
  cin >> str;
  string key = "keyence";
  
  if(str.size() < key.size()){
    cout << "No" <<endl;
    return 0;
  }
  
  int i = 0;
  for(; i < key.size(); i++){
    if(str[i] != key[i]) break;
  }
  int j = 0;
  for(; j < key.size(); j++){
    if(str[str.size()-j-1] != key[key.size()-j-1]) break;
  }
  
  //cout << i << " " << j << endl;
  if(i + j >= key.size())
    cout << "YES" << endl;
  else  
    cout << "NO" << endl;

}


Measured memory_bytes: 256
fun main() {
    val XN = readLine()!!.split(" ").map { it.toInt() }
    val X = XN[0]
    val N = XN[1]
    var answer = 0
    if (N > 0) {
        val ps = readLine()!!.split(" ").map { it.toInt() }
        for (i in 0..100) {
            if (!ps.contains(X - i)) {
                answer = X - i
                break
            } else if (!ps.contains(X + i)) {
                answer = X + i
                break
            }
        }
    } else {
        val b= readLine()!!
        answer = X
    }

    println(answer)
}

Measured memory_bytes: 36592
import math
def ip():return int(input())
def inp():return map(int,input().split())
def linp():return list(map(int,input().split()))

n=int(input())
g=n%10
s=n//10%10
b=n//100%10
q=n//1000%10
if g==s or s==b or b==q:print("Bad")
else:print("Good")


Measured memory_bytes: 3060
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner s = new Scanner(System.in);
			int a = s.nextInt();
			int b = s.nextInt();
			int c = s.nextInt();
			int d = s.nextInt();
			int start;
			int end;
			if(a < c){
				start = c;
       		}else{
                start = a;
        	}
      		if(b < d){
				end = b;
      		}else{
        		end = d;
      		}
      		if(start < end){
				System.out.println(end - start);
      		}else{
				System.out.println("0");
            }
	}
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

// 出力
void print() { std::cout << '\n'; }
template <class T>void print(const T &x) {std::cout << x <<'\n';}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}

void solve(long long N, std::vector<long long> A){
    int countE = 0;
    int count = 0;
    REP(i, A.size()) {
        if (A[i] % 2 == 0) {
            countE++;
            if (A[i] % 3 == 0 || A[i] % 5 == 0)
                count++;
        }
    }
    if (countE == count) print("APPROVED");
    else print("DENIED");
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    solve(N, std::move(A));
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define se second
#define fi first
#define ll long long
#define INF INT_MAX
#define mod 1000000007
#define chutiyaap ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
using namespace std;
int main()
{
	int n;cin>>n;
	int x=n%10;
	if(x==3)cout<<"bon";
	else if(x==0||x==1||x==6||x==8)cout<<"pon";
	else cout<<"hon";
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <iterator>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <string>
#include <cmath>
using namespace std;
#define MOD 1000000007
#define INF 1<<30
#define LINF (ll)1<<62
#define MAX 510000
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(),(x).end()
#define uni(q) unique(all(q)),q.end()
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll, ll> P;
typedef vector<pair<ll, ll>> vpl;

vvl G(10);
bool visit[10];
ll cnt = 0;
ll n,m;

void dfs(ll u){
    if(visit[u]) return;
    visit[u] = true;
    for(auto v : G[u]){
        if(visit[v]) continue;
        dfs(v);
    }
    bool flag = true;
    rep(i,n){
        if(!visit[i]){
            flag = false;
            break;
        }
    }
    if(flag) cnt++;
    visit[u] = false;
}

int main(){
	cin >> n >> m;
    rep(i,m){
        ll a,b; cin >> a >> b;
        a--;  b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    dfs(0);
    cout << cnt << endl;
}

Measured memory_bytes: 256
import java.io.{BufferedReader, InputStreamReader}

object Main {
  def main(args: Array[String]): Unit = {
    val in = new BufferedReader(new InputStreamReader(System.in))
    val _ = in.readLine().toInt
    val bs = in.readLine().split("\\s+").map(_.toInt)

    System.out.println(
      bs.head + bs.zip(bs.tail).map {
        case (b1, b2) => Math.min(b1, b2)
      }.sum + bs.last
    )
  }
}


Measured memory_bytes: 27216
#include<iostream>

using namespace std;

int main() {
    while(1){
      int n;
      cin >> n;
      if(n==0) break;
      int min = 1000000;
      int fee;
      for(int a=0;a<=n/200+1;a++){
	for(int b=0;b<=n/300+1;b++){
	  for(int c=0;c<=n/500+1;c++){
	    if(a*200+b*300+c*500==n){
	      fee=a*380+b*550+c*850;
	    if(a>=5) fee+=((a/5)*5*380)*0.8-(a/5*5*380);
	  if(b>=4) fee+=((b/4)*4*550)*0.85-(b/4*4*550);
	if(c>=3) fee+=((c/3)*3*850)*0.88-(c/3*3*850);
      if(min>fee) min=fee;
	    }
	  }
	}
      }	
      cout << min <<endl;
     } 
   return 0;
    }



Measured memory_bytes: 2984
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ll long long
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i, a, b) for (ll i = a; i < b; i++)
#define VREP(it, v) for (vector<int>::iterator it = v.begin(); it != v.end(); it++)
typedef pair<ll,ll> pi;
typedef vector<ll> vi;

template <typename T>
using pbds_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

template <typename K, typename V>
using pbds_map = tree<K, V, less<K>, rb_tree_tag, tree_order_statistics_node_update>;
ll n, x;
char arr[200005];
ll ans[200005];
ll dp[200005];

ll power(ll a, ll b, ll mod){
	a %= mod;
	if (b == 0) return (ll)1;
	if (b == 1) return a;
	ll half = power(a, b/2, mod);
	half *= half;
	half %= mod;
	if (b % 2) half *= a;
	half %= mod;
	return half;
}

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cin >> n;
	REP(i, 0, n) cin >> arr[i];
	ll tot = 0;
	REP(i, 0, n){
		if (arr[i] == '1') tot++;
	}
	
	dp[0] = 0;
	REP(i, 1, 200001){
		ll x = i;
		ll ans = 0;
		while (x != 0){
			if (x % 2 == 1) ans++;
			x /= 2;
		}
		dp[i] = 1 + dp[i%ans];
	}
	ll atotal = 0, btotal = 0, cur = 1, cur2 = 1;
	for (ll i = n - 1; i >= 0; i--){
		atotal += cur*(arr[i] == '1');
		atotal %= (tot + 1);
		cur *= 2;
		cur %= (tot + 1);
		if (tot > 1){
			btotal += cur2*(arr[i] == '1');
			btotal %= (tot - 1);
			cur2 *= 2;
			cur2 %= (tot - 1);
		}
	}
	
	REP(i, 0, n){
		if (tot == 1 && arr[i] == '1'){
			ans[i] = 0;
			continue;
		}
		
		if (arr[i] == '1'){
			ans[i] = 1 + dp[(btotal - power((ll)2, n - 1 - i, tot - 1) + tot - 1)%(tot - 1)];
		} else {
			ans[i] = 1 + dp[(atotal + power((ll)2, n - 1 - i, tot + 1) + tot + 1)%(tot + 1)];
		}
	}
	
	REP(i, 0, n) cout << ans[i] << endl;
	
}

//cout.flush()

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

int main() {
    long long n, k; //ansが結構大きくなるのでそれに合わせてlong longで対応
    cin >> n >> k; //nとkの入力
    /* 最初のボールの塗り方はk通り、次のボールの塗り方は最初のボールを塗った色を抜いた
    k-1通りその次はまたk-1と続いていくのでk(k-1)^(n-1)通りを求めればいい */
    long long ans = k;
    for (int i=1; i<n; i++) { //iを1からn-1まで増やしていく（n-1回ループしたいだけ）
        ans *= (k - 1); //n-1回(k-1)をかける
    }
    cout << ans << endl; //ansを出力
    return 0;
}

Measured memory_bytes: 3512
digits = [int(c) for c in input()]
n = len(digits)
m = int(input())

dp = [[[0 for _ in range(2)] for _ in range(m + 2)] for _ in range(n + 1)]
dp[0][0][0] = 1

for i, digit in enumerate(digits):
    for j in range(m + 1):
        for k in range(2):
            for d in range(10 if k else digit + 1):
                dp[i + 1][j + (d > 0)][k or (d < digit)] += dp[i][j][k]

print(sum(dp[n][m]))

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

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

        vector<vector<int> > day(n);
        for(int i=0; i<n; i++){
            int tmp,m;
            cin >> tmp;
            m = tmp;
            for(int j=0; j<m; j++){
                cin >> tmp;
                day[i].push_back(tmp);
            }
        }
        
        int max=0,nearest=-1;
        for(int i=0; i<100; i++){
            int sum=0;
            for(int j=0; j<n; j++){
                auto itr = find(day[j].begin(), day[j].end(), i);
                if(itr!=day[j].end()){
                    sum++;
                }
            }
            if(sum>max){
                nearest = i;
                max = sum;
            }
        }

        if(max >= q){
            cout << nearest << endl;
        }else{
            cout << 0 << endl;
        }
    }

    return 0;
}

Measured memory_bytes: 3080
#include <iostream>
#include <cstdlib>
#include <algorithm>
#define ll long long
using namespace std;
int value[100000];
int weight[100000];
ll dp[101][100001];


ll KS(int index, int req) 
{
    if(index<0 || req<=0)
        return 0;
     if(dp[index][req] != -1)
        return dp[index][req];
    if(weight[index]<=req)
    {
        dp[index][req]=max(KS(index-1,req),(value[index]+KS(index-1,req-weight[index])));
    }
    
    else
        dp[index][req]=KS(index-1,req);
        
    return dp[index][req];
}


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

for(int i=0;i<n;i++)
{
    cin>>weight[i];
    cin>>value[i];
}

for(int i=0;i<101;i++)
{
     for(int j=0;j<100001;j++)
    {
        dp[i][j] = -1;
    }
}
   
   
ll ans=KS(n-1,w);
cout<<ans;
return 0;
}

Measured memory_bytes: 79104
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <bits/stdc++.h>
#include <iomanip>
#include <numeric>
#include <utility>
#include <map>
#include <algorithm>
using namespace std;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long a;
    string b;
    cin >> a >> b;
    vector<char> st(a);
    for (int i = 0; i < a; ++i)
        st[i] = b[i];
    int count = 0;
    char chr;
    for (int i = 0; i < a; ++i)
    {
        if (chr == st[i])
            continue;
        else
        {
            chr = st[i];
            count++;
        }
    }
    cout << count << "\n";
}



Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main() {

    int n;
    cin >> n;

    ++n;

    int nums[n];
    bool visited[n];
    for (int i = 1; i < n; i++){
        cin >> nums[i];
        visited[i] = false;  
    }

    int i = 1;
    int cnt = 1;
    visited[i] = true;

    if (nums[i] == 2){
        cout << 1 << endl;
        return 0;
    }
    
    while (true){
        
        int nxt = nums[i];
        visited[i] = true;

        if (nums[nxt] == 2){
            cout << cnt + 1 << endl;
            return 0;
        }

        if (visited[nxt]){
            cout << -1 << endl;
            return 0; 
        }

        cnt++;

        i = nxt;
    }

}

Measured memory_bytes: 768
const main = (arg) => {
    let N = arg.split("\n")[0]
    arg = arg.split("\n").splice(1)
    let D1 = arg.map(x=>x.split(" ")[0])
    let D2 = arg.map(x=>x.split(" ")[1])
    
    let count = 0
    let isSame=false
    for(let i=0; i<N; i++) {
        if(D1[i]===D2[i]) {
            count++
            if(count>=3) {
                isSame=true
            }
        } else {
            count=0
        }
    }
    
    console.log(isSame ? "Yes" : "No")

}
main(require("fs").readFileSync("/dev/stdin", "utf8"));


Measured memory_bytes: 29740
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, m, n) for(ll i = m;i < n;i++)
#define VSORT(v) sort(v.begin(), v.end());
#define VREV(v) reverse(v.begin(), v.end());
using namespace std;
using ll = long long;
using pll = pair<ll,ll>;
using vll = vector<ll>;
using vdouble = vector<double>;
using vstr = vector<string>;
typedef pair<int,int> P;
int dx[4] = {1, 0, -1, 0},dy[4] = {0, 1, 0, -1};
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}
template<class T> inline bool chmax(T& a, T b){if(a<b) {a=b; return 1;} return 0; }
template<class T> inline bool chmin(T& a, T b){if(a>b) {a=b; return 1;} return 0; }
const ll INF = 1LL << 60;
const ll mod = 1000000007;

int main(){
	//入力
    ll K,N;cin>>K>>N;
	vll A(N+1); rep(i,N)cin>>A[i];
	A[N]=A[0]+K;
	ll ma=0;
	rep(i,N) chmax(ma,A[i+1]-A[i]);
	cout<<K-ma<<endl;
}

Measured memory_bytes: 1792
using System;
using static System.Console;

class Proram
{
    public static void Main()
    {
	long n = long.Parse(ReadLine());

	if (n == 0){ WriteLine(0); return; }

	long m = 0;
	string ans = "";

	long x = 1; // (-2)^k
	long y = 2; // 2^(k+1)
	while (n != m)
	{

	    long mm = n%y;
	    if (mm < 0) mm += y;
	    
	    if (mm >= y/2)
	    {
		ans = "1" + ans;
		n -= x;
	    }
	    else
		ans = "0" + ans;

	    x *= -2;
	    y *= 2;
	}
	WriteLine(ans);
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
#define int long long int
int32_t main()
{
	
    int x, y;
    cin >> x >> y;
    if (y%2!= 0) { cout << "No" << endl; return 0; }
    int a = y /2  - x;
    int b = x - a;
    if (a >= 0 && b >=0) { cout << "Yes" << endl; }
    else { cout << "No" << endl;}
    return 0;

	
}


Measured memory_bytes: 3532
#include <iostream>
typedef long long ll;
using namespace std;
ll modpow(ll x, ll e, ll n) {
  ll res = 1;
  while (e > 0) {
    if (e % 2 == 1) {
      res = res * x % n;
    }
    e /= 2;
    x = x * x % n;
  }
  return res;
}
int main() {
  ll m, n;
  cin >> m >> n;
  cout << modpow(m, n, 1000000007) << endl;
  return 0;
}

Measured memory_bytes: 3096
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>

typedef std::uint64_t u64;
typedef std::int64_t  i64;
typedef std::uint32_t u32;
typedef std::int32_t  i32;

using namespace std;

#define swap(a, b)    do { typeof(a) __tmp = (a); (a) = (b); (b) = __tmp; } while(0)
#define repd(i, a, b) for(typeof(b) i = a; i < (b); ++i)
#define rep(i, n)     repd(i, 0, n)
#define dump(x)       cerr << #x << " = " << (x) << endl
#define debug(x)      cerr << "L" << __LINE__ << ": " << #x << " = " << (x) << endl

int main(int argc, const char* argv[]) {
  u64 s;
  cin >> s;
  
  u64 ret = 0xFFFFFFFFFFFFFFFF;
  while(s >= 100) {
    u64 tmp = ((s % 1000) > 753) ? ((s % 1000) - 753) : (753 - (s % 1000));
    if(tmp < ret) ret = tmp;;
    s /= 10;
  }
  cout << ret;
  return 0;
}

Measured memory_bytes: 256
// 桁DPのテンプレ
// Nを入力するとN以下の自然数の数(=N)のmodQを出力

#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;

// N ... 最大桁数
#define N 1000
#define Q 1000000007

#define rep(i,f,t) for(int i=f; i<t; i++)

int main(void){
  char n[N+1];
  int len, m;
  long long dp[N][2][5]; // digit, less, non-zero
  
  cin >> n;
  cin >> m;
  len = strlen(n);
  
  memset(dp, 0, sizeof(dp));
  dp[0][0][0] = 1;
  rep(i,0,len) rep(j,0,2) rep(k,0,4){
    int mx = j ? 9 : n[i]-'0'; // 今の桁に入れられる最大値
    for (int dig=0; dig<=mx; dig++){
      int ii, jj, kk;
      ii = i+1;
      jj = j || (dig<mx); // すでにlessまたは今入れようとしてる数がn[i]未満
      kk = k + (dig==0?0:1);
      
      dp[ii][jj][kk] = (dp[ii][jj][kk] + dp[i][j][k]) % Q;
    }
  }
  
  printf("%lld\n", (dp[len][0][m]+dp[len][1][m])%Q);
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

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

	int H, W, N; cin >> H >> W >> N;
	vector<int> a(N, 0), b(N, 0);
	rep (i, N){
		cin >> a[i] >> b[i];
		--a[i], --b[i];
	} // end rep

	map<ll,int> cnt;cnt.clear();
	rep (i, N){
		int p = a[i], q = b[i];
		rep (k, 3){
			rep (l, 3){
				if (p - k < 0 || q - l < 0 || p - k + 2 >= H || q - l + 2 >= W) continue;
				++cnt[(ll)(p - k) * (ll)W + (ll)(q - l)];
			} // end rep
		} // end rep
	} // end rep

	vector<ll> res(10,0LL);
	ll total = 0LL;
	map<ll,int>::iterator it = cnt.begin();
	for(; it != cnt.end(); ++it){
		ll p = (*it).first;
		int c = (*it).second;
//		cerr << "pos:(" << (p/W) << ',' << (p%W) << ")" << " c: " << c << endl;
		++res[c];
		++total;
	} // end for

	res[0] = ((ll)H - 2LL)*((ll)W - 2LL) - total;
	rep (i, 10){
		cout << res[i] << endl;
	} // end rep

	return 0;
}

Measured memory_bytes: 57344
package main

import (
    "fmt"
)

func main() {
    var C string
    fmt.Scan(&C)
    a := []string{"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"}
    for i :=0;i<26;i++ {
        if C == a[i]{
            fmt.Print(a[i+1])
        }
    }
}

Measured memory_bytes: 512
#include <stdio.h>
#include <bits/stdc++.h>
     
#define uint unsigned int
#define ll long long
#define ull unsigned long long
#define ld long double
#define rep(i, l, r) for (int i = l; i < r; i++)
#define repb(i, r, l) for (int i = r; i > l; i--)
#define sz(a) (int)a.size()
#define fi first
#define se second
#define mp(a, b) make_pair(a, b)

using namespace std;

const int N = 200000;
const int inf = (int)1e9 + 1;
const ll big = (ll)1e18 + 1;
const int P = 239;
const int MOD = (int)1e9 + 7;
const int MOD1 = (int)1e9 + 9;
const double eps = 1e-6;
const double pi = atan2(0, -1);
const int ABC = 26;

bool prime(int x)
{
    if (x < 3)
        return false;
    for (int i = 2; i * i <= x; i++)
        if (x % i == 0)
            return false;
    return true;
}

vector<int> p0, p1;

void add(int x)
{
    if (x % 2 == 0)
        p0.push_back(x);
    else
        p1.push_back(x);
}

vector<vector<int> > g;
vector<bool> used;
vector<int> mt;

bool dfs(int u)
{
    if (used[u])
        return false;
    used[u] = true;
    for (int v : g[u])
        if (mt[v] == -1 || dfs(mt[v]))
        {
            mt[v] = u;
            return true;
        }
    return false;
}

int main()
{
    //freopen("a.in", "r", stdin);
    //freopen("a.out", "w", stdout);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.precision(20);
    cout << fixed;
    //ll TL = 1.95 * CLOCKS_PER_SEC;
    //clock_t time = clock();
    int n;
    cin >> n;
    int a[n];
    rep(i, 0, n)
        cin >> a[i];
    sort(a, a + n);
    rep(i, 0, n)
    {
        if (i == 0 || a[i - 1] != a[i] - 1)
            add(a[i] - 1);
        if (i == n - 1 || a[i + 1] != a[i] + 1)
            add(a[i]);
    }
    n = sz(p0); int m = sz(p1);
    g.resize(n);
    rep(i, 0, n)
        rep(j, 0, m)
            if (prime(abs(p0[i] - p1[j])))
                g[i].push_back(j);
    used.resize(n);
    mt.resize(m, -1);
    rep(i, 0, n)
    {
        used.assign(n, false);
        dfs(i);
    }
    int ans = 0;
    rep(i, 0, m)
        if (mt[i] != -1)
            ans++;
    cout << ans + (n - ans) / 2 * 2 + (m - ans) / 2 * 2 + ((n - ans) % 2 == 1 && (m - ans) % 2 == 1 ? 3 : 0) << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define inf 1000000000
#define INF 100000000000000
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back




template< typename T >
struct edge {
  int src, to;
  T cost;

  edge(int to, T cost) : src(-1), to(to), cost(cost) {}

  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}

  edge &operator=(const int &x) {
    to = x;
    return *this;
  }

  operator int() const { return to; }
};

template< typename T >
using Edges = vector< edge< T > >;
template< typename T >
using WG = vector< Edges< T > >;
using UG = vector< vector< int > >;
template< typename T >
using Matrix = vector< vector< T > >;



template< typename T >
vector<T> dijkstra(WG<T> &g,int s){
  const auto lim = numeric_limits<T>::max();
  vector<T> dist(g.size(),lim);
  using Pi = pair<T,int>;
  priority_queue<Pi,vector<Pi>,greater<Pi>> q;
  dist[s] = 0;
  q.emplace(dist[s],s);
  while(!q.empty()){
    T cost;
    int idx;
    tie(cost,idx) = q.top();
    q.pop();
    if(dist[idx] < cost) continue;
    for( auto &e : g[idx]){
      auto next_cost = cost + e.cost;
      if(dist[e.to] <= next_cost) continue;
      dist[e.to] = next_cost;
      q.emplace(dist[e.to],e.to);
    }
  }
  return dist;
}


int n;

int main(){
  cin>>n;
  WG<ll> es(n+1);
  
  rep(i,n-1){
    int a,b,c;
    cin>>a>>b>>c;
    es[a].EB(edge<ll>(b,c));
    es[b].EB(edge<ll>(a,c));
  }

  int q,k;
  cin>>q>>k;
  vector<ll> v = dijkstra(es,k);

  rep(i,q){
    int x,y;
    cin>>x>>y;
    cout<<v[x]+v[y]<<endl;
  }

}


Measured memory_bytes: 11120
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<queue>


#define rep(i,n) for(int i = 0; i < n; i++)
#define all(X) (X).begin(),(X).end()
#define X first
#define Y second

using namespace std;
using ll = long long;
using pll = pair<long, long>;
using pii = pair<int, int>;

template<typename T>
class Dinic{
//max flow
  public:
    int V;
    class edge{
        public:
            int to;
            T cap, rev;
            edge(int t, T c, T r):to(t),cap(c),rev(r){};
    };
    vector< vector<edge> > g;
    vector<T> itr, l;
    T inf;

    Dinic(int v, T inf):V(v),inf(inf){g.assign(V, vector<edge>());}
    void add_edge(int from, int to, T cap){
      g[from].push_back(edge(to, cap, g[to].size()));
      g[to].push_back(edge(from, 0, g[from].size()-1));
    }

    void d(int s){
      l.assign(V, -1);
      queue<int> q;
      l[s] = 0;q.push(s);
      while(!q.empty()){
        int next = q.front(); q.pop();
        for(auto &e: g[next]){
          if(e.cap > 0 && l[e.to] < 0){
            l[e.to] = l[next] + 1;
            q.push(e.to);
          }
        }
      }
    }

    T dfs(int v, int t, T f){
      if(v==t) return f;
      for(int &i = itr[v]; i < (int)g[v].size(); ++i){
        edge& e = g[v][i];
        if( e.cap > 0 && l[v] < l[e.to]){
          T d = dfs(e.to, t, min(f, e.cap));
          if( d > 0 ){
            e.cap -= d;
            g[e.to][e.rev].cap += d;
            return d;
          }
        }
      }
      return 0;
    }

    T run(int s, int t){
      T ret = 0, f;
      while(d(s), l[t] >= 0){
        itr.assign(V, 0);
        while((f = dfs(s,t, inf)) > 0) ret += f;
      }
      return ret;
    }
};



int main(void){
    int n, x, y;
    vector<pii> a, b;
    cin >> n;
    rep(i, n){
        cin >> x >> y;
        a.push_back(pii(x, y));
    }
    rep(i, n){
        cin >> x >> y;
        b.push_back(pii(x, y));
    }

    Dinic<int> d(2*n+2, 100000000);
    rep(i, n){
        rep(j, n){
            if(b[i].X > a[j].X && b[i].Y > a[j].Y){
                d.add_edge(i, j+n, 1);
            }
        }
    }
    rep(i, n){
        d.add_edge(n*2, i, 1);
        d.add_edge(n+i, n*2+1, 1);
    }

    cout << d.run(n*2, n*2+1) << endl;

    return 0;
}



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

using namespace std;

int main() {
    int A, B, C, D, E;
    cin >> B >> A;
    if (B%500 <= A)
    {
        cout << "Yes" << endl;
        /* code */
    }else
    {
        cout << "No" << endl;
    }
    
    

}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
int main(){
	string s;
	cin>>s;
	int n;n = s.size();
	int r, b;
	r = 0;
	b = 0;
	for(int i = 0; i < n; ++i){
		if(s[i]=='0')r++;
		else b++;
	}
	cout<<min(r, b) * 2<<endl;
	return 0;
}


Measured memory_bytes: 512
N = int(input())
A, B, C = [int(i) for i in input().split()], [int(i) for i in input().split()], [int(i) for i in input().split()]
ans = sum(B)

for i in range(N-1):
  if A[i] + 1 == A[i+1]:
    ans += C[A[i]-1]

print(ans)

Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
int N;
int main(){
	cin>>N;
	bool iya=true;
	while(N>0){
		if(N%10==7){
			cout<<"Yes"<<'\n';
			iya=false;
			break;
		}
		N/=10;
	}
	if(iya){
		cout<<"No"<<'\n';
	}
}


Measured memory_bytes: 3600
#include <iostream>
using namespace std;
int main(){
        int n,counter=0;
        long long int t;
        cin >> n;
        for(int i=0 ; i<n ; i++ ){
                cin >> t;
                while(!(t&0x1)){
                        t>>=1;
                        ++counter;
                }
        }
        cout << counter << endl;
        return 0;
}

Measured memory_bytes: 256