akhauriyash/Code-Regression huggingface dataset:
// first second push_back unordered return continue break vector visited check flag bool while iterator begin end lower_bound upper_bound temp true false ll_MAX ll_MIN insert erase clear pop push compare ll64_MAX ll64_MIN  reverse replace stringstream string::npos length substr front
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define all(x) x.begin(),x.end()
const ll mod = 1e9 + 7 ;
const ll inf =
 1e9 + 5 ;
 //1e18L + 5;
const ll nax = 2e5 + 5;
void min_self(ll&a , ll b){a=min(a,b);}
void max_self(ll&a , ll b){a=max(a,b);}
void add_self(ll& a , ll b){a = (a+b)%mod;}
ll rrmax(ll a , ll b){
	if(a>b)return a;
	return b;
}
//#define (x)  get<0>(x) 
//#define (x)  get<1>(x)
//#define (x)  get<2>(x)
signed main(){
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

ll n , k ; cin>> n>> k ;
vector<ll>a(n);
for(auto &i:a)cin>>i;

// vector<vector<ll>>dp(n,vector<ll>(k+2));
// for(ll i = 0 ; i<=a[0] ;i++)dp[0][i] = 1;
// for(ll i = 1 ; i<n ; i++){
// 	for(ll j = 0 ; j<=k ; j++){
// 		// cout<<i<<" "<<j<<endl;
// 		for(ll k = 0 ; k<=a[i] && j - k >=0 ; k++){
// 			add_self(dp[i][j],dp[i-1][j-k]);
// 		}

// 	}
// }

vector<ll>dp(k+1);
for(ll i = 0 ; i<=a[0] ;i++)dp[i] = 1;
for(ll i = 1 ;i<n ; i++)
{
	unordered_map<ll,ll> prefix;
	prefix[-1] = 0 ;
	for(ll it = 0 ; it<=k ; it++)prefix[it] = prefix[it-1] + dp[it];
	for(ll j = 0 ; j<= k ;j++){
		dp[j] = 0;
		add_self(dp[j] , prefix[j] - prefix[  rrmax(0,j - a[i]) - 1    ] );
	}

}



// for(ll i = 0 ; i<n ; i++){
// 	for(ll j = 0 ; j<k ; j++)cout<<dp[i][j]<<" ";cout<<endl;
// }

cout<<dp[k];	

	
}


Measured memory_bytes: 5208
/*
 * Author : Sadi
 * Sat 04/07/2020
 * 17:26:10.18
 */
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <bitset>
#include <cassert>

using namespace std;

#define    watch(x); cout << "\n" <<  #x << " is: " << x << "\n";
#define    all(a) (a).begin(), (a).end()
#define    fi first
#define    se second

template<class A, class B>
ostream& operator << (ostream& output, const pair<A, B>& p) {
    output << "(" << p.first << ", " << p.second << ")";
    return output;
}

template<class A>
ostream& operator << (ostream& output, const vector<A>& a) {
    output << "[";
    for(auto it = a.begin(); it != a.end(); ++it) {
        if(it != a.begin()) {
            output << ", ";
        }
        output << *it;
    }
    output << "]";
    return output;
}

using lld = long long;
using pii = pair<int, int>;
using pll = pair<lld, lld>;

//const int inf = 1e9;
//const int mod = 1e9 + 7;
//const double PI = acos(-1.0);
//const int mx = 1e5 + 5;



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE

    double x, t;
    cin >> t >> x;
    cout << fixed << setprecision(10) << t / x << endl;

    return 0;
}


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

using namespace std;

#define int long long
#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)


int32_t main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    int q;
    cin >> q;
    int cur=0;
    string m,n;
    while(q--){
        int t;
        cin >> t;
        if(t==1) cur^=1;
        else{
            int f;
            string ch;
            cin >> f >> ch;
            if(f==1){
                if(cur==0){
                    ch+=n;
                    n=ch;
                }
                else m+=ch;
            }
            else{
                if(cur==0) m+=ch;
                else{
                    ch+=n;
                    n=ch;
                }
            }
        }
    }
    s=n+s;
    s=s+m;
    if(cur) reverse(all(s));
    cout << s;
    return 0;
}


Measured memory_bytes: 1308
#include <bits/stdc++.h> 
#define rep(i,n) for(int i=0; i<(n); ++i)
#define cout(x) cout<<x<<endl
#define all(v) v.begin(), v.end()
using namespace std;
//型エイリアス
using vi = vector<int>;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
const ll inf = 1e18;
const int N = 2e5 + 10;


int main(){
    int n,m;
    cin >> n >> m;
    vi a(m),b(m);
    rep(i,m) cin >> a[i] >> b[i];

    vi path(n);
    rep(i,n) path[i] = i+1;
    int ans = 0;
    do{
        bool can = false;
        rep(i,n-1){
            can = false;
            rep(j,m){
                if((path[i]==a[j]&&path[i+1]==b[j]) || (path[i+1]==a[j]&&path[i]==b[j])){
                    can = true;
                    break;
                }
            }
            if(can==false) break;
        }
        if(can && path[0]==1) ans += 1; 
    }
    while(next_permutation(all(path)));

    cout(ans);
    return 0;
}

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

bun=[]
bun.append([0,0]+[1]*(s-2))
for j in range(1,s//3):
    bun.append([0]*(3*(j+1)-1)+[1])
    for i in range(3*(j+1),s):
        bun[j].append((bun[j][i-1]+bun[j-1][i-3])%(10**9+7))

ans=0
for i in range(s//3):
    ans = (ans+bun[i][s-1])%(10**9+7)

print(ans)

Measured memory_bytes: 46076
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <random>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(int argc, char const *argv[]) {
  ll D;std::cin >> D;

  vll c(26);
  re(i, 26) std::cin >> c[i];

  vvl s = VV(D, 26, 0, ll);
  re(i, D) re(j, 26) std::cin >> s[i][j];

  for(int i=0;i<D;i++){
    ll idx = 0, num = -1;
    for(int j=0;j<26;j++) if(num<s[i][j]) num = s[i][j], idx = j;
    std::cout << idx+1 << '\n';
  }
  return 0;
}


Measured memory_bytes: 3316
#include<bits/stdc++.h>
#include<math.h>
#include <stdio.h>
#include<vector>
#include<stdlib.h>
//#include <algorithm>
#include <limits>
#include<string>
#define rep(i,n) for(int i = 0; i < n; i++)
typedef long long ll;
using namespace std;
#define llMAX numeric_limits<long long>::max()
#define intMAX numeric_limits<int>::max()
#define ll long long
#define d_5 100000
int main(void){
  int n;
  ll x;
  cin >> n >> x;
  ll a[n];
  ll result = 0;
  rep(i,n){
    cin >> a[i];
  }
  rep(i,n-1){
    ll sum = a[i]+a[i+1];
    ll subtract = max((ll)0,sum -x);
    a[i+1] =max((ll)0,a[i+1]-subtract);
    result += subtract;
  }
  cout << result;
	return 0;
}

Measured memory_bytes: 1024
MOD = 10**9 + 7
def comb(n, k, MOD):
    if n < k or n < 0 or k < 0:
        return 0
    k = min(k, n - k)
    if k == 0:
        return 1
    iinv = [1] * (k + 1)
    ans = n
    for i in range(2, k + 1):
        iinv[i] = MOD - iinv[MOD % i] * (MOD // i) % MOD
        ans *= (n + 1 - i) * iinv[i] % MOD
        ans %= MOD
    return ans
X, Y = map(int,input().split())
if (X+Y) % 3 != 0:
    print(0)
    exit()
n = (2*Y-X)//3
m = (2*X-Y)//3
print(comb(n+m,m,MOD))

Measured memory_bytes: 41200
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String string = sc.nextLine();
		Main main = new Main();

		if (main.chkPalindrome(string) && main.chkPalindrome(string.substring(0, (string.length() - 1)/2)) && main.chkPalindrome(string.substring((string.length() + 2)/2,string.length()))) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

	public boolean chkPalindrome(String string) {
		int len = string.length();
		int right = len - 1;
		int left = 0;
		while (true) {
			if (len % 2 == 0 && right < left) {
				break;
			}else if(len % 2 == 1 && right == left){
				break;
			}
			if (string.charAt(left) != string.charAt(right)) {
				return false;
			}
			left++;
			right--;
		}
		return true;
	}
}

Measured memory_bytes: 35620
#include<stdio.h>

int main(void){
    int N;
    int i;
    long int ans = 0;
    scanf("%d",&N);
    int A[N+1], B[N];
    for(i=0;i<N+1;i++){
        scanf("%d",&A[i]);
    }
    for(i=0;i<N;i++){
        scanf("%d",&B[i]);
    }
    for(i=0;i<N;i++){
        if(B[i]-A[i]>=0){
            ans = ans + A[i];
            if(A[i+1]+A[i]-B[i] >= 0){
                ans = ans + B[i]-A[i];
                A[i+1] = A[i+1]+A[i]-B[i];
            }
            else{
                ans = ans + A[i+1];
                A[i+1] = 0;
            }
        }
        else{
            ans = ans + B[i];
        }
    }
    printf("%ld\n",ans);   
    return 0;
    
}


Measured memory_bytes: 896
'use strict';
(function(stdin) {
  //declare function
  function mosaic(array) {
    var h = array[0];
    var w = array[1];
    var line1 = [];
    var char = '';
    for (var i = 0; i < w; i++) {
      char = (i % 2 === 0 ? '#' : '.');
      line1.push(char);
    }
    line1 = line1.join('');
    var line2 = [];
    for (var j = 0; j < w; j++) {
      char = (j % 2 === 0 ? '.' : '#');
      line2.push(char);
    }
    line2 = line2.join('');
    var result = [];
    for (var k = 0; k < h; k++) {
      char = k % 2 === 0 ? line1 : line2;
      result.push(char);
    }
    return result.join('\n');
  }

  //declare variable
  var inputs = stdin.toString().trim().split('\n');
  var data = inputs.slice(0, inputs.indexOf('0 0'));
  data = data.map(function(v) {
    return v.split(' ').map(Number);
  });
  //main
  var all = data.map(mosaic);
  all = all.join('\n\n');
  //display
  console.log(all + '\n');
})(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 16456
#define _USE_MATH_DEFINES
#include<iostream>
#include<algorithm>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#define ll long long
#define str string
#define ld long double
#define vec vector
#define vll vec<ll>
#define rep(i,a,b) for(ll i=a;i<b;i++)
#define rrep(i,b,a) for(ll i=b;i>=a;i--)
#define ALL(a) a.begin(),a.end()
#define rALL(a) a.rbegin(),a.rend()
#define kai "\n"
#define yuque priority_queue
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define mie min_element
#define mae max_element
#define tos to_string
#define sep setprecision
#define lob lower_bound
#define upb upper_bound
#define nep next_permutation
#define MOD 1000000007ll
#define MIN (1e-10)
#define equal(a,b) (abs((a)-(b))<MIN)
#define v2 ten
#define chokusen senbun
#define tenten senbun
#define takaku vec<ten>
using namespace std;
void solve();
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed;
	solve();
}
struct pea{
	ll f,s;
	bool operator<(const pea &p)const{
		return f!=p.f?f<p.f:s<p.s;
	};
};
struct tri{
	ll f,s,t;
	bool operator<(const tri &p)const{
		if(f!=p.f)return f<p.f;
		if(s!=p.s)return s<p.s;
		return t<p.t;
	};
};
class ten{
public:
	ld x,y;
	ten operator+(ten p){return{x+p.x,y+p.y};}
	ten operator-(ten p){return{x-p.x,y-p.y};}
	ten operator*(ld k){return{k*x,k*y};}
	ten operator/(ld k){return{x/k,y/k};}
	ld abs(){return sqrt(abs2());}
	ld abs2(){return x*x+y*y;};
	bool operator<(const ten &p)const{return x!=p.x?x<p.x:y<p.y;};
	bool operator==(const ten &p)const{return (-MIN<x-p.x)&&(x-p.x<MIN)&&(-MIN<y-p.y)&&(y-p.y<MIN);};
	ld naiseki(v2 b){return x*b.x+y*b.y;}
	ld gaiseki(v2 b){return x*b.y-y*b.x;}
};
struct senbun{ten p1,p2;};
struct en{ten o;ld r;};
//幅優先探索(8パズル)
ll bfs(vll hajime){
	struct pazzle{vll id;ll depth;};
	vll goal={1,2,3,4,5,6,7,8,0};
	map<vll,bool> hantei;
	deque<pazzle> p;
	p.pub({hajime,0});
	while(!p.empty()){
		if(p[0].id==goal)return p[0].depth;
		ll pos=find(ALL(p[0].id),0)-p[0].id.begin();
		if(pos%3!=2){
			swap(p[0].id[pos],p[0].id[pos+1]);
			if(!hantei[p[0].id]){
				p.pub({p[0].id,p[0].depth+1});
				hantei[p[0].id]=true;
			}
			swap(p[0].id[pos],p[0].id[pos+1]);
		}
		if(pos%3!=0){
			swap(p[0].id[pos],p[0].id[pos-1]);
			if(!hantei[p[0].id]){
				p.pub({p[0].id,p[0].depth+1});
				hantei[p[0].id]=true;
			}
			swap(p[0].id[pos],p[0].id[pos-1]);
		}
		if(pos>=3){
			swap(p[0].id[pos],p[0].id[pos-3]);
			if(!hantei[p[0].id]){
				p.pub({p[0].id,p[0].depth+1});
				hantei[p[0].id]=true;
			}
			swap(p[0].id[pos],p[0].id[pos-3]);
		}
		if(pos<=5){
			swap(p[0].id[pos],p[0].id[pos+3]);
			if(!hantei[p[0].id]){
				p.pub({p[0].id,p[0].depth+1});
				hantei[p[0].id]=true;
			}
			swap(p[0].id[pos],p[0].id[pos+3]);
		}
		p.pof();
	}
}
void solve(){
	vll a(9);
	rep(i,0,9)cin>>a[i];
	cout<<bfs(a)<<kai;
}


Measured memory_bytes: 32372
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,start,end) for(int i=start;i<=end;i++)
const int INF = 1001001001;
typedef long long ll;
const ll MOD=1000000007;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }

int main(void){
    // Your code here!
    int n,k; cin >> n >> k;
    string s; cin >> s;
    int ans = 0;
    rep(i,n-1) {
        if (s[i] == s[i+1]) ans++;
    }
    ans += 2*k;
    cout << min(ans,n-1) << endl;
}


Measured memory_bytes: 512
#include <stdio.h>
 
int main(){
 
int   a, b;
int   d   ;
int   r   ;
double f   ;
 
scanf("%d %d", &a, &b) ;
 
d = a / b;
r = a % b;
f = 1.0 * a / b;
 
printf("%d %d %f\n", d, r, f);
 
return 0;
}

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

using namespace std;

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

	while(n--)
	{
		map<char,int> P;
		string str;
		string set;
		int mi=1026,mx=0;

		cin >> str;

		int count=1000;
		for(int i=0;i<str.length();i++)
		{
			P[str[i]]=count;
			for(int j=0;j<2;j++)set+=str[i+j];
			if(set=="<-")count--;
			else if(set=="->")count++;
			set.erase(set.begin(),set.end());

			mi=min(mi,count);
			mx=max(mx,count);
		}
		for(int i=mi;i<=mx;i++)
		{
			for(int j=0;j<26;j++)
			{
				char ans;
				ans = j + 'a';
				if(P[ans]==i)cout << ans ;
			}		
		}
		cout << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1212
#include<stdio.h>
int main(void)
{
  int x,y,z;
  do{
  scanf("%d",&x);
     scanf("%d",&y);
     scanf("%d",&z);
  }while(x<1||100<x||y<1||100<y||z<1||100<z);
  int temp;
  temp=x;
  x=y;
  y=temp;
  temp=x;
  x=z;
  z=temp;
  printf("%d %d %d",x,y,z);
return 0;
}

Measured memory_bytes: 1680
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int mod = 1e9+7;
const int mx = 1e5+7;
void add_self(int& a, int b) {
    a += b;
    if(a >= mod) {
        a -= mod;
    }
}
int mul(int a, int b){
  return (ll)a * b % mod;
}

int main(){
  int n;
  scanf("%d", &n);
  ll ans  = pow(n,3);
  std::cout << ans << '\n';
}

Measured memory_bytes: 384
/* cerberus97 - Hanit Banga */

#include <iostream>
#include <iomanip>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <numeric>

using namespace std;

#define pb push_back
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)

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

const int N = 300;

char ans[N];
bool known[N];

vector<int> get_range(int l, int r);
char range_query(vector<int> v);
void sval(int i, char c);

int main() {
	fast_cin();
	int n; cin >> n;
	char cl = range_query(get_range(1, n));
	char cr = 'R' ^ 'B' ^ cl;
	int lo = 1, hi = n + 1;
	while (lo < hi - 1) {
		int mid = (lo + hi) / 2;
		char c = range_query(get_range(mid, mid + n - 1));
		if (c == cl) {
			lo = mid;
		} else {
			hi = mid;
		}
	}
	int l = lo, r = lo + n;
	sval(l, cl);
	sval(r, cr);
	// cout << l << ' ' << r << endl;
	for (int i = 1; i <= 2 * n; ++i) {
		if (known[i]) {
			continue;
		} else if (i < l or i > r) {
			vector<int> v = get_range(l + 1, r - 1);
			v.pb(i);
			sval(i, range_query(v));
		} else {
			// cout << "guessing " << i << endl;
			vector<int> v = get_range(l, r - 1);
			v[i - l] = r;
			sval(i, 'R' ^ 'B' ^ range_query(v));
		}
	}
	cout << "! ";
	ans[2 * n + 1] = 0;
	cout << (ans + 1) << endl;
}

vector<int> get_range(int l, int r) {
	vector<int> range(r - l + 1);
	iota(range.begin(), range.end(), l);
	return range;
}

char range_query(vector<int> v) {
	cout << "? ";
	for (auto &i : v) {
		cout << i << ' ';
	}
	cout << endl;
	string s; cin >> s;
	return s[0];
}

void sval(int i, char c) {
	known[i] = true;
	ans[i] = c;
}

Measured memory_bytes: 724
import random

A = input().split()
B = input().split()
C = input().split()

A[0]=int(A[0])
A[1]=int(A[1])
A[2]=int(A[2])

B[0]=int(B[0])
B[1]=int(B[1])
B[2]=int(B[2])

C[0]=int(C[0])
C[1]=int(C[1])
C[2]=int(C[2])


N = input()
N = int(N)


for i in range(N):
  j = input()
  j=int (j)
 
  if A[0] == j :
    A[0] =1
  if A[1] == j :
    A[1] =1
  if A[2] == j :
    A[2] =1
    
  if B[0] == j :
    B[0] =1
  if B[1] == j :
    B[1] =1
  if B[2] == j :
    B[2] =1
    
  if C[0] == j :
    C[0] =1
  if C[1] == j :
    C[1] =1
  if C[2] == j :
    C[2] =1
    
if ((A[0]==1 and A[1]==1 and A[2]==1) or (B[0]==1 and B[1]==1 and B[2]==1) or (C[0]==1 and C[1]==1 and C[2]==1) or (A[0]==1 and B[0]==1 and C[0]==1) or (A[1]==1 and B[1]==1 and C[1]==1) or (A[2]==1 and B[2]==1 and C[2]==1) or (A[0]==1 and B[1]==1 and C[2]==1) or (A[2]==1 and B[1]==1 and C[0]==1)):

  print ("Yes")

else :
  print ("No")

Measured memory_bytes: 4336
import java.util.Scanner;
import java.lang.String;

public class Main {
    public static void main(String[] args) {
        // 標準入力からデータを読み込む準備
        Scanner sc = new Scanner(System.in);
        // 最初の文字の固まりを整数値と想定して読み込む
        while (true) {
            String Num = sc.next();
            int Sum = 0;
            if (Num.equals("0")) {
                break;
            }
            for (int i = 0; i < Num.length(); i++) {
                Sum += Num.charAt(i) - '0';

            }
            System.out.printf("%d\n", Sum);
        }
    }
}


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

using namespace std;
typedef long long ll;


template<typename T>
T gcd(T a, T b){
   if (a%b == 0){
       return(b);
   }
   else{
       return(gcd(b, a%b));
   }
}

template<typename T>
T lcm(T a,T b){
    return a/gcd(a,b)/b;
}


int main(void){
    vector<ll>dp(1e5+10);
    ll n;
    cin>>n;
    vector<ll>h(n);
    rep(i,n){
        cin>>h[i];
    }
    dp[0]=0;
    dp[1]=abs(h[0]-h[1]);

    for(int i=1;i<n-1;++i){
        dp[i+1]=min(
            dp[i]+abs(h[i]-h[i+1]),
            dp[i-1]+abs(h[i-1]-h[i+1])
        );
    }
    cout<<dp[n-1];
}
/*

*/

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main()
{
int n;
int i=0;
bool x = true;
cin >> n;
vector<string> vec(n);
while (i<n)
{
    cin >> vec.at(i);
    i++;
}
for(int i=0;i<n-1;i++)
{
    if(vec.at(i).at(vec.at(i).size()-1)!=vec.at(i+1).at(0))
    {
        x = false;
        break;
    }
}
if(x)
{
    for(int i=0;i<n;i++)
        {
            for(int j=n-1;i<j;j--)
            if(vec.at(i)==vec.at(j))
            {
               x =false;
                break;
            }
            if(!x)
            break;
        }
}
if(x)
cout << "Yes" << endl;
else
cout << "No" << endl;
}

Measured memory_bytes: 256
H, N = map(int, input().split())

A, B = [0] * N, [0] * N
for i in range(N):
    A[i], B[i] = map(int, input().split())

dp = [[10**9]*(H+1)]*(N+1)

dp[0][0] = 0

for i in range(N):
    for j in range(H+1):
        nj = min(j+A[i], H)

        dp[i+1][nj] = min(dp[i][nj], dp[i+1][j] + B[i])

print(dp[N][H])

Measured memory_bytes: 41836
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<map>
#include<stack>
#include<queue>
#include<bitset>

#define ipair pair<int,int>
#define rep(i,n) for(i=0;i<n;i++)

using namespace std;

typedef long long int lli;
typedef vector<int> vi;

int main() {
	int i, j, k, l, m, n;
	vi a;

	cin >> n;
	a.resize(n);
	rep(i, n) {
		cin >> a[i];
	}
	k = 0;
	rep(i, n - 1) {
		if (a[i] == a[i + 1]) {
			k++;
			i++;
		}
	}
	cout << k;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iomanip>
#include <math.h>
//#include <unistd.h>
//#include <stdio.h>
#define rep(i,x) for(ll i = 0;i<x;i++)
#define all(a) (a).begin(),(a).end()
using ll = long long;
using ld = long double;
using namespace std;
using dou = double;
const ll inf = 2147483647;
const ll INF = 1LL << 60;
const ld pi = 3.14159265358;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
using graph = vector<vector<ll>>;
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;}
ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    if(a % b == 0)return b;
    else return gcd(b,a%b);
}
//素数判定O(sqrt(N))
bool isp(ll n){
    bool res = true;
    if(n == 1)return false;
    else{
        for(ll i = 2;i * i <= n;i++){
            if(n % i == 0){
                res = false;
                break;
            }
        }
        return res;
    }
}

ll fac[510000], finv[510000], inv[510000];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < 510000; i++){
        fac[i] = fac[i - 1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod / i) % mod;
        finv[i] = finv[i - 1] * inv[i] % mod;
    }
}

// 二項係数計算
ll nCk(ll n, ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % mod) % mod;
}
//nのm乗をMODで割ったあまりO(logN)
ll modpow(ll n,ll m,ll MOD){
    ll res = 1;
    while(m){
        if(m & 1)res = (res * n) % MOD;
        m >>= 1;
        n *= n;
        n %= MOD;
    }
    return res;
}

//printf("%.10f\n", N);
/*  vector<ll> vec = {1,2,5,6,8,9,10};
    cout << binary_search(all(vec),5) << endl; -> true*/
/*
    vector<ll> vec = {1,2,5,6,8,9,10};
    auto n = upper_bound(all(vec),4);
    cout << *n << endl; -> 5*/

//    cout << fixed << setprecision(15);

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll N,A,B;
    cin >> N >> A>> B;
    vector<ll> vec(N);
    rep(i,N)cin >> vec[i];
    ll ans = 0;
    rep(i,N - 1){
        ll kyori = vec[i + 1] - vec[i];
        ans += min(B,kyori * A);
    }
    cout<< ans << endl;
}

Measured memory_bytes: 3964
import java.util.Scanner;
import java.util.Arrays;
import java.util.Collections;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();

        Long[] a = new Long[n*3];
        for(int i=0; i<n*3; i++) {
            a[i] = sc.nextLong();
        }
        sc.close();

        Arrays.sort(a, Collections.reverseOrder());

        int cnt = 1;
        long sum = 0;
        for(int i=1; i<=n*3; i+=2) {
            if(cnt > n) {
                break;
            } else {
                sum += a[i];
            }
            cnt++;
        }
        System.out.println(sum);
    }
}


Measured memory_bytes: 100420
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
const int inf=1e9+7;
const ll mod=1e9+7;

int main() {
    ll X;
    cin>>X;
    ll mon = 100;
    int ans = 0;
    while(mon < X){
        ans++;
        mon += mon/100;
    }
    cout<<ans<<endl;
}



Measured memory_bytes: 3636
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
	
	static final int MAX = 400000000;
	
	public static void main(String[] args) throws IOException {
		MyScanner sc = new MyScanner();
		PrintWriter out = new PrintWriter(System.out);
		int N = sc.nextInt();
		int l = 2 * MAX, l1 = 2 * MAX, l2 = 2 * MAX, r = -2 * MAX, r1 = -2 * MAX, r2 = -2 * MAX;
		int d = 2 * MAX, d1 = 2 * MAX, d2 = 2 * MAX, u = -2 * MAX, u1 = -2 * MAX, u2 = -2 * MAX;
		int x, y;
		char c;
		for (int i = 0; i < N; i++) {
			x = sc.nextInt() * 2;
			y = sc.nextInt() * 2;
			c = sc.next().charAt(0);
			if (c == 'L') {
				l2 = Math.min(l2, x);
				r2 = Math.max(r2, x);
			} else if (c == 'R') {
				l1 = Math.min(l1, x);
				r1 = Math.max(r1, x);
			} else {
				l = Math.min(l, x);
				r = Math.max(r, x);
			}
			if (c == 'D') {
				d2 = Math.min(d2, y);
				u2 = Math.max(u2, y);
			} else if (c == 'U') {
				d1 = Math.min(d1, y);
				u1 = Math.max(u1, y);
			} else {
				d = Math.min(d, y);
				u = Math.max(u, y);
			}
		}
		long ans = MAX * (long)MAX, first, second;
		for (int t = 0; t <= MAX; t++) {
			first = Math.max(r, Math.max(r1, r2)) - Math.min(l, Math.min(l1, l2));
			second = Math.max(u, Math.max(u1, u2)) - Math.min(d, Math.min(d1, d2));
			ans = Math.min(ans, first * second);
			l1++; r1++; d1++; u1++;
			l2--; r2--; d2--; u2--;
		}
		out.println(ans / 4.0);
		
		out.flush();
	}
	
	static class MyScanner {
		private BufferedReader br;
		private StringTokenizer tokenizer;
		
		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		
		public int nextInt() {
			return Integer.parseInt(next());
		}
		
		public long nextLong() {
			return Long.parseLong(next());
		}
	}
}


Measured memory_bytes: 42468
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String x = br.readLine();
		System.out.println(x.charAt(0) == x.charAt(2) ? "Yes" : "No");

	}
}

Measured memory_bytes: 23124
n,m = gets.split.map &:to_i
ans = []

a = 1
c = ((n - 1) / 2 + 1) / 2
b = a + c * 2 - 1

c.times do |i|
  ans << [a + i, b - i]
end

e = n
f = ((n - 1) / 2) / 2
d = e - f * 2

f.times do |i|
  ans << [d + i, e - i]
end

# debug = -> a,b {
#   a,b = b,a if a > b
#   p [a, b, b-a, a+n-b]
# }

ans.take(m).each do |i,j|
  puts [i,j].join(" ")
  # debug[i,j]
end


Measured memory_bytes: 20384
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)

int main() {
	string s;
	cin >> s;
	int ans=0;
	rep(i, s.length()) {
		if(s[i] != s[s.length()-1-i]) {
			s[i] = s[s.length()-1-i];
			ans++;
		}
	}
	cout << ans << endl;

  return 0;
}


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

int order(int a){
  if (a/100000 > 0){
    return 100000;
  }
  else if (a/10000 > 0){
    return 10000;
  }
  else if (a/1000 > 0){
    return 1000;
  }
  else if (a/100 > 0){
    return 100;
  }
  else if (a/10 > 0){
    return 10;
  }
  else{
    return 1;
  }
}

int judge(int k, int i, int j){
  int top = k / order(k);
  int under = k % 10;
  if (top == i){
    if (under == j){
      return 1;
    }
    else{
      return 0;
    }
  }
  else{
    return 0;
  }
}

int c(int i, int j, int N){
  int counter = 0;
  for (int k = 1; k <= N; k++){
    counter += judge(k, i, j);
  }
  return counter;
}

int main() {
  int N;
  cin >> N;
  int counter = 0;
  for (int i = 0; i <= 9; i++){
    for (int j = 0; j <= 9; j++){
      counter += c(i, j, N) * c(j, i, N);
    }
  }
  cout << counter << endl;
}

Measured memory_bytes: 256
import sys
n=int(input())
a=list(map(int,input().split()))
idx=0
if a==list(range(1,n+1)):
  print(0)
  sys.exit()
if sum(a)==n:
  print(n-1)
  sys.exit()
if 1 not in a:
  print('-1')
  sys.exit()
for i in range(1,n+1):
  for j in range(idx,n):
    if a[j]==i:
      idx=j
      break
    if j==n-1:
      print(n-i+1)
      sys.exit()
    
    


Measured memory_bytes: 26140
#pragma GCC optimize ("O3")
// #pragma GCC target ("avx")
#include<stdio.h>
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>

#ifdef LOCAL
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
#define NDEBUG
#define eprintf(...) do {} while (0)
#endif
#include<cassert>

using namespace std;

typedef long long LL;
typedef vector<int> VI;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define EACH(i,c) for(__typeof((c).begin()) i=(c).begin(),i##_end=(c).end();i!=i##_end;++i)

template<class T> inline void amin(T &x, const T &y) { if (y<x) x=y; }
template<class T> inline void amax(T &x, const T &y) { if (x<y) x=y; }
template<class Iter> void rprintf(const char *fmt, Iter begin, Iter end) {
    for (bool sp=0; begin!=end; ++begin) { if (sp) putchar(' '); else sp = true; printf(fmt, *begin); }
    putchar('\n');
}

int N;
int A[200011];
int que[200011];

void MAIN() {
    scanf("%d", &N);
    REP (i, N) scanf("%d", A+i);
    sort(A, A+N);
    reverse(A, A+N);

    int head = 0;
    int len = 1;
    que[0] = A[0];
    LL ans = 0;
    for (int i=1; i<N; i++) {
	ans += que[head++];
	if (len < N) que[len++] = A[i];
	if (len < N) que[len++] = A[i];
    }

    printf("%lld\n", ans);
}

int main() {
    int TC = 1;
//    scanf("%d", &TC);
    REP (tc, TC) MAIN();
    return 0;
}



Measured memory_bytes: 5388
use std::collections::HashMap;

fn main() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let n: usize = s.trim().parse().unwrap();
    let mut h: HashMap<String, isize> = HashMap::new();
    for _ in 0..n {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let x = match h.get(&s) {Some(x) => *x, None => 0};
        h.insert(s, x+1);
    }

    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let m: usize = s.trim().parse().unwrap();
    for _ in 0..m {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        let x = match h.get(&s) {Some(x) => *x, None => 0};
        h.insert(s, std::cmp::max(-1, x-1));
    }

    println!("{:?}", std::cmp::max(h.values().max().unwrap(), &0));
}



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

using namespace std;

int main()
{
	// 入力
	int N;
	cin >> N;
	vector<int> B(N - 1);
	for (int i = 0; i < N - 1; i++)
	{
		cin >> B[i];
	}
	
	vector<int> A(N);
	// A(1) = B(1)
	A[0] = B[0];
	// A(N) = B(N)
	A[N - 1] = B[N - 2];
	
	for (int i = 1; i < N - 1; i++)
	{
		// A(i) = min(B(i-1), B(i))
		A[i] = min(B[i - 1], B[i]);
	}
	
	int answer = 0;
	for (int i = 0; i < N; i++)
	{
		answer += A[i];
	}
	
	// 出力
	cout << answer << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <stdio.h>
using namespace std;
#define ll long long
int n;
vector<int> primelist;
int arr[1000];

ll mod = 1000000007;

int main(){
	scanf("%d", &n);
	for (int i = 0; i < 1000; i++){
		arr[i] = 1;
	}
	
	primelist.push_back(2);
	for (int i = 3; i <= n; i+=2){
		bool yes = true;
		for (vector<int>::iterator it = primelist.begin(); it != primelist.end(); it++){
			if ((*it)*(*it) > i) break;
			if (i % (*it) == 0){
				yes = false;
				break;
			}
		}
		if (yes){
			primelist.push_back(i);
		}
	}
	
	for (int i = 1; i <= n; i++){
		int a = i;
		for (int j = 0; j < primelist.size(); j++){
			if (a == 1) break;
			while (a % primelist[j] == 0){
				a /= primelist[j];
				arr[j]++;
			}
		}
	}
	
	ll answer = 1;
	for (int i =0 ; i < 1000; i++){
		answer *= arr[i];
		answer %= mod;
	}
	
	printf("%lld\n", answer);
	
	
}

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

#define rep(i,n) for(int i=0;i<(n);++i)
#define reps(i,n) for(int i=1;i<=(n);++i)
#define all(x) (x).begin(),(x).end()
#define int long long
using pii = pair<int,int>;
constexpr int INF  = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;

signed main(){
	int q,h,s,d,n;
	int a,b,c;
	int ans = 0;
	cin >> q >> h >> s >> d >> n;
	n *= 1000;
	while(n){
		if(n >= 2000){
			if(d == min({q * 8,h * 4,s * 2,d})){
				ans += d * (n / 2000);
				n %= 2000;
			}
			else if(s * 2 == min({q * 8,h * 4,s * 2,d})){
				ans += s * (n / 1000);
				n %= 1000;
			}
			else if(h * 4 == min({q * 8,h * 4,s * 2,d})){
				ans += h * (n / 500);
				n %= 500;
			}
			else{
				ans += q * (n / 250);
				n%= 250;
			}
		}
		else if(n >= 1000){
	        if(s == min({q * 4,h * 2,s})){
				ans += s * (n / 1000);
	            n %= 1000;
	        }
	        else if(h * 2 == min({q * 4,h * 2,s})){
				ans += h * (n / 500);
	            n %= 500;
	        }
	        else{
				ans += q * (n / 250);
				n%= 250;
			}
	    }
		else if(n >= 500){
	        if(h == min(q * 2,h)){
				ans += h * (n / 500);
	            n %= 500;
	        }
	        else{
				ans += q * (n / 250);
				n%= 250;
			}
	    }
		else{
			ans += q * (n / 250);
			n %= 250;
		}
	}
	cout << ans << '\n';
    return 0;	
}


Measured memory_bytes: 256
import sys
import heapq
import math


def input():
    return sys.stdin.readline().rstrip()


def main():
    N, K = map(int, input().split())
    A = list(map(int, input().split()))
    ok = max(A)
    ng = 0

    while abs(ok - ng) > 1:
        mid = abs(ok + ng) // 2
        count = 0
        for i in range(N):
            count += math.ceil(A[i] / mid)-1
        if count <=K:
            ok = mid
        else:
            ng = mid

    print(ok)


if __name__ == "__main__":
    main()


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

int main(){
  int n;
  string ans = "YES";
  cin >> n;
  vector<int> vec(n);
  for(int i=0;i<n;i++){
    cin >> vec.at(i);}
  sort(vec.begin(), vec.end());
  for(int i=0;i<n-1;i++){
     if(vec.at(i)==vec.at(i+1)){
        ans = "NO";
     }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
typedef  long long ll;
ll gcd(ll x,ll y){
   if(y==0) return x;
   else return gcd(y,x%y);
}
ll lcm(ll x,ll y){
   return x/gcd(x,y)*y;
}
using namespace std;
int main(){ 
   int n,k;
   cin>>n>>k;
   int ans=1;
   rep(i,n){
      if(ans<k){
         ans*=2;
      }
      else{
         ans+=k;
      }

   }
   cout<<ans;
   return 0;
}

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

using namespace std;

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

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

    int x[3][n];
    x[0][0] = max(a[1][0], a[2][0]);
    x[1][0] = max(a[2][0], a[0][0]);
    x[2][0] = max(a[0][0], a[1][0]);
    for(int i = 1; i < n; i++)
    {
        x[0][i] = a[0][i] + max(x[1][i - 1], x[2][i - 1]);
        x[1][i] = a[1][i] + max(x[2][i - 1], x[0][i - 1]);
        x[2][i] = a[2][i] + max(x[0][i - 1], x[1][i - 1]);
    }
    cout << max({x[0][n - 1], x[1][n - 1], x[2][n - 1]}) << endl;
    return 0;
}


Measured memory_bytes: 2560
// 16:39〜16:43

#include <cstdio>
#include <iostream>
#include <algorithm>
#include <deque>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <map>
#include <cmath>

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

using namespace std;

int main(){
	string a, b, c;
	cin >> a >> b >> c;
	cout << a[0] << b[0] << c[0] << endl;
	return 0;
}


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

map<int,bool> mp;

int a[10010],b[10010];
int p[10010],h[10010],n,tt,tot,ans;
bool bo[10010];

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

inline int gcd(int x,int y) { return (!y)?x:gcd(y,x%y); }

inline void pre_gao()
{
	tot=0;
	for (int i=2;i<=n;i++)
	{
		if (!bo[i]) p[++tot]=i;
		for (int j=1;j<=tot&&i*p[j]<=n;j++)
		{
			bo[i*p[j]]=true;
			if (i%p[j]==0) break;
		}
	}
}

inline void gao(int hh)
{
	for (int i=2;i*i<=hh;i++) if (hh%i==0)
	{
		ans++;mp[i]=true;
		while (hh%i==0) hh/=i;
	}
	if (hh>1) ans++,mp[hh]=true;
}

inline void check(int hh)
{
	bool flag=true;
	for (int i=0;i<=n;i++) b[i]=a[i]%hh;
	tt=0;
	for (int i=0;i<hh;i++) h[++tt]=i;
	random_shuffle(h+1,h+tt+1);
	for (int i=1;i<=tt;i++)
	{
		int now=1;
		ll res=0;
		for (int j=0;j<=n;j++)
		{
			if (j>0) now=now*h[i]%hh;
			res+=(ll)now*b[j];
		}
		res%=hh;
		if (res!=0) { flag=false;break; }
	}
	if (flag) mp[hh]=true,ans++;
}

int main()
{
	srand(19260816);
	n=rd();pre_gao();
	for (int i=n;i>=0;i--) a[i]=rd();
	int hh=0;ans=0;
	for (int i=0;i<=n;i++) hh=gcd(hh,abs(a[i]));
	gao(hh);
	for (int i=1;i<=tot;i++) if (!mp[p[i]]) check(p[i]);
	for (map<int,bool>::iterator it=mp.begin();it!=mp.end();it++) if (it->second==true) printf("%d\n",it->first);
	return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N,M;
    cin >> N >> M;
    vector<int> vec(N+1), flag(N+1);
    int cnt = 0, ans = 0;
    rep(i,0,M){
        int x;
        string s;
        cin >> x >> s;
        if(flag[x])continue;
        if(s == "WA")vec[x]++;
        if(s == "AC"){
            flag[x] = 1;
            cnt += vec[x];
            ans++;
        }
    }
    cout << ans << " " << cnt << endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>

using namespace std;
typedef long long ll;

const int _INF = 0x7fffffff + 1;

int a[102];
int b[102];

int main()
{
    int n;
    cin>>n;
    int sumtime = 0;
    for(int i = 1; i  <= n; i++)
    {
        scanf("%d", &a[i]);
        sumtime += a[i];
    }

    int m;
    cin>>m;
    for(int i = 0; i < m; i++)
    {
        int pa, pb;
        scanf("%d %d", &pa, &pb);

        printf("%d\n", sumtime - (a[pa] - pb));
    }

    return 0;
}


Measured memory_bytes: 256
matcing = gets.chomp.to_s
alphabet = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
0.step(alphabet.length) do |i|
    if matcing == alphabet[i]
        printf("%s\n",alphabet[i+1])
        break
    end
end

Measured memory_bytes: 1788
n, m = map(int, input().split())
h = list(map(int, input().split()))
table = [[] for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    table[a-1].append(h[b-1])
    table[b-1].append(h[a-1])

ans = 0
for i in range(n):
    if len(table[i]) > 0:
        if h[i] > max(table[i]):
            ans += 1
    else:
        ans += 1
print(ans)

Measured memory_bytes: 92820
#include<iostream>
#include<bits/stdc++.h>
#include<iomanip>
#include<math.h>
#include<vector>
#include<cctype>
#include<string>
#include<set>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
std::string line;
typedef long long ll;

int main(){
   int a,b,c,d;
   cin >> a >> b >> c >> d;

   int cnt = 0;
   for(int i=a+1;i<=b;i++){
      if(i>d) break;
      else if(i>=c+1) cnt++;
   }

   cout << cnt << endl;


   return 0;
}

Measured memory_bytes: 256
import sys
from math import *
from collections import deque, Counter, defaultdict
from fractions import gcd
input = lambda: sys.stdin.readline().rstrip()

def eprint(s):
    sys.stderr.write('DEBUG: {}'.format(s))
    return

def main():
    n, m, k = map(int, input().split())
    fgraph = [list() for i in range(n)]
    bgraph = [list() for i in range(n)]
    cgraph = [list() for i in range(n)]
    
    rks = [None] *n
    sys.setrecursionlimit(10**9)
    # r: どの連結成分に存在するかをメモするid
    def dfs(graph,s,r):
        if rks[s] is None:
            rks[s] = r
        for i in range(len(graph[s])):
            if rks[graph[s][i]-1] is not None:
                continue
            dfs(graph, graph[s][i]-1,r)

    for i in range(m):
        a,b = map(int, input().split())
        fgraph[a-1].append(b)
        fgraph[b-1].append(a)

    # print(fgraph)
    #print(bgraph)
    # 連結成分に対してid的なindexをつける
    c = -1
    for i in range(n):
        if rks[i] is None:
            c += 1
            dfs(fgraph, i, c)
    
    for i in range(k):
        c,d = map(int, input().split())
        if rks[c-1] == rks[d-1]:
            bgraph[d-1].append(c)
            bgraph[c-1].append(d)

    counter = Counter(rks)
    for i in range(n):
        # counter[rks[i]] 連結成分のサイズ
        # len(fgraph[i]) 友達の数
        # len(bgraph[i]) 連結成分内のブロックの数
        # 1 自分
        print(counter[rks[i]] - len(fgraph[i]) - len(bgraph[i]) - 1)

if __name__ == '__main__':
    main()


   

Measured memory_bytes: 420756
/*
Keep clam  Believe youself
*/
#include<cstdio>
#include<iostream>
#include<cstring>
#include<string>
#include<algorithm>
#include<queue>
#include<map>
#include<vector>
#include<stack>
#include<set>
#include<cmath>
#define Xiaobo main
using namespace std;
const int maxn=2e5+7;
const int mod=1e9+7;
const double eps=1e-15;
const double pi=acos(-1);
const int INF=0x3f3f3f;
typedef long long ll;
ll read(){ll c = getchar(),Nig = 1,x = 0;while(!isdigit(c) && c!='-')c = getchar();if(c == '-')Nig = -1,c = getchar();while(isdigit(c))x = ((x<<1) + (x<<3)) + (c^'0'),c = getchar();return Nig*x;}
ll gcd(ll a,ll b){ return b==0?a:gcd(b,a%b);}
int a[maxn];
bool cmp(int x,int y) {
	return x>y;
}
int Xiaobo()
{
	int n,k;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++) {
		scanf("%d",&a[i]);
	}
	sort(a+1,a+1+n,cmp);
	ll sum=0;
	for(int i=k+1;i<=n;i++) {
		sum+=a[i];
	}
	cout<<sum<<'\n';
}


Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <istream>
using namespace std;

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

    int month = stoi(S.substr(5, 2));
    int day = stoi(S.substr(8, 2));

    if (month <= 4)
    {
        cout << "Heisei" << endl;
    }
    else
    {
        cout << "TBD" << endl;
    }
}

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

int n,cnt,last[MAXN];
int father[MAXN],deep[MAXN],dis[MAXN];
int q[MAXN],nnn[MAXN],mx[MAXN];
int tim,a[MAXN][2],xx,yy;
bool vis[MAXN],win[MAXN];

struct edge
{
    int to,next,h;
}t[MAXN*4];

void add(int u,int v,int h)
{
    t[++cnt].to=v;t[cnt].h=h;
    t[cnt].next=last[u];last[u]=cnt;
    t[++cnt].to=u;t[cnt].h=h;
    t[cnt].next=last[v];last[v]=cnt;
}

void dfs(int x)
{
    deep[x]=deep[father[x]]+1;nnn[x]=++tim;
    for (int i=last[x];i;i=t[i].next)
        if (t[i].to!=father[x]) father[t[i].to]=x,dfs(t[i].to);
    mx[x]=++tim;
}

bool check(int x,int y)
{
    if (nnn[x]>nnn[y]) swap(x,y);
    if (nnn[x]<nnn[y]&&mx[x]>nnn[y]) return deep[y]-deep[x]>2 ? true : false;
    if (father[x]==father[y]) return false;
    return true;
}

void bfs()
{
    int h=1,tt=1;q[1]=xx;vis[xx]=1;
    while (h<=tt)
    {
        int x=q[h++];
        for (int i=last[x];i;i=t[i].next)
            if (!t[i].h&&!vis[t[i].to])
            {
                dis[t[i].to]=dis[x]+1;
                if (dis[t[i].to]<deep[t[i].to]) vis[t[i].to]=1,q[++tt]=t[i].to;
            }
    }
}

int max(int a,int b){return a>b?a:b;}

template<class T>inline void read(T &res)
{
    static char ch;T flag=1;
    while((ch=getchar())<'0'||ch>'9')if(ch=='-')flag=-1;res=ch-48;
    while((ch=getchar())>='0'&&ch<='9')res=res*10+ch-48;res*=flag;
}

int main()
{
    int ans=0;
    read(n);read(xx);read(yy);

    for (int i=1;i<n;i++) {read(a[i][0]);read(a[i][1]);}

    for (int i=1;i<n;i++)
    {
        int x,y;
        read(x);read(y);
        add(x,y,1);
    }

    deep[0]=-1;
    dfs( yy );

    for (int i=1;i<n;i++)
    {
        if (check(a[i][0],a[i][1]))
            win[a[i][0]]=win[a[i][1]]=1;
        else add(a[i][0],a[i][1],0);
    }

    bfs();

    for (int i=1;i<=n;i++)
        if (win[i]&&vis[i])
            {putchar('-');putchar('1');return 0;}

    for (int i=1;i<=n;i++)
        if (vis[i])
            ans=max(ans,deep[i]<<1);

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

Measured memory_bytes: 22656
n, m = map(int, input().split(' '))
l_ = []
r_ = []
for i in range(m):
    l,r = map(int, input().split(' '))
    l_ += [l]
    r_ += [r]
l = max(l_)
r = min(r_)
if n < l:
    print(0)
elif n < r:
    r = n
    print(r - l + 1)
elif l > r:
    print(0)
elif l == r:
    print(1)
else:
    print(r - l + 1)

Measured memory_bytes: 56664
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

int main() {
    int N;
    cin >> N;
    
    int ans = 0;
    rep(i, N) {
        int l,r;
        cin >> l >> r;
        ans+=(r-l+1);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, e) for (int i = s; i < e; ++i)
#define sort_(a) stable_sort(a.begin(), a.end())
#define rsort(a) stable_sort(a.rbegin(), a.rend())
#define sum(a) accumulate(a.begin(), a.end(), 0LL)
#define join(a, d) accumulate(a.begin() + 1, a.end(), a[0], [](string s, string t) {return s + d + t;})
#define all(a) a.begin(), a.end()
// #define __lcm(a, b) std::__detail::__lcm(a, b)
typedef long long ll;
const long mod = 1e9 + 7;

vector<int> prime_factors(ll n) {
  vector<int> ret;
  while (n >= 4) {
    if (n % 2) {
      break;
    } else {
      n /= 2;
      ret.push_back(2);
    }
  }
  ll i = 3;
  while (n >= i * i) {
    if (n % i) {
      i += 2;
    } else {
      n /= i;
      ret.push_back(i);
    }
  }
  ret.push_back(n);
  return ret;
}

int main(void) {
#ifdef DEBUG
  freopen("input.txt", "r", stdin);
#endif

  ios_base::sync_with_stdio(false);
  cin.tie(0);

  int N;
  cin >> N;
  vector<long> A(N);
  rep(i, 0, N) {
    cin >> A[i];
  }

  int ans = 0;
  rep(i, 0, N) {
    if (A[i] % 2 == 0) {
      vector<int> p;
      p = prime_factors(A[i]);
      ans += count(all(p), 2);
    }
  }
  cout << ans << endl;
  return 0;
}


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

using namespace std;

class B {
	vector<string> S;
	int N, L;

public:
	void solve()
	{
		cin >> N >> L;
		S.resize(N);
		for (int i{ 0 }; i < N; i++) cin >> S[i];

		sort(S.begin(), S.end());
		
		for (int i{ 0 }; i < N; i++) cout << S[i];
		cout << endl;
	}
};


int main()
{
	B solution;
	solution.solve();

	return 0;
}

Measured memory_bytes: 256