akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;
using ll = long long int;

int main() {
    int l[] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K;
    cin >> K;
    cout << l[K-1];
    return 0;
}

Measured memory_bytes: 256
def lcs(X, Y):
    C = []
    for y in Y:
        bgn_idx = 0
        for i, cur_idx in enumerate(C):
            chr_idx = X.find(y, bgn_idx) + 1
            if chr_idx == 0:
                break
            C[i] = min(cur_idx, chr_idx)
            bgn_idx = cur_idx
        chr_idx = X.find(y, bgn_idx) + 1
        if chr_idx != 0:
            C.append(chr_idx)
    return len(C)

q = int(input())
for _ in range(q):
    X = input()
    Y = input()
    print(lcs(X, Y))


Measured memory_bytes: 5612
a = list(map(int, input().split()))

a.sort()

sum = 0
sum += (a[2] - a[0]) // 2
sum += (a[2] - a[1]) // 2

if (a[2] - a[0]) % 2 == 0 and (a[2] - a[1]) % 2 == 0:
  print(sum)
elif (a[2] - a[0]) % 2 == 1 and (a[2] - a[1]) % 2 == 1:
  print(sum+1)
else:
  print(sum+2)


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

const ll mod=(ll)1e9+7;

int main() {
  int n;
  ll k, ans=0;
  scanf("%d%lld", &n, &k);
  vector<int> a(n);
  rep(i, n) scanf("%d", &a[i]);
  rep(i, n) {
    rep(j, n) {
      if (a[i]<=a[j]) continue;
      ans+=k*(k-1)/2;
      if (i<j) ans+=k;
      ans%=mod;
    }
  }
  printf("%lld\n", ans); 
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
#if DEBUG
    #include "debug.h"
#else
    #define debug(args...)
#endif    

using namespace std;

#define int long long

typedef vector<int> vi;
typedef pair<int,int> ii;


#define M 1000000 
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define sz(x) (int)x.size()
#define fill(a,x) memset(a,x,sizeof(a))
#define F first
#define S second
#define FOR(i,a,b) for(int i = a; i<=b; ++i)
#define NFOR(i,a,b) for(int i = a; i>=b; --i)
#define fast ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0)
const int INF = 1e18;
const int mod = 1e9+7;
const int N = 2e5 + 10;
inline int add(int x,int y){
  x += y;
  if(x >= mod) x -= mod;
  return x;
}
inline int mul(int x,int y){
  x = (1LL * x * y) % mod;
  return x;
}
// mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());



int32_t main(){
  fast;

  int n;
  cin >> n;
  vector<int>a(n),b(n),c(n);
  FOR(i,0,n-1)cin>>a[i],a[i]--;
  FOR(i,0,n-1)cin >> b[i];
  FOR(i,0,n-2)cin >> c[i];

  int ans = 0;
  FOR(i,0,n-1) {
    ans += b[a[i]];
    if(i != 0 and a[i] == a[i-1] + 1)
      ans+=c[a[i-1]];
  } 
  cout << ans;
  

  return 0;
}

Measured memory_bytes: 256
h,w=map(int,input().split())
c=[list(map(int,input().split())) for _ in range(10)]
a=[list(map(int,input().split())) for _ in range(h)]


def warshall_floyd(d):
    #d[i][j]: iからjへの最短距離
    for k in range(n):
        for i in range(n):
            for j in range(n):
                d[i][j] = min(d[i][j],d[i][k] + d[k][j])
    return d

n=10
warshall_floyd(c)


ans=0
for i in range(h):
    for j in range(w):
        if a[i][j]==-1:
            continue
        else:
            ans+=c[a[i][j]][1]
print(ans)


Measured memory_bytes: 40796
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem C


def dfs(x: int):
    global visited, graph

    if visited[x]:
        return

    visited[x] = True

    for i in range(n):
        if graph[x][i]:
            dfs(i)


if __name__ == '__main__':
    n, m = list(map(int, input().split()))
    a = [0 for _ in range(m)]
    b = [0 for _ in range(m)]
    graph = [[0 for i in range(n)] for j in range(n)]

    # See:
    # https://img.atcoder.jp/abc075/editorial.pdf
    # https://www.youtube.com/watch?v=VJntQuR2zNI
    for i in range(m):
        line = list(map(int, input().split()))
        a[i] = line[0] - 1
        b[i] = line[1] - 1
        graph[a[i]][b[i]] = True
        graph[b[i]][a[i]] = True

    bridge_count = 0

    for j in range(m):
        graph[a[j]][b[j]] = False
        graph[b[j]][a[j]] = False

        visited = [False] * len(graph[0])
        dfs(0)

        if False in visited:
            bridge_count += 1

        graph[a[j]][b[j]] = True
        graph[b[j]][a[j]] = True

    print(bridge_count)


Measured memory_bytes: 3064
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n)-1; i >= 0; i--)
using namespace std;
using lli = long long int;
lli n;
lli a[1000005];

bool ok(lli k)
{
    lli size = a[k];
    rep(i, n)
    {
        if (i == k)
            continue;
        if (size * 2 < a[i]) {
            return false;
        } else {
            size += a[i];
        }
    }
    return true;
}
int main()
{
    cin >> n;
    rep(i, n) cin >> a[i];
    sort(a, a + n);
    lli low = -1;
    lli up = 2 * n;
    while (up - low > 1) {
        lli mid = (low + up) / 2;
        if (ok(mid)) {
            up = mid;
        } else {
            low = mid;
        }
    }
    cout << n - low - 1 << endl;
}


Measured memory_bytes: 1024
#include <stdio.h>
int main(void)
{
	int m,j,b,s;
	scanf("%d %d %d",&m,&j,&b);
	if(m>=b){
		printf("0\n");
	}
	if(m<=b){
		s=b-m;
		m=m+j;
		if(m>=b){
			printf("%d\n",s);
		}
		if(m<b){
			printf("NA\n");
		}
	}
	return 0;
}


Measured memory_bytes: 2112
/* created   : 2019-10-27 23:07:58
 * accepted  : 2019-10-27 23:09:07
 * author    : landcold7
 */
#include <bits/stdc++.h>
using namespace std;
#define x first
#define y second
#define mt make_tuple
#ifndef LOCAL
#define trace(...)
#endif
typedef long long ll;

void solve() {
  int a, b; cin >> a >> b;
  if (1 <= a && a <= 9 && 1 <= b && b <= 9) {
    cout << a * b << '\n';
  }
  else {
    cout << -1 << '\n';
  }
}

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


Measured memory_bytes: 256
//Tue Dec 22 22:01:34 JST 2009
#include<set>
#include<iostream>
#include<queue>
#include<algorithm>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define mp make_pair
int dx[]={0,1,1,0,-1,-1};
int dy[]={-1,-1,0,1,1,0};
#define CONNECT true
#define UNCONNECT false
#define CANMOVE true
#define CANNOTMOVE false

class state{
public:
  int len;
  int x[8],y[8];
  int cnt;
  bool is_connected(int,int);
  bool can_good_pos(int);
  void make_next(int,queue<state>&,set<state>&,bool,set<pair<int,int> > &);
  
  bool operator<(const state & a)const{
    rep(i,len){
      if ( x[i]!=a.x[i])return x[i]<a.x[i];
      if ( y[i]!=a.y[i])return y[i]<a.y[i];
    }
    return false;
  }
  
};

bool state::is_connected(int me,int you){
  if ( x[me]==x[you]){
    if ( y[me]-1 == y[you] || y[me]+1 == y[you] || y[me]==y[you])return CONNECT;
  }else if ( x[me]+1 == x[you]){
    if (y[me] ==y[you] || y[me]-1==y[you])return CONNECT;
  }else if ( x[me]-1==x[you]){
    if (y[me] ==y[you] || y[me]+1 == y[you])return CONNECT;
  }
  
  return UNCONNECT;
}

bool state::can_good_pos(int cur){
  rep(i,cur-1){
    if ( is_connected(cur,i)==CONNECT)return false;//©ªÌOÈOÌâÂÆÂÈªÁÄ¢éÌÅ¾ßB
  }
  if (cur==0 ||  is_connected(cur,cur-1)==CONNECT)return true;//©ªÆOÌâÂÆÂÈªÁÄ¢éÌÅ¨
  return false;
}

  
void state::make_next(int now,queue<state>&Q,set<state>&S,bool flag,set<pair<int,int> > & NG){
  if ( now == len){
    if ( S.find((*this))==S.end()){
      cnt++;
      S.insert(*this);
      Q.push(*this);
      cnt--;
    }
    return;
  }
  
  //don't move
  
  if (can_good_pos(now) ){
    make_next(now+1,Q,S,CANMOVE,NG);
  }
  
  if ( flag == CANNOTMOVE)return;//OÌª®¢Ä½ç©ªÍ®¯È¢
  
  rep(i,6){
    x[now]+=dx[i];
    y[now]+=dy[i];
    
    
    if (NG.find(mp(x[now],y[now])) == NG.end() && can_good_pos(now)){
      make_next(now+1,Q,S,CANNOTMOVE,NG);//©ªª®¢½çÌÍ®¯È¢B
    }
    x[now]-=dx[i];
    y[now]-=dy[i];
  }
  
}




int bfs(state ini,int dx,int dy,set<pair<int,int> > &NG){
  queue<state> Q;
  set<state> S;
  Q.push(ini);
  S.insert(ini);
  while(!Q.empty()){
    state now = Q.front();
    Q.pop();
    if ( (max(now.x[0],dx)-min(now.x[0],dx)+max(now.y[0],dy)-min(now.y[0],dy))/2+now.cnt>20)continue;
    if ( now.x[0]==dx && now.y[0]==dy){
      return now.cnt;
    }
    now.make_next(0,Q,S,CANMOVE,NG);
  }
  return -1;
}


main(){
  int n,m,dx,dy;
  while(cin>>n && n){
    state ini;
    set<pair<int,int> > NG;
    
    ini.len=n;
    ini.cnt=0;
    rep(i,n)cin>>ini.x[i]>>ini.y[i];
    cin>>m;
    rep(i,m){
      int f,s;
      cin>>f>>s;
      NG.insert(mp(f,s));
    }
    cin>>dx>>dy;
    cout << bfs(ini,dx,dy,NG)<<endl;
  }
  return false;
}

Measured memory_bytes: 13000
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
int n,K;
int X1[55],X2[55],Y1[55],Y2[55],D1[55],D2[55];
int sx1[55],sx2[55],sy1[55],sy2[55],sd1[55],sd2[55];
vector<int> xs,ys,ds;
int m[111][111][111];
int main(void){
  cin >> n >> K;
  for(int i = 0; i < n; i++){
    cin >> X1[i] >> Y1[i] >> D1[i] >> X2[i] >> Y2[i] >> D2[i];
    xs.push_back(X1[i]);
    xs.push_back(X2[i]);
    ys.push_back(Y1[i]);
    ys.push_back(Y2[i]);
    ds.push_back(D1[i]);
    ds.push_back(D2[i]);
  }

  sort(xs.begin(),xs.end());
  sort(ys.begin(),ys.end());
  sort(ds.begin(),ds.end());

  xs.erase(unique(xs.begin(),xs.end()),xs.end());
  ys.erase(unique(ys.begin(),ys.end()),ys.end());
  ds.erase(unique(ds.begin(),ds.end()),ds.end());

  for(int i = 0; i < n; i++){
    sx1[i] = find(xs.begin(),xs.end(),X1[i]) - xs.begin();
    sx2[i] = find(xs.begin(),xs.end(),X2[i]) - xs.begin();
    sy1[i] = find(ys.begin(),ys.end(),Y1[i]) - ys.begin();
    sy2[i] = find(ys.begin(),ys.end(),Y2[i]) - ys.begin();
    sd1[i] = find(ds.begin(),ds.end(),D1[i]) - ds.begin();
    sd2[i] = find(ds.begin(),ds.end(),D2[i]) - ds.begin();

    m[sx1[i]][sy1[i]][sd1[i]]++; m[sx2[i]][sy2[i]][sd1[i]]++; m[sx1[i]][sy2[i]][sd2[i]]++; m[sx2[i]][sy1[i]][sd2[i]]++;
    m[sx1[i]][sy2[i]][sd1[i]]--; m[sx2[i]][sy1[i]][sd1[i]]--; m[sx1[i]][sy1[i]][sd2[i]]--; m[sx2[i]][sy2[i]][sd2[i]]--;
  }

  for(int i = 0; i <= 105; i++){
    for(int j = 0; j <= 105; j++){
      for(int k = 0; k <= 105; k++){
	m[i+1][j][k] += m[i][j][k];
      }
    }
  }  
  for(int i = 0; i <= 105; i++){
    for(int j = 0; j <= 105; j++){
      for(int k = 0; k <= 105; k++){
	m[i][j+1][k] += m[i][j][k];
      }
    }
  }
  for(int i = 0; i <= 105; i++){
    for(int j = 0; j <= 105; j++){
      for(int k = 0; k <= 105; k++){
	m[i][j][k+1] += m[i][j][k];
      }
    }
  }

  long long int res = 0;
  for(int i = 0; i <= 105; i++){
    for(int j = 0; j <= 105; j++){
      for(int k = 0; k <= 105; k++){
	if(m[i][j][k] < K) continue;
	res += (long long int)(xs[i+1]-xs[i]) * (ys[j+1]-ys[j]) * (ds[k+1]-ds[k]);
      }
    }
  }
  cout << res << endl;
}

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

#define rep(i, N) for(int i = 0;i < N;i++)
typedef long long ll;
const int mod = 1e9 + 7;

using namespace std;

int main(void) {
	int H, W; cin >> H >> W;
	vector<vector<char>> field(H+2, vector<char>(W+2));

	rep(i, H) {
		rep(j, W) {
			cin >> field[i + 1][j + 1];
		}
	}

	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			if (field[i][j] != '.')continue;
			int cnt = 0;
			for (int k = -1; k <= 1; k++)for (int l = -1; l <= 1; l++)if (field[i + k][j + l] == '#')cnt++;
			field[i][j] = '0' + cnt;
		}
	}

	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			cout << field[i][j];
		}
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 256
argN = int(input())
aryS = list(input())

cnt = aryS.count(".") 
ans = cnt
for i in range(argN):
  if aryS[i] == ".":
    cnt -= 1
  elif aryS[i] == "#":
    cnt += 1

  if ans > cnt:
    ans = cnt

print(ans)

Measured memory_bytes: 4840
N,M = map(int,input().split())
AB = [list(map(int,input().split())) for _ in range(N)]

AB.sort()
count = 0
ans = 0
for i,j in AB:
  if count+j >= M:
    ans += (M-count)*i
    break
  else:
    count += j
    ans += j*i
print(ans)



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

namespace TInfo
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] str = Console.ReadLine().Split(' ');
            int c11 = int.Parse(str[0]);
            int c12 = int.Parse(str[1]);
            int c13 = int.Parse(str[2]);

            str = Console.ReadLine().Split(' ');
            int c21 = int.Parse(str[0]);
            int c22 = int.Parse(str[1]);
            int c23 = int.Parse(str[2]);

            str = Console.ReadLine().Split(' ');
            int c31 = int.Parse(str[0]);
            int c32 = int.Parse(str[1]);
            int c33 = int.Parse(str[2]);

            int c1 = c22 - c21 - c12 + c11;
            int c2 = c32 - c31 - c12 + c11;
            int c3 = c23 - c21 - c13 + c11;
            int c4 = c33 - c31 - c13 + c11;

            if (c1 == 0 && c2 == 0 && c3 == 0 && c4 == 0)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}

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

int search(int a[], int key, int n) {
	for (int i = 0; i < n; i++)
		if (a[i] == key) return 1;
	return 0;
}

int identify(int m[], int p[][100], int l[], int a, int b) {
	int isCrim[a] = {0};
	int count = 0, flag = 0;
	for (int i = 0; i < a; i++) {
		for (int j = 0; j < b; j++) {
			if (!search(p[i], l[j], m[i])) {
				flag = 1;
				break;
			}
		}
		if (!flag) {
			isCrim[i] = 1;
			count++;
		}
		flag = 0;
	}
	if (count != 1) return -1;
	for (int i = 0; i < a; i++)
		if (isCrim[i]) return i + 1;
}

int main() {
	while (true) {
		int n;
		cin >> n;
		if (n == 0) break;
		
		int m[n], p[n][100];
		for (int i = 0; i < n; i++)
			for (int j = 0; j < 100; j++)
				p[i][j] = 0;
			
		for (int i = 0; i < n; i++) {
			cin >> m[i];
			for (int j = 0; j < m[i]; j++)
				cin >> p[i][j];
		}
		
		int k;
		cin >> k;
		int l[k];
		for (int i = 0; i < k; i++)
			cin >> l[i];
		
		int crim = identify(m, p, l, n, k);
		cout << crim << endl;
	}
	return 0;
}

Measured memory_bytes: 3148
#include<bits/stdc++.h>
#define rep(i, n) for (int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
 
int main(void){
    int n;
    cin>>n;
    vector<ll> v(n);
    rep(i, n) cin>>v[i];
    sort(v.begin(), v.end());
    /*小さい奴を真ん中にする場合*/
    deque<ll>que1;
    rep(i, n) que1.push_back(v[i]);
    ll ans1 = 0;
    ll left = que1.front();
    ll right = left;
    que1.pop_front();
    int idx = 0;
    while(!que1.empty()){
        if(que1.size()==1){
            ll a = que1.front();
            ans1 += max(abs(left-a), abs(right-a));
            que1.pop_front();
        }
        else {
            ll a, b;
            if(idx%2){
                a = que1.front();
                que1.pop_front();
                b = que1.front();
                que1.pop_front();
            }
            else{
                a = que1.back();
                que1.pop_back();
                b = que1.back();
                que1.pop_back();
            }
            ll c = abs(a-left)+abs(b-right);
            ll d = abs(a-right)+abs(b-left);
            if(c>d){
                left=a;
                right=b;
                ans1 += c;
            }
            else {
                left=b;
                right=a;
                ans1 += d;
            }
        }
        idx++;
    }
    deque<ll>que2;
    rep(i, n) que2.push_back(v[i]);
    ll ans2 = 0;
    ll left2 = que2.back();
    ll right2 = left2;
    que2.pop_back();
    int idx2 = 0;
    while(!que2.empty()){
        if(que2.size()==1){
            ll a = que2.front();
            ans2 += max(abs(left2-a), abs(right2-a));
            que2.pop_front();
        }
        else {
            ll a, b;
            if(idx2%2==0){
                a = que2.front();
                que2.pop_front();
                b = que2.front();
                que2.pop_front();
            }
            else{
                a = que2.back();
                que2.pop_back();
                b = que2.back();
                que2.pop_back();
            }
            ll c = abs(a-left2)+abs(b-right2);
            ll d = abs(a-right2)+abs(b-left2);
            if(c>d){
                left2=a;
                right2=b;
                ans2 += c;
            }
            else {
                left2=b;
                right2=a;
                ans2 += d;
            }
        }
        idx2++;
    }
    cout<<max(ans1, ans2)<<endl;
    return 0;
}

Measured memory_bytes: 1948
#include<iostream>
#include<cstdio>

using namespace std;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  while (true) {
    int n, m; cin >> n >> m;
    if (n == 0) break;
    V<> h(n + 1);
    for (int i = 0; i < n; ++i) {
      int _h; cin >> _h;
      h[i + 1] = h[i] + _h;
    }
    V<> w(m + 1);
    for (int i = 0; i < m; ++i) {
      int _w; cin >> _w;
      w[i + 1] = w[i] + _w;
    }
    V<> ch(1000 * n + 1);
    for (int i = 0; i < n; ++i) for (int j = i + 1; j <= n; ++j) {
      ++ch[h[j] - h[i]];
    }
    V<> cw(1000 * m + 1);
    for (int i = 0; i < m; ++i) for (int j = i + 1; j <= m; ++j) {
      ++cw[w[j] - w[i]];
    }
    lint res = 0;
    for (int i = 1; i <= 1000 * min(n, m); ++i) {
      res += ch[i] * cw[i];
    }
    cout << res << '\n';
  }
}


Measured memory_bytes: 14688
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> V;
typedef map<int, int> M;

constexpr ll INF = 1e18;
constexpr ll MOD = 1e9 + 7;

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

    int n, m, p[112345], y[112345];
    vector<P> q[112345];
    cin >> n >> m;
    vector<P> res(m);
    REP(i, m)
    {
        cin >> p[i] >> y[i];
        q[p[i]].push_back(make_pair(y[i], i));
    }

    REP(i, n + 1)
    {
        if (q[i].size())
        {
            SORT(q[i]);
            int cnt = 1;
            REP(j, q[i].size())
            {
                res[q[i][j].second].first = p[q[i][j].second];
                res[q[i][j].second].second = cnt;
                cnt++;
            }
        }
    }

    REP(i, m)
    {
        printf("%06d%06d", res[i].first, res[i].second);
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 8832
#include<iostream>
using namespace std;
int main(){
for(int x,y,i=0;  ; i++){
cin >> x >> y;
if(x==0 && y==0)break;
if(x>y) cout << y << " " << x <<endl;
else cout << x << " " << y <<endl;
}
return 0;
}



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

#define ll long long
#define mp make_pair
#define pb push_back

#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#define rep(i, n) for (int i = 0; i < (int)(n); ++ i)
#define forall(it, c) for (__typeof(c.begin()) it = c.begin(); it != c.end(); ++ it)

template <typename T> inline void read(T &x) {
	x = 0; bool f = 1; char c = getchar();
	for (; !isdigit(c); c = getchar()) if (c == '-') f = 0;
	for (;  isdigit(c); c = getchar()) x = x * 10 + (c & 15);
	if (!f) x = -x;
}

int main() {
	int k; read(k);
	string s; cin >> s;
	if (s.size() > k) cout << s.substr(0, k) << "..." << endl;
	else cout << s << endl;
	return 0;
}


Measured memory_bytes: 3636
parseInt(x) = parse(Int, x)
parseBigInt(x) = parse(BigInt, x)
parseFloat(x) = parse(Float64, x)
parseBigFloat(x) = parse(BigFloat, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    x,y,z=parseMap(split(readline()))
    println("$z $x $y")
end
main()

Measured memory_bytes: 110424
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <stack>
#include <numeric>
#include <algorithm>
#include <tuple>
#include <stdio.h>
#include <bitset>
#include <limits.h>
#include <complex>
#include <deque>
#include <iomanip>
#include <list>
using namespace std;
#define pi pair<int32,int32>
#define pl pair<int64,int64>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
#define en cout << endl //セミコロンつけろ
//#define MM 1000000000
//#define MOD MM+7
const int MM = 1e9;
const int MOD = MM+7;
const long double PI = acos(-1);
const long long INF = 1e15;
int dx[8] = {-1,0,1,0,-1,-1,1,1};
int dy[8] = {0,-1,0,1,-1,1,1,-1};
// 'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122
template<typename T>
T GCD(T u,T v){
    return v ? GCD(v,u%v) : u;
}
template<typename T>
T LCM(T x,T y){
    T gc = GCD(x,y);
    return x*y/gc;
}

int main(){
    long long H,W; long long ans = 1e18; cin >> H >> W;

    if (H % 3 == 0 || W % 3 == 0){
        cout << 0 << endl;
        return 0;
    } else {
        ans = min(H,W);
    }

    long long s1,s2,s3;
    for (long long i = 1; i < H; i++){
        s1 = i*W;
        s2 = (H-i)*(W/2);
        s3 = (H-i)*W-s2;
        ans = min(ans, max(s1,max(s2,s3)) - min(s1,min(s2,s3)));
    }

    for (long long i = 1; i < W; i++){
        s1 = i*H;
        s2 = (W-i)*(H/2);
        s3 = (W-i)*H-s2;
        ans = min(ans, max(s1,max(s2,s3)) - min(s1,min(s2,s3)));
    }
    cout << ans << endl;
}

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

int main()
{
	int D, N,answer,power;
	cin >> D >> N;
	power = 1;
	for (int i = 0; i < D; i++) {
		power *= 100;
	}
	answer = power * N;

	if (N == 100)
		answer += power;


	cout << answer << endl;
}

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

#define REP(i,n) for(int i=0; i<int(n); i++)
#define FOR(i,m,n) for(int i=int(m); i<int(n); i+=2)
#define ALL(obj) (obj).begin(),(obj).end()
#define VI vector<int>
#define VC vector<char>
#define FOREACH(x,a) for(auto& (x) : (a) )
using namespace std;

int main() {
	int n;
	cin >> n;
	int ans = 0;
	FOR(i, 1, n + 1) {
		int res = 0;
		FOR(j, 1, n+1) {
			if ((i % j) == 0) res++;
		}
		if (res == 8) {
			ans++;
			
		}
	}
	cout << ans << endl;
	return 0;
}

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

using namespace std;

void get_input();

int d, n, m;
vector<int> sp, dp;

int main()
{
	while (true)
	{
		get_input();
		if (d == 0) { break; }

		sort(sp.begin(), sp.end());
		int dist_sum = 0;
		
		for (int i = 0; i < m; i++)
		{
			int dest = dp[i];

			// when the destination is between the headquarter and the (n-1)th store.
			if (sp[n - 1] <= dest)
			{
				dist_sum += min(abs(sp[n - 1] - dest), abs(d - dest));
			}
			else
			{
				// otherwise conduct binary search.
				int right = n - 1;
				int left = 0;
				int part = (right + left) / 2;

				while (true)
				{
					if ((left + 1) == right)
					{
						dist_sum += min(abs(sp[left] - dest), abs(sp[right] - dest));
						break;
					}

					if (dest == sp[part])
					{
						break;
					}
					else if (dest < sp[part])
					{
						right = part;
						part = (right + left) / 2;
					}
					else
					{
						left = part;
						part = (right + left) / 2;
					}
				}
			}
		}

		cout << dist_sum << endl;
	}
	
	cin.get();
	return 0;
}

void get_input()
{
	cin >> d;
	if (d == 0)
	{
		return;
	}
	
	cin >> n;
	cin >> m;

	sp.resize(n);
	sp[0] = 0;
	for (int i = 1; i < n; ++i)
	{
		cin >> sp[i];
	}

	dp.resize(m);
	for (int i = 0; i < m; ++i)
	{
		cin >> dp[i];
	}
}

Measured memory_bytes: 3476
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
using namespace std;
int main() {
	long long int N, ans = 10000000000000, a = 0;
	cin >> N;
	vector<int>A(N);
	for (int i = 0; i < N; i++)cin >> A[i];
	for (int i = -100; i <= 100; i++)
	{
		a = 0;
		for (int j = 0; j < N; j++)
		{
			a += abs(A[j] - i)*abs(A[j] - i);
		}
		ans = min(ans, a);
	}
	cout << ans;
}


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

using namespace std;

#define   M             100005
#define   ll            long long
#define   PI            atan(1.0)*4
#define   mst(x,v)      memset(x,v,sizeof(x))
#define   inf           1e9
#define   rush()        int T;scanf("%d",&T);while(T--)

typedef   pair<int,int> P;

vector< P > E[M];
P temp;
int d[M],n,m,l,r,dis;
bool  vis[M],f;

bool dfs(int now,int bef) {
	vis[now]=1;
	if(f) return false;
	
	for(int i=0;i<E[now].size();i++) {
		temp=E[now][i];
		
		if(!vis[temp.first]) {
			d[temp.first]=d[now]+temp.second;
			dfs(temp.first,now);
		}
		else {
			if(d[temp.first] != d[now] + temp.second) {
				f=1;
				return false;
			}
		}
	}
	return true;
}


int main() {

	scanf("%d %d",&n,&m);
	
	while(m--) {
		scanf("%d %d %d",&l,&r,&dis);
		E[l].push_back(make_pair(r,dis));
		E[r].push_back(make_pair(l,-dis));
	}
	
	f=0;
	for(int i=1;i<=n;i++) {
		if(!vis[i]) {
			if(!dfs(i,-1)) {
				f=1;
				break;
			}
		}
	}
	
	puts(f?"No":"Yes");
}



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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 998244353
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;

inline li keta(li x) {
    stringstream ss;
    ss << x;
    return ss.str().size();
}

int main() {
    li n;
    cin >> n;
    li res = INF;
    repp(i, 1, sqrt(n) + 1) {
        if (n % i == 0) {
            res = min(res, max(keta(i), keta(n / i)));
        }
    }
    cout << res << endl;


    return 0;
}

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

using ll = long long;

int main() {
    int a, b;
    cin >> a >> b;
    if(b % a == 0)
        cout << a + b << endl;
    else
        cout << b - a << endl;
    return 0;
}

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

using namespace std;
// ascending order
#define vsort(v) sort(v.begin(), v.end())
// descending order
#define vsort_r(v) sort(v.begin(), v.end(), greater<int>())
#define vunique(v) unique(v.begin(), v.end())
#define mp make_pair
#define ts(x) to_string(x)
#define rep(i, a, b) for(int i = (int)a; i < (int)b; i++)
#define repm(i, a, b) for(int i = (int)a; i > (int)b; i--)
#define bit(a) bitset<8>(a)
#define des_priority_queue priority_queue<int, vector<int>, greater<int> >
typedef long long ll;
typedef pair<int, int> P;
const ll INF = 1e18;

#define MAX_N 100001
int N, M;

struct union_find_tree {
	int par[MAX_N]; // 親
	int depth[MAX_N]; // 木の深さ

	// n要素で初期化
	void init(int n) {
		rep(i, 0, n) {
			par[i] = i;
			depth[i] = 0;
		}
	}

	// 木の根を求める
	int find(int x) {
		if(par[x] == x) return x;
		else return par[x] = find(par[x]);
	}

	// xとyの属する集合を併合
	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if(x == y) return;

		if(depth[x] < depth[y]) {
			par[x] = y;
		} else {
			par[y] = x;
			if(depth[x] == depth[y]) depth[x]++;
		}
	}

	// xとyが同じ集合に属するか否か
	bool same(int x, int y) {
		return find(x) == find(y);
	}
};

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

	cin >> N >> M;
	union_find_tree uft;
	uft.init(N);
	int p[N];
	rep(i, 0, N) cin >> p[i];

	rep(i, 0, M) {
		int x, y;
		cin >> x >> y;
		uft.unite(x - 1, y - 1);
	}

	int ans = 0;
	rep(i, 0, N) {
		if(uft.same(p[i] - 1, i)) ans++;
	}
	cout << ans << endl;

}


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

#define isNum(a) (a >= '0' && a <= '9')
#define SP putchar(' ')
#define EL putchar('\n')
#define File(a) freopen(a ".in", "r", stdin), freopen(a ".out", "w", stdout)

template <class T> void read(T &);
template <class T> void write(const T &);

typedef long long ll;
typedef unsigned long long ull;
typedef const long long &cll;
typedef const int &ci;
typedef std::pair<int, int> pii;
const int iinf = 2147483647;
const ll llinf = 9223372036854775807ll;
using std::abs;
using std::max;
using std::min;

const int N = 1000005;
const int Mod = 1000000007;

int dp[N][2][2];
int n;

int main() {
  read(n);
  dp[0][0][0] = 1;
  for (int i = 1; i <= n; ++i) {
    dp[i][0][0] = dp[i - 1][0][0] * 8ll % Mod;
    dp[i][1][0] = (dp[i - 1][0][0] + dp[i - 1][1][0] * 9ll % Mod) % Mod;
    dp[i][0][1] = (dp[i - 1][0][0] + dp[i - 1][0][1] * 9ll % Mod) % Mod;
    dp[i][1][1] =
        (dp[i - 1][1][0] + dp[i - 1][0][1] + dp[i - 1][1][1] * 10ll % Mod) %
        Mod;
  }
  write(dp[n][1][1]), EL;
  return 0;
}

template <class T> inline void read(T &Re) {
  T k = 0;
  char ch = getchar();
  int flag = 1;
  while (!isNum(ch)) {
    if (ch == '-') {
      flag = -1;
    }
    ch = getchar();
  }
  while (isNum(ch)) {
    k = (k << 1) + (k << 3) + ch - '0';
    ch = getchar();
  }
  Re = flag * k;
}
template <class T> inline void write(const T &Wr) {
  if (Wr < 0) {
    putchar('-');
    write(-Wr);
  } else {
    if (Wr < 10) {
      putchar(Wr + '0');
    } else {
      write(Wr / 10);
      putchar((Wr % 10) + '0');
    }
  }
}


Measured memory_bytes: 19212
N = int(input())
a = list(map(int,input().split()))

one_list = []
two_list = []
four_list = []

for i in range(N):
    if a[i]%2 == 0:
        if a[i]%4 == 0:
            four_list.append(a[i])
        else:
            two_list.append(a[i])
    else:
        one_list.append(a[i])
        
if len(two_list) > 0:
    if len(four_list) >= len(one_list):
        print('Yes')
    else:
        print('No')
else:
    if len(four_list)+1 >= len(one_list):
        print('Yes')
    else:
        print('No')

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

int main(){
    llong h, w;
    cin >> h >> w;
    if(h == 1 || w == 1){
        cout << 1 << endl;
    }
    else if(h * w % 2 == 0){
        cout << (llong)(h * w / 2) << endl;
    }else{
        cout << (llong)(h * w / 2 + 1) << endl;
    }
}


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

#define FOR(i, j, k) for(int i = j; i < k; i++)
#define REP(i, j) FOR(i, 0, j)
#define fst first
#define snd second
#define pb push_back
#define eb emplace_back
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

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 <typename T> istream &operator>>(istream &is, vector<T> &vec) {
    for(T &x : vec)
        is >> x;
    return is;
}

//  see abc066 D

#define MOD 1000000007
#define MAX 200010

long long int f[MAX] = {};
long long int rf[MAX] = {};

long long int pw(long long int x, long long int y) {
    long long ret = 1LL;

    for(long long int mask = 0; mask < 50; ++mask) {
        if(y >> mask & 1)
            ret = ret * x % MOD;
        x = x * x % MOD;
    }
    return ret % MOD;
}

long long int getComb(int n, int k) {
    if(k > n)
        return 0;
    long long int ret = f[n];
    ret = ret * rf[k] % MOD;
    ret = ret * rf[n - k] % MOD;
    return ret;
}

long long int initComb(int n) {
    rf[0] = f[0] = 1;
    for(int i = 1; i < n + 1; i++) {
        f[i] = f[i - 1] * i % MOD;
        rf[i] = pw(f[i], MOD - 2);
    }
    return 1;
}

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int n, k;
    cin >> n >> k;

    initComb(n);

    for(int i = 1; i <= k; i++) {
        int l = n - k + 1;
        ll a = getComb(l, i);
        // cout << a << endl;

        // cout << l << " C " << i << endl;
        // cout << k - 1 << " C " << i - 1 << endl;
        a *= getComb((k - i) + (i - 1), i - 1);
        a %= MOD;
        cout << a << endl;
    }

    return 0;
}


Measured memory_bytes: 256
N,M = map(int,input().split())
A = set([int(input()) for _ in range(M)])
Div = 10**9+7
#dp[i]:i段目にたどり着く移動方法のパターン数
dp = [0 for _ in range(N+1)]
dp[0] = 1
if 1 not in A:
    dp[1] = 1

for i in range(2,N+1):
    if i not in A:
        dp[i] = (dp[i-1] + dp[i-2]) % Div

print(dp[N])


Measured memory_bytes: 13192
n = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
ab = list(zip(A, B))
c1, c2 = 0, 0
for a, b in ab:
  if a >= b:
    c1 += a-b
  else:
    c2 += (b-a)//2
if c2 >= c1:
  print("Yes")
else:
  print("No")

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

int main()
{
    int n;

    cin >> n;

    vector<int>list(n);

    rep(i , n)
    {
        cin >> list.at(i);
    }

    int count = 0;
    rep(i , n)
    {
        if(list.at(i)!= i + 1)
        {
            count++;
        }
    }

    if(count == 0 || count == 2)
    {
        cout << "YES" << endl;
    }
    else
    {
        cout << "NO" << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,K;
  cin >> N >> K;
  vector<int>ans(N);
  for(int i=0 ; i<K ; i++){
    int d;
    cin >> d;
    for (int j=0; j<d ; j++){
      int Z;
      cin >> Z;
      ans.at(Z-1)++;
    }
  }
  cout << count(ans.begin(),ans.end(),0) << endl;
}

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

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<double, double> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<string> &o) {
    string a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

int main() {
    string s;
    cin >> s;
    int ci = INT_MAX, fi = INT_MIN;
    rep(i, s.size()) {
        char c = s[i];
        if (c == 'C') cmin(ci, i);
        if (c == 'F') cmax(fi, i);
    }

    if (ci == INT_MIN || fi == INT_MIN) {
        cout << "No" << endl;
    } else {
        if (ci < fi) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }

}


Measured memory_bytes: 256
#include <sstream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>

using namespace std;

int main(){
	int N,x;
	cin>>N>>x;
	vector<unsigned long> a(N);
	for(int i=0;i<N;i++){
		cin>>a[i];
	}
	vector<unsigned long> Array(N);
	unsigned long total=0;
	unsigned long mini;
	for(int i=0;i<N;i++){
		Array[i]=a[i];
		total+=a[i];
	}
	mini=total;

	for(int i=0;i<N;i++){
		total=0;
		for(int j=0;j<N;j++){
			Array[j]=min(Array[j],a[((j+N)-i)%N]);
			total+=Array[j];
		}
		mini=min(mini,total+i*x);
	}

	cout<<mini<<endl;

	return 0;
}

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

int main(){
    int N, T, A, minplace;
    double min, temp;
    cin >> N >> T >> A;
    int H[N];
    for(int i=0; i<N; i++) cin >> H[i];
    temp = T - H[0]*0.006;
    min = fabs(A - temp);
    minplace = 0+1;
    for(int i=1; i<N; i++){
        temp = T - H[i]*0.006;
        if(min > fabs(A-temp)){
            min = fabs(A- temp);
            minplace = i+1;
        }
    }
    cout << minplace << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast { Fast() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20);} } fast;
 
long long mod = 1000000007;
 
long long div(long long a, long long b, long long c){
    return b / c - (a - 1) / c;
}
 
void print_binary(long long a) {
    for (int i = 31; i >= 0; i--) {
        cout << (a >> i & 1);
    }
    cout << endl;
}
long long modpow(long long m, long long n) {
    if (n == 0) return 1;
    if (n % 2 == 0) {
        long long t = modpow(m, n / 2);
        return t * t;
    } else {
        return modpow(m, n - 1) * m;
    }
}
 
int main() {
    int a, b, c;
    cin >> a >> b >> c;
    if (b > c - a){
        cout << b + c << endl;
    }else if (b == c - a){
        cout << b + c << endl;
    }else{   
        cout << b + a + b + 1 << endl;
    }
}

Measured memory_bytes: 256
<?php
fscanf(STDIN, "%d %d", $N, $X);
$x = array_map("intval", explode(" ", trim(fgets(STDIN))));
$x[] = $X;
sort($x);
$x_min = min($x);
$x = array_map(function($a) use($x_min) {return $a - $x_min;}, $x);

for ($i = 1; $i <= $N; $i++) {
    if (!isset($ans)) {
        $ans = gcd($x[$i - 1], $x[$i]);
    } else {
        $ans = gcd($ans, $x[$i]);
    }
    if ($ans === 1) break;
}
echo $ans;

//最大公約数
function gcd($m, $n){
    if($n > $m) list($m, $n) = array($n, $m);
     
    while($n !== 0){
        $tmp_n = $n;
        $n = $m % $n;
        $m = $tmp_n;
    }
    return $m;
}


Measured memory_bytes: 16884
// tested by Hightail - https://github.com/dj3500/hightail
import std.stdio, std.string, std.conv, std.algorithm;
import std.range, std.array, std.math, std.typecons, std.container, core.bitop;

int a, b;

void main() {
    int a, b, c;
    scan(a, b, c);
    writeln(min(min(a + b, b + c), a + c));
}


void scan(T...)(ref T args) {
    string[] line = readln.split;
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront();
    }
    assert(line.empty);
}


void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<stdlib.h>

int min(int a,int b){
	if(a>b){
		return b;
	}
	else{

		return a;
	}


}




int main(void){
	int n;
	int a[100000];
	int i;
	int min_num;
	int v_min = 1000000001;
	int v_min_old;

	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&a[i]);
		v_min = min(v_min,a[i]);
		if(v_min == a[i]){
			min_num = i;
		}
	}
	do{
		v_min_old = v_min;

		for(i=0;i<n;i++){
			if(a[i] % v_min > 0){
				a[i] = a[i] % v_min;
			}else{
				a[i] = v_min;
			}
		}

		for(i=0;i<n;i++){
			v_min = min(v_min,a[i]);
			if(v_min == a[i]){
				min_num = i;
			}
		}
	}while(v_min_old != v_min);

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

	return 0;
}


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

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

    char c[3][3];
    for(int i = 0; i < 3; i++){
        for(int j = 0; j < 3; j++){
            cin >> c[i][j];
        }
    }

    cout << c[0][0] << c[1][1] << c[2][2] << endl;
}


Measured memory_bytes: 256
import Control.Monad

main = do
    n <- read <$> getLine
    putStrLn $ solve n

solve :: Int -> String
solve n = convert (n `div` 100) : convert (n `div` 10) : convert n : []
  where
    convert n | n `mod` 10 == 1 = '9'
              | otherwise       = '1'


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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int main(){
    vi a(3);
    rep(i,3)cin>>a[i];
    sort(all(a));
    cout<<a[2]*10+a[1]+a[0]<<endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include<vector>
#include <math.h>
#include<stdio.h>
#include <climits>
#include<algorithm>
#include<string>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define LL  long long 
#define Pi 3.14159265358979;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	int i = 0, j = 0;//ループ用配列

	string s;
	int count[26] = {};
	char ans;
	int flag = 0;

	cin >> s;
	rep(i, s.size()) {
		count[s[i] - 97]++; //asciiで小文字指定
	}

	rep(i, 26) {
		if (flag==0 and count[i] == 0) {
			ans = i + 97;
			cout << ans << "\n";
			flag++;
		}
	}
	if(flag==0)	cout << "None" << "\n";
}


Measured memory_bytes: 512
long long l,i;main(r,x){for(;scanf("%lld",&l),l;printf("%d\n",(l>1?3:1)*r/2+1))for(i=r=1;++i*i<=l;r*=2*x+1)for(x=0;!(l%i);l/=i)x++;exit(0);}

Measured memory_bytes: 596
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define sync ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define MOD  1000000007 
int powm(int base,int exp,int mod=MOD) {int ans=1;while(exp){if(exp&1) ans=(ans*base)%mod;exp>>=1,base=(base*base)%mod;}return ans;}
int32_t main()
{
	int m,d;
	cin>>m>>d;
	int count=0;
	for(int i=1;i<=m;i++)
	{
		for(int j=1;j<=d;j++)
		{
			if(j>=10 && j<=99 )
			{
				int a=j/10;
				int b=j%10;
				if(a>=2 && b>=2 && i==a*b)
					count++;
			}
		}
	}
	cout<<count<<endl;
}

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

int main(){
	string a,b,c;
	int x,y;
	cin>>a>>b>>x>>y>>c;
	if(c==a) cout<<x-1<<" "<<y<<endl;
	else cout<<x<<" "<<y-1<<endl;
	return 0;
}

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

int main() {
    int n;
    cin >> n;
    vector<pair<long long, long long>> sections(n); 
    for (int i = 0; i < n; i++) {
        int l, r;
        cin >> l >> r;
        sections.at(i) = make_pair(l, r);
    }
    sort(sections.begin(), sections.end());

    vector<long long> l_from_front(n), r_from_front(n), l_from_back(n), r_from_back(n);
    long long l = 0, r = 1e+9;
    for (int i = 0; i < n - 1; i++) {
        l = max(l, sections.at(i).first);
        r = min(r, sections.at(i).second);
        l_from_front.at(i) = l;
        r_from_front.at(i) = r;
    }
    l = 0, r = 1e+9;
    for (int i = n - 1; i >= 1; i--) {
        l = max(l, sections.at(i).first);
        r = min(r, sections.at(i).second);
        l_from_back.at(i) = l;
        r_from_back.at(i) = r;
    }

    long long maxi = 0;
    for (int i = 0; i < n - 1; i++) {
        long long cnt = max(0ll, r_from_front.at(i) - l_from_front.at(i) + 1) + max(0ll, r_from_back.at(i + 1) - l_from_back.at(i + 1) + 1);
        maxi = max(maxi, cnt);

        if (i != 0) {
            long long l = max(l_from_front.at(i - 1), l_from_back.at(i + 1));
            long long r = min(r_from_front.at(i - 1), r_from_back.at(i + 1));
            cnt = max(0ll, r - l + 1) + max(0ll, sections.at(i).second - sections.at(i).first + 1);
            maxi = max(maxi, cnt);
        }
    }
    cout << maxi << endl;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
using namespace std;
const int Maxn=1005,Maxm=200005;
int vis[Maxn][Maxn],lst1[Maxn][Maxn],lst2[Maxn][Maxn],ans[Maxm];
vector<pair<int,int>>e[Maxn];
void dfs1(int x,int s){
    vis[s][x]=true;
    for(auto i:e[x]){
        int y=i.first;
        if(vis[s][y])continue;
        dfs1(y,s);
    }
}
void dfs2(int x,int s,int lst[][Maxn]){
    for(auto i:e[x]){
        int y,id;tie(y,id)=i;
        if(!lst[s][y]&&y!=s){
            lst[s][y]=id;
            dfs2(y,s,lst);
        }
    }
}
int main(){
    int n,m;scanf("%d%d",&n,&m);
    for(int i=1;i<=m;i++){
        int x,y;scanf("%d%d",&x,&y);
        e[x].emplace_back(y,i);
    }
    for(int i=1;i<=n;i++)
        dfs1(i,i);
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++)reverse(e[j].begin(),e[j].end());
        dfs2(i,i,lst1);
        for(int j=1;j<=n;j++)reverse(e[j].begin(),e[j].end());
        dfs2(i,i,lst2);
        for(auto o:e[i]){
            int y,id;tie(y,id)=o;
            ans[id]=vis[y][i]^(lst1[i][y]!=id||lst2[i][y]!=id);
        }
    }
    for(int i=1;i<=m;i++)
        puts(ans[i]?"diff":"same");
    return 0;
}

Measured memory_bytes: 16768