akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstdlib>
#include<vector>
#include<map>
#include<cassert>
#include<iomanip>
#include<queue>
#include<set>
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<28)
#define MAX 100
#define MAX2 2510
using namespace std;
/*
struct P
{
  int x,y,cost;
  P(int x=-1,int y=-1,int cost=-inf):x(x),y(y),cost(cost){}
};
*/

int h,w;
//string G[MAX][MAX];
//int mincost[MAX2][MAX2];
vector<int> vec[MAX2];
int dp[MAX2];
//int Index[MAX2];
int dx[] = {0,1,0,-1};
int dy[] = {1,0,-1,0};

int getManhattan(int a,int b)
{
  int x1 = a%w;
  int y1 = a/w;
  int x2 = b%w;
  int y2 = b/w; 
  return abs(x1-x2) + abs(y1-y2);
}

int main()
{
  while(cin >> w >> h,w|h)
    {
      //vector<int> ps;
      //rep(i,MAX2)rep(j,MAX2)mincost[i][j] = inf;
      rep(i,MAX2)
	{
	  //Index[i] = -inf;
	  dp[i] = inf;
	  vec[i].clear(); 
	}
      int max_digit = -inf;
      //int index = 0;
      int g;
      rep(i,h)
	{
	  rep(j,w)
	    {
	      string s;
	      cin >> s;
	      if(s[0] == '.')continue;
	      if(s[0] == 'S')
		{
		  //ps.push_back(index);
		  //Index[j+i*w] = index++;
		  vec[0].push_back(j+i*w);
		  dp[j+i*w] = 0;
		}
	      else if(s[0] == 'G')
		{
		  g = j+i*w;	  
		}
	      else
		{
		  //Index[j+i*w] = index;
		  //ps.push_back(index++);
		  int intValue = (atoi)(s.c_str());
		  assert(intValue < MAX2);
		  vec[intValue].push_back(j+i*w);
		  max_digit = max(max_digit,intValue);
		}
	    }
	}

      //Index[g] = index;
      //ps.push_back(index++);
      if(max_digit == -inf)max_digit = 0;
      vec[++max_digit].push_back(g);

      /*
      rep(i,max_digit-1)
	{
	  rep(j,vec[i].size())
	    {
	      int x = vec[i][j]%w;
	      int y = vec[i][j]/w;
	      queue<P> que;
	      que.push(P(x,y,0));
	      mincost[vec[i][j]][vec[i][j]] = 0;
	      while(!que.empty())
		{
		  P p = que.front(); que.pop();

		  rep(k,4)
		    {
		      int nx = p.x + dx[k];
		      int ny = p.y + dy[k];
		      if(!(0 <= nx && nx < w && 0 <= ny && ny < h))continue;
		      if(mincost[vec[i][j]][nx+ny*w] > p.cost + 1)
			{
			  mincost[vec[i][j]][nx+ny*w] = p.cost + 1;
			  que.push(P(nx,ny,p.cost+1));
			}
		    }
		}
	    }
	}
*/
    

      rep(i,max_digit)
	{
	  rep(j,vec[i].size())
	    {
	      //cout << "now : " << vec[i][j] << " (" << vec[i][j]%w << "," << vec[i][j]/w << ")" << endl;
	      if(dp[vec[i][j]] == inf)continue;
	      rep(k,vec[i+1].size())
		{
		  dp[vec[i+1][k]] = min(dp[vec[i+1][k]],
					dp[vec[i  ][j]]+getManhattan(vec[i][j],vec[i+1][k])/*mincost[vec[i][j]][vec[i+1][k]]*/);
		}
	    }
	}
      assert(max_digit < MAX2);
      assert(vec[max_digit][0] < MAX2);
      cout << dp[vec[max_digit][0]] << endl;
    }
  return 0;
}

Measured memory_bytes: 1416
//ようこ
#include<iostream>
#include<string>
using namespace std;

string n;

int sw(int a,int b,int c,int ans){
	if(n[a] == n[b] && n[b] == n[c]){
		if(n[a] == 'o'){return 1;}
		if(n[a] == 'x'){return 0;}
	}
	return ans != -1 ? ans : -1;
}
int main(void){
	while(cin>>n){
		int ans = -1;
		ans=sw(0,1,2,ans);
		ans=sw(3,4,5,ans);
		ans=sw(6,7,8,ans);
		ans=sw(0,4,8,ans);
		ans=sw(2,4,6,ans);
		ans=sw(0,3,6,ans);
		ans=sw(1,4,7,ans);
		ans=sw(2,5,8,ans);
		
		if(ans == 0)cout<<'x';
		else if(ans == 1)cout<<'o';
		else cout<<"d"; 
		cout<<endl;
	}
}

Measured memory_bytes: 1172
#include <iostream>
#include <vector>
using namespace std;
int cnt = 0;
int power(int a,int x)
{
    if(x==0)
        return 1;
    else if (x==1)
        return a;
    else
        return power(a,x-1)*a;
}
void insertSort(vector<int> &a,int g)
{
    unsigned int i;
    int v,j;
    for(i=g;i<a.size();i++)
    {
        v = a[i];
        j = i-g;
        while(j>=0&&a[j]>v)
        {
            a[j+g]=a[j];
            j -= g;
            cnt++;
        }
        a[j+g]=v;
    }
}
void shellSort(vector<int> &a,const vector<int> &g)
{
    for(unsigned int i=0;i<g.size();i++)
        insertSort(a,g[i]);
    return ;
}
int main()
{
    int n,m;
    unsigned int i,length;
    vector<int> input,g;
    cin>>n;
    for(int i=0;i<n;i++)
    {
        cin>>m;
        input.push_back(m);
    }
    for(i=31;i>=0;i--)
    {
        if((n>>i)%2==1)
            break;
    }
    length = i+1;
    m=power(2,i);
    for(i=0;i<length;i++)
    {
        g.push_back(m);
        m /= 2;
    }
    shellSort(input,g);
    cout<<g.size()<<endl;
    for(i=0;i<g.size();i++)
    {
        if(i)
            cout<<' ';
        cout<<g[i];
    }
    cout<<endl<<cnt<<endl;
    for(i=0;i<input.size();i++)
        cout<<input[i]<<endl;
    return 0;
}

Measured memory_bytes: 7024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int,int>> vp;
typedef pair<int,int> pii;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i,n) for(int i=0; i<(int)(n);i++)
#define REP(i,n) for(int i=1;i<=(int)(n);i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define ALL(a)  a.begin(),a.end()
#define RALL(a) a.begin(),a.end(),greater<int>()
#define ROT(a) a.begin(),a.begin()+1,a.end()
#define RROT(a) a.begin(),a.end()-1,a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9+7;
const int MAX = 10000000;
template<typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a, T b) { if (b == 0) return a; return gcd(b, a % b); }
//cout << 'H' << endl;
//next_permutation(ALL(p));
//typedef priority_queue<int> pque;//これは大きい順
//typedef priority_queue<int, vector<int>, greater<int>> pque;//これは小さい順
//factorizeは、素因数分解用の関数

int main(){
	int a;
	string s;
	cin >> a >> s;
	if(a >= 3200){
		cout << s << endl;
		return 0;
	}else{
		cout << "red" << endl;
	}

  return 0;
}


Measured memory_bytes: 256
require 'set'; require 'prime'; require 'pp'
INF=Float::INFINITY; MOD=10**9+7
n,d = gets.chomp.split.map(&:to_i)
ans = 0
n.times do
  x,y = gets.chomp.split.map(&:to_i)
  if x*x + y*y <= d*d
    ans += 1
  end
end

puts ans

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

int main() {
    int64_t H, N;
    cin >> H >> N;
    struct Magic {
        int64_t A, B;
    };
    vector<Magic> magics(N);
    for (Magic& m : magics) {
        cin >> m.A >> m.B;
    }

    vector<vector<int64_t>> dp(N + 1, vector<int64_t>(H + 1, INT_MAX));
    dp[0][H] = 0;
    for (int64_t i = 0; i < N; i++) {
        for (int64_t j = H; j >= 0; j--) {
            dp[i + 1][j] = min(dp[i][j], dp[i + 1][min(j + magics[i].A, H)] + magics[i].B);
        }
    }

    cout << dp[N][0] << endl;
}

Measured memory_bytes: 78592
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using  namespace std;

int main() {
    int a, b, c;
    cin >> a >> b;
    if((a * b) % 2 == 0)
    {
        cout << "No" << endl;
    }else{
        cout << "Yes" << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    string s;
    char c;
    cin>>s;
    int i,j,d[4]={0};
    for(i=0;i<4;i++){
        c=s[i];
        for(j=0;j<4;j++){
            if(s[j]==c)
                d[i]=d[i]+1;
        }
    }
    j=0;
    for(i=0;i<4;i++){
        if(d[i]==2)
            j=j+1;
    }
    if(j==4)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rep1(i, n) for(ll i = 1; i < (ll)(n); i++)
const ll mo=1000000007;
const ll INF=1<<30;
ll ans=0;
int num[2010][2010]={};

struct edge {
    int x,y;
    char c;
};
vector<edge> ta;
int main()
{ 
ll n,k;
cin >> n>>k; 
for (int i = 0; i < n; i++) {
    int x, y;
    char D;
    cin >> x >> y >> D;
    x=x%(2*k);
    y=y%(2*k);
    if(y>=k){
        x=(x+k)%(2*k);
        y=y-k;
    }
    if(D=='W'){
        x=(x+k)%(2*k);
    }
    ta.push_back({ x,y,D });
}



rep(i,n){
    num[ta[i].y][ta[i].x]++;
    num[ta[i].y+k][(ta[i].x+k)%(2*k)]++;
}
rep(i,2*k)rep1(j,2*k){
    num[i][j]+=num[i][j-1];
}
rep1(i,2*k)rep(j,2*k){
    num[i][j]+=num[i-1][j];
}
ll temp;

rep(i,k)rep(j,k){
    ll p=0,q=0,r=0;
    if(i!=0&&j!=0)r=num[i-1][j-1];
    if(i!=0)p=num[i-1][j+k-1];
    if(j!=0)q=num[i+k-1][j-1];
    temp=num[i+k-1][j+k-1]+r-p-q;
    ans=max(ans,max(temp,n-temp));
}

/* for (int i = 0; i < 2*k; ++i){
for (int j = 0; j < 2*k; ++j) {
    cout << num[i][j] << " ";
}cout  << endl;} */
cout << ans << endl;
return 0;
} 

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

using namespace std;

int main(){
    int N, K;
    cin >> N >> K;

    vector<int> v(N);
    for(int i=0; i<N; ++i) v[i] = 0;

    for(int i=0; i<K; ++i){
        int okasi;
        cin >> okasi;
        for(int j=0; j<okasi; ++j){
            int who;
            cin >> who;
            who--;
            v[who]++;
        }
    }

    int count = 0;
    for(int i=0; i<v.size(); ++i){
        if(v[i]  ==0){
            count++;
        }
    }

    cout << count << endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n,a[100010];
	cin>>n;
	for(ll i=0;i<=n;i++){
		cin>>a[i];
	}
	ll ma[100010];
	ma[n-1]=a[n];
	for(ll i=n-2;i>=0;i--){
		ma[i]=ma[i+1]+a[i+1];
	}
//	for(ll i=0;i<=n;i++){
//		cout <<ma[i]<<endl;
//	}
//	cout <<endl;
	ll now=1;
	ll ans=1;
	for(ll i=0;i<=n;i++){
		ll next=now;
//		cout <<now;
		if(i==n&&a[i]==next){
//			cout << "K";
			continue;
		}
		if(next<=a[i]){
			cout <<-1;
			return 0;
		}
		next-=a[i];		
		next=min(next*2,ma[i]);
		ans+=next;
		now=next;
//		cout << " "<<next <<" "<<ma[i]<< " "<<i<<endl;
	}
	cout <<ans;
	// your code goes here
	return 0;
}

Measured memory_bytes: 5160
s=list(input())
count1=0
count2=0
for i in range(len(s)-1):
  if s[i]==s[i+1]:
    count1=count1+1
    if s[i+1]=='0':
      s[i+1]='1'
    else:
      s[i+1]='0'
for i in range(1,len(s)-1):
  if s[i]==s[i+1]:
    count2=count2+1
    count1=count1+1
    if s[i+1]=='0':
      s[i+1]='1'
    else:
      s[i+1]='0'
if count1>=count2:
  print(count1)
else:
  print(count2)

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

#define for_(i,a,b) for(int i=a;i<b;++i)

void solve() {
	int X, Y, W, H;
	cin >> X >> Y >> W >> H;
	
	int N, ans = 0;
	cin >> N;
	
	for_(i,0,N) {
		int x, y;
		cin >> x >> y;
		
		if (X <= x && x <= X + W && Y <= y && y <= Y + H) ++ans;
	}
	
	cout << ans << endl;
}

int main() {
	int T;
	cin >> T;
	
	for_(i,0,T) solve();
	
	return 0;
}

Measured memory_bytes: 1160
#include "bits/stdc++.h"

using namespace std;

using ll = long long;

#define FOR(i,l,r) for(size_t i=(l);i<(r);++i)
#define REP(i,n) FOR(i,0,n)
#define REP1(i,n) FOR(i,1,n+1)
#define INF 100000000000ULL

unordered_set<string> se;

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

	size_t n;
	cin >> n;

	REP(i, n) {
		string s;
		cin >> s;
		se.insert(s);
	}
	cout << se.size() << endl;
	
	return 0;
}

Measured memory_bytes: 17752
n,c=map(int,input().split())
d=[list(map(int,input().split())) for _ in range(c)]
z=[]
o=[]
t=[]
for i in range(n):
  a=list(map(int,input().split()))
  for j in range(n):
    if (i+j+2)%3==0:
      z.append(a[j])
    elif (i+j+2)%3==1:
      o.append(a[j])
    else:
      t.append(a[j])
zz=[0]*c
oo=[0]*c
tt=[0]*c
for i in range(c):
  su=0
  for j in z:
    su+=d[j-1][i]
  zz[i]=su
  su=0
  for j in o:
    su+=d[j-1][i]
  oo[i]=su
  su=0
  for j in t:
    su+=d[j-1][i]
  tt[i]=su
x=10**10
for i in range(c):
  for j in range(c):
    if i==j:
      continue
    for k in range(c):
      if i==k or j==k:
        continue
      x=min(x,zz[i]+oo[j]+tt[k])
print(x)

Measured memory_bytes: 56540
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <climits>
using namespace std;

#define REP(i,a,n) for(i=a; i<n; i++)
#define rep(i,n) REP(i,0,n)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define foreach(it,x) for(typeof(x.begin()) it=x.begin(); it!=x.end(); it++)

const int dx[] = {0,1,1,0,-1,-1};
const int dy[] = {-1,-1,0,1,1,0};
int N,K, goalX,goalY;
int res;
vector<pair<int,int> > snake_init;
map<vector<pair<int,int> >, int> dp;
set<vector<pair<int,int> > > used;
set<pair<int,int> > stone;

// {{{ input() //
void input(){
    int i,j,k;

    rep(i,N){
        int x,y; cin >> x >> y;
        snake_init.push_back(make_pair(x,y));
    }
    // stone
    cin >> K;
    rep(i,K){
        int u,v; cin >> u >> v;
        stone.insert(make_pair(u,v));
    }
    cin >> goalX >> goalY;
}
// }}} //


bool ccc(int idx, const vector<pair<int,int> >& buf){
    int i,j,k;
    int res = 0;

    if( stone.count(buf[idx]) ) return false;
    if( idx == 0 || idx == buf.size()-1 ) res = 1;

    rep(i,idx) if( buf[i] == buf[idx] ) return false;

    rep(k,6){
        int tx = buf[idx].first + dx[k];
        int ty = buf[idx].second + dy[k];
        if( idx != 0 ){
            if( buf[idx-1].first == tx && buf[idx-1].second == ty ) res++;
        }
        if( idx != N-1 ){
            if( buf[idx+1].first == tx && buf[idx+1].second == ty ) res++;
        }
        rep(i,idx-1){
            if( buf[i].first == tx && buf[i].second == ty ) return false;
        }
    }
    return res == 2;
}


// {{{ dfs //

void dfs(int idx, bool f, int cost, queue<vector<pair<int,int> > >& q, vector<pair<int,int> >& buf){
    int i,j,k;

    if( idx > 0 && ( 20 < cost + max(abs(buf[0].first-goalX), abs(buf[0].second-goalY)) ) ) return ;

    if( idx == N ){
        if( dp.count(buf) == 0 ){
            dp[buf] = cost + 1;
            q.push(buf);
            if( buf[0].first == goalX && buf[0].second == goalY ){
                res = cost + 1;
            }
        }
        return;
    }

    if( ccc(idx, buf) ) dfs(idx+1, true, cost, q, buf);

    if( idx == 0 || f ){
        rep(k,6){
            buf[idx].first += dx[k]; buf[idx].second += dy[k];
            if( ccc(idx, buf) ) dfs(idx+1, false, cost, q, buf);
            buf[idx].first -= dx[k]; buf[idx].second -= dy[k];
            if( res != INT_MAX ) return;
        }
    }
}

// }}} //



void bfs(){
    int i,j,u,v,k;

    queue<vector<pair<int,int> > > q;
    q.push(snake_init);
    dp[snake_init] = 0;

    while( !q.empty() ){
        vector<pair<int,int> >& tmpv = q.front();
        int cost = dp[tmpv];

        if( cost > 20 || res != INT_MAX ) break;

        if( used.count(tmpv) ) continue;
        used.insert(tmpv);

        dfs(0,true,cost,q,tmpv);
        q.pop();
    }
}




int main(){

    while( cin >> N, N ){
        // init
        res = INT_MAX;
        snake_init.clear();
        stone.clear();
        used.clear();
        dp.clear();

        input();
        
        bfs();
        cout << res << endl;
    }

    return 0;
}

Measured memory_bytes: 0
#include<cmath>
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
stack<int> st;
queue<int> qu;
queue<pair<int,int> > qu2;
priority_queue<int> pq;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define rep2(i,n) for(int i=1; i<=(int)(n); i++)
#define mins(x,y) x=min(x,y)
#define maxs(x,y) x=max(x,y)
#define ALL(a) a.begin(), a.end()
typedef set<int> set_t;
typedef set<string> set_g;
typedef complex<double> xy_t;
static const int NIL = -1;
static const int INF = 1000000007;
#define mp make_pair
#define sz(x) int(x.sise())
#define mod 1000000007
#define reps(i,s,n) for(int i = s; i < n; i++)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
deque<int> deq;
#define fi first
#define se second
//const ll MOD = 998244353;
const ll MOD = (1e+9) + 7;
typedef pair<int, int> P;
typedef vector<ll> vec;
typedef vector<vec> mat;
int main(){
    int n;
    cin >> n;
    ll ans=0;
    rep2(c,n-1){
        int m=n-c;
        ll temp=0;
        for(int i=1;i<=sqrt(m);i++){
            if(m%i==0&&i!=sqrt(m)){
                temp+=2;
            }else if(m%i==0&&i==sqrt(m)){
                temp+=1;
            }
        }
        ans+=temp;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3720
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
# vim:fenc=utf-8 ff=unix


def solv(N, A, B):
    m = N // (A+B)
    n = N % (A+B)
    if n < A:
        return A * m + n
    return A * m + A


if __name__ == "__main__":

    # N A B
    #
    N, A, B = map(int, input().split())
    ans = solv(N, A, B)

    print(ans)


Measured memory_bytes: 2940
import java.util.Scanner;
class Main{
	public static void main(String[] args){
    Scanner sr = new Scanner(System.in);
    	int N = sr.nextInt();
        int f = N % 10;
        if(f==2 || f==4|| f==5 || f==7 || f==9)
        	System.out.println("hon");
        else if(f==0 || f==1 || f==6 || f==8)
        	System.out.println("pon");
        else 
        	System.out.println("bon");    
     }
}

Measured memory_bytes: 35824
//shara's here
#include <bits/stdc++.h>
using namespace std;
typedef int q;
typedef double w;
typedef string s;
typedef long long ll;
int main(){
    ll x,y,n,o;
    cin>>x>>y;
    n=-(x-1);
    o=x-1;
    for(int i=n+y;i<=o+y;i++){
        cout<<i<<" ";
    }

















return 0;}
/*
███████████████████████████████████████████████████
███████████████████████████████████████████████████
██████████████████████████████████▀████████████████
██████████████████████████████████░▀███████████████
██████████████████████████████▌███░░░▀▀████████████
██▀████████████████████▐██████░▐██░░░░░░▀▀█████████
██░████████████████████▐█████▌░██▌▄░░░░▄▄░▄████▀███
█▌░███████████████████▀░█████░░░█░░░▄████░░███▀▐███
█▌░▐██████████████████░░████▌░░░▀░░▀███▀▀░▐███▄████
██░▀██████████████▌▐█▐▄▄████▌░░░░░░░░░░░░░▌████████
███░███████████████▀░▄▄██▀█▐░░░░░░░░░░░░░░▐████████
███▄░██████████████▄░░░░░░▀▀▀░░░░░░░░░░░░░█▐███████
████▄░██████████████████▄▄▄▄▄▄▐▄░░░░░░░░░░░████████
█████▄█████████████████▀▀▀▀▀▀░░░░░░░░░░░░░░████████
████████████████████████▄░░░░░░░░░░░░░░░▄░░████████
██████████████████████████▄▄▄░░░░░░░░░▄█░▄█████████
████████████████████████████████▄░░░░██▄███▀░░▀████
█████████████████████████████▀█████▄███▀▀▀░░▄▄░████
████████████████████████████▀░░▀░░▀▀░░░░▄▄▄██▀░░▀▀█
███████████████████████████▌░░░░░░░░░░░███████░░░▄█
███████████████▄░▀████████▀░░░░░░▀░░░░███████▌░░░██
███▄▄████████████▄░▀██████▄░░░░░█░░░░████████░░░▀▀
░▀█████████████████▄░▀█████░░░░██░░░░▀██████░░░░░▄█
▐█▄▀█████████████████▄░▀████░░░██▌░░░▐████▀░░░░▄███
▐███▄▀▀█████████████████▄░▀▀░░░░▀██▌▄█▀▀░░░▄▄██████
▀▀▀▀▀░░░▀▀▀▀▀░░░▀▀▀▀▀▀▀▀▀▀▀░░░░░░░▀▀░░░░░░▀▀▀▀▀▀▀▀▀
*/



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

int main(){
	string s;
	cin>>s;
	int S=0;
	for(int i=0;i<s.size();i++){
		S+=s[i]-'0';
	}
	if(stoi(s)%S==0)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("unroll-loops,no-stack-protector")
#pragma GCC target("sse,sse2,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define watch(x) cout <<(#x)<<" is "<<(x)<<endl
#define debug cout <<"hi"<<endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
const int MOD=1e9+7;
const int INF32=1<<30;
const ll INF64=1LL<<60;

void solve(){
  int n,k,r,s,p; cin >>n >>k >>r >>s >>p;
  int R=0,S=0,P=0,cnt=1; vector<vector<char>>v(k);
  for(int i=0; i<n; i++){
    char c; cin >>c;
    v[i%k].push_back(c);
  }
  for(int i=0; i<k; i++){
  if(v[i].size()==1){
    if(v[i][0]=='s') R++;
    else if(v[i][0]=='p') S++;
    else P++;
    cnt=1;
  }
  else for(int j=0; j<v[i].size()-1; j++){
    if(v[i][j]==v[i][j+1]) cnt++;
    else{
      if(v[i][j]=='s') R+=(cnt+1)/2;
      else if(v[i][j]=='p') S+=(cnt+1)/2;
      else P+=(cnt+1)/2;
      cnt=1;
    }
    if(j==v[i].size()-2&&v[i][j]==v[i][j+1]){
      if(v[i][j+1]=='s') R+=(cnt+1)/2;
      else if(v[i][j+1]=='p') S+=(cnt+1)/2;
      else P+=(cnt+1)/2;
      cnt=1;
    }
    else if(j==v[i].size()-2){
      if(v[i][j+1]=='s') R++;
      else if(v[i][j+1]=='p') S++;
      else P++;
      cnt=1;
    }
  }
  }
  cout <<R*r+S*s+P*p;
}

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

Measured memory_bytes: 7884
#include<iostream>
#include <stdlib.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <vector>
#include <numeric>
typedef long long int ll;
using namespace std;
int main(){ 
	char a;
	int i;
	cin>>a;
	i=(int)a+1;
	a=(char)i;
	cout <<a <<endl;
	return 0;
}

Measured memory_bytes: 256
N,M=map(int,input().split())
W=[list(map(int,input().split())) for i in range(N)]
E=[0]*(M+1)
for h in range(N):
  a=sum(W[h])
  W[h].append(a)
for l in range(N):
  for g in range(M+1):
    E[g]+=W[l][g]
W.append(E)
for e in range(N+1):
  for b in range(M+1):
    if b!=M:
      print(W[e][b],end=" ")
    else:
      print(W[e][b])


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

int main(){
    int A, B; cin >> A >> B;
    if (A >= 13) cout << B << endl;
    else if (A >= 6) cout << B/2 << endl;
    else cout << 0 << endl;
}


Measured memory_bytes: 256
#include<string.h>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<stdio.h>
//100000
int main(void){
    int n,a=0,i;
    scanf("%d",&n);
    for(i=1;i<=n;i++){
        if((10<=i&&i<=99)||(1000<=i&&i<=9999)||i==100000) continue;
        a++;
    }
    printf("%d",a);
    printf("\n");
    return 0;
}

Measured memory_bytes: 128
N = int(input())
A = [int(input()) for i in range(N)]

ma_n = 0
ma_b = 0
mn = 0
for i in range(N):
    if A[i] >= ma_n:
        ma_b = ma_n
        ma_n = A[i]
        mn = i
    elif A[i] >= ma_b:
        ma_b = A[i]
for i in range(N):
    if i != mn:
        print(ma_n)
    else:
        print(ma_b)


Measured memory_bytes: 69208
N = int(input())
if (N%10 == 2) or (N%10 == 4) or (N%10 == 5) or (N%10 == 7) or (N%10 == 9):
    print("hon")
elif (N%10 == 0) or (N%10 == 1) or (N%10 == 6) or (N%10 == 8):
    print("pon")
else:
    print("bon")

Measured memory_bytes: 9132
#include<bits/stdc++.h>
using namespace std;
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int N;
	cin >> N;
	long long int a[1000000],b[1000000];
	long long ans=0,t,small = -1,r;
	for(int i=0;i<N;i++)
		cin >> a[i] >> b[i];
	for(int i=0;i<N;i++){
		if( a[i] > b[i] ){
            if(small > b[i]||small == -1){
                small =  b[i];
                r = i;
            }
		}
	}
	for(int i=0;i<N;i++)
		if( i != r ) ans += b[i];
	if(small==-1) cout << 0 << endl;
	else cout << ans << endl;
}



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

#define y1 dmytxdy
#define fi first
#define se second
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;

template <typename T> bool chkmin(T &x,T y){return x>y?x=y,1:0;}
template <typename T> bool chkmax(T &x,T y){return x<y?x=y,1:0;}

int readint(){
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}

int n,tot,cnt,ans,res;
int a[100005],du[100005],q[100005],v[200005],nxt[200005],h[100005],mx1[100005],mx2[100005];
bool vis[100005];
char s[100005];

void addedge(int x,int y){
	v[++tot]=y; nxt[tot]=h[x]; h[x]=tot; du[x]++;
	v[++tot]=x; nxt[tot]=h[y]; h[y]=tot; du[y]++;
}

void dfs(int u,int fa){
	for(int p=h[u];p;p=nxt[p]){
		if(v[p]==fa||vis[v[p]]) continue;
		dfs(v[p],u);
		int t1=mx1[v[p]]+a[v[p]],t2=mx2[v[p]]+a[u];
		chkmax(res,t1+mx2[u]);
		chkmax(res,t2+mx1[u]);
		chkmax(mx1[u],t1);
		chkmax(mx2[u],t2);
	}
}

int main(){
	n=readint();
	for(int i=1;i<n;i++) addedge(readint(),readint());
	scanf("%s",s+1);
	int front=0,rear=0;
	for(int i=1;i<=n;i++) if(du[i]==1) q[rear++]=i;
	while(front<rear){
		int t=q[front++];
		if(s[t]=='W'||vis[t]) continue;
		vis[t]=true,cnt++;
		for(int p=h[t];p;p=nxt[p]) if(!vis[v[p]]&&(--du[v[p]])<=1) q[rear++]=v[p];
	}
	if(cnt==n) return printf("0\n"),0;
	ans=2*(n-cnt-1);
	int rt=0;
	for(int i=1;i<=n;i++) if(!vis[i]) a[i]=(s[i]=='B')^(du[i]&1)^1,ans+=a[i];
	for(int i=1;i<=n;i++) a[i]=a[i]==0?0:2;
	for(int i=1;i<=n;i++) if(!vis[i]) rt=i;
	if(rt) dfs(rt,-1);
	printf("%d\n",ans-res);
	return 0;
}

Measured memory_bytes: 8704
#include<bits/stdc++.h>
using namespace std;
int main () {
	int a, b;
	cin >> a >> b;
    int n;
	if(a > b ){
		n = a;
	}else {
      n = b;
    }

    int res;
    int t1, t2;
    bool flag;
    flag = true;
	for (int i = 0; i < n; i++){
      t1 = abs(a-i);
      t2 = abs(b-i);
      res = abs(t1-t2);
      if ( res == 0 ){
		cout << i << endl;
        flag = false;
      }
    }
    if( flag ){
               cout << "IMPOSSIBLE" << endl;
    }
	return 0;
}


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

int main(){
  int N,M,C;cin >> N >> M >> C;
  int B[20];
  int A[20][20];
  for (int i=0;i<M;i++){
    cin >> B[i];
  }
  for (int i=0;i<N;i++){
    for (int j=0;j<M;j++){
      cin >> A[i][j];
    }
  }
  int ans = 0;
  for (int i=0;i<N;i++){
    int c = 0;
    for (int j=0;j<M;j++){
      c += B[j]*A[i][j];
    }
    if (c + C >0)ans ++;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

main(){
  int n,count;

  while(1){
    scanf("%d", &n);
    if(n==0) break;
    count=0;

    while(n!=1){
      if(n%2==0){
	n/=2;
      }
      else{
	n=n*3+1;
      }
      count++;
    }

    printf("%d\n", count);
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
#define int long
#define ll long long
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;

using pi=pair<int,int>;
using vi=vc<int>;

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    vi d(100010,0);
    int N,C; cin >> N >> C;
    vc<pi> A[C];
    rep(i,N){
        int a,b,c; cin >> a >> b >> c;
        a--; b--; c--;
        A[c].eb(a,b);
        d[a]++;
        d[b+1]--;
    }
    rep(i,100010){
        d[i+1]+=d[i];
    }
    rep(i,C){
        sort(all(A[i]));
        rep(j,A[i].size()-1){
            if(A[i][j].se ==A[i][j+1].fi) 
                d[A[i][j].se]--;
        }
    }
    int ans=0;
    rep(i,100010){
        ans=max(ans,d[i]);
    }
    cout << ans << endl;
}

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


template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i,n) for(int i=0; i<(int)n; i++)
#define ll long long
#define all(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())
#define COUT(x) cout << x << endl;
#define PB(x) push_back(x)
int gcd(int a,int b){return b?gcd(b,a%b):a;}
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int INF = 1e9;
const int MOD = 1e9+7;



int main() {
    //番号は高々000~999の1000通り
    //なので1000回回して存在するかを考える．
    int n; cin >> n;
    string s; cin >> s;
    int key[3],ans=0;

    for(int i=0; i<1000; i++){
        int temp=i;
        key[2]=temp%10; temp/=10; 
        key[1]=temp%10; temp/=10;
        key[0]=temp;
        int f=0;
        rep(j,n){
            if(s[j]==('0'+key[f])) f++;
            if(f==3) break;
        }
        if(f==3) ans++;
    }
    COUT(ans);
    
}

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

int main() {

    int a, b, c, d; cin >> a >> b >> c >> d;
    bool takaAttack = true;
    while (0 < a || 0 < c) {
        if (takaAttack) {
            c -= b;
            takaAttack = false;
        }
        else {
            a -= d;
            takaAttack = true;
        }
    }
    if (!takaAttack) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 3640
#include<bits/stdc++.h>
using namespace std;
using lli = long long int;
using ld = long double;
using ulli = unsigned long long int;
#define filein freopen ("in.txt", "r", stdin)
#define fileout freopen ("out.txt", "w", stdout)
#define dbg(args...) do {cerr << #args << " : "; debug(args); } while(0)
#define all(v) ((v).begin()),((v).end())
#define size(x) (int) x.size() 
#define pb emplace_back
#define mp make_pair
#define PI 3.14159265
#define mod 1000000007
void debug () {cerr << endl;}
template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
template < typename T, typename ... hello>void debug( T arg, const hello &... rest) {cerr << arg << ' ';debug(rest...);}
int main(){
	ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,k;
    cin >> n >> k;
    vector<int> nums;
    for(int i = 1;i <= n; i++){
		int in;
		cin >> in;
		nums.pb(in);
	}
	sort(all(nums));
	int sum = 0;
	for(int i = 0;i < k; i++){
		sum += nums[i];
	}
	cout << sum;
}




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

using namespace std;

int main() {
  string s;
  cin >> s;
  for (int i = 0; i < s.size(); i++) {
    if ( (i % 2 == 0 && s[i] == 'L') || (i % 2 == 1 && s[i] == 'R') ){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(a,b) for(int a = 0;a < b;++a)
string se[7] ={"SAT","FRI","THU","WED","TUE","MON","SUN"};
int main(){
int k;
cin >> k;
   string s;
cin >> s;
REP(i,s.length()) cout <<(char)(((s[i] - 'A' + k) % 26) + 'A');
cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF LLONG_MAX/5
#define all(v) v.begin(),v.end()
#define P pair<int,int>
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
signed main(){
	int n;
	cin>>n;
	cout<<(n-1)/2<<endl;
}


Measured memory_bytes: 256
import fractions
N=int(input())
A=list(map(int,input().split()))
left=[0]
right=[0]
l,r=0,0
ans=0
for i in range(N-1):
    l=fractions.gcd(l,A[i])
    r=fractions.gcd(r,A[N-1-i])
    left.append(l)
    right.append(r)
for i in range(N):
    ans=max(ans,fractions.gcd(left[i],right[N-i-1]))
print(ans)

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

#define MP make_pair
#define PB push_back
#define ALL(x)      (x).begin(),(x).end()
#define REP(i,n)    for(int i=0;i<(n);i++)
#define REP1(i,n)   for(int i=1;i<(n);i++)
#define REP2(i,d,n) for(int i=(d);i<(n);i++)
#define RREP(i,n)   for(int i=(n);i>=0;i--)
#define CLR(a)      memset((a),0,sizeof(a))
#define MCLR(a)     memset((a),-1,sizeof(a))
#define RANGE(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVI;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int INF = 0x3f3f3f3f;
const LL INFL = 0x3f3f3f3f3f3f3f3fLL;
const double EPS = 1e-9;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int main(){
    int H, W, D;
    cin >> H >> W >> D;
    VI x(H*W+1), y(H*W+1);
    int a;
    REP(i, H) REP(j, W) {
        cin >> a;
        x[a] = j;
        y[a] = i;
    }

    vector<VI> memo(D);
    REP1(i, D + 1) {
        int cost = 0;
        int now_idx = i;

        while(true) {
            memo[i%D].PB(cost);
            now_idx += D;
            if(H*W < now_idx) break;
            int prev_idx = now_idx - D;
            cost += abs(x[prev_idx] - x[now_idx]) + abs(y[prev_idx] - y[now_idx]);
        }
    }

    int Q;
    cin >> Q;
    int L, R;
    REP(i, Q){
        cin >> L >> R;
        cout << memo[R % D][R / D - (R % D == 0 ? 1 : 0)] - memo[L % D][L / D - (L % D == 0 ? 1 : 0)] << endl;
    }
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
set<int> E[101010];



void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N-1) {
		cin>>x>>y;
		E[x-1].insert(y-1);
		E[y-1].insert(x-1);
	}
	
	set<pair<int,int>> S;
	FOR(i,N) {
		S.insert({E[i].size(),i});
	}
	
	while(S.size()) {
		if(S.begin()->first==0) return _P("First\n");
		x = S.begin()->second;
		y = *E[x].begin();
		
		FORR(r,E[y]) {
			S.erase({E[r].size(),r});
			E[r].erase(y);
			S.insert({E[r].size(),r});
		}
		S.erase({E[y].size(),y});
		S.erase({E[x].size(),x});
	}
	_P("Second\n");
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n';
	FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	solve(); return 0;
}


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

int max(int a,int b){
  if(a>b) return a;
  else return b;
}
double min(double a,double b){
  if(a<b) return a;
  else return b;
}
int absolute(int a,int b){
  if(a-b<0) return -(a-b);
  else return a-b;
}
int sum_keta(int n){
  if(n==0) return 0;
  return n%10 + sum_keta(n/10);
}
int main(void){
  int N,M,X; cin >> N >> M >> X;
  vector<int> cost(N);
  for(int i=0;i<M;i++){
    int A;
    cin >> A;
    cost.at(A)++;
  }
  
  int sum_right = 0 , sum_left = 0;
  for(int i=1;i<N;i++){
  	if(X+i < N) sum_right += cost.at(X+i);
    if(X-i > 0) sum_left += cost.at(X-i);
  }
  cout << min(sum_right,sum_left);
}

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int H,W;
ll mo=998244353;

const int MAT=402;
int A[402][402];
ll dp[603][603];
ll p2[3030];

int gf2_rank(int A[MAT][MAT]) { /* input */
	int i,j,k;
	FOR(i,H) {
		int be=i,mi=W+1;
		for(j=i;j<H;j++) {
			FOR(k,W) if(A[j][k]) break;
			if(k<mi) be=j,mi=k;
		}
		if(mi>=W) break;
		FOR(j,W) swap(A[i][j],A[be][j]);
		
		FOR(j,H) if(i!=j&&A[j][mi]) {
			FOR(k,W) A[j][k] ^= A[i][k];
		}
	}
	return i;
}


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>H>>W;
	FOR(y,H) FOR(x,W) cin>>A[y][x];
	
	p2[0]=1;
	FOR(i,305) p2[i+1]=p2[i]*2%mo;
	
	x=gf2_rank(A);
	ll ret=(p2[x]+mo-1)*p2[H-x]%mo*p2[W-1]%mo;
	cout<<ret<<endl;
	
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 768
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
    String[] str = in.readLine().split(" ");
    int p = Integer.parseInt(str[0]);
    int q = Integer.parseInt(str[1]);
    int r = Integer.parseInt(str[2]);
    
    int ans = 0;
    System.out.println(Math.min(p+q,Math.min(q+r,p+r)));
  }
}

Measured memory_bytes: 23124
#include<stdio.h>
int main(void)
{
	int A=0, B=0, n, i, Aa[10001] = { 0 }, Bb[10001] = { 0 },c;
	while (1)
	{		
		scanf("%d", &n);

		if (n == 0)
		{
			break;
		}

		for (i = 1; i <= n; i++)
		{
			scanf("%d %d", &Aa[i], &Bb[i]);

			if (Aa[i] > Bb[i])
			{
				A = A + Aa[i] + Bb[i];
			}

			else if (Aa[i] < Bb[i])
			{
				B = B + Aa[i] + Bb[i];
			}

			else
			{
				A = A + Aa[i];
				B = B + Bb[i];
			}

		}

		printf("%d %d\n", A, B);

		A = 0;
		B = 0;

		for (c = 1; c <= n; c++)
		{
			Aa[c] = 0;
			Bb[c] = 0;
		}


	}
	return 0;
}

Measured memory_bytes: 1816
#include<stdio.h>
int main(void){
  long long int a,b,i,con=1,ans=0;
  scanf("%lld%lld",&a,&b);

  
  while(con<b){
    con=con-1+a;
    ans++;
   
  }
  
  printf("%lld",ans);
  return 0;
}

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

int main(void){
    int N;
    cin>>N;
    vector<int> h(N+2);
    h.at(0)=0;
    h.at(N+1)=0;
    int i,k=0;
    int sum=0;
    
    for(i=1;i<=N;i++)cin>>h.at(i);
    
    for(i=1;i<=N;i++){
        if(h.at(i)>h.at(i+1)){
            sum+=h.at(i)-k;
            k=h.at(i+1);
        }
    }
    
    cout<<sum<<endl;
    
}

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

using namespace std;

typedef long long int ll;



int n, a[100010];


int main(){

	while(scanf("%d", &n)!=EOF){
		for(int i=0; i<n; i++){
			scanf("%d", &a[i]);
		}
		ll sum=0, ans=0;
		for(int i=0; i<n; i++){
			sum += a[i];
			if((i%2)==0){
				if(sum<=0){
					ans += 1-sum;					
					sum = 1;
				}
			}
			else{
				if(sum>=0){
					ans += sum+1;
					sum = -1;
				}
			}	
		}
		ll ans2 = ans;
		sum = 0; ans = 0;
		for(int i=0; i<n; i++){
			sum += a[i];
			if(i%2){
				if(sum<=0){
					ans += 1-sum;
					sum = 1;
				}
			}
			else{
				if(sum>=0){
					ans += sum+1;					
					sum = -1;
				}
			}	
		}	
		ans2 = min(ans, ans2);
		printf("%lld\n", ans2);
	}		

	return 0;

}


Measured memory_bytes: 640
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

using namespace std;
typedef long long LL;
typedef pair<int,int> P;

#if 0
int f(int N,int K){
	vector<int> vs;
	for(int i=0;i<3*N;i++){
		vs.push_back(K+i);
	}
	do{
		bool ok=true;
		for(int i=0;i<N;i++){
			if(vs[i]+vs[i+N]>vs[i+2*N]){
				ok=false;
				break;
			}
		}
		if(ok){
			for(int v:vs){
				cout << " " << v;
			}
			cout << endl;
			return 0;
		}
	} while(next_permutation(vs.begin(),vs.begin()+2*N));
	cout << -1 << endl;
	return 0;

}
#endif
int main() {

	int N,K;
	cin >> N >> K;
	vector<int> a,b,c;
	for(int i=0;i<(N+1)/2;i++){
		a.push_back(K+2*i);
		b.push_back(K+N+(N-1)/2-i);
		c.push_back(K+2*N+i);
		if(a.back()+b.back()>c.back()){
			//cerr << a.back() << ", " << b.back() << " " << c.back() << endl;
			cout << -1 << endl;
			return 0;
		}
	}
	for(int i=0;i+(N+1)/2<N;i++){
		a.push_back(K+1+2*i);
		b.push_back(K+2*N-1-i);
		c.push_back(K+2*N+i+(N+1)/2);
		if(a.back()+b.back()>c.back()){
			//cerr << a.back() << ", " << b.back() << " " << c.back() << endl;
			cout << -1 << endl;
			return 0;
		}
	}
	for(int i=0;i<N;i++){
		cout << a[i] << " " << b[i] << " " << c[i] << endl;
	}
	return 0;
}



Measured memory_bytes: 3692
#include <iostream>
#include <cstdio>
#include <cmath>
#include <climits>
using namespace std;

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

  for(int i = n-1; i>=0; i--){
    if(i != n-1){cout<<' ';}
    cout<<a[i];
  }
  cout<<endl;
  return 0;
}

Measured memory_bytes: 3068
using System;
using System.Linq;
using System.Collections.Generic;

using E = System.Linq.Enumerable;

public class Program
{
    public static void Main()
    {
        var nmq = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
        var (n, m, q) = (nmq[0], nmq[1], nmq[2]);
        var quadraples = new (int a, int b, int c, int d)[q];
        for (int i = 0; i < quadraples.Length; ++i)
        {
            var abcd = Console.ReadLine().Split().Select(x => int.Parse(x)).ToArray();
            quadraples[i] = (abcd[0], abcd[1], abcd[2], abcd[3]);
        }

        Array.Sort(quadraples);

        var seqA = new int[n + 1];
        (seqA[0], seqA[^1]) = (1, m);
        var max = Dfs(quadraples, seqA, 1);

        Console.WriteLine(max);
    }

    static long Dfs((int a, int b, int c, int d)[] qs, int[] seqA, int index)
    {
        if (index + 1 >= seqA.Length)
        {
            return qs.Where(x => seqA[x.b] - seqA[x.a] == x.c).Sum(x => x.d);
        }

        seqA[index] = seqA[index - 1];

        var r = 0L;
        while (seqA[index] <= seqA.Last())
        {
            r = Math.Max(r, Dfs(qs, seqA, index + 1));
            ++seqA[index];
        }

        return r;
    }
}


Measured memory_bytes: 36484
#include<cstdio>
#include<algorithm>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<iostream>
#include<sstream>
using namespace std;
typedef long long ll;

int main(){
    int sum=0;
    for(int i=0;i<4;i++){
        int ins;
        scanf("%d",&ins);
        sum+=ins;
    }
    printf("%d\n%d\n",sum/60,sum%60);
}

Measured memory_bytes: 0
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  const ll NUM = 100000;
  ll N;
  std::cin >> N;
  std::vector<ll> vx(NUM+1, 0LL);
  for (ll i = 0; i < N; i ++) {
    ll l, r;
    std::cin >> l >> r;
    l--;
    vx[l]++;
    vx[r]--;
  }

  ll ans = 0LL;
  if (vx[0] > 0) ans++;
  for (ll i = 1; i <= NUM; i++) {
    vx[i] += vx[i-1];
    if (vx[i] > 0) ans++;
  }
  print(ans);
  return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<numeric>
#include<utility>
#include<regex>

#pragma region _define

#define f(i,a,b) for(int i=a;i<b;i++)
#define f_vI(v,n) f(i,0,n)cin>>v[i]
#define f_v2I(v1,v2,n) f(i,0,n)cin>>v1[i]>>v2[i]
#define f_v3I(v1,v2,v3,n) f(i,0,n)cin>>v1[i]>>v2[i]>>v3[i]
#define f_vO(v,n) f(i,0,n)cout<<v[i]<<endl
#define all(a) a.begin(),a.end()
#define size(s) s.size()
#define endl "\n"
#define _y() cout<<"Yes"<<endl
#define _Y() cout<<"YES"<<endl
#define _n() cout<<"No"<<endl
#define _N() cout<<"NO"<<endl

#pragma endregion

#pragma region _using

using namespace std;

using LL = long long;
using st = string;
using vi = vector<LL>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vs = vector<st>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using si = stack<LL>;
using pi = pair<LL, LL>;
using v_pi = vector<pi>;

#pragma endregion

#pragma region _graph

#define node 50
//bool graph[node][node]; bool visited[node] = { false };
#define link(a,b) f(i,0,n){cin>>a[i]>>b[i]; a[i]--; b[i]--; graph[a[i]][b[i]]=graph[b[i]][a[i]]=true;}

#pragma endregion

LL gcd(LL a, LL b) {
	LL r;
	while ((r = a % b) != 0) {
		a = b;
		b = r;
	}
	return b;
}
LL lcm(LL a, LL b) {
	return (a / gcd(a, b) * b);
}

/*****************************************************************************/


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

	int n;
	cin >> n;
	int i = 1;
	si s;
	if (n == 0) {
		cout << 0;
		return 0;
	}
	while (n != 0) {
		if (n % 2 != 0) {
			s.push(1);
			n += pow(-1, i);
			n /= 2;
		}
		else {
			s.push(0);
			n /= 2;
		}
		i++;
	}
	while (!s.empty()) {
		cout << s.top();
		s.pop();
	}
	return 0;
}

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

int main() {
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    if (A + B == C + D) {
        cout << "Balanced" << endl;
    } else if (A + B > C + D) {
        cout << "Left" << endl;
    } else {
        cout << "Right" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
typedef long long   ll;
#define pb                push_back
#define mp                make_pair
#define all(a)            (a).begin(), (a).end()
#define clr(a,h)          memset(a, (h), sizeof(a))
#define mem(a,h)          memset(a, (h), sizeof(a))
#define fi first
#define se second
#define por(a,b) (((a%MOD) * (b%MOD))%MOD)
#define forg(i, b, e, c)    for (ll i = (ll)b; i < (ll)e; i+=c)
#define forr(i, b, e)    for (ll i = b; i < e; i++)
 
 
using namespace std;
using namespace __gnu_pbds;
typedef double lldb;
typedef pair<ll, ll>  ii;
typedef pair<ll, ii>  iii;
typedef vector<ll>     vi;
typedef vector<vi>     vvi;
typedef vector<ii>      vii;
typedef vector<ll>      vll;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
const ll INF = 1e9;
const double PI = acos(-1);
#define offset 
const ll MOD= 1e9+7;
#define initseg ll new_nodo=(nodo*2),mid=(iz+der)/2;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
#define tam 223455
ll v[tam];
ll sum[tam];
int  main()
{
    ios::sync_with_stdio(false);cin.tie(0);
    ll n,k;
    cin>>n>>k;
    forr(i,1,n+1)
    {
        cin>>v[i];
        v[i]-=k;
    }
    sum[0]=0;
    map<ll,ll> mapa;
    ordered_set S;
    
    S.insert(mp(0,mapa[0]++));
    ll tot=0;
    forr(i,1,n+1)
    {
        sum[i]=sum[i-1]+v[i];
        tot+=S.order_of_key({sum[i]+1,-1});
        S.insert({sum[i],mapa[sum[i]]++});
    }
    cout<<tot<<endl;
}
// PLUS ULTRA!ac

Measured memory_bytes: 28416
s = input()
a = list("abcdefghijklmnopqrstuvwxyz")
if s == "zyxwvutsrqponmlkjihgfedcba":
    print(-1)
elif len(s) != 26:
    nokori = set(a) - set(s)
    nokori = sorted(nokori, key=a.index)
    print(s + nokori[0])
else:
    for i in range(2, 27):
        if s[-i] <= s[-i + 1]:
            break
    s_ = sorted(s[-i:])
    for j in s_:
        if j > s[-i]:
            break
    print(s[:-i] + j)

Measured memory_bytes: 3064