akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>

void addEdge(int* count, int** edges, int to) {
	int* newEdges = realloc(*edges, sizeof(int) * (*count + 1));
	if (newEdges == NULL) exit(2);
	newEdges[(*count)++] = to;
	*edges = newEdges;
}

int N;
int edgeCount[114514];
int* edges[114514];
int to_N[114514], to_1[114514];

int nextEdge[114514];
int fenekku_phase, sunuke_phase;

int fenekku_candidate_count, sunuke_candidate_count;
int fenekku_candidate_use, sunuke_candidate_use;
int fenekku_candidates[114514], sunuke_candidates[114514];

int color[114514];

int dfs(int node, int parent) {
	int i;
	int yes = 0;
	if (node == N) return 1;
	for (i = 0; i < edgeCount[node]; i++) {
		if (edges[node][i] != parent) {
			int res = dfs(edges[node][i], node);
			if (res) {
				to_N[node] = edges[node][i];
				to_1[edges[node][i]] = node;
				yes = 1;
			}
		}
	}
	return yes;
}

int main(void) {
	int i;
	if (scanf("%d", &N) != 1) return 1;
	for (i = 1; i < N; i++) {
		int a, b;
		if (scanf("%d%d", &a, &b) != 2) return 1;
		addEdge(&edgeCount[a], &edges[a], b);
		addEdge(&edgeCount[b], &edges[b], a);
	}
	dfs(1, 0);
	fenekku_candidate_count = 1;
	sunuke_candidate_count = 1;
	fenekku_candidates[0] = 1;
	sunuke_candidates[0] = N;
	fenekku_candidate_use = 0;
	sunuke_candidate_use = 0;
	fenekku_phase = 1;
	sunuke_phase = 1;
	color[1] = 1;
	color[N] = -1;
	for (;;) {
		if (fenekku_phase) {
			int node = fenekku_candidates[fenekku_candidate_count - 1];
			if (color[to_N[node]] == 0) {
				color[to_N[node]] = 1;
				fenekku_candidates[fenekku_candidate_count++] = to_N[node];
			} else {
				fenekku_phase = 0;
			}
		}
		if (!fenekku_phase) { /* 上からフォールバックすることがあるのでelseにしない */
			for (;;) {
				int node, next;
				if (fenekku_candidate_use >= fenekku_candidate_count) {
					puts("Snuke");
					return 0;
				}
				node = fenekku_candidates[fenekku_candidate_use];
				if (nextEdge[node] >= edgeCount[node]) {
					fenekku_candidate_use++;
					continue;
				}
				next = edges[node][nextEdge[node]++];
				if (color[next] == 0) {
					color[next] = 1;
					fenekku_candidates[fenekku_candidate_count++] = next;
					break;
				}
			}
		}
		if (sunuke_phase) {
			int node = sunuke_candidates[sunuke_candidate_count - 1];
			if (color[to_1[node]] == 0) {
				color[to_1[node]] = -1;
				sunuke_candidates[sunuke_candidate_count++] = to_1[node];
			} else {
				sunuke_phase = 0;
			}
		}
		if (!sunuke_phase) { /* 上からフォールバックすることがあるのでelseにしない */
			for (;;) {
				int node, next;
				if (sunuke_candidate_use >= sunuke_candidate_count) {
					puts("Fennec");
					return 0;
				}
				node = sunuke_candidates[sunuke_candidate_use];
				if (nextEdge[node] >= edgeCount[node]) {
					sunuke_candidate_use++;
					continue;
				}
				next = edges[node][nextEdge[node]++];
				if (color[next] == 0) {
					color[next] = -1;
					sunuke_candidates[sunuke_candidate_count++] = next;
					break;
				}
			}
		}
	}
}

/*
まず相手のスタート地点に向かって全力で走る (hoge_phase == 1)
衝突したら、道中の残りを埋める (hoge_phase == 0)
*/


Measured memory_bytes: 12672
#include <iostream>
#include <cstdio>
#include <algorithm>

using namespace std;

int a[10010];

int main() {
    int n;
    cin >> n;
    long long sum = 0;
    int ma = -2000000000, mi = 2000000000;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
        mi = min(mi, a[i]);
        ma = max(ma, a[i]);
    }
    cout << mi << ' ' << ma << ' ' << sum << endl;
}


Measured memory_bytes: 3132
// package app;

import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.Stream;

public class Main {

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

        // final String S = sc.next();
        // final int A = sc.nextInt();
        final int A = sc.nextInt();
        final int B = sc.nextInt();
        final int C = sc.nextInt();

        // System.out.println();
        System.out.println(A + B >= C ? "Yes" : "No");

        // System.out.println(A <= X && A + B >= X ? "YES" : "NO");

    }
}

Measured memory_bytes: 21844
import java.util.*;

public class Main{
	public static void main(String[] args){
    	Scanner sc = new Scanner(System.in);
      	int N = sc.nextInt();
      	int K = sc.nextInt();
      
      	long result = (long)K * (long)Math.pow(K - 1, N - 1);
      	System.out.println(result);
    }
}

Measured memory_bytes: 21588
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <numeric>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}

#define INF (1LL<<60)

ll f(ll N, ll K) {
//	DD(N);
	ll m = N;
	if(K<N) {
		ll a = N/K;
		N-=a*K;
		N+=10*K;
	}
//	DD(N);
	set<ll> vis;
	REP(i, 10*1000*1000) {
		N = abs(N-K);
		if(vis.count(N)) break;
		vis.insert(N);
		minUpdate(m, N);
//		DD(N);DD(m);
	}
	return m;
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,K;
	while(cin>>N>>K) {
		ll ans = f(N, K);
		cout<<ans<<endl;
//		break;
	}
	
	return 0;
}


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

int main(){

    ll N;
    cin >> N;
    vector<ll>A(3 * N);
    for(int i = 0; i < A.size(); i++)cin >> A[i];
    sort(A.begin(), A.end());
    ll ans = 0;
    for(ll i = N; i < A.size(); i += 2)ans += A[i];
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
typedef unsigned long long ull;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#define ALL(a)    a.begin(), a.end() 
#define rep(i, K, N)  for(long long int i = K; i < N; i++)
#define ll long long int
using namespace std;

int main() {
ll N, Ans = 0;cin >> N;
vector<ll> A(N);


rep(i, 0, N)cin >> A[i];

sort(ALL(A));


rep(i, 0, N){
rep(j, i + 1, N){

ll a = A[i], b = A[j];

if(b - a < A[i])Ans-=2;
if(A[i] <= b - a && b - a < A[j])Ans-=1;

auto Iter1 = upper_bound(ALL(A), A[j] - A[i]);
auto Iter2 = lower_bound(ALL(A), A[i] + A[j]);

Ans += N - (Iter1 - A.begin()) - (A.end() - Iter2);

}
}

cout << Ans/3;

}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

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

	int i = 1;
	int x;
	while (cin >> x) {
		if (x) {
			cout << "Case " << i << ": " << x << endl;
			i++;
		}
	}
}




Measured memory_bytes: 3148
# C - こだわり者いろはちゃん / Iroha's Obsession

N, K = map(int, input().split())
D = set(input().split())

set_str_N = set(str(N))

while len(set_str_N & D) > 0:
    N = N + 1
    set_str_N = set(str(N))
    
print(N)

Measured memory_bytes: 2940
while gets
    *ls, v1, v2 = $_.split(?,).map &:to_i
    x = v1.to_f * ls.inject(:+) / (v1 + v2)
    s = 0
    (0..ls.size-1).each{|i|
        s += ls[i]
        if x <= s
            puts i+1
            break
        end
    }
end

Measured memory_bytes: 6116
h = int(input())

checked = {}


def check_attack(h):
    if h == 1:
        checked[h] = 1
        return 1
    elif h in checked:
        return checked[h]
    else:
        k = 1 + 2 * check_attack(h//2)
        checked[h] = k
        return k

print(check_attack(h))


Measured memory_bytes: 2940
class Array
    def bsearch_last_index(l = 0, r = size - 1, &pred)
        return nil if l > r
        c = (l + r) / 2 
        if pred[self[c]]
            bsearch_last_index(c+1, r, &pred) || c
        else
            bsearch_last_index(l, c-1, &pred)
        end 
    end 
end 

loop do
    q1, b, c1, c2, q2 = gets.split.map &:to_i
    break if q1 == 0
    
    x = 0
    if c1 <= c2
        x = [q2, b / c1].min
    else
        x = (0..[q2, b / c1].min).to_a.bsearch_last_index do |x|
            y = (b - c1 * x) / c2
            x <= q2 && x + y >= q1
        end 
        x ||= 0
    end 

    b -= c1 * x
    y = b / c2
    
    if x > 0 && x + y >= q1
        puts "#{x} #{y}" 
    else
        puts 'NA'
    end
end 

Measured memory_bytes: 8736
#include <stdio.h>
int main(void){
    // Here your code !
    int a,b,c;
    scanf("%d%d%d",&a,&b,&c);
    if(a+b == c || b+c == a || c+a == b){
        printf("Yes\n");
    }
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair <int, int>;
const double PI = acos(-1);

int main() {
  ll N;
  cin >> N;
  vector<ll> A(N+1);
  vector<ll> B(N);
  rep(i, N+1) cin >> A[i];
  rep(i, N) cin >> B[i];

  ll ans = 0;

  rep(i, N){
    if(A[i] + A[i+1] <= B[i]) {
      ans += A[i] + A[i+1];
      A[i+1] = 0;
    }
    else if(A[i] <= B[i]){
      ans += B[i];
      A[i+1] -= (B[i] - A[i]);
    }
    else ans += B[i];
  }



  cout << ans << endl;

}


Measured memory_bytes: 1792
n = int(input())
dict = {'A':0}
for i in range(n):
    str = input()
    dict[str] = dict.get(str,0) + 1
m = int(input())
for i in range(m):
    str = input()
    dict[str] = dict.get(str,0) - 1
print(max(dict.values()))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string.h>
#include <utility> 
#include <tuple>
#include <iterator>
#include <functional>
using namespace std;
#define rep(i,n) for(long i=0; i<n; i++)





void solve(){
  long n,m;
  cin >> n >> m;
  long a[m];
  rep(i,m){
    long k;
    cin >> k;
    a[i]=k;
  }
  long vec[n+1];
  vec[0] = 1;
  int j=0; //壊れた床へのポインタ
  if(a[0]==1) {vec[1]=0; 
               j=1;
              }
  else vec[1] = 1;
  for(int i=2; i<=n; i++){
    if(a[j]==i) {vec[i]=0; 
    j++;}
    else{
      vec[i]=(vec[i-1]+vec[i-2]) % 1000000007;
    }
  }
  //rep(i,n+1) cout << vec[i] << endl;
  cout << vec[n] << endl;
  
}

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


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



int main() {
    string s, t;
    cin >> s >> t;
    
    int ans = 0;
    rep(i,3) {
        if(s[i] == t[i])
            ans++;
    }
    
    cout << ans << endl;
    
    
    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
const double PI = acos(-1);
#define rep(i, n) for (int i = 0; i < (int)(n); i++ )
using namespace std;
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}
int main(){
  int n;
  while(true){
    cin >> n;
    if(n == 0) break;
    int sum = 0,average = 0;
    vector<long long> x(n);
    rep(i,n) cin >> x.at(i);
    sort(x.begin(),x.end());
    for(int i = 1; i < n-1; i++){
      sum +=x.at(i);
    }
    average = sum /(n-2);
    cout << average << endl;
  }
}


Measured memory_bytes: 3152
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
#include<type_traits>
#include<tuple>
#include<deque>
#include<cassert>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
const int mod = 1000000007;

int main() {
  string s, t;
  cin >> s >> t;
  vector<vector<int>> ch(26);
  s += s;
  int n = s.length() ;
  rep(i, n) {
    ch[s[i] - 'a'].push_back(i + 1);
  }

  int cur = 0;
  ll ans = 0;
  rep(i, t.length()) {
    int c = t[i] - 'a';
    if (ch[c].size() == 0) {
      puts("-1");
      return 0;
    }
    cur = *upper_bound(ch[c].begin(), ch[c].end(), cur);

    if (cur >= n / 2) {
      ans += n / 2;
      cur -= n / 2;
    }
  }
  ans += cur;
  cout << ans << endl;
}

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

#define pb(x) push_back(x);
#define in(y) insert(y);
#define tt(t) while(t--)
#define itr ::iterator it;
#define ll long long
#define vi vector<int>
#define ii pair<int, int>
#define vii vector<ii>
#define si set<int>                      
#define msi map<string, int>
#define new cout<<endl
#define ff(n) for(int i=0;i<n;i++)
#define all(v) sort(v.begin(),v.end())

using namespace std;
vector<int> nots;
bool done(int n){
	string s=to_string(n);
	bool ret=false;
	ff(nots.size()){
		string p=to_string(nots[i]);
		// if p is there in n return false
		size_t found=s.find(p);
		if(found!=std::string::npos) return false;
	}
	return true;
}
int main(){
    int n,k;
    cin>>n>>k;
    nots.resize(k);
    ff(k) cin>>nots[i];
    
    while(!done(n)){
    	++n;
    }
    cout<<n<<endl;
    return 0;
}


Measured memory_bytes: 256
N = int(input())
a = [0]*10**5
a = [0]+a
x = 0
y = 0
z = 0
total = 0
for i in range(1,101):
  x = i
  for j in range(i,101):
    y = j
    for k in range(i,j+1):
      z = k
      total = int(((x+y)**2+(y+z)**2+(z+x)**2)/2)
      if(x==y and y==z):
        a[total]+=1
      elif(x==y or y==z or z==x):
        a[total]+=3
      else:
        a[total]+=6
for l in range(1,N+1):
  print(a[l])

Measured memory_bytes: 10452
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << #x << " is " << x << endl
#define int ll

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int INF = 1e9 + 7;

int dp[33][10];


signed main()
{
	IO_OP;
	
	for(int i=0;i<10;i++) dp[1][i] = 1;
	for(int i=2;i<33;i++) {
		for(int j=0;j<10;j++) {
			if(j - 1 >= 0) dp[i][j] += dp[i-1][j-1];
			dp[i][j] += dp[i-1][j];
			if(j + 1 < 10) dp[i][j] += dp[i-1][j+1];
		}
	}

	int k;
	cin >> k;
	for(int i=1;i<=32;i++) {
		for(int j=1;j<10;j++) {
			if(dp[i][j] >= k) {
				string ans;
				ans += '0' + j;
				int pre = j;
				for(int l=i-1;l>=1;l--) {
					for(int h=0;h<10;h++) {
						if(abs(h-pre) > 1) continue;
						if(dp[l][h] >= k) {
							ans += '0' + h; 
							pre = h;
							break;
						} else {
							k -= dp[l][h];
						}
					}
				}
				cout << ans << endl;
				return 0;
			} else {
				k -= dp[i][j];
			}
		}
	}
}





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

int main(){

  long long int a[1000000] = {0};

  a[0] = 1;
  a[1] = 1;

  for(long long int i=2;i*i<1000000;i++){
    if(a[i] == 0){
      for(long long int j=i+i;j<1000000;j+=i) a[j] = 1;
    }
  }

  int n,z = 0;

  while(cin >> n, n){
    z = 0;

    for(int i=2;i<=n/2;i++){
      if(a[i] == 0 && a[n-i] == 0) z++;
    }

    cout << z << endl;

  }
}

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

#define db long double
const db eps = 1e-6;
int sgn(db a, db b = 0) {
	a -= b;
	return (a > eps) - (a < -eps);
}

struct poi {
	db x, y;
	void r() { cin >> x; cin >> y; }
	void w() { cout << x << ' ' << y << '\n'; }
	poi operator -(poi p) {
		return {x - p.x, y - p.y};
	}
	poi operator +(poi p) {
		return {x + p.x, y + p.y};
	}
	poi operator *(db d) {
		return {x * d, y * d};
	}
	poi operator /(db d) {
		return {x / d, y / d};
	}
	bool operator ==(poi p) {
		return !sgn(x, p.x) && !sgn(y, p.y);
	}
	db dot(poi p) {
		return x * p.x + y * p.y;
	}
	db cross(poi p) {
		return x * p.y - y * p.x;
	}
	db len() { return sqrt(x * x + y * y); }
	db len2() { return x * x + y * y; }
	poi proj(poi p, poi q) {
		db s = (*this - p).dot(q - p) / (q - p).len2();
		return p + (q - p) * s;
	}
	db dis(poi p, poi q) {
		if((*this - p).dot(q - p) < 0) return (*this - p).len();
		if((*this - q).dot(p - q) < 0) return (*this - q).len();
		return abs((*this - p).cross(q - p) / (q - p).len());
	}
};
db xmul(poi a, poi b, poi c) {
	return (b - a).cross(c - a);
}

int ccw(poi a, poi b, poi c) {
	poi u = b - a, v = c - a;
	if(u.cross(v) > eps) return 1;
	if(u.cross(v) < -eps) return -1;
	if(u.dot(v) < -eps) return -2;
	if(u.len2() + eps < v.len2()) return 2;
	return 0;
}
bool si(poi a, poi b, poi c, poi d) {
	return ccw(a, b, c) * ccw(a, b, d) <= 0 &&
		ccw(c, d, a) * ccw(c, d, b) <= 0;
}
poi li(poi a, poi b, poi c, poi d) {
	db u = xmul(c, d, a), v = xmul(c, d, b);
	return (a * v - b * u) / (v - u);
}

const int N = 111;
poi p[N];

int main() {
	ios :: sync_with_stdio(false);
	cout << fixed << setprecision(1);

	int n; cin >> n;
	for(int i = 0; i < n; i ++)
		p[i].r();
	p[n] = p[0];
	db ans = 0;
	for(int i = 0; i < n; i ++)
		ans += p[i].cross(p[i + 1]);
	cout << ans / 2 << '\n';

	return 0;
}

Measured memory_bytes: 3292
loop do
  h,w = gets.split(" ").map(&:to_i)
  break if h==0 and w==0
  line = '#'*w
  h.times do |i|
    if i == 0 or i == h-1
      puts('#' * w)
    else
      puts('#' + '.'*(w-2) + '#') 
    end
  end
  puts ''
end


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

using namespace std;
using ll=long long;

int main()
{
    int n,m;cin >>n>>m;
    int l,r;
    int mx=0,mint=1001001;
    for(int i=0;i<m;i++){
        cin >>l>>r;
        mx=max(l,mx);
        mint=min(mint,r);
    }
    if(mint-mx<0){
        cout <<0 << endl;
        return 0;
    }
    cout << mint-mx+1<< endl;
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<string> S(N);
  for (int i = 0; i < N; ++i)
    cin >> S[i];
  int ans = 0;
  for (int i = 0; i < N; ++i)
    if (S[i] == "E869120")
      ++ans;
  cout << ans << endl;
}


Measured memory_bytes: 3292
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<cstring>
#include<cmath>
#include<ctime>
#include<algorithm>
#include<utility>
#include<stack>
#include<queue>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#define EPS 1e-9
#define PI acos(-1.0)
#define INF 0x3f3f3f3f
#define LL long long
const int MOD = 1E9+7;
const int N = 8000+5;
const int dx[] = {-1,1,0,0,-1,-1,1,1};
const int dy[] = {0,0,-1,1,-1,1,-1,1};
using namespace std;

int x,y;
string str;
bitset<N*2> bs[2];
int main(){
    cin>>str;
    scanf("%d%d",&x,&y);

    int i=0;
    while(str[i]=='F')
        i++;
    bs[0][i+N]=1;
    bs[1][N]=1;

    int num=0;
    int pos=0;
    while(i<=str.size()){
        if(str[i]=='F')
            num++;
        else{
            bs[pos]=(bs[pos]<<num) | (bs[pos]>>num);
            pos=!pos;
            num=0;
        }
        i++;
    }

    if(bs[0][x+N] & bs[1][y+N])
        printf("Yes\n");
    else
        printf("No\n");

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cassert>
#include <cstring>
#include <vector>
#include <valarray>
#include <array>
#include <queue>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <complex>
#include <random>
#include <bitset>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;

ll pow_mod(ll x, ll n, ll md) {
    ll r = 1;
    while (n) {
        if (n & 1) r = (r * x) % md;
        x = (x * x) % md;
        n >>= 1;
    }
    return r;
}

ll invp(ll x, ll md) {
    return pow_mod(x, md-2, md);
}

const int MN = 400100;
ll powB[MN];
ll res[2][MN];

int n, m;
string s;
string T[MN];
void solve(int id, ll B, ll MD) {
    ll invB = invp(B, MD);
    powB[0] = 1;
    for (int i = 1; i < MN; i++) {
        powB[i] = powB[i-1]*B % MD;
    }
    int l = 0, r = 1;
    ll hs = s[0];
    for (int i = 0; i < m; i++) {
        string t = T[i];
        if (t == "L--") {
            l--;
            hs *= B;
            hs += s[l];
            hs %= MD;
        } else if (t == "L++") {
            hs -= s[l];
            hs *= invB;
            hs %= MD; hs += MD; hs %= MD;
            l++;
        } else if (t == "R--") {
            r--;
            hs -= powB[r-l]*s[r] % MD;
            hs %= MD; hs += MD; hs %= MD;
        } else if (t == "R++") {
            hs += powB[r-l]*s[r] % MD;
            hs %= MD;
            r++;
        }
//        cout << "hash: " << hs << endl;
        res[id][i] = hs;
    }
}

const ll MD = 1e9+7;
const ll B = 454519190;
const ll MD2 = 1e9+9;
const ll B2 = 124598427;
typedef pair<ll, ll> P;

int main() {
    cin >> n >> m;
    cin >> s;
    for (int i = 0; i < m; i++) {
        cin >> T[i];
    }
    solve(0, B, MD);
    solve(1, B2, MD2);
    set<P> st;
    for (int i = 0; i < m; i++) {
        st.insert(P(res[0][i], res[1][i]));
    }
    cout << st.size() << endl;
}

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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> pll;


const ll LongINF=1e13+7;
const int INF=1e9+7;
const int dx[]={0,1,0,-1};
const int dy[]={1,0,-1,0};

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template <class T, class Y>T GCD(T a, Y b){if(a<b){int c=a;a=b;b=c;}if (a % b == 0){return b;}return GCD(b, a % b);}
void clear(queue<pair<int, int>> &q){queue<pair<int, int>> empty;swap(q, empty);} //queueの中身の型は適時変更を忘れない

#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define rv reverse
#define ALL(a) (a).begin(),(a).end()


int main(){
    int K,X;
    cin>>K>>X;
    if(K*500>=X)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

//a=97,z=122

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

int dx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
int dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};

int board[8][8];

void print_board() {
  for ( int i = 0; i < 8; i++ ) {
    for ( int j = 0; j < 8; j++ ) {
      if ( board[i][j] >= 2 ) {
	cout << 'Q';
      } else {
	cout << '.';
      }
    }
    cout << endl;
  }

  exit(0);
}

void dfs(int n) {
  if ( n == 8 ) print_board();  

  for ( int i = 0; i < 8; i++ ) {
    for ( int j = 0; j < 8; j++ ) {
      if ( !board[i][j] ) {
	int tmp[8][8];
	for ( int a = 0; a < 8; a++ ) {
	  for ( int b = 0; b < 8; b++ ) {
	    tmp[a][b] = board[a][b];
	  }
	}

	board[i][j] = 2;
	for ( int k = 0; k < 8; k++ ) {
	  int ny = i, nx = j;
	  while ( ny < 8 && nx < 8 && ny >= 0 && nx >= 0 ) {
	    board[ny][nx] |= 1;
	    ny += dy[k]; nx += dx[k];
	  }      
	}
	dfs(n+1);
	for ( int a = 0; a < 8; a++ ) {
	  for ( int b = 0; b < 8; b++ ) {
	    board[a][b] = tmp[a][b];
	  }
	}	
      }
    }
  }

}

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

  for ( int i = 0; i < k; i++ ) {
    int r, c;
    cin >> r >> c;
    board[r][c] = 2;
    for ( int j = 0; j < 8; j++ ) {
      int ny = r, nx = c;
      while ( ny < 8 && nx < 8 && ny >= 0 && nx >= 0 ) {
	board[ny][nx] |= 1;
	ny += dy[j]; nx += dx[j];
      }      
    }
  }

  dfs(k);
  
  return 0;
}



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

int main()
{
  int N,W;
  int v[101],w[101],T[101][10001];

  cin>>N>>W;
  for(int i=1;i<N+1;i++)cin>>v[i]>>w[i];

  for(int i=0;i<W+1;i++)T[0][i]=0;
  for(int i=1;i<N+1;i++)T[i][0]=0;

  for(int i=1;i<=N;i++){
    for(int j=1;j<=W;j++){
      if(j>=w[i]){
	if(T[i-1][j]<=(T[i-1][j-w[i]]+v[i]))T[i][j]=(T[i-1][j-w[i]]+v[i]);
	if(T[i-1][j]<=(T[i][j-w[i]]+v[i]))T[i][j]=(T[i][j-w[i]]+v[i]);
	else T[i][j]=T[i-1][j];
      }
      else T[i][j]=T[i-1][j];
    }
  }
  cout<<T[N][W]<<endl;
  return 0;
}

Measured memory_bytes: 5104
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#include<random>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;

//ここから

void solve(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  int q;
  cin>>q;
  vector<set<int>>st(26);
  rep(i,n){
    st[s[i]-'a'].emplace(i);
  }
  while(q--){
    int query;
    cin>>query;
    if(query==1){
      int a;
      char c;
      cin>>a>>c;
      a--;
      st[s[a]-'a'].erase(a);
      st[c-'a'].emplace(a);
      s[a]=c;
    }
    else {
      int l,r;
      cin>>l>>r;
      int cnt=0;
      l--;r--;
      rep(i,26){
        if(st[i].empty())continue;
        auto x=st[i].lower_bound(l);
        if(x!=st[i].end()&&*x<=r)++cnt;
      }
      cout<<cnt<<"\n";
    }
  }
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}

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

namespace atCocderCs
{
    class Program
    {

        static void Main(string[] args)
        {
            bool res = true;
            int N = Convert.ToInt32(Console.ReadLine());
            int pt = 0, px = 0, py = 0;
            for (int i = 0; i < N && res; i++)
            {
                string[] vals = Console.ReadLine().Split(' ');
                int t = Convert.ToInt32(vals[0]);
                int x = Convert.ToInt32(vals[1]);
                int y = Convert.ToInt32(vals[2]);

                int tm = t - pt;
                int len = Math.Abs(x - px) + Math.Abs(y - py);

                res = (tm >= len) && ((len - tm) % 2 == 0);

                pt = t;
                px = x;
                py = y;
            }

            Console.WriteLine(res ? "Yes" : "No");
        }

    }
}


Measured memory_bytes: 15292
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb emplace_back
#define INF (1e9+1)
//#define INF (1LL<<59)

#define int ll

signed main(){
    int n,k;
    cin>>n>>k;
    vector<pii> vp;
    rep(i,n){
        int a,b;
        cin>>a>>b;
        vp.pb(pii(a,b));
    }
    
    sort(all(vp));
    
    int ind = 0;
    
    rep(i,vp.size()){
        k-=vp[i].second;
        if(k<=0){
            cout<<vp[i].first<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 1400
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N;

int main() {
  INCANT;
  cin >> N;
  
  cout << (1999-N)/200+1 << "\n";
  return 0;
}

Measured memory_bytes: 3648
from collections import Counter
n = int(input())
v = list(map(int, input().split()))
c1 = Counter(v[::2])
c2 = Counter(v[1::2])
s1 = sorted(c1.items(), key=lambda x:x[1], reverse=True)
s2 = sorted(c2.items(), key=lambda x:x[1], reverse=True)

if len(s1) == 1 and len(s2) == 1:
    if s1[0][0] == s2[0][0]:
        ans = int(n / 2)
    else:
        ans = 0
else:
    if s1[0][0] != s2[0][0]:
        ans = n - s1[0][1] - s2[0][1]
    else:
        if s1[0][1] > s2[0][1]:
            ans = n - s1[0][1] - s2[1][1]
        elif s1[0][1] < s2[0][1]:
            ans = n - s1[1][1] - s2[0][1]
        else:
            ans = min(n - s1[0][1] - s2[1][1], n - s1[1][1] - s2[0][1])
print(ans)

Measured memory_bytes: 21184
from itertools import product

D, G = map(int, input().split())
pc = [tuple(map(int, input().split())) for _ in range(D)]

ans = 10**18
for pair in product(range(2), repeat=D):
    score = 0
    cnt = 0
    for i, solve in enumerate(pair):
        p, c = pc[i]
        if solve:  # ポイント合算
            score += (i + 1) * 100 * p + c
            cnt += p

    if score >= G:
        ans = min(ans, cnt)
        continue

    rest = G - score
    plus = 10**9
    for i, solve in enumerate(pair):
        j = 100*(i+1)
        p, _ = pc[i]
        if not solve:
            need = (rest + j - 1) // j
            if need <= p:
                plus = min(plus, need)
    ans = min(ans, cnt + plus)

print(ans)

Measured memory_bytes: 3064
#include "bits/stdc++.h"
using namespace std;
typedef int64_t ll;
typedef vector<int64_t> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SIZE(a) int((a).size())
const int inf=100000;

vll par(inf),myrank(inf);
struct edge{
  ll cost;
  ll v;
  ll u;
};
vector<edge> es(inf);
ll v,e;
//par[i]=iならiは根（はじめは全て根）
void init(ll n){
  REP(i,n){
    par[i]=i;myrank[i]=0;
  }
  return;
}
//xの根
ll root(ll x){
  return (par[x]==x)?x:par[x]=root(par[x]);
}
//xが根の木とyが根の木を繋げる
void unite(ll x,ll y){
  x=root(x);y=root(y);
  if(x==y){return;}
  if(myrank[x]<myrank[y]){par[x]=y;}
  else{par[y]=x;}
  if(myrank[x]==myrank[y]){myrank[x]++;}
}
//根が同じかどうか
bool same(ll x,ll y){
  return root(x)==root(y);
}
//クラスカル法
bool comp(const edge &e1,const edge &e2){
  return e1.cost<e2.cost;
}
ll kruskal(vector<edge> es){
  sort(es.begin(),es.end(),comp);
  init(v);
  ll ans=0;
  REP(i,e){
    edge &g=es[i];
    if(!same(g.u,g.v)){
      unite(g.u,g.v);
      ans+=g.cost;
    }
  }
  return ans;
}
int main(){
  cin>>v>>e;
  
  vector<edge> es(e);
  REP(i,e){
    cin>>es[i].u>>es[i].v>>es[i].cost;
  }
  
  cout<<kruskal(es)<<endl;
}



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

# input
N = int(input())

# solve
ans = 0
for i in range(N):
    x, u = map(str, input().split())
    if u == 'JPY':
        ans += int(x)
    if u == 'BTC':
        ans += 380000.0 * float(x)

# output
print(ans)


Measured memory_bytes: 2940
from itertools import accumulate

n = int(input())
A = map(int, input().split())

A_acc = sorted([0] + list(accumulate(A)))
A_acc_dic = {}
for a_acc in A_acc:
    if a_acc not in A_acc_dic:
        A_acc_dic[a_acc] = 1
    else:
        A_acc_dic[a_acc] += 1

res = 0
for v in A_acc_dic.values():
    res += v * (v - 1) // 2
print(res)


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

using namespace std;

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

  string ret="Yes";
  int sum=0;
  int num=N;
  while(num)
  {
    sum+=num%10;
    num/=10;
  }
  cerr <<":"<< sum<< endl;
  if(N%sum)ret="No";
  cout<< ret<< endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    long a,b,c,k,sum,i;
    cin >> a >> b >> c >> k;
    if(a >= k)
    {
        cout << k << endl;
    }
    else if(a<k && b>=(k-a))
    {
        cout << a << endl;
    }
    else
    {
        k = k-a-b;
        sum = a;
        for(i = 0;i < k;i++)
            sum -= 1;
        cout << sum << endl;
    }
    return 0;
}

Measured memory_bytes: 3632
package main

import (
	"fmt"
)

func min(nums ...int) int {
	min := nums[0]
	for _, v := range nums {
		if v < min {
			min = v
		}
	}
	return min
}

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)

	fmt.Println(min(a+b, b+c, c+a))
}


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


char p[11]   = { 0 };
int		n;

void calc(int idx, char *s) {
	char str[11] = {0};
	char  mm = 0;

	for (int i=0; i<=idx; i++) {
		str[i] = s[i];
		mm = max(mm,str[i]);
	}
	
	if (idx == n-1) {
		for (int i=0; i<n; i++) str[i] += 'a';
		cout << str << endl;
		return;
	}
	for (int i=0; i<=mm+1; i++) {
		str[idx+1] = i;
		calc(idx+1,str);
	}
}
	

int main() {
	int		a,b,c,i,j,k,m,x,y,ans = 0;
	char str[11] = { 0 };
	
	cin >> n;

	calc(0 , str);


}


Measured memory_bytes: 1536
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
using namespace std;
long long x(long long a,long long b){
  long long k=1;
  long long c=0;
  while(k<=max(a,b)){
    if((a/k)%2!=(b/k)%2) c+=k;
    k=k*2;
  }
  return c;
}
int main(){
  /*long long N;
  cin>>N;
  string answer;
  long long k=1;
  while(k*26<=N) k=k*26;
  while(k>0){
    long long x=((N/k)%26)-1;
    if(x==0) answer+='a';
    if(x==1) answer+='b';
    if(x==2) answer+='c';
    if(x==3) answer+='d';
    if(x==4) answer+='e';
    if(x==5) answer+='f';
    if(x==6) answer+='g';
    if(x==7) answer+='h';
    if(x==8) answer+='i';
    if(x==9) answer+='j';
    if(x==10) answer+='k';
    if(x==11) answer+='l';
    if(x==12) answer+='m';
    if(x==13) answer+="n";
    if(x==14) answer+='o';
    if(x==15) answer+='p';
    if(x==16) answer+='q';
    if(x==17) answer+='r';
    if(x==18) answer+='s';
    if(x==19) answer+='t';
    if(x==20) answer+='u';
    if(x==21) answer+='v';
    if(x==22) answer+='w';
    if(x==23) answer+='x';
    if(x==24) answer+='y';
    if(x==25) answer+='z';
    k=k/26;
  }
  cout<<answer<<endl;*/
  
  int N;
  cin>>N;
  long long a[200000];
  long long key=0;
  for(int i=0;i<N;i++){
   cin>>a[i];
    if(i%2==1) key=x(key,x(a[i-1],a[i]));
  }
  for(int i=0;i<N;i++){
    if(i!=N-1) cout<<x(a[i],key)<<' ';
    else cout<<x(a[i],key)<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 4728
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(a); i<(b); i++)
#define REP(i, n) FOR(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
 
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
        return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}

int main() {
        char c; cin >> c;
        
        cout << static_cast<char>(c + 1) << endl;

        return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using pdd = pair<double, double>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

    int N, M;
    cin >> N;
    vector<int> a(N);
    for (int i = 0; i < N; ++i)
        cin >> a[i];

    vector<vector<ll>> dp(N + 1, vector<ll>(N + 1));
    for (int i = 0; i <= N; ++i)
        dp[i][i] = 0;
    for (int w = 1; w <= N; ++w) {
        for (int l = 0; l + w <= N; ++l) {
            int r = l + w;
            int cnt = N - w;
            if (cnt & 1)
                dp[l][r] = min(dp[l + 1][r] - a[l], dp[l][r - 1] - a[r - 1]);
            else
                dp[l][r] = max(dp[l + 1][r] + a[l], dp[l][r - 1] + a[r - 1]);
        }
    }

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

    return 0;
}


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

int main(void){

	int a,b,c;
	cin>>a>>b>>c;
	if(a==b)
	cout<<c<<endl;
	if(a==c)
	cout<<b<<endl;
	if(b==c)
	cout<<a<<endl;
	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define MOD 1000000007
#define INF 0x7fffffff
#define IO ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
using namespace __gnu_pbds;
typedef tree<int,null_type,std::less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
using namespace std;
/*
ordered_set X;
X.insert(1);
cout<<*X.find_by_order(1)<<endl; Kth largest element
cout<<X.order_of_key(-5)<<endl;  number of elemets less than K
*/

int main(){
    //freopen(".txt", "w", stdout
    //IO;

    int n;
    cin>>n;
    ll dp[n+1][3];
    int a,b,c;
    cin>>a>>b>>c;
    dp[1][0] = a;
    dp[1][1] = b;
    dp[1][2] = c;
    for(int i = 2; i <= n; i++){
        cin>>a>>b>>c;
        dp[i][0] = max(dp[i-1][1],dp[i-1][2]) + a;
        dp[i][1] = max(dp[i-1][0],dp[i-1][2]) + b;
        dp[i][2] = max(dp[i-1][1],dp[i-1][0]) + c;
    }
    cout<<max(max(dp[n][0],dp[n][1]),dp[n][2]);
    return 0;
}


Measured memory_bytes: 2560
#include <stdio.h>
#include <math.h>
int main(void){
    int a,n,c=0,i,j,f,r,min,max=-100000000;
    scanf("%d",&n);
    
    for(i=0;i<n;i++){
    	scanf("%d",&a);
    	if(i==1){
    		min=f;
    		max=a-min;
    	}
    	
    	if(min>f&&i!=0){
    		min=f;
    	}
    	if(max<a-min){
    		max=a-min;
    	}
    	f=a;
    	//printf("max=%d,min=%d\n",max,min);
	}
    printf("%d\n",max);
    
    return 0;
}


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

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    ll ok = 2e9, ng = 0;
    auto check = [&](ll x) -> bool {
        int cnt = 0;
        rep(i, n) {
            cnt += (a[i] - 1) / x;
        }

        return cnt <= k;
    };
    while (abs(ok - ng) > 1) {
        ll mid = (ok + ng) / 2;
        if (check(mid))
            ok = mid;
        else
            ng = mid;
    }

    cout << ok << endl;

    return 0;
}

Measured memory_bytes: 3996
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // ifstream in("input.txt");
    // cin.rdbuf(in.rdbuf());
    string s;
    cin >> s;
    if (len(s) % 2 == 1) {
        cout << "No" << endl;
        return 0;
    }
    rep(i, len(s)) {
        if ((i % 2 == 0) && (s[i] != 'h')) {
            cout << "No" << endl;
            return 0;
        }
        if ((i % 2 == 1) && (s[i] != 'i')) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
/**
    BISMILLAH
    @Author : Arham
*/
#include <bits/stdc++.h>
#define endl "\n"
#define found true
#define infinity 1e+10+10
#define not_found false
#define FOR(limit) for(int i = 0; i < limit; i++)
#define __FOR(limit) for(int j = 0; j < limit; j++)
#define __FOR__(limit) for(int k = 1; k <= limit; k++)
#define hello(a) a ? "Yes" : "No"
#define HELLO(a) a ? "YES" : "NO"
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define pf push_front
#define pof pop_front
#define pob pop_back
#define I insert
#define fr front
#define B back
#define P push
#define pp pop
#define T top
#define F first
#define S second
/// getline (cin, string);
/// find (lower_bound(inclusive), upper_bound(exclusive), value);
/// set.find (value):
typedef long long lld;
using namespace std;

void solving_f() {
    int n, x, t;
    cin >> n >> x >> t;
    int temp;
    temp = n / x;
    if(n % x) {
        temp++;
    }
    cout << temp * t << endl;
}

int main(string hello_world) {
    ios_base :: sync_with_stdio(not_found);
    cin.tie(NULL);
//    cout.tie(0);

//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);

    solving_f();

    return not_found;
}


Measured memory_bytes: 3536
#include"bits/stdc++.h"
using namespace std;

int main()
{
    int n,t;
    cin >> n >> t;
    double x[n],h[n];
    double m=0;
    for(int i=0;i<n;i++){
        cin >> x[i] >> h[i];
        m=max(m,h[i]/x[i]);
    }
    double a=m*t;
    cout << fixed << setprecision(7) << a << endl;
    return 0;
}



Measured memory_bytes: 3300
#include <stdio.h>


int main(void){
  long n;
  long temp,ans;

  scanf("%ld",&n );
  ans = n;

  for (long i = 1; i <= 1000000; i++) {
    if(n%i==0){
      temp=(n/i)+i-2;

      if(temp<ans){
        ans = temp;
      }
    }
  }
  printf("%ld\n",ans );

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <set>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <limits>
#include <bitset>
#include <stack>

typedef long long int lli;
#define rep(i,s,N) for(int i=s;i<N;i++)
#define MOD 1000000007
using namespace std;


int main(void)
{
	int N; cin >> N;
	vector<int> h(N); rep(i, 0, N)cin >> h[i];
	vector<lli> dp(N, MOD);
	dp[0] = 0; 
	rep(i, 1, N) {
		dp[i] = (dp[i] < (dp[i - 1] + abs(h[i] - h[i - 1]))) ? dp[i] : (dp[i - 1] + abs(h[i] - h[i - 1]));
		if (i > 1)dp[i] = (dp[i] < (dp[i - 2] + abs(h[i] - h[i - 2]))) ? dp[i] : (dp[i - 2] + abs(h[i] - h[i - 2]));
	}
	cout << dp[N - 1] << endl;

	return 0;
}

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

int main(){
    string s;
    int cnt=0,c;
    cin>>s;
    if(s[0]!='A'){
        cout<<"WA"<<endl;
        return 0;
    }
    for(int i=2;i<s.size()-1;i++){
        if(s[i]=='C'){
            cnt++;
            c=i;
        }
    }
    if(cnt!=1){
        cout<<"WA"<<endl;
        return 0;
    }
    for(int i=1;i<s.size();i++){
        if(i!=c){
            if(s[i]>'z'||s[i]<'a'){
                cout<<"WA"<<endl;
                return 0;
            }
        }
    }
    cout<<"AC"<<endl;
}


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

vector<ll> to[55];


int main(){
    ll N,M;cin>>N>>M;
    ll a[3000],b[3000],ans=0;
    rep(i,0,M){
        cin>>a[i]>>b[i];
        a[i]--;b[i]--;
    }
    rep(i,0,M){
        rep(j,0,N)to[j].clear();
        rep(j,0,M){
            if(i==j)continue;
            to[a[j]].push_back(b[j]);
            to[b[j]].push_back(a[j]);
        }
        vector<int> dist(N,-1);    
        queue<int> que;
        int cn=0;
        for(int i=0;i<N;i++){
            if(dist[i]!=-1)continue; 
            dist[i]=0;
            que.push(i);
            while(!que.empty()){
                int v=que.front();
                que.pop();
                for(auto nv:to[v]){
                    if(dist[nv]==-1){
                        dist[nv]=dist[v]+1;
                        que.push(nv);
                    }
                }
            }
            cn++;
        }
        if(cn>=2)ans++;
    }
    cout<<ans<<endl;
}







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

using namespace std;

int in(){ int a; cin >> a; return a; }
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

bool isp(int n){
  if(n == 1) return 0;
  if(n == 2) return 1;
  int a = sqrt(n) + 1;
  for(int i = 2; i <= a; i++){
    if(n % i == 0) return 0;
  }
  return 1;
}

int main(){
  ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(0); cerr.tie(0);
  int x;
  cin >> x;
  while(!isp(x)) x++;
  cout << x << endl;
  return 0;
}



Measured memory_bytes: 3492