akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();

		int a = K;
		for (int i = 1; i < N; i++) {
			a *= K-1;
		}
		System.out.println(a);
		sc.close();
	}
}


Measured memory_bytes: 23636
#include <iostream>
#include <vector>
#include <string>
#include <map>

using namespace std;

map<pair<vector<int>, int>, int> mp;
string qes[128];

int search(vector<int> &vi, int depth, int used, int m, int n){
	if(mp.count(make_pair(vi, used))) return mp[make_pair(vi,used)];
	if(vi.size() > (1<<(m-depth))) return 100;
	if(vi.size() == 1) return depth;
	int res = 100;
	for(int i=0;i<m;i++){
		if((used>>i)&1) continue;
		vector<int> a, b;
		for(int j=0;j<vi.size();j++){
			if(qes[vi[j]][i]=='0') a.push_back(vi[j]);
			else                   b.push_back(vi[j]);
		}
		if(a.empty()||b.empty()) continue;
		res = min(res, max(search(a, depth+1, used|(1<<i), m, n), search(b, depth+1, used|(1<<i), m, n)));
	}
	return mp[make_pair(vi,used)] = res;
}

int main(){
	int m, n;
	while(cin >> m >> n, m){
		for(int i=0;i<n;i++) cin >> qes[i];
		vector<int> vi(n);
		for(int i=0;i<n;i++) vi[i] = i;
		mp.clear();
		cout << search(vi, 0, 0, m, n) << endl; 
	}
}

Measured memory_bytes: 4080
#include <bits/stdc++.h>
typedef long long int lld;
typedef unsigned long long int llu;
#define INF (lld)(9223372036854775807)
#define IINF (int)(2147483647)

using namespace std;

int main(void) {
  lld x, y;
  cin >> x >> y;
  cout << (y % 2 == 0 && x * 2 <= y && y <= x * 4 ? "Yes" : "No") << "\n";
}

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

#define REP(i, n) for (int i = 0; i < (n); i++)
#define REP1(i, n) for (int i = 1; i < (n); i++)
#define CIN(A) int A; cin >> A;
#define CIN2(A, B) int A, B; cin >> A >> B;
#define CIN3(A, B, C) int A, B, C; cin >> A >> B >> C;
#define CINVEC(A, N) vector<int> A; REP(i, N) { int a; cin >> a; A.emplace_back(a); }
#define ANS(ans) cout << (ans) << endl
#define rsort(p, q) sort(p, q, greater<int>());

#define DEBUGV(V) REP(i, V.size() - 1) cout << V.at(i) << " "; cout << endl 

int
main()
{
  CIN(N);
  string S; cin >> S;
  
  int x = 0;
  int max = 0;
  REP(i, N) {
    if (S.at(i) == 'I') x++;
    if (S.at(i) == 'D') x--;

    if (max < x) max = x;
  }

  ANS(max);

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <limits>
#include <map>
#include <set>
#include <tuple>
#include <vector>

template <class... Ts> using tuple_t = std::tuple<Ts...>;
template <class T, class U> using map_t = std::map<T, U>;
template <class T, class U> using pair_t = std::pair<T, U>;
template <class T> using vector_t = std::vector<T>;
template <class T> using set_t = std::set<T>;

int min(vector_t<int> nums) {
  int min_ = std::numeric_limits<int>::max();
  for (auto &i : nums)
    if (min_ > i)
      min_ = i;
  return min_;
}

int max(vector_t<int> nums) {
  int max_ = std::numeric_limits<int>::min();
  for (auto &i : nums)
    if (max_ < i)
      max_ = i;
  return max_;
}

int main() {
  int A, B, C;
  std::cin >> A >> B >> C;
  std::cout << max({A, B, C}) - min({A, B, C}) << std::endl;
  return 0;
}


Measured memory_bytes: 256
h, w = map(int, input().split())
grid = ['#' * (h + 2)]
for _ in range(h):
    grid.append('#' + input() + '#')
grid.append('#' * (h + 2))
lgrid = [[0 for _ in range(w+2)] for _ in range(h+2)]
rgrid = [[0 for _ in range(w+2)] for _ in range(h+2)]
dgrid = [[0 for _ in range(w+2)] for _ in range(h+2)]
ugrid = [[0 for _ in range(w+2)] for _ in range(h+2)]
for i in range(1, h+1):
    for j in range(1, w+1):
        if grid[i][j] == '#':
            lgrid[i][j] = 0
            ugrid[i][j] = 0
        else:
            lgrid[i][j] = lgrid[i][j-1] + 1
            ugrid[i][j] = ugrid[i-1][j] + 1
        if grid[i][w+1-j] == '#':
            rgrid[i][w+1-j] = 0
        else:
            rgrid[i][w+1-j] = rgrid[i][w+2-j] + 1
        if grid[h+1-i][j] == '#':
            dgrid[h+1-i][j] = 0
        else:
            dgrid[h+1-i][j] = dgrid[h+2-i][j] + 1        
cnt = 0
for i in range(1, h+1):
    for j in range(1, w+1):
        tmp = lgrid[i][j]+rgrid[i][j]+ugrid[i][j]+dgrid[i][j] - 3
        cnt = max(cnt, tmp)
print(cnt)


Measured memory_bytes: 184452
#include<bits/stdc++.h>
#define rep(i,a,...) for(int i = (a)*(strlen(#__VA_ARGS__)!=0);i<(int)(strlen(#__VA_ARGS__)?__VA_ARGS__:(a));++i)
#define per(i,a,...) for(int i = (strlen(#__VA_ARGS__)?__VA_ARGS__:(a))-1;i>=(int)(strlen(#__VA_ARGS__)?(a):0);--i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define debug(x) cout<<"LINE "<<__LINE__<<": "<<#x<<" = "<<x<<endl;
#else
#define debug(x) (void)0
#endif

ll modpow(ll x, ll b){
    ll res = 1;
    while(b){
        if(b&1)res = res * x % MOD;
        x = x * x % MOD;
        b>>=1;
    }
    return res;
}

ll modinv(ll x){
    return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
    if(was_output)cout << " ";
    cout << a;
    was_output = true;
}
void outendl(){
    was_output = false;
    cout << endl;
}
ll in(){
    ll res;
    (void)scanf("%lld", &res);
    return res;
}
string in_s(){
    string res;
    cin >> res;
    return res;
}

template<class t>
istream& operator>>(istream&is, vector<t>&x){
    for(auto &i:x)is >> i;
    return is;
}

template<class t, class u>
istream& operator>>(istream&is, pair<t, u>&x){
    is >> x.first >> x.second;
    return is;
}

int main(){
    ll n = in();
    ll p = in();
    string str = in_s();
    ll ans = 0;
    if(p==2||p==5){
        vector<ll> sum(p,0);
        foreach(ch,str){
            int num = ch - '0';
            vector<ll> nsum(p,0);
            ++nsum[num%p];
            rep(i,p){
                nsum[(i*10+num)%p] += sum[i];
            }
            sum = nsum;
            ans += sum[0];
        }
    }else{
        reverse(all(str));
        vector<ll> cnt(p,0);
        cnt[0]=1;
        ll sum = 0;
        {
            ll tens = 1;
            foreach(ch,str){
                int num = ch - '0';
                sum = (sum + num * tens) % p;
                ans += cnt[sum];
                ++cnt[sum];
                tens = tens * 10 % p;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <vector>
#include <sstream>
#include <iomanip>
using namespace std;

int main(void){
    long long int n;
    cin >> n;
    long long int a[n+1], b[n];
    long long int ans = 0;
    for(int i = 0; i < n+1; i++)
        cin >> a[i];
    for(int i = 0; i < n; i++)
        cin >> b[i];
    for(int i = n-1; i >= 0; i--){
        long long int check = a[i]+a[i+1];
        if(check <= b[i]){
            ans+=check;
            a[i] = 0;
        }
        else if(check > b[i]){
            ans+=b[i];
            if(a[i+1] < b[i])
                a[i] -= (b[i]-a[i+1]);
        }
    }
    cout << ans << endl;
    return 0;    
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define X first
#define Y second
#define sz(x) (int)x.size()
#define all(x) x.begin(), x.end()
#define ini(x, y) memset(x, y, sizeof(x))
#define endl '\n'
#define fastio cin.sync_with_stdio(false); cin.tie(nullptr)
using namespace std;

using ll = long long;
using pii = pair<int, int>;
const int dx[] = { -1, 0, 1, 0, -1, 1, 1, -1 };
const int dy[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

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

	int a = N / 2;
	int b = N - a;

	cout << fixed << setprecision(9) << (double)b / N;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<iomanip>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (2e9)
// cout << setprecision(10)

using namespace std;
typedef long long int ll;

template<typename T>
T gcd(T x, T y){
    if (y == 0) return x;
    else return gcd(y, x % y);
}
template<typename T>
T lcm(T x, T y){
    return (x / gcd(x, y)) * y;
}

ll A, B, C, D;
int main(void){
    cin >> A >> B >> C >> D;
    ll total = B - A + 1;
    ll a = lcm(C, D);

    ll MC = B / C;
    ll mC = (A-1) / C;

    ll MD = B / D;
    ll mD = (A-1) / D;

    ll M = B / a;
    ll m = (A - 1) / a;

    cout << total - (MC - mC) - (MD - mD) + (M - m) << endl;

    return 0;
}



Measured memory_bytes: 256
from collections import deque
n, m = map(int, input().split())
g = [[] for _ in range(n)]
for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    g[a].append(b)
    g[b].append(a)

ans = [-1]*n
used = [0]*n
used[0] = 1
que = deque()
que.appendleft(0)
while que:
    v = que.pop()
    # print(v)
    for nv in g[v]:
        if used[nv]:
            continue
        used[nv] = 1
        que.appendleft(nv)
        if ans[nv] == -1:
            ans[nv] = v
    # exit()
# print(ans)    
# print(g)
print('Yes')
for i in range(1, n):
    print(ans[i]+1)

Measured memory_bytes: 34976
#include<cstdio>
#include<algorithm>
#include<string.h>
#include<set>
using namespace std;
typedef long long ll;
set<ll> st;set<ll>::iterator it;
int main() {
	ll n;
	scanf("%lld", &n);
	for (ll i = 0;i < n;i++) {
		ll t;scanf("%lld", &t);
		it = st.find(t);
		if ( it== st.end()) {
			st.insert(t);
		}
		else st.erase(it);
	}
	printf("%d\n", st.size());
	getchar();getchar();
	return 0;
}

Measured memory_bytes: 4864
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")
 
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<pair<int, int> > vpii;
typedef pair<int, int> pii;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
#define INF 0x3f3f3f3f
#define MOD 1000000007
#define EPSILON 0.00001
#define f first
#define s second
#define pb push_back
#define mp make_pair
 
#define FOR(i, a, b) for (int i=(a); i<=(signed)(b); i++)
#define F0R(i, a) for (int i=0; i<(signed)(a); i++)
#define RFOR(i, a, b) for (int i=(a); i >= b; i--)

#define MN 100005
int n, k, s;
int a[MN];

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

    cin >> n >> k >> s;
    F0R(i, k){
        a[i] = s;
    }
    FOR(i, k, n-1){
        a[i] = s+1;
        if(s == 1000000000) a[i] = s-1;
    }

    F0R(i, n){
        cout << a[i] << " ";
    }

    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define rep(var,cnt) for(int (var)=0; (var)<(int)(cnt); ++(var))
#define REP(var,init,cnt) for(int (var)=(init); (var)<(cnt); ++(var))
#define ran(var,vec) for(auto &(var):(vec))
#define all(v) (v).begin(),(v).end()
#define TF(flag) (flag)?1:0
using namespace std;

using ll = long long;
using ull = unsigned long long;
using pi = pair<int,int>;
using pl = pair<ll,ll>;
using ti = tuple<int,int,int>;
using tl = tuple<ll,ll,ll>;

template<typename T>
using vec = vector<T>;
template<typename T>
using mat = vector<vec<T>>;
template<typename T>
using cub = vector<mat<T>>;
template<typename T>
using val = valarray<T>;

template<typename T>
using pq = priority_queue<T>;
template<typename T>
using rpq = priority_queue<T,vec<T>,greater<T>>;

template<typename T1,typename T2>
ostream &operator<<(ostream &os, const pair<T1,T2> &p){
  os<<"P("<<p.first<<", "<<p.second<<") ";
  return os;
}

template<typename T1,typename T2>
istream &operator>>(istream &is, pair<T1,T2> &p){
  is>>p.first>>p.second;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, vector<T> &v){
  for(T &in:v) is>>in;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const valarray<T> &v){
  cout<<"V{";
  for(int i=0; i<(int)v.size(); ++i){
    os<<v[i]<<(i+1!=v.size()?" ":"");
  }
  cout<<"}";
  return os;
}

template<typename T>
istream &operator>>(istream &is, valarray<T> &v){
  for(T &in:v) is>>in;
  return is;
}

// Usual Template End ================================================

// Template End ======================================================

int main(void){
  int a,b,c; cin>>a>>b>>c;
  cout<<(b-a==c-b?"YES":"NO");
}














Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <utility>
#include <numeric>
#include <functional>
#include <stdio.h>
#include <math.h>
#include <string>
#include <algorithm>
#include <deque>
#include <queue>
#include <map>

#define rep(i, m, n) for (int (i)(m); (i)<(n); ++(i))
#define repr(i, m, n) for (int (i)(m - 1); (i)>=(n); --(i))
#define repv(i, v) for (unsigned (i)(0); (i)<(v.size()); ++(i))
#define all(v) (v).begin(), (v).end()
#define sortv(v) sort(all(v))
#define sortgi(v) sort(all(v), greater<int>())
#define sortgd(v) sort(all(v), greater<double>())
#define sortgll(v) sort(all(v), greater<ll>())
#define debug(x) cerr << #x << ": " << x << '\n'

using namespace std;
using pii = pair<int, int>;
using pss = pair<string, string>;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vd = vector<double>;
using vvd = vector<vd>;
using vs = vector<string>;
using ll = long long;
using pllll = pair<ll, ll>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using vpii = vector<pii>;
using pqi = priority_queue<int>;
using pqd = priority_queue<double>;
using pqll = priority_queue<ll>;
using pqvi = priority_queue<vi>;
using pqvll = priority_queue<vll>;

int main() {
	int a, b;
	cin >> a >> b;
	cout << a*b - a - b + 1 << endl;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back
 
typedef long long ll;
typedef pair<ll, int> ll_i;

double f(ll N){
    ll n, dig;
    n = N;
    ll sum = 0;

    while(n){
        dig = n % 10;
        sum = sum + dig;
        n = n / 10;
    }
    return (double)N / sum; 
}

int main() {
    ll K;
    cin >> K;
    ll a = 1, order=1;
    for(int i = 0; i < K; i++){
        cout << a << endl;
        if (f(a + pow(10, order-1)) > f(a + pow(10, order))){
            order++;
        }
        a += pow(10, order-1);
    }
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys

YES = "Yes"  # type: str
NO = "No"  # type: str

def solve(N: int, W: "List[str]"):
    used = set()
    used.add(W[0])
    ret = YES
    for i in range(1, N):
        if W[i][0] != W[i - 1][-1] or W[i] in used:
            ret = NO
            break
        used.add(W[i])
    print(ret)
    return


def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    W = [ next(tokens) for _ in range(N) ]  # type: "List[str]"
    solve(N, W)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
 
using namespace std;
 
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
 
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
 
using ll = long long;
/*
    g++ -std=c++11 test.cpp -o test.out && ./test.out
*/


void solve(){
    int n; cin >>n ;
    if (n % 1000 == 0){
        cout << 0 << endl;
    } else {
        cout << 1000 - (n % 1000) << endl;
    }
}

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

Measured memory_bytes: 3652
N, M = map(int, input().split())

votes = list(map(int, input().split()))

total_votes = sum(votes)
threshold = total_votes / (4*M)
temp = 0
for v in votes:
    if v >= threshold:
        temp += 1

if temp >= M:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <map>
#include <vector>

using namespace std;

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

typedef pair<int, int> pii;

int n, m;
vector<pii> edge;
int cnt[5000];
bool done[5000], used[100000];

int main() {
	cin >> n >> m;
	
	REP(i, m) {
		int a, b;
		scanf("%d %d", &a, &b);
		a--; b--;
		edge.push_back(pii(a, b));
	}
	
	vector<int> ans;
	bool flag = false;
	vector<int> next;
	
	REP(i, m) cnt[edge[i].second]++;
	REP(i, n) if (cnt[i] == 0) next.push_back(i);
	
	REP(i, n) {
		int tar = next[next.size() - 1];
		ans.push_back(tar + 1);
		done[tar] = true;
		next.erase(next.end() - 1);
		
		if (next.size() > 0) flag = true;
		
		REP(j, edge.size()) {
			if (!used[j] && edge[j].first == tar) {
				int to = edge[j].second;
				cnt[to]--;
				if (cnt[to] == 0 && !done[to]) next.push_back(to);
				
				used[j] = true;
			}
		}
	}
	
	REP(i, ans.size()) printf("%d\n", ans[i]);
	if (flag) puts("1");
	else puts("0");
	
	return 0;
}

Measured memory_bytes: 3908
#include <stdio.h>

int main(){

	int a,b;
	int d,r;
	double f;

	scanf("%d %d",&a,&b);
	
	d=a/b;
	r=a%b;
	double t=a,t2=b;
	
	f=t/t2;

	
	printf("%d %d %f\n",d,r,f);

	return 0;
}


Measured memory_bytes: 2112
N, K = map(int, input().split())
A = [int(a) for a in input().split()]
a = sum([sum([1 for j in range(i) if A[i]<A[j]]) for i in range(N)])
b = sum([sum([1 for j in range(N) if A[i]<A[j]]) for i in range(N)])
print((a*K+b*K*(K-1)//2)%(10**9+7))

Measured memory_bytes: 43228
#include<bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
using namespace std;
typedef long long ll;
ll gcd(ll a,ll b){return b!=0?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}

int main(){
    ll a,b;
    cin>>a>>b;
    cout<<6-a-b<<endl;
    return 0;
}

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

template<class VAL> struct UnionFind {
	vector<int> par;
	vector<int> rank;
	vector<VAL> diff_weight;

	UnionFind(int n = 1, VAL SUM_UNITY = 0) {
		init(n, SUM_UNITY);
	}

	void init(int n = 1, VAL SUM_UNITY = 0) {
		par.resize(n); rank.resize(n); diff_weight.resize(n);
		for (int i = 0; i < n; ++i) par[i] = i, rank[i] = 0, diff_weight[i] = SUM_UNITY;
	}

	int root(int x) {
		if (par[x] == x) {
			return x;
		}
		else {
			int r = root(par[x]);
			diff_weight[x] += diff_weight[par[x]];
			return par[x] = r;
		}
	}

	VAL weight(int x) {
		root(x);
		return diff_weight[x];
	}

	bool issame(int x, int y) {
		return root(x) == root(y);
	}

	bool merge(int x, int y, VAL w) {
		w += weight(x); w -= weight(y);
		x = root(x); y = root(y);
		if (x == y) return false;
		if (rank[x] < rank[y]) swap(x, y), w = -w;
		if (rank[x] == rank[y]) ++rank[x];
		par[y] = x;
		diff_weight[y] = w;
		return true;
	}

	VAL diff(int x, int y) {
		return weight(y) - weight(x);
	}
};

int main() {
	int N, M;
	cin >> N >> M;
	UnionFind<int> uf(N);
	for (int i = 0; i < M; ++i) {
		int l, r, d;
		cin >> l >> r >> d;
		--l, --r;
		if (uf.issame(l, r)) {
			int diff = uf.diff(l, r);
			if (diff != d) {
				cout << "No" << endl;
				return 0;
			}
		}
		else {
			uf.merge(l, r, d);
		}
	}
	cout << "Yes" << endl;
}


Measured memory_bytes: 1408
//This is getting accepted!
// I HATE BUG
// God Of The Bugs
#include<bits/stdc++.h>

using namespace std;

#define ms(s, n) memset(s, n, sizeof(s))
#define FI first
#define SE second
#define pb push_back
#define mp make_pair
#define ll long long
#define sz(a) ((int)(a).size())
#define __builtin_popcount __builtin_popcounll
#define ld long double

typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef pair<int, pii> ppi;

const double PI = acos(0) * 2;
const double EPS = 1e-8;
const ll MOD = 1e9 + 7;
const int MAXN = 1e5 + 5;
const int oo = 1e9;
const double foo = 1e30;

template<class T> int getbit(T s, int i) { return (s >> i) & 1; }
template<class T> T onbit(T s, int i) { return s | (T(1) << i); }
template<class T> T offbit(T s, int i) { return s & (~(T(1) << i)); }
template<class T> int cntbit(T s) { return __builtin_popcounll(s);}
template<class T> T sqr(T x) { return x * x; }

inline void addmod(int& a, int val, int p = MOD) {if ((a = (a + val)) >= p) a -= p;}
inline void submod(int& a, int val, int p = MOD) {if ((a = (a - val)) < 0) a += p;}
inline int mult(int a, int b, int p = MOD) {return (ll) a * b % p;}

int valMax = -1, valMin = -1;
int n, a[MAXN], T;

int main() {
//#ifndef ONLINE_JUDGE
//    freopen("inp.txt", "r", stdin);
////    freopen("out.txt", "w", stdout);
//#endif

	cin >> n >> T;
	for (int i=0; i<n; i++) {
		cin >> a[i];
	}
	
	int cur = a[0];
	int ans = 0, now = -1;
	for (int i=1; i<n; i++) {
//		cout << a[i] << " " << cur << endl;
		if (a[i] > cur) {
			if (a[i] - cur > now) {
//				cout << a[i] << " "  << cur << endl;
				now = a[i] - cur;
				ans = 1;
			}
			else if (a[i] - cur == now) ans++;
		}
		
		if (cur > a[i]) cur = a[i];
	}
	
	cout << ans;


}


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

int main() {
    string s;
    cin >> s;
    int c0 = 0;
    int c1 = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s.at(i) == '0') {
            c0++;
        }
        else c1++;
    }
    int ans = min(c0, c1) * 2;
    cout << ans << endl;
}

Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <set>
#include <vector>
#include <cmath>
#include <utility>
#include <numeric>

using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

#define all(a) (a).begin(), (a).end()
#define rep(i, n) for (int i=0;(i)<(n);(i)++)
#define repi(i, n) for (int i=0;(i)<=(n);(i)++)
#define repr(i, n) for (int i=n;(i)>=0;(i)--)
#define print(x) (cout<<(x)<<"\n")

int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int h,w; cin>>h>>w;
    int n; cin>>n;
    vvi grid(h, vi(w));
    int color=1;
    int p=0;
    rep(i, n) {
        int a; cin>>a;
        rep(j, a) {
            grid[p/w][p%w] = color;
            p++;
        }
        color++;
    }
    rep(i, h) {
        if (i%2==0) continue;
        rep(j, w/2) {
            swap(grid[i][j], grid[i][w-1-j]);
        }
    }
    rep(i, h) {
        rep(j, w) {
            printf("%d ", grid[i][j]);
        }
        printf("\n");
    }
}

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

int main()
{
    int m, n, l;
    cin >> m >> n >> l;
    long long a[1000][1000] = {0};
    long long b[1000][1000] = {0};
    long long  sum[1000][1000] = {0};

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

    for (int j = 1; j < n + 1; j++)
    {
        for (int k = 1; k < l + 1; k++)
        {
            cin >> b[j][k];
        }
    }

    for (int i = 1; i < m + 1; i++)
    {
        for (int j = 1; j < n + 1; j++)
        {
            for (int k = 1; k < l + 1; k++)
            {
                sum[i][k] += a[i][j] * b[j][k];
            }
        }
    }

    for (int i = 1; i < m + 1; i++)
    {
        for (int j = 1; j < l + 1; j++)
        {
            cout << sum[i][j];
            if (j != l)
            {
                cout << ' ';
            }
        }

        cout << endl;
    }

    return 0;
}


Measured memory_bytes: 26536
/*
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0013&lang=jp
*/


#include<stdio.h>
#define MAX 100

typedef struct{
    int array[MAX]; //データが格納される配列
    int current;    //現在の位置
}STACK;

void init(STACK* pstack){
    int i;
    for(i=0;i<MAX;i++){
        pstack->array[i]=0;
    }
    pstack->current=0;
}

int push(STACK * pstack,int value){

    if(pstack->current<MAX){
        pstack->array[pstack->current]=value;
        pstack->current++;
        return 1;
    }
    return 0;
}

int pop(STACK* pstack,int* pvalue){

    if(pstack->current>0){
        pstack->current--;
        *pvalue=pstack->array[pstack->current];
        return 1;
    }
    return 0;
}

int main(void)
{
    STACK s;
    int value;  //値
    int num;
    int i;

    init(&s);

    while(scanf("%d",&num)!=EOF){
        
        if(num==0){
            pop(&s,&value);
            printf("%d\n",value);
        }else{
            push(&s,num);

        }
    }

    return 0;
}


Measured memory_bytes: 1912
fn main(){
    let mut line = String::new();
    std::io::stdin().read_line(&mut line);
    
	let v = read_vec::<i64>();
	let mut min = 1000000;
	let mut max = -1000000;
	let mut sum = 0;
	for x in &v {
		if *x < min { min = *x; }
		if max < *x { max = *x; }
		sum += *x;
	}
	println!("{} {} {}", min, max, sum)
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}


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

int main(void){
    char c;
    cin >> c;
    cout << (char)(c+1) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using PII = pair<ll, ll>;
#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
template<typename T> void chmin(T &a, const T &b) { a = min(a, b); }
template<typename T> void chmax(T &a, const T &b) { a = max(a, b); }
struct FastIO {FastIO() { cin.tie(0); ios::sync_with_stdio(0); }}fastiofastio;
#ifdef DEBUG
#include "../program_contest_library/memo/dump.hpp"
#else
#define dump(...)
#endif
const ll INF = 1LL<<60;

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

    if(s[1]=='B') cout << "ARC" << endl;
    else cout << "ABC" << endl;   

    return 0;
}

Measured memory_bytes: 3652
Scanf.scanf "%d" (fun n ->
    let a = Array.init n (fun _ -> Scanf.scanf " %d" (fun a -> a)) in
    Array.sort compare a;
    let asm = Array.make n 0 in
    asm.(0) <- a.(0);
    for i = 1 to n - 1 do
        asm.(i) <- asm.(i - 1) + a.(i)
    done;
    let rec loop i =
        if i < 0 then n else
            if asm.(i) * 2 >= a.(i + 1) then loop (i - 1) else n - i - 1
    in
    loop (n - 2) |> Printf.printf "%d\n"
)

Measured memory_bytes: 7532
#include <algorithm> // std::sort(begin,end), std::min, std::max
#include <cmath>
#include <iomanip>
#include <iostream>
#include <queue>
#include <string>
#include <unordered_map>
#include <utility> // std::swap
#include <vector>
using namespace std;
using ll = long long;
using pii = pair<int, int>;

template <typename T> // 0<1<2<3<4
using pq_asc = priority_queue<T, vector<T>, greater<T>>;
template <typename T> // 0>1>2>3>4
using pq_dsc = priority_queue<T>;
const double PI = 3.14159265358979323846;

int main(int argc, char const *argv[]) {

  ll a_i, b_i, x_i;
  cin >> a_i >> b_i >> x_i;
  double a = a_i;
  double b = b_i;
  double x = x_i;
  double y, rad, ret;

  if (x <= a * a * b / 2) {
    rad = atan(b / x * a * b / 2);
  } else {
    // y = (a * a * b - x) / (a * a * b / 2) * b;
    // rad = atan(y / a);
    rad = atan(2 * b / a - x / a / a / a * 2);
  }
  ret = 180 / PI * rad;
  cout << std::setprecision(15) << ret << endl;
  return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) REP(i, 0, n)
#define rrep(i, n) for (int i = (int)(n-1); i >= 0; i--)
#define sz(x) int(x.size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define INF 2e9
#define LINF 1e18
#define mod 1e9+7
template<class T> inline bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (a > b) { a = b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> P;

bool isPrime(int n) {
    for (int i=2; i*i<=n; i++) {
        if (n%i == 0) return false;
    }
    return n != 1;
}

int main() {
    int x; cin >> x;
    bool flag = isPrime(x);
    while (!flag) {
        x++;
        flag = isPrime(x);
    }
    cout << x << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        int l = s.length();
        StringBuilder sb = new StringBuilder();
        for (int i = l - 1; i > -1; i--) {
            sb.append(s.charAt(i));
        }
        System.out.println(sb.toString());
    }
}

Measured memory_bytes: 25920
n,d=map(int, input().split())
xy = [map(int, input().split()) for _ in range(n)]
yx= set(xy)
xy=list(yx)
x, y = [list(i) for i in zip(*xy)]
d2=d*d
count=0
for i in range(n):
    xi=x[i]
    yi=y[i]
    if xi*xi+yi*yi<=d2:
        count+=1

print(count)

Measured memory_bytes: 159044
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
#include<map>
#include<set>
#include<climits>
#include<vector>
#define INF (1<<29)
#define all(c) (c).begin(),(c).end()

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};

vector<int> l[100001];

int main(void){
  int n,m;
  cin >> n >> m;
  int mx=0;
  for(int i=0;i<n;i++){
    int k;
    cin >> k;
    for(int j=0;j<k;j++){
      int tmp;
      cin >> tmp;
      l[tmp-1].push_back(i);
      mx=max(mx,tmp);
    }
    sort(all(l[i]));
  }

  UnionFind uf(n);
  for(int i=0;i<mx;i++){
    for(int j=0;j+1<(int)l[i].size();j++){
      uf.unionSet(l[i][j],l[i][j+1]);
    }
  }

  bool fg=true;
  for(int i=0;i<n;i++){
    fg &= uf.size(i) == n;
  }
  cout << (fg?"YES":"NO") << endl;

  
  return 0;
}


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

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

  if (S == "Sunny") {
    cout << "Cloudy" << endl;
  }
  else if (S == "Cloudy") {
    cout << "Rainy" << endl;
  }
  else {
    cout << "Sunny" << endl;
  }
  return 0;
}


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

int main(){
    int N;
    cin>>N;
    map<long long,int> mp;
    mp[0] = 1;
    long long s = 0;
    long long res = 0;

    for(int i = 0; i < N;i++){
        int A;
        cin>>A;
        s += A;
        res += mp[s];
        mp[s]++;
    }

    cout<<res<<endl;   
}


Measured memory_bytes: 12800
#include <iostream>
#include <string>
#include <vector>
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include <cmath>
#include <iomanip>
#include <ctype.h>

using namespace std;
using ll = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<ll, ll>;
using vi = vector<int>;
using vvi = vector<vi>;

#define TR ","
#define fi first
#define se second
#define rep(i,N) for(int i=0;i<(int)N;++i)
#define all(v) v.begin(), v.end()
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)

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 x, ll y) {
    return x / gcd(x, y) * y;
}

ll waz = 76543217;

ll inv(ll x) {
    if (x == 1) { return 1; }
    if (x == 0) { return 0; }
    else {
        ll a = (waz - inv(waz % x) * (waz / x)) % waz;
        if (a >= 0) { return a; }
        else { return waz + a; }
    }
}

void printVector(const vector<int>& vec) {
    for (int value : vec) {
        cout << value << " ";
    }
    cout << endl;
}

vector<ll> p;

ll phi(ll x) {
    ll a = x;
    ll b = x;
    for (ll k = 0; k != p.size(); ++k) {
        if (a % p[k] == 0) {
            while (a % p[k] == 0) {
                a /= p[k];
            }
            b = b / p[k] * (p[k] - 1);
        }
        if (a == 1) { break; }
    }
    return b;
}

bool my_compare(pair<string, int> a, pair<string, int> b) {
    if (a.first != b.first) {
        return a.first < b.first;
    }

    if (a.second != b.second) {
        return a.second > b.second;
    }
    else {
        return true;
    }
}

int main()
{
    IO;

    int N, Q; cin >> N >> Q;
    string S; cin >> S;

    vector<int> l(Q), r(Q);
    vector<int> T(N);

    rep(i, Q) {
        cin >> l[i] >> r[i];
    }

    int jj = 0;

    rep(i,S.size()-1) {
        if (S[i] == 'A' && S[i + 1] == 'C') { 
            ++jj;
            T[i+1]=jj; }
        else { T[i + 1] = jj; }
    }

    rep(i, Q) {
        cout << T[r[i] - 1] - T[l[i] - 1] << endl;
    }

}

Measured memory_bytes: 2256
program B
    implicit none
    character(len=100)::S
    integer::i, N, N1, N2
    read(*,*) S
    N = len_trim(S)

    do i = 1, N/2
        if(S(i:i) .ne. S(N+1-i:N+1-i)) then
            write(*,*) "No"
            stop
        end if
    end do

    N1 = (N-1)/2

    do i = 1, N1
        if(S(i:i) .ne. S(N1-i+1:N1-i+1)) then
            write(*,*) "No"
            stop
        end if
    end do

    N2 = (N+3)/2

    do i = N2, N
        if(S(i:i) .ne. S(N-i+N2:N-i+N2)) then
            write(*,*) "No"
            stop
        end if
    end do

    write(*,*) "Yes"

    stop
end program B

Measured memory_bytes: 640
def two(n):
    if n == 1:
        return True
    elif n%2 != 0:
        return three(n)
    else:
        q = n/2
        return two(q)

def three(n):
    if n == 1:
        return True
    elif n%3 != 0:
        return five(n)
    else:
        q = n/3
        return three(q)

def five(n):
    if n == 1:
        return True
    elif n%5 != 0:
        return False
    else:
        q = n/5
        return two(q)

while True:
    input_line = raw_input()
    if input_line == '0': break
    m, n = map(int, input_line.split())
    c = 0
    for n in range(m, n+1):
        if two(n):
            c += 1
    else:
        print c

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

int main(void){
    int n, a[100010], d[100010], dsum = 0;
    cin >> n;
    a[0] = 0;
    a[n + 1] = 0;
    for (int i = 1; i <= n + 1; i++) {
        cin >> a[i];
        if (a[i] - a[i - 1] >= 0) {
            dsum += a[i] - a[i - 1];
            d[i] = a[i] - a[i - 1];
        }
        else {
            dsum += a[i - 1] - a[i];
            d[i] = a[i - 1] - a[i];
        }
    }
    for (int i = 1; i <= n; i++) {
        if (a[i + 1] > a[i - 1]) cout << dsum - d[i + 1] - d[i] + a[i + 1] - a[i - 1] << endl;
        else cout << dsum - d[i + 1] - d[i] - a[i + 1] + a[i - 1] << endl;
    }
    return 0;
}

Measured memory_bytes: 2048
/*
    Written by Nitrogens
    Desire for getting accepted!!
*/
#include <cstdio>
#include <ctime>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <algorithm>
#include <queue>
#include <map>
#include <bitset>
#include <stack>
#include <set>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef double db;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ll, int> pli;
typedef pair <db, db> pdd;

const int maxn = 1e2+5;
const int Mod = 1000000007;
const int INF = 0x3f3f3f3f;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
const double e = exp(1);
const db PI = acos(-1);
const db ERR = 1e-10;

#define Se second
#define Fi first
#define pb push_back
#define dbg(x) cout<<#x<<" = "<< (x)<< endl
#define dbg2(x1,x2) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<endl
#define dbg3(x1,x2,x3) cout<<#x1<<" = "<<x1<<" "<<#x2<<" = "<<x2<<" "<<#x3<<" = "<<x3<<endl

ll w[maxn], v[maxn];
ll dp[105][100005];

int main()
{
    //ios::sync_with_stdio(false);
    //freopen("a.txt","r",stdin);
    //freopen("b.txt","w",stdout);

    int n;
    ll W;
    scanf("%d%lld", &n, &W);

    for(int i = 1; i <= n; i++) scanf("%lld%lld", &w[i], &v[i]);

    memset(dp, 0x3f, sizeof(dp));
    //memset(dp[0], 0, sizeof(dp[0]));
    for(int i = 0; i <= n; i++) dp[i][0] = 0;
    ll answer = 0;
    for(int i = 1; i <= n; i++)
    {
        for(int j = 0; j <= 100000; j++)
        {
            if(j >= v[i])
                dp[i][j] = min(dp[i][j], min(dp[i - 1][j], dp[i - 1][j - v[i]] + w[i]));
            else
                dp[i][j] = min(dp[i][j], dp[i - 1][j]);
            if(dp[i][j] <= W)
                answer = max(answer, j * 1LL);
            //dbg3(i, j, dp[i][j]);
        }
    }
    printf("%lld\n", answer);

    //cout << "time: " << (long long)clock() * 1000 / CLOCKS_PER_SEC << " ms" << endl;
    return 0;
}


Measured memory_bytes: 82304
N, Q = map(int, input().split())
S = str(input())

t = [0] * (N+1)
for i in range(N):
    t[i+1] = t[i] + (1 if S[i:i+2] == 'AC' else 0)

for i in range(Q):
    l, r = map(int, input().split())
    print(t[r-1] - t[l-1])

Measured memory_bytes: 9284
#include<cstdio>
#include<iostream>
#include<algorithm>

using namespace std;

int main(void) {

	int n, d[100],dan,k;
	dan = 1;

	cin >> n;
	for (k = 0; k < n; k++) cin >> d[k];

	sort(d, d + n);

	for (k = 1; k < n; k++) {
		if (d[k] != d[k - 1]) {
			dan++;
		}
	}

	cout << dan << "\n";

	return 0;
}

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

using namespace std;

int main(void){
//string S;
int H;
int A;
cin >> H;
//vector<int> a(N);
cin >> A;
/*for(int i = 0; i < N; i++){
  cin >> a[i];
}

for(int i = 0; i < 2; i++){
  cin >> N[i];
}*/
if(H%A == 0){
  cout << H/A << endl;
}else{
  cout << H/A + 1 << endl;
}
return 0;
}


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

#define NREP() for(ll i = 0; i < n; i++)
#define MREP() for(ll j = 0; j < m; j++)
#define REP(i, x, y) for(ll i = x; i < y; i++)
#define ALL(x) (x).begin(), (x).end()
#define MSG(x) cout << x << endl;
#define MSGF(x, n) MSG(fixed << setprecision(n) << x)
#define END(x) cout << x << endl; exit(0);
#define IPT(v, n) REP(i, 0, n){ cin >> v[i]; }
#define YN(x) x ? cout << "YES" << endl : cout << "NO" << endl;
#define Yn(x) x ? cout << "Yes" << endl : cout << "No" << endl;
#define yn(x) x ? cout << "yes" << endl : cout << "no" << endl;

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<ull> vul;
typedef vector<vector<ull>> vvul;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;

const static ll MOD = 1e9 + 7;
const static ll INF = 1LL << 30;

ll a, b, c, d, k, l, m, n, h, w, q, x, y;
string s, t;

ll ans = 0;
ll sum = 0;
ll cnt = 0;
ll cur = 0;
ll tmp = 0;
ll mini = INF;
ll maxi = 0;

double ave = 0.0;

ll mod_pow(ll base, ll power) {
    if (power == 0) return 1;
    if (power == 1) return base % MOD;
    if (power % 2 == 0) return ((mod_pow(base % MOD, (power / 2)) % MOD) * (mod_pow(base, (power / 2)) % MOD)) % MOD;
    return (base % MOD * (mod_pow(base % MOD, power - 1) % MOD)) % MOD;
}

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

int main() {
    cin >> x;
    cnt = 1;
    while (true) {
        if (cnt * (cnt + 1) / 2 >= x) break;
        cnt++;
    }
    MSG(cnt)
}


Measured memory_bytes: 256
import sys
import itertools
sys.setrecursionlimit(1000000000)
from heapq import heapify,heappop,heappush,heappushpop
import math
import collections
import copy

s = input()
ans = ""
koho = []
for i in range(len(s)):
    ans = ""
    if s[i] == "A" or s[i] == "C" or s[i] == "G" or s[i] == "T":
        ans = s[i]
        for j in range(i+1,len(s)):
            if s[j] == "A" or s[j] == "C" or s[j] == "G" or s[j] == "T":
                ans += s[j]
            else:
                break
    koho.append(ans)
s = set(koho)
c = 0
for i in s:
    c = max(c,len(i))
print(c)

Measured memory_bytes: 3444
// This code Write By chtholly_micromaker(MicroMaker)
#include <cstdio>
#include <cctype>
#define reg register
#define int long long
using namespace std;
template <class t> inline void rd(t &s)
{
	s=0;
	reg char c=getchar();
	while(!isdigit(c))
		c=getchar();
	while(isdigit(c))
		s=(s<<3)+(s<<1)+(c^48),c=getchar();
	return;
}
signed main(void)
{
	int r;rd(r);
	printf("%lld",3ll*r*r);
	return 0;
}


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


int N;	
int A[200001];

int main() {
	std::cin>>N;
	for (int i = 1; i <= N; ++i) {
		std::cin>>A[i];
		A[i] -= i;
	}
	
	std::sort(A+1, A+N+1);
	
	long long b = A[(N+1)/2];
	long long ans = 0;
	for (int i = 1; i <= N; ++i)
		ans += std::abs(A[i] - b);
	
	std::cout<<ans<<"\n";
	
	return 0;
}

Measured memory_bytes: 1024
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();
        if((a * b) % 2 != 0) {
            System.out.println("Odd");
        } else {
            System.out.println("Even");
        }
    }
}


Measured memory_bytes: 20820
n = gets.to_i
a = gets.split.map(&:to_i)
bef = a[0]
money = 1000
have = 0
(1...n).each do |i|
  if a[i] > a[i-1]
    have += money / a[i - 1]
    money %= a[i-1]
    money += a[i] * have
    have = 0
  end
end
puts money
    

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

#define F first
#define S second
#define PB push_back
#define MP make_pair
#define mod 1000000007;

typedef long long ll; 
typedef pair<int, int> ii; 
typedef vector<ii> vii;
typedef vector<int> vi;
typedef vector<ll> vll;

// Print fn to print array

int main(){
	int n;
	cin >> n;
	bool flag = true;
	for(int i=1;i<=9;i++){
		for(int j=1;j<=9;j++){
			if(i*j==n){
				flag = false;
				break;
			}
		}
	}
	if(flag){
		cout << "No\n";
	}
	else cout << "Yes\n";
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
const int M = 1000000007;

int main() {
    int n;
    cin >> n;
    puts(n == 0 ? "1" : n == 1 ? "2" : n == 2 ? "1" : "0");
    return 0;
}

Measured memory_bytes: 3092
#include<bits/stdc++.h>
#define ld double
#define ull unsigned long long
#define ll long long
#define pii pair<int,int >
#define iiii pair<int,pii >
#define mp make_pair
#define INF 1000000000
#define MOD 1000000007
#define rep(i,x) for(int (i)=0;(i)<(x);(i)++)
inline int getint(){
	int x=0,p=1;char c=getchar();
	while (c<=32)c=getchar();
	if(c==45)p=-p,c=getchar();
	while (c>32)x=x*10+c-48,c=getchar();
	return x*p;
}
using namespace std;
//ruogu
ll n;
//
ll gcd(ll x,ll y){
	if(!y)return x;
	return gcd(y,x%y);
}
int main(){
	ll x,y;
	cin>>x>>y;
	ll n=gcd(x,y);
	int res=0;
	for(ll i=2;i*i<=n;i++){
		if(n%i==0){
			++res;
			while(n%i==0)n/=i;
		}
	}
	if(n>1)res++;
	cout<<res+1<<endl;
	return 0;
}


Measured memory_bytes: 256
x=input()
y=[[int(x[i]),-int(x[i])] for i in range(4)]
for a in range(2):
    for b in range(2):
        for c in range(2):
            if y[0][0]+y[1][a]+y[2][b]+y[3][c]==7:
                ans=[x[0],"-" if a else "+",x[1],"-" if b else "+",x[2],"-" if c else "+",x[3]]
                break
print("".join(ans)+"=7") 

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

int main() {
  char alpha;
  cin >> alpha;
  if ((alpha >= 'a') && (alpha <= 'z')) {
    cout << 'a' << endl;
  } else if ((alpha >= 'A') && (alpha <= 'Z')) {
    cout << 'A' << endl;
  }
  return 0;
}

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

using namespace std;

int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int su = 0;
    for (char c : s) if (c == '1') su++;
    if (su == 0) {
        for (int i = 0; i<n; i++) cout << 1 << '\n';
        return 0;
    }
    int sum[2];
    sum[0] = su-1;
    sum[1] = su+1;
    int a[n][2];
    int b[2];
    for (int i=0; i<2; i++) {
        if (sum[i] == 0) continue;
        a[0][i] = (1 % sum[i]);
        b[i] = 0;
        if (s[n-1] == '1') b[i] = a[0][i];
        for (int j=1; j<n; j++) {
            a[j][i] = (2*a[j-1][i]) % sum[i];
            if (s[n-1-j] == '1') {
                b[i] += a[j][i];
                b[i] %= sum[i];
            }
        }
    }
    int res[n];
    for (int i=0; i<n; i++) {
        int j;
        if (s[i] == '1') j = 0;
        else j = 1;
        if (sum[j] == 0) {
            res[i] = 0;
            continue;
        }
        
        int c;
        if (j == 0){
            c = b[0] - a[n-1-i][0];
        }
        else 
            c = b[1] + a[n-1-i][1]; 
        
        if (c < 0) c += sum[j];
        c %= sum[j];
        //cout << sum[j] << " " << c << '\n';
        res[i] = 1;
        while (c > 0) {
            int d = 0, k = 0;
            while (c >= (1<<k)) {
                if (c & (1<<k)) d++;
                k++;
            }
            c %= d;
            res[i]++;
        }
        
    }
    for (int i=0; i<n; i++) cout << res[i] << '\n';
    return 0;
}

Measured memory_bytes: 6076
/*
    Created by 10_months
    Tag:
    Link:
*/

#include <iostream>
#include <iomanip>
#include <cstring>
#include <cstdio>
#include <math.h>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <algorithm>

using namespace std;

const long long inf = 1e17;
const int INF = 1e9 + 7;
const int N = 1234567;
const int M = 123456;

long long n, m;

int main() {
    #ifdef home
        freopen("in", "r", stdin);
        freopen("out", "w", stdout);
    #endif       
    while (cin >> n >> m) {
        long long ans = 0;
        if (2 * n <= m) {
            ans += n;
            m -= 2 * n;
        } else {
            ans += m / 2;
            m = 0;
        }
        ans += m / 4;
        cout << ans << endl;
    }
    return 0;
}


Measured memory_bytes: 256