akhauriyash/Code-Regression huggingface dataset:
/*
[abc133] E - Virus Tree 2
*/

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;

const int MAX_N = 1e5;
const int MOD = 1e9 + 7;

class gf {
public:
    int n;
    static int extgcd(int a, int b, int& x, int& y) {
        int d = a;
        if (b != 0) {
            d = extgcd(b, a % b, y, x);
            y -= (a / b) * x;
        } else {
            x = 1;
            y = 0;
        }
        return d;
    }
    static int mod_inv(int a, int m) {
        int x, y;
        extgcd(a, m, x, y);
        return (m + x) % m;
    }
    gf() : n(0) {}
    gf(int n) : n(n % MOD) {}
    gf operator+(const gf x) const { return gf((n + x.n) % MOD); }
    gf operator-(const gf x) const { return gf((n - x.n + MOD) % MOD); }
    gf operator*(const gf x) const { return gf((1LL * n * x.n) % MOD); }
    gf operator/(const gf x) const { return *this * x.inv(); }
    gf& operator+=(const gf x) { return *this = (*this + x); }
    gf& operator-=(const gf x) { return *this = (*this - x); }
    gf& operator*=(const gf x) { return *this = (*this * x); }
    gf& operator/=(const gf x) { return *this = (*this / x); }
    gf inv() const { return gf(mod_inv(n, MOD)); }
    gf pow(ll e) const {
        gf a = *this;
        gf x = 1;
        for (; e > 0; e >>= 1) {
            if (e & 1) {
                x = x * a;
            }
            a = a * a;
        }
        return x;
    }
};

int N, K;
vector<int> g[MAX_N];

gf dfs(int v, int par = -1) {
    if ((int)g[v].size() >= K) {
        return 0;
    }

    gf ret = 1;
    int k = (par == -1 ? K - 1 : K - 2);
    for (int to : g[v]) {
        if (to == par) {
            continue;
        }
        ret *= k;
        k--;
        ret *= dfs(to, v);
    }
    return ret;
}

ll solve() { return (dfs(0) * K).n; }

int main() {
    cin >> N >> K;
    for (int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    cout << solve() << endl;

    return 0;
}


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

int main() {
    int m, f, r; cin >> m >> f >> r;
    while (m != -1 || f != -1 || r != -1) {
        int sum_p = m + f;
        string result;
        if (m == -1 || f == -1) result = "F";
        else if (sum_p >= 80) result = "A";
        else if (65 <= sum_p && sum_p < 80) result = "B";
        else if ((50 <= sum_p && sum_p < 65) || r >= 50) result = "C";
        else if (30 <= sum_p && sum_p < 50) result = "D";
        else if (sum_p < 30) result = "F";
        
        cout << result << endl;
        
        cin >> m >> f >> r;
    }
    return 0;
}


Measured memory_bytes: 3172
#include<iostream>
#include<cmath>
#include<algorithm>
#include<string>
#include<vector>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<iomanip>
#include<bitset>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<ll,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define fi first
#define sc second
#define rep(i,x) for(ll i=0;i<x;i++)
#define repn(i,x) for(ll i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())

const int MAX = 510000;
const int MOD = 1000000007;

ll dp[210][210];
// dp[i][j] は from i to jまで　の積の計算の最小回数

int main(){
  ll N; cin >> N;
  vector<P> a(N); rep(i,N) cin >> a[i].fi >> a[i].sc;

  // dp 初期化
  rep(i,N) rep(j,N) dp[i][j] = INF;
  rep(i,N) dp[i][i] = 0;

  repn(i,N){
    // iはいくつ離れてるか
    rep(j,N){
      // j is start
      for(ll k = j; k <= i + j; k++){
        // k が空いてた
        if(k == j){
          dp[j][j + i] = min(dp[j][j + i] , a[k].fi * a[k].sc * a[j + i].sc  + dp[j + 1][j + i]);
        }
        else if(k == i + j){
          dp[j][j + i] = min(dp[j][j + i] , dp[j][j + i - 1] + a[j].fi * a[k].fi * a[k].sc);
        }
        else{
          dp[j][j + i] = min(dp[j][j + i] ,
            dp[j][k] + a[j].fi * a[k].sc * a[j + i].sc + dp[k + 1][j + i]);
        }
      }
    }
  }

  // rep(i,N) rep(j,N) cout << i << " " << j << " " << dp[i][j] << endl;

  cout << dp[0][N - 1] << endl;
}



Measured memory_bytes: 3248
#include <cstdio>
#include <cmath>
#include <stack>
#include <queue>
#include <string>
#include <iostream>
#include <sstream>
#include <ostream>
#include <cstring>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <map>
#include<iomanip>
#include <set>
#define INT_MINs -2000000000
#define INT_MAXs 1000000001
#define mod 1000000007
#define MID mid=(l+r)/2
#define REP1(i,x,y) for(int i=x;i<y;i++)
#define REP2(i,x,y) for(int i=x;i<=y;i++)
#define ls (2*k)
#define lr (2*k+1)
#define lson l,mid,2*k
#define lron mid+1,r,2*k+1
#define inf 0x3f3f3f3f
#define INF 0x3f3f3f3f3f3f3f3f
#define IOS ios::sync_with_stdio(0);
#define pb(a) push_back(a)
#define pi acos(-1)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int dx[8] = { 0,-1,0,1,-1,-1,1,1}, dy[8] = { 1,0,-1,0,-1,1,-1,1};
int num[10000005];
int main()
{
    int n;
    cin>>n;
    printf("%d\n",n+n*n+n*n*n);
    return 0;
}


Measured memory_bytes: 3160
str_ = input()
q = int(input())
ss = str_
ans = []
for i in range(q):
  t = input().split(' ')
  if t[0] == 'replace':
    s = ss[0: int(t[1])]
    e = ss[int(t[2]) + 1:len(ss)]
    ss = s + t[3] + e
  elif t[0] == 'reverse':
    s = ss[0: int(t[1])]
    c = ss[int(t[1]):int(t[2]) + 1]
    e = ss[int(t[2]) + 1:len(ss)]
    ss = s + c[::-1] + e
  elif t[0] == 'print':
    ans.append(ss[int(t[1]):int(t[2]) + 1])
for a in ans:
  print(a)


Measured memory_bytes: 5624
#include <stdio.h>

int max(int a,int b){
  if(a > b){
    return a;
  }
  return b;
}

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

int main(void){
  int A,B,C,X,Y;
  scanf("%d%d%d%d%d",&A,&B,&C,&X,&Y);

  int ans;
  if(X < Y) ans = X*2*C+(Y-X)*B;
  else ans = Y*2*C+(X-Y)*A;

  ans = min(ans,A*X+B*Y);
  ans = min(ans,max(X,Y)*2*C);

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

  return 0;
}

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

#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
#define all(x) (x).begin(), (x).end()
#define uniq(x) (x).erase(unique(all(x)), end(x))
#define bit(n) (1LL << (n))
#define cdiv(a, b) (((a) - 1) / (b) + 1)
#define dump(x) cerr << #x " = " << (x) << endl
using vint = vector<int>;
using vvint = vector<vint>;
using pint = pair<int, int>;
using vpint = vector<pint>;
template<typename T> using priority_queue_rev = priority_queue<T, vector<T>, greater<T>>;
constexpr double PI = 3.1415926535897932384626433832795028;
constexpr int DY[8] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr int DX[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
template<typename T> void fin(T mes) {
    cout << mes << endl;
    exit(0);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> bool chmin(T &a, const U &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}
template<typename T, typename U> ostream &operator<<(ostream &os, const pair<T, U> &rhs) {
    os << "(" << rhs.first << ", " << rhs.second << ")";
    return os;
}
template<typename T> ostream &operator<<(ostream &os, const vector<T> &rhs) {
    os << "{";
    for (auto itr = rhs.begin(); itr != rhs.end(); itr++) {
        os << *itr << (next(itr) != rhs.end() ? ", " : "");
    }
    os << "}";
    return os;
}
struct setup {
    static constexpr int PREC = 20;
    setup() {
        cout << fixed << setprecision(PREC);
        cerr << fixed << setprecision(PREC);
    };
} setup;

std::vector<std::pair<long long, int>> get_prime_factors(long long n) {
    std::vector<std::pair<long long, int>> ret;
    for (long long i = 2; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back({i, 1});
            n /= i;
        }
        while (n % i == 0) {
            ret.back().second++;
            n /= i;
        }
    }
    if (n != 1) { ret.push_back({n, 1}); }
    return ret;
}

signed main() {
    int N;
    cin >> N;
    int ans = 0;
    vpint d = get_prime_factors(N);
    rep(i, d.size()) {
        int k = d[i].second;
        int j = 1;
        while (k >= j) {
            ans++;
            k -= j;
            j++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
from math import sqrt

N = 10 ** 6
# 初期値は全部trueでリストにセット
p = [True] * (N + 1)
# 2以上だから1以下はfalse
p[0] = False
p[1] = False
n = int(sqrt(N) + 1)
# 3の2ステップで奇数4の2ステップで偶数を潰す
# 素数がありえるとしたら奇数行だからそこでまたfor文
for j in range(4, N + 1, 2):
  p[j] = False
for i in range(3, n + 1, 2):
#   もしp[j]とかぶるものがあればfalse
  if p[i]:
    for j in range(i + i, N + 1, i):
      p[j] = False



X = int(input())
for i in range(X, N + 1):
    if p[i]:
        print(i)
        break

Measured memory_bytes: 10868
#include<bits/stdc++.h>
#define sqr(x) ((x)*(x))
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define ld long double
#define vi vector<int>
#define HEAP priority_queue
#define heap(T) priority_queue<T,vector<T>,greater<T> > 
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define debuge cerr<<"isok"<<endl
#define debug(x) cerr<<#x<<"="<<x<<endl
#define SS second
#define FF first
#define ls (k<<1)
#define rs (k<<1|1)
#define inf 0x3f3f3f3f
#define clr(a,x) memset(a,x,sizeof(a))
#define cpy(a,x) memcpy(a,x,sizeof(a))
#define file(x) freopen(x".in","r",stdin),freopen(x".out","w",stdout);
using namespace std;

const int N=105,M=100005,mod=1e9+7;
template<class T> inline void gmin(T &x,const T &y){if(x>y) x=y;}
template<class T> inline void gmax(T &x,const T &y){if(x<y) x=y;}
inline void ch(int &x,int y){x=(x+y)%mod;}
const int BufferSize=1<<25;
char buffer[BufferSize],*Bufferhead,*Buffertail;
int Terminal;
inline char Getchar(){
	if(Bufferhead==Buffertail){
		int l=fread(buffer,1,BufferSize,stdin);
		if(!l){Terminal=1;return 0;}
		Buffertail=(Bufferhead=buffer)+l;
	}
	return *Bufferhead++;
}
template<class T> inline bool read(T &x){
	x=0;char c=Getchar(),rev=0;
	while(c<'0'||c>'9'){c=Getchar();rev|=c=='-';if(Terminal)return 0;}
	while(c>='0'&&c<='9') x=x*10+c-'0',c=Getchar();
	x=rev?-x:x;
	return 1;
}
template<class T>inline void print(T x,const char c){
	if(!x){putchar('0');putchar(c);return;}
	if(x<0) putchar('-'),x=-x;
	int m=0,a[10];
	while(x) a[m++]=x%10,x/=10;
	while(m--) putchar(a[m]+'0');
	putchar(c);
}
inline int exp(int x,int y){
	int ans=1;
	while(y){
		if(y&1) ans=(ll)ans*x%mod;
		x=(ll)x*x%mod;y>>=1;
	}return ans;
}

map<ll,bool> a;
inline bool ask(ll x){
	if(a.count(x)) return a[x];
	string str;
	cout<<"? "<<x<<endl;
	cin>>str;fflush(stdout);
	return a[x]=(str[0]=='Y');
}
inline void put(int ans){
	cout<<"! "<<ans<<endl;
	fflush(stdout);
	exit(0);
}

int main(){
	if(ask(1e9)){
		int ans=1e9;
		for(int i=0,j=2;i<9;i++,j*=10)
			if(ask(j)){ans=j>>1;break;}
		put(ans);
	}
	for(int i=1,j=10;i<=9;i++,j*=10)
		if(!ask(j)){
			int l=j/10,r=j-1;
			while(l<r){
				ll mid=l+r>>1;
				if(ask(mid*10)) r=mid; else l=mid+1;
			}
			put(r);
		}
	return 0;
}

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

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int count = 0;
	
	if (a + b >= c) {
		cout << b + c << endl;
	}
	else {
		while (a > 0 || b > 0) {
			c--;
			count++;
			if (b > 0) {
				b--;
				count++;
			}
			else if (a > 0) {
				a--;
			}
		}
		cout << count + 1 << endl;
	}
	return 0;
}

Measured memory_bytes: 256
/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

/**
 *
 * @author otsuhata
 */
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);            
        
        for(int i = 0; i < 3000; i ++) {
            int x = sc.nextInt();
            int y = sc.nextInt();
            
            if((x == 0 && y == 0) || x < 0 || x > 10000 || y < 0 || y > 10000) {
                break;
            }else if(x < y){                
                System.out.println(x + " " + y);
            }else {
                System.out.println(y + " " + x);
            }
        }
    }    
}

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

int main()
{
	long long N, A, B;
	cin >> N >> A >> B;

	long long ma = (N - 1) * B + A;
	long long mi = (N - 1) * A + B;
	long long ans = max( 0LL, ma - mi + 1 );

	cout << ans << endl;
}


Measured memory_bytes: 3632
#include<stdio.h>

int main(void)
{
	
	int a, b;
	int d, r;
	double f;
	
	scanf("%d %d", &a, &b);
	
	d = a/b ;
	r = a%b ;
	f = (double)a/b;
	
	printf("%d %d %.6f\n", d,r ,f);
	
    return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<cmath>
#include<vector>
using namespace std;

int main() {
	int n, cnt; 
	while (cin >> n) {
		cnt = 0;
		vector<bool> v(n + 1, true);
		for (int i = 2; i*i <= n; i++) {
			if (v[i]) {
				for (int j = 2 * i; j <= n; j += i) {
					v[j] = false;
				}
			}
		}
			for (int i = 2; i <= n; i++) {
				if (v[i]) cnt++;
			}
		cout << cnt << endl;
	}
	return 0;
}

Measured memory_bytes: 3216
import java.util.*;
public class Main {
	
	public static int gcd(int a, int b) {
		if(b == 0)
			return a;
		else
			return gcd(b, a % b);
	}
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int answer = gcd(sc.nextInt(), sc.nextInt());
		for(int i = 2; i < n; i++) {
			answer = gcd(answer, sc.nextInt());
		}
		System.out.println(answer);
	}

}


Measured memory_bytes: 49372
import math
import fractions
import copy
#以下てんぷら
def j(q):
    if q==1: print("YES")
    elif q == 0:print("NO")
    exit(0)
rem = pow(10,9)+7
"""
def ct(x,y):
    if (x>y):print("+")
    elif (x<y): print("-")
    else: print("?")
"""

def ip():
    return int(input())
def printrow(a):
    for i in range(len(a)):
        print(a[i])
def combinations(n,r):
    if n<r:return 0
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))
def permutations(n,r):
    if n<r:return 0
    return math.factorial(n) // math.factorial(n - r)
def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)


#n = ip()                                     #入力整数1つ
m,n= (int(i) for i in input().split())       #入力整数横2つ以上
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#a=[input() for i in range(n)]    #入力セット(整数改行あり)(2/2)
#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
print((m*3+n)//2)

Measured memory_bytes: 5316
import sys
readline = sys.stdin.readline

def main():
    N, x = map(int, readline().rstrip().split())
    A = list(map(int, readline().rstrip().split()))
    ans = 0
    for i, a in enumerate(A):
        if a > x:
            ans += a - x
            A[i] = x
    
    pre = 0
    for i, a in enumerate(A):
        if pre + a > x:
            A[i] = x - pre
            ans += a - A[i]
        pre = A[i]
    
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 14252
# -*- coding: utf-8 -*-

N = int(input())
A = list(map(int, input().split()))

max_A = min_A = A[0]
for i in range(1,N,1):
    if A[i] > max_A:
        max_A = A[i]
    if A[i] < min_A:
        min_A = A[i]

max_diff = max_A - min_A
print(max_diff)


Measured memory_bytes: 9088
// J'aime
// Chemise Blanche

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

#define int long long

#define ii pair<int,int>
#define fi first
#define sc second

#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr << __LINE__ << " > " << #x << " = " << (x) << endl

void MAIN() {
  string s;
  cin >> s;
  int cnt = 0, ans = 0;
  for (auto &i : s) {
    if (i == 'R') cnt++;
    else cnt = 0;
    ans = max(ans, cnt);
  }
  cout << ans << '\n';
}

signed main() {
#ifdef _DEBUG
  // freopen("in" , "r", stdin );
  // freopen("out", "w", stdout);
#endif
  ios::sync_with_stdio(0); cin.tie(0);
  int T = 1;
  // cin >> T;
  while (T--) MAIN();
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    if((fabs(a-b)<=d&&fabs(c-b)<=d)||fabs(c-a)<=d)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#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++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

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

	int n, k, q;
	cin >> n >> k >> q;
	vector<int> v(n);
	rep(_, q) {
		int a;
		cin >> a;
		a--;
		v[a]++;
	}
	for (int x : v) {
		if (q - x < k)
			cout << "Yes" << endl;
		else
			cout << "No" << endl;
	}
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int main(){
    string n; cin >> n;
    for(int i = 0; i < 3; i++){
        if(n[i] == '1') n[i] = '9';
        else if(n[i] == '9') n[i] = '1';
    }
    cout << n << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
typedef long long ll;
int n;
struct P {
	ll p, q, r, l;
};
P a[101];
int o[101];
int s(ll a, ll b) {
	if (a > b)
		swap(a, b);
	while (a > 0) {
		ll c = a;
		a = b%a;
		b = c;
	}
	return b;
}
ll solve(ll i) {
	if (a[i].r == 0 && a[i].l == 0) {
		return a[i].p + a[i].q;
	}
	ll d, e, f, g, h;
	if (a[i].r == 0)
		d = a[i].q;
	else
		d = solve(a[i].r);
	e = s(d, a[i].q);
	e = (e*(d / e)*(a[i].q / e));
	f = (e / a[i].q*a[i].p);
	if (a[i].l == 0)
		d = a[i].p;
	else
		d = solve(a[i].l);
	g = s(d, f);
	g = (g*(f / g)*(d / g));
	h = (g / f)*e + g;
	return h;
}
int main() {
	while (cin >> n&&n != 0) {
		for (int i = 0; i <= n; i++)
			o[i] = -1;
		for (int i = 1; i <= n; i++) {
			cin >> a[i].p >> a[i].q >> a[i].r >> a[i].l;
			ll u = s(a[i].p, a[i].q);
			a[i].p = (a[i].p / u);
			a[i].q = (a[i].q / u);
			o[a[i].r] = i;
			o[a[i].l] = i;
		}
		ll ans = 0;
		for (int i = 1; i <= n; i++) {
			if (o[i] == -1) {
				cout << solve(i) << endl;
				break;
			}
		}
	}
}

Measured memory_bytes: 3012
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }


const int maxn = 510;

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    string s;
    while (cin >> s) {
        bool good = true;
        good &= (s[0] == 'A');
        int cnt = 0;
        int j = 2;
        for (int i = 2; i < s.size()-1; i++)
            if (s[i] == 'C') {
                cnt ++;
                j = i;
            }
        good &= (cnt == 1);
        for (int i = 0; i < s.size(); i++) {
            if (i == 0 || i == j)
                continue;
            good &= ('A' == s[i] || 'C' == s[i]) || ('a' <= s[i] && s[i] <= 'z');
        }
        if (good)
            cout << "AC" << endl;
        else
            cout << "WA" << endl;
    }
    return 0;
}


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

int main(){
	int a[5];
	for(int i=0 ; i<5 ; i++){
		cin >> a[i];
	}
	sort(a, a+5, greater<int>());

	for (int i=0 ; i<5; i++) {
        cout << a[i] ;
		if(i!=4){
			cout << " ";
		}
    }
	cout << endl;
	
    return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>

using namespace std;

#define ll long long

int H, W;
string FD[105];
string buff;
bool isNotWhiteRow[105] = {0}, isNotWhiteCol[105] = {0};

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

    for(int i = 0; i < H; i++){
        cin >> buff;
        FD[i] = buff;
        for(int j = 0; j < W; j++){
            if(buff[j]=='#') {
                isNotWhiteRow[i] = true;
                isNotWhiteCol[j] = true;
            }
        }
    }

    for(int i = 0; i < H; i++){
        for(int j = 0; j < W; j++){
            if(isNotWhiteRow[i] && isNotWhiteCol[j]) {
                cout << FD[i][j];
            }
        }
        if(isNotWhiteRow[i]) cout << endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define in insert
#define all(x) (x).begin(), (x).end()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int INF = 1e9 + 5;
ll a, b, c, d;
ll gcd (ll x, ll y) {
	return y ? gcd (y, x % y) : x;
}
ll numOfDevisors(ll x){
    /*int a_mod = a % x;
    if(a_mod != 0) a += (x - a_mod);
    b -= b % x;
    return (b - a) / x + 1;*/
    return ( b / x ) - (( a - 1 ) / x );
}
int main(){
    cin >> a >> b >> c >> d;
    ll lcm = c*d/gcd(c, d);
    cout << b-a+1 - numOfDevisors(c) - numOfDevisors(d) + numOfDevisors(lcm);   
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<unordered_set>
#include<unordered_map>
#include<bitset>
#include<iomanip>
#include<list>
#include<deque>
using namespace std;
//#define MODE 1
#ifdef MODE
#define DEB(X) cout<< #X <<": "<<X<<" ";
#define DEB2(X) cout<<X<<" ";
#define END cout<<endl;
#else
#define DEB(X) {}
#define DEB2(X) {}
#define END {}
#endif
typedef long long ll;
#define int ll
#define uset unordered_set
#define umap unordered_map
//typedef std::pair<int,int> P;
struct edge{int to,cost;};
const int INF=100000000000000000;
const int INF2=9223372036854775807;
const int MOD=1000000007;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define min(X,Y) (((int)(X)<(int)(Y))?(X):(Y))
#define max(X,Y) (((int)(X)>(int)(Y))?(X):(Y))
#define NP(X,Y) next_permutation(X,Y)
#define setdouble(X,Y) cout<<fixed<<setprecision(X)<<Y
int ceil2(int a,int b){if(a%b==0){return a/b;}else{return a/b+1;}}
int pow2(int a,int b){int r=1;for(int i=1;i<=b;i++){r*=a;}return r;}
int Log2(int a){int t=0;while(1){if(a==0||a==1){break;}a/=2;t++;}return t;}

int N;
int A[200010];
int B[200010];
int dp[200010];

signed main(){
	cin>>N;
	REP(i,N){
		cin>>A[i];
	}
	if(A[0]!=0){
		cout<<-1<<endl;
		return 0;
	}
	REP(i,N-1){
		if(A[i+1]-A[i]>1){
			cout<<-1<<endl;
			return 0;
		}
	}
	int ans=0;
	REP(i,N-1){
		if(A[i]+1==A[i+1]){
			ans++;
		}
		else{
			ans+=A[i+1];
		}
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 2944
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        String[] nm = scanner.nextLine().split(" ", 2);
        int n = Integer.parseInt(nm[0]);
        int m = Integer.parseInt(nm[1]);

        int[] roadCount = new int[n];
        for (int i = 0; i < m; i++) {
            String[] ab = scanner.nextLine().split(" ", 2);
            int a = Integer.parseInt(ab[0]) - 1;
            int b = Integer.parseInt(ab[1]) - 1;
            roadCount[a]++;
            roadCount[b]++;
        }

        for (int i = 0; i < n; i++) {
            System.out.println(roadCount[i]);
        }
    }
}


Measured memory_bytes: 21844
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<long long> vll;
typedef pair<int,int> pint;
typedef pair<long long, long long> pll;

#define MP make_pair
#define PB push_back
#define ALL(s) (s).begin(),(s).end()
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P) 
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P) 
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P) 
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P) 
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s; }




pint list[10] = {
    pint(0, 1), pint(1, 2), pint(2, 3), pint(4, 5), pint(5, 6), pint(6, 7), pint(0, 4), pint(1, 5), pint(2, 6), pint(3, 7)
};

int main() {
    //freopen( "/Users/macuser/Dropbox/Contest/input.in", "r", stdin );
    vint start(8);
    vint goal(8);
    for (int i = 0; i < 8; ++i) goal[i] = i;
    

        queue<vint> que;
        que.push(goal);
        map<vint,int> ma;
        ma[goal] = 0;
        
        while (!que.empty()) {
            vint vec = que.front(); que.pop();
            int dis = ma[vec];
            
            for (int i = 0; i < 10; ++i) {
                if (vec[list[i].first] != 0 && vec[list[i].second] != 0) continue;

                swap(vec[list[i].first], vec[list[i].second]);
                if (!ma.count(vec)) {
                    ma[vec] = dis + 1;
                    que.push(vec);
                }
                swap(vec[list[i].first], vec[list[i].second]);
            }
        }
        
    while (cin >> start[0]) {
        for (int i = 1; i < 8; ++i) cin >> start[i];
        cout << ma[start] << endl;
    }
    return 0;
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

#include <fstream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <functional>
#include <stack>
#include <queue>
#include <map>
#include <unordered_map>
#include <bitset>
#include <numeric>
#include <unordered_set>
#include <bitset>
#include <limits>
#include <random>
#include <complex>
#include <numeric>
#include <cstdlib>
#include <random>
#include <bits/stdc++.h>


using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
//typedef vector<ll> vec;
//typedef vector<vec> mat;

const ll mod=1000000007ll;
const ll inf=1000000000000000ll;

ll N;

int main(){
  cin>>N;
  bool fl=false;
  for(ll i=0;i<=15;i++){
    for(ll j=0;j<=25;j++){
      if(i*7+j*4 == N)fl=true;
    }
  }
  if(fl) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int D,N; cin >>D>>N;
  if(D==0){
    if(N==100){
      cout<<101<<endl;
    }else{
      cout<<N<<endl;
    }
  }else if(D==1){
    if(N==100){
      cout<<10100<<endl;
    }else{
      cout<<N*100<<endl;
    }
  }else if(D==2){
    if(N==100){
      cout<<1010000<<endl;
    }else{
      cout<<N*10000<<endl;
    }
  }
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
using I=long long;
#define rep(i,n) for(I i=0;i<n;++i)
bool check(){
  string s;
  cin>>s;
  rep(i,s.size()){
    if(i%2){
      if(s[i]=='R')return false;}
    else{
      if(s[i]=='L')return false;}
  }
  return true;
}
int main(){
  cout<<(check()?"Yes":"No")<<endl;
}


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

int main() {
  int N,K,num;
  cin >> N >> K;
  
  // N-1個の入力を受け取る
  for (int i = 0; i < N; i++) {
    int h;
    cin >> h;
    if(h >= K)num++;
  }
  cout << num << endl;
}


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

int main()
{
    int D;
    cin >> D;
    if(D == 22)
        cout << "Christmas Eve Eve Eve" << endl;
    else if(D == 23)
        cout << "Christmas Eve Eve" << endl;
    else if(D == 24)
        cout << "Christmas Eve" << endl;
    else
        cout << "Christmas" << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
 
using namespace std;
 
int N;
int P[200000];
bool used[200002];
int memo[200001];
 
int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> P[i];
	}
	int ans = 1;
	used[200001] = true;
	for (int i = 0; i < N; i++) {
		used[P[i]] = true;
		if (used[P[i] - 1]) {
			memo[P[i]] = memo[P[i] - 1] + 1;
			ans = max(ans, memo[P[i]] + 1);
		}
	}
	cout << N - ans << endl;
	return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
 
using namespace std;
 
typedef pair<int,int> pi;
typedef pair<pi,string> pis;
 
int N;
vector<pi> good, bad;
string s;
 
bool cmp(pi A, pi B){
	return A.second + A.first > B.second + B.first;
}
 
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie();
	cin >> N;
	for (int i = 1; i <= N; ++i){
		cin >> s;
		int op = 0, clo = 0, dep = 0;
		for (auto it : s){
			((it == '(') ? op++ : clo++);
			dep = max(dep,clo-op);
		}
		if (op >= clo){
			good.push_back(pi(dep,op-clo));
		}
		else bad.push_back(pi(dep,op-clo));
	}
	sort(good.begin(),good.end());
	sort(bad.begin(),bad.end(),cmp);
	int num = 0;
	for (auto it : good){
		if (num < it.first){
			cout << "No\n";
			return 0;
		}
		num += it.second;
	}
	for (auto it : bad){	
		if (num < it.first){
			cout << "No\n";
			return 0;
		}
		num += it.second;
	}
	if (num == 0){
		cout << "Yes\n";
	}
	else cout << "No\n";
}

Measured memory_bytes: 11340
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    n,k = LI()
    s = input()
    for i in range(k-1):
        print(s[i],end = "")
    print(s[k-1].lower(),end = "")
    for i in range(k,n):
        print(s[i],end = "")
    print()
    return

#B
def B():
    s = S()
    k = int(s[0])*10+int(s[1])
    l = int(s[2])*10+int(s[3])
    if k == 0:
        if l == 0:
            print("NA")
        elif l < 13:
            print("YYMM")
        else:
            print("NA")
    elif k < 13:
        if l == 0:
            print("MMYY")
        elif l < 13:
            print("AMBIGUOUS")
        else:
            print("MMYY")
    else:
        if l == 0:
            print("NA")
        elif l < 13:
            print("YYMM")
        else:
            print("NA")

#C
def C():
    n,k = LI()
    ans = 0
    for i in range(1,n+1):
        l = k/i
        ans += 1/n*1/(2 << max(0,math.ceil(math.log(l,2))))
    print(ans*2)
    return

#D
def D():
    n = I()
    v = [[] for i in range(n)]
    for i in range(n-1):
        x,y,w = LI()
        x -= 1
        y -= 1
        v[x].append((y,w))
        v[y].append((x,w))
    ans = [0 for i in range(n)]
    bfs_map = [1 for i in range(n)]
    bfs_map[0] = 0
    q = deque()
    q.append(0)
    while q:
        x = q.popleft()
        for y,w in v[x]:
            if bfs_map[y]:
                if w%2:
                    ans[y] = ans[x]^1
                else:
                    ans[y] = ans[x]
                bfs_map[y] = 0
                q.append(y)
    for i in ans:
        print(i)
    return

#E
def E():
    def root(x):
        if par[x] == x:
            return par[x]
        par[x] = root(par[x])
        return par[x]
    def same(x,y):
        return root(x) == root(y)
    def unite(x,y):
        x = root(x)
        y = root(y)
        if rank[x] < rank[y]:
            par[x] = y
        else:
            par[y] = x
            if rank[x] == rank[y]:
                rank[x] += 1
    n,m = LI()
    par = [i for i in range(n)]
    rank = [0 for i in range(n)]
    for i in range(m):
        x,y,z = LI()
        x -= 1
        y -= 1
        if not same(x,y):
            unite(x,y)
    for i in range(n):
        root(i)
    par = list(set(par))
    print(len(par))
    return

#F
def F():
    n = I()

    return

#Solve
if __name__ == "__main__":
    E()


Measured memory_bytes: 80944
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#define LL long long
using namespace std;
struct Node{
    string name;
    int score;
    int loc;
}a[1000];
int cmp(const Node &a, const Node &b){
    if(a.name == b.name) return a.score > b.score;
    else return a.name < b.name;
}
int main(){
    ios::sync_with_stdio(false);
    int n; cin>>n;
    for(int i = 1; i <= n; i++){
        cin>>a[i].name>>a[i].score;
        a[i].loc = i;
    }
    sort(a + 1, a + n +1, cmp);
    for(int i = 1; i <= n; i++) cout<<a[i].loc<<endl;
    return 0;
}

Measured memory_bytes: 888
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)\
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)\
#pragma GCC optimize("unroll-loops")
#include<bits/stdc++.h>

using namespace std;

#define ll long long
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define pii pair<ll,ll>
#define vpii vector<pair<ll,ll> >
#define F first
#define S second
#define ld long double
#define built __builtin_popcountll
#define mst(a,i) memset(a,i,sizeof(a))
#define all(x) x.begin(),x.end()
#define itit(it,a) for(auto it=(a).begin(); it!=(a).end(); it++)
#define rep(i,a,b) for(ll i=a; i<b; i++)
#define repr(i,a,b) for(ll i=a; i>b; i--)
#define reprr(i,a,b) for(ll i=a; i>=b; i--)
#define pi 3.14159265358979323846264338327950288419716939937510582097494459230
ll max3(ll x,ll y,ll z) {return max(max(x,y),z);}
ll min3(ll x,ll y,ll z) {return min(min(x,y),z);}
const ll M=2e5+10,M2=1e6+10,mod=1e9+7,inf=1e17+10;
void add(int& a, int b) {a+=b;if(a>=mod){a-=mod;}}
#define trace1(x)			 	 cerr<<#x<<": "<<x<<endl
#define trace2(x, y)		 	 cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)		 	 cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)	 	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)	 cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<endl
#define trace6(a, b, c, d, e, f) cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<" | "<<#f<<": "<<f<<endl
int X[] = {0, 1, 0, -1};
int Y[] = {-1, 0, 1, 0};
ll power(ll x,ll n){ll result=1;while(n>0){if(n%2==1)result=(result*x)%mod; x=((x%mod)*(x%mod))%mod;n=n/2;}return result;}


int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	string s;
	cin >> s;
	if(s[0]==s[1]&& s[2]==s[1]){
		cout << "Yes";
		return 0;
	}
	if(s[1]==s[2]&& s[2]==s[3]){
		cout << "Yes";
		return 0;
	}
	cout << "No";
	return 0;
}
/* The judge is never wrong! Your code is buggy 
   Look for:
 * * Read the problem carefully.
 * * Don't forget to sort(), mod, ll!!!!
 * * Initial value = +/- infinity instead of zero!!!
 * * an easier and alternate approach
 * * read the problem statement carefully
 * * if concept is correct and still WA, try with a different implementation
 * * special cases (n=1?)
 * * if you have no idea just guess the appropriate well-known algorithm instead of doing nothing :/
 */

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,k,mx,f[2010][2010],a1[4000010],a2[4000010],b[4000010];
void add(int &x,int y)
{
	x+=y;
	x%=1000000007;
}
int js(int n,int m)
{
	return 1ll*a1[n]*a2[m]%1000000007*a2[n-m]%1000000007;
}
int main()
{
	cin>>n>>k;
	mx=n*k;
	if(k==1)
	{
		cout<<1;
		return 0;
	}
	a1[0]=a2[0]=b[0]=b[1]=1;
	for(int i=1;i<=n*k;i++)
	{
		a1[i]=1ll*a1[i-1]*i%1000000007;
	}
	for(int i=2;i<=n*k;i++)
	{
		b[i]=1ll*b[1000000007%i]*(1000000007-1000000007/i)%1000000007;
	}
	for(int i=1;i<=n*k;i++)
	{
		a2[i]=1ll*a2[i-1]*b[i]%1000000007;
	}
	f[0][0]=1;
	for(int i=1;i<=n;++i)
	{
		for(int j=0;j<=i;++j)
		{
			add(f[i][j],f[i-1][j]);
			if(j!=0)
			{
				add(f[i][j],1ll*f[i][j-1]*(n-j+1)%1000000007*js((n-i)+(n-j+1)*(k-1)-1,k-2)%1000000007);
			}
		}
	}
	cout<<f[n][n];
    return 0;
}


Measured memory_bytes: 64288
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

#(方針)和の差分の回数(n回)で合わせられるか(1回の操作で和の差が1ずつ小さくなる)　
#ex 1 2 3 / 5 2 2 -> (和)6 9 -> 3回の操作
#・aにする操作 n回 / ・bにする操作 n回　ばらばらに考える
#・とりあえず対応要素の差が0になるように操作

num = sum(B) - sum(A) #操作回数
judge = 1 

if(num < 0): judge = 0
elif(num == 0): 
  if(A==B): judge = 1
  else: judge = 0
else:
  count_a,count_b = 0,0 #現在のaの操作回数 ,bの操作回数
  for i in range(N):
    if(A[i] < B[i]): #bが大きい
      dif = B[i]-A[i]
      if(dif%2 == 0): 
        count_a += dif//2
      else: 
        count_a += (dif//2)+1
        count_b += 1
        
    elif(A[i] > B[i]): #aが大きい
      dif = A[i] - B[i]
      count_b += dif
    
    if((count_a > num)or(count_b > num)) : #不可
      judge = 0
      break
      
  if(judge == 1): #全ての操作後,余りで合わせられるか
    if((num-count_a)*2 != (num-count_b)):
      judge = 0

if(judge == 0): print('No')
else: print('Yes')

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

int main(){
char c[4][8][8];
for(int a=0;a<8;a++){
	for(int b=0;b<8;b++)cin>>c[0][a][b];
}
for(int d=1;d<4;d++){
	for(int e=0;e<8;e++){
		for(int f=0;f<8;f++){
			c[d][e][f]=c[d-1][f][7-e];
		}
	}
}
for(int x=3;x!=0;x--){
	printf("%d\n",(4-x)*90);
	for(int y=0;y<8;y++){
		for(int z=0;z<8;z++)printf("%c",c[x][y][z]);
		puts("");
	}
}
}

Measured memory_bytes: 3120
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
	int e,m;
	while(true){
		cin>>e;
		if(0==e)
			break;
		m = 1000000; 
		for(int z = 0; z*z*z <= e; z++){
			for(int y = 0; y*y + z*z*z <= e; y++)
				m = min(m, z+y+(e-z*z*z-y*y));
		}
		cout<<m<<endl;
	}
} 


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

#define REP(i, n) for(int (i)=0;(i)<(n);++(i))
#define REPV(iter, v) for(auto (iter)=(v).begin(); (iter)!=(v).end();++(iter))
#define ALL(v) (v).begin(),(v).end()

#define MOD 1000000007

using namespace std;

typedef long long ll;

int main()
{
    ll a;
    cin >> a;
    ll ans = 0;
    ans = a + a * a + a * a * a;

    cout << ans << endl;
}


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

namespace IntegerMath
{
  uint64_t gcd(uint64_t a, uint64_t b)
  {
    uint64_t n = std::min(a, b), m = std::max(a, b);
    return (n == 0) ? m : gcd(m % n, n);
  }

  uint64_t lcm(uint64_t a, uint64_t b)
  {
    uint64_t d = gcd(a, b);
    return (a % d == 0) ? (a / d) * b : a * (b / d);
  }
};

int main()
{
  uint64_t N;
  std::cin >> N;
  
  uint64_t T;
  std::cin >> T;
  
  for (uint64_t n = 1; n < N; ++n) {
    uint64_t t;
    std::cin >> t;
    
    T = IntegerMath::lcm(t, T);
  }
  
  std::cout << T << std::endl;
  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>
#include <climits>
#include <cmath>
#include <unordered_map>

using namespace std;

typedef long long ll;

int main(void) {
  ll A, B, C;
  cin >> A >> B >> C;
  if ((A < C && C < B) || (A > C) && (C > B))
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <math.h>
using namespace std;

int main()
{
    vector <int> a(100);
    int cnt = 0;
    int n;
    cin >> n;
    int d, x;
    cin >> d >> x;
    for(int i = 0; i < n; ++i)
    {
        cin >> a[i];
    }
    for(int i = 0; i < n; ++i)
    {
        int j = 1;
        while(j*a[i] + 1 <= d)
        {
            ++j;
            ++cnt;
        }
    }
    cout << cnt + x + n;
}

Measured memory_bytes: 256
MOD = int(1e9) + 7

n, m = map(int, input().split())

if abs(m - n) >= 2:
  ans = 0
else:
  ans = 1
  for i in range(1, m+1):
    ans *= i
    ans %= MOD
  for i in range(1, n+1):
    ans *= i
    ans %= MOD
  if n == m:
    ans = (ans * 2) % MOD

print(ans)

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

signed main(void)
{
	int n;
	cin >> n;
	n %= 10;
	if (n  == 3)
		cout << "bon" << endl;
	else if (n == 2 || n == 4 || n == 5 || n == 7 || n == 9)
		cout << "hon" << endl;
	else
		cout << "pon" << endl;
	return 0;
}


Measured memory_bytes: 3544
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long

int main() {
	int H, W;
	cin >> H >> W;
	vector<vector<int>> a(H, vector<int>(W, -1));
	queue<tuple<int, int, int>> q;
	for (int i = 0; i < H; ++i) {
		string ai; cin >> ai;
		for (int j = 0; j < W; ++j) {
			if (ai[j] == '#') {
				a[i][j] = 0;
				q.push(make_tuple(i, j, 0));
			}
		}
	}
	while (!q.empty()) {
		auto t = q.front();
		q.pop();
		int i = get<0>(t);
		int j = get<1>(t);
		int c = get<2>(t);
		if (i > 0 && a[i - 1][j] == -1) {
			a[i - 1][j] = c + 1;
			q.push(make_tuple(i - 1, j, c + 1));
		}
		if (i < H - 1 && a[i + 1][j] == -1) {
			a[i + 1][j] = c + 1;
			q.push(make_tuple(i + 1, j, c + 1));
		}
		if (j > 0 && a[i][j - 1] == -1) {
			a[i][j - 1] = c + 1;
			q.push(make_tuple(i, j - 1, c + 1));
		}
		if (j < W - 1 && a[i][j + 1] == -1) {
			a[i][j + 1] = c + 1;
			q.push(make_tuple(i, j + 1, c + 1));
		}
		if (q.empty())
			cout << c << endl;
	}
	/*
	for (int i = 0; i < H; ++i) {
		for (int j = 0; j < W; ++j)
			cout << a[i][j] << " ";
		cout << endl;
	}
	*/
	return 0;
}

Measured memory_bytes: 16400
/*package whatever //do not write package name here */

import java.io.*;
import java.lang.Math; 
import java.util.Scanner;

public class Main {
	public static void main (String[] args) {
	    Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int k = scan.nextInt();
		int[] arr = new int[n];
		
		for(int i = 0; i < n; i++){
		    arr[i] = scan.nextInt();
		}
		
		int[] dp = new int[n];
		dp[1] = Math.abs(arr[0]-arr[1]);
		
		for(int i = 2; i < n; i++ ){
		    dp[i] = Integer.MAX_VALUE;
		    for(int j = 1; j <= k; j++){
		        if(i-j >= 0){
		            dp[i] = Math.min(dp[i],dp[i-j]+Math.abs(arr[i-j]-arr[i]));
		        }
		    }
		}
		System.out.println(dp[n-1]);
		
	}
}

Measured memory_bytes: 49512
#include <bits/stdc++.h>
	using namespace std;
	
	typedef long long ll;
	#define pi 3.14159265 
	#define EPS 1e-8
	
	#define mod 1000000007
	#define fi first
	#define se second
	#define mp make_pair
	#define pb push_back
	#define endl "\n"

	const ll INF=(ll)2e18;
	
	long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
	}
	
	int main()
	{
		 ios_base::sync_with_stdio(false);
		 cin.tie(NULL);
			
		 ll n,k;
		 cin>>n>>k;
		 
		 vector<ll> ans(k+1,0);
		 ll res=0;
		 for(ll i=k;i>0;i--)
		 {
			 ans[i]=binpow(k/i,n,mod);
			 
			 for(ll j=2;(i*j)<=k;j++)
			 {
				 ans[i]-=ans[i*j];
				 ans[i]+=mod;
				 ans[i]%=mod;
			 }
			 res+=i*(ans[i]);
			 res%=mod;
		 }
		 cout<<res;
	}


Measured memory_bytes: 3960
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e5+7;
int n,Q,num;
ll sum[N],ou[N],ji[N],a[N],ans;
bool check(int pos,ll x)
{
	int sz=n-pos+1,posl=pos-sz+1;
	if(posl<1)return 0;
	if(x<=a[posl]||a[pos]-x>=x-a[posl])return 1;
	return 0;
}
int main()
{
	scanf("%d%d",&n,&Q);
	for(int i=1;i<=n;i++)scanf("%lld",&a[i]);
	for(int i=1;i<=n;i++)
	{
		sum[i]=sum[i-1]+a[i];
		if(i==1)ji[i]=a[i];
		else if(i&1)ji[i]=ji[i-2]+a[i];
		else ou[i]=ou[i-2]+a[i];
	}
	num=(n+1)/2;
	while(Q--)
	{
		ll x;scanf("%lld",&x);
		if(x<=a[n/2+1]&&a[n/2+1]-x>x-a[1]){printf("%lld\n",sum[n]-sum[n/2]);continue;}
		int l=n/2+1,r=n,mid,pos=n;
		while(l<=r)
		{
			mid=(l+r)/2;
			if(check(mid,x))pos=mid,r=mid-1;
			else l=mid+1;
		}
		int sz=n-pos+1,posl=pos-sz;
		ans=sum[n]-sum[pos-1]+max(ou[posl-1],ji[posl-1]);
		printf("%lld\n",ans);
	}
}

Measured memory_bytes: 4864
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <vector>
#define mp make_pair
#define pii pair<int,int>
#define fi first
#define se second

using namespace std;
typedef long long ll;
const int MAXN = 100005;
inline ll readint()
{
	ll res = 0;
	char c = 0;
	while(!isdigit(c))
		c = getchar();
	while(isdigit(c))
	    res = res*10+c-'0', c = getchar();
	return res;
}
int n,q;
ll m; 
int fa[MAXN];
vector<pii> s[2];
inline int getFather(int v)
    { return v==fa[v]?v:(fa[v] = getFather(fa[v])); }
int num;
inline void merge(int x, int y)
{
	int fx = getFather(x), fy = getFather(y);
	if(fx!=fy)
		num--, fa[fx] = fy;
}

int main()
{
	n = readint(), m = readint(), q = readint();
	num = n;
	int u,v,c;
	for(int i = 1; i<=q; i++)
	{
		u = readint(), v = readint(), c = readint();
		s[c].push_back(mp(u,v));	
	}
	for(int i = 1; i<=n; i++)
		fa[i] = i;
	for(int i = 0; i<s[0].size(); i++)
		merge(s[0][i].fi,s[0][i].se);
	for(int i = 0; i<s[1].size(); i++)
		if(getFather(s[1][i].fi)==getFather(s[1][i].se))
		{
			cout << "No" << endl;
			return 0;
		}
	if(m<n-1)
	{
		cout << "No" << endl;
		return 0;
	}
	if(m==n-1)
	{
		cout << (q==s[0].size()?"Yes":"No") << endl;
		return 0;
	}
	ll left = n, right = 1ll*num*(num-1)/2+n-num;
	if(m>=left&&m<=right)
		cout << "Yes" << endl;
	else
	    cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 1656