akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <cmath>
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;

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

int main() {
    long long N,K,x,ans;
    cin >> N >>K ;
    x = N % K;
    if (x < -1 * (x - K)) {
        ans = x;

    }
    else {
        ans = -1 * (x - K);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

#define MAX_N 1
#define INF 1000000000 //1e9

#define PI 3.14159265359

int main(){
    int r;
    cin >> r;
    double a = 2*PI*r ;
    cout << a << endl;
    return 0;
}

Measured memory_bytes: 3772
N,Y = input().split()
N = int(N)
Y_k=int(Y)/1000

answer = [-1,-1,-1]
for i in range(N+1):
    for j in range(N+1 - i):
        k = N-i-j
        if 10*i + 5*j + 1*k == Y_k:
            answer = [i,j,k]

print(answer[0],answer[1],answer[2])


Measured memory_bytes: 9072
def p_a():
    n, a, b = map(int, input().split())
    if (b - a) & 1 == 0:
        print((b - a) // 2)
        exit()
    print((b - a - 1) // 2 + min(a - 1, n - b) + 1)
    
p_a()

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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define MT make_tuple
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

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

#define FF first
#define SS second

template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}
void debug(istringstream&){}
template <char sep=',', class Head, class... Tail>
void debug(istringstream& iss, Head&& head, Tail&&... tail)
{
  string name;
  getline(iss, name, ',');
  cerr << sep << name << "=" << head;
  debug(iss, forward<Tail>(tail)...);
}
#define DEBUG(...) \
  do{ \
    istringstream ss(#__VA_ARGS__); \
    debug<' '>(ss, __VA_ARGS__); \
    cerr<<endl; \
  }while(0)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

LL dp[22][1<<21];

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

  int N;;
  cin >> N;

  VVI xs(N, VI(N));
  cin >> xs;
  const int B = 1<<N;

  dp[0][0] = 1;
  REP(i,N){
    REP(b,B){
      if(!dp[i][b]) continue;
      REP(k,N){
        if(!xs[i][k] || b>>k&1) continue;
        int nb = b | (1<<k);
        dp[i+1][nb] += dp[i][b];
        if(dp[i+1][nb] >= MOD) dp[i+1][nb] -= MOD;
      }
    }
  }

  cout << dp[N][B-1] << endl;

  return 0;
}


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

using namespace std;

using ll = long long;
using ld = long double;

const int INF = (1 << 30) - 1;
const ll INF64 = ((ll)1 << 62) - 1;
const double PI = 3.1415926535897932384626433832795;

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

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

	string s;
	cin >> s;

	int n = s.size();
	ll ans = 0;
	for (int i = 0; i < 1 << (n - 1); i++) {
		ll score = 0;
		ll v = s[0] - '0';
		for (int j = 0; j < n - 1; j++) {
			if ((1 & i >> j) == 1) {
				score += v;
				v = 0;
			}
			v = 10LL * v + (s[j + 1] - '0');
		}

		score += v;
		ans += score;
	}

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vd=vector<double>;
using vvd=vector<vd>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using vs=vector<string>;
#define rep(i,n) range(i,0,n)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define LINF    	((ll)1ll<60)
#define INF     	((int)1<<30)
#define EPS     	(1e-9)
#define MOD     	(1000000007)
#define fcout(a)	cout<<setprecision(a)<<fixed
#define fs 			first
#define sc			second
#define PI			3.141592653589793

template<class S,class T>ostream& operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1; for(auto s:t){os<<(a?"":" ")<<s; a=0;} return os;}

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	
	int n,x;
	cin>>n>>x;
	vl a(n);
	rep(i,n)cin>>a[i];
	sort(all(a));
	rep(i,n){
	    if(a[i]>x){
	        cout<<i<<endl;
	        return 0;
	    }
	    x-=a[i];
	}
	if(x==0)cout<<n<<endl;
	else cout<<n-1<<endl;
}


Measured memory_bytes: 256
#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>;

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> a(h);
  rep(i, h) cin >> a[i];
  int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
  vector<vector<int>> dist(h, vector<int>(w, -1));
  queue<P> q;
  q.push(P(0, 0));
  dist[0][0] = 0;
  while(!q.empty()) {
    P now = q.front(); q.pop();
    
    rep(i, 4) {
      int nx = now.first+dx[i], ny = now.second+dy[i];
      if (nx >= 0 && nx <h && ny >= 0 && ny < w && a[nx][ny] == '#' && dist[nx][ny] == -1) {
        if (i == 0 || i == 1) {
          q.push(P(nx, ny));
          dist[nx][ny] = 0;
        }
        if (i == 2 || i == 3) {
          cerr << "nx=" << nx << " ny=" << ny << endl;
          cerr << "i= " << i << endl;
          cerr << "dist[" << nx << "][" << ny << "]=" << dist[nx][ny] << endl;
          cout << "Impossible" << endl;
          return 0;
        }
      }
    }
    if (now == P(h-1, w-1)) break;
    if ((int)q.size() > 1 || q.size() == 0) {
      cout << "Impossible" << endl;
      return 0;
    }
  }
  cout << "Possible" << endl;
  return 0;
}


Measured memory_bytes: 3632
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


int main(){
    ll H, W;
    cin >> H >> W;

    char C[W + 1];
    C[W] = '\0';
    rep(i, H){
        rep(j, W){
            cin >> C[j];
        }
        cout << C << endl;
        cout << C << endl;
    }

    return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include<cstdlib>
#include<queue>
#include<set>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i=0;i<a;i++)
#define mp make_pair
#define pb push_back
#define P pair<int,int>
//#define ll __int64
#define ll long long
int n,m,r;
int G[500][500];
ll d[500][500];

vector<int>visit;
ll ans;
 
const ll INF=1000000000;
 
int main(){
cin>>n>>m>>r;
 
ll a,b,c;
visit.resize(r);
rep(i,r){
	cin>>a;
	a--;
	visit[i]=a;
}
 
rep(i,n){
	rep(j,n){
		if(i==j)d[i][j]=0;
		else d[i][j]=INF;
	}
}
 
rep(i,m){
	cin>>a>>b>>c;
	a--;b--;
	//cout<<i<<endl;

	d[a][b]=min(d[a][b],c);
  	d[b][a]=d[a][b];
	
}
 
rep(k,n){
	rep(i,n){
		rep(j,n)d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
	}
}
 
ans=100000000000000000;
sort(visit.begin(),visit.end());
do{
	ll tmp=0;
	for(int i=1;i<r;i++)tmp+=d[visit[i-1]][visit[i]];
	ans=min(ans,tmp);
}while(next_permutation(visit.begin(),visit.end()));
 
cout<<ans<<endl;
 
 
	return 0;
}

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

typedef long long int ll;
typedef unsigned long long int ull;

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

using namespace std;

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

  cout << n - k + 1 << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner scn = new Scanner(System.in);
		char[] S = scn.next().toCharArray(), T = scn.next().toCharArray();
		int A = scn.nextInt(), B = scn.nextInt();
		scn.nextLine();
		char[] U = scn.next().toCharArray();
		boolean a = true;
		for(int i = 0;i < S.length;i++) {
			a &= S[i] == U[i];
		}
		System.out.println((a)?(A-1) + " " + B:A + " " + (B-1));
	}

}

Measured memory_bytes: 22608
#include<iostream>
#include<cstdlib>
#include<stack>

using namespace std;


/*
int top, S[1000];
void push(int x);
int pop();


int main() {
	int a, b;
	top = 0;
	char s[100];

	int t = 0;

	while (cin >> s) {
		if (s[0] == '+') {
			a = pop();
			b = pop();
			push(a + b);
		}
		else if (s[0] == '-') {
			a = pop();
			b = pop();
			push(a - b);
		}
		else if (s[0] == '*') {
			a = pop();
			b = pop();
			push(a * b);
		}
		else {
			push(atoi(s));
		}
	}

	cout << pop() << endl;

	return 0;
}

void push(int x) {
	S[++top] = x;
}

int pop() {
	top--;
	return S[top + 1];
}


*/

int main() {
	stack<int> st;
	char s[10];
	int a = 0, b = 0;
	while (cin >> s) {
		if (s[0] == '+') {
			a = st.top(); st.pop();
			b = st.top(); st.pop();
			st.push(a + b);
		}
		else if (s[0] == '-') {
			a = st.top(); st.pop();
			b = st.top(); st.pop();
			st.push(b - a);
		}
		else if (s[0] == '*') {
			a = st.top(); st.pop();
			b = st.top(); st.pop();
			st.push(a * b);
		}
		else {
			st.push(atoi(s));
		}
	}
	cout << st.top() << endl;
	return 0;
}


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

const int N = 330000;

int a[N], sum[N], prv[N], nxt[N];

int main() {
	
	ios::sync_with_stdio(0);
	cin.tie(0), cout.tie(0);
	
	int n; cin >> n;
	for (int i = 1; i <= n; i++) cin >> a[i], sum[i] = sum[i - 1] + (a[i] == i);
	for (int i = 1; i <= n; i++) {
		if (a[i] == i) {
			if (i - 2 >= 1 && a[i - 1] != i - 1 && a[i - 2] == i - 2) prv[i] = prv[i - 2];
			else prv[i] = i;
		}
	}
	for (int i = n; i >= 1; i--) {
		if (a[i] == i) {
			if (i + 2 <= n && a[i + 1] != i + 1 && a[i + 2] == i + 2) nxt[i] = nxt[i + 2];
			else nxt[i] = i;
		}
	}
	
	auto good = [&]() {
		for (int i = 1; i <= n; i++) if (a[i] != i) {
			int l = min(a[i], i), r = max(a[i], i);
			if ((r - l) & 1) return false;
			if (sum[r] - sum[l - 1] != (r - l) / 2) return false;
			if (a[l + 1] != l + 1) return false;
			if (a[r - 1] != r - 1) return false;
			if (nxt[l + 1] < r - 1) return false;
		}
		vector<pair<int, int>> V;
		for (int i = 1; i <= n; i++) if (a[i] > i) V.emplace_back(min(a[i], i), max(a[i], i));
		int Max = 0;
		for (auto it : V) {
			if (it.second < Max) return false;
			Max = max(Max, it.second);
		}
		V.clear();
		for (int i = 1; i <= n; i++) if (a[i] < i) V.emplace_back(min(a[i], i), max(a[i], i));
sort(V.begin(), V.end());
		Max = 0;
		for (auto it : V) {
			if (it.second < Max) return false;
			Max = max(Max, it.second);
		}
		return true;
	};
	
	cout << (good() ? "Yes" : "No") << "\n";
	
	return 0;
}

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

int main(){
	int k;
	scanf("%d", &k);
	int n = (k+3)/4*2;
	printf("%d\n", n);
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			int t = ((i+j)%n+1)*2 - i%2;
			if(k%4 == 1 && t >= k-1) t--;
			if((k%4 == 1 || k%4 == 2) && t >= k) t--;
			if(k%4 != 0 && t >= k+1) t--;
			if(k == 1) t = 1;
			printf("%d", t);
			printf("%s", j == n-1 ? "\n" : " ");
		}
	}
}

Measured memory_bytes: 1152
/**
 * C++ による参考実装
 */

#include <bits/stdc++.h>

using namespace std;

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

int H, W;
vector<vector<int>> M;

void solve() {
    int ans = 0;
    REP(y, H) REP(x, W) {
        if(M[y][x] == 1) {
            M[y][x] = 0;
        }
        else if(y == 0 || x == 0) {
            M[y][x] = 1;
        }
        else {
            M[y][x] = 1 + min({ M[y-1][x-1], M[y-1][x], M[y][x-1] });
        }

        ans = max(ans, M[y][x]);
    }
    ans *= ans;

#if 0
    REP(y, H) {
        REP(x, W) {
            cout << M[y][x] << " ";
        }
        cout << "\n";
    }
#endif
    cout << ans << "\n";
}

signed main() {
    cin >> H >> W;
    M.assign(H, vector<int>(W, 0));
    REP(y, H) REP(x, W) {
        cin >> M[y][x];
    }

    solve();

    return 0;
}



Measured memory_bytes: 10452
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
const int N=1e5+4;
bool f=true;
int n,mx;
int main() {
	scanf("%d",&n);
	for (register int i=1;i<=n;++i) {
		int cur;
		scanf("%d",&cur);
		if (mx-cur>1) {
			f=false;
			break;
		}
		mx=max(mx,cur);
	}
	puts(f?"Yes":"No");
	return 0;
}

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

typedef long long LL;

template<typename T>
void printmatrix(vector<vector<T> > ar){
    for (int i = 0; i < (int)ar.size(); i++) {
        for (int j = 0; j < (int)ar.size(); j++) {
            cout << ar[i][j];
        }
        cout << endl;
    }
}

template<typename T>
void printvector(vector<T> vec){
    for (int i = 0; i < (int)vec.size(); i++) {
        cout << vec[i] << endl;
    }
}

template<typename T>
void unique(vector<T>& vec){
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
}

template<typename T>
vector<T> cumsum(vector<T> vec){
    vector<T> newvec((T)vec.size());
    int tmp = 0;
    for (int i = 0; i < (int)vec.size(); i++) {
        tmp += vec[i];
        newvec[i] = tmp;
    }

    return newvec;
}


int main(int argc, char const* argv[])
{
    int a,b,c;
    cin >> a >> b >> c;
    if (a == b) {
        cout << c << endl;
    } else if (b == c){
        cout << a << endl;
    }else{
        cout << b << endl;
    }
    return 0;
}

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

int stone[100005];
int dp[100005];
int n;
int frog(int pos){
	if(dp[pos]!=-1)return dp[pos];
	if(pos==n-2)return abs(stone[pos]-stone[pos+1]);
	if(pos==n-1)return 0;
	int a=abs(stone[pos]-stone[pos+1])+frog(pos+1);
	int b=abs(stone[pos]-stone[pos+2])+frog(pos+2);
	dp[pos]=min(a,b);
	return dp[pos];
}

int main() {	
	memset(dp,-1,sizeof(dp));
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>stone[i];
	}
	cout<<frog(0);
	return 0;
}

Measured memory_bytes: 4096
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n;
  cin >> n;
  vector<int> f(1000000);
  for (int x = 1; x <= 100; ++x) {
    for (int y = 1; y <= 100; ++y) {
      for (int z = 1; z <= 100; ++z) {
        f[x * x + y * y + z * z + x * y + y * z + z * x]++;
      }
    }
  }
  for (int i = 1; i <= n; ++i) {
    cout << f[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 7188
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update

using namespace std;
using namespace __gnu_pbds;

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update>
ordered_set;	

#define FOR(i,a,b) for(int i = (a); i <= (b); ++i)
#define FORD(i,a,b) for(int i = (a); i >= (b); --i)
#define RI(i,n) FOR(i,1,(n))
#define REP(i,n) FOR(i,0,(n)-1)
#define mini(a,b) a=min(a,b)
#define maxi(a,b) a=max(a,b)
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define sz(w) (int) w.size()
typedef vector<int> vi;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<pii, int> para;
const ll inf = 1e18 + 7;
const ll maxN = 1e6 + 5;
const ll MOD = 1e9 + 7;

template<typename T>
struct SegmentTree {
	
	SegmentTree(int _n) : n(_n) { 
		t.resize(n * 4); 
	}
	
	SegmentTree(vector<T>& a) {
		n = (int)a.size();
		t.resize(4 * n);
		build(a, 1, 1, n);
	}
	
	int n;
	vector<T> t;
	
	void build(vector<T>& a, int v, int tl, int tr) {
	    if (tl == tr) {
	        t[v] = a[tl - 1];
	    } else {
	        int tm = (tl + tr) / 2;
	        build(a, v*2, tl, tm);
	        build(a, v*2+1, tm+1, tr);
	        t[v] = t[v*2] + t[v*2+1];
	    }
	}
	
	T query(int l, int r) {
		assert(l >= 1 && r <= n && l <= r);
		return _query(1, 1, n, l, r);
	}
	
	T _query(int v, int tl, int tr, int l, int r) {
	    if (l > r) 
	        return 0;
	    if (l == tl && r == tr) {
	        return t[v];
	    }
	    int tm = (tl + tr) / 2;
	    return _query(v*2, tl, tm, l, min(r, tm))
	           + _query(v*2+1, tm+1, tr, max(l, tm+1), r);
	}
	
	void update(int pos, T new_val) {
		assert(pos >= 1 && pos <= n);
		_update(1, 1, n, pos, new_val);
	}
	
	void _update(int v, int tl, int tr, int pos, T new_val) {
	    if (tl == tr) {
	        t[v] += new_val;
	    } else {
	        int tm = (tl + tr) / 2;
	        if (pos <= tm)
	            _update(v*2, tl, tm, pos, new_val);
	        else
	            _update(v*2+1, tm+1, tr, pos, new_val);
	        t[v] = t[v*2] + t[v*2+1];
	    }
	}
};

int main() {
	ios_base::sync_with_stdio(0);
	int n, q;
	cin >> n >> q;
	SegmentTree<int> s(n);
	REP(_, q) {
		int t, x, y;
		cin >> t >> x >> y;
		if (t == 0) {
			s.update(x, y);
		} else {
			cout << s.query(x, y) << "\n";
		}
	}
	return 0;
}


Measured memory_bytes: 4424
#include <cstdio>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

#define R register
#define ll long long
const int MAXN=1e5+10;

int n;
ll D[MAXN];
int siz[MAXN];
map<ll,int> loc;
set<ll> st;

struct edge
{
	int fr,to,next;
}e[MAXN<<1];
int tot;
int head[MAXN];
int dep[MAXN];

inline void add(int x,int y)
{
	tot++;
	e[tot].fr=x;e[tot].to=y;e[tot].next=head[x];head[x]=tot;
}

inline void dfs(int x,int fx)
{
	dep[x]=dep[fx]+1;
	for(R int i=head[x];i;i=e[i].next)
	{
		int y=e[i].to;
		if(y==fx) continue;
		dfs(y,x);
	}
}

int main()
{
	scanf("%d",&n);
	for(R int i=1;i<=n;i++) 
	{
		scanf("%lld",&D[i]);
		siz[i]=1;
		loc[D[i]]=i;
		st.insert(D[i]);
	}
	int rt=0,cnt=0;
	while(st.size()&&cnt<n-1)
	{
		ll dx=*st.rbegin(),dy;
		int x,y;
		st.erase(dx);
		x=loc[dx];
		dy=dx+siz[x]*2-n;
		y=loc[dy];
		if(y==0) {printf("-1\n");return 0;}
		siz[y]+=siz[x];
		add(x,y);add(y,x);
		cnt++;
	}
	rt=loc[*st.begin()];
	dfs(rt,0);
	ll ans=0;
	for(R int i=1;i<=n;i++) ans+=dep[i];
	if(ans-n!=D[rt]) {printf("-1\n");return 0;}
	
	for(R int i=1;i<=tot;i+=2)
	{
		int x=e[i].fr,y=e[i].to;
		if(x>y) swap(x,y);
		printf("%d %d\n",x,y);
	}
	return 0;
}

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

int main() {
	string a;
	cin >> a;
	int flg = 0;
	for (int i = 0; i < a.size(); i++) {
		if (a[i] >= '0'&&a[i] <= '9') {
			if (!(flg & 1))flg += 1;
		}
		if (a[i] >= 'a'&&a[i] <= 'z') {
			if (!(flg & 2))flg += 2;
		}
		if (a[i] >= 'A'&&a[i] <= 'Z') {
			if (!(flg & 4))flg += 4;
		}
	}
	if (a.size() >= 6)flg += 8;
	if (flg == 15)cout << "VALID" << endl;
	else cout << "INVALID" << endl;
	return 0;
}

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

// constexpr long MOD = 998244353;
constexpr long MOD = 1000000007;
vector<long> fact, inv;

long mpow(long a, long b) {
  long res = 1;
  while (b > 0) {
    if (b & 1) res = res * a % MOD;
    a = a * a % MOD;
    b /= 2;
  }
  return res;
}

void init(int n) {
  fact.push_back(1);
  inv.push_back(1);
  for (int i = 0; i < n; i++) {
    fact.push_back(fact.at(i) * (i + 1) % MOD);
    inv.push_back(mpow(fact.at(i + 1), MOD - 2));
  }
}

long qcom(long n, long r) {
  if (n - r < 0) return 0;
  return fact.at(n) * inv.at(r) % MOD * inv.at(n - r) % MOD;
}

long com(long n, long r) {
  long x = 1, y = 1;
  for (int i = 1; i <= r; i++) {
    x = x * (n - i + 1) % MOD;
    y = y * i % MOD;
  }
  return x * mpow(y, MOD - 2) % MOD;
}

int main() {
  int N, K;
  cin >> N >> K;
  init(510000);
  vector<int> A(N);
  for (int i = 0; i < N; i++) cin >> A.at(i);
  sort(A.begin(), A.end());
  long ans = 0;
  for (int i = 0; i + 1 < N; i++) {
    ans += (qcom(N, K) - qcom(i + 1, K) - qcom(N - i - 1, K)) * (A.at(i + 1) - A.at(i));
    ans %= MOD;
  }
  while (ans < 0) ans += MOD;
  cout << ans << "\n";
}

Measured memory_bytes: 10336
#include<stdio.h>
int main()
{
    int S;
    scanf("%d",&S);
    int h,m,s;
    h=S/3600;
    m=(S%3600)/60;
    s=(S%3600)%60;
    scanf("%d %d %d",&h,&m,&s);
    printf("%d:%d:%d\n",h,m,s);
    return 0;
}


Measured memory_bytes: 2740
n, h = map(int, input().split())
arr = []
for _ in range(n) :
    a,b = map(int, input().split())
    arr.append((a,-1))
    arr.append((b,1))

arr.sort()
arr.reverse()

cnt = 0
ans = 10**9 + 100
for p in arr :
    if p[1] == -1 :
        # a
        ans = min(ans, cnt + (h+p[0]-1)//p[0])
        break
    elif p[1] == 1 and h>0 :
        # b
        h -= p[0]
        cnt += 1
        if h <= 0 :
            h = 0
            ans = min(ans, cnt)

print(ans)


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

int n;
vector<int> A(100000),L(100000);

int lis(){
    L[0]=A[0];
    int length=1;
    for(int i=0;i<n;i++){
        if(L[length-1]<A[i]){
            L[length++]=A[i];
        }
        else{
            *lower_bound(L.begin(),L.begin()+length,A[i])=A[i];
        }
    }
    return length;
}

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

    cout<<lis()<<endl;
}


Measured memory_bytes: 3452
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const ll MOD = 1000000007;

vector<vector<ll>> dp(13, vector<ll>(100001, 0));

int main() {
	string S, st;
	cin >> S;
	int ss = S.size();
	dp[0][ss] = 1;
	int d = 1, g;
	for (int i = ss - 1;i >= 0;i--) {
		d %= 13;
		if (S[i] == '?') {
			for (int j = 13;j < 26;j++) {
				for (int k = 0;k < 10;k++) {
					g = (k*d) % 13;
					dp[j - 13][i] += dp[(j - g) % 13][i + 1];
				}
				dp[j - 13][i] %= MOD;
			}
		}
		else {
			st = S[i];
			g = (stoi(st)*d) % 13;
			for (int j = 13;j < 26;j++) {
				dp[j - 13][i] = dp[(j - g) % 13][i + 1];
				dp[j - 13][i] %= MOD;
			}
		}
		d *= 10;
	}
	cout << dp[5][0] << endl;
}

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


int main(void){
    int N; cin >> N;
    vector<int> T(N);
    int sum=0;
    for(int i=0; i<N; i++){
        cin>>T[i];
        sum+=T[i];
    }
    int M; cin >> M;

    for(int i=0; i<M; i++){
        int p,x;
        cin >> p >> x;
        cout << sum-T[p-1]+x << endl;
    }

    return 0;
}

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

int main() {
  int H,W,i=0,j=0;
  cin >> H >> W;
  vector<char> a(W);
  
  for (i=0;i<W+2;i++){
    cout << "#";
  }
  cout << endl;
  for (i=0;i<H;i++){
    for (j=0;j<W;j++){
      cin >> a[j];
      if(j==0){
        cout << "#";
      }
      cout << a[j];
      if(j==W-1){
        cout << "#" << endl;
      }
    }
  }
  for (i=0;i<W+2;i++){
    cout << "#";
  }
  cout << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int i,j,N;
    int a[10][10]={};
    int flag=0;
    for(i=1;i<=9;i++){
        for(j=1;j<=9;j++){
            a[i][j] = i*j;
        }
    }
    scanf("%d",&N);
    for(i=1;i<=9;i++){
        for(j=1;j<=9;j++){
            if(a[i][j]==N) flag = 1;
        }
    }

    if(flag==0) printf("No\n");
    else printf("Yes\n");

    return 0;
}


Measured memory_bytes: 128
import java.util.Scanner;

public class Main {

    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        for(int i = 0;i < 3000;++i){
            int a = sc.nextInt(),b = sc.nextInt();
            if(a == 0 && b == 0) break;
            System.out.printf("%d %d\n",a < b ? a : b,a < b ? b : a);
        }
        sc.close();
    }

}

Measured memory_bytes: 39636
// Problem : A - ∴ (Therefore)
// Contest : AtCoder - AtCoder Beginner Contest 168
// URL : https://atcoder.jp/contests/abc168/tasks/abc168_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;

#ifdef LOCAL
#define DEBUG(...) debug(#__VA_ARGS__, __VA_ARGS__);
#else
#define DEBUG(...)
#endif

template<typename T, typename S> ostream& operator << (ostream &os, const pair<T, S> &p) {return os << "(" << p.first << ", " << p.second << ")";}
template<typename C, typename T = decay<decltype(*begin(declval<C>()))>, typename enable_if<!is_same<C, string>::value>::type* = nullptr>
ostream& operator << (ostream &os, const C &c) {bool f = true; os << "["; for (const auto &x : c) {if (!f) os << ", "; f = false; os << x;} return os << "]";}
template<typename T> void debug(string s, T x) {cerr << s << " = " << x << "\n";}
template<typename T, typename... Args> void debug(string s, T x, Args... args) {cerr << s.substr(0, s.find(',')) << " = " << x << " | "; debug(s.substr(s.find(',') + 2), args...);}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    
    int n;
    cin >> n;
    n %= 10;
    
    if (n == 3)
        cout << "bon\n";
    else if (n == 0 || n == 1 || n == 6 || n == 8)
        cout << "pon\n";
    else
        cout << "hon\n";

    return 0;
}


Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define int long long
#define _GLIBCXX_DEBUG

signed main() {
  int A, B, C, D; cin >> A >> B >> C >> D;
  while(true) {
    C-=B;
    if(C<=0) {
      cout << "Yes" << endl;
      return 0;
    }
    A-=D;
    if(A<=0) {
      cout << "No" << endl;
      return 0;
    }
  }

}


Measured memory_bytes: 3600
#include <iostream>

using namespace std;
int i,j,minj,count,box;

void selert_sort(int n,int a[]){
    for(i = 0;i <= n - 1;i++){
        minj = i;
        for(j = i;j <= n - 1;j++){
            if(a[j] < a[minj]){
                minj = j;
            }
        }
        
        if(i != minj){
            box = a[i];
            a[i] = a[minj];
            a[minj] = box;
            count++;
        }
    }
}

int main() {
    int n,a[100];

    cin >> n;

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

    selert_sort(n,a);

    for(i = 0;i < n - 1;i++){
        cout << a[i] << ' ';
    }
    cout << a[i] << endl << count << endl;

    return 0;
}

Measured memory_bytes: 1160
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ALDS1_6_D
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int n = ReadInt();
            int[] line = ReadIntAr();
            Console.WriteLine(SillySort(line).ToString());
        }

        public struct node { public int value; public int place; }
        public static int SillySort(int[] seq)
        {

            int cost = 0, s;
            node[] nodes = new node[seq.Count()];
            node[] tmp = new node[seq.Count()];

            for (int i = 0 ; i < seq.Count() ; i++) { tmp[i].value = seq[i]; tmp[i].place = i; }
            tmp = tmp.OrderBy(x => x.value).ToArray<node>();
            for (int i = 0 ; i < seq.Count() ; i++) { nodes[i].value = seq[i]; nodes[tmp[i].place].place = i; }
            s = tmp[0].value;

            for (int i = 0 ; i < seq.Count() ; i++)
            {
                int j = nodes[i].place;
                if (j >= 0 && j != i)
                {
                    int n = 1, sum, amin;
                    amin = sum = nodes[i].value;
                    while (j != i)
                    {
                        int next = nodes[j].place;
                        amin = Math.Min(amin, nodes[j].value);
                        sum += nodes[j].value;
                        n++;
                        nodes[j].place = -1;
                        j = next;
                    }
                    cost += Math.Min(sum + ((n - 2) * amin), sum + amin + (n + 1) * s);
                }
            }

            return cost;
        }


        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }

    }

}



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

const int SIZ = 4010, MAXN = 1e5 + 5;

int pref1[SIZ][SIZ], pref2[SIZ][SIZ], numBlack;
int n, k, x[MAXN], y[MAXN];
string c[MAXN];
int ans;

int getBlock1(int l, int d, int r, int u){
	int sum = pref1[r][u];
	if(l > 0){
		sum -= pref1[l-1][u];
	}
	if(d > 0){
		sum -= pref1[r][d-1];
	}
	if(l > 0 && d > 0){
		sum += pref1[l-1][d-1];
	}
	return sum;
}

int getBlock2(int l, int d, int r, int u){
	int sum = pref2[r][u];
	if(l > 0){
		sum -= pref2[l-1][u];
	}
	if(d > 0){
		sum -= pref2[r][d-1];
	}
	if(l > 0 && d > 0){
		sum += pref2[l-1][d-1];
	}
	return sum;
}

int main(){
	cin >> n >> k;
	// k *= 2;
	for(int i = 0; i < n; ++i){
		cin >> x[i] >> y[i] >> c[i];
		if(c[i][0] == 'B'){
			pref1[(x[i]%(2*k)) + k][(y[i]%(2*k)) + k]++;
		}else{
			pref2[(x[i]%(2*k)) + k][(y[i]%(2*k)) + k]++;
		}
	}
	// k /= 2;
	for(int i = 0; i < SIZ; ++i){
		for(int j = 0; j < SIZ; ++j){
			if(i){
				pref1[i][j] += pref1[i-1][j];
				pref2[i][j] += pref2[i-1][j];
			}
			if(j){
				pref1[i][j] += pref1[i][j-1];
				pref2[i][j] += pref2[i][j-1];
			}
			if(i && j){
				pref1[i][j] -= pref1[i-1][j-1];
				pref2[i][j] -= pref2[i-1][j-1];
			}
		}
	}
	for(int i = k; i < 2*k; ++i){
		for(int j = k; j < 2*k; ++j){
			int sum1 = 0, sum2 = 0;
			for(int p = -1; p <= 1; p++){
				for(int q = -1; q <= 1; q++){
					if((p+q+5)%2 == 0){
						sum1 += getBlock1(i+p*k, j+q*k, i+p*k+k-1, j+q*k+k-1);
						sum2 += getBlock2(i+p*k, j+q*k, i+p*k+k-1, j+q*k+k-1);
					}else{
						sum2 += getBlock1(i+p*k, j+q*k, i+p*k+k-1, j+q*k+k-1);
						sum1 += getBlock2(i+p*k, j+q*k, i+p*k+k-1, j+q*k+k-1);
					}
				}
			}
			// printf("(%d, %d) = %lld %lld\n", i-k, j-k, sum1, sum2);
			ans = max(ans, max(sum1, sum2));
		}
	}
	printf("%d\n", ans);
}

Measured memory_bytes: 132096
#include<bits/stdc++.h>
using namespace std;
long long k;
long long a[55];
int main() {
	scanf("%lld",&k);
	if(k==0) {
		puts("3");
		puts("2 2 2");
		return 0;
	}
	puts("50");
	for(int i=1;i<=50;i++) {
		a[i]=i+k/50-1;
	}
	k=k%50;
	for(int i=1;i<=k;i++) {
		a[i]+=50;
		for(int j=1;j<=50;j++) {
			if(i==j)
				continue;
			a[j]--;
		}
	}
	for(int i=1;i<=50;i++) {
		printf("%lld ",a[i]);
	}
	puts("");
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
#include<queue>
#include<vector>
#include<map>
#include<string>
using namespace std;
#define rep2(x,from,to) for(int x=from;x<to;x++)
#define rep(x,to) rep2(x,0,to)
int h,a;
int main()
{
    cin>>h>>a;
    int k=h/a;
    if(h%a!=0)k++;
    cout<<k<<endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		String[] suits = new String[] {"S", "H", "C", "D"};
		boolean[][] cards = new boolean[4][13];
		Scanner sc = new Scanner(System.in);
		String str;
		String[] strs = new String[2];
		int s = 0;

		int n = Integer.parseInt( sc.nextLine() );

		for (int i = 0; i < n; i++) {

			str = sc.nextLine();
			strs = str.split(" ");

			String suit = strs[0];
			int num = Integer.parseInt(strs[1]);

			switch(suit) {
				case "S":
					s = 0;
					break;
				case "H":
					s = 1;
					break;
				case "C":
					s = 2;
					break;
				case "D":
					s = 3;
					break;
				default:
					break;
			}

			cards[s][num - 1] = true;
		}



		for (int i = 0; i < 4; i++) {
			for (int j = 0; j < 13; j++) {
				if( cards[i][j] == false) {
					System.out.println(suits[i] + " " + (j+1));
				}
			}
		}

		sc.close();
	}


}


Measured memory_bytes: 26220
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<utility>
#include<set>
#include<stack>
#include<list>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cstring>
#include<sstream>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<cmath>
#include<cctype>


#define pb push_back
#define mp make_pair
#define rep(i,a,b) for(int i=a;i<=b;i++)
#define ren(i,a,b) for(int i=a;i>=b;i--)
#define ff first
#define ss second
#define pll pair<long long int,long long int>
#define pii pair<int,int>
#define vll vector<long long int>
#define vii vector<int>
#define gi(n) scanf("%d",&n)
#define gll(n) scanf("%lld",&n)
#define gstr(n) scanf("%s",n)
#define gl(n) cin >> n
#define oi(n) printf("%d",n)
#define oll(n) printf("%lld",n)
#define ostr(n) printf("%s",n)
#define ol(n) cout << n
#define os cout<<" "
#define on cout<<"\n"
#define o2(a,b) cout<<a<<" "<<b
#define all(n) n.begin(),n.end()
#define present(s,x) (s.find(x) != s.end())
#define cpresent(s,x) (find(all(s),x) != s.end())
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;

typedef unsigned long long int ull;
typedef long long int ll;
typedef vector<vector<ll> > mat;

ll x[100005],a[100005],n,m,k,dis[100005],per[100005],tmp[100005];

int main()
{ios_base::sync_with_stdio(false);
cin>>n;
rep(i,1,n)cin>>x[i];
cin>>m>>k;
rep(i,1,n-1)dis[i]=x[i+1]-x[i],per[i]=i;
rep(i,1,m)
{
	cin>>a[i];
	swap(per[a[i]-1],per[a[i]]);
}

while(k)
{
	if(k%2)
	{
		rep(i,1,n-1)tmp[i]=dis[per[i]];
		rep(i,1,n-1)dis[i]=tmp[i];
	}
	rep(i,1,n-1)tmp[i]=per[per[i]];
	rep(i,1,n-1)per[i]=tmp[i];
	k/=2;
}

ll s=x[1];

rep(i,1,n)
{
	ol(s);on;
	s+=dis[i];
}

return 0;
}


Measured memory_bytes: 5120
using System;

class MyClass
{
    public static void Main(string[] args)
    {
        var input = Console.ReadLine().Split();
        var x1 = double.Parse(input[0]);
        var y1 = double.Parse(input[1]);
        var x2 = double.Parse(input[2]);
        var y2 = double.Parse(input[3]);
        var d = Math.Sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
        Console.WriteLine(d.ToString("F8"));
    }
}


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

int num[4];
string names[]={
    "AC",
    "WA",
    "TLE",
    "RE"
};

int main(){
    int price=0;
    int N=0;
    cin>>N;
    for(int i=0;i<N;i++){
        string input="";
        cin>>input;
        for(int j=0;j<4;j++){
            if(names[j]==input){
                num[j]++;
            }
        }
    }
    for(int i=0;i<4;i++){
        cout<<names[i]<<" x "<<num[i]<<endl;
    }
}

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

char incrementChar(char x){
    return static_cast<char>(x + 1);
}

int weekToInt(string x){
    int num;
    if(x == "SUN"){
        num = 1;
    }else if(x == "MON"){
        num = 2;
    }else if(x == "TUE"){
        num = 3;
    }else if(x == "WED"){
        num = 4;
    }else if(x == "THU"){
        num = 5;
    }else if(x == "FRI"){
        num = 6;
    }else if(x == "SAT"){
        num = 7;
    }else{
        num = 0;
    }

    return num;
}

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

    cout << r * r << endl;

    return 0;
}


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFやMODの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const ll MOD = 1000000007;

int main() {
  ll n, m;
  cin >> n >> m;
  string s, t;
  cin >> s >> t;

  ll g = __gcd(n, m);
  bool f = true;
  rep(i, g) {
    if (s[n / g * i] != t[m / g * i]) {
      f = false;
      break;
    }
  }

  cout << (f ? n * m / g : -1) << endl;
}


Measured memory_bytes: 512
import java.util.*;
class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int H=sc.nextInt();
        int W=sc.nextInt();
        int h=sc.nextInt();
        int w=sc.nextInt();
        
        if(H==h && W==w) {
            System.out.println(0);
        } else {
            System.out.println((H-h) * (W-w));
        }
    }
}

Measured memory_bytes: 23636
#define _CRT_SECURE_NO_WARNINGS
#pragma GCC optimize(3)
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma comment(linker, "/stack:200000000")
#include <bits/stdc++.h>
#define SIZE 300010
#define rep(i, a, b) for (int i = a; i <= b; ++i)
#define ll long long
#define mp make_pair
#define pi acos(-1.0)
using namespace std;
void io() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); }
ll n, a, b;
int main() {
	io(); cin >> n >> a >> b;
	if (a == b) cout << 0;
	else if (abs(b - a) % 2 == 0) cout << abs(b - a) / 2;
	else {
		ll opt1 = 0, opt2 = 0;
		const ll nafter = abs(a - b) / 2;
		opt1 = (min(a, b) - 1) + 1 + nafter;
		opt2 = (n - max(a, b)) + 1 + nafter;
		cout << min(opt1, opt2) << "\n";
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <limits>

using namespace std;
typedef long long int ll;
void sayYes() { cout << "Yes" << endl; };
void sayNo() { cout << "No" << endl; };
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }                   // 最大公約数
ll lcm(ll a, ll b) { return a * b / gcd(a, b); };                      // 最小公倍数
ll getDigit(ll num) { return log10(num) + 1; }                         // 桁数
ll digitSum(ll n) { return (n < 10) ? n : digitSum(n / 10) + n % 10; } // 各桁の和
#define rep(i, n) for (ll i = 0; i < n; i++)

void Main()
{
    // int n;
    // cin >> n;
    // vector<int> a(n);
    // rep(i, n)
    // {
    //     cin >> a[i];
    // }
    ll x;
    cin >> x;
    ll ans = 100;
    int i = 0;

    while (1)
    {
        if (ans >= x)
            break;
        ans = ans * 1.01;
        i++;
    }

    cout << i << endl;

    return;
}

signed main(void)
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


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

int n;
ll a, ans;
map<ll, ll> L, R;

void solve(){
    ans = 0;
    map<ll, ll>::iterator it;
    for(it = L.begin(); it != L.end(); it++){
        pair<ll, ll> p = *it;
        if(R.find(p.first) == R.end()) continue;
        ans += p.second * R.find(p.first)->second;
    }
    cout << ans << endl;
}

int main(){
    cin >> n;
    for(int i = 1; i <= n; i++){
        cin >> a;
        if(L.find(i + a) == L.end()) {
            L.insert(make_pair(a + i, 1));
        }else {
            L.find(i + a)->second++;
        }
        if(R.find(i - a) == R.end()) {
            R.insert(make_pair(i - a, 1));
        }else {
            R.find(i - a)->second++;
        }
    }
    solve();
    return 0;
}

Measured memory_bytes: 26604
#include<stdio.h>
#include<stdlib.h>
 
struct node{
  struct node *r;
  struct node *l;
  struct node *parent;
  int key;
};
typedef struct node * Node;
 
Node root, NIL;
 
void insert(int);
void inorder(Node);
void preorder(Node);
Node treeSearch(Node, int);
 
int main(){
   
  int n, i, x;
  char com[10];
   
  scanf("%d", &n);
   
  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
 
    if ( strcmp(com, "insert") == 0 ){
      scanf("%d", &x);
      insert(x);
    }
    else if ( strcmp(com, "print") == 0 ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
    else if ( strcmp(com, "find") == 0 ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    }
  }
  return 0;
}
 
void insert(int k){
  int H;
  Node y = NIL;
  Node x = root;
  Node z;
   
  z = malloc(sizeof(struct node));
  z->key = k;
  z->l = NIL;
  z->r = NIL;
   
  while( x != NIL ){
    y = x;
    if ( z->key < x->key ){
      x = x->l;
    } else {
      x = x->r;
    }
  }
   
  z->parent = y;  
  if ( y == NIL ){
    root = z;
  }
  else if (z->key < y->key) {
    y->l = z;
  }
  else {
    y->r = z;
  }
}
 
void inorder(Node u){
  if ( u == NIL ) return;
  inorder(u->l);
  printf(" %d", u->key);
  inorder(u->r);
}
 
void preorder(Node u){
  if ( u == NIL ) return;
  printf(" %d", u->key);
  preorder(u->l);
  preorder(u->r);
}
 
Node treeSearch(Node x, int k){
  while( x != NIL && k != x->key ){
    if ( k < x->key ) x = x->l;
    else x = x->r;
  }
  return x;
}

Measured memory_bytes: 19364
n,m=map(int, input().split())
alist=[]
for i in range(m):
  a,b=map(int, input().split())
  alist.append([a,b])
  alist.append([b,a])
ans=0
import itertools
t=[i for i in range(1,n+1)]
blist=list(itertools.permutations(t,n))
ans=0
for i in blist:
  flag=True
  for j in range(n-1):
    if [i[j],i[j+1]] not in alist:
      flag=False
  if i[0]!=1:
      flag=False
  if flag:
    ans+=1
print(ans)

Measured memory_bytes: 13840
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <stdio.h>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);++i)
#define urep(i,a,n) for(ll i = (a);i>=(n);--i)
#define all(x) (x).begin(),(x).end()
#define INF 1e18
const int mod = 1e9 + 7;
typedef long long ll;
using namespace std;
ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };
ll N,M,X,Y,A,B,C,Q,K,R,W,H,P;
string S,T;
ll ans;
ll x[1000000];
ll y[1000000];
ll a[1000000];
ll b[1000000];
ll c[1000000];
ll t[1000000];
string s[10000];
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}
struct Edge{
	ll to,cost;
	 Edge(int to, int cost) : to(to), cost(cost) {}
};
typedef vector<vector<Edge> > AdjList;
AdjList graph;
vector<ll> dist;
int main() {
	cin>>N;
	rep(i,0,N){
		cin>>a[i];
	}
	if(N==1){
		if(a[0]%2==0){
			cout<<"second"<<endl;
		}else{
			cout<<"first"<<endl;
		}
		return 0;
	}
	sort(a,a+N);
	ll num1=a[N-1];
	ll num2=a[N-2];
	if(num1==num2){
		for(int i=N-3;i>=0;i--){
			if(a[i]!=num1){
				num2=a[i];
			}
		}
	}
	if(num1%2==0 && num2%2==0){
		for(int i=N-3;i>=0;i--){
			if(a[i]!=num1 && a[i]!=num2){
				if(a[i]%2 ==1){
					cout<<"first"<<endl;
					return 0;
				}
			}
		}
		cout<<"second"<<endl;
	}else{
		cout<<"first"<<endl;
	}
	return 0;
}


Measured memory_bytes: 2432
#include <stdio.h>
//#include <string.h>

int main(void){
  int p, q, r = 0;
  scanf("%d %d %d", &p, &q, &r);

  if((p+q)<=(q+r) && (p+q)<=(p+r)) printf("%d", p+q);
  else if((r+q)<=(q+p) && (q+r)<=(p+r)) printf("%d", q+r);
  else if((p+r)<=(q+r) && (p+r)<=(p+q)) printf("%d", p+r);


  
  return 0;
}

  


Measured memory_bytes: 1700
#include <stdio.h>
#include <vector>
#include <map>
#include <string>
#include <iostream>
#include <limits.h>
#include <algorithm>
#include <cmath>
using namespace std;

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

    int X[10][10];

    for (int i = 0; i < N; i++)
    {
        for(int j = 0;  j < D;  j++) {
            cin >> X[i][j];
        }
    }

int count = 0;

    for (int i = 0; i < N; i++) {
     
    for (int k = 0; k < N; k++) {
        if (i == k) continue;
        double total = 0;

        for(int j = 0;  j < D;  j++) {
             total += pow(X[i][j] - X[k][j], 2);
        }
         total = sqrt(total);
         if (total == int(total)) {
             count ++;
         }
    }

    }
            cout << count  / 2<< endl;

    return 0;
}

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

int n, m;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

bool contains_square(int y, int x, vector<string> &A, vector<string> &B){
  if(y + m > n) return false;
  if(x + m > n) return false;
  for (int i = 0; i < m; i++){
    for (int j = 0; j < m; j++){
      if(A[y+i][x+j] != B[i][j]) return false;
    }
  }
  return true;
}

int main() {
  cin >> n >> m;
  bool ok = false;
  vector<string> A(n);
  rep(i, n) cin >> A[i];
  vector<string> B(m);
  rep(i,m) cin >> B[i];
  rep(i,n){
    rep(j,n){
      ok = contains_square(i, j, A, B);
      if(ok){
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;
}

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

int main()
{
    int iNum = 0;
    
    cin >> iNum;
    
    for (int i = 1; i <= iNum; i++)
    {
        int iTmp = i;
        if (0 == iTmp % 3)
        {
            cout << " " << i;
            continue;
        }
        else if (3 == iTmp % 10)
        {
            cout << " " << i;
            continue;
        }
        
        iTmp /= 10;
        while (iTmp)
        {
            if (3 == iTmp % 10)
            {
                cout << " " << i;
                break;
            }
            
            iTmp /= 10;
        }
    }
    
    cout << endl;
    
    return 0;
}



Measured memory_bytes: 3088
#include<bits/stdc++.h>
typedef long long ll;
ll gi(){
	ll x=0,f=1;
	char ch=getchar();
	while(!isdigit(ch))f^=ch=='-',ch=getchar();
	while(isdigit(ch))x=x*10+ch-'0',ch=getchar();
	return f?x:-x;
}
ll X[100010],P[100010];
int main(){
#ifdef XZZSB
	freopen("in.in","r",stdin);
	freopen("out.out","w",stdout);
#endif
	int n=gi(),S=gi();
	for(int i=1;i<=n;++i)X[i]=gi(),P[i]=gi();
	int l=1,r=n;ll ans=0,s;
	int o=-1;
	while(1ll*(S-X[l])*(S-X[r])<0){
		s=P[l]+P[r];
		if(P[l]<P[r]){
			if(o!=r)ans+=X[r]-X[l];
			P[o=r]=s,++l;
		}else{
			if(o!=l)ans+=X[r]-X[l];
			P[o=l]=s,--r;
		}
	}
	ans+=std::max(abs(S-X[l]),abs(S-X[r]));
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 1792