akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <array>
#include <tuple>
#include <string>
#include <algorithm>
#include <functional> // greater など
#include <cmath>      // abs など
#include <numeric>    // accumulate, gcd など
#include <cassert>    // assert
#include <stdexcept>
#include <bitset>
using namespace std;

// #include <boost/multiprecision/cpp_int.hpp>
// using namespace boost::multiprecision;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
// typedef int128_t ll;
// typedef cpp_int ll;

// GCC, 配列のアクセスなど
#define _GLIBCXX_DEBUG
// Clang, 配列のアクセスなど
#define _LIBCPP_DEBUG 0

#define NDEBUG 1
// debug用出力 https://trap.jp/post/998/
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T)
{
    cerr << H << " ";
    debug_out(T...);
}
#ifdef NDEBUG
#define debug(...)
#else
#define debug(...) debug_out(__VA_ARGS__)
#endif

//////////////// //////////////// //////////////// //////////////// ////////////////
//////////////// //////////////// //////////////// //////////////// ////////////////

constexpr inline ll mod = 1'000'000'007;
constexpr int max_n = 200'000 + 5;

int n;
vector<vector<int>> tos(max_n);
ll sum;
vector<int> treesize1(max_n, 1); // 0を根とした部分木の大きさ

ll modpow(ll n, ll k)
{
    if (k == 0)
    {
        return 1;
    }
    else if (k % 2 == 0)
    {
        ll res = modpow(n, k / 2);
        return res * res % mod;
    }
    else
    {
        ll res = modpow(n, k - 1);
        return res * n % mod;
    }
}

ll modinv(ll n)
{
    return modpow(n, mod - 2);
}

void dfs1(int v, int par = -1) {
    for (auto u : tos[v]) {
        if (u == par) { continue; }
        dfs1(u, v);
        treesize1[v] += treesize1[u];
    }
    debug(v, treesize1[v]);
}

void dfs2(int v, int par = -1) {
    for (auto u : tos[v])
    {
        ll s;
        if (u == par)
        {
            s = n - treesize1[v];
        }
        else
        {
            s = treesize1[u];
            dfs2(u, v);
        }
        sum = (sum + modpow(2, s)) % mod;
        debug(v, u, s);
    }
}

int main()
{
    // 入出力
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << setprecision(10); // 浮動小数の表示の精度

    cin >> n;
    rep(i, n - 1) {
        int a,b; cin>>a>>b; a--; b--;
        tos[a].push_back(b);
        tos[b].push_back(a);
    }

    dfs1(0);
    dfs2(0);

    ll res = (modpow(2, mod - n) * (n - 2 - sum + mod) % mod + n) * modinv(2) % mod;
    cout << res << '\n';

    return 0;
}


Measured memory_bytes: 25964
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define all(v) v.begin(), v.end()
#define sz(v) v.size()
#define INF 100000000000000 //10^14
template <typename T>
bool chmax(T &a, const T& b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <typename T>
bool chmin(T &a, const T& b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
  if ((x += a.x) >= mod) x -= mod;
  return *this;
  }
  mint& operator-=(const mint a) {
  if ((x += mod-a.x) >= mod) x -= mod;
  return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
  if (!t) return 1;
  mint a = pow(t>>1);
  a *= a;
  if (t&1) a *= *this;
  return a;
  }
  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

vector<mint> dp(200001, 0);
vector<mint> dpc(200000, 0);

int main()
{
    ll N;
    cin >> N;
    vector<ll> C(N+1);
    C.at(0) = -1;
    rep(i, N) cin >> C.at(i+1);
    rep(i, N){
        C.at(i+1)--;
    }
    dp.at(0) = 1;
    rep(i, N){
        if(C.at(i) != C.at(i+1)){
            dpc.at(C.at(i+1)) += dp.at(i);
        }
        dp.at(i+1) = dpc.at(C.at(i+1));
    }
    cout << dp.at(N) << endl;
}

Measured memory_bytes: 8008
n = int(input())

a = list()
for i in range(n):
    a.append(int(input()))
    
sn = sum(a)

a.sort()

for i in range(n):
    if(sn%10!=0):
        break
    if(a[i]%10!=0):
        sn -= a[i]
        
    
if(sn%10==0):
    print(0)
else:
    print(sn)



Measured memory_bytes: 38384
import java.util.*;

public class Main {

  public static void main (String[] args) {

    Scanner sc = new Scanner(System.in);
    
    double W = sc.nextInt();
    double H = sc.nextInt();
    int x = sc.nextInt();
    int y = sc.nextInt();

    sc.close();

    int flg = 0;

    if (x == W /2 && y == H / 2){
      flg = 1;
    }

    System.out.println(W * H / 2 + " " + flg);
    
  }

}

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

int main() {
	int w1, h1, n;
	cin >> w1 >> h1 >> n;
	int w0 = 0;
	int h0 = 0;
	for (int i = 0; i < n; i++) {
		int x, y, a;
		cin >> x >> y >> a;
		if (a == 1) {
			if (w0 < x)w0 = x;
		}
		else if (a == 2) {
			if (w1 > x)w1 = x;
		}
		else if (a == 3) {
			if (h0 < y)h0 = y;
		}
		else {
			if (h1 > y)h1 = y;
		}
	}
	ll ans = (w1 - w0) * (h1 - h0);
	if ((w1 - w0) < 0 || (h1 - h0) < 0)ans = 0;
	cout << ans << endl;
}

Measured memory_bytes: 256
# coding;utf-8

n=int(input())
ans_dict={}
for i in range(0, n):
    a=input()
    if not a in ans_dict:
        ans_dict[a]=1
    else:
        ans_dict[a]+=1
sum=0
for thing in ans_dict:
    if ans_dict[thing]%2:
        sum+=1
print(sum)


Measured memory_bytes: 17884
#include<stdio.h>
#include<stdlib.h>
int main(){
	char day[8][10]={"Saturday",
			"Sunday",
			"Monday",
			"Tuesday",
			"Wednesday",
			"Thursday",
			"Friday",
	};
	int m,d,h,k=4;
	int j=20;
	for(;1;k=4){
		scanf("%d %d",&m,&d);
		if(!m && !d)break;
		if(m==1 || m==2){m+=12;k=3;}
		h=(d+((m+1)*26)/10+k+(k/4)+(j/4)-2*j)%7;
		if(h<0)h+=7;
		printf("%s\n",day[h]);
	}
	exit(0);
}

Measured memory_bytes: 0
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <array>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <regex>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
using ll = long long;

int main()
{
    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    // phase 1
    for (int y = sy; y < ty; y++)
        putchar('U');
    for (int x = sx; x < tx; x++)
        putchar('R');
    for (int y = ty; y > sy; y--)
        putchar('D');
    for (int x = tx; x > sx; x--)
        putchar('L');
    putchar('L');
    for (int y = sy; y < ty + 1; y++)
        putchar('U');
    for (int x = sx - 1; x < tx; x++)
        putchar('R');
    putchar('D');
    putchar('R');
    for (int y = ty; y > sy - 1; y--)
        putchar('D');
    for (int x = tx + 1; x > sx; x--)
        putchar('L');
    putchar('U');
    putchar('\n');
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
	int h, n, a, x;

	scanf("%d%d", &h, &n);
	x = 0;
	while (n--) {
		scanf("%d", &a);
		x += a;
	}
	printf(x >= h ? "Yes\n" : "No\n");
	return 0;
}


Measured memory_bytes: 128
#pragma GCC optimize("O2")
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using PII = pair<int,int>;
using PLL = pair<LL, LL>;
using VI = vector<int>;
using VVI = vector<vector<int>>;
const int INF = 1e9;
const int MXN = 0;
const int MXV = 0;
const double EPS = 1e-9;
const int MOD = 1e9+7;
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define FOR(i, L, R) for(int i = L; i < (int)R; ++i)
#define FORD(i, L, R) for(int i = L; i > (int)R; --i)
#define IOS cin.tie(nullptr); cout.tie(nullptr); ios_base::sync_with_stdio(false);

int main()
{
    IOS;
    int n;
    cin >> n;
    vector<int> h(n+5),dp(n+5);
    FOR(i,0,n){cin >> h[i];}
    fill(dp.begin(),dp.end(),INF);
    dp[0] = 0;
    FOR(i,1,n)FOR(j,1,3)
    {
        if(i-j<0)
        {
            break;
        }
        dp[i] = min(dp[i], dp[i - j] + abs(h[i] - h[i - j]));
    }
    cout << dp[n - 1] << '\n';
}


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

using namespace std;

typedef long long ll;
#define int ll
typedef long double ld;

typedef pair<int,int> pii;
#define x first
#define y second

signed main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    int a,v;
    int b,w;
    int t;
    cin>>a>>v>>b>>w>>t;
    if(abs(a-b)<=(v-w)*t)
        cout<<"YES\n";
    else
        cout<<"NO\n";
}


Measured memory_bytes: 3648
<?php
  $a = explode(' ', trim(fgets(STDIN)));
  $f = 0;
  $s = 0;

  foreach($a as $value){
  	if($value == 5){
      $f += 1;
    }elseif($value == 7){
    	$s += 1;
    }
  }
	if($f == 2 && $s == 1){
    	echo'YES';
    }else{
    	echo 'NO';
    }

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

int N, S;
int main() {
	while(cin >> N && N > 0) {
		int sum = 0;
		int largest = 0;
		int smallest = 1000;

		for(int i = 0; i < N; i++) {
			cin >> S;
			sum += S;
			if(S > largest) largest = S;
			if(S < smallest) smallest = S;
		}

		sum = sum - largest - smallest;
		//cout << "laegest:" << largest << endl;
		//cout << "smallest:" << smallest << endl;
		cout << sum / (N-2) << endl;

	}
}

Measured memory_bytes: 1156
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		long inputNum = scan.nextLong();
		scan.close();

		if (inputNum == 2) {
			System.out.println(2);
			return;
		}
		if (inputNum == 3) {
			System.out.println(3);
			return;
		}

		for (int i = 0; ; i++) {
			if (isPrimeNumber(inputNum + i)) {
				System.out.println(inputNum + i);
				return;
			}
		}
	}

	private static boolean isPrimeNumber(long value) {
		boolean ret = true;

		for (int i = 2; ; i++) {
			if (value % i == 0) {
				ret = false;
				break;
			}

			if (i >= (value / 2)) {
				break;
			}
		}
		return ret;
	}
}

Measured memory_bytes: 21844
h = list(input() for i in range(3))
hand = {'a':h[0], 'b':h[1], 'c':h[2]}   # 各手札
count = {'a':0, 'b':0, 'c':0}   # 捨てた枚数

def who_is_the_winner(ch):
    if ch == 'a':
        winner = 'A'
    elif ch == 'b':
        winner = 'B'
    else:
        winner = 'C'
    return winner

ch = 'a'
while True:
    count[ch] += 1
    if count[ch] == len(hand[ch])+1:
        winner = who_is_the_winner(ch)
        print(winner)
        break
    ch = hand[ch][count[ch]-1]

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
long long int t[105][100005];
long long int f(long long int wt[], long long int v[], long long int w, long long int n)
{
    if (w == 0 || n == 0)
    {
        return 0;
    }
    if (t[n][w] != -1)
    {
        return t[n][w];
    }
    // cout << wt[n] << "\n";
    if (wt[n] <= w)
    {
        return t[n][w] = max(v[n] + f(wt, v, w - wt[n], n - 1), f(wt, v, w, n - 1));
    }
    else
    {
        return t[n][w] = f(wt, v, w, n - 1);
    }
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    memset(t, -1, sizeof(t));
    long long int n, w;
    cin >> n >> w;
    long long int wt[n + 1], val[n + 1];
    for (int i = 1; i <= n; i++)
    {
        cin >> wt[i] >> val[i];
    }
    cout << f(wt, val, w, n) << "\n";
}

Measured memory_bytes: 85700
//{{{
#include <bits/stdc++.h>
using namespace std;
#define repX(a,b,c,x,...) x
#define repN(a) repX a
#define rep(...) repN((__VA_ARGS__,rep3,rep2,loop))(__VA_ARGS__)
#define rrep(...) repN((__VA_ARGS__,rrep3,rrep2))(__VA_ARGS__)
#define loop(n) rep2(i_,n)
#define rep2(i,n) rep3(i,0,n)
#define rep3(i,begin,end) for(int i=(int)(begin),i##_end=(int)(end);i<i##_end;++i)
#define rrep2(i,n) rrep3(i,n,0)
#define rrep3(i,begin,end) for(int i=(int)(begin-1),i##_end=(int)(end);i>=i##_end;--i)
#define foreach(x,a) for(auto&x:a)
using ll=long long;
const ll mod=(ll)1e9+7;
//}}}

bool check(string &s, int Q, int N, int pos, vector<char> &t, vector<char> &d, bool left_check)
{
  char c = s[pos];
  rep(i, Q){
    if(t[i] == c){
      pos += d[i] == 'L' ? -1 : 1;
      if(pos < 0) return left_check ^ true;
      if(pos >= N) return left_check ^ false;
      c = s[pos];
    }
  }
  return true;
}

int main()
{
  int N, Q;
  string s;
  cin >> N >> Q;
  cin >> s;
  vector<char> t(Q);
  vector<char> d(Q);
  rep(i, Q){
    cin >> t[i] >> d[i];
  }
  int ans = N;
  {
    int ok = N;
    int ng = -1;
    while(ok - ng > 1){
      int mid = (ok + ng) / 2;
      (check(s, Q, N, mid, t, d, true) ? ok : ng) = mid;
    }
    ans -= ng + 1;
  }
  {
    int ok = -1;
    int ng = N;
    while(ng - ok > 1){
      int mid = (ok + ng) / 2;
      (check(s, Q, N, mid, t, d, false) ? ok : ng) = mid;
    }
    ans -= N - ng;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1028
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //int:2*10**9
typedef long double ld;
typedef pair<ll,ll> P;
#define REP(i,n) for(ll i = 0; i<(ll)(n); i++)
#define REPS(i,n) for (ll i = 1; i<=(ll)(n); i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define vec2(name,i,j) vector<vector<ll>> name(i,vector<ll>(j))
#define vec2f(name,i,j,k) vector<vector<ll>> name(i,vector<ll>(j,k))
#define vec3(name,i,j,k) vector<vector<vector<ll>>> name(i,vector<vector<ll>>(j,vector<ll>(k)))
#define vec3f(name,i,j,k,l) vector<vector<vector<ll>>> name(i,vector<vector<ll>>(j,vector<ll>(k,l)))
#define vec4(name,i,j,k,l) vector<vector<vector<vector<ll>>>> name(i,vector<vector<vector<ll>>>(j,vector<vector<ll>>(k,vector<ll>(l))))
#define vec4f(name,i,j,k,l,m) vector<vector<vector<vector<ll>>>> name(i,vector<vector<vector<ll>>>(j,vector<vector<ll>>(k,vector<ll>(l,m))))
#define pb push_back
#define MOD 1000000007
#define MOD2 998244353
#define PI 3.141592653
#define INF 100000000000000 //14
//cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);

int main(){
    string s; cin >> s;
    ll n = s.length();
    s='2'+s;
    //cout << s << endl;
    if (s[1]!='1'||s[n]!='0'){
        cout << -1 << endl;
        return 0;
    }
    vector<ll> okl;
    FOR(i,1,n-1) if (s[i]!=s[n-i]){
        cout << -1 << endl;
        return 0;
    }
    FOR(i,1,n/2) if (s[i]=='1') okl.pb(i);
    ll j=1;
    ll ind = 0;
    while(j<=n/2){
        if (j==okl[okl.size()-1]) break;
        if (s[j]=='1'){
            if (ind+1<okl.size()){
                cout << okl[ind] << " " << okl[ind+1] << endl;
                ind++;
            }
        }
        else{
            cout << j << " " << okl[ind] << endl;
        }
        j++;
    }
    cout << j << " " << j+1 << endl;
    FOR(i,j+2,n) cout << j+1 << " " << i << endl;
}

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

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

#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())

#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).begin(),(c).end(),greater<int>())

#define PB(a) push_back(a)

#define FS first
#define SE second

#define ALL(x) (x).begin(),(x).end()
#define MAX_EL(c) *max_element((c).begin(),(c).end())
#define MIN_EL(c) *min_element((c).begin(),(c).end())
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<long long> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef string str;
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//grobal var
//------------------------------------------
int N,M;
bool visited[100];
bool world[100][100];


int main(){
// magic spell------------------------------
  cin.tie(0);
  ios::sync_with_stdio(false);
//------------------------------------------

  str S;
  cin >> S;
  int N=S.end()-S.begin();

  if(S=="0"){
    cout << "0" << endl;
    return 0;
  } 
  int ans=0;
  FOR(i,1,N){
    if(S[i]==S[i-1]){
      S[i] =  S[i-1]=='0'?'1':'0';
      ans++;
    }
    debug(S)
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
#include <map>
#include <queue>
#include <cmath>
#include <ctime>
#include <vector>
#include <cstdio>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <tr1/unordered_map>
#define mo 1000000007
#define num(x) (x>='0' && x<='9')
typedef unsigned long long ull;
typedef long long ll;
using namespace std::tr1;
using namespace std;
int read(){
    int p=0, q=1;
    char ch=getchar();
    while (!num(ch))
        (ch=='-'?q=-1:0),
        ch=getchar();
    while (num(ch)) p=p*10+ch-'0', ch=getchar();
    return p*q;
}
int power(ll a, int b){
	ll c=1;
	while (b){
		if (b&1) c=c*a%mo;
		a=a*a%mo;
		b>>=1;
	}
	return c;
}
#define N 200005
#define M N*3
int n, m, cnt, nex[M], nu[M], flag[N];
void add(int u, int v){
	nex[++cnt]=nex[u];nex[u]=cnt;nu[cnt]=v;
}
int sum;
void dfs(int u){
	sum++;
	flag[u]=1;
	for (int j=nex[u];j;j=nex[j]){
		int v=nu[j];
		if (!flag[v]) dfs(v);
	}
}
int main(){
	cnt=n=read();m=read();
	for (int i=1;i<=m;i++){
		int u=read(), v=read();
		add(u,v);
		add(v,u);
	}
	int ans=0;
	for (int i=1;i<=n;i++)
		if (!flag[i]) sum=0, dfs(i), ans=max(ans,sum);
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 17652
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		int b=scan.nextInt();
		int c=scan.nextInt();
		int cnt=0;
		
		for(int i=a;i<=b;i++){
			if(c % i == 0)cnt++;
		}
		System.out.println(cnt);
		
	}
}


Measured memory_bytes: 26368
#include <iostream>
#include <string>
#include <string.h>
using namespace std;

int main() {
	while(1){
		string str; cin >> str ; if(str=="0") break;
		int Color[3]={0};
		for(int i=1;i<str.size();i+=2){
			char ch[2];
			ch[0]=str[i],ch[1]=str[i+1];
			int tmp=0;
			for(int j=0;j<2;j++){
				if('0'<=ch[j] && ch[j]<='9') tmp+=(ch[j]-'0');
				else if('a'<=ch[j] && ch[j]<='f') tmp+=(ch[j]-'a')+10;
				if(j==0) tmp*=16;
			}
			Color[(int)( (i-1)/2 )] = tmp;
		}
		int samp[8][3]; memset(samp,0,sizeof(samp));
		samp[1][2]=samp[2][1]=samp[3][1]=samp[3][2]=255;
		samp[4][0]=samp[5][0]=samp[5][2]=samp[6][0]=samp[6][1]
		=samp[7][0]=samp[7][1]=samp[7][2]=255;
		string tmp[8];
		tmp[0]="black", tmp[1]="blue", tmp[2]="lime", tmp[3]="aqua",
		tmp[4]="red", tmp[5]="fuchsia", tmp[6]="yellow", tmp[7]="white";
		long MIN=0; for(int i=0;i<3;i++) MIN+=Color[i]*Color[i];
		string ans="black";
		for(int i=1;i<8;i++){
			long TMP=0;
			for(int j=0;j<3;j++) TMP+=(Color[j]-samp[i][j])*(Color[j]-samp[i][j]);
			if(TMP<MIN) MIN=TMP, ans=tmp[i];
		}
		cout << ans << '\n' ;
	}
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> ii;
#define DEBUG freopen("in.txt", "r", stdin);

struct fastio {
    fastio() {
        ios::sync_with_stdio(false);
        cout << setprecision(10) << fixed;
        cin.tie(0);
    }
};

fastio _fast_io;

const int N = 1e5 + 5;
int n, m;
int a[N], b[N];
ll sum;

int main() {
    cin >> n >> m;
    for (int i = 0; i < n; ++i) {
        cin >> a[i] >> b[i];
    }
    sort(a, a + n, greater<int>());
    sort(b, b + n, greater<int>());
    for (int i = 0; i < n; ++i) {
        if (b[i] <= a[0]) {
            m -= sum;
            cout << (m + a[0] - 1) / a[0] + i << endl;
            exit(0);
        }
        sum += b[i];
        if (sum >= m) {
            cout << i + 1 << endl;
            exit(0);
        }
    }
    m -= sum;
    cout << (m + a[0] - 1) / a[0] + n << endl;
    return 0;
}


Measured memory_bytes: 4392
#include<bits/stdc++.h>
using namespace std;
long long arr[1000000];
int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);   
    long long n,y;
    long long x=100;
    cin>>n;
    y=0;
    while (x<n)
    {
    	x=x+(0.01)*x;
    	y++;
	}
	cout<<y<<endl;
}

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

long long d[200][200];

void warshall_floyd(int n) {
  for (int k = 0; k < n; k++){       // 経由する頂点
    for (int i = 0; i < n; i++) {    // 始点
      for (int j = 0; j < n; j++) {  // 終点
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }
}

int main(){
    for(int i=0;i<200;++i){
        for(int j=0;j<200;++j){
            if(i==j)d[i][j]=0;
            else d[i][j]=1e18;
        }
    }
    int n,m,r;cin>>n>>m>>r;
    vector<int>R(r);
    for(int i=0;i<r;++i){
        cin>>R[i];
        R[i]--;
    }
    sort(R.begin(),R.end());
    for(int i=0;i<m;++i){
        long long a,b,c;
        cin>>a>>b>>c;
        a--;b--;
        d[a][b]=c;
        d[b][a]=c;
    }
    warshall_floyd(n);
    long long ans=1e18;
    do{
        long long sum=0;
        for(int i=1;i<r;++i){
            sum+=d[R[i-1]][R[i]];
        }
        ans=min(ans,sum);
    }while(next_permutation(R.begin(),R.end()));
    cout<<ans<<endl;
}


Measured memory_bytes: 3912
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back 
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define ld long double
#define int long long int 
#define F first 
#define S second
signed main()
{
    fast;
    int r;
    cin>>r;
    cout<<r*r;
}

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


using namespace std;
#define _rep(n, a, b) for (ll n = (a); n <= (b); ++n)
#define _rev(n, a, b) for (ll n = (a); n >= (b); --n)
#define _for(n, a, b) for (ll n = (a); n < (b); ++n)
#define _rof(n, a, b) for (ll n = (a); n > (b); --n)
#define oo 0x3f3f3f3f3f3f
#define ll long long
#define db double
#define eps 1e-6
#define bin(x) cout << bitset<10>(x) << endl;
#define what_is(x) cerr << #x << " is " << x << endl
#define met(a, b) memset(a, b, sizeof(a))
#define mp(a, b) make_pair(a, b)
#define all(x) x.begin(), x.end()
#define pii pair<ll, ll>
#define pdd pair<db, db>
#define pi acos(-1.0)
const ll maxn = 2e5 + 10;
signed main(){
	int n;
	cin >> n;
	bool app = 1;
	_rep(i, 1, n){
		int tmp ;
		cin >> tmp;
		if(tmp % 2== 0){
			if(tmp % 5 != 0 && tmp % 3 != 0){
				app = 0;
			}
		}
	}
	app ? cout << "APPROVED" << endl : cout << "DENIED" << endl;
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

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

typedef unsigned int uint;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef map<int, int> mii;
typedef map<string, int> msi;
typedef map<int, string> mis;
typedef pair<int, ii> edge;


#define sc(x)  scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mem(arr,val) memset(arr,val,sizeof arr)
#define sz(v) (int)v.size()
#define rsz(v) v.resize
#define clr(v) v.clear()
#define rev(v) reverse(all(v))
#define lop(i,end) for(int i=0; i<end; i++)
#define rlop(i,start) for(int i=start-1; i>=0; i--)
#define loop(i,start,end) for(int i=start; i<end; i++)
#define rloop(i,start,end) for(int i=start-1; i>=end; i--)
#define PB push_back
#define pb pop_back
#define mP make_pair
#define f first
#define s second

const ll OO = (4e18) + 9;
const int MOD = (1e9) + 7;
const int oo = 2147483647;
const double EPS = 1e-8;
const double PI = acos(-1.0);

//enum dir { r, d, l, u };
int dx[] = { 0, 1, 0,-1 };
int dy[] = { 1, 0,-1, 0 };

//enum diR { d, r, u, l , dr, ur, dl, ul };
int dX[] = { 1, 0, -1, 0, 1, -1, 1, -1 };
int dY[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

string abc = "abcdefghijklmnopqrstuvwxyz";
string vowels = "aeiou"; //and sometimes "aeiouy"

int dcmp(ld d1, ld d2) { return fabs(d1 - d2) <= EPS ? 0 : d1 > d2 ? 1 : -1; } //Compare Double Numbers
ll gcd(ll x, ll y) { return !y ? x : gcd(y, x%y); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
//convert index from 2D matrix to 1D array. (Zero-indexed)
int ord(int r, int c, int nCol) { return (nCol*r) + c + 1; }
//convert index from 1D array to 2D matrix . (One-indexed)
ii rord(int n, int nCol) {
	int r = n%nCol, c = n / nCol;
	if (n%nCol == 0) c--, r = nCol;
	return ii(r, c);
}

ll poww(ll num, ll p, ll md = MOD) {
	num %= md;
	ll ret = 1;
	while (p > 0) {
		if (p & 1) ret = (ret * num) % md;
		num = (num * num) % md;
		p >>= 1;
	}
	return ret;
}

ll nCr(ll n, ll r) {
	if (n < r)
		return 0;
	if (r == 0)
		return 1;
	return n * nCr(n - 1, r - 1) / r;
}

const int N = 400;



bool win[100100];

int main()
{
#ifndef ONLINE_JUDGE

#else
	//freopen("pyramid.in", "r", stdin);
#endif
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n, k;
	cin >> n >> k;
	vi v(n);
	lop(i, n) cin >> v[i];
	sort(all(v));
	for (int i = 1; i <= k; i++) {
		win[i] = false;
		lop(j, n) {
			if (i - v[j] >= 0) {
				if (!win[i - v[j]] || i == v[j]) {
					win[i] = true;
					break;
				}
			}
		}
	}
	if (win[k]) cout << "First\n";
	else cout << "Second\n";


	return 0;
}


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

using namespace std;

int main() {
  #ifdef LOCAL
    freopen("data.in", "r", stdin);
    freopen("data.out", "w", stdout);
  #endif
  int n;
  while(scanf("%d", &n) != EOF) {
    printf("ABC%d\n", n);
  }
  return 0;
}

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

using namespace std;


void ncout(int x , char ch) {
	for (int i = 0;i < x;i++) {
		cout << ch;
	}
}


int main() {
	int N, T[102] = { 0 }, M;
	cin >> N;
	for (int i = 1;i <= N;i++) {
		cin >> T[i];
	}
	cin >> M;
	int ans[102] = { 0 };
	int P, X;

	for (int i = 1;i <= M;i++) {
		cin >> P >> X;
		ans[i] = accumulate(T, T+N+1, 0) - T[P] + X;

	}

	for (int i = 1;i <= M;i++) {
		cout << ans[i] << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
const int inf=1e9+7;
const ll INF=1LL<<61;
const ll mod=1e9+7;

int main(){
  int i,j;
  int n;
  cin>>n;
  map<ll,ll> ma;
  for(i=0;i<n;i++){
    ll a;
    cin>>a;
    ma[a]++;
    if(ma[a]>1){
      cout<<"NO"<<endl;
      return 0;
    }
  }
  cout<<"YES"<<endl;
  

  return 0;
}



Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
int main() {
    int N,M;
    int K,A;
    cin >> N >> M;
    vector<int> c(M);
    for (int i=0;i<N;i++) {
        cin >> K;
        for (int i=0;i<K;i++) {
            cin >> A;
            c[A-1]++;
        }
    }
    int ans = 0;
    for (int i=0; i<M; i++) {
        if (c[i]==N) ans++;
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <cstring>
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <numeric>
#include <float.h>
#include <math.h>
#include <sstream>
using namespace std;
// repマクロの定義
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
// allマクロの定義
#define all(v) v.begin(), v.end()
const  long long INF = 1LL << 60;
typedef  long long ll;
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 ctoi(char c) {
 	switch (c) {
		case '0': return 0;
		case '1': return 1;
		case '2': return 2;
		case '3': return 3;
		case '4': return 4;
		case '5': return 5;
		case '6': return 6;
		case '7': return 7;
		case '8': return 8;
		case '9': return 9;
		default: return 0;
	}
}

auto my_lcm(auto n , auto m){
	auto a = n;
	auto b = m;
  if(n < m){
    auto tmp = n;
    n = m;
    m = tmp;
  }
  auto l  = n % m;
  while(l != 0){
    n = m;
    m = l;
    l = n % m;
}
return (a / m) * (b/m) * m;
}

int main(){ 
int N; cin >> N;
vector<ll> T(N);
rep(i,N) cin >> T[i];
ll a = 1;
rep(i,N){
	a = my_lcm(a,T[i]);
}
cout << a << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  public static void main(String args[])
  {
    Scanner scanner = new Scanner(System.in);
    int a = scanner.nextInt();
    int b = scanner.nextInt();
    int c = scanner.nextInt();

    if(a < b){
      if(b < c){
        System.out.println("Yes");
      }
      else{
        System.out.println("No");
      }
    }
    else{
      System.out.println("No");
    }
  }
}



Measured memory_bytes: 26260
#include<bits/stdc++.h>
#define INF (1e9)
#define N 105
using namespace std;
int n,dp[N],cnt,f;
string s[N],t[N];
map<string,int> m;
int edge[N];

int main(){
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>s[i];
    if(s[i]=="goto"){
      cin>>t[i];
      t[i][t[i].size()-1]=':';
    }
    else m[s[i]]=i;
  }
  for(int i=0;i<n;i++){
    if(s[i]=="goto")edge[i]=m[t[i]];
    else edge[i]=i+1;
  }
  for(int i=0;i<n;i++)dp[i]=INF;
  dp[n]=cnt=0,f=1;
  while(f){
    f=0;
    for(int i=n-1;i>=0;i--){
      if(dp[i]>dp[edge[i]])dp[i]=dp[edge[i]],f=1;
      if(dp[i]>dp[i+1]+1)dp[i]=dp[i+1]+1,f=1;
    }
  }
  cout<<dp[0]<<endl;
  return 0;
}

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

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

  vector<vector<string>> s(h, vector<string>(w));

  for (auto& hi : s)
    for (auto& si : hi)
      cin >> si;

  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      if (s[i][j] == "snuke") {
        printf("%c%d\n", 'A' + j, i + 1);
        return 0;
      }
    }
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int a=1;
string s,ss[220000];
signed main()
{
	cin>>s;
	ss[0]=s[0];
	for(int i=1;i<s.size();i++){
		ss[a]+=s[i];
		if(ss[a-1]!=ss[a]){
			a+=1;
		}
	}
	cout<<a;
}

Measured memory_bytes: 11140
#include <iostream>
#include <algorithm>

using namespace std;

static const int N = 65000;

int n;
int pi[N], jo[N];

main(){
  while(cin >> n && n){
    long long sum = 0;
    for(int i=0;i<n;i++){ cin >> pi[i]; sum += pi[i]; }
    for(int i=0;i<n-1;i++) cin >> jo[i];
    sort(jo, jo+n-1);
    long long ans = n * sum;
    for(int i=n-2;i>=0;i--){
      sum += jo[i];
      ans = max(ans, (i+1) * sum);
    }
    cout << ans << endl;
  }
}

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

int main() {
  int N; cin >> N;
  map<int, int> mp;
  rep(i, N - 1) {
    int A; cin >> A;
    A--;
    mp[A]++;
  }
  rep(i, N) cout << mp[i] << endl;
}

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


int main()
{
	int n,a=0,b=0;
	scanf("%d",&n);
	vector<int>v(n);
	for(int i=0 ; i < n ; i++)
		scanf("%d",&v[i]);
	sort(v.rbegin(),v.rend());
	for(int i=0 ; i < n ; i+=2)
	{
		a += v[i];
		if(i < n-1)
			b += v[i+1];
	}
	printf("%d\n",a-b);
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define ll long long
#define fr(i,k,N) for(ll i=k; i<N;i++)
#define rep(i,N) for(ll i=0; i<N;i++)
#define alll(v) v.begin(),v.end()
using namespace std;
template <class X> void pr(X test){cout<<test<<endl;}
template <class X> void prr(X test){for(auto it:test){cout<<it<<endl;}cout<<endl;}

int main() {
    ll n,k;
    cin>>n>>k;
    ll j = (n+1)/2;
    string s;
    if (j >=k) s="YES";
    else s = "NO";
    cout<<s<<endl;
    
}



Measured memory_bytes: 256
#include <stdio.h>

void class_(double w);

int main(void)
{
	double x;
	
	while (scanf("%lf", &x) != EOF){
		class_(x);
	}
	
	return (0);
}

void class_(double w)
{
	if (w <= 48.00)printf("light fly\n");
	if (w > 48.00 && w <= 51.00)printf("fly\n");
	if (w > 51.00 && w <= 54.00)printf("bantam\n");
	if (w > 54.00 && w <= 57.00)printf("feather\n");
	if (w > 57.00 && w <= 60.00)printf("light\n");
	if (w > 60.00 && w <= 64.00)printf("light welter\n");
	if (w > 64.00 && w <= 69.00)printf("welter\n");
	if (w > 69.00 && w <= 75.00)printf("light middle\n");
	if (w > 75.00 && w <= 81.00)printf("middle\n");
	if (w > 81.00 && w <= 91.00)printf("light heavy\n");
	if (w > 91.00)printf("heavy\n");
	
}

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

int main() {
	string s;
	cin >> s;

	int n = s.length();
	vector<int> group;

	int zero = 0;
	int one = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == '0') zero++;
		else one++;

		if (i == s.length() - 1) {
			group.push_back(zero > 0? zero : one);
		} else if (zero > 0 && s[i + 1] == '1') {
			group.push_back(zero);
			zero = 0;
		} else if (one > 0 && s[i + 1] == '0') {
			group.push_back(one);
			one = 0;
		}
	}

	int gsize = (int) group.size();
	if (gsize == 1) {
		printf("%d\n", group[0]);
		return 0;
	}

	int tot = 0;
	for (int i = 0; i < gsize; i++) {
		tot += group[i];
	}

	int ans = n;
	int tmp = 0;
	for (int i = 0; i < gsize - 1; i++) {
		tmp += group[i];
		tot -= group[i];

		ans = min(ans, max(n - tmp, n - tot));
	}

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

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

#define INF ((1<<30)-1)
#define LLINF (1LL<<60)
#define EPS (1e-10)

int dr[] = { 1, 0, -1, 0 };
int dc[] = { 0, 1, 0, -1 };

int main() {
    int H, W;
    cin >> H >> W;
    int sr, sc;
    int gr, gc;
    cin >> sr >> sc;
    cin >> gr >> gc;
    sr--; sc--;
    gr--; gc--;

    string b[1010];
    rep(i, H) cin >> b[i];

    vector< vector<int> > dist(H, vector<int>(W, INF));

    dist[sr][sc] = 0;
    deque<pair<int, int>> que;
    que.push_front({sr,sc});
    while (que.size()) {
        int r = que.front().first, c = que.front().second;
        que.pop_front();

        rep(d, 4) {
            int nr = r + dr[d], nc = c + dc[d];
            if (0 <= nr and nr < H and 0 <= nc and nc < W) {
                if (b[nr][nc] == '.' and dist[nr][nc] > dist[r][c]) {
                    dist[nr][nc] = dist[r][c];
                    que.push_front({nr, nc});
                }
            }
        }

        for (int er = -2; er <= 2; ++er) {
            for (int ec = -2; ec <= 2; ++ec) {
                int nr = r + er, nc = c + ec;
                if (0 <= nr and nr < H and 0 <= nc and nc < W) {
                    if (b[nr][nc] == '.' and dist[nr][nc] > dist[r][c] + 1) {
                        dist[nr][nc] = dist[r][c] + 1;
                        que.push_back({nr, nc});
                    }
                }
            }
        }
    }

    cout << (dist[gr][gc] == INF ? -1 : dist[gr][gc]) << endl;
}


Measured memory_bytes: 9440
#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 <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
using namespace std;

using ll = long long;

ll chart[11][5] = 
{};


ll n, k;

int main(void)
{
	for (ll i = 0; i < 11; ++i)
	{
		for (ll j = 0; j < 5; ++j)
		{
			chart[i][j] = (((7 * (i + 2) + (j + 2) - 7) * 9) + 110) % 11;
		}
	}
	scanf("%lld %lld", &n, &k);
	if (n <= 2)return 0 * printf("0\n");
	n -= 2;
	ll big = n / 11;
	ll small = n % 11;
	ll cnt[11] = {}; fill(cnt, cnt + 11, 0);
	for (ll i = 0; i < 11; ++i)
	{
		for (ll j = 0; j < 5; ++j)
		{
			++cnt[chart[i][j]];
		}
	}
	ll ans = cnt[k] * big;
	fill(cnt, cnt + 11, 0);
	for (ll i = 0; i < small; ++i)
	{
		for (ll j = 0; j < 5; ++j)
		{
			++cnt[chart[i][j]];
		}
	}
	ans += cnt[k];
	printf("%lld\n", ans);
	return 0;
}


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

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

  if (N[0] != 'A') {
    cout << "WA" << endl;
    return 0;
  }

  int flag = 0;
  for (int i = 2; i < N.size() - 1; i++) {
    if (N[i] == 'C') {
        flag++;
    }
  }

  if (flag != 1) {
    cout << "WA" << endl;
    return 0;
  }

  int count = 0;
  rep(i, N.size()) {
    if (islower(N[i]))
      count++;
  }

  if (count == N.size()-2) {
    cout << "AC" << endl;
    return 0;
  }

  cout << "WA" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
  //しょっぱなやばい、とけなそう感･･･
  //方針たたんな
  //最後から見るか。
  //連結数はN(N-1)/2。最後は-1;
  //毎回すべての連結確認する、はむりむり
  //1[2,3,,,10] 2[3,4,,,10] 3[4,5,,,10]みたいな
  //和を足せばいい？
  //んなことないか。1-2,1-3,2-3で1-2きれても3連結
  //孤立した島の積をとるか
  //1-2-3,4-5-6だったら3*3=9がだめ 3+3+3
  //1,2,3,4,5だったら？5*4/2 4+4+4+4+4)/2
  //1-2,3-4,5だったら8 3+3+3+3+4)/2
  //はしを1本折るごとに探索してたんじゃ絶対むりむりちん10^5でしょ
  //DP,どんなふうに・・・。
  //俺のもってる知識じゃまったくあてにならなそうだな。
  //解答みちゃう。
  //ミカサがどうしたって?
  //Union-Findすげえ。sizeを調べるのはどうしたらいいか
  //子どものsizeの配列をつねに用意。親に+1しとく
  //1-2でS[1]=2 S[2]=1
  //1-2-3 1-2-4 で、S[4]=1 S[3]=1 S[2]=3 S[1]=4みたいな感じか
  //S[親]+=S[子1]+S[子2]か
struct UnionFind{
  vector<ll> par;
  vector<ll> siz;
  
  UnionFind(ll N):par(N),siz(N,1){
    for(int i=0; i<N; i++){
      par[i]=i;
    }
  }
  
  ll root(ll x){
    if(par[x]==x)
       return x;
    par[x]=root(par[x]);
    return par[x];
  }
  
  void unite(ll x, ll y){
    ll rx=root(x), ry=root(y);
    if(rx==ry)
      return;
    par[ry] = rx;//x<yとしたい
    siz[rx]+=siz[ry];//小さい数に集める
  }
  
  bool issame(ll x, ll y){
    return root(x)==root(y);
  }
  
  ll size(ll x){
    return siz[root(x)];
  }
};

int main(){
  ll N,M;
  cin>>N>>M;
  vector<ll> A(M,0), B(M,0);
  for(int i=0; i<M; i++){
    ll a,b;
    cin>>a>>b;
    A[i]=a-1;
    B[i]=b-1;
  }  
  UnionFind tree(N);
  ll all=N*(N-1)/2;  
  vector<ll> ans(M,0);
  for(int i=M-1; i>=0; i--){
    ans[i]=all;
    if(all==0)
      break;
    //連結成分の大きさってなんだ
    //all-N1*N2をしたい
    //いみわかった。
    //1 2-3 4 5 9 10-1*1
    //1 2-3 4-5 8 9-1*1
    //1-2-3 4-5 6 8-1*2
    //1-2-3-4-5 0 6-3*2
    if(tree.issame(A[i],B[i])==false){
      all-=tree.size(A[i])*tree.size(B[i]);
    }
    tree.unite(A[i],B[i]);
  }
  for(int i=0; i<M; i++)
    cout<<ans[i]<<endl;
}


Measured memory_bytes: 5248
import sys
import copy
import  math
from _bisect import *
from collections import *
from operator import itemgetter
from math import factorial
"""
from fractions import gcd
def lcm(x, y):
    return (x * y) // gcd(x, y)
"""
stdin = sys.stdin
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
ns = lambda: stdin.readline()

h, w = na()
s = "#" * (w + 2)
img = [s]
for _ in range(h):
    img.append("#" + input() + "#")
img.append(s)
for i in range(h+2):
    print(img[i])



Measured memory_bytes: 3572
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
N = I()
s, t = M()
ans = ''
for i in range(N):
    ans += s[i]
    ans += t[i]
print(ans)

Measured memory_bytes: 38512
#include <iostream>
#include <iomanip>
#include <bits/stdc++.h>
#include <vector>
#include <iterator>
#include <string>
#define pan(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define vi vector<int>
#define pb push_back
using namespace std;
 
 
 
int main(){
    ll n,ans=0,i=1;
    cin>>n;
    if(n==1) cout<<1;
    else{
        do{
            n=n/2;
            i++;
        }while(n/2>0);
        for(ll j=0;j<i;j++){
            ans+=pow(2,j);
        }
        //cout<<i;
        cout<<ans;
    }
        
}

Measured memory_bytes: 256
// O(1)

   #include <bits/stdc++.h>




   using namespace std;         


int solve(){

	int x,y;
	if(!(cin>>x>>y)) exit(0);
	x=abs(x);
	y=abs(y);
	
	if(x%2==0 && y%2==0)return x+y;
	if(x>y) swap(x,y);
	if(x==0){
		if(y==1) return 1;
		else return y+1;
	}
	
	
	return 1+x/2*2+y/2*2;
}



 signed main(){
 	
 
    	       cin.tie(0);
   			ios::sync_with_stdio(false);
	
 	
 	while(1){
 		cout<<solve()<<endl;
 	}
 	
 	return 0;
 
  }
 


Measured memory_bytes: 3136
#include<bits/stdc++.h>
using namespace std;
int n,a,b,c,i,l[9],ans;
void dfs(int x,int A,int B,int C,int s){
	if(x>n){
    if(A&&B&&C)ans=min(ans,s+abs(a-A)+abs(b-B)+abs(c-C));
		return;
	}
	dfs(x+1,A,B,C,s);
	dfs(x+1,A+l[x],B,C,s+10*(A>0));
	dfs(x+1,A,B+l[x],C,s+10*(B>0));
	dfs(x+1,A,B,C+l[x],s+10*(C>0));
}
int main(){
	ans=1e9;
	cin>>n>>a>>b>>c;
	for(i=1;i<=n;i++)cin>>l[i];
	dfs(1,0,0,0,0);
	printf("%d",ans);
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define int long long
int hmt() {int x=0;int c=getchar(),n=0;for(;!isdigit(c);c=getchar()) n=(c=='-');for(;isdigit(c);c=getchar()) x=x*10+c-'0';if(n) x=-x;return x;}
#define in hmt()
#define ins ({string x;char c=getchar();for(;c==' '||c=='\n';c=getchar());for(;c!=' '&&c!='\n';c=getchar()) x+=c;x;})
#define forinc(i,a,b) for(int i=a,_b=b;i<=_b;++i)
#define fordec(i,a,b) for(int i=a;i>=b;--i)
#define forb(i,BS) for(int i=BS._Find_first();i< BS.size();i = BS._Find_next(i))
#define forv(a,b) for(auto &a:b)
#define pb push_back
#define pii pair<int,int>
#define fi first
#define se second
#define all(a) a.begin(),a.end()
#define reset(f,x) memset(f,x,sizeof(f))
#define bit(x,i) ((x>>(i-1))&1)
#define onbit(x,i) (x|(1<<(i-1)))
#define offbit(x,i) (x&~(1<<(i-1)))
int n;
struct oo {int a,b,c;};
vector<oo> ans;
main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin>>n;
    int nd=1,o=1;
    while(o*2<=n)
    {
        ans.pb({nd,nd+1,0});
        ans.pb({nd,nd+1,o});
        nd++;
        o*=2;
    }
    while(o<n)
    {
        int res=1,tmp=1;
        while(tmp<=n-o) tmp*=2,res++;
        tmp/=2;res--;
        ans.pb({res,nd,o});
        o+=tmp;
    }
    cout<<nd<<" "<<ans.size()<<" "<<"\n";
    forv(x,ans) cout<<x.a<<" "<<x.b<<" "<<x.c<<"\n";
}


Measured memory_bytes: 256
N, M = map(int, input().split())
n = [input().strip() for _ in range(N)]
m = [input().strip() for _ in range(M)]

ans = "No"
for y in range(N-M+1):
    for x in range(N-M+1):
        same = True
        for dy in range(M):
            for dx in range(M):
                if n[y+dy][x+dx] != m[dy][dx]:
                    same = False
                    break
            if not same:
                break
        if same:
            ans = "Yes"
            break
print(ans)


Measured memory_bytes: 40432
#include <bits/stdc++.h>
#define int long long
const int INF = 1e18L + 5;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;

signed main() {

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

    int n; cin >> n;
    vector<int> L(n);
    rep(i,n) cin >> L[i];
    sort(L.begin(),L.end());
    int ans = 0;
    rep(i,n) rep(j,i) {
        int ij = L[i]+L[j];
        int r = lower_bound(L.begin(), L.end(), ij) - L.begin();
        int l = i + 1;
        ans += max((long long)0,r-l);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <time.h>
#include <stdlib.h>
#include <string>
#include <bitset>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <sstream>
#include <stack>
#include <iomanip>
using namespace std;
#define pb push_back
#define mp make_pair
typedef pair<int,int> pii;
typedef long long ll;
typedef double ld;
typedef vector<int> vi;
#define fi first
#define se second
#define fe first
#define FO(x) {freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);}
#define Edg int M=0,fst[SZ],vb[SZ],nxt[SZ];void ad_de(int a,int b){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;}void adde(int a,int b){ad_de(a,b);ad_de(b,a);}
#define Edgc int M=0,fst[SZ],vb[SZ],nxt[SZ],vc[SZ];void ad_de(int a,int b,int c){++M;nxt[M]=fst[a];fst[a]=M;vb[M]=b;vc[M]=c;}void adde(int a,int b,int c){ad_de(a,b,c);ad_de(b,a,c);}
#define es(x,e) (int e=fst[x];e;e=nxt[e])
#define esb(x,e,b) (int e=fst[x],b=vb[e];e;e=nxt[e],b=vb[e])
#define SZ 666666
char s[SZ];
int main()
{
	scanf("%s",s);
	int a=0; ll b=0;
	for(int i=0;s[i];++i)
		if(s[i]=='W') b+=a;
		else ++a;
	cout<<b<<"\n";
}


Measured memory_bytes: 1020
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define sort(s) sort(s.begin(),s.end())
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind
#define rt (a); return (a); 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 1000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
int gcd(int a, int b) {
	if (b > a)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}

int main() {
	int n;
	cin >> n;
	hei(int)a(n), x(n), y(n);
	rep(i, 0, n)cin >> a[i];
	x[0] = a[0];
	y[n - 1] = a[n - 1];
	int ans = 0;
	rep(i, 1, n)x[i] = gcd(x[i - 1], a[i]);
	for (int i = n - 2; i >= 0; i--)y[i] = gcd(y[i + 1], a[i]);
	rep(i, 0, n) {
		if (i == 0) {
			ans = max(ans, y[i + 1]);
		}
		else {
			if (i == n - 1) {
				ans = max(ans, x[i - 1]);
			}
			else {
				ans = max(ans, gcd(x[i - 1], y[i + 1]));
			}
		}
	}
	cout << ans << endl;
		return 0;
}

Measured memory_bytes: 1408
#include <stdio.h>
int main(void){
    int n;
    int d[200];
    int count=0,h=0,j=0;
    
    if(scanf("%d",&n)==1);
    
    for(int i=0;i<n;i++){
        if(scanf("%d %d",&d[i*2],&d[i*2+1])==2);
        if(d[i*2]==d[i*2+1]){
            count++;
            h=count;
            if(h==3){
                j=1;
            }
        }
        else{
            count=0;
        }
    }
    
    if(j)
        printf("Yes");
    else
        printf("No");
    
    return 0;
}


Measured memory_bytes: 1736