akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("-O3")
#include <bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
// using namespace __gnu_pbds;
//#include <boost/multiprecision/cpp_int.hpp>
//using namespace boost::multiprecision;
using namespace std;

#define all(c) (c).begin(),(c).end()
#define endl "\n"
#define ff first
#define ss second
#define allr(c) (c).rbegin(),(c).rend()
#define ifr(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define pof pop_front
#define pob pop_back
#define pb emplace_back
#define pf emplace_front
#define fstm(m,n,r) m.reserve(n);m.max_load_factor(r)
#define mp make_pair
#define mt make_tuple
#define inf LLONG_MAX
#define os tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
//order_of_key (k) : Number of items strictly smaller than k .
//find_by_order(k) : K-th element in a set (counting from zero).
const double PI = acos(-1);
typedef complex<double> cd;
typedef long long ll;
ll gcd(){return 0ll;} template<typename T,typename... Args> T gcd(T a,Args... args) { return __gcd(a,(__typeof(a))gcd(args...)); }
typedef map<ll,ll> mll;
typedef map<string,ll> msll;
typedef unordered_map<ll,ll> umap;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;
typedef long double ld;
#define mod 1000000007 
#define N 100001

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    ll n;
    cin>>n;
    ll ans = 0,cnt=1;
    while(n>1) {
        ans+=cnt;
        n/=2;
        cnt*=2;
    }
    ans+=cnt;
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
uses math;
{
const
        fi = 'test.inp';
        fo = 'test.out';
}
var
//        f: Text;
        a,b: array [0..4000] of int64;
        dp: array [0..4000, 0..4000] of int64;
        i,j,n: longint;
        x,y: int64;

begin
//        assign (f, fi); reset (F);
        readln (n);
        for i:= 1 to n do
        begin
                read ( a[i]);

        end;
//        close (f);

  //      assign (F, fo); rewrite (f);

        for i:=n downto 1 do
        for j:=i to n do
        begin
                if i = j then dp[i,j]:= a[i]
                else
                dp[i,j]:= max( a[i] - dp[i+1,j], a[j] - dp[i,j-1]);
        end;

        write ( dp[1,n]);
        readln;
    //    close (f);
end.



Measured memory_bytes: 95744
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	private static final int MOD = (int)Math.pow(10, 9);
	public static void main(String[] args) {
		FastReader sc = new FastReader();
		String s = sc.next();
		long k = sc.nextLong();
		char res = '1';
		int pos = 0;
		while (k > 0 && pos < s.length()) {
			char c = s.charAt(pos);
			if (c != '1') {
				res = c;
				break;
			}
			k--;
			pos++;
		}
		System.out.println(res);
	}

    static class FastReader {
	    BufferedReader br;
	    StringTokenizer st;
	
	    public FastReader() {
	      br = new BufferedReader(new InputStreamReader(System.in));
	    }
	  
	    String next() { 
	      while (st == null || !st.hasMoreElements()) {
	        try {
	          st = new StringTokenizer(br.readLine());
	        } catch (IOException  e) {
	          e.printStackTrace();
	        }
	      }
	      return st.nextToken();
	    }
	
	    int nextInt() {
	      return Integer.parseInt(next());
	    }
	
	    long nextLong() {
	      return Long.parseLong(next());
	    }
	
	    double nextDouble() { 
	      return Double.parseDouble(next());
	    }
	
	    String nextLine() {
	      String str = "";
	        try{
	            str = br.readLine();
	        } catch (IOException e) {
	            e.printStackTrace();
	        }
	        return str;
	      }
	  }
}


Measured memory_bytes: 22996
using System;
using static System.Console;
using static System.Math;

public class Hello{
    public static void Main(){
        string[] input = ReadLine().Split(' ');
        long a = long.Parse(input[0]);
        long b = long.Parse(input[1]);
        
        if(a*2 > b){
            WriteLine(b/2);
        }else{
            b -= a*2;
            b /= 4;
            WriteLine(a+b);
        }
    }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
int n, m, x;
vector <vector <int>> qw;
vector <int> pay;
vector <int> under;
long long pott;
void pot (int q)
{
    if (q!=n)
    {
        for (int i=0; i<2; ++i)
        {
            under[q]=i+1;
            pot(q+1);
        }
    }
    else
    {
        vector <int> cou (m);
        long long money=0;
        for (int i=0; i<n; ++i)
            if (under[i]==1)
            {
                for (int j=0; j<m; ++j)
                    cou[j]+=qw[i][j];
                money+=pay[i];
            }
        long long mm=cou[0];
        for (int j=1; j<m; ++j)
            if (mm>cou[j])
                mm=cou[j];
        if (x<=mm && pott>money)
            pott=money;

    }
}
int main ()
{
    pott=1000000000;
    cin >> n >> m >> x;
    long long yy=1000000000;
    vector <long long> know (m);
    qw.resize(n);
    for (int i=0; i<n; ++i)
        under.push_back(0);
    for (int i=0; i<n; ++i)
    {
        for (int j=0; j<m+1; ++j)
            if (j==0)
            {
                int f;
                cin >> f;
                pay.push_back(f);
            }
            else
            {   int f;
                cin >> f;
                qw[i].push_back(f);
                know[j-1]+=f;
            }
    }
    for (int i=0; i<m ;++i)
        if (yy>know[i])
            yy=know[i];
    if (yy<x)
        cout << -1 << endl;
    else
    {
        pot(0);
        cout << pott << endl;
    }
}



Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define FOR(i, n) for(int i = 0; i < (n); ++i)
#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define TRAV(i, a) for(auto & i : (a))
#define SZ(x) ((int)(x).size())
#define PR std::pair
#define MP std::make_pair
#define X first
#define Y second
typedef long long ll;
typedef std::pair<int, int> PII;
typedef std::vector<int> VI;
typedef long double ld;

const ld PI = std::acos((ld)-1);

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

  ld a, b, h, m;
  std::cin >> a >> b >> h >> m;

  ld min = 2*PI*m/60;
  ld hor = 2*PI*(m+h*60)/720;

  ld hx = std::sin(hor)*a;
  ld hy = std::cos(hor)*a;

  ld mx = std::sin(min)*b;
  ld my = std::cos(min)*b;

  std::cout << std::setprecision(12) << std::fixed << std::sqrt((hx-mx)*(hx-mx) + (hy-my)*(hy-my));

	return 0;
}

Measured memory_bytes: 4188
// organize and work - Abhinav IIITA
#include <bits/stdc++.h>
using namespace std;
#define int long long 
void q1(){
	int n;
	cin>>n;
	double even=n/2;
	double odd=n-even;
	double ans=odd/n;
	cout << fixed << setprecision(6) << ans <<endl; 
}
void q2(){
	int n,k,c=0;
	cin>>n>>k;
	while(n--){
	int t; cin>>t;
	if(t>=k)
	c++;
	}
	cout<<c<<endl;
}
void q3(){
	int n;	cin>>n; int arr[n];
	for(int i=1;i<=n;++i){
		int t;
		cin>>t;	t--;
		arr[t]=i;
	}
	for(int i=0;i<n;++i)
	cout<<arr[i]<< " ";
}
int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int t;
	t=1;
	while(t--)
	q3();
	return 0;
}


Measured memory_bytes: 1664
#include <stdio.h>
#include <bitset>
using namespace std;
int read()
{
	int x=0,p=1;
	char c;
	c=getchar();
	while(c<'0'||c>'9')
	{
		if(c=='-')
			p=-1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		x=x*10+c-'0';
		c=getchar();
	}
	return x*p;
}
#define N 2100
bitset<N*N>f;
int ans,x,n;
int main()
{
	n=read();
	int i;
	f[0]=1;
	for(i=1;i<=n;i++)
	{
		x=read();
		f|=f<<x;
		ans=ans+x;
	}
	for(i=(ans+1)/2;i<=ans;i++)
		if(f[i])
		{
			printf("%d\n",i);
			return 0;
		}
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod_) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod_;
		}
		x = x * x % mod_;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}
/*--------Library Zone!--------*/

int n, m, ma;
int a[114514];
signed main() {
	cin >> n >> m;
	rep(i, n) {
		int b; cin >> b; ma = max(ma, b);
		cin >> a[i];
	}
	sort(a, a + n, greater<>());
	int ans = 0;
	rep(i, n) {
		if (a[i] < ma)break;
		if (m > 0) {
			ans++; m -= a[i];
		}
		if (m < 1) {
			cout << ans << endl; return 0;
		}
	}
	ans += (m - 1) / ma + 1;
	cout << ans << endl;
}

Measured memory_bytes: 1024
z;t[99],k;char s[99];f(int*x){z=x[1]-1[&x][1];}main(n){for(;scanf("%d",&n),z=n*=2;){for(;z;t[--z]=*s)for(t[--z]=z,scanf(" %[^\n]",s),k=n;k-=2;)t[z]+=s[k]&2?30:s[k]&1?0:999;qsort(t,n/2,8,f);for(;n;puts(t+n))n-=2;}}

Measured memory_bytes: 0
import java.util.Scanner;
 
class Main {
	public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A[] = new int[N-1];
        int M[] = new int[N];
        

        for(int i=0;i<N;i++) {
        	M[i] = 0;
        }
        
        for(int i=0;i<N-1;i++) {
        	A[i] = sc.nextInt();
        }
        
        for(int i=0;i<N-1;i++) {
        	M[A[i]-1] ++;
        }
        
      
        
        for(int i=0;i<N;i++){
        System.out.println(M[i]);
        
        }
	}
}

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

int main(){
	int N, M, s = 0;
	long long ans = 0;
	cin >> N >> M;
	map<int, int> m;
	m[0] = 1;
	int A[N];
	for(int i=0; i<N; i++){
		cin >> A[i];
		s = (s + A[i]) % M;
		m[s]++;
		ans += m[s] - 1;
	}
	cout << ans << endl;
	return 0;
}

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

int main(void) {
	
	
	string S, T;
	cin >> S >> T;
	int size = S.size();
	for(int i=0; i<size; i++) {
		S = S.substr(size-1, 1)+S.substr(0,size-1);
		if(S == T) {
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
	return 0;
}

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

for i in range(N):
    s.append(int(input()))

s = sorted(s)

if sum(s) % 10 != 0:
    ans = sum(s)
else:
    for i in range(N):
        if s[i] % 10 != 0:
            ans = sum(s) - s[i]
            break
        else:
            ans = 0
print(ans)


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define INFTY 10000000000
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const int MOD=1000000007;
const int di[4] = {-1,0,1,0};
const int dj[4] = {0,-1,0,1};
const int INF = 1e9;
int main(){
    int h,w;cin>>h>>w;
    int ch,dh,cw,dw;
    cin>>ch>>cw>>dh>>dw;
    vector<string> s(h);
    int dp[1003][1003],seen[1003][1003];
    rep(i,1003){
        rep(j,1003){
            dp[i][j] = INF;
            seen[i][j]= 0;
        }
    }dp[ch-1][cw-1] = 0;
    rep(i,h)cin>>s[i];
    deque<pair<int,int>> q;
    q.emplace_back(make_pair(ch-1,cw-1));
    while(!q.empty()){
        pair<int,int> p = q.front();q.pop_front();
        int x = p.first,y = p.second;
        if(seen[x][y]||s[x][y]=='#')continue;
        seen[x][y] = 1;
        //cout<<x<<y<<endl;
        rep(i,4){
            if(0<=x+di[i]&&0<=y+dj[i]&&h>x+di[i]&&w>y+dj[i]&&s[x+di[i]][y+dj[i]]=='.'){
               if(!seen[x+di[i]][y+dj[i]])q.emplace_front(make_pair(x+di[i],y+dj[i]));
               if(dp[x+di[i]][y+dj[i]]>=0)dp[x+di[i]][y+dj[i]] = min(dp[x+di[i]][y+dj[i]],dp[x][y]);
               else dp[x+di[i]][y+dj[i]] = dp[x][y]; 
            }
        }
        for (int i = -2; i < 3; i++)
        {
            for (int j = -2; j < 3; j++)
            {
                if(i==0&&abs(j)==1||j==0&&abs(i)==1||i==0&&j==0)continue;
                if(0<=x+i&&0<=y+j&&h>x+i&&w>y+j&&s[x+i][y+j]=='.'){
                
                    if(!seen[x+i][y+j]){
                        q.emplace_back(make_pair(x+i,y+j));
                        dp[x+i][y+j] = min(dp[x+i][y+j],dp[x][y]+1);
                    }
                    
                }
            
            }
            
        }
        
    }
    if(dp[dh-1][dw-1]==INF)cout<<-1<<endl;
    else cout<<dp[dh-1][dw-1]<<endl;
    return 0;
}

Measured memory_bytes: 13720
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define F first
#define S second
#define pii pair<int, int>
#define mp make_pair
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep3(i, l, n) for (int i = l; i < (n); ++i)
#define sz(v) (int)v.size()
#define inf (int)(1e9+7)
#define abs(x) (x >= 0 ? x : -(x))
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) { if (a < b) a = b; }
template<typename T> inline T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }




int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    
    
    int n;
    cin >> n;
    int m = n - 1;
    vector<int> b(m);
    rep(i, m) cin >> b[i];
    
    int ans = 0;
    ans += b[m - 1];
    // cout << ans << endl;
    for (int i = m - 2; i >= 0; --i) {
        ans += min(b[i], b[i + 1]);
        
    }
    ans += b[0];
    cout << ans << endl;
}


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

int main(){
    int x,ans=1;cin>>x;
    for(int i=2;pow(i,2)<=x;i++){
        int k=2,v=i;
        while(v<=x){
            v*=i;
            if(v>x) ans=max(ans,v/i);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#define REP(i, b, n) for (Int i = b; i < Int(n); i++)
#define rep(i, n) REP(i, 0, n)
using namespace std;
using Int = long long;
Int inf = 1000000000000000001LL;
using vi = vector<Int>;
using vvi = vector<vi>;
using pii = pair<Int,Int>;
using mapis = unordered_map<Int,string>;
using mapii = unordered_map<Int,Int>;

Int GCD(Int a, Int b){
    if(b==0) return a;
    if(a < b) return GCD(b, a);
    unsigned r;
    while ((r=a%b)) {
        a = b;
        b = r;
    }
    return b;
}

Int LCM(Int a, Int b){
    return a*b/GCD(a,b);
}

int main() {
    Int N,M,S,T;
    cin >> N >> M;
    map<pii,vector<pii>> node;
    int from, to;
    rep(i,M){
        cin >> from >> to;

        // フェーズ付きに拡張してグラフを作る
        node[make_pair(from,0)].push_back(make_pair(to,1));
        node[make_pair(from,1)].push_back(make_pair(to,2));
        node[make_pair(from,2)].push_back(make_pair(to,0));
    }
    cin >> S >> T;

    int ans =0;

    queue<pii> next;
    map<int,map<int,int>> done;
    map<int,map<int,int>> route;
    next.push(make_pair(S,0));


    // BFSで回す
    while(!next.empty()){
        pii now = next.front();
        next.pop();
        if(done[now.first][now.second] == 1 ){
            continue;
        }

        done[now.first][now.second] = 1;

        rep(i,node[now].size()){
            pii next_node = node[now][i];
            next.push(node[now][i]);
            route[next_node.first][next_node.second] = route[now.first][now.second]+1;
        }

        if(now.first==T && now.second==0){
            break;
        }
    }

    if(done[T][0]==0){
        ans = -1;
    }else{
        ans = route[T][0]/3;
    }

    cout << ans << endl;

    return 0;
}

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

counter = 0
ans = 'No'
for i in range(N):
    D1, D2 = map(int, input().split())
    if D1 == D2:
        counter += 1
        if counter == 3:
            ans = 'Yes'
            break
    else:
        counter = 0

print(ans)

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

string s;
int n, k;

int main() {
	cin >> s >> k;
	n = s.size();
	for (int i = 0; i < n - 1; i++) {
		int x = ('z' - s[i] + 1) % 26;
		if (x <= k) {
			s[i] = 'a';
			k -= x;
		}
	}
	s[n - 1] = 'a' + ((s[n - 1] - 'a') + k) % 26;
	cout << s << endl;
}


Measured memory_bytes: 512
#include<stdio.h>

int main(void){
	int number[3];
	int change = 0;
	int i = 0;
	int j = 0;
		
	scanf("%d %d %d", &number[0], &number[1], &number[2]);
	
	if(number[0] > number[1]){
		change = number[0];
		number[0] = number[1];
		number[1] = change;
	}
	if(number[1] > number[2]){
		change = number[1];
		number[1] = number[2];
		number[2] = change;
		if(number[0] > number[1]){
			change = number[0];
			number[0] = number[1];
			number[1] = change;
		}
	}
	
	printf("%d %d %d\n", number[0], number[1], number[2]);
	
	return 0;
}


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

int main() {
	int n, m;
	cin >> n;
	vector<int> a(n);
	for (int& i : a) cin >> i;
	cin >> m;
	vector<int> b(m);
	for (int& i : b) cin >> i;
	cout << (a < b) << endl;
}


Measured memory_bytes: 3100
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#define INF 9223372036854775807
#define MOD 1000000007
#define PI 4*atan(1.0)
typedef long long ll;
typedef long double ld;
using namespace std;
int dx[4]={0,0,-1,1};
int dy[4]={-1,1,0,0};
const int SIZE=1001;
//int arr[SIZE]={};
//ここまでテンプレ
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(auto i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
typedef ll Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;

typedef vector<Weight> Array;
typedef vector<Array> Matrix;
void shortestPath(const Graph &g, int s,
    vector<Weight> &dist, vector<int> &prev) {
  int n = g.size();
  dist.assign(n, INF); dist[s] = 0;
  prev.assign(n, -1);
  priority_queue<Edge> Q; // "e < f" <=> "e.weight > f.weight"
  for (Q.push(Edge(-2, s, 0)); !Q.empty(); ) {
    Edge e = Q.top(); Q.pop();
    if (prev[e.dst] != -1) continue;
    prev[e.dst] = e.src;
    FOR(f,g[e.dst]) {
      if (dist[f->dst] > e.weight+f->weight) {
        dist[f->dst] = e.weight+f->weight;
        Q.push(Edge(f->src, f->dst, e.weight+f->weight));
      }
    }
  }
}
vector<int> buildPath(const vector<int> &prev, int t) {
  vector<int> path;
  for (int u = t; u >= 0; u = prev[u])
    path.push_back(u);
  reverse(path.begin(), path.end());
  return path;
}
int main(){
	Graph G;
	int N;
	cin>>N;
	for(int i=0;i<N;i++){
		Edges E;
		G.push_back(E);
	}
	for(int i=0;i<N-1;i++){
		int a,b;
		ll c;
		cin>>a>>b>>c;
		a--,b--;
		G[a].push_back(Edge(a,b,c));
		G[b].push_back(Edge(b,a,c));
	}
	int Q,K;
	cin>>Q>>K;
	K--;
	vector<Weight> dist;
	vector<int> prev;
	shortestPath(G,K,dist,prev);
	for(int i=0;i<Q;i++){
		int x,y;
		cin>>x>>y;
		x--,y--;
		cout<<dist[x]+dist[y]<<endl;
	}
	return 0;
}


Measured memory_bytes: 12656
from heapq import heapify, heappop, heappush, heappushpop


class PriorityQueue:
    def __init__(self, heap):
        '''
        heap ... list
        '''
        self.heap = heap
        heapify(self.heap)

    def push(self, item):
        heappush(self.heap, item)

    def pop(self):
        return heappop(self.heap)

    def pushpop(self, item):
        return heappushpop(self.heap, item)

    def __call__(self):
        return self.heap

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


def dijkstra(graph, s, N):
    '''
    graph...隣接リスト形式 リスト内要素は(ノード, エッジ長)
    s...始点ノード
    N...頂点数

    return
    ----------
    D ... 各点までの最短距離
    P ... 最短経路木における親
    '''
    pq = PriorityQueue([])
    P = [None] * N
    D = [float('inf')] * N
    D[s] = 0
    pq.push((D[s], s))  # (最短距離, 次のノード)
    while pq:
        d, v = pq.pop()
        if D[v] < d:  # この辺を扱っても最短距離にならない
            continue  # is_visitedなくてもこれを使うことで最小のものを再び探索するのを防げる
        for to, cost in graph[v]:
            if D[to] > D[v] + cost:  # v周りにおける最短経路の候補の更新
                D[to] = D[v] + cost
                pq.push((D[to], to))
                P[to] = v
    return D, P

# load datas
N = int(input())
adj = [[] for _ in range(N)]  # (node_id, 隣接要素, 隣接nodeidとコスト)の順で格納する
'''
例
[
(0について) [(1,1235), (4,65)]
(1について) [(20,6000)]
...
]
'''
for _ in range(N):
    tmp = list(map(int, input().split()))
    if tmp[1] != 0:
        node = tmp[0]
        for i in range(2, 2 + tmp[1] * 2, 2):
            adj[node].append((tmp[i], tmp[i + 1]))

D, P = dijkstra(adj, 0,N)

for i in range(N):
    print(i, D[i])


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

#define ln '\n'
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, a, b) for(int i = (a); i <= (int)(b); ++i)
#define FORR(i, a, b) for(int i = (a); i >= (int)(b); --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;
typedef vector<P> VP;
typedef vector<PL> VPL;
typedef vector<string> VS;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    VI t(n), v(n);
    REP(i, n) cin >> t[i];
    REP(i, n) {
        cin >> v[i];
        v[i] *= 2;
    }

    VI vmin;
    REP(i, n)REP(j, t[i] * 2) {
        if(j == 0 and i > 0) vmin.push_back(min(vmin.back(), v[i]));
        else vmin.push_back(v[i]);
    }
    vmin[0] = 0;
    vmin.push_back(0);
    
    int t_st = 0;
    REP(i, n) {
        FOR(j, t_st + 1, vmin.size() - 1)
            vmin[j] = min(vmin[j], vmin[j - 1] + 1);
        t_st += t[i] * 2;
    }

    t_st = vmin.size() - 1;
    FORR(i, n - 1, 0) {
        FORR(j, t_st - 1, 0)
            vmin[j] = min(vmin[j], vmin[j + 1] + 1);
        t_st -= t[i] * 2;
    }

    int ans = 0;
    REP(i, vmin.size() - 1)
        ans += vmin[i] + vmin[i + 1];
    cout << fixed << setprecision(4) << (double)ans / 8 << ln;
    return 0;
}



Measured memory_bytes: 636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<=n;i++)
const ll MOD = 1000000007;
long long modinv(long long a, long long m=MOD) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
    /*MODの割り算の際に
    a/＝b;
    を
    a *= modinv(b,MOD);
    とする。
        */
}
int main(){
    int x;
    cin >> x;
    if(x>=30)cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

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



#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)

using namespace std;

template <class T>
using vec = std::vector<T>;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

const long long INF = 1LL<<60;

int lcm(int a,int b){
    //最小公倍数
    return a/__gcd(a,b) * b;
}

int k;

int main()
{
    cin>>k;
    ll sum=0;
    int tmp;
    loop(a,1,k+1)loop(b,1,k+1)loop(c,1,k+1){
        tmp=__gcd(a,b);
        sum+=__gcd(tmp,c);
    }
    cout<<sum<<endl;

    return 0;

}




Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;

int main() {
  int k, x;
  cin >> k >> x;
  for (int n = x - k + 1; n <= x + k - 1; n++) {
    cout << n << ' ';
  }

  cout << endl;
  return 0;
}


Measured memory_bytes: 3588
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
	Scanner sc = new Scanner(System.in);
 int s = sc.nextInt();
 int sec=(s%3600)%60;
 int min=(s%3600)/60;
 int hour=s/3600;
System.out.println(hour+ ":"+min +":"+sec);
}}

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


int main(){
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
ios_base::sync_with_stdio(false);
cin.tie(NULL);
       string s,t,s1;
       cin>>s>>t;
       int tt = t.length();

       s1 = t[tt-1];
       
       s = s+s1;
       if(s==t)
        cout<<"Yes"<<"\n";
      else
        cout<<"No"<<"\n";
       /*int count=0;
       int i;
       for(i=0;s[i]!='\0';i++){
        if(s[i]!=t[i])
          count++;
       }
       cout<<s.size()<<endl;
       cout<<t.size()<<endl;
       if(t.size()==s.size()+1)
       {if(count)
        cout<<"N0"<<"\n";
      else{
        if(t[i] >= 'a' && t[i] <= 'z')
          cout<<"Yes"<<"\n";
        else
          cout<<"No"<<"\n";
      }}
      else
        cout<<"No"<<"\n";*/
     return 0;   
            
        
}



Measured memory_bytes: 3656
#include<cstdio>
#include<cstring>
using namespace std;
const int MAX = 100000 + 10;
char str[MAX];
int main(){
  scanf("%s", str);
  int len = strlen(str);
  int ansl = -1, ansr = -1;
  for(int i = 0 ; i < len-1 ; i++){
    if(str[i] == str[i+1]){
      ansl = i+1, ansr = i+2;
    }
  }
  for(int i = 0 ; i < len-2 ; i++){
    if(str[i] == str[i+2]){
      ansl = i+1, ansr = i+3;
    }
  }
  printf("%d %d\n", ansl, ansr);
  return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
a=[input() for q in range(n)]
b=[input() for w in range(m)]
Flag=False
for i in range (n-m+1):
    for j in range (n-m+1):
        Flag=False
        for I in range(m):
            for J in range(m):
                if a[i+I][j+J]==b[I][J]:
                    continue
                else:
                    Flag=True
                    break
        if Flag:
            continue
        else:
            print("Yes")
            exit()
print("No")
             

Measured memory_bytes: 3064
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cstdio>
const int mod = 1000000007;
using namespace std;
int main(){
	int n;
	long long ans=1;
	cin>>n;
	for(register int i=1;i<=n;i++){
		ans=ans*i;ans%=mod;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define r(i,n) for(int i=0;i<n;i++)
int uni[100000],r[100000];
int find(int a){
  if(a!=uni[a])a=find(uni[a]);
  return a;
}
bool same(int a,int b){
  return find(a)==find(b);
}
void unit(int a,int b){
  int c=find(a),d=find(b);
  if(r[c]>r[d])uni[d]=c;
  else{uni[c]=d;
    if(r[c]==r[d])r[c]++;
  }
}
int ans,n,w,h,sum,c,y[100000],x[100000];
bool used[100000];
int main(){
  cin>>n>>w>>h;
  r(i,n)uni[i]=i,r[i]=0;
  r(i,n)cin>>x[i]>>y[i];
  r(i,n)r(j,n)if(x[i]==x[j]||y[i]==y[j])unit(i,j);
  r(i,n)if(!used[i]){
    int f=0;
    used[i]=1;
    for(int j=i;j<n;j++){
      if(same(i,j)){//cout<<w<<h<<endl;
        used[j]=1;
        if(x[j]==1)f++;
        else if(x[j]==w)f++;
        else if(y[j]==1)f++;
        else if(y[j]==h)f++;
      }
    }
    if(f)sum=1;
    c++;
  }
  if(c==1)cout<<n-1<<endl;
  else cout<<n+c-1-sum<<endl;
}


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

int main(){
    while(true){
        string s;
        cin >> s;
        if(s == "0"){
            break;
        }
        int n = s.size();
        int ans = 0;
        for(int i = 0; i < n; i++){
            ans += s[i]-'0';
        }
        cout << ans << endl;
    }
    return 0;
}


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

long long solve(long long h) {
  if (h == 1) {
    return 1;
  }
  return 1 + 2 * solve(h / 2);
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  long long h;
  cin >> h;
  cout << solve(h) << '\n';
  return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define _ ios::sync_with_stdio(false);cin.tie(0);

using namespace std;

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


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

int main() {
	long N;
  cin >> N;
  long i=0;
  long ma=0;
  long ans=0;
  while( i*(i+1)<N ){
    ma = i;
    i++;
  }
  for (long j=1; j <= ma; j++){
  if(N%j==0){
    ans = ans + (N/j) - 1;
  }
  }
  
  
  
  cout << ans << endl;
    
}

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

typedef long long ll;
typedef long long LL;
typedef pair<int,int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

#ifdef DEBUG
    #define cek(x) cout<<x
#else
    #define cek(x) if(false){}
#endif // DEBUG

#define fi first
#define se second
#define INF 1000000000
#define INFLL 1000000000000000000LL
#define EPS 1e-9
#define PI acos(-1.0)
#define pb push_back
#define TC() while(tc--)
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORN(i,n) for(int i=0;i<=n;i++)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define REPN(i,a,b) for(int i=a;i<=b;i++)
#define reset(a,b) memset(a,b,sizeof(a))
#define sc(x) scanf("%d",&x)

void open(){
	freopen("D:/Code/in.txt","r",stdin);
	freopen("D:/Code/out.txt", "w", stdout);
}

int val[100010];
vi adjList[100010];
ll ss[100010];
bool valid;

void dfs(int node, int p = -1){
	ll totwajib = 0;
	vector<ll> sisa;
	for(int i = 0;i<adjList[node].size();i++){
		int nxt = adjList[node][i];
		if(nxt == p)continue;
		if(adjList[nxt].size() == 1){
			sisa.pb(val[nxt]);
		}else{
			dfs(nxt, node);
			sisa.pb(ss[nxt]);
		}
	}

	sort(sisa.begin(), sisa.end());
	ll cur = 0;
	int l, rr;
	ll maxi = 0;
	l = 0;
	rr = sisa.size() - 1;
	FOR(i,sisa.size()){
		
		maxi += sisa[i];
		// cout <<"maxi : " << maxi << endl;
	}
	
	ll kurang;

	if(2 * sisa[sisa.size()-1] <= maxi){
		kurang = maxi/2;
	}else kurang = maxi - sisa[sisa.size()-1];

	ll benersisa = maxi - kurang * 2;
	totwajib = benersisa + kurang;
	
	// printf("node %d : %I64d %I64d %d\n", node, totwajib, maxi, val[node]);
	if(totwajib > val[node])valid = false;
	if(maxi < val[node])valid = false;
	ll nonp = val[node] - benersisa - kurang;
	ss[node] = benersisa + 2 * nonp;
	// if(!valid){
	// 	printf("valid not : %d\n",node);
	// }

	// if(totwajib + gawajib < val[node])
}

int main(void){
	int n;
	sc(n);
	reset(ss, 0);
	FOR(i,n){
		sc(val[i]);
	}

	valid = true;

	FOR(i,n-1){
		int fr, to;
		sc(fr);sc(to);
		fr--,to--;
		adjList[fr].pb(to);
		adjList[to].pb(fr);
	}

	if(n == 2){
		printf("%s", (val[0] == val[1]) ? "YES" : "NO");
		return 0;
	}

	FOR(i,n){
		if(adjList[i].size() != 1){
			// cout << i << endl;
			dfs(i);
			if(ss[i] != 0)valid = false;
			// cout << ss[i] << endl;
			break;
		}
	}

	printf("%s", valid ? "YES" : "NO");



    return 0;
}




Measured memory_bytes: 17664
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
typedef long long ll;
int main() {
    int n;cin>>n;
    int count=0;
    string s;
    for (int i = 1; i <=n ; i++)
    {
        s=to_string(i);
        if (s.size()%2!=0)
        {
            /* code */
            count++;
        }
        
        
    }
    cout<<count<<endl;
    
  
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define dunk(n) cout << n << endl
#define all(a) (a).begin(),(a).end()
int main() {
    long long n,ans = 0;
    cin >> n;
    for(long long i = 1; i <= n; i++){
        if(i%3 != 0 && i%5 != 0) ans += i;
    }
  dunk(ans);
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

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

int main(){
    ll m, n;
    cin >> m >> n;
    cout << modpow(m, n, 1e9+7) << endl;
}


Measured memory_bytes: 3116
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  vector<int> x(5);
  REP(i, 5){
    cin >> x[i];
  }
  REP(i, 5){
    if(x[i] == 0){
      cout << i+1 << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
const long long mod = pow(10, 9) + 7;
const long long MOD = 998244353;
const long long INF = 1LL << 60;
const int inf = pow(10, 9) + 7;
template <class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template <class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
int divCeil(int A, int B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, int B) {return (A + (B - 1)) / B;}
long long divCeil(int A, long long B) {return (A + (B - 1)) / B;}
long long divCeil(long long A, long long B) {return (A + (B - 1)) / B;}

int main()
{
  int N, M;
  cin >> N >> M;
  vector<string> A(N), B(M);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  for (int i = 0; i < M; i++) cin >> B.at(i);
  
  string ans = "No";
  for (int i = 0; i < N - M + 1; i++)
  {
    for (int j = 0; j < N - M + 1; j++)
    {
      bool flg = true;
      for (int k = 0; k < M; k++)
      {
        string S = (A.at(j + k).substr(i, M));
        if (S != B.at(k)) {flg = false; break;}
      }
      if (flg) {ans = "Yes"; break;}
    }
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<cmath>
#include<string>
#include<stack>
#include<set>
#include<queue>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll m = (1e+9) + 7;

int main() {
	int n, d, ans = 0;
	cin >> n >> d;
	cout << ceil((double)n/(2*d+1)) << endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
/*
g++ -std=c++11 -Wall -g -fsanitize=undefined -D_GLIBCXX_DEBUG library/dijkstra.cpp
*/
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define SZ(x) ((int)(x).size())
typedef long long ll;
#define INF (1e16)

int n, m, s, t;

vector<vector<pair<int, ll>>> g;// i番目のノードから出るj番目のedgeの行き先がfirst, コストがsecond
vector<vector<pair<int, ll>>> g2;

vector<ll> dist;
vector<ll> dist2;

void dijkstra(){// 1はじまりのindex
    priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> q;
    q.push(make_pair(0, s));// 始点
    vector<int> visited(n + 1);
    for(int i = 1; i <= n; i++){
        visited[i] = 0;
    }

    while(!q.empty()){
        pair<ll, int> p = q.top();
        q.pop();
        int nd = p.second;//nd番目のノード
        visited[nd] = 1;
        rep(i, g[nd].size()){
            int next = g[nd][i].first;// ndから出るi本目のedgeの行き先
            ll nd_next = g[nd][i].second;// nd <--> next間の距離
            if(visited[next] == 1) continue;

            if(dist[next] > dist[nd] + nd_next){
                dist[next] = dist[nd] + nd_next;
                q.push(make_pair(dist[next], next));
            }
        }
    }
}

void dijkstra2(){// 1はじまりのindex
    priority_queue<pair<ll, int>, vector<pair<ll, int>>, greater<pair<ll, int>>> q;
    q.push(make_pair(0, t));// 始点
    vector<int> visited(n + 1);
    for(int i = 1; i <= n; i++){
        visited[i] = 0;
    }

    while(!q.empty()){
        pair<ll, int> p = q.top();
        q.pop();
        int nd = p.second;//nd番目のノード
        visited[nd] = 1;
        rep(i, g2[nd].size()){
            int next = g2[nd][i].first;// ndから出るi本目のedgeの行き先
            ll nd_next = g2[nd][i].second;// nd <--> next間の距離
            if(visited[next] == 1) continue;

            if(dist2[next] > dist2[nd] + nd_next){
                dist2[next] = dist2[nd] + nd_next;
                q.push(make_pair(dist2[next], next));
            }
        }
    }
}

int main(){
    cin >> n >> m >> s >> t;
    g.resize(n + 1);
    g2.resize(n + 1);
    dist.resize(n + 1);
    dist2.resize(n + 1);
    for(int i = 1; i <= n; i++){
        dist[i] = INF;
        dist2[i] = INF;
    }
    dist[s] = 0;
    dist2[t] = 0;
    rep(i, m){
        int u, v, a, b;
        cin >> u >> v >> a >> b;
        g[u].push_back(make_pair(v, a));
        g[v].push_back(make_pair(u, a));
        g2[u].push_back(make_pair(v, b));
        g2[v].push_back(make_pair(u, b));
    }
    
    dijkstra();
    dijkstra2();

    vector<ll> ans(n);
    ans[n - 1] = dist[n] + dist2[n];
    for(int i = n - 2; i >= 0; i--){
        if(dist[i + 1] + dist2[i + 1] < ans[i + 1]){
            ans[i] = dist[i + 1] + dist2[i + 1];
        }else{
            ans[i] = ans[i + 1];
        }
    }
    ll tmp = 1e15;
    rep(i, n){
        cout << tmp - ans[i] << "\n";
    }
    return 0;
}

Measured memory_bytes: 19320
#include <stdio.h>
#include <stdlib.h>
int
main(void) {
    int pch = 0;
    int cnt = -1;
    for (;;) {
        int ch = getchar();
        if (ch != 'B' && ch != 'W') {
            printf("%d\n", cnt);
            exit(0);
        }
        if (pch != ch)
            cnt++;
        pch = ch;
    }
}



Measured memory_bytes: 256
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
const int INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
const ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q, now;

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

  cin >> s >> k;
  rep(i, Size(s)) {
    cnt = 0;
    rep(j, Size(alph)) {
      if (alph[j] == s[i]) now = j;
    }
    while (1) {
      if (alph[now] == 'a') break;
      now++;
      now %= 26;
      cnt++;
    }
    if (cnt <= k) {
      s[i] = 'a';
      k -= cnt;
    }
  }
  k %= 26;
  rep(j, Size(alph)) {
    if (alph[j] == s[Size(s) - 1]) now = j;
  }
  while (1) {
    s[Size(s) - 1] = alph[now];
    if (k == 0) break;
    now++;
    now %= 26;
    k--;
  }
  Cout(s);
  return 0;
}

Measured memory_bytes: 592
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<cctype>
#include<complex>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<functional>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<bitset>
#include<numeric>
#define INF 1e+8
#define EPS 1e-8
#define PB push_back
#define fi first
#define se second
#define rep(i,j) for(int  i = 0; i < (j); i++)
#define reps(i,j,k) for(int i = j; i < k; i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
int main(){
    int w,h,n;
    int ans = 0;
    int bx,by;
    scanf("%d%d%d",&w,&h,&n);
    scanf("%d%d",&bx,&by);
    rep(i,n-1){
        int nx,ny;
        scanf("%d%d",&nx,&ny);
        if((nx-bx >= 0 && ny-by >= 0) || (nx-bx <= 0 && ny-by <= 0)){
            ans += max(abs(nx-bx),abs(ny-by));
        }
        else{
            ans += (abs(nx-bx)+abs(ny-by));
        }
        bx = nx;
        by = ny;
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1188
// #define STOPIT
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;

void debug_impl() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
    #define debug(...)\
    do {\
        cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
        debug_impl(__VA_ARGS__);\
        cerr << std::noboolalpha;\
    } while (false)
#else
    #define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, enable_if_t<!is_same< Container, string >::value, nullptr_t> = nullptr>
istream& operator>> (istream& is, Container& v)
  { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, enable_if_t<!is_same< Container, string >::value, nullptr_t> = nullptr >
ostream& operator<< (ostream& os, Container const& v) {
  os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}";
}
struct UnionFind
{
    int n;
    vector<int> parent;
    vector<int> rank;
    UnionFind(int _n) :n(_n)
    {
        parent.assign(n, -1);
        rank.assign(n, 1);
    }

    int find(int i)
    {
        if (parent[i] == -1)
            return i;
        else
            return parent[i] = find(parent[i]);
    }

    void unite(int i, int j)
    {
        i = find(i);
        j = find(j);

        if (i == j) return;

        if (rank[i] == rank[j])
        {
            parent[j] = i;
            ++rank[i];
        }
        else
        {
            if (rank[i] < rank[j]) swap(i, j);
            parent[j] = i;
        }
    }

    bool is_same(int i, int j)
    {
        return find(i) == find(j);
    }
};

using pii = pair<int, int>;
using tiii = tuple<int, int, int>;

int main()
{
    ll N;
    cin >> N;
    vector<pii> data_x, data_y;
    rep(i, 0, N)
    {
        // read data
        int x, y;
        cin >> x >> y;
        data_x.emplace_back(x, i);
        data_y.emplace_back(y, i);
    }

    // sort each data
    sort(data_x.begin(), data_x.end());
    sort(data_y.begin(), data_y.end());

    // make graph
    vector<tiii> edge;
    for (int i=0; i<N-1; ++i)
    {
        int dx = abs(data_x[i].first - data_x[i+1].first);
        int dy = abs(data_y[i].first - data_y[i+1].first);
        
        edge.push_back(make_tuple(dx, data_x[i].second, data_x[i+1].second));
        edge.push_back(make_tuple(dy, data_y[i].second, data_y[i+1].second));
    }

    // do kruskal
    sort(edge.begin(), edge.end());
    int pos = 0;
    ll money = 0;
    UnionFind uf(N);
    while (pos<edge.size())
    {
        int d, from, to;
        tie(d, from, to) = edge[pos];
        ++pos;

        if (uf.is_same(from, to)) continue;

        uf.unite(from, to);
        money += d;
    }
    cout << money << endl;
    return 0;
}


Measured memory_bytes: 7144
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1LL << 60;
#define REP(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, n) for (ll i = a; i < n; i++)
struct kukan{
    ll s,t;
};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    vector<kukan>A(n);
    REP(i,n){
        ll x,a;
        cin >> x >> a;
        A[i]= {x-a, x+a};
    }
    sort(A.begin(), A.end(), [](const kukan &a, const kukan &b) { return a.s < b.s; });
    sort(A.begin(), A.end(), [](const kukan &a, const kukan &b) { return a.t < b.t; });
    ll ans= 0; 
    ll tt= A[0].s-1;
    REP(i,n){
        if(tt<=A[i].s){
            ans++;
            tt= A[i].t;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
//
//  CPlibrary
//
//  Created by Tanmay Singh on 3/03/2020.
// INDIAN INSTITUTE OF TECHNOLOGY (BHU) , VARANASI
//  Copyright © 2020 Tanmay Singh. All rights reserved.
//#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
//#pragma GCC optimization ("unroll-loops")
 
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <climits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <ratio>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
 
#define FAST(); ios_base::sync_with_stdio(false);cin.tie(NULL);
#define endl "\n"
#define mod 1000000007
typedef long long int  bigint ;
typedef std::vector< int > vi;
typedef std::vector< long long int > vll;
typedef std::vector< vi > vvi;
 
using namespace std;

int main(){
    FAST() ;
    int N ; cin >> N ;
    int arr[N] , freq[100001] = { 0 } ;
    for( int i = 0 ; i < N ; i++ ){
        cin >> arr[i] ;
        freq[arr[i]] ++ ;
    }
    int curr = freq[0] + freq[1] + freq[2] ;
    int ans = curr ;
    for( int i = 3 ; i < 100001 ; i++ ){
        curr += freq[i] - freq[i-3] ;
        ans = max( ans , curr ) ;
    }
    cout << ans << endl ;
    return 0 ;
}


Measured memory_bytes: 1024
package main

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

var (
	h, w int
	s    []string
	ch   = make(chan [][]int)
)

func calcLeft() {
	ls := make([][]int, h)
	for i := range ls {
		ls[i] = make([]int, w)
		for j := 0; j < w; j++ {
			if s[i][j] == '#' {
				ls[i][j] = 0
				continue
			}
			if j == 0 {
				ls[i][j] = 1
				continue
			}
			ls[i][j] = ls[i][j-1] + 1
		}
	}
	ch <- ls
}

func calcRight() {
	rs := make([][]int, h)
	for i := range rs {
		rs[i] = make([]int, w)
		for j := w - 1; j >= 0; j-- {
			if s[i][j] == '#' {
				rs[i][j] = 0
				continue
			}
			if j == w-1 {
				rs[i][j] = 1
				continue
			}
			rs[i][j] = rs[i][j+1] + 1
		}
	}
	ch <- rs
}

func calcTop() {
	ts := make([][]int, h)
	for i := range ts {
		ts[i] = make([]int, w)
	}
	for j := 0; j < w; j++ {
		for i := 0; i < h; i++ {
			if s[i][j] == '#' {
				ts[i][j] = 0
				continue
			}
			if i == 0 {
				ts[i][j] = 1
				continue
			}
			ts[i][j] = ts[i-1][j] + 1
		}
	}
	ch <- ts
}

func calcDown() {
	ds := make([][]int, h)
	for i := range ds {
		ds[i] = make([]int, w)
	}
	for j := 0; j < w; j++ {
		for i := h - 1; i >= 0; i-- {
			if s[i][j] == '#' {
				ds[i][j] = 0
				continue
			}
			if i == h-1 {
				ds[i][j] = 1
				continue
			}
			ds[i][j] = ds[i+1][j] + 1
		}
	}
	ch <- ds
}

func main() {
	fmt.Scan(&h, &w)

	sc := bufio.NewScanner(os.Stdin)
	s = make([]string, h)
	for i := range s {
		sc.Scan()
		s[i] = sc.Text()
	}

	go calcLeft()
	go calcRight()
	go calcTop()
	go calcDown()

	s1 := <-ch
	s2 := <-ch
	s3 := <-ch
	s4 := <-ch
	ans := 0
	for i := 0; i < h; i++ {
		for j := 0; j < w; j++ {
			if v := s1[i][j] + s2[i][j] + s3[i][j] + s4[i][j] - 3; v > ans {
				ans = v
			}
		}
	}
	fmt.Println(ans)
}


Measured memory_bytes: 138260