akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <queue>

using namespace std;

void bfs(vector<vector<int>> matrix) {
	
	//初期化
	//始点からの距離は1次元vectorで管理
	//始点から各頂点への距離をinf(-1)に設定
	int n = matrix.size();
	vector<int> d(n, -1);
	
	//始点をキューに入れる。始点の距離を0に
	queue<int> Q;
	Q.push(0);
	d.at(0) = 0;

	//以下ループ処理で距離の算出
	//キューが空になるまでこのループを回す
	while(! Q.empty()) {
		//キューの先頭の頂点を取り出す
		int head = Q.front();
		Q.pop();
		//その頂点から行ける点について-1なら
		for (int i = 0; i < matrix.at(0).size(); i++) {
			if (matrix[head][i] == 1 && d.at(i) == -1) {
				Q.push(i);
				d.at(i) = d.at(head) + 1;
			}
		}
	}

	// 表示
	for (int j = 0; j < d.size(); j++) {
		cout << j + 1 << " " << d.at(j) << endl;
	}
}

int main(void) {

	//標準入力を受け取る
	int n; //頂点数
	cin >> n;
	vector<vector<int>> matrix(n, vector<int>(n,0)); //隣接行列
	int u, k, v; //頂点番号、出次数、隣接する頂点番号
	for(int i = 0; i < n; i++) {
		cin >> u >> k;
		while(k--) {
			cin >> v;
			matrix.at(u-1).at(v-1) = 1; //有向グラフならこれだけ
			// matrix.at(v-1).at(u-1) = 1; //無向グラフなら反対向きも
		}
	}

	bfs(matrix);
	//
	// 隣接行列の表示
	// for(int i = 0; i < matrix.size(); i++) {
	//	 for(int j = 0 ;j < matrix.at(0).size(); j++) {
	//	 	cout << matrix.at(i).at(j) << " ";
	//	 }
	//	cout << endl;
	// }
}

//隣接リストどうやるの？



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

DP = [10 ** 10] * N
for i in range(N):
  if i == 0:
    DP[i] = 0
  elif i == 1:
    DP[i] = DP[i-1] + abs(H[i] - H[i - 1])
  else:
    DP[i] = min(DP[i -1] + abs(H[i] - H[i - 1]), DP[i - 2] + abs(H[i] - H[i - 2]))

#print(DP)
print(DP[-1])


Measured memory_bytes: 13924
#include <iostream>
#include <math.h>
#include <algorithm>
#include <string>
#include <string.h>
#include <queue>
#include <vector>
#include <set>
using namespace std;
int main() {
	int r, d, x,tmp=0;
	cin >> r >> d >> x;
	tmp = x;
	for (int i = 0; i < 10; i++)
	{
		cout << tmp*r - d << endl;
		tmp = tmp*r - d;
	}
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    LL n;
    cin>>n;
    LL ans = 0;
    FOR(i,1,n+1){
        if(i<10 || (100<=i && i<1000) || (10000<=i && i<100000))ans++;
    }
    PUTS(ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define INF 1000000000000
#define MOD 1000000007LL
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
#include <boost/multiprecision/integer.hpp>


template<typename T>
void invec(vector<T> &A){rep(i, 0, A.size()) cin >> A[i];}

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

int N; cin >> N;
VI A(N); invec(A);

i64 ans = 0;
rep(digit, 0, 60){//(int)log2(*max_element(ALL(A)))+ 1){
    i64 cnt1 = 0;
    rep(i, 0, N)
        if (A[i] & (1LL<<digit)) ++cnt1;
    (ans += (1LL<<digit) %MOD * cnt1 %MOD * (N - cnt1) %MOD) %= MOD;
}
cout << ans << endl;

}
// 書いて考える．場合分け
// 境界，出力文字列 チェック
// 可読性優先．高速化次点．
// まずは全探索，分割統治，次にDP
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり
// 実行エラー：vector添え字超え．0割り．



Measured memory_bytes: 2560
#include<iostream>
#include<cstdio>
#include<cstring>
using namespace std;
typedef long long ll;
inline ll read(){
    ll x=0,f=1;
    char c=getchar();
    while(c<'0'||c>'9'){
        if(c=='-')f=-1;
        c=getchar();
    }
    while(c>='0'&&c<='9'){
        x=(x<<3)+(x<<1)+c-'0';
        c=getchar();
    }
    return x*f;
}
ll n,ans;
void check(ll x){
	for(ll i=1;i*i<=x;++i){
		if(x%i==0){
			++ans;
			if(i*i!=x)++ans;
		}
	}
}
int main(){
	n=read();
	check(n-1);
	for(ll i=2;i*i<=n;++i){
		if(n%i==0){
			ll tmp=n;
			while(tmp%i==0)tmp/=i;
			if(tmp%i==1)++ans;
			if(i*i!=n){
				ll tmp=n;
				while(tmp%(n/i)==0)tmp/=(n/i);
				if(tmp%(n/i)==1)++ans;
			}
		}
	}
	cout<<ans<<endl;
//	getchar();
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <string>
using namespace std;
typedef double  dbl;
typedef long long int lld;
#define foi(i,n) for(i = 0; i < n; i+=1)
#define fod(i,n) for(i=n-1; i >=0; i-=1)
#define MAX std::numeric_limits<lld>::max()
#define MIN std::numeric_limits<lld>::min()
#define FastIO  ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main (){
    FastIO
    lld n, i;
    cin >> n;
    if (n % 2 == 0)
    	cout << n/2 + 0 << "\n";
    else
    	cout << n/2 + 1 << "\n";
    return 0;
}

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

int main(void){

    int N;
    long long T;

    scanf("%d%lld", &N, &T);

    long long t[N];

    for(int i = 0; i < N; i++){
        scanf("%lld", &t[i]);
    }

    long long ans = 0;

    for(int i = 1; i < N; i++){
        if(t[i-1] + T < t[i]){
            ans += T;
        }else{
            ans += t[i]-t[i-1];
        }
    }
    ans += T;

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

    return 0;
}

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

int main() {
    int a, b;
    std::cin >> a >> b;

    if ((a + b) % 2 == 0) {
        std::printf("%d\n", (a + b) / 2);
    } else {
        std::printf("%d\n", (int)((a + b) / 2.0 + 1.0));
    }
    return 0;
}


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

vector<vector<int>> f;
vector<bool> vis;

void dfs(int n,int &c){
	c++;
	vis[n]=true;
	for(auto x:f[n]){
		if(!vis[x]){
			dfs(x,c);
		}
	}
}


int main(){
	int n,m;cin>>n>>m;
	f.assign(n+1,vector<int>(0));
	vis.assign(n+1,false);
	int u,v;
	for(int i=0;i<m;i++){
		cin>>u>>v;
		f[u].push_back(v);
		f[v].push_back(u);
	}

	int c=0,k=0;

	for(int i=1;i<=n;i++){
		if(!vis[i]){
			dfs(i,k);
			c=max(c,k);
			k=0;
		}
	}
	cout<<c<<endl;
}

Measured memory_bytes: 23444
#include <iostream>

using namespace std;

int main() {
  int N;
  cin >> N;
  int a[100001];
  for (int i = 1; i <= N; i++) {
    cin >> a[i];
  }
  //cout << "==============" << endl;
  int count = 0;
  int next_index = 1;
  for (int i = 0; i < N; i++) {
    count++;
    if (a[next_index] == 2) {
      cout << count << endl;
      return 0;
    }
    next_index = a[next_index];
  }
  cout << -1 << endl;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define l_ength size
const int inf = (1<<30);
const int mod = 1000003;
using ll = long long;
using namespace std;

ll modPow(ll a, int n){
	ll res = 1;
	int i = 1;
	while( i <= n ) {
		if( n & i ){
			res *= a;
			res %= mod;
		}
		i <<= 1;
		a = a*a%mod;
	}
	return res;
}

ll mf[2000200];
ll dvf[2000200];

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int q; cin >> q;
	mf[0] = 1; dvf[0] = 1;
	for( int k = 1; k <= 2000100; ++k ){
		mf[k] = (k*mf[k-1]) % mod;
		dvf[k] = (modPow(k, mod-2)*dvf[k-1]) % mod;
	}
	while( q-- ){
		ll x, d, n; cin >> x >> d >> n;
		if( d == 0 ){
				cout << modPow(x, n) << endl;
				continue;
		}
		if( n >= mod ){
			cout << 0 << endl;
			continue;
		}
		if( d != 1 ){
			x = (x*modPow(d, mod-2))%mod;
		}
		cout << ( modPow(d, n) * ( mf[x+n-1]*dvf[x-1] % mod ) ) % mod << endl;
	}
	return 0;
}

Measured memory_bytes: 32128
H,W=map(int,input().split())
A=[list(map(int,input().split())) for i in range(H)]

ANSLIST=[]

for i in range(H):
    for j in range(W-1):
        if A[i][j]%2==1:
            ANSLIST.append((i,j,i,j+1))
            A[i][j]-=1
            A[i][j+1]+=1

for i in range(H-1):
    if A[i][W-1]%2==1:
        ANSLIST.append((i,W-1,i+1,W-1))
        A[i][W-1]-=1
        A[i+1][W-1]+=1

print(len(ANSLIST))
for x,y,z,w in ANSLIST:
    print(x+1,y+1,z+1,w+1)

Measured memory_bytes: 22792
#include <bits/stdc++.h>
using namespace std;
 
using ll=long long;
 
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define pb push_back
#define eb emplace_back
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed

int main() {
    int n; cin >> n;
    int cnt = 0;
    rep(i, n) {
        int a; cin >> a;
        if (i%2 == 0 && a%2 == 1) ++cnt; 
    }
    cout << cnt << endl; 
    return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

ll n,x;
ll a[2010];
int main(){
	cin>>n>>x;
	REP(i,n){
		cin>>a[i];
	}
	ll ans=INFl;
	REP(i,n){
		ll tans=x*i;
		multiset<ll> m1;
		m1.clear();
		for(int j=n-i-1;j<n;j++){
			m1.insert(a[j]);
		}
		for(int k=0;k<n;k++){
			auto itr=m1.find(a[(k-i-1+n)%n]);
			m1.erase(itr);
			m1.insert(a[k]);
			tans+=*m1.begin();
		}
		ans=min(tans,ans);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <memory.h>
#include <string>
#include <numeric>
#include <random>
#include <stdio.h>
#include <map>
#define forn(i, j, n) for(int i = j; i < n; ++i)
#pragma comment(linker, "/STACK:1000000000")
using namespace std;
typedef long long LL;
typedef double D;

const int N = 200001;

int a[N];
vector<pair<int, int>> v;

int main()
{
	ios::sync_with_stdio(0);
	int n, k, t;
	cin >> n >> k;
	for (int i = 0 ; i < n; ++i)
	{
		cin >> t;
		a[t]++;
	}
	for (int i = 1; i < N; ++i)
		if (a[i]) v.push_back({i, a[i]});
	
	sort(v.begin(), v.end(), [](pair<int, int> a, pair<int, int> b){return a.second < b.second;});
	
	t = 0;
	for (int i = 0; i < (int)v.size() - k; ++i)
		t += v[i].second;
	cout << t;
}


Measured memory_bytes: 3188
#include "bits/stdc++.h"
using namespace std;
typedef pair<long long, long long> P;
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
int main() {
	long long N; cin >> N;
	vector<long long>A(N);
	for (long long i = 0; i < N; i++) {
		cin >> A.at(i);
	}
	long long ans = 1;
	sort(A.begin(), A.end());
	if (A.at(0) == 0) {
		cout << 0 << endl;
		return 0;
	}
	else {
		for (long long i = 0; i < N; i++) {
			if (A.at(i) <= 1000000000000000000 / ans) {
				ans *= A.at(i);
			}
			else {
				cout << -1 << endl;
				return 0;
			}
		}
		cout << ans << endl;
	}
}

Measured memory_bytes: 3984
//B-kotae
#include <bits/stdc++.h>
using namespace std;

int main(){
  int a,b,i,sum=0;
  cin>>a>>b;
  for(i=a;i<=b;i++){
    if(i/10000==i%10&&(i/1000)%10==(i/10)%10) sum++;
  }
  cout<<sum<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main() {
    int N, M;
    cin >> N >> M;
    int sum = 0;
    if (N > 1) {
        sum += N * (N - 1) / 2;
    }
    if (M > 1) {
        sum += M * (M - 1) / 2;
    }
    cout << sum << endl;
    return 0;
}

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

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

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

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

  for(int i=0; i<n; i++){
    for(int j=0; j<m; j++){
      c[i]+=a[i][j]*b[j];
    }
  }
  for(int i=0; i<n; i++){
    cout << c[i] << endl;
  }
}



Measured memory_bytes: 3132
#include <iostream>
using namespace std;
int main() {
    char c;
    cin >> c;
    for (auto d : {'a','e','i','o','u'}){
        if (c == d){
            cout << "vowel" << endl;
            return 0;
        }
    }
    cout << "consonant" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long int c[100000];
int main()
{
	int n;
	long int a[100005],ans=0;
	cin>>n;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		if(a[i]>100000){
			ans+=1;
			continue;
		}
		c[a[i]]+=1;
	}
	
	for(long int i=0;i<100000;i++)
	{
		if(c[i]<i) 
			ans+=c[i];
		else if(c[i]>i)
			{
				ans+=c[i]-i;
			}
	}
	cout<<ans;

	return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<algorithm>
using namespace std;

const int maxn = 200005;
const int inf = 0x7fffffff;

int a[maxn], n;

int main(){
    while(~scanf("%d", &n)){
        for(int i = 0; i < n; i++){
            scanf("%d", &a[i]);
        }

        int maxv = -inf;
        int minv = a[0];

        for(int i = 1; i < n; i++){
            maxv = max(maxv, a[i] - minv);
            minv = min(minv, a[i]);
        }

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



Measured memory_bytes: 3452
#include <bits/stdc++.h>
using namespace std;
int main()
{
  string s, t;
   cin >> s;
   cin >> t;
   int cnt = 0;
   for(int  i = 0; i < s.size(); i++) {
   	   if(s[i] != t[i]) {
   	   	cnt++;
   	   }
   }
   cout << cnt << "\n";
	return 0;
}


Measured memory_bytes: 3916
#include <iostream> 
#include <cstdio> 
#include <cstdlib> 
#include <cstring> 
#include <cmath> 
#include <algorithm> 
using namespace std; 
inline int gi() { 
    register int data = 0, w = 1; 
    register char ch = 0; 
    while (!isdigit(ch) && ch != '-') ch = getchar(); 
    if (ch == '-') w = -1, ch = getchar(); 
    while (isdigit(ch)) data = 10 * data + ch - '0', ch = getchar(); 
    return w * data; 
} 
const int MAX_N = 3e5 + 5; 
int mx[MAX_N << 2], tg[MAX_N << 2]; 
#define lson (o << 1)
#define rson (o << 1 | 1) 
void puttag(int o, int v) { mx[o] += v, tg[o] += v; } 
void pushup(int o) { mx[o] = max(mx[lson], mx[rson]); } 
void pushdown(int o) { 
	if (!tg[o]) return ; 
	puttag(lson, tg[o]), puttag(rson, tg[o]); 
	tg[o] = 0; 
} 
void modify(int o, int l, int r, int ql, int qr, int v) { 
	if (ql <= l && r <= qr) return puttag(o, v); 
	pushdown(o); 
	int mid = (l + r) >> 1; 
	if (ql <= mid) modify(lson, l, mid, ql, qr, v); 
	if (qr > mid) modify(rson, mid + 1, r, ql, qr, v); 
	pushup(o); 
}
struct Node { int x, y; } a[MAX_N]; 
int stk1[MAX_N], stk2[MAX_N], top1, top2; 
int N, H, W, ans = 0; 
void solve() { 
	sort(&a[1], &a[N + 1], [&](const Node &l, const Node &r) { return l.x < r.x; } ); 
	memset(mx, 0, sizeof(mx)); 
	memset(tg, 0, sizeof(tg)); 
	modify(1, 1, N, 1, N, H); 
	top1 = top2 = 0; 
	stk1[0] = stk2[0] = 1; 
	for (int i = 2; i <= N; i++) { 
		modify(1, 1, N, 1, i - 1, a[i].x - a[i - 1].x); 
		ans = max(ans, mx[1]); 
		if (a[i].y >= H >> 1) { 
			modify(1, 1, N, stk1[top1], i - 1, a[i].y - H); 
			while (top1 && a[stk1[top1]].y > a[i].y) {
				modify(1, 1, N, stk1[top1 - 1], stk1[top1] - 1, a[i].y - a[stk1[top1]].y); 
				--top1; 
			} 
			stk1[++top1] = i; 
		} else { 
			modify(1, 1, N, stk2[top2], i - 1, -a[i].y); 
			while (top2 && a[stk2[top2]].y < a[i].y) {
				modify(1, 1, N, stk2[top2 - 1], stk2[top2] - 1, a[stk2[top2]].y - a[i].y); 
				--top2; 
			} 
			stk2[++top2] = i; 
		} 
	} 
} 
int main () { 
	W = gi(), H = gi(), N = gi() + 1; 
	ans = max(W, H) + 1; 
	for (int i = 1; i < N; i++) a[i] = (Node){gi(), gi()}; 
	a[N] = (Node){W, H}; a[++N] = (Node){0, 0}; 
	solve(); 
	for (int i = 1; i <= N; i++) swap(a[i].x, a[i].y); 
	swap(W, H); 
	solve(); 
	printf("%d\n", ans << 1); 
	return 0; 
} 

Measured memory_bytes: 12800
#include <stdio.h>
#include <math.h>

struct Point{double x , y;};

void koch(int n ,struct  Point a ,struct  Point b){
	if(n == 0)return;
	struct Point s , t , u;
	double th = M_PI * 60.0 / 180.0;
	
	s.x = (2.0 * a.x + 1.0 * b.x) / 3.0;
	s.y = (2.0 * a.y + 1.0 * b.y) / 3.0;
	t.x = (1.0 * a.x + 2.0 * b.x) / 3.0;
	t.y = (1.0 * a.y + 2.0 * b.y) / 3.0;
	u.x = (t.x - s.x) * cos(th) - (t.y - s.y) * sin(th) + s.x;
	u.y = (t.x - s.x) * sin(th) + (t.y - s.y) * cos(th) + s.y;
	
	koch(n-1,a,s);
	printf("%.8f %.8f\n",s.x,s.y);
	koch(n-1,s,u);
	printf("%.8f %.8f\n",u.x,u.y);
	koch(n-1,u,t);
	printf("%.8f %.8f\n",t.x,t.y);
	koch(n-1,t,b);
}

int main(void)
{
	struct Point a , b;
	int n;
	scanf("%d",&n);
	a.x = 0;
	a.y = 0;
	b.x = 100;
	b.y = 0;
	
	printf("%.8f %.8f\n",a.x,a.y);
	koch(n,a,b);
	printf("%.8f %.8f\n",b.x,b.y);
	
	return 0;
}


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


int main()
{
  ull n, s;

  cin>>n>>s;
  ull c = 0;
  for(int i = 0; i<= n; i++)
  {
    for(int j = 0; j<=n; j++)
    {
      int s2  = s- i - j;


        if(  s2>= 0 && s2<=n)
        c++;

    }

  }
  cout<<c<<endl;

}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.TreeMap;
import java.util.Map;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author KharYusuf
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastReader in = new FastReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        EThisMessageWillSelfDestructIn5s solver = new EThisMessageWillSelfDestructIn5s();
        solver.solve(1, in, out);
        out.close();
    }

    static class EThisMessageWillSelfDestructIn5s {
        public void solve(int testNumber, FastReader s, PrintWriter w) {
            int n = s.nextInt();
            int[] a = new int[n];
            for (int i = 0; i < n; i++) a[i] = s.nextInt();
            TreeMap<Integer, Integer> t = new TreeMap<>();
            long ans = 0;
            for (int i = 0; i < n; i++) {
                ans += t.getOrDefault(i - a[i], 0);
                t.put(i + a[i], t.getOrDefault(i + a[i], 0) + 1);
            }
            w.println(ans);
        }

    }

    static class FastReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;
        private FastReader.SpaceCharFilter filter;

        public FastReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {

            if (numChars == -1)
                throw new InputMismatchException();

            if (curChar >= numChars) {

                curChar = 0;

                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }

                if (numChars <= 0)
                    return -1;
            }

            return buf[curChar++];
        }

        public int nextInt() {

            int c = read();

            while (isSpaceChar(c))
                c = read();

            int sgn = 1;

            if (c == '-') {
                sgn = -1;
                c = read();
            }

            int res = 0;

            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();

                res *= 10;
                res += c - '0';
                c = read();
            }
            while (!isSpaceChar(c));

            return res * sgn;
        }

        public boolean isSpaceChar(int c) {

            if (filter != null)
                return filter.isSpaceChar(c);

            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

        public interface SpaceCharFilter {
            public boolean isSpaceChar(int ch);

        }

    }
}



Measured memory_bytes: 53124
#include <iostream>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#define int long long
using namespace std;
signed main() {
    string A,B,C;
    cin>>A>>B>>C;

    cout<<A[0]<<B[1]<<C[2]<<endl;
}

Measured memory_bytes: 3572
//import java.util.Scanner;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) throws Exception {
		//BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		//String line = br.readLine();
		Scanner scan = new Scanner(System.in);

		int X = scan.nextInt();
		int A = scan.nextInt();
		int B = scan.nextInt();
		
		X = X-A;
		X=X%B;
		System.out.println(X);
		
	}}

Measured memory_bytes: 21716
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;

int main() {

    int n;
    cin>>n;
    char s[999999];
    cin>>s;
    for(int i=0; s[i] != '\0'; i++) {
            cout<<(char)('A' + ((s[i] - 'A' + n) % 26));
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		 //sort(all(vi S)) sort(all(string S))
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

const int MOD = 1e9+7;
const int INF = 1e9;
int main() {
    int N;
    cin>>N;
    vector<ll> P(N),Q(N),C;
    rep(i,N){
        cin>>P[i];
        P[i]--;
        Q[P[i]] = i;
    }
    print(P);print(Q);
    int ans = 0;
    int cnt = 1;
    rep1(i,N){
        if(Q[i-1]<Q[i])cnt++;
        else{
            ans = max(ans, cnt);
            C.push_back(cnt);
            cnt = 1;
        }
    }
    ans = max(ans, cnt);
    ans = N - ans;
    print(C);
    cout<<ans<<endl;

}

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

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;

const int CASES = 3;

ll dp[1100][5000];

void solve(){
    int N, M; cin >> N >> M;
    vector<ll> a(M), b(M), c(M);
    for (int i = 0; i < M; ++i) {
        cin >> a[i] >> b[i];
        for (int j = 0; j < b[i]; ++j){
            int t; cin >> t; --t;
            // c はビットで表す
            c[i] += (1<<t);
        }
    }

    for (int i = 0; i < 1100; ++i){
        for (int j = 0; j < 5000; ++j){
            dp[i][j] = INF64;
        }
    }
    dp[0][0] = 0;

    for (int i = 0; i < M; ++i) {
        for (int j = 0; j < (1<<N); ++j) {
            // i番目の鍵を使わない
            dp[i+1][j] = min(dp[i+1][j], dp[i][j]);

            // i番目の鍵を使う
            dp[i+1][j | c[i]] = min(dp[i+1][j | c[i]], dp[i][j] + a[i]);
        }
    }
    ll ans = -1;
    if(dp[M][(1<<N)-1] < INF64){
        ans = dp[M][(1<<N)-1];
    }
    cout << ans << endl;
}

int main() {
    #ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
    #else

    solve();

    #endif
    return 0;
}



Measured memory_bytes: 43264
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i=0; i<(int)(n); i++)
#define FOR(i, r, n) for (int i=(int)(r); i<=(int)(n); i++)
#define all(v) v.begin(), v.end()
#define INF 2147483647
#define INF64 9223372036854775807
#define MOD 1000000007

int main(){

    int a; cin>>a;
    cout<<a+a*a+a*a*a<<endl;

}

Measured memory_bytes: 3632
#include <stdio.h>

int main()
{
    int n,i,j,a[3][101],ans,ame[101],cnt1=0,cnt2=0;
    
    scanf("%d",&n);
    for(i=0;i<2;i++){
        for(j=0;j<n;j++){
            scanf("%d",&a[i][j]);
            if(i==1){
                cnt2+=a[i][j];
            }
        }
    }
    
    ame[0]=a[0][0]+cnt2;
    cnt1=a[0][0];
    cnt2-=a[1][0];
    
    ans=ame[0];
    for(i=1;i<n;i++){
        ame[i]=cnt1+a[0][i]+cnt2;
        cnt1+=a[0][i];
        cnt2-=a[1][i];
        
    }
    for(i=0;i<n;i++){
        if(ans<ame[i]){
            ans=ame[i];
        }
    }
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 128
import sys
import math
import itertools
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

D,N = I()
if D == 0:
    if N == 100:
        print(101)
    else:
        print(N)
elif D == 1:
    if N == 100:
        print(10100)
    else:
        print(N*100)
else:
    if N == 100:
        print(1010000)
    else:
        print(N*10000)

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

using namespace std;

using ll = long long;

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

    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << max(a * b, c * d) << endl;

    return 0;
}


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


#define ll long long
#define MOD 1000000007
#define PI 3.1415


int main(){
    int h,w,k;
    cin>>h>>w>>k;

    vector<string> c(h);


    for(int i=0;i<h;i++)cin>>c.at(i);

    int co=0;
    int v=0;
    for(int bits1=0;bits1<(1<<h);bits1++){
        for(int bits2=0;bits2<(1<<w);bits2++){
            v=0;
            for(int i=0;i<h;i++){
                for(int j=0;j<w;j++){
                    if((bits1&(1<<i))==0&&(bits2&(1<<j))==0&&c.at(i).at(j)=='#')v++;
                }
            }
            if(v==k)co++;
        }
    }
    cout<<co<<endl;


}



Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  int l = a + b;
  int r = c + d;
  if (l > r) {
    cout << "Left" << endl;
  }
  else if (l == r) {
    cout << "Balanced" << endl;
  }
  else {
    cout << "Right" << endl;
  }
}

Measured memory_bytes: 256
from collections import Counter
import itertools

N = int(input())
xy = [list(map(int, input().split())) for i in range(N)]
xy.sort()
if N == 1:
        print(1)
        exit()

ptn=list(itertools.combinations(xy,2))
pq=[]
for idx,val in enumerate(ptn):
        if val[1][0]-val[0][0] <= 0 and val[1][1]-val[0][1] <= 0:
                pq.append(str(abs(val[1][0]-val[0][0])) + 'x' + str(abs(val[1][1]-val[0][1])))
        else:
                pq.append(str(val[1][0]-val[0][0]) + 'x' + str(val[1][1]-val[0][1]))

cpq = Counter(pq)

# pqans=cpq.most_common(1)[0][0]
redsc=cpq.most_common(1)[0][1]

# p,q = map(int,pqans.split('x'))
print(N-redsc)


Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
#define ALL(x) (x).begin(), (x).end()
#define OUT(x) std::cout << (x) << std::endl
typedef long long ll;

int main() {
    int k, x;
    cin >> k >> x;
    if (500 * k >= x)
        OUT("Yes");
    else
        OUT("No");
}

Measured memory_bytes: 256
n = gets.to_i
a = gets.chomp.split.map(&:to_i).sort.reverse
b = gets.chomp.split.map(&:to_i).sort
c = gets.chomp.split.map(&:to_i).sort

ans = 0
n.times do |i|
  idx1 = a.bsearch_index { |x| x < b[i] } || n
  idx2 = c.bsearch_index { |x| x > b[i] } || n
  ans += (n - idx1) * (n - idx2)
end
puts ans

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

int main(){
  int n; cin >> n;
  int ans = 1;
  vector<int> h(n);
  for(int i = 0; i < n; i++){
    cin >> h.at(i);
  }
  for(int i = 1; i < n; i++){
    bool ok = true;
    for(int j = 0; j < i; j++){
      if(h.at(i) < h.at(j)) ok = false;
    }
    if(ok) ans++;
  }
  cout << ans << 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() {
  ll N;
  vector<ll> cap(6);
  cin >> N;
  cap[0] = N;
  for (int i = 1; i < 6; i++){
    cin >> cap[i];
  }

  vector<ll> cnt(6);
  cnt[0] = 1;
  for (int i = 1; i < 6; i++)
  {
    cnt[i] = (N + cap[i] - 1) / cap[i];
    //cerr << "cnt[" << i << "=" << cnt[i] << endl;
  }
  
  sort(cnt.begin(), cnt.end());
  ll sum = 5 + (cnt.back() - 1);
  
  cout << sum << endl;
  return 0;
}


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

int main(){
    int H;
    int W;

    cin >> H >> W;

    while(H != 0&& W != 0){
         for(int x=1; x<=H; x++){
             for(int y=1; y<=W; y++){
                 if(x%2 == 1){
                     if(y%2==1){
                     cout << '#';
                 }else{
                     cout << '.';
                 }
             }else{
                 if(y%2==1){
                     cout << '.';
                 }else{
                     cout << '#';
                 }
             }
         }
         
         cout << endl;
         }
         cout << endl;

         cin >> H >> W;
     }

     return 0;
}


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

#define rep(i,n) for(int i = 0;i<n;i++)
#define cint(a) int a; cin >> a;
#define cstr(str) string str; cin >> str;


using namespace std;
using ll = long long;

const ll mod = 1e9 + 7;

int main(void) {

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

	string str;
	cin >> str;

	int ct = 0;
	int q; cin >> q;
	int t;
	int f;
	char c;
	queue<char> r;
	queue<char> l;
	stack<char> s;
	while (q--) {
		cin >> t;
		if (t == 1) ct += 1;
		if (t == 2) {
			 cin >> f;
			 cin >> c;
			 if ((f + ct) % 2) l.push(c);
			 else r.push(c);
		}
	}
	if (ct % 2) {
		reverse(str.begin(), str.end());
		while (!r.empty()) {
			s.push(r.front());
			r.pop();
		}
		while (!s.empty()) {
			cout << s.top() << flush;
			s.pop();

		}
		cout << str << flush;
		while (!l.empty()) {
			cout << l.front() << flush;
			l.pop();
		}
	}
	else {
		while (!l.empty()) {
			s.push(l.front());
			l.pop();
		}
		while (!s.empty()) {
			cout << s.top() << flush;
			s.pop();

		}
		cout << str << flush;
		while (!r.empty()) {
			cout << r.front() << flush;
			r.pop();
		}
	}

	cout << endl;


	return 0;
}


Measured memory_bytes: 3856
a = [i for i in input().split()]

b = []
for i in a:
    if i == "+":
        x = int(b.pop())
        y = int(b.pop())
        z = x + y
        b.append(z)
    elif i == "-":
        x = int(b.pop())
        y = int(b.pop())
        z = y - x
        b.append(z)
    elif i == "*":
        x = int(b.pop())
        y = int(b.pop())
        z = x * y
        b.append(z)
    else:
        b.append(int(i))

print(b[0])


Measured memory_bytes: 5604
#include <iostream>
using namespace std;
int main()
{
	char a,b;
	cin>>a>>b;
	if(a == 'H')
	{
		if(b == 'H')
		{
			cout<<"H";
		}
		else if(b == 'D')
		{
			cout<<"D";
		}
	}
	else if(a == 'D' )
	{
		if(b == 'H')
		{
			cout<<"D";
		}
		else if(b == 'D')
		{
			cout<<"H";
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
//#include<iostream>
//#include<vector>
//#include<map>
//#include<math.h>
//#include<algorithm>

#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rep2(i,a,n) for(int i = (int)(a); i <= (int)(n); i++)
#define rrep(i,n) for(int i = (int)(n-1); i > -1; i--)
#define rrep2(i,n,a) for(int i = (int)(n); i >= (int)(a); i--)

#define fi first
#define se second

using namespace std;

using ll = long long;
using v_int = vector<int>;
using v2_int = vector<v_int>;
using v_ll = vector<ll>;
using v2_ll = vector<v_ll>;
using v_string = vector<string>;
using v_bool = vector<bool>;
using v2_bool = vector<v_bool>;
using pii = pair<int, int>;
using mii = map<int, int>;

const double PI = 3.1415926535897932;
const int INF = (int)2e9;
const ll LINF = (ll)2e18;
const ll MOD = 1000000007;
const int dc[8] = {1, -1, 0,  0, 1, -1,  1, -1};
const int dr[8] = {0,  0, 1, -1, 1,  1, -1, -1};

template<typename T, typename U> inline
ostream& operator<<(ostream &o, pair<T,U> &p) {
    return o << "{" << p.first << "," << p.second << "}";
}
template<typename T> inline
istream& operator>>(istream &is, vector<T> &vec) {
    for(auto &v : vec) { is >> v; }
    return is;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<T> &vec) {
    for(auto &v : vec) { os << v << ",";}
    return os;
}
template<typename T> inline
ostream& operator<<(ostream &os, vector<vector<T> > &mat) {
    for(auto &row : mat) { os << row << endl; }
    return os;
}

template<typename T> inline
void chmin(T &a, T b) { a = min(a, b); }
template<typename T> inline
void chmax(T &a, T b) { a = max(a, b); }

v_string s;
int h,w;

int solve(int sr, int sc, int gr, int gc)
{
    v2_int dist(h, v_int(w,INF));

    queue<pii> q;
    q.push({sr,sc});
    dist[sr][sc] = 0;

    while(q.size()) {
        pii now = q.front(); q.pop();
        rep(i,4) {
            int row = now.fi + dr[i];
            int col = now.se + dc[i];
            if(row < 0 || row >= h) { continue; }
            if(col < 0 || col >= w) { continue; }
            if(dist[row][col] != INF) { continue; }
            if(s[row][col] == '#') { continue; }
            dist[row][col] = min(dist[row][col], dist[now.fi][now.se]+1);
            q.push({row,col});
        }
    }
    return dist[gr][gc];
}

int main(void)
{
    cin >> h >> w;
    
    s.resize(h);
    cin >> s;
    
    int ans = -1;
    rep(sr,h) {
        rep(sc,w) {
            if(s[sr][sc] == '#') { continue; }
            rep(gr,h) {
                rep(gc,w) {
                    if(sr == gr && sc == gc) { continue; }
                    if(s[gr][gc] == '#') { continue; }
                    chmax(ans, solve(sr,sc,gr,gc));
                }
            }
        }
    }   
    cout << ans << endl;
    return 0;
} /*atcoder*/


Measured memory_bytes: 3592
#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <cassert>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

const int ms = 200200;

std::vector<int> edges[ms];
long long ans[ms];
int size[ms], good[ms], col[ms];

void pre(int on, int par) {
	for(auto to : edges[on]) {
		if(to == par) continue;
		pre(to, on);
		size[on] += size[to];
	}
	size[on]++;
}

void go(int on, int par) {
	long long cur = good[col[on]] - size[on] + 1;
	//std::cout << "base adding " << good[col[on]] << " - " << size[on] << " + 1 to " << col[on] << '\n';
	ans[col[on]] += cur;
	for(auto to : edges[on]) {
		if(to == par) continue;
		int wtf = good[col[on]];
		good[col[on]] = size[to];
		go(to, on);
		good[col[on]] = wtf;
		//std::cout << "other adding " << cur << " * " << size[to] << " to " << col[on] << '\n';
		ans[col[on]] += cur * size[to];
		cur += size[to];
	}
	good[col[on]] -= size[on];
}

int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	int n;
	std::cin >> n;
	for(int i = 0; i <= n; i++) {
		good[i] = n;
	}
	for(int i = 1; i <= n; i++) {
		std::cin >> col[i];
	}
	for(int i = 1; i < n; i++) {
		int u, v;
		std::cin >> u >> v;
		edges[u].push_back(v);
		edges[v].push_back(u);
	}
	pre(1, 0);
	go(1, 0);
	for(int i = 1; i <= n; i++) {
		std::cout << ans[i] << '\n';
	}
}

Measured memory_bytes: 37132
#include<bits/stdc++.h>
#define REP(i,n) for(int i = 0; i < n; ++i)
#define rep(i,n) for(int i = 1; i <= n; ++i)
#define boost ios::sync_with_stdio(0)
#define ms0(s) memset((s), 0, sizeof(s))
#define INF 0x3f3f3f3f
#define ABS(x) ((x)<0 ? (-(x)) : (x))
#define forvec(it,v) for(vector<int>::iterator it = v.begin(); it != v.end(); ++it)

#ifdef LOCAL
#define DEBUG 1
#else
#define DEBUG 0
#endif
#define $ if(DEBUG)
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

//quick I/O
ostream& operator << (ostream& out, const pii& p){
	out << "(" << p.first << ", " << p.second << ")";
	return out;
}
template <typename T>
inline void read(T& x){
	int w = 1; T data = 0;
	char ch = getchar();
	while(!isdigit(ch) && ch != '-') ch = getchar();
	if(ch == '-') w = -1, ch = getchar();
	while(isdigit(ch))
		data = 10 * data + ch - '0', ch = getchar();
	x = data * w;
}
template <typename T>
void write(T x){
	 if (x < 0) putchar('-'),x = ~x + 1;
	 if (x > 9) write(x / 10);
	 putchar( x % 10 + '0');
}

//debug
template<typename T>
void printvec(vector<T> vec){
	for(T v : vec) cout << ' ' << v;
	cout << '\n';
}
template<typename T>
void printset(set<T> s){
	for(auto it = s.begin(); it != s.end(); ++it)
		cout << ' ' << *it;
	cout << '\n';
}
template<typename T>
void printarray(T* p,int n){
	cout << '{';
	REP (i,n) cout << ' ' << p[i];
	cout << "}\n";
}
int n, sum = 0;
int main()
{
	read(n);
	int p;
	REP(i, n) read(p), sum += p;
	printf("%d\n", sum - n);
	return 0;
}



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

typedef long long ll;

int main() {
    int N, a, mina = 1e9;
    cin >> N;
    ll s = 0;
    bool f = false;
    rep(i, N) {
        cin >> a;
        s += a;
        if (a == 1) f = true;
        mina = min(a, mina);
    }
    if (N % 2) {
        if (s % 2) {
            cout << "First\n";
        } else {
            cout << "Second\n";
        }
    } else {
        if (mina % 2) {
            cout << "First\n";
        } else {
            if (s % 2) {
                cout << "First\n";
            } else {
                cout << "Second\n";
            }
        }
    }
}


Measured memory_bytes: 3104
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<iostream>
using namespace std;
#define mx 100001
int main(){
    int cost[mx],h[mx];
    int n;
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    cost[0] = 0;
    for(int i = 1; i < n; i++){
        cost[i] = min(abs(h[i] - h[i - 1]) + cost[i - 1], abs(h[i] - h[i - 2]) + cost[i - 2]);
    }
    cout << cost[n - 1] << endl;
    return 0;
}

Measured memory_bytes: 4324
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
 
const int N = 1e6 + 5;
 
int n;
int a[N];
int have[N], mark[N];
 
void work()
{
    for(int i = 1; i < N; i++)
    {
        if(have[i])
        {
            if(have[i] >= 2)
                mark[i] = 1;
            for(int j = 2; i * j < N; j++)
                mark[i * j] = 1;
        }
    }
}
 
int32_t main()
{
    IOS;
    cin >> n;
    for(int i = 1; i <= n; i++)
    {
        cin >> a[i];
        have[a[i]]++;
    }
    int ans = 0;
    work();
    for(int i = 1; i <= n; i++)
        ans += !mark[a[i]];
    cout << ans;
    return 0;
}

Measured memory_bytes: 20740
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,K;
  cin>>N;
  string s;
  cin>>s;
  cin>>K;
  for(int i = 0;i<N;i++){
    if(s.at(i) != s.at(K-1)){
      cout << "*";
    }
    else{
      cout << s.at(K-1);
    }
  }
  cout << endl;
  return 0;
}
  

Measured memory_bytes: 256
#include <stdio.h>
int main() {
int i,N,v,k,j;
int A[100];
scanf("%d",&N);
for(i=0;i<N;i++) {
scanf("%d",&A[i]);
}
 for(i=0;i<N-1;i++){
   printf("%d ",A[i]);
 }
 printf("%d\n",A[N-1]);
for(i=1;i<=N-1;i++){
v=A[i];
j=i-1;
while(j>=0&&A[j]>v){
A[j+1]=A[j];
j--;
A[j+1]=v;
}
for(k=0;k<N-1;k++){
printf("%d ",A[k]);
}
 printf("%d\n",A[N-1]);
}
return 0;
}



Measured memory_bytes: 2064
while True:
	n = int(input())
	if n == 0:
		break
	game = [[int(s) for s in input().split()] for i in range(n)]
	a,b = 0,0
	for g in game:
		if g[0] > g[1]:
			a += sum(g)
		elif g[0] < g[1]:
			b += sum(g)
		else:
			a += g[0]
			b += g[1]
	print(a,b)

Measured memory_bytes: 9168
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long ll;

int main()
{
	string A, B, C;
	cin >> A;
	cin >> B;
	cin >> C;
	if (A[A.size()-1]==B[0] && B[B.size()-1]==C[0])
	{
		cout << "YES";
	}
	else
	{
		cout << "NO";
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <queue>
using namespace std;
int h,w;
const int INF = 100000000;
typedef pair<int,int>P;
int dx[4]={2,0,-2,0},dy[4]={0,2,0,-2};
int main(){
    while(1){
        scanf("%d%d", &w, &h);
        if(h==0&&w==0) break;
        int field[h*2][w*2];
        int d[h][w];
        memset(field,0,sizeof(field));
        for(int i=0;i<h*2-1;i++){
            if(i%2==0)
                for(int j=0;j<w-1;j++)
                    scanf("%d",&field[i][j*2+1]);
            else
                for(int j=0;j<w;j++)
                    scanf("%d",&field[i][j*2]);
        }
        for(int i=0;i<h;i++)
            for(int j=0;j<w;j++)
                d[i][j]=INF;
        queue<P> que;
        que.push(P(0,0));
        d[0][0]=0;
        while(que.size()){
            P p=que.front();que.pop();
            if(p.first==h*2-2&&p.second==w*2-2)break;
            for (int i=0;i<4;i++){
                int ny=p.first+dy[i],nx=p.second+dx[i];
                int my=p.first+(dy[i]/2),mx=p.second+(dx[i]/2);
                if(0<=ny&&ny<h*2-1&&0<=nx&&nx<w*2-1&&d[ny/2][nx/2]==INF&&field[my][mx]==0){
                    que.push(P(ny,nx));
                    d[ny/2][nx/2]=d[p.first/2][p.second/2]+1;
                }
            }
        }
        if(d[h-1][w-1]>=INF)
            printf("0\n");
        else
            printf("%d\n",(d[h-1][w-1])+1);
    }
    return 0;
}



Measured memory_bytes: 2736
# Review problem
from collections import deque
H, W = map(int, input().split())
D = [list(input()) for i in range(H)]

visited = [[False for i in range(W)] for j in range(H)]
dis = [[0 for i in range(W)] for j in range(H)]

black = deque()
dif = [(-1, 0), (1, 0), (0, 1), (0, -1)]
for i in range(H):
    for j in range(W):
        if D[i][j] == "#":
            visited[i][j] = True
            black.append((i, j))

while black:
    x, y = black.popleft()
    for dx, dy in dif:
        if 0 <= dx+x < H and 0 <= dy+y < W and visited[dx+x][dy+y] == False:
            visited[dx+x][dy+y] = True
            dis[dx+x][dy+y] = dis[x][y]+1
            black.append((dx+x, dy+y))
ans = 0
for i in range(H):
    for j in range(W):
        ans = max(ans, dis[i][j])
print(ans)

Measured memory_bytes: 164788
def ZZ(): return list(map(int, input().split()))
def Z(): return int(input())

N, M, X = ZZ()
C = []
A = []
for _ in range(N):
    tmp = ZZ()
    C.append(tmp[0])
    A.append(tmp[1:])

ans = 10 ** 100
for i in range(1 << N):
    rikai = [0] * M
    cost = 0
    for j in range(N):
        if i >> j & 1:
            cost += C[j]
            for k in range(M):
                rikai[k] += A[j][k]
    if min(rikai) >= X:
        ans = min(ans, cost)

if ans == 10 ** 100: ans = -1
print(ans)

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

int main(){
  int i=0;
  int j=0;
  int a,b,c;
  cin>>a>>b>>c;
  int k;
  cin>>k;
  while(1){
    if(a<b)break;
    i++;
    b*=2;
  }
  while(1){
    if(b<c)break;
    j++;
    c*=2;
  }
  if(k<(i+j)){
    cout<<"No"<<endl;
  }else{
    cout<<"Yes"<<endl;
  }
  return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e8;
// l, r, v
using Data = tuple<int, int, int>;
int main() {
    int N;
    cin >> N;
    vector<Data> data;
    data.emplace_back(0, 0, 0);
    int T = 0;
    {
        vector<int> t(N), v(N);
        for(int i = 0; i < N; i++) {
            cin >> t[i];
            t[i] *= 2;
        }
        for(int i = 0; i < N; i++) {
            cin >> v[i];
            v[i] *= 2;
        }
        for(int i = 0; i < N; i++) {
            data.emplace_back(T, T + t[i], v[i]);
            T += t[i];
        }
    }
    data.emplace_back(T, T, 0);
    vector<int> V(T + 1, INF);
    for(int j = 0; j <= T; j++) {
        for(int i = 0; i < N + 2; i++) {
            int l, r, v;
            tie(l, r, v) = data[i];
            if(j < l) {
                V[j] = min(V[j], v + l - j);
            } else if(r < j) {
                V[j] = min(V[j], v + j - r);
            } else {
                V[j] = min(V[j], v);
            }
        }
    }
    double ans = 0;
    for (int j = 0; j < T; j++) {
        ans += V[j] + V[j + 1];
    }
    cout << std::fixed << std::setprecision(6) << ans / 8 << endl;
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define ll long long
#define MODV 1000000007
#define INFLL LLONG_MAX // 9223372036854775807
#define EPS 1e-9
#define rep(i, n) for(ll i=0, i##_len=(ll)(n); i<i##_len; i++)
#define repf(i, n) for(ll i=1, i##_len=(ll)(n+1); i<i##_len; i++)
#define all(v) v.begin(), v.end()
#define endl "\n"
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define Yes() cout << "Yes" << endl
#define YES() cout << "YES" << endl
#define No() cout << "No" << endl
#define NO() cout << "NO" << endl
#define Init() std::ios::sync_with_stdio(false); std::cin.tie(0); std::cout<<fixed<<setprecision(15);
template<class T>bool chmax(T &a, const T &b){ if(a<b){ a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a){ a=b; return 1; } return 0; }
using namespace std;

int main(){
    Init();
    ll cnt = INFLL;
    ll x, y; cin >> x >> y;
    if(x <= y) chmin(cnt, y-x);

    x *= -1;
    if(x <= y) chmin(cnt, y-x+1);

    y *= -1;
    if(x <= y) chmin(cnt, y-x+2);

    x *= -1;
    if(x <= y) chmin(cnt, y-x+1);

    cout << cnt << endl;

}

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

int main () {
  int n;
  cin >> n;
  int ans = 0;
  if (n%10 == 2) ans++;
  if (n/10%10 == 2) ans++;
  if (n/100%10 == 2) ans++;
  if (n/1000 == 2) ans++;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int inf=0x3f3f3f3f;
const ll INF=0x3f3f3f3f3f3f3f;
const double pi=3.1415926535897932384626;
inline ll read(){
	ll x=0,f=1;
	char ch=getchar();
	while(ch<'0'||ch>'9'){
		if(ch=='-') f=-1;
		ch=getchar();
	}
	while(ch>='0'&&ch<='9'){
		x=(x<<1)+(x<<3)+(ch^48);
		ch=getchar();
	}
	return x*f;
}
int n,a,b,c,d;
string s;
int main(){
	n=read();
	for(int i=1;i<=n;i++){
		cin>>s;
		if(s[0]=='A') ++a;
		else if(s[0]=='W') ++b;
		else if(s[0]=='T') ++c;
		else if(s[0]=='R') ++d;
	}
	printf("AC x %d\n",a);
	printf("WA x %d\n",b);
	printf("TLE x %d\n",c);
	printf("RE x %d\n",d);
	return 0;
}

Measured memory_bytes: 3760