akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>				//Written by ThiDaiLoc
using namespace std;				//Team Three Wolves
typedef long long ll;
typedef vector<ll> vi;
typedef pair<ll,ll> pll;
#define fu(i,a,b)   for(ll i=a;i<b;i++)
#define fd(i,b,a)   for(ll i=b;i>=a;i--)
#define ms(a,x) 	memset(a, x, sizeof a)
#define prec(n) 	fixed<<setprecision(n)
#define pb(i)	    push_back(i)
#define popb()    	pop_back()
#define sc(a) 	    cin>>a
#define sc2(a,b)    cin>>a>>b
#define pr(a)	    cout<<a<<" "
#define pr2(a,b)    cout<<a<<" "<<b<<" "
#define lowb(a,n,x) lower_bound(a,a+n,x) -a
#define lowb2(a,x)	lower_bound(a.begin(),a.end(),x) -a.begin()
#define all(x) 		(x).begin(), (x).end()
#define sz(a) 		(ll)a.size()
#define le			length()						
#define re 			return 	
#define	mp(a,b)  	make_pair(a,b)
#define se			second
#define fi			first 
#define debug(x)    cerr << #x << " = " << x << endl
#define INPUT       freopen("locin.txt", "r", stdin)
#define OUTPUT      freopen("locout.txt", "w", stdout)
void inline minize(ll& a,ll b){a=(a>b?b:a);};
void inline maxize(ll& a,ll b){a=(a<b?b:a);};
double const eps = 1e-6;
ll const Base=1e9+7,oo=1e17;


ll arr[1000000],mark[1000000];

ll Solves(){
//	INPUT;
	ll n,k,cnt=0,ans=oo,x,l,flag;
	// PROCESSING IN HERE
	string s,t;
	cin>>s;
	
	fu(i,0,s.le)mark[s[i]]=1;
	
	fu(i,'a','z'+1){
		if(!mark[i])continue;
		t=s; l=s.le; flag=cnt=0;
//		debug(i);
		do{
			flag=0;
			fu(j,1,l)if(t[j]!=t[j-1]){
				flag=1; break;
			}
			if(flag){
				cnt++; l--;
				fu(j,0,l){
					if(t[j]==(char)i or t[j+1]==(char)i)t[j]=(char)i;
				}
			}
		//	debug(t);
		}
		while(flag);
		minize(ans,cnt);
	}
	
	pr(ans);
	re 0;
	// Hack it if you can :)
}
int main(){
	
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	Solves();
}

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

string fun (string A, string B){
    vector<string> vec(2);
    vec.at(0)=A;
    vec.at(1)=B;
    sort(vec.begin(),vec.end());
    return vec.at(0);
}
 

int main() {
    int a, b;

    cin >>a >>b;
    string A, B;
    A="";
    B="";
    
    for(int i=0;i<b;i++) A += to_string(a);
    for(int i=0;i<a;i++) B += to_string(b);
 

    cout << fun(A,B) <<endl;


    }

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

typedef long long int ll;
#define REP(i,a,b) for(ll i = ll(a); i < ll(b); i++)

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	ll h, w;
	cin>>h>>w;
	ll grid[h][w];
	queue<pair<ll,ll>> q;
	char c;
	REP(i,0,h) REP(j,0,w){
		cin>>c;
		if(c == '#'){
			q.push(pair<ll,ll>(i,j));
			grid[i][j] = 0;
		} else {
			grid[i][j] = -1;
		}
	}
	ll ans = 0;
	while(!q.empty()){
		pair<ll,ll> cur = q.front();
		q.pop();
		if(cur.first > 0 && grid[cur.first-1][cur.second]== -1){
			grid[cur.first-1][cur.second] = grid[cur.first][cur.second] + 1;
			// cout<<grid[cur.first][cur.second]<<endl;
			ans = max(ans, grid[cur.first-1][cur.second]); 
			q.push(pair<ll,ll>(cur.first-1, cur.second));
		}
		if(cur.first < h-1 && grid[cur.first+1][cur.second]== -1){
			grid[cur.first+1][cur.second] = grid[cur.first][cur.second] + 1;
			ans = max(ans, grid[cur.first+1][cur.second]); 
			q.push(pair<ll,ll>(cur.first+1, cur.second));
		}
		if(cur.second > 0 && grid[cur.first][cur.second-1]== -1){
			grid[cur.first][cur.second-1] = grid[cur.first][cur.second] + 1;
			ans = max(ans, grid[cur.first][cur.second-1]); 
			q.push(pair<ll,ll>(cur.first, cur.second-1));
		}
		if(cur.second < w-1 && grid[cur.first][cur.second+1]== -1){
			grid[cur.first][cur.second+1] = grid[cur.first][cur.second] + 1;
			ans = max(ans, grid[cur.first][cur.second+1]); 
			q.push(pair<ll,ll>(cur.first, cur.second+1));
		}
		// cout<<ans<<endl;
	}

	cout<<ans;
	return 0;
}

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

int main() {
    int a, b, c, x, y; cin >>a >>b >>c >>x >>y;
    int ret = a*x + b*y;
    if (x<=y) ret = min(ret, 2*c*x + min(b,2*c)*(y-x));
    if (x>=y) ret = min(ret, 2*c*y + min(a,2*c)*(x-y));
    cout << ret << endl;
    return 0;
}

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

int n,a,ans;
map<int,int> v2c;

int main(){
    scanf("%d",&n);
    for(int i=0;i<n;i++){
        scanf("%d",&a);
        v2c[a]++;
    }
    for(map<int,int>::iterator iter=v2c.begin();iter!=v2c.end();iter++)
        if(iter->first>iter->second)ans+=iter->second;
        else ans+=iter->second-iter->first;
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 4736
use proconio::marker::*;
use proconio::{fastout, input};
use std::cmp::{max, min};

fn main() {
    input! {
        w: usize,
        h: usize,
        x: usize,
        y: usize,
    }

    let ws = min(w - x, x) * h;
    let hs = min(h - y, y) * w;

    println!(
        "{} {}",
        (w * h) as f64 / 2.0,
        (w - x == x && h - y == y) as usize
    );
}


Measured memory_bytes: 2216
#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 int ui;
const ll mod = 1000000007;
typedef long double ld;
const ll INF = 1e+14;
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(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

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

  int N ,C; cin >> N >> C;
  int D[33][33], c[510][510];
  rep1(i, C) rep1(j, C) cin >> D[i][j];
  rep(i, N) rep(j, N) cin >> c[i][j];

  map<int, int> color[3];
  rep(i, N) {
      rep(j, N) {
          color[(i + j) % 3][c[i][j]] ++;
      }
  }

  int d[3][33];
  rep(i, 3) {
      rep1(j, C) {
          d[i][j] = 0;
      }
  }
  rep(i, 3) {
      rep1(j, C) {
          rep1(k, C) {
              d[i][j] += D[k][j] * color[i][k];
          }
      }
  }

  int ans = 1<<30;
  rep1(i, C) {
      rep1(j, C) {
          if(j != i) {
              rep1(k, C) {
                  if(k != i && k != j) {
                      int iwakan = d[0][i] + d[1][j] + d[2][k];
                      ans = min(ans, iwakan);
                  }
              }
          }
      }
  }
  cout << ans << endl;

  return 0;
}

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

void func1(int64_t nd,int64_t current_num,int64_t current_total,int64_t &all_total,int ketasuu,vector<int> kakuketa){
  if (nd==ketasuu-1){
    all_total=current_total+current_num+all_total;
  }
    else{
      int64_t current_num1=current_num;
      int64_t current_total1=current_total;
    for (int i=0;i<2;i++){
      if (i==0){
        
        func1(nd+1,kakuketa.at(nd+1),current_total1+current_num1,all_total,ketasuu,kakuketa);
      }

      else{
        func1(nd+1,current_num1*10+kakuketa.at(nd+1),current_total1,all_total,ketasuu,kakuketa);
      }
    }
  }
}
    
int main(){
  int64_t N;
  cin >> N;
  if (N<10){
    cout << N <<endl;
  }
  else{
  int ketasuu=0;
  vector<int> kakuketa;
  int64_t H=N;
  
  while (H>0){
    kakuketa.push_back(H%10);
    H/=10;
    ketasuu++;
  }
  ;
  reverse(kakuketa.begin(),kakuketa.end());
  if (N<10){
    cout << N <<endl;
  }
  int64_t all_total=0;
  func1(0,kakuketa.at(0),0,all_total,ketasuu,kakuketa);
  cout << all_total << endl;
  }       
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INIT  ios_base :: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define mp make_pair
#define pb push_back
#define ft first
#define sc second
#define ll long long
#define pii pair<int, int>
#define count_bits __builtin_popcount
#define int ll

int t, n, m, k, h[100010], q, l, r;
int cost[100010];
bool v[100010];
int32_t main(){
INIT
cin>>n;
for(int i=1; i<=n; i++){
    cin>>h[i];
}
cost[2]=abs(h[2]-h[1]);
for(int i=3; i<=n; i++){
    cost[i]=min(cost[i-1]+abs(h[i]-h[i-1]), cost[i-2]+abs(h[i]-h[i-2]));
}
cout<<cost[n];




return 0;
}



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

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

string s;
cin>>s;

if(s.at(2)==s.at(3)&&s.at(4)==s.at(5))
cout<<"Yes"<<endl;
else
{
    cout<<"No"<<endl;
}

return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline

n,m = map(int,input().split())
s = input()
ab = [list(map(int, input().split())) for i in range(m)]
graph = [[] for i in range(n+1)]
ABs = [[0,0] for i in range(n+1)]
for a,b in ab:
  graph[a].append(b)
  graph[b].append(a)
  if s[a-1] == "A":
    ABs[b][0] += 1
  else:
    ABs[b][1] += 1
  if s[b-1] == "A":
    ABs[a][0] += 1
  else:
    ABs[a][1] += 1
ablack = [-1 for i in range(n+1)]
ablack[0] = 0
stack = []
visited = [0 for i in range(n+1)]
for x in range(1,n+1):
  if ABs[x][0] == 0 or ABs[x][1] == 0:
    if s[x-1] == "A":
      ablack[x] = 0
    else:
      ablack[x] = 1
    stack.append(x)

while stack:
  x = stack.pop()
  if visited[x] == 1:
    continue
  visited[x] = 1
  for y in graph[x]:
    if visited[y] == 0:
      if ablack[x] == 0:
        ABs[y][0] -= 1
      else:
        ABs[y][1] -= 1
      if ABs[y][0] <= 0 or ABs[y][1] <= 0:
        if s[y-1] == "A":
          ablack[y] = 0
        else:
          ablack[y] = 1
        stack.append(y)
if ablack.count(-1) >= 1:
  print("Yes")
else:
  print("No")

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

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

	return 0;
}


Measured memory_bytes: 3100
#include <cstdio>
#include <cmath>
#include <vector>
#include <algorithm>

int main() {
  int N;
  scanf("%d", &N);

  std::vector<int> A(N+2);
  for (int i=1; i<=N; ++i)
    scanf("%d", &A[i]);

  // NOTE: N=2 case

  int S=std::abs(A[1]);
  for (int i=1; i<=N; ++i)
    S += std::abs(A[i]-A[i+1]);

  for (int i=1; i<=N; ++i) {
    if (A[i-1] <= A[i] && A[i] <= A[i+1]) {
      printf("%d\n", S);
    } else if (A[i-1] >= A[i] && A[i] >= A[i+1]) {
      printf("%d\n", S);
    } else if (A[i-1] <= A[i+1] && A[i+1] <= A[i]) {
      printf("%d\n", S-2*std::abs(A[i]-A[i+1]));
    } else if (A[i] <= A[i-1] && A[i-1] <= A[i+1]) {
      printf("%d\n", S-2*std::abs(A[i-1]-A[i]));
    } else if (A[i] <= A[i+1] && A[i+1] <= A[i-1]) {
      printf("%d\n", S-2*std::abs(A[i]-A[i+1]));
    } else {
      printf("%d\n", S-2*std::abs(A[i]-A[i-1]));
    }
  }
}


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

int main(){
  int n;
  cin >> n;
  int t=0, x=0, y=0;
  bool ans = true;
  for(int i=0; i<n; ++i){
    int nt, nx, ny;
    cin >> nt >> nx >> ny;
    if((nt-t)%2 != abs((x+y)-(nx+ny))%2) ans = false;
    if((nt-t) < (abs(x-nx)+abs(y-ny))) ans = false;
    if(!ans){
      cout << "No" << endl;
      return 0;
    }
    t = nt; x = nx; y = ny;
  }
  cout << "Yes" << endl;
}

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

int main(void) {
  char a, b;
  cin >> a >> b;
  if(a=='H') {
    cout << b << endl;
  } else {
    if(b=='H')
    cout << "D" << endl;
    else 
    cout << "H" << endl;
  }
}

Measured memory_bytes: 3628
using System;
using System.Linq;

namespace AtCoder.Abc
{
    class QuestionB
    {
        public static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            var inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            var a = inputLongArray[0];
            var b = inputLongArray[1];
            var c = inputLongArray[2];
            var d = inputLongArray[3];

            var w = ((a - 1) / d + 1) >= ((c - 1) / b + 1);

            Console.WriteLine(w?"Yes":"No");

            Console.Out.Flush();
        }
    }
}


Measured memory_bytes: 28224
#include <stdio.h>

int main(){
  int N,c=1;
  int H[100002];
  scanf("%d",&N);
  for(int i=1;i<=N;i++)
    scanf("%d",H+i);
  for(int i=N;i>1;i--)
    if(H[i-1]>H[i]) H[i-1]--;
  for(int i=2;i<=N;i++)
    if(H[i-1]>H[i]) c=0;
  if(c) printf("Yes\n");
  else printf("No\n");
  return 0;
}

Measured memory_bytes: 2048
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;

    int l[50];
    for (int i = 0; i < n; i++)
        cin >> l[i];

    sort(l, l+n, greater<int>());
    int len = 0;
    for (int i = 0; i < k; i++)
        len += l[i];

    cout << len << endl;

    return 0;
}

Measured memory_bytes: 256
s = list(input())
n = len(s) + 1
al, ar = [0] * n, [0] * n

for i in range(len(s)):
    if s[i] == "<":
        al[i+1] = al[i] + 1

for i in range(len(s)):
    if s[-(i+1)] == ">":
        ar[i+1] = ar[i] + 1

ans = 0
ar = ar[::-1]

for i in range(len(al)):
    if al[i] >= ar[i]:
        ans += al[i]
    else:
        ans += ar[i]

print(ans)

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

using namespace std;

int main() {

	long long int k, x;
	queue<long long int> q;

	cin >> k;

	for (int i = 1;i < 10;i++) q.push(i);

	for(int i=0;i<k-1;i++) {
		x = q.front();
		//cout << x << endl;
		q.pop();
		if (x % 10 != 0) q.push(10 * x + x % 10 - 1);
		q.push(10 * x + x % 10);
		if (x % 10 != 9) q.push(10 * x + x % 10 + 1);
	}

	cout << q.front() << endl;

	return 0;
}


Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<set>
#include<cmath>
#define MAX 2000050
#define ll long long int
ll n;
ll s = 0;
using namespace std;


int main(){
  cin>>n;
  s = n*(n+1)/2;
  cout<<s<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<string>
#include<stdio.h>
#include<stdlib.h>
#include<float.h>
#include<tuple>
#include<string.h>
#include<iomanip>

using namespace std;
#define ll long long
#define rep(i,n) for(ll i=0;i<n;i++)
const ll mod=1000000007;

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


ll modinv(ll a) {
    return modpow(a,mod-2);
}

int main(void){
    ll N,K;
    cin>>N>>K;
    ll ans=N-K+1;
    cout<<ans<<endl;
    
    for(ll i=2;i<=K;i++){
        ans=(ans*(N-K-i+2)*(K-i+1))%mod;
        ans=(ans*modinv(i))%mod;
        ans=(ans*modinv(i-1))%mod;
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define mod 1000000007 
#define pb push_back
//#define mp make_pair
#define INF 2000000011LL
#define INFLL 1000000000000000011LL
#define eps 1e-9
#define pp pair < pair<ll,ll> , ll> 
#define fo(i,j,k) for(int i=j;i<=k;i++)
#define foll(i,j,k) for(ll i=j;i<=k;i++)
#define clr(a) memset(a,0,sizeof(a))
#define vi vector<int>
#define vll vector<ll>
#define sz(a) a.size()
#define len(a) a.length()
#define all(a) a.begin(),a.end()
#define io_file freopen("Contest/input_file.in", "r", stdin); freopen("Contest/output_file.in", "w", stdout)

const int MAXN = 2e5+5;
using namespace std;
ll power(ll x, ll y)
{
  ll res = 1;
  while(y>0)
  {
    if(y&1)
       {
         res = (res*x)%mod;
        }
     x = (x*x)%mod;
     y = y>>1;
  }
    return res;
}
// std::vector<ll> divi[100004];
// void divisor(int n)
// {
//    for(ll i=1;i<=n;i++)
//    {
//      for(ll j=i;j<=n;j+=i)
//      {
//        divi[j].pb(i);
//      }
//    }
// }



int cnt[26];

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

    cin>>s;
    int n = s.length();
    for(int i=0;i<n;i++)
    {
      cnt[s[i]-'a']++;
    }
    if(n < 26)
    {
      cout<<s;
      for(int i=0;i<26;i++)
      {
        if(cnt[i]==0)
        {
          cout<<(char)(i + 'a')<<endl;
          return 0;
        }
      }
    }
    else{
      set<int>st;
      st.insert(s[n-1]-'a');
      for(int i=n-2;i>=0;i--)
      {
        if(s[i]-'a' > s[i+1]-'a')
        {
          st.insert(s[i]-'a');
        }
        else{
          // cout<<"hihih"<<endl;
          for(int x : st)
          {
            
            if(x > s[i]-'a')
            {
              for(int j=0;j<i;j++)
              {
                cout<<(char)s[j];
              }
              cout<<(char)(x + 'a')<<endl;
              return 0;
            }
          }
        }
      }
      cout<<-1<<endl;
    }

    return 0;

}



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

int binarySearch(int A[], int n, int key){
    int i = 0;
    int left = 0;
    int right = n;
    while( left < right){
        int mid = (left + right) / 2;
        if ( A[mid] == key ) return 1;
        if (key < A[mid]) right = mid;
        else if ( key >A[mid] ) left = mid + 1;
    }
    
    return 0;
}

int main(){
    int n;
    cin >> n;
    int S[1000000];
    for( int i = 0; i < n; i++){
        cin >> S[i];
    }
    
    int q;
    cin >> q;
    int key;
    int count = 0;
    for( int i = 0; i < q; i++ ){
        cin >> key;
        if( binarySearch(S, n, key) ) count++;
    }
    
    cout << count << endl;
    
    return 0;
}


Measured memory_bytes: 3412
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
// #include<ext/pb_ds/assoc_container.hpp>
// #include<ext/pb_ds/tree_policy.hpp>
// #include<ext/pb_ds/tag_and_trait.hpp>
// using namespace __gnu_pbds;
using namespace std;
using ll=long long;
#define double long double
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
// using llset=tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a-1;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define eb emplace_back
#define print(v) cout<<v<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define printYES cout<<"YES"<<endl
#define printNO cout<<"NO"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
// const ll mod=998244353;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas x,ddatas y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

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

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

int main(){
  // startupcpp();
  // ll test;cin>>test;while(test--){
  ll i,j,N,H,W,ans;
  string s;
  cin>>s;
  N=s.size();
  rep(i,N)if(s[i]!=s[N-i-1])break;
  if(i!=N){printno;return 0;}
  H=N/2;
  rep(i,H)if(s[i]!=s[H-i-1])break;
  if(i==H)printyes;
  else printno;
  return 0;
}

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

using namespace std;

const int MAXN = 2E5;
pair<int, int> monsters[MAXN];

int main()
{
    int n, d, a;
    cin >> n >> d >> a;
    for (int i = 0; i < n; i++)
    {
        cin >> monsters[i].first >> monsters[i].second;
        monsters[i].second = (monsters[i].second + a - 1) / a;
    }
    sort(monsters, monsters + n);
    deque<pair<int, int>> bombs;
    int ptr = 0;
    long long ans = 0;
    long long dam = 0;
    while (ptr < n)
    {
        int pos = monsters[ptr].first;
        int hp = monsters[ptr].second;
        while (!bombs.empty() && (long long) bombs.front().first + 2 * d < pos)
        {
            dam -= bombs.front().second;
            bombs.pop_front();
        }
        if (dam < hp)
        {
            ans += hp - dam;
            bombs.push_back(make_pair(pos, hp - dam));
            dam = hp;
        }
        ptr++;
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
    int N,M,C,check=0,ans=0;
    cin>>N>>M>>C;
    vector<int>B(M);
    vector<vector<int>>A(N,vector<int>(M));
    for(int i=0;i<M;i++){
        cin>>B.at(i);
    }
    for(int i=0;i<N;i++){
        for(int j=0;j<M;j++){
            cin>>A.at(i).at(j);
        }
    }
    
    for(int i=0;i<N;i++){
        check = 0;
        for(int j=0;j<M;j++){
            check +=A.at(i).at(j)*B.at(j);
        }
        if(check + C >0){
            ++ans;
        }
    }
    cout<<ans<<endl;
}


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

int main() {
  int a;
  int b;
  cin >> a;
  cin >> b;
  if((a+b)%2==0){
  	cout << (a+b)/2 << endl;
  }
  else{
  	cout << (a+b+1)/2 << endl;
  }
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		for(int i = 0; i < n; i++){
			int[] card = new int[9];
			int[][] color = new int[3][9];
			int[] rgb = new int[3]; // ???????????°
			int set = 0;
			for(int j = 0; j < 9; j++){
				card[j] = sc.nextInt();
			}
			for(int j = 0; j < 9; j++){
				String s = sc.next();
				switch(s.charAt(0)){
					case 'R':
						color[0][rgb[0]] = card[j];
						rgb[0]++;
						break;
					case 'G':
						color[1][rgb[1]] = card[j];
						rgb[1]++;
						break;
					case 'B':
						color[2][rgb[2]] = card[j];
						rgb[2]++;
						break;
				}
			}
			for(int j = 0; j < 3; j++){
				for (int k = 0; k < rgb[j]; k++) {
					for (int l = k+1; l < rgb[j]; l++) {
						if(color[j][k] > color[j][l]){
							int tmp = color[j][k];
							color[j][k] = color[j][l];
							color[j][l] = tmp;
						}
					}
				}
				for(int k = 0; k < rgb[j]; k++){
					for(int l = k+1; l < rgb[j]; l++){
						for(int m = l+1; m < rgb[j]; m++){
							if(color[j][k] != 0 && color[j][l] != 0 && color[j][m] != 0){
								int[] tmp = new int[3];
								tmp[0] = color[j][k];
								tmp[1] = color[j][l];
								tmp[2] = color[j][m];
								Arrays.sort(tmp);
								if((tmp[0] == tmp[1] && tmp[1] == tmp[2]) || (tmp[0]+1 == tmp[1] && tmp[1]+1 == tmp[2])){
									color[j][k] = 0;
									color[j][l] = 0;
									color[j][m] = 0;
									set++;
								}
							}
						}
					}
				}
			}
			if(set == 3) System.out.println("1");
			else System.out.println("0");
		}
	}
}

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

int main() {
  int a[4],b[4],hit,blow;
  while(cin >> a[0] >> a[1] >> a[2] >> a[3] >> b[0] >> b[1] >> b[2] >> b[3]) {
    hit = 0;
    blow = 0;
    for(int i=0;i<4;i++) {
      for(int j=0;j<4;j++) {
        if((a[i] == b[j]) && (i == j))
          hit++;
        else if((a[i] == b[j]) && (i != j))
          blow++;
      }
    }
    cout << hit << " " << blow << endl;
  }
}

Measured memory_bytes: 0
#include <iostream>
using namespace std;
void swap(int a, int b){
    int t = a;
    a = b;
    b = t;
}

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

int main(void){
    int a, b;
    cin >> a >> b;
    cout << gcd(a, b) << endl;
    return 0;
}

Measured memory_bytes: 1160
#include <iostream>
 
using namespace std;
 
int solve(int &total) {
	if (total < 5) return 0;
	int happyPoints = 0;
	happyPoints += 1000 * (total / 500);
	total = total % 500;
	happyPoints += 5 * (total / 5);
	return happyPoints;
}
 
int main() {
	int total; 
	cin >> total;
	cout << solve(total) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define CK(N, A, B) (A <= N && N < B)
#define REP(i, a, b) for (int i = a; i < b; i++)
#define RREP(i, a, b) for (int i = (b - 1); a <= i; i--)
#define F first
#define S second
#define ll long long

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

using namespace std;

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

/*==================================================*/
/*variable*/
ll N, A[110];
/*==================================================*/
/*function*/

/*==================================================*/

int main() {

    cin>>N;
    REP(i,0,N){
        cin>>A[i];
    }

    ll ans = 0;
    REP(i,0,N){
        REP(j,0,N){

            ans = max(ans, abs(A[i] - A[j]));
        }
    }

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


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

using namespace std;

int main() {
  string s;
  cin >> s;
  for (size_t i = 0; i < 4; i++) {
    cout << s[i];
  }
  cout << " ";
  for (size_t i = 4; i < s.size(); i++) {
    cout << s[i];
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

const int NMAX = 1e5;
const int inf = 1e6;

int N, M;
vector <int> g[NMAX + 2];

queue <int> Q;
int d[NMAX + 2], t[NMAX + 2];

void BFS(int src)
{
    for(int i = 1; i <= N; i++)
        d[i] = 0;
    
    Q.push(src);
    d[src] = 0;

    while(!Q.empty())
    {
        int node = Q.front();
        Q.pop();

        for(auto it : g[node])
            if(d[it] == 0)
                {
                    d[it] = d[node] + 1;
                    t[it] = node;
                    Q.push(it);
                }
    }
}

int main()
{
    cin >> N >> M;

    for(int i = 1; i <= M; i++)
    {
        int x, y; cin >> x >> y;
        g[x].push_back(y);
        g[y].push_back(x);
    }

    BFS(1);

    cout << "Yes\n";
    for(int i = 2; i <= N; i++)
        cout << t[i] << '\n';

    return 0;
}

Measured memory_bytes: 10812
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func solve() {
	rs := getRunes()
	n := len(rs)

	ans := 0
	for i := n - 2; i >= 0; i -= 2 {
		r1, r2 := rs[0:i/2], rs[i/2:i]

		isEqual := true
		for i := 0; i < len(r1); i++ {
			if r1[i] != r2[i] {
				isEqual = false
			}
		}

		if isEqual {
			ans = i
			break
		}
	}

	fmt.Fprintln(wr, ans)
}

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

const (
	inf = 1 << 60
	// mod = 1000000007
)

var (
	sc = bufio.NewScanner(os.Stdin)
	wr = bufio.NewWriter(os.Stdout)
)

func main() {
	maxBufSize := int(1e8)
	sc.Buffer(make([]byte, 4096), maxBufSize)
	sc.Split(bufio.ScanWords)
	solve()
	wr.Flush()
}

func getInt() (ret int) {
	sc.Scan()
	ret, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return
}

func getIntSlice(n int) (ret []int) {
	ret = make([]int, n)
	for i := range ret {
		ret[i] = getInt()
	}
	return
}

func getString() (ret string) {
	sc.Scan()
	ret = sc.Text()
	return
}

func getRunes() (ret []rune) {
	ret = []rune(getString())
	return
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
  string  s,t;
  cin >> s >> t;
  int n = s.size();
    int ans = 0;
  for(int i =0; i < n; i++){
    if(s.at(i) != t.at(i)) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3916
/*
CF ID: Ankit717
PROG: Frog2
LANG: C++
*/
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> pll;
#define mod 1000000007
#define maxn 200005
#define f(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rf(i,a,b) for(ll i=(ll)(a);i>=(ll)(b);i--)
#define pb push_back
#define pf push_front
#define nl cout << "\n";

const ll INF=1e18L+5;
 
struct Data{
	ll p;
	ll h;
};

void ini(){
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
}

bool comp(pll &a,pll &b){
	// if(a.first==b.first){
	// 	return a.second<b.second;
	// }else{
		return a.first>b.first;
	//}
}

// vector<pll> adj[maxn];
// vector<ll> par;
// vector<bool> vis;

ll gcd(ll a,ll b){
    while(a!=0){
        ll temp=a;
        a = b % a;
        b = temp;
    }

    return b;
}

// bool prime[maxn],near[maxn];
// void sieve(){
// 	f(i,0,maxn+1){
// 		prime[i]=true;
// 	}
// 	prime[0]=falsrime[1]=false;
// 	for(ll i=2;i*i<=maxn;i++){
// 		if(prime[i]){
// 			for(j=i*i;j<=maxn;j+=i){
// 				prime[j]=false;
// 			}
// 		}
// 	}
// }

void solve(){
	ll n,k;
	cin >> n >> k;
	ll h[n];
	f(i,0,n){
		cin >> h[i];
	}

	vector<ll> dp(n,INF);
	dp[0]=0;
	dp[1]=abs(h[1]-h[0]);

	f(i,2,n){
		//cout << dp[i];nl;
		f(j,max(0LL,i-k),i){
			dp[i]=min(dp[i],dp[j]+abs(h[j]-h[i]));
		}
	}

	cout << dp[n-1];
}

int main(){
	ini();
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
	
    
	// ll t;
	// cin >> t;
	// f(i,0,t){
		solve();
	//}
}


Measured memory_bytes: 4780
#include <iostream>
#include<string>
#include<math.h>
#include<algorithm>
#include<vector>
using namespace std;
int main()
{
	string s; 
	int z;
	cin >> s; int c = 0; 
	c = s.find_first_of('A');
	z = s.find_last_of('Z');
	cout << z - c + 1;
}



Measured memory_bytes: 3700
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
ll n, k;
vector<ll> dp(1e7+1, -1);
vector<ll> v(1e5+1);

ll frog2(ll ind) {
	if (ind==n-1) return 0;
	if (dp[ind]!=-1) return dp[ind];
	ll ans=1e9+1;
	for (int i=1; i<=k; ++i) {
		if (i+ind<n) ans=min(ans, frog2(ind+i)+abs(v[ind]-v[ind+i]));
		else break;
	}
	return dp[ind]=ans;
}

int main() {
	cin >> n >> k;
	for (ll i=0; i<n; ++i) cin >> v[i];
	cout << frog2(0) << endl;

	return 0;
}



Measured memory_bytes: 86852
package main

import (
	. "fmt"
    "strings"
    "sort"
)

// func init() { Println("----------------------------------------") }

func main() {
    var s string
    Scanf("%s", &s)

    chars := strings.Split(s, "")

    sort.Sort(sort.StringSlice(chars))

    if chars[0] == "a" && chars[1] == "b" && chars[2] == "c" {
        Println("Yes")
    } else {
        Println("No")
    }
}


Measured memory_bytes: 640
/* C++14 (Clang 3.8.0) for AtCoder */

#include <iostream>
#include <vector>
#include <string>
// #include <cmath>
// #include <math.h>
// #include <map>
// #include <algorithm>

namespace AtCoder {
	using Str = std::vector<std::string>;
	using Num = std::vector<int>;

	class Ans {
	public:
		void showResult(void);
		void increment(void);
		void increment(double);
		void decrement(void);
		void decrement(double);
		double getResult(void);
	private:
		double result;
	};
	void Ans::showResult(void) {
		printf("%.0lf\n", this->result);
	}
	void AtCoder::Ans::increment(void) {
		this->result++;
	}
	void AtCoder::Ans::increment(double value) {
		this->result += value;
	}
	void AtCoder::Ans::decrement(void) {
		this->result--;
	}
	void AtCoder::Ans::decrement(double value) {
		this->result -= value;
	}
	double AtCoder::Ans::getResult(void) {
		return this->result;
	}

	void input(Str* str) {
		str->clear();
		std::string buf = "", row = "";
		std::getline(std::cin, buf);
		for (unsigned int i = 0; i < buf.size(); i++) {
			if (' ' == buf[i]) {
				str->push_back(row);
				row = "";
			} else {
				row += buf[i];
			}
		}
		str->push_back(row);
	}
	void input(Num* num) {
		num->clear();
		std::string buf = "", row = "";
		std::getline(std::cin, buf);
		for (unsigned int i = 0; i < buf.size(); i++) {
			if (' ' == buf[i]) {
				num->push_back(std::atoi(row.c_str()));
				row = "";
			} else {
				row += buf[i];
			}
		}
		num->push_back(std::atoi(row.c_str()));
	}
	void exp(std::string* str,  Str* newStr) {
		std::string pre = *str;
		newStr->clear();
		for (unsigned int i = 0; i < pre.length(); i++) {
			newStr->push_back(pre.substr(i, 1));
		}
	}
}

int main(void) {

	AtCoder::Num s;
	AtCoder::input(&s);

	const int n = s[0];

	AtCoder::Num a, b, c;

	AtCoder::input(&a);
	AtCoder::input(&b);
	AtCoder::input(&c);
	
	AtCoder::Ans* ans = new AtCoder::Ans();

	int bufc = -1;
	for (int od : a) {
		ans->increment(b[(od - 1)]);
		int bufd = (od - 1);
		if (0 != bufd && bufc == bufd) {
			ans->increment(c[(bufd - 1)]);
		}
		bufc = od;
	}

	ans->showResult();

	delete(ans);

	return 0;
}


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

const int MAX_N = 100 + 10;
int n, sum, maxx, tmp;

int main() {
	scanf("%d", &n);
	for (int i = 1; i <= n; i++) {
		scanf("%d", &tmp);
		if (maxx < tmp) maxx = tmp;
		sum += tmp;
	}
	sum -= maxx;
	if (maxx >= sum) puts("No");
	else puts("Yes");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
main()
{
    int n,s;
    cin>>n>>s;
    int sm=0;
    for(int i=1;i<=s;i++){
        int x;
        cin>>x;
        sm+=x;
    }
    cout<<max(-1LL,n-sm);
}


Measured memory_bytes: 3596
import sys
import math
import collections
import decimal
import itertools
from collections import deque
from functools import reduce
import heapq
#a = int(input())
#h, w = map(int, sys.stdin.readline().split())
s = input()
#a = list(map(int, sys.stdin.readline().split()))

t = input()

ans = 0
for i in range(len(s)):
    if s[i] != t[i]:
        ans += 1

print(ans)
      
    
    













Measured memory_bytes: 10140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int dx[] = {1, 0, -1, 0}, dy[] = {0, 1, 0, -1};
using pii = pair<int, int>;

// 1-indexed
class BIT {
 public:
  ll n;                               //データの長さ
  vector<ll> bit;                     //データの格納先
  BIT(ll n) : n(n), bit(n + 1, 0) {}  //コンストラクタ

  // k & -kはLSB

  // bit_iにxをO(log(n))で加算する
  void add(ll i, ll x) {
    if (i == 0) return;
    for (ll k = i; k <= n; k += (k & -k)) {
      bit[k] += x;
    }
  }

  // bit_1 + bit_2 + …  + bit_n をO(log(n))で求める
  ll sum(ll i) {
    ll s = 0;
    if (i == 0) return s;
    for (ll k = i; k > 0; k -= (k & -k)) {
      s += bit[k];
    }
    return s;
  }

  // a_1 + a_2 + … + a_i >= x となるような最小のiを求める(a_k >= 0)
  // xが0以下の場合は該当するものなし→0を返す
  ll lower_bound(ll x) {
    if (x <= 0) {
      return 0;
    } else {
      ll i = 0;
      ll r = 1;
      //最大としてありうる区間の長さを取得する
      // n以下の最小の二乗のべき(BITで管理する数列の区間で最大のもの)を求める
      while (r < n) r = r << 1;
      //区間の長さは調べるごとに半分になる
      for (int len = r; len > 0; len = len >> 1) {
        //その区間を採用する場合
        if (i + len < n && bit[i + len] < x) {
          x -= bit[i + len];
          i += len;
        }
      }
      return i + 1;
    }
  }
};

int main() {
  int n, q;
  cin >> n >> q;

  BIT b(n);

  for (int i = 0; i < n; i++) {
    int temp;
    cin >> temp;
    b.add(i + 1, temp);
  }

  for (int i = 0; i < q; i++) {
    int p, q, r;
    cin >> p >> q >> r;

    if (p == 0) {
      b.add(q + 1, r);
    }

    if (p == 1) {
      cout << b.sum(r) - b.sum(q) << endl;
    }
  }
}


Measured memory_bytes: 8220
"use strict";
var input=require("fs").readFileSync("/dev/stdin","utf8");
var cin=input.split(/ |\n/),cid=0;
function next(){return +cin[cid++];}
function nextstr(){return cin[cid++];}
function nextbig(){return BigInt(cin[cid++]);}
function nexts(n,a){return a?cin.slice(cid,cid+=n):cin.slice(cid,cid+=n).map(a=>+a);}
function nextm(h,w,a){var r=[],i=0;if(a)for(;i<h;i++)r.push(cin.slice(cid,cid+=w));else for(;i<h;i++)r.push(cin.slice(cid,cid+=w).map(a=>+a));return r;}
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill().map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill().map(x=>"+r+")";return eval(r);}

class priorityQueue{
  constructor(){
    this.a=[];
  }
  push(num,inc){
    const a = this.a;
    for(var i = a.length, j; i; i = j){
      j = i - 1 >> 1;
      if(a[j][0] <= num)break;
      a[i] = a[j];
    }
    a[i] = [num,inc];
  }
  pop(){
    const a = this.a, r = a[0], x = a.pop(), k = a.length >> 1;
    for(var i = 0, j; i < k; i = j){
      j = (i << 1) + 1;
      if(a[j+1] && a[j+1][0] < a[j][0])j++;
      if(x[0] <= a[j][0])break;
      a[i] = a[j];
    }
    if(a.length)a[i] = x;
    return r;
  }
  get size(){
    return this.a.length;
  }
  get top(){
    return this.a[0];
  }
}

var myOut = main();
if(myOut !== undefined)console.log(myOut);

function main(){
  var q = next();
  var div = [2n,3n,5n];
  for(var i = 0; i < q; i++){
    var n = nextbig();
    var a = [nextbig(),nextbig(),nextbig()];
    var d = nextbig();
    var pq = new priorityQueue();
    var map = new Map();
    map.set(n,0n);
    pq.push(0n,n);
    while(1){
      var [cost,now] = pq.pop();
      if(map.has(now) && map.get(now) < cost)continue;
      if(now === 1n){
        console.log((cost+d).toString());
        break;
      }
      for(var j = 0; j < 3; j++){
        var aft = now / div[j];
        if(aft === 0n){
          if(now !== 4n)continue;
          var c = 3n * d + cost;
          if(!map.has(1n) || map.get(1n) > c){
            map.set(1n,c);
            pq.push(c,1n);
          }
          now++, cost += d, aft = 1n;
        }
        var mod = now % div[j];
        var c1 = mod * d + a[j];
        var c2 = (now - aft) * d;
        if(c2 < c1)c1 = c2;
        c1 += cost;
        if(!map.has(aft) || map.get(aft) > c1){
          map.set(aft,c1);
          pq.push(c1,aft);
        }
        if(mod === 0n)continue;
        aft++;
        c1 = (div[j] - mod) * d + a[j];
        c2 = (now - aft) * d;
        if(c2 < c1)c1 = c2;
        c1 += cost;
        if(!map.has(aft) || map.get(aft) > c1){
          map.set(aft,c1);
          pq.push(c1,aft);
        }
      }
    }
  }
}

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


int main()
{
  string s;
  cin >> s;
  long long ans = 0;
  for(int bit=0; bit < (1<<s.size() - 1); ++bit){
    long long num = s[0] - '0';
    for(int i = 0; i<s.size()-1; i++){
      if (bit&(1<<i)){
        ans += num;
        num=0;
      }
      num = num*10 + s[i+1] - '0';
    }
    ans += num;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner scanner = new Scanner(System.in);
		System.out.print(" ");

		 int S= scanner.nextInt();
		 int W = scanner.nextInt();
		 
		 
		 
		 if(W>=S) {
			 System.out.println("unsafe"); 
		 }
		 else {
			 System.out.println("safe"); 
		 }

		scanner.close();
     
	}
}


Measured memory_bytes: 27048
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <utility>
#include <cstdio>
#include <vector>
#include <string>
#include <queue>
#include <stack>
#include <cmath>
#include <set>
#include <map>
#define my_abs(x) ((x) < 0 ? -(x) : (x))
#define mp std::make_pair
#define pb push_back
#define X first
#define Y second
typedef long long ll; 
int n, a[200005], b[200005];
ll ans, app[200005]; 
int calc(ll l, ll r)
{
	return std::max(0, (int)(std::upper_bound(app, app + n, r) - std::lower_bound(app, app + n, l)));
}
int main()
{
	// freopen("ARC092-D.in", "r", stdin); 
	scanf("%d", &n); 
	for (int i = 0; i < n; i++)
		scanf("%d", a + i); 
	for (int i = 0; i < n; i++)
		scanf("%d", b + i); 
	for (int i = 0; i < 30; i++)
	{
		for (int j = 0; j < n; j++)
			app[j] = b[j] & (1ll << i + 1) - 1; 
		std::sort(app, app + n);
		for (int j = 0; j < n; j++)
		{
			int x = a[j] & (1ll << i + 1) - 1; 
			if (calc((1ll << i) - x, (1ll << i + 1) - x - 1)
			 + calc((1ll << i + 1) + (1ll << i) - x, (1ll << i + 2) - x - 1) & 1)
				ans ^= 1ll << i; 
		}
	}
	printf("%lld\n", ans);
	return 0; 
}


Measured memory_bytes: 3328
#include<stdio.h>
#include<stdlib.h>


int main(){

  int n,i,j,*a,maxi,mini;
  scanf("%d",&n);

  a=(int *)malloc(n*sizeof(int));

  for(i=0;i<n;i++){
    scanf("%d",&a[i]);

  }
  mini=a[0];
  maxi=a[1]-a[0];
  for(j=1;j<n;j++){
    if(maxi<a[j]-mini)maxi=a[j]-mini;
    if(mini>a[j])mini=a[j];
  }
  printf("%d\n",maxi);


  return 0;

}



Measured memory_bytes: 2540
#include <stdio.h>
#define N 1000001

int binarySearch(int A[], int n, int key)
{
  int left=0, right=n, mid;

  while(left < right){
    mid = (left+right) / 2;
    if(A[mid] == key){
      return mid;
    } else if(key < A[mid]){
      right =  mid;
    } else {
      left = mid + 1;
    }
  }
    return 0;
}

int main(){

  int i, n, q, key, count=0;
  int A[N];
  
  scanf("%d", &n);
  for(i=0; i<n; i++){
    scanf("%d", &A[i]);
  }

  scanf("%d", &q);

  for(i=0; i<q; i++){
    scanf("%d", &key);
    if(binarySearch(A, n, key)){
	count++;
      }
  }

    printf("%d\n", count);

  return 0;
}

Measured memory_bytes: 996
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int32_t main() {
    int n;
    cin >> n;
    int ans = 0;
    for(int i = 1; i < n; ++i) {
        int cnt = (n - 1) / i;
        if (cnt > 0) {
            ans += cnt;
        }
    }
    cout << ans;
}


Measured memory_bytes: 3604
#include<cstdio>
#include<map>
using namespace std;
map<int,int> mp;
int main(){
	int n;
	scanf("%d",&n);
	int x;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&x);
		mp[x]=mp[x]+1;
	}
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&x);
		if(mp[x]>0)
			mp[x]=mp[x]-1;
		else
		{
			printf("NO\n");
			return 0;
		}
	}
	printf("YES\n");
	return 0;
}


Measured memory_bytes: 9600
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#define swap(type,a,b) do{type t=a;a=b;b=t;}while(0);
#define MAX(a,b) (((a)>(b))?(a):(b))
#define MIN(a,b) (((a)<(b))?(a):(b))
#define ll long long
#define INF 100000000
#define FOR(i,a,n) for(i=a;i<n;i++)
int comp(const void* a,const void* b){
	return *(int*)a-*(int*)b;
}
void fill(int a[],int b,int c){
	int i;
	FOR(i,0,b) a[i]=c;
	return;
}
int a[100000];
ll d[100000];
int main(void)
{
	int n,i;
	ll sum=0,cnt=0,k,t;
	scanf("%d",&n);
	k=(ll)n*(n+1)/2;
	FOR(i,0,n){
		scanf("%d",&a[i]);
		sum+=a[i];
	}
	if(sum%k){
		puts("NO");
		return 0;
	}
	t=sum/k;
	FOR(i,0,n){
		d[i]=a[i]-a[(i+1)%n]+t;
		if(d[i]<0||d[i]%n){
			puts("NO");
			return 0;
		}
		cnt+=d[i]/n;
	}
	if(cnt==t) puts("YES");
	else puts("NO");
	return 0;
}
    
    

Measured memory_bytes: 1280
#include <iostream>
#include <iomanip>
#include <queue>
#include <complex>
#include <tuple>
using namespace std;

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

const double INF = 1e16;

typedef complex<double> point;

int x[1003], y[1003], r[1003];
point p[1003];
double E[1003][1003];
double dist[1003];

signed main() {
  ios::sync_with_stdio(false);

  int xs, ys, xt, yt;
  int N;

  cin >> xs >> ys >> xt >> yt;
  point s = point(xs, ys), t = point(xt, yt);

  cin >> N;
  REP(i, N) {
    cin >> x[i] >> y[i] >> r[i];
    p[i] = point(x[i], y[i]);
  }

  REP(i, N) {
    REP(j, N) {
      E[i][j] = max(abs(p[i] - p[j]) - r[i] - r[j], 0.0);
    }
  }

  REP(i, N) {
    E[N][i]   = E[i][N]   = max(abs(p[i] - s) - r[i], 0.0);
    E[N+1][i] = E[i][N+1] = max(abs(p[i] - t) - r[i], 0.0);
  }

  E[N][N+1] = E[N+1][N] = abs(t - s);

  REP(i, N+2) {
    dist[i] = INF;
  }
  dist[N] = 0;

  priority_queue<tuple<double, int> > que;

  que.push({0, N});

  while(que.size() > 0) {
    double d; int u;
    tie(d, u) = que.top(); que.pop();
    d = -d;

    if(dist[u] < d) {
      continue;
    }
    REP(t, N+2) {
      double cost = E[u][t];
      if(d + cost < dist[t]) {
        dist[t] = d + cost;
        que.push({-dist[t], t});
      }
    }
  }

  cout << setprecision(10) << dist[N+1] << endl;
}


Measured memory_bytes: 12400
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
#define ld long double
#define pii pair<int,int>
#define fi first
#define se second
#define mex 1000005
#define fast  ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
//vector<int> adj[mex];
//a+b=a^b+2*(a&b)

// FIRST THINK, THEN CODE
// DO NOT JUMP BETWEEN PROBLEMS

int main(){
	fast
	
	int l,r,d;
	cin>>l>>r>>d;
	cout<<(r/d-(l-1)/d)<<endl;
}


Measured memory_bytes: 3648
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<iomanip>
#include<set>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define brep(index,num) for(int index=num-1;index>=0;index--)
#define brep1(index,num) for(int index=num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N;
	int a[200001];
	int nokosu=0;
	scan(N);
	rep(i,N){
		scan(a[i]);
	}
	rep(i,N){
		if(a[i]==nokosu+1){
			nokosu++;
		}
	}
	if(nokosu==0) prin(-1);
	else prin(N-nokosu);
	return 0;
}


Measured memory_bytes: 1024
import java.lang.Math.abs

fun main(args: Array<String>) {
    abc057b()
}

private data class Coordinate(val x: Long, val y: Long)

fun abc057b() {
    val (n, m) = readLine()!!.split(" ").map { it.toInt() }
    val students = (1..n).map { readLine()!!.split(" ").map { it.toInt() } }
        .map { Coordinate(it[0].toLong(), it[1].toLong()) }
    val flags = (1..m).map { readLine()!!.split(" ").map { it.toInt() } }
        .map { Coordinate(it[0].toLong(), it[1].toLong()) }

    val answer = students.map { student ->
        // index, coordinate
        var nearestFlagOfStudent = Pair(1, flags.first())
        flags.forEachIndexed { index, flag ->
            val diff = abs(student.x - flag.x) + abs(student.y - flag.y)
            val cnf = nearestFlagOfStudent.second
            val cnfDiff = abs(student.x - cnf.x) + abs(student.y - cnf.y)
            if (diff < cnfDiff) nearestFlagOfStudent = Pair(index + 1, flag)
        }
        nearestFlagOfStudent.first
    }.joinToString(System.lineSeparator())

    println(answer)
}


Measured memory_bytes: 35892