akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
#include<cstring>
using namespace std;
long long int mod = 1e9 + 7;
template <class T>
void inputV(vector<T> &x, int n){
  for(int i=0; i<n; i++) cin >> x[i];
}

int main() {
  int a[2], k;
  cin >> a[0] >> a[1] >> k;

  int l = 0;
  while(l != k){
    if(a[l%2]%2 == 1) a[l%2]--;
    a[(l+1)%2] += a[l%2] / 2;
    a[l%2] /= 2;
    l++;
  }
  cout << a[0] << " " << a[1] << endl;

  return 0;
}


///


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        // 入力受付
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();

        if(a < b * 2){
            System.out.println(0);
        }else{
            System.out.println(a - b * 2);
        }

    }

}

Measured memory_bytes: 23764
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

//typedef pair<int,int> P;

int main(){
	int N;
	char s[101];

	scanf("%d",&N);
	scanf("%s",s);

	int x[101];
	x[0] = 0;
	for(int i=1;i<=N;i++){
		if(s[i-1]=='I') x[i] = x[i-1] + 1;
		if(s[i-1]=='D') x[i] = x[i-1] - 1;
	}

	int max = 0;
	for(int i=1;i<=N;i++){
		if(max<x[i]) max = x[i];
	}

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

	return 0;
}


Measured memory_bytes: 256
n = gets.chomp.to_i
h = gets.chomp.split(" ").map(&:to_i)

a = Array.new(n,Float::INFINITY)
b = [0,(h[1]-h[0]).abs]

(2..n-1).each do |i|
  b[i] = [b[i-1]+(h[i-1]-h[i]).abs, b[i-2]+(h[i-2]-h[i]).abs].min()
end

puts b[n-1]

Measured memory_bytes: 12676
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
#define pb push_back
#define pii pair < int , int >
#define F first
#define S second
#define int long long
#define sync ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#pragma GCC optimize ("Ofast")
using namespace std;
/// khodaya komak kon
/// ya navid navid
const int N=2e5+100;
ll seg[4*N];
void shift(ll nod){
    if (seg[nod]==1){
        seg[nod*2]=1;
        seg[nod*2+1]=1;
    }
}
void upd(ll nod,ll l,ll r,ll L,ll R){
    if (l>=R || L>=r){
        return ;
    }
    if (l>=L && r<=R){
        seg[nod]=1;
        return ;
    }
    shift(nod);
    ll mid=(r+l)/2;
    upd(nod*2,l,mid,L,R);
    upd(nod*2+1,mid,r,L,R);
}
ll get(ll nod,ll l,ll r,ll id){
    if (r-l==1){
        return seg[nod];
    }
    shift(nod);
    ll mid=(r+l)/2;
    if (mid>id){
        return get(nod*2,l,mid,id);
    }
    else{
        return get(nod*2+1,mid,r,id);
    }
}
ll k;
vector <pii> h;
ll st[N];
ll fn[N];
vector <int> g[N];
ll cnt=0;
ll par[N];
vector <int> t;
ll par1[N];
ll dfs(ll v,ll p,ll hi){
    par1[v]=p;
    t.pb(v);
    ll z=t.size();
    z-=k;
    z=max((ll)0,z);
    par[v]=t[z];
    h.pb({hi,v});
    st[v]=cnt;
    for (int i=0;i<g[v].size();i++){
        ll u=g[v][i];
        if (u==p){
            continue;
        }
        cnt++;
        dfs(u,v,hi+1);
    }
    t.pop_back();
    fn[v]=cnt;
}
int32_t main(){
    sync;
    ll n;
    cin >> n >> k;
    ll ans=0;
    ll x;
    cin >> x;
    if (x!=1){
        ans++;
    }
    for (int i=2;i<=n;i++){
        cin >> x;
        g[x].pb(i);
        g[i].pb(x);
    }
    upd(1,0,N,0,1);
    dfs(1,1,0);
    sort(h.begin(),h.end());
    reverse(h.begin(),h.end());
    for (int i=0;i<n-1;i++){
        ll v=h[i].S;
        ll u=par[v];
        //cout << v << " " << u << endl;
        ll z=get(1,0,N,st[v]);
        if (z==1 || par1[u]==1){
            continue;
        }
        ans++;
        upd(1,0,N,st[u],fn[u]+1);
    }
    cout << ans;
}


Measured memory_bytes: 28824
k = (1..10).to_a
while n = gets
c1,c2,c3 = n.split.map(&:to_i)
sum = c1 + c2
count = 0
count1 = 0
  for i in k
    if sum + i <= 20 && i != c3
      count += 1
    else
      count1 += 1
    end
  end
  if count >= 4
    puts "YES"
  else
    puts "NO"
  end
end


Measured memory_bytes: 6852
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <set>
#include <map>
#include <vector>
#include <math.h>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <functional>
#include <numeric>
#include <iostream>
#include <string>
#include <time.h>
#include <bitset>

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }

ll N, X, M;

int main() {

	cin >> N >> X >> M;

	if (N <= 112345) {
		ll ans = 0;
		ll A = X;
		rep(i, N) {
			ans += A;
			A = A * A % M;
		}
		cout << ans << endl;
		return 0;
	}

	map<ll, ll> E;
	ll A = X;
	ll lb = 0, le = 1;
	rep(i, N) {
		if (E.find(A) == E.end()) {
			E[A] = i;
			A = A * A % M;
		}
		else {
			lb = E[A];
			le = i;
			break;
		}
	}

	ll pre = 0, loop = 0, end = 0, endc = (N - lb) % (le - lb);

	A = X;
	rep(i, lb) {
		pre += A;
		A = A * A % M;
	}

	rep(i, le - lb) {
		if (i < endc) end += A;
		loop += A;
		A = A * A % M;
	}

	cout << pre + loop * ((N - lb) / (le - lb)) + end << endl;

	return 0;
}


Measured memory_bytes: 6664
import java.util.Scanner;

class Main
{
   public static void main(String[] args)
   {
      Scanner stdIn = new Scanner(System.in);
      int a = stdIn.nextInt();
      int b = stdIn.nextInt();
      if ( a < b ) {
         System.out.println( "a < b" );
      } else if ( a > b ) {
         System.out.println( "a > b" );
      } else {
         System.out.println( "a == b" );
      }
   }
}

Measured memory_bytes: 25960
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(a)  (a).begin(),(a).end()
int n,m;
int p[100000],y[100000]; vector<ll> yd[100001];
int main(){
  cin>>n>>m;
  rep(i,m){
    cin>>p[i]>>y[i];
    yd[p[i]].push_back(y[i]);
  }
  rep(i,n){
    sort(ALL(yd[i+1]));
  }
  rep(i,m){
    printf("%012lld\n",ll(p[i])*1000000+int(lower_bound(ALL(yd[p[i]]),y[i])-yd[p[i]].begin())+1);
  }
}


Measured memory_bytes: 7808
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e4+10;
int main()
{
    int s,w;
    cin>>s>>w;
    if(w>=s){
        printf("unsafe\n");
    }
    else{
        printf("safe\n");
    }
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

int N, K;
int H[301];
int h[301];
ll dp[301][301][301];
ll dp_min1[301][301][301]; // min{dp[i][j][k]}
ll dp_min2[301][301][301]; // min{dp[i][j][k]+H[k]-H[i]}

const ll INF = 1e+15;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> N >> K;
    for(int i = 0; i < N; i++) {
        cin >> H[i+1];
        h[i+1] = H[i+1];
    }
    sort(h, h+N+1);
    for(int i = 0; i <= K; i++){
        for(int k = 0; k <= N; k++){
            dp[0][i][k] = INF;
            dp_min1[0][i][k] = INF;
            dp_min2[0][i][k] = INF;
        }
    }
    dp[0][0][0] = 0;
    dp_min1[0][0][0] = 0;
    dp_min2[0][0][0] = 0;
    for(int j = 0; j <= K; j++){
        dp_min1[0][j][0] = dp[0][j][0];
        for(int k = 1; k <= N; k++){
            dp_min1[0][j][k] = min(dp[0][j][k], dp_min1[0][j][k-1]+h[k]-h[k-1]); 
        }
    }
    for(int j = 0; j <= K; j++){
        dp_min2[0][j][N] = dp[0][j][N];
        for(int k = N-1; k >= 0; k--){
            dp_min2[0][j][k] = min(dp[0][j][k], dp_min2[0][j][k+1]);                 
        }
    }
    // for(int i = 1; i <= N; i++)cout << h[i] << ' ';
    // cout << endl;
    for(int i = 1; i <= N; i++){
        for(int j = 0; j <= K; j++){
            for(int k = 0; k <= N; k++){
                if(h[k] != H[i]){
                    if(j >= 1) dp[i][j][k] = min({dp[i-1][j-1][k], dp_min1[i-1][j-1][k], dp_min2[i-1][j-1][k]}); 
                    else dp[i][j][k] = INF;
                }else{
                    dp[i][j][k] = min({dp[i-1][j][k], dp_min1[i-1][j][k], dp_min2[i-1][j][k]}); 
                }
            }
        }
        for(int j = 0; j <= K; j++){
            dp_min1[i][j][0] = dp[i][j][0];
            for(int k = 1; k <= N; k++){
                dp_min1[i][j][k] = min(dp[i][j][k], dp_min1[i][j][k-1]+h[k]-h[k-1]); 
            }
        }
        for(int j = 0; j <= K; j++){
            dp_min2[i][j][N] = dp[i][j][N];
            for(int k = N-1; k >= 0; k--){
                dp_min2[i][j][k] = min(dp[i][j][k], dp_min2[i][j][k+1]);                 
            }
        }
        // for(int j = 0; j <= K; j++){
        //     for(int k = 0; k <= N; k++){
        //         cout << dp[i][j][k] << ' ';            
        //     }
        //     cout << endl;
        // }
    }
    ll ans = INF;
    for(int j = 0; j <= K; j++){
        for(int k = 0; k <= N; k++){
            ans = min(ans, dp[N][j][k]);   
            // cout << dp[N][j][k] << ' ';            
        }
        // cout << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 639488
import java.io.*;
import java.util.*;

public class Main {

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

    static class Question {
        public void solve(Scanner sc) {
            int n = sc.nextInt();
            long sum = 0;
            while(n > 0) {
                if(n % 3 == 0 && n % 5 == 0 || n % 3 == 0 || n % 5 == 0) {
                    n--;
                    continue;
                }
                sum += n--;
            }
            System.out.println(sum);
        }
    }
}


Measured memory_bytes: 35808
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using GraphC = vector<vector<char>>;
using GraphI = vector<vector<int>>;
using pint = pair<int, int>;

int main() {
  int h, w;
  cin >> h >> w;
  GraphC g(h, vector<char>(w));
  rep(y, h) rep(x, w) cin >> g[y][x];

  // 多点をスタートとして扱う
  GraphI d(h, vector<int>(w, -1));
  queue<pint> q;
  rep(y, h) {
    rep(x, w) {
      if (g[y][x] == '#') {
        d[y][x] = 0;
        q.push(pint(y, x));
      }
    }
  }

  int dy[4] = {-1, 0, 1, 0};
  int dx[4] = {0, 1, 0, -1};
  while (!q.empty()) {
    auto now = q.front();
    q.pop();
    rep(i, 4) {
      int ny, nx;
      ny = now.first + dy[i];
      nx = now.second + dx[i];
      if (ny < 0 || ny >= h || nx < 0 || nx >= w) continue;
      if (g[ny][nx] == '#') continue;
      if (d[ny][nx] != -1) continue;
      d[ny][nx] = d[now.first][now.second] + 1;
      q.push(pint(ny, nx));
    }
  }

  int ans = 0;
  rep(y, h) rep(x, w) ans = max(ans, d[y][x]);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 13456
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**15
mod = 10**9+7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)


def main():
    n = I()
    d = {}
    d[0] = -1
    for i in range(n):
        d[I()] = i
    r = n - 1
    c = 0
    for i in range(1,n+1):
        if d[i-1] > d[i]:
            if r > n - c:
                r = n - c
            c = 1
        else:
            c += 1
    if r > n - c:
        r = n - c

    return r




print(main())



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

#define ff first
#define ss second
#define vi vector<int>
#define fo(n) for(int i = 0;i < int(n);i++)
#define foo(a,b) for(int i = int(a);i <= int(b);i++)
#define mk make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define fastio ios_base:: sync_with_stdio(false)


const int MAXN = 1e6;
const int mod = 1e9 + 7;
const int inf = 1e9;

int nd(int n){
	int d = 0;

	while(n){
		d++;
		n /= 10;
	}

	return d;
}


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

	int cnt = 0;
	for(int i = 1;i <= n;i++){
		if(nd(i)%2 == 1) cnt++;
	}

	cout << cnt << endl;
	return 0;
 }	

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define N 1000005
#define mod 1000000007
using namespace std;
template<typename T>
inline void in(T &x)
{
	x=0;
	char c=getchar();
	bool fu=0;
	while(c<'0'||c>'9'){if(c=='-')fu=1;c=getchar();}
	while(c>='0'&&c<='9')x=(x<<1)+(x<<3)+(c^48),c=getchar();
}
int n,a[N],has[N];
bool not_prime[N],pairwise=1,setwise=1;
void produce(int lim)
{
	not_prime[1]=1;
	for(int i=2;i<=lim;++i)
	{
		if(!not_prime[i])
		{
			bool flag=0;
			int cnt=0;
			if(has[i])cnt+=has[i];
			for(int j=i+i;j<=lim;j+=i)
			{
				not_prime[j]=1;
				if(has[j])
				{
					cnt+=has[j];
				}
			}
			if(cnt>1)pairwise=0;
			if(cnt==n)setwise=0;
		}
	}
}
int main()
{
	in(n);
	bool flag=0;
	for(int i=0;i<n;++i)
	{
		int t;
		in(t);
		++has[t];
	}
	produce(N-1);
	if(flag)setwise=1;
	if(pairwise)puts("pairwise coprime");
	else if(setwise)puts("setwise coprime");
	else puts("not coprime");
	return 0;
}

Measured memory_bytes: 8524
N, K = map(int, input().split())
H = list(map(int, input().split()))

INF = 10**10
lis = [INF]*N
lis[0] = 0
for i in range(1, N):
    H_i = H[i]
    for j in range(max(0, i-K), i):
        lis[i] = min(lis[j] + abs(H[j] - H_i), lis[i])
print(lis[N-1])

Measured memory_bytes: 84612
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String args[])throws Exception
    {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        PrintWriter pw=new PrintWriter(System.out);
        String s=br.readLine();
        int n=Integer.parseInt(s);
        long five=(long)n/500;
        n%=500;
        long t=(long)n/5;
        pw.println(five*1000+t*5);
        pw.flush();
        pw.close();
    }
}

Measured memory_bytes: 21204
#include <iostream>
#include <bits/stdc++.h>
#include <queue>
#include <stack>
#include <vector>
#define loop(n) for(ll i=0;i<n;i++)
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
using namespace std;
typedef long long int ll;

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

int main()
{
    fastio;
    ll n,k;
    cin>>n>>k;
    ll arr[n];
    for(ll i=0;i<n;i++)
		cin>>arr[i];
	
	ll dp[n];
	dp[0] = 0;
	for(ll i = 1;i<n;i++)
	{
		ll mn = INT_MAX;
		for(ll j= max(i-k,0);j < i;j++)
		{
			mn = min(mn,abs(arr[i] - arr[j]) + dp[j]);
		}
		dp[i] = mn;
	}
	cout<<dp[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 5188
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define allR(x) (x).rbegin(), (x).rend()
using ll = long long;
using P = pair<int, int>;
const int INF (1<<30);

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

  vector<int> b(N);
  vector<ll> sum(N+1, 0);

  rep(i, N) {
    cin >> b[i];
    sum[b[i]]++;
  }

  ll ref = 0LL;
  rep(i, N+1) {
    ref += sum[i] * (sum[i]-1) / 2;
  }

  rep(i, N) {
    if (sum[b[i]] == 0) {
      cout << ref << endl;
    }
    else {
      ll ans = ref;
      ll x = sum[b[i]];
      ans -= x * (x-1)/2;
      ans += (x-1) * (x-2) / 2;
      cout << ans << endl;
    }
  }
    

  return 0;
}


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

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

int main()
{
    string s;
    int a,b;
    cin>>a>>b;
    cin>>s;

    bool flag = true;

    int len = a+b+1;
    if(s[a]!='-') flag = false;
    for(int i=0; i<len; i++)
    {
        if(i==a) continue;
        else if(s[i]<'0' || s[i]>'9')
        {
            flag = false;
            break;
        }
    }

    if(flag) puts("Yes");
    else puts("No");

   // main();


    return 0;
}


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

int main(){
  int N, M;
  cin >> N >> M;
  vector<int> X(M);
  vector<int> diff(M-1);
  for(int i=0; i<M; i++) cin >> X.at(i);
  sort(X.begin(), X.end());
  for(int i=0; i<M-1; i++){
    diff.at(i)=X.at(i+1)-X.at(i);
  }
  sort(diff.begin(),diff.end());
  int ans = 0;
  if(N>=M) ans = 0;
  else{
    for(int i=0; i<M-N; i++){
      ans+=diff.at(i);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
import fractions
n,x = map(int,input().split())
a = list(map(int,input().split()))
b = [abs(a[i]-x) for i in range(n)]

if n >= 2:
	ans = fractions.gcd(b[0], b[1])
	for i in range(2, n):
		ans = fractions.gcd(ans, b[i])
	print(ans)
if n == 1:
	print(b[0])

Measured memory_bytes: 16240
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int mod = 1e9 + 7;
const int MAX = 510000;

int main() {
    ll x,t; cin >> x >> t;
    cout << max(x-t,0LL) << endl;
}

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

using namespace std;

int main() {
	vector<int> Array(3);
	cin >> Array[0] >> Array[1] >> Array[2];
	sort(Array.begin(), Array.end());
	int ans = Array[0] + Array[1] + Array[2] * 10;
	cout << ans << endl;
}

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

#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define RFOR(i, a, b) for(int i=(a); i>=(b); i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define CEIL(n, m) ceil(n/pow(10.0, m))*pow(10.0, m)
#define FLOOR(n, m) floor(n/pow(10.0, m))*pow(10.0, m)
#define ROUND(n, m) round(n/pow(10.0, m))*pow(10.0, m)
#define ALL(x) (x).begin(),(x).end()
#define SORT(x) sort((x).begin(),(x).end())
#define RSORT(x) sort((x).begin(),(x).end(),greater<int>())
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define llong long long
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) " (L" << __LINE__ << ") " << __FILE__ << endl;

void solve()
{
  int n;
  cin >> n;
  int a=n;
  int s=0;
  while (a!=0) {
    s+=a%10;
    a/=10;
  }

  if (n%s==0)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }

}

int main()
{
  solve();
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long N = sc.nextLong();
        long A = sc.nextLong();
        long B = sc.nextLong();
        long ans;
        if (A==0 || (A==0 && B==0)) {
            ans = 0;
        } else {
            long M = N/(A+B);
            ans = M*A+Math.min(A, N-M*(A+B));
        }
        System.out.println(ans);
    }
}


Measured memory_bytes: 23636
import sys

f_i = sys.stdin

n = int(f_i.readline())

adj = [[]] * n
for x in f_i:
    x = list(map(int, x.split()))
    adj[x[0]] = [c_v for c_v in zip(x[3::2], x[2::2])]

import heapq

def dijkstra():
    PQ = [(0, 0)]
    isVisited = [False] * n
    distance = [999900001] * n

    distance[0] = 0
    
    while PQ:
        uc, u = heapq.heappop(PQ)

        if uc > distance[u]:
            continue

        isVisited[u] = True
        
        for vc, v in adj[u]:
            if isVisited[v] == False:
                t_cost = distance[u] + vc
                if t_cost < distance[v]:
                    distance[v] = t_cost
                    heapq.heappush(PQ, (t_cost, v))

    for v, d in enumerate(distance):
        print(v, d)


dijkstra()

Measured memory_bytes: 70412
#include<iostream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<string>
#include<cstring>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<bitset>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#define mod 1000000007LL
#define eps 0.0001
#define pi acos(-1)
#define INF 10000000000000000

#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    // ---------------------
    // コーディング開始
    // ---------------------
    int n , m;
    cin >> n >> m ;
    int a[m],b[m];
    int i,j;
    rep(i,m){
        cin >> a[i] >> b[i];
    }
    rep(i,n){
        int ans =0;
        rep(j,m){
            if (a[j]  ==  i+1) ans++;
            if (b[j]  ==  i+1) ans++;
        }
        pri(ans);
    }


    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define rep1(i,n) for(int i=1; i<=(n); ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define sz(v) (int)v.size()
#define pb push_back

using namespace std;
int n,a,b;
int main(){
    cin >> n >> a >> b;
    cout << min(n*a,b) <<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <cmath>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <functional>
#include <cstring>
#include <string>
#include <map>
#include <set>
#include <iostream>
#include <ctime>
#include <complex>

#define enp 	printf("**Entry Point**\n")
#define A		first
#define B		second
#define MP		make_pair

using namespace std;

typedef long long ll;

const int INF = 0x6fffffff;
const int MINF = 0x80000000;
const ll mod = 100003;
const int cons = 100001;
const double pi = 3.141592653589793;



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

	int cnt[26] = { 0 };

	for (int i = 0; i < n; i++)
	{
		string str;
		cin >> str;
		cnt[str[0] - 'A']++;
	}

	int ans = 0;

	while (1)
	{
		sort(cnt, cnt + 26);

		int tmp = k;
		for (int i = 25; i >= 0; i--)
		{
			if (cnt[i] == 0)break;

			cnt[i]--;
			tmp--;
			if (tmp == 0)break;
		}

		if (tmp == 0)ans++;
		else break;
	}

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

	return 0;
}

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

namespace ITP1_8_B
{
    class Program
    {
        static void Main(string[] args)
        {
            string input;
            while(!( (input = Console.ReadLine()) == "0") )
            {
                Console.WriteLine(input.Select(c =>  Convert.ToInt32(c.ToString())).Sum());
            }
        }
    }
}

Measured memory_bytes: 9592
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main(void){
  int n,i;
  vector<int> a,b;
  int s,t;
  long long int tmp,res;
  cin>>n;
  tmp=res=0;
  for(i=0;i<n;i++){
    cin>>s>>t;
    a.push_back(s);
    b.push_back(t);
  }

  for(i=n-1;i>=0;i--){
    if((a[i]+res)%b[i]!=0){
      res+=(b[i]-(a[i]+res)%b[i]);
    }
  }
  cout<<res<<endl;
  return 0;
}

Measured memory_bytes: 1276
n, k, q = gets.strip.split.map(&:to_i)
a = q.times.map { gets.strip.to_i }

scores = (1..n).map{|i| i = 0 }

(1..q).each do |i|
  scores[a[i-1]-1] += 1
end
scores.map{|s|
            if s + ( k - q ) <= 0
              puts 'No'
            else
              puts 'Yes'
            end
          }

Measured memory_bytes: 4984
#include<stdio.h>

int main(void){
    
    int a,b,c;
    
    scanf("%d %d %d",&a,&b,&c);
    
    if(a<b && b<c){
        printf("Yes\n");
    }
    else{
        printf("No\n");
    }
    
    return 0;
}


Measured memory_bytes: 2144
#include <iostream>
using namespace std;
int main(){
	int n;
	while(cin>>n){
		int answer = 0;
		for(int a=0;a<10;a++){
			int m = n-a;
			for(int b=0;b<10;b++){
				int l = m-b;
				for(int c=0;c<10;c++){
					int k = l-c;
					for(int d=0;d<10;d++){
						if(d == k) answer++;
					}
				}
			}
		}
	cout<<answer<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include<bits/stdc++.h>
using namespace std;
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define ll long long int
#define pb push_back
#define fe first
#define se second
#define pii pair<int,int>
#define PI  3.14159265358979323846
const int N=1e5+10;
const int INF=1e9+10;
int a[N];

void solve()
{  int n;
	cin>>n;
	vector<int> dp(n+1,INF);
	for(int i=0;i<n;i++)
		cin>>a[i];
	dp[0]=0;
  for(int i=0;i<n;i++)
    {  int tot=0;
    	for(int j=i+1; ;j++ )
    	 {  tot++;
    	 	if(j<n)
    	 	 { dp[j]=min(dp[j],dp[i]+abs(a[j]-a[i]));
    	 	 }
    	 	 if(tot==2)
    	 	 	break;    	 	 
    	 }
    }
  
  cout<<dp[n-1];

}


int main()
{  cool;
   int t=1;
   while(t--)   
     solve(); 

  return 0; 
}



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

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

using namespace std;

const int MAX_V = 50 *  30;
const int IINF = INT_MAX;

struct Edge { int src,dst; };
vector<Edge> G[MAX_V];
vector<int> computer;
int n,V,mat[61][61];

void dfs(int cur,int prev,int depth,vector<int> &mindist){

  rep(i,computer.size()) {
    if( computer[i] == -1 ) break;
    assert( i < mindist.size() );
    if( cur == computer[i] ) { assert( mindist[i] == IINF); mindist[i] = depth; }
  }

  rep(i,G[cur].size()){
    int next = G[cur][i].dst;
    if( next == prev ) continue;
    dfs(next,cur,depth+1,mindist);
  }

}

void compute(){
  computer.clear();
  computer.resize(n,-1);
  computer[0] = 0;
  V = 1;
  REP(i,1,n) {
    bool update = false; // for debug
    rep(candidate,V) {
      vector<int> mindist(i,IINF);
      dfs(candidate,-1,0,mindist);
      assert( mindist[0] != IINF );
      int add_length = -1;
      rep(j,i){
        int length = mat[i][j] - mindist[j];
        if( length <= 0 ) { add_length = -1; break; }
        if( add_length == -1 ) add_length = length;
        else if( add_length != length ) { add_length = -1; break; }
      }
      if( add_length != -1 ) {
        // add_length ????????????????????????
        // ????????????????????????????????? i ?????????????????\??????
        int prev = candidate;
        rep(k,add_length){
          G[prev].push_back((Edge){prev,V});
          G[V].push_back((Edge){V,prev});
          prev = V;
          ++V;
        }
        computer[i] = V-1;
        update = true;
        break;
      }
    }
    assert( update );
  }
  set<int> S;
  rep(i,n) S.insert(computer[i]);
  vector<int> answer;
  rep(i,V) if( !S.count(i) ) answer.push_back(G[i].size());
  sort(answer.begin(),answer.end());
  rep(i,answer.size()){
    if( i ) printf(" ");
    printf("%d",answer[i]);
  } puts("");
}

int main(){
  while( scanf("%d",&n), n ){
    rep(i,MAX_V) G[i].clear();
    rep(i,n) rep(j,n) scanf("%d",&mat[i][j]);
    compute();
  }
  return 0;
}

Measured memory_bytes: 1308
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

class topological_sort {
private:
	int V;
	vector<vector<int>> edges;
	vector<int> in;
public:
	topological_sort(int n) :V(n), edges(n), in(n) {}
	topological_sort(vector<vector<int>> &edges) :V(edges.size()), in(edges.size()) { this->edges = edges; }

	void add_edge(int from, int to) { edges[from].emplace_back(to); }

	vector<int> build() {

		for (int i = 0; i < V; i++) for (const auto &e : edges[i]) in[e]++;
		vector<int> used(V), res;
		res.reserve(V);

		queue<int> que;
		for (int i = 0; i < V; i++) {
			if (in[i] == 0 && !used[i]) {
				used[i] = 1;
				que.emplace(i);
			}
		}

		while (!que.empty()) {
			int now = que.front();
			DMP(now, in);
			que.pop();
			res.emplace_back(now);
			for (const auto &e : edges[now]) {
				in[e]--;
				if (in[e] == 0) {
					if (used[e]) return vector<int>(); // unable to sort
					used[e] = 1;
					que.emplace(e);
				}
			}
		}

		return res;
	}

};

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	auto id = [&](int l, int r) { return min(l, r)*N + max(l, r); };

	auto rid = [&](int id) {
		int row = id / N, col = id % N;
		if (row >= col) return make_pair(-1, -1);
		else return make_pair(row, col);
	};

	topological_sort ts(N * N);
	for (int i = 0; i < N; i++) {
		vector<int> A(N - 1);
		for (int j = 0; j < N - 1; j++) cin >> A[j];
		for (int j = 0; j < N - 2; j++) ts.add_edge(id(i, A[j] - 1), id(i, A[j + 1] - 1));
	}

	auto ord = ts.build();
	DMP(ord);

	if (ord.size() != N * N) cout << -1 << "\n";
	else {

		vector<int> used(N);
		int ans = 1;
		for (int i = 0; i < N*N; i++) {
			int row, col;
			tie(row, col) = rid(ord[i]);

			if (row == -1) continue;

			if (used[row] || used[col]) {
				ans++;
				fill(used.begin(), used.end(), 0);
			}

			used[row] = 1;
			used[col] = 1;

		}

		cout << ans << "\n";

	}

	return 0;
}


Measured memory_bytes: 53032
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> bool cmax(T& a, U b) { if (a<b) {a = b; return true;} else return false; }
template<class T, class U> bool cmin(T& a, U b) { if (a>b) {a = b; return true;} else return false; }

vector<bool> f(int n) {
  vector<bool> res(10);
  while (n > 0) {
    res[n%10] = true;
    n /= 10;
  }
  return res;
}

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

  ll n, k;
  cin >> n >> k;
  vl d(k);
  rep(i, k) {
    cin >> d[i];
  }

  for (;;n++) {
    auto vec = f(n);
    bool f = false;
    rep(i, k) {
      if (vec[d[i]]) f = true;
    }
    if (f) continue;
    cout << n << endl;
    return 0;
  }
}


Measured memory_bytes: 256
#include <iostream>

int main()
{
    std::string A, B, C;
    std::cin >> A >> B >> C;

    if (A.back() == *B.begin() && B.back() == *C.begin()) {
        std::cout << "YES" << std::endl;
    } else {
        std::cout << "NO" << std::endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <b; i++)
typedef long long ll;
#define int ll
typedef vector<int> vi;
typedef vector<long long> vl;
typedef pair<int,int> pi;
#define trace(x) cout<<#x<<"="<<x<<"\n";
#define sz(x) (int)(x.size())
#define mod 1000000007

template < typename F, typename S >
ostream& operator << ( ostream& os, const pair< F, S > & p ) {
    return os << "(" << p.first << ", " << p.second << ")";
}

template < typename T >
ostream &operator << ( ostream & os, const vector< T > &v ) {
    os << "{";
    typename vector< T > :: const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "}";
}

template < typename T >
ostream &operator << ( ostream & os, const set< T > &v ) {
    os << "[";
    typename set< T > :: const_iterator it;
    for ( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << *it;
    }
    return os << "]";
}

template < typename F, typename S >
ostream &operator << ( ostream & os, const map< F, S > &v ) {
    os << "[";
    typename map< F , S >::const_iterator it;
    for( it = v.begin(); it != v.end(); it++ ) {
        if( it != v.begin() ) os << ", ";
        os << it -> first << " = " << it -> second ;
    }
    return os << "]";
}

#define deb(x) cerr << #x << " = " << x << endl;



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

    int a, b, c;
    cin>>a>>b>>c;
    // int ans=min(a,c);
    // cout<<ans<<"\n";
    int ans=max(0LL,c-(a-b) );
    cout<<ans<<"\n";


    return 0;
}

Measured memory_bytes: 256
def main():
    from collections import Counter

    N = int(input())
    a = map(int, input().split())

    a = map(lambda x: min(8, x // 400), a)

    ctr = Counter(a)

    len_ = len(ctr.keys())
    free = ctr[8]
    if free:
        ma = len_ - 1 + free
        mi = max(1, len_ - 1)
        ans = mi, ma
    else:
        ans = len_, len_
    print(*ans)


if __name__ == '__main__':
    main()

# import sys
# input = sys.stdin.readline
# 
# sys.setrecursionlimit(10 ** 7)
# 
# (int(x)-1 for x in input().split())
# rstrip()
#
# def binary_search(*, ok, ng, func):
#     while abs(ok - ng) > 1:
#         mid = (ok + ng) // 2
#         if func(mid):
#             ok = mid
#         else:
#             ng = mid
#     return ok


Measured memory_bytes: 3316
c =0
while True:
    W = input()
    if W==0: break
    dt = [0]*1001
    c +=1
    N = input()
    m = 0
    n = 0
    for i in range(N):
        p,w = input()
        for w0 in range(W+1)[::-1]:
            p0 = dt[w0]
            if w0==0 or p0!=0:
                w1 = w0+w
                p1 = p0+p
                if w1<=W and dt[w1]<p1: dt[w1]=p1
    m = max(dt)
    n = dt.index(m)
    print "Case {}:".format(c)
    print m
    print n

Measured memory_bytes: 4332
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Volume0006
{
    class Program
    {
        static void Main(string[] args)
        {
            char[] str = Console.ReadLine().ToCharArray();
            Array.Reverse(str);
            string Answer = new string(str);
            Console.WriteLine(Answer);
        }
    }
}



Measured memory_bytes: 17824
using System;

namespace Therefore
{
    class Program
    {
        static void Main(string[] args)
        {
            string cheskDT=Console.ReadLine();

            string LastChar = cheskDT.Substring(cheskDT.Length-1,1);

            string callChar;
            callChar = "";

            switch (LastChar)
            {
                case "0":
                case "1":
                case "6":
                case "8":
                    callChar = "pon";
                    break;
                case "2":
                case "4":
                case "5":
                case "7":
                case "9":
                    callChar = "hon";
                    break;
                case "3":
                    callChar = "bon";
                    break;
            }
            Console.WriteLine(callChar);
        }
    }
}


Measured memory_bytes: 25788
#include <stdio.h>
#include <string>
#include <cstring>
#include <stdlib.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <iterator>
#pragma warning(disable:4996)
 
typedef long long ll;
#define MIN(a, b) ((a)>(b)? (b): (a))
#define MAX(a, b) ((a)<(b)? (b): (a))
#define LINF 9223372036854775807
#define INF 2147483647
#define MOD 1000000007
using namespace std;

ll comb(long n, long k)
{
    ll curr=1;
    long i;
    for(i=0; i<k; i++) {
        curr = curr * (n-i) / (1+i);
    }
    return curr;
}

int main(int argc, char* argv[])
{
    char str0[2]={0};
    char str1[2]={0};
    scanf("%s", str0);
    scanf("%s", str1);
    if( str0[0]==str1[0]) {
        printf("H\n");
    }
    else {
        printf("D\n");
    }

    return 0;
}



Measured memory_bytes: 128
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1e9 + 7;

int main() {
  string s;
  cin >> s;
  int a = (s[0] - '0') * 10 + s[1] - '0';
  int b = (s[2] - '0') * 10 + s[3] - '0';
  string ans;
  if (0 < a && a <= 12 && 0 < b && b <= 12)
    ans = "AMBIGUOUS";
  else if (0 < a && a <= 12)
    ans = "MMYY";
  else if (0 < b && b <= 12)
    ans = "YYMM";
  else
    ans = "NA";
  cout << ans << endl;
}

Measured memory_bytes: 256
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

int n,k;
string s;

int main()
{
	cin>>n>>k>>s;
	s[k-1]+='a'-'A';
	cout<<s<<endl;
	rt0;
}

Measured memory_bytes: 256
n = int(input())
abc = [list(map(int,input().split())) for _ in range(n)]

dp = [[0,0,0] for _ in range(n)]
dp[0] = [abc[0][0],abc[0][1],abc[0][2]]

for i in range(n-1):
    dp[i+1][0] = abc[i+1][0]+max(dp[i][1],dp[i][2])
    dp[i+1][1] = abc[i+1][1]+max(dp[i][2],dp[i][0])
    dp[i+1][2] = abc[i+1][2]+max(dp[i][0],dp[i][1])

print(max(dp[n-1]))

Measured memory_bytes: 50192
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <cstring>
#include <map>
#include <math.h>
#include <queue>
#include <set>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> P;
#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1<<30;
const ll LINF = 1LL<<58;
const int mod = 1000000007;

int main(){
	int n, m;
	cin >> n >> m;
	int l = -INF, r = INF;
	rep(i,m){
		int x, y;
		cin >> x >> y;
		chmax(l, x); chmin(r, y);
	}
	cout << max(0, r-l+1) << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>//class string???????????????
using namespace std;

int main(){
	string str,str1,str2;
	int m,h;
	
	while(1){
	cin >> str;
	if(str=="-")break;
	cin >> m;
	for(int i=0;i<m;i++){
		cin >> h;
		str1=str.substr(0,h);
		str2=str.substr(h,str.size()-h);
		str=str2+str1;
	}
	cout << str <<endl;
	}
	return 0;
}

Measured memory_bytes: 3180
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef unsigned long long ull;
typedef long double ld; 
typedef tree<ii, null_type, less<ii>, rb_tree_tag, tree_order_statistics_node_update> pbds;

vector<int> fact;
vector<int> ifact;
vector<int> inv;
vector<int> pow2;
const int MOD = (1e9 + 7);
int add(int a, int b)
{
	a+=b;
	while(a>=MOD) a-=MOD;
	return a;
}
int mult(int a, int b)
{
	return (a*1LL*b)%MOD;
}
int modpow(int a, int b)
{
	int r=1;
	while(b)
	{
		if(b&1) r=mult(r,a);
		a=mult(a,a);
		b>>=1;
	}
	return r;
}
	
int a[111];
int dp[111][111111];
int S[111][111111];

int sum(int i, int l, int r)
{
	l=max(l,0);
	if(l>r) return 0;
	if(l==0) return S[i][r];
	else return add(S[i][r],MOD-S[i][l-1]);
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	int n,k; cin>>n>>k;
	for(int i=1;i<=n;i++) cin>>a[i];
	dp[0][0]=1;
	for(int i=0;i<=k;i++) S[0][i]=1;
	for(int i=1;i<=n;i++)
	{
		for(int j=0;j<=k;j++)
		{
			dp[i][j]=sum(i-1,j-a[i],j);
		}
		for(int j=0;j<=k;j++)
		{
			S[i][j]=dp[i][j];
			if(j>0) S[i][j]=add(S[i][j],S[i][j-1]);
		}
	}
	cout<<dp[n][k]<<'\n';
}


Measured memory_bytes: 90240
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define per(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define INF 2e9
#define LINF 1e18
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;

int main() {
    int a, b; cin >> a >> b;
    if (a > b) cout << 2*a-1 << endl;
    else if (a == b) cout << 2*a << endl;
    else cout << 2*b-1 << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
	int x;
	
	public void solve(){
		Scanner sc = new Scanner(System.in);
		x=sc.nextInt();
		x=x*x*x;
		System.out.println(x);
	}
	public static void main(String[] args){
		Main obj = new Main();
		obj.solve();
	}
}

Measured memory_bytes: 17348
import math

n, k = map(int, input().split(" "))
li = list(map(int, input().split(" ")))

fk = k
crnt = 1
st = set()
wl = []
key = crnt
cy = 0
mg = 0

for i in range(n):
    if crnt in st:
        key = crnt
        cy = i - wl.index(crnt)
        mg = wl.index(crnt)
        break
    st.add(crnt)
    wl.append(crnt)
    crnt = li[crnt - 1]

k -= mg
if cy != 0:
    k %= cy
crnt = key
if n > fk:
    k = fk
    crnt = 1
for i in range(k):
    crnt = li[crnt - 1]

print(crnt)


Measured memory_bytes: 130796
#include <iostream>

using namespace std;

int main(){
  string name[4] = {"M","T","S","H"};
  int start[4] = {1868, 1912, 1926, 1989};
  int end[4] = {1911, 1925, 1988, 2016};
  int e,y;cin>>e>>y;
  if(e==0){
    for(int i=0;i<4;i++){
      if(y>=start[i] && y<=end[i]){
        cout<<name[i]<<y-start[i]+1<<endl;
      }
    }
  }else{
    cout<<y+start[e-1]-1<<endl;
  }
}


Measured memory_bytes: 3152
N,M=map(int,input().split())
KA=[[] for _ in range(N)]
hist=[0]*M

for i in range(N):
    KA[i]=list(map(int,input().split()))
    for j in range(KA[i][0]):
        hist[KA[i][j+1]-1]+=1
        
ans=0
for i in range(M):
    if hist[i]==N:
        ans+=1
print(ans)

Measured memory_bytes: 38384
#include"bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main(){
	int64_t A, B, K;
	cin >> A >> B >> K;
	if (A < K) B -= K - A;
	if (B < 0) B = 0;
	A -= K;
	if (A < 0) A = 0;
	cout << A << " " << B << endl;
	return 0;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <algorithm>
#include<cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include<iostream>
#include<list>
#include<queue>
#include<set>
#include<string>
#include <vector>

#define ll long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define FORL(i,a,b) for(ll i=(a);i<(b);++i)
#define REPL(i,n) FORL(i,0,n)
#define FORR(i,a,b) for(int i=(a);i>=(b);--i)
#define REPR(i,n)   RFOR(i,n,0)

using namespace std;

int main(){
	ll A, B, C, K, ans, tmp;
	scanf("%lld %lld %lld", &A, &B, &C);
	scanf("%lld", &K);

	if (A >= B){
		tmp = A;
	}
	else{
		tmp = B;
	}
	if (tmp < C){
		tmp = C;
	}
	if (tmp == A){
		ans = B + C + tmp*pow(2, K);
	}
	else if (tmp == B){
		ans = A + C + tmp* pow(2, K);
	}
	else{
		ans = A + B + tmp*pow(2, K);
	}
	printf("%lld\n", ans);

	return 0;
}

Measured memory_bytes: 256
import math

a, b, h, m = map(int, input().split())

h = h * 30 + (m/2)

m = m * 6

if h < m:
    x = m - h
elif m < h:
    x = h - m
else:
    x = 0

if x == 0:
    if a > b:
        print(a-b)
    elif b > a:
        print(b-a)
    else:
        print(0)
elif x == 180:
    print(a+b)
else:
    cosx = math.cos(math.radians(x))
    ans = math.sqrt(a**2 + b**2 - (2 * a * b * cosx))
    print(ans)


Measured memory_bytes: 62436
#include<bits/stdc++.h>
using namespace std;
int n,m,l,k,s,t,d[100][100];

void ch(){
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
      for(int k=0;k<n;k++)d[j][k]=min(d[j][k],d[j][i]+d[i][k]); 
}

int main(){
  while(cin>>n>>m>>l>>k>>s>>t,n){
    vector<int> v;
    for(int i=0;i<n;i++)
      for(int j=0;j<n;j++)d[i][j]=(i==j?0:1e9);
    bool e[100]={};
    e[s]=e[t]=1;
    for(int i=0,x;i<l;i++)cin>>x,e[x]=1;
    for(int i=0,x,y,c;i<k;i++)cin>>x>>y>>c,d[x][y]=c,d[y][x]=c;
    ch();
    for(int i=0;i<n;i++)
      for(int j=0;j<n;j++)
	if(!e[i]||!e[j]||d[i][j]>m)d[i][j]=1e9;
    ch();
    if(d[s][t]==1e9)cout<<"Help!"<<endl;
    else if(d[s][t]<m)cout<<d[s][t]<<endl;
    else cout<<d[s][t]*2-m<<endl;
  }
  return 0;
}


Measured memory_bytes: 3080
#pragma GCC optimize("O3")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("-Ofast")
#include <bits/stdc++.h>
using namespace std;

typedef int in;
#define int long long
#define pb push_back
#define f first
#define s second
#define double long double
const int MAX=2e5+10;
const int MAX2=2e5+4;
const int MAAX=2e18;
const int MOD=1e9+7;
int n;
int dp[MAX][4];
int a[MAX],b[MAX],c[MAX];
int fun(int idx,int last)
{
    if(idx==n)
    {
        return 0;
    }
    int &ret=dp[idx][last];
    if(ret!=-1)
    {
        return ret;
    }
    if(!last)
    {
        ret=max(ret,a[idx]+fun(idx+1,1));
         ret=max(ret,b[idx]+fun(idx+1,2));
          ret=max(ret,c[idx]+fun(idx+1,3));
    }
    if(last==1)
    {
         ret=max(ret,b[idx]+fun(idx+1,2));
          ret=max(ret,c[idx]+fun(idx+1,3));

    }
    if(last==2)
    {
         ret=max(ret,a[idx]+fun(idx+1,1));
          ret=max(ret,c[idx]+fun(idx+1,3));
    }
    if(last==3)
    {
         ret=max(ret,a[idx]+fun(idx+1,1));
          ret=max(ret,b[idx]+fun(idx+1,2));
    }
    return ret;
}
in main()
{
    memset(dp,-1,sizeof dp);
cin>>n;
for(int i=0;i<n;i++)
{
    cin>>a[i]>>b[i]>>c[i];
}
cout<<fun(0,0)<<endl;
    return 0;
}


Measured memory_bytes: 15104
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = (int)(n - 1); i >= 0; i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) int(x.size())
#define get_unique(x) x.erase(unique(all(x)), x.end());
typedef long long ll;
typedef complex<double> Complex;
const int INF = 1e9;
const ll MOD = 1e9 + 7;
const ll LINF = 1e18;
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (int i = 0; i < sz(v); i++) {
        os << v[i];
        if (i < sz(v) - 1) os << " ";
    }
    return os;
}
int main() {
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int a = h1 * 60 + m1;
    int b = h2 * 60 + m2;
    cout << b - a - k << endl;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
using namespace std;
#define int long long
#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,n) for(int i=0;i<=n;i++)
#define repr(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define P pair<long long,long long>
#define double long double
#define vector2(a,b,c) vector<vector<int>> a(b/*縦！w*/,vector<int>(c/*横！w*/))
#define INF 1e10
#define MOD 1e9+7
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; }
using Graph = vector<vector<int>>;
signed main(){
  int a,b,c;
  cin>>a>>b>>c;
  if(a+b>=c)
    cout<<"Yes";
  else
    cout<<"No";
}

Measured memory_bytes: 256