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

typedef long long int int64;
struct vertex {
	std::vector<int> next;
	int parent;
	int depth;
	bool vis;
} v[303];
void dfs(int i)
{
	v[i].vis = true;
	for(int j = 0;j < v[i].next.size();++j) {
		int to = v[i].next[j];
		if(!v[to].vis) {
			v[to].depth = v[i].depth + 1;
			v[to].parent = i;
			dfs(to);
		}
	}
	v[i].vis = false;
}
int n;
int maxd[303];
int main()
{
	scanf("%d",&n);
	for(int i = 0;i < n - 1;++i) {
		int a,b;
		scanf("%d%d",&a,&b);--a,--b;
		v[a].next.push_back(b);
		v[b].next.push_back(a);
	}
	int64 min = 99999999999999999LL;
	int mind = 1000;
	for(int addi = -1;addi < n;++addi) {
		if(addi != -1) {
			v[addi].next.push_back(n);
			v[n].next.push_back(addi);
			++n;
		}
		int addn = 0;
		for(;;) {
			v[0].depth = 0;dfs(0);
			int root = 0;
			for(int i = 1;i < n;++i) if(v[i].depth > v[root].depth) root = i;
			v[root].depth = 0;dfs(root);
			int root2 = 0;
			for(int i = 1;i < n;++i) if(v[i].depth > v[root2].depth) root2 = i;
			int dia = v[root2].depth;
			int c1 = root2;
			for(int i = 0;i < dia / 2;++i) c1 = v[c1].parent;
			bool doub;
			if(dia % 2 == 0) {
				doub = false;
				v[c1].depth = 0;dfs(c1);
			} else {
				doub = true;
				int c2 = v[c1].parent;
				v[c1].vis = true;v[c2].depth = 0;dfs(c2);v[c1].vis = false;
				v[c2].vis = true;v[c1].depth = 0;dfs(c1);v[c2].vis = false;
			}
			for(int i = 0;i < n;++i) maxd[i] = 0;
			for(int i = 0;i < n;++i) if(v[i].next.size() > maxd[v[i].depth]) maxd[v[i].depth] = v[i].next.size();
			if(!doub) ++maxd[0];
			int64 ans = 1;
			for(int i = n - 1;i >= 0;--i) if(maxd[i] > 1) ans = ans * (maxd[i]-1);
			if(doub) ans *= 2;
			int cnt = dia/2+1;
			if(cnt < mind || (cnt == mind && ans < min)) {
				mind = cnt;
				min = ans;
			}
			if(addi == -1 || cnt > mind) break;
			v[n-1].next.push_back(n);
			v[n].next.push_back(n-1);
			++n;++addn;
		}
		if(addi != -1) {
			for(int j = 0;j < addn;++j) {
				--n;
				v[n-1].next.pop_back();
				v[n].next.pop_back();
			}
			--n;
			v[n].next.pop_back();
			v[addi].next.pop_back();
		}
	}
	printf("%d %lld\n", mind, min);
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)
int main(){
    int n;
    cin >> n;
    map<int ,int> mp_even;
    map<int, int> mp_odd;
    rep(i, n) {
        int tmp_num;
        cin >> tmp_num;
        if ( i&1 ) {
            ++mp_odd[tmp_num];
        }
        else {
            ++mp_even[tmp_num];
        }
    }
    int ans = 0;
    vector<pair<int, int>> odd_v;
    vector<pair<int, int>> even_v;
    for ( auto tmp_mp : mp_odd ) {
        odd_v.emplace_back(tmp_mp.second, tmp_mp.first);
    }
    for ( auto tmp_mp : mp_even ) {
        even_v.emplace_back(tmp_mp.second, tmp_mp.first);
    }
    sort(odd_v.begin(), odd_v.end());
    sort(even_v.begin(), even_v.end());

    if ( odd_v[odd_v.size()-1].second != even_v[even_v.size()-1].second ) {
        cout << n - odd_v[odd_v.size()-1].first - even_v[even_v.size()-1].first << endl;
    }
    else {
        int odd_second_num = ( odd_v.size() >= 2 ) ? odd_v[odd_v.size()-2].first : 0;
        int even_second_num = ( even_v.size() >= 2 ) ? even_v[even_v.size()-2].first : 0;
        cout << n - max(odd_second_num + even_v[even_v.size()-1].first,
                        odd_v[odd_v.size()-1].first + even_second_num) << endl;
    }
//    int max_odd = 0;
//    int max_odd_second = 0;
//    int max_num_odd = 0;
//    int max_num_odd_second = 0;
//    for ( auto tmp_mp : mp_odd ) {
//        if ( max_num_odd < tmp_mp.second ) {
//            max_odd_second = max_odd;
//            max_num_odd_second = max_num_odd;
//            max_num_odd = tmp_mp.second;
//            max_odd = tmp_mp.first;
//        }
//    }
//    int max_even = 0;
//    int max_even_second = 0;
//    int max_num_even = 0;
//    int max_num_even_second = 0;
//    for ( auto tmp_mp : mp_even ) {
//        if ( max_num_even < tmp_mp.second ) {
//            max_even_second = max_even;
//            max_num_even_second = max_num_even;
//            max_num_even = tmp_mp.second;
//            max_even = tmp_mp.first;
//        }
//    }
//    if ( max_odd == max_even ) {
//        ans = max( n - max_num_odd - max_num_even_second, n - max_num_odd_second - max_num_even );
//    }
//    else {
//        ans = n - max_num_odd - max_num_even;
//    }
//    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6136
//(各チーム,各問題)ごとに(正解問題,時間)2つのようそを持っておくと簡単。
#include<iostream>
#include<stdlib.h>
using namespace std;
#define rep(i,N) for(i=0;i<N;i++)

int M,T,P,R;
int m,t,p,j;

struct TEAM{
	int sac;
	int stime;
	int id;
	int ac[10];
	int time[10];
}team[50],syukei_team[50];

int compare( const void *s1,const void *s2 ){
	int t1 = ((TEAM*)s2)->sac - ((TEAM*)s1)->sac;
	int t2 = ((TEAM*)s1)->stime - ((TEAM*)s2)->stime;
	int t3 = ((TEAM*)s2)->id - ((TEAM*)s1)->id;
	if( t1 )
		return t1;
	if( t2 )
		return t2;
	return t3;
}

int main(){
	int y,x;
	while( cin >> M >> T >> P >> R ){
		if(!M)break;
		rep(y,T){
			rep(x,P){
				team[y].ac[x] = 0;
				team[y].time[x] = 0;
			}
			syukei_team[y].sac = 0;
			syukei_team[y].stime = 0;
			syukei_team[y].id = y+1;
		}
		rep(y,R){
			cin >> m >> t >> p >> j;
			t--;
			p--;
			if( j == 0 ){
				team[t].ac[p] = 1;
				team[t].time[p] += m;
			}
			else{
				team[t].time[p] += 20;
			}
		}
		rep(y,T){
			rep(x,P){
				if( team[y].ac[x] == 1 ){
					syukei_team[y].stime += team[y].time[x];
					syukei_team[y].sac++;
				}
			}
		}
		qsort( syukei_team, T, sizeof(syukei_team[0]), compare );
		
		rep(y,T){
			cout << syukei_team[y].id;
			if( y < T-1 ){
				if( syukei_team[y].sac == syukei_team[y+1].sac && syukei_team[y].stime == syukei_team[y+1].stime ){
					cout << "=";
				}
				else{
					cout << ",";
				}
			}
			else{
				cout << endl;
			}
			//printf(" team=%d ac=%d time=%d\n",syukei_team[y].id,syukei_team[y].sac,syukei_team[y].stime);
		}
	}
	return 0;
}

Measured memory_bytes: 1180
#include <iostream>
#include <stdio.h>
#include <cstring>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string>
#include <stdlib.h>
#include <queue>
#include <utility>
#define rep(i,n) for(int i=0;i<n;i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define LL long long
#define INF 1000000001
#define mod 1000000007
using namespace std;
int keta(int n,int k){return (n/int(pow(10,double(k-1)))) % 10;} //nの下からk桁目
ll gcd(ll n,ll m){
	if(n<m){ll a=m;m=n;n=a;}
	ll r=n%m;
	while(r!=0){
		n=m;
		m=r;
		r=n%m;
	}
	return m;
}
ll lcm(ll n,ll m){
	return n*m/gcd(n,m);
}


int main(){
	ll n;
	cin>>n;
	int q=sqrt((double)n);
	//cout<<q<<endl;
	while(1){
		if(n%q==0){
			int x=n/q;
			cout<<(int)log10((double)x)+1<<endl;
			return 0;
		}
		q--;
	}
	
}

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

int main(){
    string s;
    cin >> s;
    string first, second, third;
    first = s.at(0);
    second = s.at(1);
    third = s.at(2);
    if(first == second && second == third){
        cout << "No";
    } else {
        cout << "Yes";
    }
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<numeric>
#include<vector>
#include<cstdlib>
#include<cmath>
template<typename T>
void fin(std::vector<T>const& t, char delim=' '){
  if(t.size() > 0) {
    for(int i = 0; i < t.size() -1; ++i) std::cout << t[i] << delim;
    std::cout << t.back();
  }
  std::cout << std::endl; 
  exit(0);
}

double const epsilon = 1e-10;

struct P { 
  double x, y; 
  static double add(double x, double y) {
    if(abs(x+y) < epsilon*(abs(x)+abs(y))) return 0.0;
    return x+y;
  }
  P operator -(P const& p) const { return {add(x, -p.x), add(y, -p.y)}; }
  double det(P const& p) const { return add(x*p.y, -y*p.x); }
  P operator -() const { return {-x, -y}; }
};

double const PI = std::acos(-1);

int main() {
  std::cin.tie(0); std::ios::sync_with_stdio(false);
  std::cout << std::setprecision(10) << std::fixed;
  int N; std::cin >> N;
  std::vector<P> p(N);
  for(int i = 0; i < N; ++i) std::cin >> p[i].x >> p[i].y;
  std::vector<int> ix(N);
  std::iota(ix.begin(), ix.end(), 0);
  std::sort(ix.begin(), ix.end(), [&](int l, int r){ return p[l].x < p[r].x; });
  std::vector<int> q(N+N);
  int k = 0;
  for(int i = 0; i < N; ++i) {
    while(k > 1 && (p[q[k-1]] - p[q[k-2]]).det(p[ix[i]] - p[q[k-1]]) <= 0.0) --k;
    q[k++] = ix[i];
  }
  for(int i = N-2, t = k; i >= 0; --i) {
    while(k > t && (p[q[k-1]] - p[q[k-2]]).det(p[ix[i]] - p[q[k-1]]) <= 0.0) --k;
    q[k++] = ix[i];
  }
  q.resize(--k); // remove duplicate of start point
  std::vector<double> th;
  for(int i = 0; i < k; ++i) {
    P pb = p[q[i]], pe = p[q[(i+1)%k]];
    P v({pb.y-pe.y, pe.x-pb.x});
    if(v.det(pe-pb) <= 0) v = -v;
    th.push_back(std::atan2(v.y, v.x));
  }
  std::vector<double> ans(N, 0.0);
  for(int i = 0; i < k; ++i) {
    double thb = th[i], the = th[(i+1)%k];
    double thd = the-thb;
    if(thd < 0) thd += PI*2.0;
    ans[q[(i+1)%k]] = thd/(PI*2.0);
  }
  fin(ans, '\n');
  return 0;
}


Measured memory_bytes: 512
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include <fstream>
#include <time.h>
#include <iterator>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()

using namespace std;

const int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
ll add(ll x, ll y) {
	x += y;
	if (x >= MOD) return x - MOD;
	return x;
}
ll sub(ll x, ll y) {
	x -= y;
	if (x < 0) return x + MOD;
	return x;
}
ll mult(ll x, ll y) {
	return (x * y) % MOD;
}
ll bin_pow(ll x, ll p) {
	if (p == 0) return 1;
	if (p & 1) return mult(x, bin_pow(x, p - 1));
	return bin_pow(mult(x, x), p / 2);
}

string S;
ll com[100010];//0~i-1桁の組み合わせ
ll dp[100010];
vector<int>v;
ll func(int n) {
	auto itr = lb(v, n);
	if (itr == v.begin()) {
		ll res = add(2, com[n]);
		return res;
	}
	else {
		itr--; 
		ll res = add(com[n], mult(2, func(*itr)));
		return res;
	}
}

signed main() {
	/*cin.tie(0);
	ios::sync_with_stdio(false);*/
	cin >> S;
	com[0] = 1;
	REP(i, 100009) {
		com[i + 1] = mult(com[i], 3);
	}
	int N = S.size();
	VREVERSE(S);
	REP(i, N) {
		if (S[i] == '1') {
			v.pb(i);
		}
	}
	VSORT(v);
	int M = v.size();
	ll ans = func(v[M - 1]);
	print(ans);

}


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

const int N = 2e5+5 , M = 1e9+5, OO = 0x3f3f3f3f;
typedef long long ll;
ll a[4];
ll x, n, in;

ll power(ll a, ll b){           //O(log(b))
    if(!b)  return 1;
    ll t = power(a, b>>1);
    return t*t * (b&1 ? a : 1);
}


int main()
{
    for(int i=0; i<4; ++i)
    {
        cin >> a[i];
    }
    cin >> in;
    n = in*4;
    for(int i=0; i<3; ++i) if(a[i]*2 < a[i+1]) a[i+1] = a[i]*2;
    //for(int i=0; i<4; ++i) cout << a[i] << " ";
    //cout << endl;
    ll ans = 0;
    for(int i=3; i>=0; --i)
    {
        ll u = n/power(2, i);
        //cout << u << " ";
        ans += n/power(2, i) * a[i];
        n -=  u*power(2, i);
        //cout << n << " "<<  ans << endl;
    }
    cout << ans << endl;

    return 0;
}



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

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

    string s; cin >> s;
    rep(i, 0, s.size()) {
      if (s[i] == '1') { s[i] = '9'; continue; }
      if (s[i] == '9') { s[i] = '1'; continue; }
    }
  
    cout << s << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define sz(a) int((a).size())
#define all(a) (a).begin(), (a).end()
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPD(i,n) for(int i=(n)-1;i>=0;--i)
#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 TLE() cerr<<"\nTime elapsed: "<<1000*clock()/CLOCKS_PER_SEC<<"ms.\n";
const ll MOD = 1E9+7;
const ll IINF = 1E18;
const int INF = 1e9;
const double EPS = 1E-9;
const double PI = atan(1.0) * 4.0;
template<class T> T getbit(T s, int i) {return s>>i&1;}
template<class T> void flipbit(T& s, int i) {s^=(1LL<<i);}
constexpr int cntbit(ll x) {return __builtin_popcountll(x);}
constexpr int lg2(ll x) {return __lg(x);} // return int(log2(x))
// mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937 rng((uint32_t)chrono::steady_clock::now().time_since_epoch().count()); 
ll fpow(ll a,ll p){ll res=1LL;while(p){if(p&1LL) res=res*a%MOD;a=a*a%MOD;p>>=1LL;} return res;}

const int N=105;
int n,k;
vector<int> adj[N];

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	cin>>n>>k;
	int g=(n-1)*(n-2)/2;
	if(k>g) exit(puts("-1")*0);
	int cnt=0;
	FOR(i,1,n-2)
		FOR(j,i+1,n-1)
			if(g>k){
				adj[i].pb(j);
				g--;
				cnt++;
			}
	FOR(i,1,n-1)
		adj[i].pb(n),cnt++;
	cout<<cnt<<'\n';
	FOR(i,1,n)
		for(int u:adj[i])
			cout<<i<<' '<<u<<'\n';
}




Measured memory_bytes: 3656
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <deque>
#include <utility>

long long dp[3004][3004];

int main(){
  int A, B, C, D;
  scanf("%d", &A);
  scanf("%d", &B);
  scanf("%d", &C);
  scanf("%d", &D);
  int H = C-A;
  int W = D-B;
  long long mod = 998244353;
  dp[0][0]=1;
  for (int h=0; h<=H; h++){
    for (int w=0; w<=W; w++){
      // delete
      if (h>0 && w>0){
	dp[h][w] -= dp[h-1][w-1]*(A+h-1)*(B+w-1);
	while (dp[h][w]<0){
	  dp[h][w] += mod;
	}
      }
      //printf("dp[%d][%d]=%lld\n", h, w, dp[h][w]);
      // add
      if (h+1<=H){
	dp[h+1][w] += dp[h][w]*(B+w);
	dp[h+1][w] %= mod;
      }
      if (w+1<=W){
	dp[h][w+1] += dp[h][w]*(A+h);
	dp[h][w+1] %= mod;
      }
    }
  }
  std::cout << dp[H][W] << std::endl;
  return 0;
}
 

Measured memory_bytes: 73456
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define printInt(a) printf("%d\n", a)
#define printll(a) printf("%lld\n", a)
#define printYes() printf("Yes\n")
#define printNo() printf("No\n")
#define scanll(a) scanf("%lld", &a)
#define scanInt(a) scanf("%d", &a)
#define scan2Int(a, b) scanf("%d %d", &a, &b)
#define scan3Int(a, b, c) scanf("%d %d %d", &a, &b, &c)
#define scan4Int(a, b, c, d) scanf("%d %d %d %d", &a, &b, &c, &d)
typedef long long ll;
const int INF = 1001001001;
using namespace std;
void swap(int *a, int *b) {
    int tmp = *a;
    *a = *b;
    *b = tmp;
    return;
}
int gdc(int a, int b) {
    int r;
    if (a < b)
        swap(&a, &b);
    r = a % b;
    while (r != 0) {
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

int main() {
    int k;
    ll total = 0;
    scanInt(k);
    for (int i = 1; i <= k; ++i) {
        for (int j = 1; j <= k; ++j) {
            for (int l = 1; l <= k; ++l) {
               total += gdc(gdc(i, j), l);
    }}}
    printll(total);
    return 0;
}

Measured memory_bytes: 3724
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String s=sc.nextLine();

		for(int i=0;i<s.length();i++) {
			char c=s.charAt(i);
			if(Character.isLowerCase(c)) {
				System.out.print(Character.toUpperCase(c));
			}else {
				System.out.print(Character.toLowerCase(c));
			}
			
		}
		System.out.println();
	}
}


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

#define printl(s) cout << s << endl;
#define rep(i,n) for(int i=0;i<(n);i++)
using ll = long long;
using vvi = vector<vector<int>>;

const ll modSeed = pow(10,9) + 7;
const int INF = 1'000'000'000;

template <typename T>
vector<T> getVector(ll num){
    vector<T> values(num);
    for(ll i=0;i<num;i++){
        cin >> values.at(i);
    }
    return values;
}

string S;
ll N,ans;

int main(){
  ans = 0;
  cin >> N;
  for(int c=0;c<=N;c++){
    for(int d=0;d<=N-c;d++){
      int p = 4*c+7*d;
      if(p==N){
        printl("Yes");
        return 0;
      }
    }
  }
  printl("No");
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair((a),(b))
#define pb(a) push_back((a))
#define all(x) (x).begin(),(x).end()
#define uniq(x) sort(all(x)),(x).erase(unique(all(x)),end(x))
#define fi first
#define se second
#define dbg(x) cout<<#x" = "<<((x))<<endl
template<class T,class U> ostream& operator<<(ostream& o, const pair<T,U> &p){o<<"("<<p.fi<<","<<p.se<<")";return o;}
template<class T> ostream& operator<<(ostream& o, const vector<T> &v){o<<"[";for(T t:v){o<<t<<",";}o<<"]";return o;}

#define INF 2147483600

class UnionFind {
public:
  vector<int> par, rank; // parent(negative := its root and abs-value is its size), depth
  UnionFind(int sz) : par(sz, -1), rank(sz, 0){}
  int find(int x){
    if(par[x]<0) return x;
    else return par[x] = find(par[x]);
  }
  void unite(int x, int y){
    x=find(x); y=find(y);
    if(x==y) return;  // already belong to same tree
    if(rank[x] < rank[y]){  // y becomes parent node
      par[y] += par[x];
      par[x] = y;
    } else {  // x becomes parent node
      par[x] += par[y];
      par[y] = x;
      if(rank[x]==rank[y]) rank[x]++;
    }
  }
  bool same(int x, int y){ return find(x) == find(y); }
  int size(int x){ return -par[find(x)]; }
}; // END class UnionFind


int main(){
  int n,m;
  while(cin>>n>>m, n|m){
    vector<pair<int,pair<int,int>>> vec;
    rep(i,n)rep(j,m){
      int d;
      cin>>d;
      if(d>0) vec.pb(mp(d,mp(m,j)));
    }
    rep(i,m)rep(j,m-i-1){
      int d;
      cin>>d;
      if(d>0) vec.pb(mp(d,mp(i, i+j+1)));
    }

    UnionFind uf(m+1);
    sort(all(vec));
    int res = 0;
    for(auto p : vec){
      int a = p.se.fi, b = p.se.se;
      if(!uf.same(a,b)){
        res += p.fi;
        uf.unite(a,b);
      }
    }
    cout << res << endl;
  }

  return 0;
}

Measured memory_bytes: 3160
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int n,a[100001];
ll ans,dp[100001][2];
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	cin>>n;
	for (int i=1;i<=n;++i) cin>>a[i];
	for (int i=1;i<=n;++i)
		for (int x=0;x<2;++x)
		{
			if (a[i]<x) continue;
			for (int y=0;y<2;++y)
			{
				if (a[i-1]<x+y) continue;
				dp[i][x]=max(dp[i][x],dp[i-1][y]+x+(a[i-1]-x-y)/2);
			}
		}
	for (int i=0;i<2;++i) ans=max(ans,dp[n][i]+(a[n]-i)/2);
	cout<<ans;
	return 0;
}

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

int main()
{
    int prime, yen_1;
    cin >> prime >> yen_1;
    int yen_2 = prime % 500;
    if (yen_1 - yen_2 >= 0)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
}

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

int main() {
  int n;
  cin >> n;
  
  int i, a;
  vector<int> x(100000);
  for(i = 0; i < n; i++){
    cin >> a;
    x.at(a)++;
  }
  
  int ans = 0;
  for(i = 0; i < 99998; i++){
    ans = max(ans, x.at(i) + x.at(i + 1) + x.at(i + 2));
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 640
#include<stdio.h>
int main(void)
{
	int i,s;
	int a[10];
	for(i=0;i<10;i++){
		scanf("%d",&a[i]);
	}
	s=a[0]+a[1]+a[2]+a[3]+a[4]+a[5]+a[6]+a[7]+a[8]+a[9];
	printf("%d\n",s);
	return 0;
}

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

int main() {
	int D,T,S;
	cin >> D >> T >> S;

	if(S * T < D){
		cout << "No" << endl;
	}else{
		cout << "Yes" << endl;
	}
	return(0);
}


Measured memory_bytes: 3628
#include<stdio.h>
#define NIL -1
int parent[100001],cleft[100001],right[100001];
int depth(int i){
  int d=0;
  while(parent[i]!=NIL){
    d++;
    i=parent[i];
  }
  return d;
}
void printchildren(int i){
  int c=cleft[i];
  while(c!=NIL && right[c]!=NIL){
    printf("%d, ",c);
    c=right[c];
  }
  if(cleft[i]!=NIL)printf("%d",c);
}

int main(){
  int n;scanf("%d",&n);
  int i;
  for(i=0;i<=n-1;i++)parent[i]=cleft[i]=right[i]=NIL;
  for(i=0;i<=n-1;i++){
    int id,k;
    scanf("%d %d",&id,&k);
    int c[k+1],j;
    for(j=1;j<=k;j++)scanf("%d",&c[j]);
    if(k>=1){
      parent[c[1]]=id;
      cleft[id]=c[1];
    }
    for(j=2;j<=k;j++){
      parent[c[j]]=id;
      right[c[j-1]]=c[j];
    }
  }
    
    
  for(i=0;i<=n-1;i++){
    printf("node %d: parent = %d, depth = %d, ",i,parent[i],depth(i));
    if(parent[i]==NIL) printf("root, [");
    else if(cleft[i]==NIL) printf("leaf, [");
    else printf("internal node, [");
    printchildren(i);
    printf("]\n");
        
  }
    
  return 0;
}



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

int main()
{
    int num;
    cin >> num;
    int first, second;
    first = num/100;
    second = num%100;
    if(first==0){
        if(second == 0){
            cout << "NA" ;
        }else if(second<=12){
            cout << "YYMM";
        }else{
            cout <<"NA";
        }
    }else if(first<=12){
        if(second == 0){
            cout << "MMYY";
        }else if(second <= 12){
            cout << "AMBIGUOUS";
        }else {
            cout << "MMYY";
        }
    }else{
        if(second == 0){
            cout << "NA";
        }else if(second <= 12){
            cout << "YYMM";
        }else{
            cout << "NA";
        }
    }
    cout << endl;
    return 0;

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;

namespace Competitive
{
    internal class Solution
    {
        public long N;
        public long MOD = 1000000007;
        public int ret;

        public void Run()
        {
            N = Input.ReadLong();
            ret = 0;
            var bf = new BruteForceBit(9, Process);
            bf.DFSRun();
            Console.WriteLine(ret);
        }

        public void Process(int[] ary)
        {
            bool flg3 = false;
            bool flg5 = false;
            bool flg7 = false;
            long x = 0;
            long m = 1;
            for (int i = 0; i < ary.Length; i++)
            {
                x += (ary[i]) * m;
                m *= 10;
                if (ary[i] == 3) flg3 = true;
                if (ary[i] == 5) flg5 = true;
                if (ary[i] == 7) flg7 = true;
            }

            // Console.Error.WriteLine(x);
            if (flg3 && flg5 && flg7 && x <= N) ret++;
        }
    }

    // libs ----------

    // 0/1ビット列を全通り列挙
    class BruteForceBit
    {
        public int N;
        public int[] F;
        private Action<int[]> Process;

        public BruteForceBit(int N, Action<int[]> process)
        {
            this.N = N;
            F = new int[N];
            Process = process;
        }

        public void DFSRun()
        {
            DFS(0);
        }

        private void DFS(int i)
        {
            Process(F);
            if (i == N)
            {
                return;
            }
            else
            {
                F[i] = 3;
                DFS(i + 1);
                F[i] = 5;
                DFS(i + 1);
                F[i] = 7;
                DFS(i + 1);
                F[i] = 0;
            }
        }

    }

    // common ----------

    internal static class Input
    {
        public static string ReadString()
        {
            string line = Console.ReadLine();
            return line;
        }

        public static int ReadInt()
        {
            string line = Console.ReadLine();
            return int.Parse(line);
        }

        public static int[] ReadIntArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(int.Parse).ToArray();
        }

        public static long ReadLong()
        {
            string line = Console.ReadLine();
            return long.Parse(line);
        }

        public static long[] ReadLongArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(long.Parse).ToArray();
        }

        public static double[] ReadDoubleArray()
        {
            string line = Console.ReadLine();
            return line.Split(' ').Select(double.Parse).ToArray();
        }
    }

    internal class Program
    {
        public static void Main(string[] args)
        {
            var s = new Solution();
            s.Run();
        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef int ll;
typedef long double ld;
const ll N = 200005;
char en = '\n';
ll inf = 1e16;
ll mod = 1e9 + 7;
ll power(ll x, ll n, ll mod) {
  ll res = 1;
  x %= mod;
  while (n) {
    if (n & 1)
      res = (res * x) % mod;
    x = (x * x) % mod;
    n >>= 1;
  }
  return res;
}

int32_t main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  ll l, r, d;
  cin >> l >> r >> d;

  cout << (r / d) - (l - 1) / d << en;

  return 0;
}


Measured memory_bytes: 3536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
#define rep(i,n) for (ll i=0;i<n;++i)
#define rep2(i,a,b) for (ll i=a;i<b;++i)
const ll MOD=1e9+7;
const ll INF=1e9;
const ll IINF=1e18;
const double EPS=1e-8;
const double pi=acos(-1);

template<class T> inline bool chmin(T &a,T b){
    if (a>b){
        a=b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T &a,T b){
    if (a<b){
        a=b;
        return true;
    }
    return false;
}

int main(){
    int H,W;
    cin >> H >> W;
    vector<string> a(H);
    rep(i,H) cin >> a[i];
    rep(i,W) cout << '.';
    cout << endl;
    rep(i,H-2){
        rep(j,W){
            if (i%2==0&&j!=W-1) cout << '#';
            else if (a[i+1][j]=='#'||j==0) cout << '#';
            else cout << '.'; 
        }
        cout << endl;
    }
    rep(i,W) cout << '.';
    cout << endl << endl;
    rep(i,W) cout << '.';
    cout << endl;
    rep(i,H-2){
        rep(j,W){
            if (i%2==1&&j!=0) cout << '#';
            else if (a[i+1][j]=='#'||j==W-1) cout << '#';
            else cout << '.';
        }
        cout << endl;
    }
    rep(i,W) cout << '.';
    cout << endl;
}

Measured memory_bytes: 1024
#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,M;
  cin >> N >> M;
  vector<int> broken(N+1);
  rep(i,M) {
    int w;
    cin >> w;
    broken[w]=1;
  }
  vector<int> a(N+2);
  a[N]=1;
  for(int i=N-1;i>=0;i--){
    if(broken[i]){
      a[i]=0;
    }else{
      a[i]=(a[i+1]+a[i+2])%1000000007;
    }
  }
  int ans = a[0];
  cout << ans << endl;
}

Measured memory_bytes: 1024
// warm heart, wagging tail,and a smile just for you!
//                                                                     ███████████
//                                                                   ███╬╬╬╬╬╬╬╬╬╬███
//                                                                ███╬╬╬╬╬████╬╬╬╬╬╬███
//                                            ███████████       ██╬╬╬╬╬████╬╬████╬╬╬╬╬██
//                                      █████████╬╬╬╬╬████████████╬╬╬╬╬██╬╬╬╬╬╬███╬╬╬╬╬██
//                               ████████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬██╬╬╬╬╬╬╬██
//                             ████╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████████╬╬╬╬╬╬╬╬╬╬╬██
//                           ███╬╬╬█╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬███╬╬╬╬╬╬╬█████
//                         ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬████████╬╬╬╬╬██
//                       ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬╬╬╬╬███
//                     ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬██
//                 ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬████
//     █████████████╬╬╬╬╬╬╬╬██╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬██████
//   ████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬██████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████╬╬╬╬╬╬╬███████████╬╬╬╬╬╬╬╬██╬╬╬██╬╬╬██
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████╬╬╬╬╬╬╬╬╬╬╬█╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬██
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬▓▓▓▓▓▓╬╬╬████╬╬████╬╬╬╬╬╬╬▓▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬███
// ██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██████▓▓▓▓▓▓▓╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬▓▓▓▓▓▓▓██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██╬╬╬╬█████
// ███╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████████
//   ███╬╬╬╬╬╬╬╬╬╬╬╬╬█████╬╬╬╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬███╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬██
//       ██████████████  ████╬╬╬╬╬╬███████████████████████████╬╬╬╬╬██╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬╬████
//                         ███████                           █████  ███████████████████
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
const double EPS = 1e-9;
#define INF (1LL<<60)
#define D double
#define fs first
#define sc second
#define int long long
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for(int i = (b-1);i>=(a);--i)
#define REP(i,n)  FOR(i,0,(n))
#define RREP(i,n) RFOR(i,0,(n))
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define range(i,a,b) ((a)<=(i) && (i)<(b))
#define debug(x)  cout << #x << " = " << (x) << endl;
#define SP << " " << 
typedef pair<int,int> P;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

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

  int n,d;
  cin >> n >> d;

  vector<vector<int>> a(n,vector<int>(d));
  REP(i,n) REP(j,d) cin >> a[i][j];
  
  int ans = 0;
  REP(i,n){
    REP(j,i){
      int sum = 0;
      REP(k,d) sum += (a[i][k]-a[j][k])*(a[i][k]-a[j][k]); 
      if(sum == (int)sqrt(sum)*(int)sqrt(sum)) ans++;
    }
    
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(void){
    // Your code here!
    int m, n;
    cin >> n >> m;
    vector<int> a(n);
    int sum = 0;
    for(int i=0; i<n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    sort(a.begin(), a.end(), greater<int>());
    for(int i=0; i<n; i++) {
        if(a[i] < sum*0.25/m) break;
        if(i+1>=m) {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    vector<int> vec(n);
    for(int i=0; i<n; i++){
        cin >> vec[i];
    }
    sort(vec.begin(),vec.end());
    double tmp;
    tmp = vec[0];
    for(int i=1; i<n; i++){
        tmp = (tmp+vec[i])/2;
    }
    cout << tmp << endl;

}




Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
A=[0]+A+[0]
ans=0
for i in range(1,N+2):
    ans+=abs(A[i]-A[i-1])
for i in range(1,N+1):
    Z=ans
    Z-=(abs(A[i]-A[i-1])+abs(A[i]-A[i+1])-abs(A[i+1]-A[i-1]))
    print(Z)

Measured memory_bytes: 20520
#include <bits/stdc++.h>
#define FI first
#define SE second
#define EPS 1e-9
#define ALL(a) a.begin(),a.end()
#define SZ(a) int((a).size())
#define MS(s, n) memset(s, n, sizeof(s))
#define FOR(i,a,b) for (int i = (a); i <= (b); i++)
#define FORE(i,a,b) for (int i = (a); i >= (b); i--)
#define FORALL(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define WHATIS(x) cout << #x << " is " << x << endl;
#define ERROR(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
//__builtin_ffs(x) return 1 + index of least significant 1-bit of x
//__builtin_clz(x) return number of leading zeros of x
//__builtin_ctz(x) return number of trailing zeros of x

using namespace std;
using ll = long long;
using ld = double;
typedef pair<int, int> II;
typedef pair<II, int> III;
typedef complex<ld> cd;
typedef vector<cd> vcd;

void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cout << *it << " = " << a << endl;
    err(++it, args...);
}

const ll MODBASE = 1000000007LL;
const int MAXN = 200010;
const int MAXM = 1000010;
const int MAXK = 510;
const int MAXQ = 200010;

int n, a[MAXN], nGroup;
vector<int> b[MAXN];

int main() {
    ios::sync_with_stdio(0);
    cin.tie(nullptr);
    cin >> n;
    FOR(i,1,n) cin >> a[i];
    nGroup = 1;
    b[nGroup].emplace_back(a[1]);
    FOR(i,2,n) {
        if (a[i] <= b[nGroup][SZ(b[nGroup])-1]) {
            nGroup++;
            b[nGroup].emplace_back(a[i]);
            continue;
        }
        int dau = 1, cuoi = nGroup;
        while (dau <= cuoi) {
            int mid = (dau + cuoi) >> 1;
            if (b[mid][SZ(b[mid])-1] >= a[i]) dau = mid+1;
            else cuoi = mid-1; 
        }
        b[dau].emplace_back(a[i]);
    }
    cout << nGroup;
    return 0;
}


Measured memory_bytes: 8448
#include<stdio.h>
int nibun(int*, int, int, int);
int main(void) {
	int n, h[200];
	int ans;

	ans = 0;
	
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d", &h[i]);
	}

	ans = nibun(h, 0, n, ans);

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

	return 0;
}
int nibun(int* h, int start, int end, int ans) {
	int i, j, k;
	int min, mini;

	min = 999;
	mini = -1;

	for (i = start; i < end; i++) {
		if (min > h[i]) {
			min = h[i];
			mini = i;
		}
	}
	if (min != 0 && min != 99) {
		ans += min;
		for (i = start; i < end; i++) {
			h[i] -= min;
		}
	}

	if (mini != start) {
		ans = nibun(h, start, mini, ans);
	}
	if (mini + 1 != end) {
		ans = nibun(h, mini+1, end, ans);
	}

	return ans;
}


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

int main()
{	
	int a[2] = { 0, 0 }, b;

	for (int i = 0; i < 2; i++) {
		for (int j = 0; j < 4; j++) {
			cin >> b;
			a[i] += b;
		}
	}

	cout << max(a[0], a[1]) << endl;	

	return 0;
}



Measured memory_bytes: 3056
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<string>
using namespace std;

#define sz(x) (int)(x.size())
#define fr(i,a,b) for(int i=a;i<b;++i)
#define fdr(i,a,b) for(int i=b-1;i>=a;--i)
#define mp make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
/////////////////////



void solve(){
	int n;
	cin >> n;
	map<int, int> a;
	fr(i, 0, n){
		int v;
		cin >> v;
		++a[v];
	}
	int f, s;
	f = s = 0;
	for(auto it : a){
		if(it.second >= 2) {
			s = max(s, it.first);
		}
		if(it.second >= 4){
			f = max(f, it.first);
		}
		if(s > f) swap(f, s);
	}
	cout << f * 1LL * s << endl;
}

int main(){
#ifdef _DEBUG
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif

	solve();


	return 0;
}

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

int n,q;
const int maxn = 1e5+5;
int a[maxn],b[maxn],c[maxn];
ll ans[maxn];
map<int,int> mp;
int main(){
	cin >> n;
	for (int i=1;i<=n;i++){
		cin >> a[i];	
		ans[0] += a[i];
		mp[a[i]]++;
	}
	cin >> q;
	for (int i=1;i<=q;i++){
		cin >> b[i] >> c[i]; 
		ans[i] = ans[i-1]+(c[i]-b[i])*mp[b[i]];
		mp[c[i]]+=mp[b[i]];
		mp[b[i]]=0;
	}
	for (int i=1;i<=q;i++){
		cout << ans[i] << endl;	
	}
	return 0;
}

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

int main() {
  ll x;
  cin >> x;

  int count=0;
  ll sum=100;;

  while(x>sum){
      sum = sum + (sum/100);
      count++;

  }

  cout << count << endl;
}

Measured memory_bytes: 3652
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll N;
  cin >> N;
  vl h(N);
  rep(i, N) cin >> h[i];
  
  ll ans = 0;
  ll flag = 0;

  rep2(i, 1, 101){
    flag = 0;

    rep(j, N){
      if((flag == 0) && (h[j] >= i))
	flag = 1;
      else if((flag == 1) && (h[j] < i)){
	ans++;
	flag = 0;
      }
    }

    if(flag == 1)
      ans++;
  }

  cout << ans << "\n";
  
  return 0;
}


Measured memory_bytes: 3592
//デバッグ用オプション：-fsanitize=undefined,address

//コンパイラ最適化
#pragma GCC optimize("Ofast")

//インクルードなど
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;

//マクロ
//forループ
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
//FORAは範囲for文(使いにくかったら消す)
#define REP(i,n) for(ll i=0;i<ll(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=ll(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=ll(b);i--)
#define FORA(i,I) for(const auto& i:I)
//xにはvectorなどのコンテナ
#define ALL(x) x.begin(),x.end() 
#define SIZE(x) ll(x.size()) 
//定数
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange
//略記
#define PB push_back //挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素

signed main(){
    //入力の高速化用のコード
    //ios::sync_with_stdio(false);
    //cin.tie(nullptr);
  string s;
  cin >> s;
  int res=0;
  if(s=="RRR"){
    res=3;
  }else if(s=="SSS"){
    res=0;
  }else if(s=="SRR" || s=="RRS"){
    res=2;
  }else{
    res=1;
  }
  cout << res;
}

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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    ll Q, H, S, D;
    ll N;
    ll money;
    cin >> Q >> H >> S >> D;
    cin >> N;
    Q *= 4;
    H *= 2;
    S = min(Q, min(H, S));
    if(D < 2 * S) {
        money = N / 2 * D;
        money += N % 2 * S;
    } else {
        money = N * S;
    }
    cout << money << endl;
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<numeric>
#include<map>
#include<queue>
#include<deque>
#include<set>
#include<cstdio>
using namespace std;
typedef long long ll;
typedef vector<int> vec;
typedef vector<vector<int>> mat;

int main(){
    int A[3];cin>>A[0]>>A[1]>>A[2];
    sort(A,A+3);
    int ans=A[2]-A[1];
    A[0]+=A[2]-A[1];
    if((A[2]-A[0])%2==0)ans+=(A[2]-A[0])/2;
    else {
        ans++;A[2]++;
        ans+=(A[2]-A[0])/2;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>
//#include<bits/stdc++.h>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;++i)
#define REP(i,s,n) for(int i=(s);i<(n);++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define REPR(i,s,n) for(int i=(s);i>=(n);--(i))
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
typedef vector<P> vP;
const ll mod = 1e9 + 7;
ll dx[4] = { 1,0,-1,0 };
ll dy[4] = { 0,1,0,-1 };

void printvll(vll v) {
	cout << "------------------------------------------------\n";
	rep(i, v.size()) cout << v[i] << " ";
	cout << endl;
	cout << "------------------------------------------------\n";
}
void printvvll(vvll v) {
	cout << "------------------------------------------------\n";
	rep(i, v.size()) {
		rep(j, v[i].size()) {
			cout << v[i][j] << " ";
		}
		cout << endl;
	}
	cout << "------------------------------------------------\n";
}

void prints(string s) {
	cout << "------------------------------------------------\n";
	rep(i, s.size()) cout << s[i] << " ";
	cout << endl;
	cout << "------------------------------------------------\n";
}

void printvs(vs s) {
	cout << "------------------------------------------------\n";
	rep(i, s.size()) {
		rep(j, s[i].size()) {
			cout << s[i][j] << " ";
		}
		cout << endl;
	}
	cout << "------------------------------------------------\n";
}

void Yes(bool x) {
	if (x) cout << "Yes\n";
	else cout << "No\n";
}

void YES(bool x) {
	if (x) cout << "YES\n";
	else cout << "NO\n";
}

void yes(bool x) {
	if (x) cout << "yes\n";
	else cout << "no\n";
}

ll calc(ll a) {
	if (a < 0) return 0;
	vll v = { a,1,a + 1,0 };
	return v[a % 4];
}

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

	ll  d, n, m, k, ans = 0, ret = M;
	bool flag = false, flag2 = false;
	string s, t;
	cin >> n >> m;
	cout << (calc(m) ^ calc(n - 1)) << endl;
	return 0;
}


Measured memory_bytes: 384
#include <stdio.h>
#include<stdlib.h>
int MEMO[100000];
int h[100000]={0};

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



#define TIMER_ON 0//提出時はここの「1」を「0」に書き換える
#if TIMER_ON
#include <time.h> 
clock_t start;
#endif

long int frog(int n){
	if (n==1) {MEMO[n]=abs(h[1]-h[0]);return MEMO[n];}
	if (n==2) {MEMO[n]=min(abs(h[2]-h[1])+abs(h[1]-h[0]),abs(h[2]-h[0]));return MEMO[n];}
	if (MEMO[n]>=0) return MEMO[n];
	MEMO[n]=min(frog(n-1)+abs(h[n]-h[n-1]),frog(n-2)+abs(h[n]-h[n-2]));
    return MEMO[n];
}


int asc(const void *a, const void *b) {
  return *(int *)a - *(int *)b;
}

int main(int argc, char *argv[]){
#if TIMER_ON
start = clock();
#endif

int n;
int i;

for (i=0;i<100000;i++) MEMO[i]=-1;


scanf("%d",&n);

for (i=0;i<n;i++) scanf("%d",&h[i]);
//  qsort(h,n, sizeof(int), asc);
//  printf("%d%d%d%d\n", h[0], h[1], h[2],h[3]); // "123"

printf("%d\n",frog(n-1));


#if TIMER_ON
printf("%.2f秒経過\n",(double)(clock()-start)/CLOCKS_PER_SEC);
#endif
return 0;
}




Measured memory_bytes: 2560
#include <iostream>
#include <iomanip>
#include <vector>
#include <complex>
#include <cmath>
#include <algorithm>
#include <map>
#define shosu(x) fixed<<setprecision(x)
using namespace std;
int main(){
	cout<<shosu(6);
	int a,b;
	cin>>a>>b;
	cout<<a*b/3.305785<<endl;
}

Measured memory_bytes: 1240
N = int(input())
S = input()
alphabet = 'ZABCDEFGHIJKLMNOPQRSTUVWXY'
alphabet_num = {st: num for num, st in enumerate(alphabet)}
alphabet_list = [st for st in alphabet]

for s in S:
  num = (alphabet_num[s] + N) % 26
  print(alphabet_list[num], end='')

Measured memory_bytes: 42992
""" abc055_b """

import sys
from functools import reduce

H = pow(10, 9) + 7

def _main():
    _n = int(sys.stdin.readline())

    # N! = aH + b
    # (N+1) * N! = aH(N+1) + b(N+1)
    #            = aH(N+1) + int(b(N+1)/H) * H + b(N+1) % H
    result = reduce(lambda a, n: (a * n) % H, range(1, _n + 1), 1)

    print(result)

if __name__ == '__main__':
    _main()


Measured memory_bytes: 3684
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <unordered_map>
#include <iomanip>
//#pragma GCC optimize("Ofast")  //デバッグ時にoptimized-outされて邪魔だった
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef pair<int,int> pii;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX / 2;
const ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  ll A, B, K;
  cin >> A >> B >> K;

  ll t = max(0LL, A - K);
  ll a = max(0LL, B - max(0LL, K - A));
  cout << t << " " << a << endl;
}

Measured memory_bytes: 256