akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#define MAX 10000
#define NIL -1

struct Node{
  int parent,left,right;
};

Node T[MAX];
int n,D[MAX],H[MAX];

void setDepth(int u,int d){
  if( u == NIL) return;
  D[u] = d;
  setDepth(T[u].left,d+1);
  setDepth(T[u].right,d+1);
}

int setHeight(int u){
  int h1 = 0, h2 = 0;
  if( T[u].left != NIL)h1 = setHeight(T[u].left) + 1;
  if( T[u].right != NIL)h2 = setHeight(T[u].right) + 1;
  return H[u] = (h1 > h2 ? h1 : h2);
}

int getSibling(int u){
  if(T[u].parent == NIL) return NIL;
  if(T[T[u].parent].left != u && T[T[u].parent].left != NIL)return T[T[u].parent].left;
  if(T[T[u].parent].right != u && T[T[u].parent].right != NIL)return T[T[u].parent].right;
  return NIL;
}

void print(int u){
  printf("node %d: ", u);
  printf("parent = %d, ", T[u].parent);
  printf("sibling = %d, ", getSibling(u));
  int deg = 0;
  if(T[u].left != NIL)deg++;
  if(T[u].right != NIL)deg++;
  printf("degree = %d, ",deg);
  printf("depth = %d, ",D[u]);
  printf("height = %d, ",H[u]);

  if(T[u].parent == NIL){
    printf("root\n");
  }else if(T[u].left == NIL && T[u].right == NIL){
    printf("leaf\n");
  }else{
    printf("internal node\n");
  }
}

int main(){
  int v,l,r,root = 0;
  scanf("%d",&n);

  for(int i = 0;i < n;i++)T[i].parent = NIL;

  for(int i = 0;i < n;i++){
    scanf("%d %d %d",&v,&l,&r);
    T[v].left = l;
    T[v].right = r;
    if( l != NIL) T[l].parent = v;
    if( r != NIL) T[r].parent = v;
  }

  for(int i = 0;i < n;i++)if(T[i].parent == NIL)root = i;

  setDepth(root,0);
  setHeight(root);

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

  return 0;
}



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

int main() {
  int n;
  cin >> n;
  vector<string> s(n);
  for (int i = 0; i < n; ++i) {
    cin >> s[i];
  }
  map<string, int> mp;
  for (int i = 0; i < n; ++i) {
    mp[s[i]]++;
  }
  int mx = 0;
  for (auto& kv : mp) {
    if (kv.second > mx) {
      mx = kv.second;
    }
  }
  for (auto& kv : mp) {
    if (kv.second == mx) {
      cout << kv.first << endl;
    }
  }
}


Measured memory_bytes: 28032
#include<bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define repk(i,k,n) for (ll i = k; i < (ll)(n); ++i)
#define INF 500000001000000000
#define MOD 1000000007
typedef long long  ll;

using namespace std;

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

	int A,P;
	cin >> A >> P;

	cout << (3*A + P) / 2 << endl;

	return 0;
}

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

typedef long long ll;

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

int main()
{
    int N;
    int A;
    int B;
    
    cin >> N >> A >> B;
    cout << min(N*A,B) << endl;
    return 0;
}

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

using namespace std;

int main()
{
    int m,d,cnt = 0;
    cin >> m >> d;
    for(int i = 2; i <= m; i++){
        for(int j = 22; j <= d; j++){
            if(j%10 == 1 )
                continue;
            if(i == (j%10)*(j/10))
                cnt++;
        }
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 384
N = int(input())
Ln = list(map(int,input().split(' ')))
Ln.sort(reverse=True)

count = 0
for a in range(N):
    a_l = Ln[a]
    current_min = N-1
    b = a +1
    while b <= current_min:
        c_idx = current_min
        bc = Ln[b] + Ln[c_idx]
        if a_l < bc:
            count += (current_min - b)
            b += 1
            continue
        current_min -= 1
    '''
    for b in range(a+1, N):
        if b >= current_min:
            break
        for c in range(b+1,N):
            c_idx = current_min
            bc = Ln[b] + Ln[c_idx]
            if a_l < bc:
                count += (current_min - b)
                break
            current_min -= 1
    '''
print(count)

Measured memory_bytes: 3188
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <list> 
#include<algorithm>
#include<cmath>
#include<map>
#include<vector>
#include<string>
#include<fstream>
#include<set>
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define forl(i,a,n) for(int i=a;i<n;i++)
#define rfor(i,n,a) for(int i=n;i>=a;i--)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pb push_back
#define ld long double
#define vi vector<int>
#define vll vector<long long>
#define pi pair<int,int>
#define pll pair<long long,long long>
#define mp make_pair
#define B begin()
#define E end()
#define S size()
#define m9 1000000007
using namespace std;
 
 

 
ll gcd(ll x,ll y)
{
    if(x==0) return y;
    return gcd(y%x,x);
}
 
/*
ll gcdextended(ll a, ll b, ll *x, ll *y) 
{ 
    if (a == 0) 
    { 
        *x = 0, *y = 1; 
        return b; 
    } 
  
    ll x1, y1; 
    int gcd = gcdextended(b%a, a, &x1, &y1); 
   
    *x = y1 - (b/a) * x1; 
    *y = x1; 
  
    return gcd; 
}
 
 
///RELATIVE COPRIME
ll modinverse(ll a, ll m) 
{ 
    ll x, y; 
   ll g = gcdextended(a, m, &x, &y); 
    if (g != 1) 
return -1;
    else
    { 
        ll res = (x%m + m) % m; 
        return res;  
    } 
} 
  */
ll powmod(ll x, ll y, ll m) 
{ 
    if (y == 0) 
        return 1; 
    ll p = powmod(x, y/2, m) % m; 
    p = (p * p) % m; 
    return (y%2 == 0)? p : (x * p) % m; 
} 
///M IS PRIME
ll modif(ll x,ll m){
return(powmod(x,m-2,m));
 
}
 
 
 
#define p0(a) cout << a << " "
#define p1(a) cout << a << endl
#define p2(a, b) cout << a << " " << b << endl
#define p3(a, b, c) cout << a << " " << b << " " << c << endl
#define p4(a, b, c, d) cout << a << " " << b << " " << c << " " << d << endl
#define pin(a) for(auto x:a)cout<<x<<" ";cout<<endl
#define fck(a) cout<<a;exit(0)
#define vvll vector<vector<ll> >
#define A(b) b.begin(),b.end()
#define vpi std::vector<pll>
#include <array>
#include <stack>
//include<bits/stdc++.h>
 
 
bool fa(vll &x,vll &y){return x[0]<y[0];}
bool fa1(vll &x,vll &y){return x[1]<y[1];}
bool f1(pll &x,pll &y){return x.second>y.second;}
bool f2(pll &x,pll &y){
    return x.first>y.first;
}
 
 
bool f3(ll &x,ll &y){
    return x>y; 
    }








const ll maxn=2e5+2;


int main()
{ fastio;
//freopen("test_input (1).txt", "r", stdin); 
//freopen("output.txt", "w", stdout);
ll m=0;
ll k;cin>>k;
ll ans=-1;
ll cnt=0;
ll r[k+1];
forl(i,0,k+1)r[i]=0;
while(r[m]==0){
    r[m]++;
    cnt++;
m*=10;
m%=k;
m+=7;
m%=k;
if(m==0){
ans=cnt;    break;
}

}
cout<<ans;






return 0;
}




  










Measured memory_bytes: 11424
#include<bits/stdc++.h>
using namespace std;
#define  ll long long int
int main(){
  ll x, y, A, B, C;
	cin >> x >> y >> A >> B >> C;
	vector<ll> a(A);
	vector<ll> b(B);
	vector<ll> c(C);
	for (int i = 0; i < A; ++i) {
		cin >> a[i];
	}
	for (int i = 0; i < B; ++i) {
		cin >> b[i];
	}
	for (int i = 0; i < C; ++i) {
		cin >> c[i];
	}
	sort(a.begin(), a.end(), greater<ll>());
	sort(b.begin(), b.end(), greater<ll>());
	ll ans = 0;
	for (int i = 0; i < x; ++i) {
		c.push_back(a[i]);
	}
	for (int i = 0; i < y; ++i) {
		c.push_back(b[i]);
	}
	sort(c.begin(), c.end(), greater<ll>());
	for (int i = 0; i < x + y; ++i)
		ans += c[i];
	cout << ans;
	return 0;
}
 
 
 
    
 
  
 

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

int main() {
  int N;
  cin >> N;
  
  for (int i=1; i<=N; i++){
    if(i*108/100 == N){
      cout << i << endl;
      break;
    }
    if(i*108/100 > N){
      cout << ":(" << endl;
      break;
    }
  }
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, k; cin >> n >> k;
  vector<int64_t> a(n, 0LL);
  for (int i = 0; i < n; i++)
    cin >> a[i];
  for (int i = 0; i < n - k; i++)
    cout << (a[i + k] > a[i] ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 4780
/*
 * @Author: RBQRBQ
 * @Date: 2020-04-17 00:12:29
 * @LastEditors: RBQRBQ
 * @LastEditTime: 2020-04-18 00:37:14
 */

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> VI;
typedef pair<int,int> pii;
namespace IO{
    template<typename T>inline void read(T &x){
        x=0;ll f=1;char ch=getchar();
        while(!isdigit(ch)){if(ch=='-')f=-f;ch=getchar();}
        while(isdigit(ch)){x=x*10+ch-48;ch=getchar();}
        x=x*f;
    }
}
using namespace IO;
const int maxn =200000;
int f[maxn+10];
int find(int x)
{
    if(f[x]==x) return x;
    else
    {
        f[x]=find(f[x]);
        return f[x];
    } 
}
int N;
ll M;
ll Q;
vector<pii> p1;
vector<pii> p2;
signed main()
{
    for(int i=0;i<=maxn;i++)
    f[i]=i;
    read(N),read(M),read(Q);
    ll pos=0;
    for(int i=1;i<=Q;i++)
    {
        int x,y,k;
        read(x),read(y),read(k);
        if(k==0) p1.push_back(make_pair(x,y));else p2.push_back(make_pair(x,y));
        if(k==0){
        int f1=find(x);
        int f2=find(y);
        if(f1!=f2) {
        pos++;
        f[f1]=f2;}
        }
    }
    ll cnt=0;
    if(M==N-1)
    {
        if(p2.size()!=0){
        cout<<"No";return 0;}
        else {cout<<"Yes";return 0;}
    }
    for(int i=0;i<N;i++)
    if(find(i)==i) cnt++;
    ll que=0;
    for(auto p:p2)
    {
        if(find(p.second)==find(p.first))
        {
            cout<<"No";
            return 0;
        }
    }
    if(cnt<=2)
    {
        
        if(p2.size()!=0)
        {
            cout<<"No";
            return 0;
        }
        else
        {
            if(cnt==1&&M>pos) {cout<<"No"; return 0;}
            if(cnt==2&&M>pos+1){cout<<"No"; return 0;}
            cout<<"Yes";
            return 0;
        }
    }
    else
    {
        ll ans=(1ll*cnt*(cnt-1))/2;
        
        if(((M-1ll*pos)>ans))
        {
            cout<<"No";
            return 0;
        }
        else
        {
            cout<<"Yes";
            return 0;
        }
        
    }
}


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

using namespace std;

int main()
{
  int n,m;
  map<string,int> blue,red;
  cin >> n;
  string s[102];
  for(int i = 0; i < n; ++i){
    cin >> s[i];
    blue[s[i]]++;
  }
  cin >> m;
  string t[102];
  for(int i = 0; i < m; ++i){
    cin >> t[i];
    red[t[i]]++;
  }
  int tot = 0;
  for(int i = 0; i < n; ++i){
    tot = max(tot,blue[s[i]]-red[s[i]]);
  }
  cout << tot << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
#include <sstream>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
#define sz(x) x.size()
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}

using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}
// 素数かどうか判定
bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}

const long long MOD = 1000000007;
const long long INF = 1LL << 60;
// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))


signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int m, d; cin >> m >> d;
	int ans = 0;
	for (int i = 1; i <= m; i++) {
		for (int j = 1; j <= d; j++) {
			int tmp = j;
			int tmp2 = j%10;
			tmp /= 10;
			if (tmp >= 2 && tmp2 >= 2 && tmp*tmp2 == i) {
				ans++;
			}
		}
	}
	cout << ans << endl;
	return 0;
}

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

#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define ll long long
#define rep(i,n) for(int i=0; i<n; i++)
#define INF 1000000000000000000 // If you use it, make sure not to put in "int" type variable ;(, use long long int
const ll mod=2;

int main()
{
    int nT; nT=1;
    while(nT--)
    {
        ll a,b,t; cin>>a>>b>>t;
        cout<<(t/a)*b;
    }
    return 0;
}

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

#define ll long long
#define ull unsigned long long

using namespace std;

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

	string s = "Christmas";

	int rem = 25 - d;

	for (int ii = 0; ii < rem; ++ii){
		s += " Eve";
	}

	cout << s << "\n";

	return 0;
}


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

using namespace std;

typedef unsigned int uint;
typedef unsigned long long ll;
typedef pair<uint, uint> Pos;

static const uint m_max = 500;
static const uint mod = 1000000007;

bool m[m_max+2][m_max+2];
// uint c[m_max+2][m_max+2];

const uint dx[] = { 2, 1, 0, 1 };
const uint dy[] = { 1, 2, 1, 0 };

// uint h, w;

int main(int, char**)
{
	uint n;
	cin >> n;
	vector<int> h(n, 0);
 int c[2];

	uint i;
	for (i = 0; i < n; i++) {
		cin >> h[i];
        cerr << h[i] << ", ";
    }

	c[0] = 0;
	c[1] = abs(h[1] - h[0]);
    // c[1] = abs(10 - 30);
  cerr << "\n" << c[0] << ", " << c[1];
	for (i = 2; i < n; i++) {
		uint n = min(c[i%2]+abs(h[i]-h[i-2]), c[(i-1)%2]+abs(h[i]-h[i-1])); 
		c[i%2] = n;
        cerr << ", " << c[i%2];
	}
  cerr << endl;

	cout << c[(i-1)%2] << endl;
	return 0;
}



Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <vector>
#define rep(i,n) for(int i=0;i<n;i++)
#define ll long long int
#define ii pair<int,int>
#define MAX 1000000007
using namespace std;

int main(void){
	int N;
	cin>>N;
	int tmp,max=0,ans=0;
	rep(i,N){
		cin>>tmp;
		if(max <= tmp){
			ans++;
			max = tmp;
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
import sys
import math
sys.setrecursionlimit(10**6)

MOD = 10**9+7


def main(input, print):
    n = int(input())

    ans = 10**n - 9**n - 9**n + 8**n
    ans %= MOD
    print(ans)


if __name__ == '__main__':
    main(sys.stdin.readline, print)


Measured memory_bytes: 89424
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    int N,M;
    int min = 1000000;
    int max = 1;
    cin >> N >> M;
    vector<int> L(M);
    vector<int> R(M);
    int Ans=0;
    for(int i = 0;i < M;i++){
        cin >> L[i] >> R[i];
        max = std::max(max,L[i]);
        min = std::min(min,R[i]);
    }
    if(min < max){
        cout << 0 << endl;
    }else{
    cout << min-max+1 << endl; 
    }
}

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

using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)

int main(){
  int n; 
  cin >> n;
  int i=0;
  int sum=0;
  while(sum<n){
    i++;
    sum+=i;    
  }
  int m=sum-n;
  for(int j=1;j<=i;j++){
    if(j==m)continue;
    else{
      cout << j << endl;
    }
  }
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){
    int height, width;
    cin >> height >> width;

    int c[10][10];
    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
            cin >> c[i][j];
        }
    }

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

    unsigned int d[11];
    bool flg[10];
    for(int i=0;i<10;i++){
        d[i] = c[i][1];
        flg[i] = false;
    }
    d[10] = 1000;
    flg[1] = true;

    for(int i=0;i<9;i++){
        int via = 10;
        for(int j=0;j<10;j++){
            if(!flg[j] && d[j]<d[via])via = j;
        }
        //cout << via << ":";
        flg[via] = true;
        for(int j=0;j<10;j++){
            int distance = c[j][via] + d[via];
            if(d[j]>distance)d[j] = distance;
        }
        //for(int j=0;j<10;j++)cout << d[j];
        //cout << endl;
    }

    //for(int i=0;i<10;i++)cout << "#" << d[i];

    unsigned long long ans = 0;
    for(int i=0;i<height;i++){
        for(int j=0;j<width;j++){
            if(a[i][j] != -1)ans += d[a[i][j]];
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 384
#pragma region includes, macros
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <map>
#include <set>
#include <list>
#include <unordered_set>
#include <unordered_map>
#include <stdlib.h>

using namespace std;
 
typedef int64_t i64;
typedef pair<i64, i64> P;

template<class T>
const T INF = numeric_limits<T>::max();
template<class T>
const T SINF = numeric_limits<T>::max() / 10;
static const i64 MOD = 1000000007;

//int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
//int dx[5] = {-1,0,0,0,1}, dy[5] = {0,-1,0,1,0};
//int dx[8] = {-1,0,1,1,1,0,-1,-1}, dy[8] = {1,1,1,0,-1,-1,-1,0};
//int dx[9] = {-1,0,1,1,1,0,-1,-1,0}, dy[9] = {1,1,1,0,-1,-1,-1,0,0};

struct edge {
	i64 from, to, cost;
	edge(i64 to, i64 cost) : from(-1), to(to), cost(cost) {}
	edge(i64 src, i64 to, i64 cost) : from(src), to(to), cost(cost) {}
};

template<typename T>
vector<T> make_v(size_t a){return vector<T>(a);}

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

template<typename T,typename V>
typename enable_if<is_class<T>::value==0>::type
fill_v(T &t,const V &v){t=v;}

template<typename T,typename V>
typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t,const V &v){
	for(auto &e:t) fill_v(e,v);
}
#pragma endregion

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	string s;
	cin >> s;
	int n = s.length();
	vector<vector<int>> dp(2, vector<int>(n, SINF<int>));
	for(int i = 0; i < n; ++i){
		if(i == 0){
			if(s[i] == '1'){
				dp[0][i] = 1;
				dp[1][i] = 0;
			}else{
				dp[0][i] = 0;
				dp[1][i] = 1;
			}
		}else{
			if(s[i] == '0'){
				dp[0][i] = dp[1][i - 1], dp[0][i - 1];
				dp[1][i] = dp[0][i - 1] + 1;
			}else{
				dp[1][i] = dp[0][i - 1];
				dp[0][i] = dp[1][i - 1] + 1;
			}
		}
	}
	cout << min(dp[0][n - 1], dp[1][n - 1]) << endl;
}

Measured memory_bytes: 1616
/**    Rose's very long and elaborated template    **/

#include<bits/stdc++.h>
#pragma GCC optimize("O3")
#define mod 1000000007
#define fi first
#define se second
using namespace std;
int a,b,c;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
    // shuffle(permutation.begin(), permutation.end(), rng);
    cin>>a>>b>>c;
    if(a>=b && a>=c)
        cout << a*10 + b + c;
    else
        if(b>=a && b>=c)
            cout << b*10 + a + c;
        else
            cout << c*10 + a + b;
    return 0;
}


Measured memory_bytes: 892
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int[][] card = new int[3][3];
    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++) {
        card[i][j] = sc.nextInt();
      }
    }

    int n = sc.nextInt();
    for (int cnt = 0; cnt < n; cnt++) {
      int num = sc.nextInt();
      for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
          if (card[i][j] == num) {
            card[i][j] = 0;
          }
        }
      }
    }
    sc.close();
    for(int i = 0; i < 3; i++){
      if(isAllZero(card[i][0], card[i][1], card[i][2]) || isAllZero(card[0][i], card[1][i], card[2][i])){
        System.out.println("Yes");
        return;
      }
    }
    if(isAllZero(card[0][0], card[1][1], card[2][2]) || isAllZero(card[0][2], card[1][1], card[2][0])){
      System.out.println("Yes");
      return;
    }
    System.out.println("No");
  }
  static boolean isAllZero(int a, int b, int c){
    if(a != 0 || b != 0 || c != 0){
      return false;
    } else {
      return true;
    }
  }
}

Measured memory_bytes: 35652
#include<bits/stdc++.h>
#define N 2010
using namespace std;
template<typename T>inline void read(T &x)
{
	x=0;
	static int p;p=1;
	static char c;c=getchar();
	while(!isdigit(c)){if(c=='-')p=-1;c=getchar();}
	while(isdigit(c)) {x=(x<<1)+(x<<3)+(c-'0');c=getchar();}
	x*=p;
}
int n,m;
char mp[N][N];
int a[N][N],b[N][N],up[N][N],righ[N][N],lef[N][N];
int ans;
int main()
{
	read(n);read(m);
	if(n==2&&m==2)
	{
		int res=0;
		char s[10];
		for(int i=1;i<=n;i++)
		{
			scanf("%s",s+1);
			for(int j=1;j<=m;j++)
				if(s[j]=='#')res^=1;
		}
		if(res)printf("3\n");
		else printf("4\n");
		return 0;
	}
	for(int i=1;i<=n;i++)
	{
		scanf("%s",mp[i]+1);
		for(int j=1;j<=m;j++) a[i][j]=mp[i][j]=='#';
	}
	for(int i=0;i<=n;i++)
		for(int j=0;j<=m;j++)
			b[i][j]=-1;
	for(int i=1;i<n;i++)
		for(int j=1;j<m;j++) b[i][j]=((a[i][j]+a[i+1][j]+a[i][j+1]+a[i+1][j+1])&1);
	n--;m--;
	for(int i=0;i<n;i++)
	{
		int l=-1,r=m;
		for(int j=0;j<m;j++)
			if(b[i+1][j+1]==1)
			{
				up[i+1][j+1]=lef[i+1][j+1]=0;
				l=j;
			}
			else if(b[i+1][j+1]==0)
			{
				up[i+1][j+1]=i==0?1:up[i][j+1]+1;
				lef[i+1][j+1]=i==0?l+1:max(lef[i][j+1],l+1);
			}
		for(int j=m-1;j>=0;j--)
			if(b[i+1][j+1]==1)
			{
				righ[i+1][j+1]=m;
				r=j;
			}
			else if(b[i+1][j+1]==0)
			{
				righ[i+1][j+1]=i==0?r-1:min(righ[i][j+1],r-1);
				ans=max(ans,(up[i+1][j+1]+1)*(righ[i+1][j+1]-lef[i+1][j+1]+1+1));
			}
	}
	printf("%d\n",max(ans,max(n+1,m+1)));
//	printf("%d\n",min(ans,n*m));
	return 0;
}

Measured memory_bytes: 83200
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<climits>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<bitset>
#include<iomanip>
using namespace std;

#define rep(i,j,n) for(int i=(j);i<(n);i++)
#define rep2(i,j,n) for(int i=(j);i<=(n);i++)
#define all(i) i.begin(),i.end()

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef pair<int, int> pi;

int main() {
	int n, m, x;
	cin >> n >> m >> x;
	vi a(m);
	vi b(n + 1, 0);
	rep(i, 0, m) {
		cin >> a[i];
		b[a[i]] = 1;
	}
	int sum = n - x;
	int ans = 0;
	rep2(i, x, n) {
		if (b[i]) {
			ans++;
		}
	}
	int ans2 = 0;
	for (int i = x; i >= 0; i--) {
		if (b[i]) {
			ans2++;
		}
	}
	cout << min(ans, ans2) << endl;
}


Measured memory_bytes: 256
(eval-when (:compile-toplevel :load-toplevel :execute)
  (defparameter OPT
    #+swank '(optimize (speed 3) (safety 2))
    #-swank '(optimize (speed 3) (safety 0) (debug 0)))
  #+swank (progn (ql:quickload '(:cl-debug-print :fiveam))
                 (shadow :run)
                 (use-package :fiveam)))
#+swank (cl-syntax:use-syntax cl-debug-print:debug-print-syntax)

;; BEGIN_INSERTED_CONTENTS
(defmacro define-int-types (&rest bits)
  `(progn
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "UINT~A" b)) () '(unsigned-byte ,b))) bits)
     ,@(mapcar (lambda (b) `(deftype ,(intern (format nil "INT~A" b)) () '(signed-byte ,b))) bits)))
(define-int-types 2 4 7 8 15 16 31 32 62 63 64)

(defmacro println (obj &optional (stream '*standard-output*))
  `(let ((*read-default-float-format* 'double-float))
     (prog1 (princ ,obj ,stream) (terpri ,stream))))

(defconstant +mod+ 1000000007)

;; Hauptteil

(defun main ()
  (let* ((n (read))
         (a (read-line))
         (b (read-line))
         (c (read-line)))
    (loop for c1 across a
          for c2 across b
          for c3 across c
          with cumul = 0
          do (cond ((char= c1 c2 c3) nil)
                   ((char= c1 c2) (incf cumul))
                   ((char= c2 c3) (incf cumul))
                   ((char= c3 c1) (incf cumul))
                   (t (incf cumul 2)))
          finally (println cumul))))

#-swank(main)


Measured memory_bytes: 16228
until (n = gets.to_i).zero?
  arr = Array.new(n + 1, Array.new(n + 1, 0))
  
  n.times do |i|
    arr[i] = gets.split.map(&:to_i).push(0)
    
    n.times do |j|
      arr[i][n] += arr[i][j]
    end
  end
  
  (n + 1).times do |i|
    (n + 1).times do |j|
      arr[n][i] += arr[j][i] unless j == n
    end
    
    puts "%5d" * (n + 1) % arr[i]
  end
end

Measured memory_bytes: 6132
// atcoder/abc088/D/main.cpp
// author: @___Johniel
// github: https://github.com/johniel/

#include <bits/stdc++.h>

#define each(i, c) for (auto& i : c)
#define unless(cond) if (!(cond))

using namespace std;

typedef long long int lli;
typedef unsigned long long ull;
typedef complex<double> point;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << "," << p.second << ")"; return os; }
template<typename P, typename Q> istream& operator >> (istream& is, pair<P, Q>& p) { is >> p.first >> p.second; return is; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ","; os << ")"; return os; }
template<typename T> istream& operator >> (istream& is, vector<T>& v) { each (i, v) is >> i; return is; }

template<typename T> inline T setmax(T& a, T b) { return a = std::max(a, b); }
template<typename T> inline T setmin(T& a, T b) { return a = std::min(a, b); }

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(0);
  cin.tie(0);

  int n;
  while (cin >> n) {
    vector<int> a(n);
    vector<int> b(n);
    cin >> a >> b;

    int z = 0;
    for (int k = 1 << 29; k; k /= 2) {
      each (i, a) i %= (k << 1);
      each (i, b) i %= (k << 1);
      sort(a.begin(), a.end());
      sort(b.begin(), b.end());
      int cnt = 0;
      each (i, a) {
        if (k & i) {
          cnt += lower_bound(b.begin(), b.end(), (k << 1) - i) - b.begin();
          cnt += b.end() - lower_bound(b.begin(), b.end(), (k << 1) + k - i);
        } else {
          cnt += lower_bound(b.begin(), b.end(), (k << 1) - i) - lower_bound(b.begin(), b.end(), k - i);
        }
      }
      if (cnt % 2) z |= k;
    }
    cout << z << endl;
  }

  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
const ll MOD = 1e9+7;
const ll SIZE = 4000;

ll n, k;
ll fact[SIZE];

ll modpow(ll base, ll exp) {
    ll result = 1LL;
    while(exp) {
        if(exp & 1)
            result = result * base % MOD;
        base = base * base % MOD;
        exp >>= 1;
    }
    return result;
}

ll inv(ll n) {
    return modpow(n, MOD-2);
}

ll modcomb(ll n, ll k) {
    if(n < k)
        return 0;
    return fact[n] * inv(fact[k]) % MOD * inv(fact[n-k]) % MOD;
}

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

    fact[1] = fact[0] = 1;
    for(ll i = 2; i < SIZE; i++)
        fact[i] = i * fact[i-1] % MOD;

    for(int i = 1; i <= k; i++) {
        ll ans = modcomb(k-1, i-1) * modcomb(n-k+1, i);
        cout << ans % MOD << endl;
    }
}


Measured memory_bytes: 256
import sys

input = sys.stdin.readline


def main():
    N = int(input())
    X = list(map(int, input().split()))

    A, B = sorted(X)[N // 2 - 1: N // 2 + 1]
    ans = [B if x <= A else A for x in X]
    print(*ans, sep="\n")


if __name__ == "__main__":
    main()


Measured memory_bytes: 25572
inputs = list(map(int, input().split()))
S = [inputs[x] for x in range(2)]
G = [inputs[x] for x in range(2,4)]
Dx = G[0] - S[0]
Dy = G[1] - S[1]
r1 = 'R'*Dx + 'U'*Dy
r2 = 'L'*Dx + 'D'*Dy
r3 = 'L'+'U'*(Dy + 1) + 'R'*(Dx+1)+'D'
r4 = 'R'+'D'*(Dy + 1) + 'L'*(Dx+1)+'U'
print(r1+r2+r3+r4)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using intl = long long;
using itnl = long long;//typo用
using itn = int;//typpo用
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define rrep(i, n) for(intl i = (intl)(n) - 1; i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define rrepi(i, a, b) for(intl i = (intl)(a); i > (intl)(b); i--)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl//1次元配列の出力
#define rrdebug(i, j, x) rep(i, alength(x))rep(j, alength(x[i]))cout << #x << "[" << i << "][" << j << "]:" << x[i][j] << endl//二次元配列の出力
#define pb push_back
#define mp make_pair
#define pii pair<intl,intl>
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld EPS = 1.0e-14;//-9
const ld PI = acos(-1);
void fp(bool f){cout << (f ? "Yes" : "No") << endl;}
void fp(bool f, string s, string t){cout << (f ? s : t) << endl;}
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; }
intl kai(intl k){//k!を求める関数
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl digit10(intl a){//aを10進数で表したときの桁数を求める関数
    intl b = 0;
    do{
        a /= 10;
        b++;
    }while(a);
    return b;
}

//--------------入力受け取る場所,分けてた方がデバッグしやすい気がする---------------------
intl n,m;
intl a[200000];
intl b[200000];
intl ans[200001];
void input_var(){
    cin >> n >> m;
    rep(i,m)cin >> a[i] >> b[i];
}
//-------------------------------------------------------------------------------

signed main(){
    cout << fixed << setprecision(10);
    input_var();
    vector<vector<intl> > v(n+1);
    rep(i,m){
        v[a[i]].pb(b[i]);
        v[b[i]].pb(a[i]);
    }
    rep(i,n+1)ans[i] = INF;
    queue<intl> q;
    bool flag[n+1];
    m1(flag);
    rep(i,v[1].size()){
        ans[v[1][i]] = 1;
        q.push(v[1][i]);
        flag[v[1][i]] = false;
    }
    intl cnt = 2;
    //cout << "-------------" << endl;
    while(!q.empty()){
        intl len = q.size();
        rep(i,len){
            intl qi = q.front();
            q.pop();
            rep(j,v[qi].size()){
                //cout << v[qi][j] << " ";
                if(!flag[v[qi][j]])continue;
                if(ans[v[qi][j]] == INF){
                    ans[v[qi][j]] = qi;
                    flag[v[qi][j]] = false;
                    q.push(v[qi][j]);
                }
            }
            //cout << endl;
        }
        cnt++;
    }
    bool f = true;
    repi(i,2,n+1){
        if(flag[i])f = false;
    }
    fp(f);
    if(f){
        repi(i,2,n+1)cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 16272
#pragma warning(disable:4996)

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <float.h>

#pragma region 定義
typedef long long  ll;
typedef unsigned long long  ull;


#define _itoa(A,N) sprintf(A, "%d", N);

int i_dsort(const void* a, const void* b);
int i_asort(const void* a, const void* b);

int  _gcd(int a, int b);
int  _swp(int* a, int* b);
int _cknum(char* a, int n);
int _atoi(char* s, int len);

int s_asort(const void* a, const void* b);
int s_dsort(const void* a, const void* b);

//昇順
int s_asort(const void* a, const void* b) {
	return(strcmp((char*)a, (char*)b));
}
int s_dsort(const void* a, const void* b) {
	return(strcmp((char*)b, (char*)a));
}

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

int _gcd(int a, int b) {
	int r, tmp;
	if (a < b) { tmp = a; a = b; b = tmp; }
	r = a % b;
	while (r) {
		if (!r) break;
		a = b; b = r;
		r = a % b;
	}
	return(b);
}
// puts("Yes\n") puts("No\n")
// scanf("%d.%d") 浮動小数点入力を整数２つで得る


//#define pai  3.1415926535 
//#define  _USE_MATH_DEFINES でM_PIが使える

#define deg_rad(X)  (X*(M_PI/180))


int _swp(int* a, int* b)
{
	int tmp;
	tmp = *b; *b = *a; *a = tmp;
	return 0;
}
#define _abs(x) ((x)>0?(x):-(x))
#define _min(x,y) ((x)<(y)?(x):(y))
#define _max(x,y) ((x)<(y)?(y):(x))

int _cknum(char* a, int n) {
	int i;
	char t = '0';

	for (i = 0; i < n; i++) {
		if (a[i] < '0' || a[i]>'9') return 1;
	}
	return 0;
}


int _atoi(char* s, int len) {
	char tmp[20];
	memcpy(tmp, s, len);
	tmp[len] = 0x00;
	return (atoi(tmp));
}

//素因数分解　pf素数が入る　pc 素数の数
ll _pfact(ll a);
static ll pf[100000000];
static ll pc;

ll _pfact(ll a) {
	long i, r;
	if (a % 2 == 0) {
		pf[pc] = 2; pc++;
		return(_pfact(a / 2));
	}
	r = sqrt(a);
	for (i = 3; i <= r; i += 2) {
		if (a % i == 0) {
			pf[pc] = i; pc++;
			return(_pfact(a / i));
		}
	}
	if (a != 1) {
		pf[pc] = a; pc++;
	}
	return 0;

}


#pragma endregion


//ABC  171 A

int main(void) {
	char       a;

	scanf("%c", &a);

	

	printf("%c\n", ((a<'a')?'A':'a'));
	return 0;
}


Measured memory_bytes: 2080
n = int(input())
cnt = [0, 0, 0, 0]
for i in range(n):
    result = str(input())
    if result == 'AC':
        cnt[0] += 1
    elif result == 'WA':
        cnt[1] += 1
    elif result == 'TLE':
        cnt[2] += 1
    else:
        cnt[3] += 1
print('AC x', cnt[0])
print('WA x', cnt[1])
print('TLE x', cnt[2])
print('RE x', cnt[3])

Measured memory_bytes: 9160
import sys
sys.setrecursionlimit(10 ** 7)
input = sys.stdin.readline

n, m = map(int, input().split())
x = [0]* n
y = [0]* n

box = [[1, 0] for _ in range(n)]
box[0] = [0,1]

for i in range(m):
    x, y = map(int, input().split())
    x,y= x-1,y-1

    if box[x][1]>0:
        box[x][1] = box[x][1]-1
        box[y][1] = box[y][1] + box[y][0] + 1
        box[y][0] = 0
    else:
        box[x][0] = box[x][0]-1
        if box[y][1]>0:
            box[y][1] = box[y][1]+1
        else:
            box[y][0] = box[y][0]+1

ans = 0
for i in range(n):
    if box[i][1]>0: ans+=1

print(ans)



Measured memory_bytes: 14836
#include <bits/stdc++.h>
using namespace std;
int n,a,x[55];
long long dp[55][55][2555];
int main()
{
    scanf("%d%d",&n,&a);
    for (int i=1;i<=n;++i) scanf("%d",&x[i]);
    dp[0][0][0]=1;
    for (int i=1;i<=n;++i) {
        for (int j=0;j<=i;++j)
            for (int k=0;k<=2500;++k) {
            dp[i][j][k]+=dp[i-1][j][k];
            dp[i][j+1][k+x[i]]+=dp[i-1][j][k];
        }
    }
    long long res=0;
    for (int i=1;i<=n;++i)
        res+=dp[n][i][i*a];
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 31284
from collections import defaultdict,deque, Counter
import sys,heapq,bisect,math,itertools,string,queue,copy,time
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())
ans = 0

n = inp()
ans = n*(n-1)//2
print(ans)

Measured memory_bytes: 12480
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if((a==b)&&(b!=c)||(c==b)&&(b!=a)||(a==c)&&(b!=c))System.out.println("Yes");
		else System.out.println("No");
		sc.close();
	}
}

Measured memory_bytes: 22484
#include <stdio.h>
#include <vector>
#include <iostream>
#include <queue>
#include <bits/stdc++.h>
 
#define rep(i,n) for (int i=0;i<(n);++i)
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<double> vd;
typedef pair<int, int> pi;


int main() {
  ll n;
  cin >> n;
  if (n % 2 == 1) {
    cout << 0 << endl;
    return 0;
  }

  ll ans = 0;
  ll m = 10;  
  while(n / m){
    ans += n / m;
    m *= 5;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define inf 0x3f3f3f3f
#define eps 1e-6
#define ll long long
using namespace std;
const int N = 2e5+5;
ll a[N],sum,b[N];
ll c(int x,int y)
{
  ll a=1,b=1;
  for(int i=y;i>y-x;i--)a*=i;
  for(int i=1;i<=x;i++)b*=i;
  return a/b;
}
int main()
{
  ios::sync_with_stdio(0);cin.tie(0);
  int n,x;
  cin>>n;
  for(int i=1;i<=n;i++)
  {
    cin>>x;a[x]++;b[i]=x;
  }
  for(int i=1;i<=n;i++)
  {
    if(a[i]>1)sum+=c(2,a[i]);
  }
  //cout<<sum<<endl;
  //for(int i=1;i<=n;i++)cout<<a[b[i]]<<" ";
  //cout<<endl;
  for(int i=1;i<=n;i++)
  {
    if(a[b[i]]>=2)cout<<sum-a[b[i]]+1<<endl;
    else cout<<sum<<endl;
  }

}


Measured memory_bytes: 4864
#include <bits/stdc++.h>
using namespace std;
int f[5];
int main()
{
    int nr,i;
    for(i=0;i<6;i++)
    {
        cin>>nr;
        if(++f[nr]>2)
        {
            cout<<"NO";
            return 0;
        }
    }
    cout<<"YES";
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define maxs(a, b) a = max(a, b)
#define mins(a, b) a = min(a, b)
using namespace std;
template<class T> inline istream& operator >> (istream & c, vector<T> & A) {rep(i, A.size()) c >> A[i];return c;}
typedef long long ll;
typedef pair<int, int> P;
const ll linf = (1ll << 61);
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	vector<int> d(n);
	cin >> d;
	sort(d.begin(), d.end());
	int ans = max(0, d[n / 2] - d[n / 2 - 1]);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3712
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define MOD7 1000000007
#define LL_INF 9000000000000000000
#define LL_MINF -9000000000000000000
#define INT_INF 2000000000
#define INT_MINF -2000000000
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int main(){
    int N;
    cin >> N;
    vector<int> P(N), Q(N);
    for(int i = 0; i < N; i++) cin >> P[i];
    for(int i = 0; i < N; i++) cin >> Q[i];
    vector<int> A(N);
    for(int i = 0; i < N; i++) A[i] = i+1;
    vector<vector<int>> all;
    do all.push_back(A);
    while (next_permutation(all(A)));
    int a, b;
    for(int i = 0; i < all.size(); i++){
        if(all[i] == P) a = i;
        if(all[i] == Q) b = i;
    }
    cout << abs(a - b) << endl;
}


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

int main(){
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  int res = 0;
  while(1){
    if(a[0] == a[1] && a[1] == a[2])break;
    sort(a,a+3);
    if(a[1] != a[2]){
      res++;
      a[0]++;
      a[1]++;
    }
    else {
      res++;
      a[0] += 2;
    }
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); ++i)
#define all(x) x.begin(),x.end()
#define ln '\n'
const long double PI = acos(-1.0L);
const long long MOD = 1000000007LL;
// const long long MOD = 998244353LL;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
template<class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true;} return false; }
template<class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true;} return false; }
//////////////////////////////////////////////////////////////////////////////////////////////////////////

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int N,K; cin >> N >> K;
    int ans = 0;
    while (N > 0) {
        N /= K;
        ans++;
    }
    cout << ans << ln;
}

Measured memory_bytes: 256
#include <iostream>
//#include <iomanip>
//#include <string>
#include <vector>
#include <algorithm>
#include <utility>
//#include <set>
#include <map>
//#include <queue>
//#include <deque>
//#include <bitset>
//#include <math.h>
using namespace std ;
using ll = long long ;
//using ld = long double ;
using vll = vector<ll> ;
using vvll = vector<vll> ;
//using vc = vector<char> ;
//using vvc = vector<vc> ;
//using vb = vector<bool> ;
//using vvb = vector<vb> ;
using pll = pair<ll,ll> ;

//ll mod = 1000000007 ;
//long double pie = acos(-1) ;

//string yorn(bool a){if(a) return"Yes" ; return "No" ;}
//string YorN(bool a){if(a) return"YES" ; return "NO" ;}
//ll gcd(long long a,long long b){if(b==0) return a ; return gcd(b,a%b) ;}
//ll lcm(long long a,long long b){return a/gcd(a,b)*b ;}
//ll sa(long long a,long long b){if(a>b) return a-b ; return b-a ;}
//void mysort(vector<long long> &a){sort(a.begin(),a.end()) ;}
//void myrev(vector<long long> &a){reverse(a.begin(),a.end()) ;}

void color(vvll &list,vll &edge,map<pll,ll> &m,ll n,int c){
	int sub = 1 ;
	for(int i=0;i<list.at(n).size();i++){
		if(edge.at(m[make_pair(min(n,list.at(n).at(i)),max(n,list.at(n).at(i)))])!=0) continue ;
		if(sub==c) sub++ ;
		edge.at(m[make_pair(min(n,list.at(n).at(i)),max(n,list.at(n).at(i)))]) = sub ;
		color(list,edge,m,list.at(n).at(i),sub) ;
		sub++ ;
	}
}

int main(){
	ll n ; cin >> n ;
	map<pll,ll> m ;
	vvll list(n,vll(0)) ;
	vll edge(n-1,0) ;
	for(int i=0;i<n-1;i++){
		ll a,b ;
		cin >> a >> b ;
		m[make_pair(a-1,b-1)] = i ;
		list.at(a-1).push_back(b-1) ;
		list.at(b-1).push_back(a-1) ;
	}
	ll mx = 0 ;
	ll pos = 0 ;
	for(int i=0;i<n;i++){
		ll sub = list.at(i).size() ;
		if(sub>mx){
			pos = i ;
			mx = sub ;
		}
	}
	cout << mx << endl ;
	color(list,edge,m,pos,-1) ;
	for(auto i:edge) cout << i << endl ;
}


Measured memory_bytes: 16768
#include <bits/stdc++.h>
#define rep(x, y) for(int x = 0; x < (y); x++)
#define REP(x, z, y) for(int x = (z); x < (y); x++)
#define all(x) x.begin(), x.end()
#define len(x) (sizeof(x) / sizeof(x[0]))
#define split_str(str, sp_word) istringstream stream(str); string res; for(int cnt = 0; getline(stream,res,sp_word); cnt++)
#define scanln(x) fgets(x, sizeof x, stdin)
#define down_queue(x) priority_queue<x>
#define up_queue(x) priority_queue<x, vector<x>, greater<x>>
#define i_str(x) atoi(x.c_str())
#define digit(x) ((int)log10((double)(x)) + 1)
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pf(x) push_front(x)
using namespace std;
const int MOD = 1000000007; 
typedef long long ll;
typedef string str;
 
int main(){
  int N;
  scanf("%d",&N);
  getchar();

  str line;
  getline(cin,line);
  int a[N],b1 = 0,b2 = 0,b4 = 0;
  split_str(line,' '){
    a[cnt] = i_str(res);
    int divi = 0;

    while(a[cnt] % 2 == 0){
      a[cnt] /= 2;
      divi++;
    }

    if(divi == 0) b1++;
    else if(divi == 1) b2++;
    else if(divi >= 2) b4++;
  }

  if(b2) b1++;   

  printf("%s",b1 <= b4 + 1 ? "Yes" : "No");
  return 0;
}

Measured memory_bytes: 2692
# 連結成分に分解、異なる連結成分から一人ずつ集めたグループが１セット。
# これを全ての連結成分が空になるまで繰り返す。
# 全ての連結成分が空になる <===> 連結成分の最大の要素数回この操作を繰り返せば良い。
# Union FInd が一番適してそう。
class UnionFind():
    
    def __init__(self,N):
        self.N = N
        self.par = [-1]*N
    
    def find(self,x):
        if self.par[x]<0:return x
        else:
            self.par[x]=self.find(self.par[x])
            return self.par[x]
    
    def union(self,x,y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return 
        
        if self.par[x]>self.par[y]:
            x,y = y,x
        
        self.par[x] += self.par[y]
        self.par[y] = x
    

N,M=map(int,input().split())
uf = UnionFind(N)
for _ in range(M):
    a,b = map(int,input().split())
    a -= 1;b -= 1
    uf.union(a,b)
print(-min(uf.par))

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

const int INF = 2e9;

int main(){
    int n,a,b,c,d;
    cin >> n >> a >> b >> c >> d;
    string s;
    cin >> s;
    int p = 0;
    for(int i = a;i < max(c,d);i++){
        if(s[i] == '#' && s[i-1] == '#'){
            p++;
            break;
        }
    }
    if(d < c){
        p++;
        for(int i = b;i <= d;i++){
            if(s[i] == '.' && s[i-1] == '.' && s[i-2] == '.'){
                p--;
                break;
            }
        }
    }
    if(p == 0) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 3644
import java.util.*;
class Main{
public static void main(String[] args){
 Scanner sc = new Scanner(System.in);

int a=sc.nextInt(); 
int b=sc.nextInt();
int c=sc.nextInt();
int d=sc.nextInt();
int e=sc.nextInt();
int f=sc.nextInt();
if((a+b+c+d+e+f)==15){
System.out.println("YES");
}else{
System.out.println("NO");
}
}
}

Measured memory_bytes: 22740
#include <iostream>
#include <cstring>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <set>
#include <utility>
#include <cstdlib>
#include <queue>
#include <stack>
#include <iomanip>
#include <cstdio>
#include <map>

using namespace std;

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

#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = ((ll)(x) - 1); i >= 0; i--)

#define _upgrade ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

//ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
//ll lcm(ll x, ll y) {return x / gcd(x, y) * y;}

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

const ll mod = 1e9 + 7;
const ll INF = 1LL << 60;
const double PI = 3.14159265358979323846;


// ****************************************CODE***************************************//



int N,M;

int main(){
        cin >> N >> M;
        vector<ll> a[3];
        for(int i = 0; i < N; i++){
                for(int j = 0; j < 3; j++){
                        ll num;
                        cin >> num;
                        a[j].push_back(num);
                }
        }

        //それぞれの総和の絶対値を求める
        //総和の絶対値はそれぞれの絶対値の最大を求めるのではなく二通りしかない。それぞれをプラスで掛けて合わせたものか、マイナスでかけて合わせたものかの二通りしかない。
        ll res = 0;
        for(int bit = 0; bit < (1 << 3); bit++){
                vector<ll> b;
                for(int i = 0; i < N; i++) {
                        ll tmp = 0;
                        for(int j = 0; j < 3; j++){
                                if(bit & (1 << j)) tmp += a[j][i];
                                else tmp -= a[j][i];
                        }
                        b.push_back(tmp);
                }
                sort(b.begin(), b.end(), greater<ll>());
                ll sum = 0;
                for(int i = 0; i < M; i++){
                        sum += b[i];
                }
                res = max(res,sum);
        }

        cout << res << endl;
}


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

using namespace std;

const int INF = 1e9 + 5;

int main() {
    int n;
    scanf("%d", &n);
    vector<int> h(n);
    for(int i=0; i<n ; i++) {
        scanf("%d", &h[i]);
    }
    vector<int> dp(n, INF);
    dp[0] = 0;
    for(int i = 0; i < n; ++i) {
        for(int j=i+1; j<(i+3); j++) {
            if(j < n) {
                dp[j] = min(dp[j], dp[i] + abs(h[i] - h[j]));
            }
        }
    }
    printf("%d\n", dp[n-1]);
}


Measured memory_bytes: 1024
S = input()

if S == 'SUN':
    print(7) 
elif S == 'MON':
    print(6) 
elif S == 'TUE':
    print(5) 
elif S == 'WED':
    print(4) 
elif S == 'THU':
    print(3) 
elif S == 'FRI':
    print(2) 
else:
    print(1)

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

int main() {
  int N, n1, n2, n3, n4;
  cin >> N;
  n1 = N / 1000;
  N %= 1000;
  n2 = N / 100;
  N %= 100;
  n3 = N / 10;
  n4 = N % 10;
  
  if(((n1==n2)&&(n2==n3))||((n2==n3)&&(n3==n4)))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

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

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

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

    int M;
    cin >> M;

    vector<int> P(M);
    vector<int> X(M);
    for (int i = 0; i < M; i++) {
        cin >> P[i] >> X[i];
    }

    int sum = 0;
    for (int i = 0; i < N; i++) {
        sum += T[i];
    }

    for (int i = 0; i < M; i++) {
        cout << sum - T[P[i] - 1] + X[i] << endl;
    }
}

Measured memory_bytes: 256