akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <cstdlib>
#include <numeric>
#include <algorithm>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
#include <stdio.h>
#include <tuple>

#define rep(i,m,n) for(int i=(m);i<(n);++i)
#define rem(i,m,n) for(int i=(m);i>(n);--i)
#define MOD 1000000007

using namespace std;

using ll = long long int;
using std::swap;

vector<int> v;
vector<long long int> vll;
vector<long long int> w;
vector<vector<int>> vec(50,vector<int>(4,0));

int N, Y;
int mode = 0;



int main() {
	string S;
	cin >> S;
	if (S == "ABC")cout << "ARC" << '\n';
	else cout << "ABC" << '\n';

	return 0;
}

Measured memory_bytes: 3636
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
#define answer(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

Int modpow(Int a, Int n, Int mod) {
    Int ret = 1;
    while (n > 0) {
        if (n & 1) {
            ret = ret * a % mod;
        }
        a = a * a % mod;
        n >>= 1;
    }

    return ret;
}

vector<Int> factorials(0), invs(0);
bool is_ncr_table = false;
void calc_ncr_table(Int n, Int mod) {
    is_ncr_table = true;

    // 1! ~ n! の計算
    Int f = 1;
    factorials.push_back(f);
    for (Int i = 1; i < n + 1; i++) {
        f *= i;
        f %= mod;
        factorials.push_back(f);
    }
    // n!^-1 の計算
    Int inv = modpow(factorials[n], mod - 2, mod);
    // (n-1)!^-1 ~ 1!^-1 の計算
    invs.assign(n, 1);
    invs[n] = inv;
    for (Int i = n; i >= 1; i--) {
        inv *= i;
        inv %= mod;
        invs[i - 1] = inv;
    }
}

Int factorial(Int n, Int mod = 1) {
    Int ret = 1;
    if (mod == 1) {
        for (Int i = 1; i < n + 1; i++) {
            ret *= i;
        }

        return ret;
    } else {
        for (Int i = 1; i < n + 1; i++) {
            ret *= i;
            ret %= mod;
        }

        return ret;
    }
}

Int ncr(Int n, Int r, Int mod, bool use_table = false) {
    if (use_table) {
        // modが素数の場合のみ
        if (!is_ncr_table) {
            calc_ncr_table(n, mod);
        }
        return factorials[n] * invs[r] * invs[n - r] % mod;
    } else {
        Int x = 1;
        for (Int i = n - r + 1; i < n + 1; i++) {
            x *= i;
            x %= MOD;
        }
        return x * modpow(factorial(r, mod), mod - 2, mod) % mod;
    }
}

int main() {
    int x;
    cin >> x;
    set<int> prime;
    for (int i = 2; i <= 100003; i++) {
        bool p = true;
        for (auto e : prime) {
            if (i % e == 0) {
                p = false;
                break;
            }
        }

        if (p) {
            prime.insert(i);
        }
    }

    auto itr = prime.lower_bound(x);

    cout << *itr << endl;

    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using namespace std;
#include "string"
#define int long long
#define pi pair < int, int>
#define ff first
#define ss second
#define boost ios::sync_with_stdio(false);cin.tie(nullptr)
#define endl "\n"

int32_t main(){
	boost;
	int n, k;
	cin >> n >> k;
	int r, s, p;
	cin >> r >> s >> p;
	string t;
	cin >> t;
	// r - 0
	// p - 1
	// s - 2
	auto win = [&](int i, char c) {
		if(c == 'r' && i == 1)
			return p;
		else if(c == 'p' && i == 2)
			return s;
		else if(c == 's' && i == 0)
			return r;
		else
			return 0ll;
	};

	int ans = 0;
	
	for(int i = 0; i < k; i++) {
		string cur = "";
		for(int j = i; j < n; j += k)
			cur += t[j];
		vector < vector < int > > dp(cur.size(), vector < int > (4, -1));
		function < int (int , int) > solve = [&](int id, int f) {
			if(id == cur.size())
				return 0ll;
			int &tmp = dp[id][f];
			if(tmp != -1)
				return tmp;
			tmp = 0;
			for(int i = 0; i < 3; i++) {
				if(i == f)
					continue;
				tmp = max(tmp, solve(id + 1, i) + win(i, cur[id]));
			}
			return tmp;
		};
		ans += solve(0, 3);
	}
	cout << ans << endl;
}

Measured memory_bytes: 19528
N = int(input())
dp = [0] * (N + 1)
for i in range(1, N + 1):
    cnt = i
    for j in range(1, 7):
        q = 6 ** j
        if i >= q:
            cnt = min(cnt, dp[i - q] + 1)
    for j in range(1, 6):
        q = 9 ** j
        if i >= q:
            cnt = min(cnt, dp[i - q] + 1)
    dp[i] = cnt
print(dp[N])

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


using ll = long long int;

using namespace std;

bool has_digit(string a, string d)
{
    /*
    bool ans = false;
    while(a)
    {
        ans = ans || ((a % 10) == d);
        a /= 10;
    }
    return ans;*/
    //bool res = (a.find(d) != std::string::npos);
    bool res = a == d;
    return res;

}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int i, j, n, d, k;
    
    cin >> n;
    string a;
    k = 0;
    d = 1;
  
    for(i = 0; i < n; ++i)
    {
        cin >> a;
        if (has_digit(a, to_string(d)))
        {
            ++d;
        }
        else
        {
            ++k;
        }
    }
    
    if (k == n)
        k = -1;
    
    cout << k;
    
    return 0;
}


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

using namespace std;

int sieve[1000100];
vector<int>v;
int fnc()
{
    sieve[0] = 1;
    sieve[1] = 1;
    for(long long int i = 2;i<1000100;i++)
    {
        if(sieve[i] == 0)
        {
            v.push_back(i);
            for(long long int j = i*2;j<1000100;j+=i)
            {
                sieve[j]=1;
            }
        }
    }
}

int main(void)
{
    fnc();
    int q;
    cin >> q;
    while(q--)
    {
        int l1,l2;
        cin >> l1 >> l2;
        int c = 0;
        for(auto bi: v)
        {
           // cout << bi << endl;
            if(bi >= l1 && bi<=l2)
            {

                if(sieve[(bi+1)/2] == 0)c++;
            }else if(bi>l2)
            {
                break;
            }
        }
        cout << c << endl;
    }
}


Measured memory_bytes: 4984
#include<bits/stdc++.h>
using namespace std;
long long n;
long long a[1000];
int main(){
	cin>>n;
	for(long long i=1;i<=n;i++){
		cin>>a[i];
	}
	long long ans=10000000000,temp;
	for(long long i=1;i<=100;i++){
		temp=0;
		for(long long j=1;j<=n;j++){
			temp+=(i-a[j])*(i-a[j]);
		}
		ans=min(ans,temp);
	}
	cout<<ans;
	return 0;
}

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

using namespace std;

int main()
{
    int n,m;
    cin>>n>>m;
    int a[m],sum=0;
    for(int i=0;i<m;i++){
        cin>>a[i];
        sum += a[i];
    }
    if(sum > n){
            cout<<"-1"<<endl;
        }
        else{
            cout<<n-sum<<endl;
        }

    return 0;
}


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

#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

using ll = long long;
using namespace std;
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1000000007;

ll comb(ll a ,ll k){
    ll div=1;
    ll den=1;
    rep(i,k){
        div=div*(a-i);
        den=den*(k-i);
    }
    return div/den;
}
int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin>>n;
vector<int>a(n);
rep(i,n)cin>>a[i];
int even_num=0,odd_num=0;
rep(i,n){
    if(a[i]%2==0){
        even_num++;
    }
    else{
        odd_num++;
    }
}
ll ans=0;
reps(i,even_num+1,1){
    ans+=comb(even_num,i)*pow(2,even_num-i)*pow(3,odd_num);
}
reps(i,odd_num+1,1){
    ans+=comb(odd_num,i)*pow(2,i)*pow(2,even_num);
}
cout<<ans<<endl;
return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
  int N;cin>>N;
  int a[N];
  for(int i = 0; N > i; i++){
    cin>>a[i];
  }
  int nw = 0;
  int nwx = 0;
  int prev = 0;
  long long ans = 0;
  for(int i = 0; N > i; i++){
    nw += a[i];
    nwx ^= a[i];
    if(nw != nwx){
      //prev ~ (i-1),
      //cout << ans << endl;
      while(nw != nwx){
        nw -= a[prev];
        nwx ^= a[prev];
        prev++;
      }
    }

    ans += i-prev+1;
    //cout << i << " " << prev << " " <<ans << endl;
  }

  cout << ans << endl;

}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<cassert>
#include<cassert>
#include<unordered_map>
#include<unordered_set>
#include<functional>
#include<queue>
#include<stack>
#include<cstring>
#include<algorithm>
#include<cmath>
#include<sstream>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<numeric>
#include<random>
#include<chrono>
#include<bitset>
using namespace std;

#define all(x) (x).begin(), (x).end()
#define pb push_back
#define xx first
#define yy second
#define sz(x) (int)(x).size()
#define gc getchar
#define IO ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mp make_pair

#ifndef ONLINE_JUDGE
#  define LOG(x) (cerr << #x << " = " << (x) << endl)
#else
#  define LOG(x) ((void)0)
#endif

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

const double PI=acos(-1);
const ll INF = 1LL<<62;
const ll MINF = -(1LL<<62);

template<typename T> T getint() {
	T val=0;
	char c;
	
	bool neg=false;
	while((c=gc()) && !(c>='0' && c<='9')) {
		neg|=c=='-';
	}

	do {
		val=(val*10)+c-'0';
	} while((c=gc()) && (c>='0' && c<='9'));

	return val*(neg?-1:1);
}

//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); uniform_int_distribution<int>(0, n-1)(rng)


int main() {
	IO;
	int n,ans=0;
	cin>>n;
	for(int i=1;i<=n;++i) {
		int x;
		cin>>x;
		ans+=(x&1)&(i&1);
	}
	cout<<ans<<"\n";
	return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
const int inf = 1e9;
typedef pair<int,int> P;
typedef pair<int, P> PP;
#define fi first
#define se second
#define rep(i,n) for(int i = 0;i < n;i++)

int a[210][210], G[210][210], R[10];
int n, m, r, dp[10][1<<9];

int main(){
	fill((int*)dp, (int*)(dp+10), inf);
	fill((int*)a, (int*)(a+210), inf);
	scanf("%d%d%d", &n, &m, &r);
	rep(i,r)scanf("%d", &R[i]);
	
	for(int i = 0;i < m;i++){
		int t[3];
		rep(i,3)scanf("%d", &t[i]);
		a[t[0]-1][t[1]-1] = t[2];
		a[t[1]-1][t[0]-1] = t[2];
	}
	rep(i,n)rep(u,n)rep(t,n){
		a[u][t] = min(a[u][t], a[u][i]+a[i][t]);
	}
	rep(i,r)rep(j,r){
		int u = R[i]-1, t = R[j]-1;
		G[i][j] = a[u][t];
		G[j][i] = a[t][u];
	}
	/*rep(i,r){
		rep(j,r)printf("%d ", G[i][j]);
		printf("\n");
	}*/
	
	int ans = inf;
	rep(i,r)dp[i][1<<i] = 0;
	for(int bit = 0;bit < (1<<r);bit++){
		rep(u,r)rep(t,r){
			if(!(bit&(1<<u)) || u == t)continue;
			int prev = bit & ~(1<<u);
			dp[u][bit] = min(dp[u][bit], dp[t][prev]+G[t][u]);
		}
	}
	
	rep(i,r)ans = min(ans, dp[i][(1<<r)-1]);
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
int main()
{
	int n,c[500],f[500],i,j;
	long long int s[500],t;
	scanf("%d",&n);
	for(i=0;i<n-1;i++)
	{
		scanf("%d%lld%d",&c[i],&s[i],&f[i]);
	}
	for(i=0;i<n-1;i++)
	{
		t=c[i]+s[i];
		for(j=i+1;j<n-1;j++)
		{
			if(t>=s[j])
			{
				if((t-s[j])%f[j]==0)
				{
					t+=c[j];
				}
				else
				{
					t=s[j]+(t-s[j])/f[j]*f[j]+f[j];
					t+=c[j];
				}
			}
			else
			{
				t=s[j]+c[j];
			}
		}
		printf("%lld\n",t);
	}
	printf("0");
}

Measured memory_bytes: 128
//12252024832524
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std; 

typedef long long LL;
const int MAXN = 10005;
int k,a,b;

int Read()
{
	int x = 0,f = 1;char c = getchar();
	while(c > '9' || c < '0'){if(c == '-')f = -1;c = getchar();}
	while(c >= '0' && c <= '9'){x = (x*10) + (c^48);c = getchar();}
	return x * f;
}
void Put1(int x)
{
	if(x > 9) Put1(x/10);
	putchar(x%10^48);
}
void Put(int x,char c = -1)
{
	if(x < 0) putchar('-'),x = -x;
	Put1(x);
	if(c >= 0) putchar(c);
}
template <typename T>T Max(T x,T y){return x > y ? x : y;}
template <typename T>T Min(T x,T y){return x < y ? x : y;}
template <typename T>T Abs(T x){return x < 0 ? -x : x;}

int main()
{
//	freopen(".in","r",stdin);
//	freopen(".out","w",stdout);
	k = Read();
	a = Read();
	b = Read();
	a = a/k*k + ((a%k) ? 1 : 0) * k;
	if(a <= b) printf("OK");
	else printf("NG");
	return 0;
}

Measured memory_bytes: 3100
#include <algorithm>
#include <array>
#include <cmath>
#include <deque>
#include <iostream>
#include <set>
#include <string>

using namespace std;

int main() {
  int obs_num, road_num;

  cin >> obs_num >> road_num;

  deque<int> heights(obs_num, 0);
  deque<bool> is_good_obs(obs_num, true);

  // 展望台の高さを入力
  for (int i = 0; i < obs_num; i++) {
    int tmp;
    cin >> tmp;
    heights[i] = tmp;
  }

  // 道を入力、良い展望台ではないものを記録
  for (int i = 0; i < road_num; i++) {
    int from, to;

    cin >> from >> to;

    // indexに変換
    from--;
    to--;

    if (heights[from] <= heights[to]) {
      // fromは良い展望台ではない
      is_good_obs[from] = false;
    }
    if (heights[to] <= heights[from]) {
      // toは良い展望台ではない
      is_good_obs[to] = false;
    }
  }

  // 良い展望台をカウント
  int cnt = 0;

  for (int i = 0; i < obs_num; i++) {
    if (is_good_obs[i]) {
      cnt++;
    }
  }

  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 3696
#include "bits/stdc++.h"
using namespace std;
static const int MAX = 50;

int main() {
    int n, D[MAX];
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> D[i];

    int sum = 0;
    for (int i = 0; i < n - 1; ++i) {
        for (int j = i + 1; j < n; ++j) {
            sum += D[i] * D[j];
        }
    }

    cout << sum;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
a=list(map(int, input().split()))

for i in range(n):
    v=a[i]
    j=i-1
    while j>=0 and a[j]>v:
        a[j+1]=a[j]
        j=j-1
    a[j+1]=v
    print(" ".join(map(str,a )))


Measured memory_bytes: 5596
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
int main() {
  int N;
  bool b = false;
  cin >> N;
  vector<vector<int>> D(N, vector<int>(2));
  rep(i, N) {
    rep(j, 2) {
      cin >> D.at(i). at(j);
    }
  }
  rep(i, N - 2) {
    if (D.at(i).at(0) == D.at(i).at(1)) {
      if (D.at(i + 1).at(0) == D.at(i + 1).at(1) && D.at(i + 2).at(0) == D.at(i + 2).at(1)) {
        b = true;
        break;
      }
    }
  }
  if (b) {cout << "Yes" << endl;}
  else {cout << "No" << endl;}
}

Measured memory_bytes: 3584
import java.util.Scanner;

public class Main {
    private static final long mod = (int) (1e9 + 7);

    public static void main(String args[]) {
        try (Scanner in = new Scanner(System.in)) {
            int N = Integer.parseInt(in.nextLine());
            run(N);
        }
    }

    private static void run(int N) {
        int[] countDivisor = new int[N + 1];
        for (int number = 1; number <= N; number++) {

            int n = number;
            for (int divisor = 2; divisor <= n; divisor++) {
                while (n % divisor == 0) {
                    countDivisor[divisor]++;
                    n /= divisor;
                }
            }

        }

        long numDivisors = 1;
        for (int i = 2; i <= N; i++) {
            numDivisors *= (1 + countDivisor[i]);
            numDivisors = numDivisors % mod;
        }

        System.out.println(numDivisors);
    }
}


Measured memory_bytes: 9684
// Problem : A - Coffee
// Contest : AtCoder Beginner Contest 160
// URL : https://atcoder.jp/contests/abc160/tasks/abc160_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <cstdio>
char s[15];
int main()
{
 scanf("%s",s+1);
 if(s[3]==s[4]&&s[5]==s[6])
  puts("Yes");
 else puts("No");
 return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main(){
    int n, y;
    cin >> n >> y;
    int f = 0;
    for(int i=0; i<=n; i++){
        for(int j=0; j+i<=n; j++){
            for(int l=0; l+j+i<=n; l++){
                if(i*10000 + j*5000 + l*1000 == y && i+j+l == n){
                    cout << i << ' ' << j << ' ' << l << endl;
                    f = 1;
                    break;
                }
            }
            if(f == 1) break;
        }
        if(f == 1) break;
    }
    if(f == 0) cout << -1 << ' ' << -1 << ' ' << -1 << endl;
    return 0;
}

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

#define MOD 1000000007ll
#define all(v) v.begin() , v.end()
#define allr(v) v.rbegin(), v.rend()
#define for0(i,n) for(__typeof(n) i = 0; i < n ; i++) 
#define forab(i,a,b) for(__typeof(a) i = a ; i < b ; i++) 
#define forba(i,b,a) for(__typeof(a) i = b ; i > a ; i--) 
#define forc(c,it) for(__typeof(c.begin()) it = c.begin(); it != c.end(); it++)
#define pb     push_back
#define mp     make_pair
#define MAX 100005

int n;
string s;
int cnt[30];

int main(int argc, char const *argv[])
{
  ios_base::sync_with_stdio(false);
  
  // #ifndef ONLINE_JUDGE
  // freopen("in","r",stdin);
  // freopen("out","w",stdout);
  // #endif

  for(int i = 0 ; i < 30 ; i++)
  	cnt[i] = INT_MAX;

  cin>>n;

  for0(i , n)
  {
  	int lcnt[30] = {0};
  	cin>>s;
  	int siz = s.size();

  	for(int i = 0 ; i < siz ; i++)
  		lcnt[s[i] - 'a']++;

  	for(int i = 0 ; i < 26 ; i++)
  		cnt[i] = min(cnt[i] , lcnt[i]);
  	
  }

  for(int i = 0 ; i < 26 ; i++)
  {
  	for(int j = 0 ; j < cnt[i] ; j++)
  		cout<<(char)('a' + i);
  }

  return 0;
}  


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

using namespace std;
typedef long long ll;
typedef pair<int,int> P;

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

    ll N,K; cin >> N >> K;

    ll A[200005];
    for (int i = 0;i < N;i++){
        cin >> A[i];
    }

    vector<ll> sum;
    sum.push_back(A[0]);
    for (int i = 1;i < N;i++){
        sum.push_back(sum[sum.size()-1]+A[i]);
    }

    ll ans = 0;
    ll tmp[200005];

    tmp[0] = 0;

    for (int i = 0;i < N;i++){
        tmp[i+1] = (sum[i]-(i+1))%K; 
    }

    map<ll,ll> cnt;

    ll las = K-1;
    for (int i = 0;i <= min(las,N);i++){
        cnt[tmp[i]]++;
    }

    for (int i = 0;i <= N;i++){
        ans += cnt[tmp[i]]-1;
        //cout << cnt[tmp[i]] << endl;
        cnt[tmp[i]]--;
        las++;
        if(las <= N){
            cnt[tmp[las]]++;
        }
    }

    cout << ans << endl;

    return 0;

}

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

int main(){
  int n,k;
  cin>>n>>k;
  int h[n];
  long long dp[n];

  for(int i=0; i<n; i++){ cin>>h[i]; dp[i]=999999999;}
  dp[0]=0;
  //dp[1]=abs(h[1]-h[0]);
  for(int i=0; i<n; i++){
    for(int j=1; j<=k; j++){
      if(i+j<n)
      dp[i+j]=min(dp[i+j],dp[i]+abs(h[i+j]-h[i]));
      else break;
      //dp[i]=min(dp[i-1]+abs(h[i]-h[i-1]), dp[i-2]+abs(h[i]-h[i-2]));
    }

  }
  cout<<dp[n-1];

}


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

int main() {
    int N; cin >> N;
    vector<int64_t> A(N);
    for(auto &e : A) cin >> e;
    int64_t all = 0;
    for(int i = 0; i < N; ++i) all ^= A[i];
    for(int i = 0; i < N; ++i) cout << (all ^ A[i]) << " ";
    cout << '\n';
    return 0;
}


Measured memory_bytes: 4772
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <set>
#include <unordered_set>
#include <unordered_map>
#define ll long long
#define fi first
#define se second
#define pb push_back
#define me memset
const int N = 1e6 + 10;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
using namespace std;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;

inline int read()
{
	int X=0; bool flag=1; char ch=getchar();
	while(ch<'0'||ch>'9') {if(ch=='-') flag=0; ch=getchar();}
	while(ch>='0'&&ch<='9') {X=(X<<1)+(X<<3)+ch-'0'; ch=getchar();}
	if(flag) return X;
	return ~(X-1);
}

int n,m;
int u,v;
int p[N];
map<int,int> mp;

int find(int x){
	if(p[x]!=x) p[x]=find(p[x]);
	return p[x];
}

int main() {
    //ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	n=read();
	m=read();
	for(int i=1;i<=n;++i) p[i]=i;
	for(int i=1;i<=m;++i){
		u=read();
		v=read();
		p[find(u)]=find(v);
	}

	for(int i=1;i<=n;++i){
		mp[find(i)]++;
	}

	int res=0;
	for(auto w:mp){
		res=max(res,w.se);
	}

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

    return 0;
}

Measured memory_bytes: 13740
#include <iostream>
#include <string>
using namespace std;
#define REP(i, a, n) for(int i=a; i<n; i++)

int main(){
	string s;
	cin>>s;
	
	REP(i, 0, s.size()){
		if(i%2==0) cout<<s[i];
	}
	cout<<endl;
	return 0;
}

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

int main() {
  int h, w;
  cin >> h >> w;
  vector<string> S(h);
  for (auto& s : S)
    cin >> s;
  vector<vector<int>> d(h * w, vector<int>(h * w, 1000));
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      if (S[i][j] == '#')
        continue;
      d[i * w + j][i * w + j] = 0;
      if (i > 0 && S[i - 1][j] == '.') {
        d[(i - 1) * w + j][i * w + j] = 1;
        d[i * w + j][(i - 1) * w + j] = 1;
      }
      if (j > 0 && S[i][j - 1] == '.') {
        d[i * w + (j - 1)][i * w + j] = 1;
        d[i * w + j][i * w + (j - 1)] = 1;
      }
    }
  }

  for (int k = 0; k < h * w; ++k) {
    for (int i = 0; i < h * w; ++i) {
      for (int j = 0; j < h * w; ++j) {
        d[i][j] = min(d[i][j], d[i][k] + d[k][j]);
      }
    }
  }

  int ret = 0;
  for (auto& di : d) {
    for (int x : di) {
      if (x >= h * w)
        continue;
      ret = max(ret, x);
    }
  }
  cout << ret << "\n";

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<int(n);++i)
#define all(a) (a).begin(),(a).end()
typedef long long ll;
#define rep1(i,n) for(int i=1;i<=int(n);++i)
#define lb(s,x) (lower_bound(all(s),x)-s.begin())
#define ub(s,x) (upper_bound(all(s),x)-s.begin())
#define uniq(a) a.erase(unique(all(a)),a.end())
#define bit(k) (1LL<<(k))


int main(void){
    double pi = acos(-1);
    double a,b,h,m;
    cin >> a >> b >> h >> m;
    printf("%.20f\n", abs(polar(a, h*(pi/6) + (pi/6)*(m/60)) - polar(b, pi*2*(m/60))));
    return 0;
}


Measured memory_bytes: 4152
import java.io.*;
import java.util.*;
 
public class Main {
 
	void submit() {
	    
	    int N = nextInt();
	    if(N%2==0){
		    out.println(N/2);
	    }else{
		    out.println(N/2+1);
	    }
	}
 
	void preCalc() {
 
	}
 
	void stress() {
 
	}
 
	void test() {
 
	}
 
	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		preCalc();
		submit();
		//stress();
		//test();
		out.close();
	}
 
	static final Random rng = new Random();
 
	static int rand(int l, int r) {
		return l + rng.nextInt(r - l + 1);
	}
 
	public static void main(String[] args) throws IOException {
		new Main();
	}
 
	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;
 
	String nextToken() {
		while (st == null || !st.hasMoreTokens()) {
			try {
				st = new StringTokenizer(br.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return st.nextToken();
	}
 
	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}
 
	int nextInt() {
		return Integer.parseInt(nextToken());
	}
 
	long nextLong() {
		return Long.parseLong(nextToken());
	}
 
	double nextDouble() {
		return Double.parseDouble(nextToken());
	}
}


Measured memory_bytes: 21332
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

int gcd(int a, int b) {return b == 0 ? a : gcd(b, a % b);}

#define ll int
#define pb push_back
#define ld long double
#define mp make_pair
#define F first
#define S second
#define pii pair<ll,ll> 

using namespace :: std;

const ll maxn=2e5+500;
const ll inf=1e9+900;
const ll maxCNT=maxn*30;


ll l[maxn];
ll r[maxn];
ll d[maxn];
vector<pii> ger[maxn];
ll minn[maxn];

void diks(ll a){
	queue<pii> qu;
	qu.push(mp(0,a));
	ll CNT=0;
	while(qu.size()){
		CNT++;
		if(CNT>maxCNT){
			cout<<"No";
			exit(0);
		}
		pii e=qu.front();
		qu.pop();
		ll v=e.S;
		ll w=e.F;
		if(minn[v]>w){
			minn[v]=w;
			for(auto e:ger[v]){
				if(minn[e.F]>e.S+minn[v]){
					qu.push(mp(e.S+minn[v],e.F));
				}
			}
		}
	}

}
int main(){
	ll n,m;
	cin>>n>>m;
	for(ll i=0;i<m;i++){
		cin>>l[i]>>r[i]>>d[i];
		ger[l[i]].pb(mp(r[i],d[i]));
		ger[r[i]].pb(mp(l[i],-d[i]));
	}
	fill(minn,minn+maxn,inf);
	for(ll i=1;i<=n;i++){
		if(minn[i]==inf){
			diks(i);
		}
	}
	for(ll i=0;i<m;i++){
		if(minn[r[i]]!=minn[l[i]]+d[i]){
			cout<<"No";
			return 0;
		}
	}
	cout<<"Yes";
}




















Measured memory_bytes: 27380
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < (n); i++)
#define ALL(v) (v).begin(),(v).end()
using ll = long long;
using P = pair<int, int>;
const int INF = 1e9;
const long long LINF = 1e18;
const long long MOD = 1e9 + 7;

using ll = long long;
template <ll MOD = 1000000007>
struct Mint{
    ll x;

    Mint() : x(0) {}
    Mint(ll t){
        x = t % MOD;
        if(x < 0) x += MOD;
    }
    
    Mint pow(ll n){
        Mint res(1), t(x);
        while(n > 0){
            if(n & 1) res *= t;
            t *= t;
            n >>= 1;
        }
        return res;
    }

    Mint inv() const {
        ll a = x, b = MOD, u = 1, v = 0, t;
        while(b > 0){
            t = a / b;
            a -= t * b;
            swap(a, b);
            u -= t * v;
            swap(u, v);
        }
        return Mint(u);
    }

    Mint & operator += (Mint a){
        x += a.x;
        if(x >= MOD) x -= MOD;
        return *this;
    }
    
    Mint & operator -= (Mint a){
        x += MOD - a.x;
        if(x >= MOD) x -= MOD;
        return *this;
    }

    Mint & operator *= (Mint a){
        x = 1LL * x * a.x % MOD;
        return *this;
    }

    Mint & operator /= (Mint a){
        return (*this) *= a.inv();
    }

    Mint operator + (Mint a) const { return Mint(x) += a; }
    Mint operator - (Mint a) const { return Mint(x) -= a; }
    Mint operator * (Mint a) const { return Mint(x) *= a; }
    Mint operator / (Mint a) const { return Mint(x) /= a; }

    Mint operator - () const{ return Mint(-x); }

    bool operator == (const Mint a){ return x == a.x; }
    bool operator != (const Mint a){ return x != a.x; }
    bool operator < (const Mint a){ return x < a.x; }

    friend ostream & operator << (ostream & os, const Mint &a){
        return os << a.x;
    }

    friend istream & operator >> (istream & is, Mint &a){
        ll t;
        is >> t;
        a = Mint<MOD>(t);
        return (is);
    }
};

signed main(){
    int n,m;
    cin >> n >> m;
    int s[n], t[m];
    rep(i,n){
        cin >> s[i];
    }
    rep(i,m){
        cin >> t[i];
    }
    Mint<> dp[n + 1][m + 1];
    for(int i = 0; i <= n; i++){
        dp[i][0] = 1;
    }
    for(int i = 0; i <= m; i++){
        dp[0][i] = 1;
    }
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            if(s[i] == t[j]){
                dp[i + 1][j + 1] = dp[i][j + 1] + dp[i + 1][j];
            }else{
                dp[i + 1][j + 1] = dp[i][j + 1] + dp[i + 1][j] - dp[i][j];
            }
        }
    }
    cout << dp[n][m] << endl;
    return 0;
}

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

using namespace std;

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

int sx, sy, gx, gy, n, bx, by;
double P[3][3][20];

bool check(int x, int y){
  return (0 <= x && x < 3 && 0 <= y && y < 3);
}

void solve(){
  P[sy][sx][n] = 1;

  while(n){
    for(int i = 0 ; i < 3 ; i++){
      for(int j = 0 ; j < 3 ; j++){
        for(int k = 0 ; k < 4 ; k++){
          int nx = i + dx[k];
          int ny = j + dy[k];
          if(!check(nx, ny) || (bx == nx && by == ny)){
            P[j][i][n-1] += P[j][i][n] / 4;
          }else if(check(nx, ny)){
            P[ny][nx][n-1] += P[j][i][n] / 4;
          }
        }
      }
    }
    n--;
  }

  printf("%.8f\n",P[gy][gx][n]);
}

int main(){
  char s, t, b;
  
  while(cin >> n, n){
    memset(P, 0, sizeof(P));

    cin >> s >> t >> b;
    int ss = s - 'A', tt = t - 'A', bb = b - 'A';
    sx = ss%3; sy = ss/3;
    gx = tt%3; gy = tt/3;
    bx = bb%3; by = bb/3;
    solve();
  }

  return 0;
}

Measured memory_bytes: 1188
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Atcoderrrrrr
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split(' ');
            Console.WriteLine(
                s.Contains("1")==true && s.Contains("9") == true
                && s.Contains("7") == true && s.Contains("4") == true ? "YES":"NO"
                );
        }
    }
}


Measured memory_bytes: 11220
#include <iostream>
#include <vector>

using namespace std;
typedef long long ll;

const ll MOD = 1e9 + 7;

ll calc_pow(ll x, ll pow) {
    if (pow == 0) return 1;
    ll a = calc_pow(x, pow / 2);
    a = a * a % MOD;
    if (pow % 2 == 1) a *= x;
    return a % MOD;
}

ll calc_div(ll b) {
    return calc_pow(b, MOD - 2) % MOD;
}

vector<ll> fact;

void init_fact(int n) {
    fact = vector<ll>(n);
    fact[0] = 1;
    for (int i = 1; i < n; i++) fact[i] = fact[i - 1] * i % MOD;
}

ll calc_comb(ll n, ll r) {
    if (n < r)return 0;
    return fact[n] * calc_div(fact[r] * fact[n - r] % MOD) % MOD;
}

int main() {
    init_fact(100000);

    ll n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;

    vector<ll> dp(n + 1);
    dp[n] = 1;
    for (int people = a; people <= b; people++) {
        vector<ll> nowdp(n + 1);

        ll divide = 1;
        for (int i = 1; i < c; i++) {
            divide *= calc_comb(people * i, people), divide %= MOD;
            divide *= calc_div(i), divide %= MOD;
        }

        for (int group = c; group <= d && people * group <= n; group++) {
            int count = people * group;

            divide *= calc_comb(count, people), divide %= MOD;
            divide *= calc_div(group), divide %= MOD;
            for (int prev = n; prev - count >= 0; prev--) {
                ll x = dp[prev] * calc_comb(prev, count) % MOD;
                nowdp[prev - count] += x * divide % MOD, nowdp[prev - count] %= MOD;
            }
        }

        for (int i = 0; i <= n; i++)dp[i] += nowdp[i], dp[i] %= MOD;
    }

    cout << dp[0] << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
main(){
  int i,j,a[10][10],x;
  long long n;
  while(scanf("%lld",&n) !=EOF){
    x=1000000000;
    for(i=0;i<10;i++){
      a[i][9]=n/x;
      n-=(long long)a[i][9]*x;
      x/=10;
    }
   
    for(i=9;i>0;i--){ 
      for(j=0;j<=i;j++){
	if(a[j][i]+a[j+1][i]>=10){
	  a[j][i-1]=(a[j][i]+a[j+1][i])/10;
	  a[j][i-1]=a[j][i]+a[j+1][i]-a[j][i-1]*10;
	}
	else a[j][i-1]=a[j][i]+a[j+1][i];
      }
    }
    
    printf("%d\n",a[0][0]); 
  }
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main()
{int n;
 int k[32]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
 cin>>n;
 cout<<k[n-1];}

Measured memory_bytes: 256
# /usr/bin/python
# -*- coding: utf-8 -*-
import math



D = 10**9+7
def fact(n):
  ret = 1
  for i in range(1,n+1):
    ret = (ret*i) % D
  return ret


def main():
  NM = sorted(list(map(int, input().split())))
  n,m = [fact(NM[0]), fact(NM[1])]
  if NM[0]==NM[1]:
    return (n*m*2) % D
  elif NM[0]+1==NM[1]:
    return (n*m) % D
  else:
    return 0

if __name__ == "__main__":
  print(main())

Measured memory_bytes: 38384
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main() {
    ll A[4];
    rep(i,4){
        cin >> A[i];
    }
    //sort(A,A+3);
    cout << (A[0]+A[1]==A[2]+A[3] ? "Balanced" : (A[0]+A[1]>A[2]+A[3] ? "Left" : "Right" )) << endl;
}

// int main(){
//     char A[19];
//     cin >> A;
//     A[3]='8';
//     cout <<  A << endl;
// }

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define SET(a,e) memset(a,e,sizeof(a))
#define LL long long
#define pb push_back
#define x first
#define y second
#define PII pair<int,int>

char s[200];
char tar[10] = "keyence";
int n;

int main() {
	
	scanf("%s", s);
	
	n = strlen(s);
	
	for (int i = 0; i < 7; i++) {
		if (tar[i] != s[i]) {
			for (int j = i; j < 7; j++) {
				if (tar[j] != s[n - 7 + j]) {
					printf("NO\n");
					return 0;
				}
			}
			printf("YES\n");
			return 0;
		}
	}
	
	printf("YES\n");
	
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(pi c, pi d){
	return c.S < d.S;
}

int main() {
	int n, m;
	cin >> n >> m;
	cout << (100*(n-m) + 1900*m)*pow(2,m);

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#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++)
typedef long long ll;
const int INF=1e+09;
double W,H,x,y;


int main(){    
    //入力
    cin >> W >> H >> x >> y;
    int flag=0;
    double max = W*H/2;
    if(x==W/2&&y==H/2) flag=1;
    printf("%.10f %d",max,flag);
}

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

template<typename T, typename U> bool chmin(T &a, const U &b) {
	return (a > b ? a = b, true : false);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
	return (a < b ? a = b, true : false);
}

typedef long long ll;

#define writeln(n) cout<<n<<"\n";

typedef pair<int, int> P;
typedef pair<string, int> Psi;

ll dis[10000000];
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);


	int x,y;
	cin>>x>>y;

	if(x)--x; if(y)--y;

	int ct=0;

	while(x){
		ct +=x;
		x--;
	}
	while(y){
			ct +=y;
			y--;
		}

	cout<<ct<<endl;


}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

int main() {
    int n;
    cin >> n;
    Int ans = 0;
    vector<Int> pairs;
    vector<string> s(n), sp;

    string in;
    for (int i = 0; i < n; i++) {
        cin >> in;
        sort(in.begin(), in.end());
        s[i] = in;
        in.clear();
    }

    sort(s.begin(), s.end());
    // unique_copy(s.begin(), s.end(), back_inserter(sp));

    // for (auto e : sp) {
    //     pairs.push_back(count(s.begin(), s.end(), e));
    // }

    for (int i = 0; i < n - 1; i++) {
        int tem = 1;
        while (i < n - 1) {
            if (s[i] == s[i + 1]) {
                tem++;
                i++;
            } else {
                break;
            }
        }
        pairs.push_back(tem);
    }

    for (auto e : pairs) {
        ans += e * (e - 1) / 2;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6904
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<map>

#define PII pair<int , int>

using namespace std;

int main(void)
{
	PII input[7];
	int sum = 0;
	
	for (int i = 0; i < 7; i++)
	{
		cin >> input[i].first >> input[i].second;
		sum = max(input[i].first , input[i].second) - min(input[i].first , input[i].second);
		
		cout << sum << endl;
	}	

	
	return 0;
}

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

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
bool srt_knsk(vector<int> v,int n){
  for(int i=0; i<v.size(); i++){
    if(v.at(i) == n){
      return true;
    }
  }
  return false;
}
int main(){
  int N, M, X;
  cin >> N >> M >> X;
  vector<int> a(M);
  for(int i=0; i<M; i++){
    cin >> a.at(i);
  }
  int cost0=0,costn=0;
  for(int i=1; i<=X-1; i++){
    if(srt_knsk(a,i)){
      cost0++;
    }
  }
  for(int i=X+1; i<=N-1; i++){
    if(srt_knsk(a,i)){
      costn++;
    }
  }
  cout << min(cost0,costn) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define mod 1000000007
#define deb(x) cerr << "\n" \
                    << #x << "=" << x << "\n";
#define deb2(x, y) cerr << "\n"                   \
                        << #x << "=" << x << "\n" \
                        << #y << "=" << y << "\n";
#define w(x) \
  int x;     \
  cin >> x;  \
  while (x--)

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

  int n;
  cin >> n;

  vector<int> a, b;

  for (int i = 0; i < n; i++)
  {
    int x, y;
    cin >> x >> y;
    a.push_back(x);
    b.push_back(y);
  }
  sort(a.begin(), a.end());
  sort(b.begin(), b.end());

  if (n % 2)
  {
    int l = a[(n + 1) / 2 - 1];
    int r = b[(n + 1) / 2 - 1];

    cout << r - l + 1;
  }
  else
  {
    int l = a[n / 2 - 1] + a[n / 2];
    int r = b[n / 2 - 1] + b[n / 2];
    cout << r - l + 1;
  }
  return 0;
}

Measured memory_bytes: 6640
#include <climits>
#include <cstdio>
#include <cstdint>
#include <cstring>

#include <algorithm>

using namespace std;

using i32 = int32_t;
using u32 = uint32_t;
using f32 = float;
using f64 = double;
using i64 = int64_t; 
using u64 = uint64_t; 

#define SELECTER(_1, _2, _3, _4, _5, _6, _7, _8, SELECT, ...) SELECT

#define _FC1(func, type, _1)      func(type, _1);
#define _FC2(func, type, _1, ...) func(type, _1); _FC1(func, type, __VA_ARGS__);
#define _FC3(func, type, _1, ...) func(type, _1); _FC2(func, type, __VA_ARGS__);
#define _FC4(func, type, _1, ...) func(type, _1); _FC3(func, type, __VA_ARGS__);
#define _FC5(func, type, _1, ...) func(type, _1); _FC4(func, type, __VA_ARGS__);
#define _FC6(func, type, _1, ...) func(type, _1); _FC5(func, type, __VA_ARGS__);
#define _FC7(func, type, _1, ...) func(type, _1); _FC6(func, type, __VA_ARGS__);
#define _FC8(func, type, _1, ...) func(type, _1); _FC7(func, type, __VA_ARGS__);

#define _FCN(func, type, ...) SELECTER(__VA_ARGS__, _FC8, _FC7, _FC6, _FC5, _FC4, _FC3, _FC2, _FC1)(func, type, __VA_ARGS__);

constexpr const char *type2fmt(const char *fmt) {
  if(strcmp(fmt, "i32")) return "%d";
  if(strcmp(fmt, "u32")) return "%u";
  if(strcmp(fmt, "f32")) return "%f";
  if(strcmp(fmt, "f64")) return "%lf";
  if(strcmp(fmt, "i64")) return "%lld";
  if(strcmp(fmt, "u64")) return "%llu";
  if(strcmp(fmt, "char*")) return "%s";
  return "";
}

#define _R(type, _1) type _1; { type _t; scanf(type2fmt(#type), &_t); _1 = _t; }
#define _P(type, _1) { const type _t = (_1); printf(type2fmt(#type), _t); putchar('\n'); }

#define RI(...)   _FCN(_R, i32, __VA_ARGS__);
#define RUI(...)  _FCN(_R, u32, __VA_ARGS__);
#define RF(...)   _FCN(_R, f32, __VA_ARGS__);
#define RD(...)   _FCN(_R, f64, __VA_ARGS__);
#define RLL(...)  _FCN(_R, i64, __VA_ARGS__);
#define RULL(...) _FCN(_R, u64, __VA_ARGS__);

#define PI(...)   _FCN(_P, i32, __VA_ARGS__);
#define PUI(...)  _FCN(_P, u32, __VA_ARGS__);
#define PF(...)   _FCN(_P, f32, __VA_ARGS__);
#define PD(...)   _FCN(_P, f64, __VA_ARGS__);
#define PLL(...)  _FCN(_P, i64, __VA_ARGS__);
#define PULL(...) _FCN(_P, u64, __VA_ARGS__);
#define PS(...)   _FCN(_P, char*, __VA_ARGS__);

#define REP(n) for (int _i = 0; _i < n; _i++)

const u64 mod = 1000000007;

int main() {
  RI(N, A);
  printf(N % 500 <= A ? "Yes" : "No");
}


Measured memory_bytes: 128
while True:
    N, M, P, A, B = map(int, input().split())
    if not (N | M | P | A | B):
        break
    A, B = A - 1, B - 1
    T = [int(x) for x in input().split()]
    dp = [[float("inf")] * M for _ in range(1 << N)]
    dp[0][A] = 0
    edges = []
    for _ in range(P):
        s, t, c = map(int, input().split())
        s, t = s - 1, t - 1
        edges.append((s, t, c))
        edges.append((t, s, c))

    for state in range(1 << N):
        for s, t, c in edges:
            for k in range(N):
                if not (state >> k & 1):
                    next_s = state | (1 << k)
                    dp[next_s][t] = min(dp[next_s][t], dp[state][s] + c / T[k])
    ans = float('inf')
    for state in range(1 << N):
        ans = min(ans, dp[state][B])
    print("Impossible" if ans == float("inf") else "{:.020f}".format(ans))

Measured memory_bytes: 7892
#include<stdio.h>
#include<stdlib.h>
#include<string>
#include<iostream>
using namespace std;

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

Node *root, *NIL;

Node * treeMinimum(Node *x) {
  while ( x->left != NIL ) x = x->left;
  return x;
}

Node * find(Node *u, int k) {
  while ( u != NIL && k != u->key ) {
    if ( k < u-> key ) u = u->left;
    else u = u->right;
  }
  return u;
}

Node * treeSuccessor(Node *x) {
  if ( x->right != NIL ) return treeMinimum(x->right);
  Node *y = x->parent;
  while ( y != NIL && x == y->right ) {
    x = y;
    y = y->parent;
  }
  return y;
}

void treeDelete(Node *z) {
  Node *y;
  Node *x;


  if ( z->left == NIL || z->right == NIL ) y = z;
  else y = treeSuccessor(z);



  if ( y->left != NIL ) {
    x = y->left;
  } else {
    x = y->right;
  }

  if ( x != NIL ) {
    x->parent = y->parent;
  }

  if ( y->parent == NIL ) {
    root = x;
  } else {
    if ( y == y->parent->left ) {
      y->parent->left = x;
    } else {
      y->parent->right = x;
    }
  }

  if ( y != z ) {
    z->key = y->key;
  }

  free(y);
}

void insert(int k) {
  Node *y = NIL;
  Node *x = root;
  Node *z;

  z = (Node *)malloc(sizeof(Node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while ( x != NIL ) {
    y = x;
    if ( z ->key < x->key ) {
      x = x->left;
    } else {
      x = x->right;
    }
  }

  z->parent = y;
  if ( y == NIL ) {
    root = z;
  } else {
    if ( z->key < y->key ) {
      y->left = z;
    } else {
      y->right = z;
    }
  }
}

void inorder(Node *u) {
  if ( u == NIL ) return;
  inorder(u->left);
  printf(" %d", u->key);
  inorder(u->right);
}
void preorder(Node *u) {
  if ( u == NIL ) return;
  printf(" %d", u->key);
  preorder(u->left);
  preorder(u->right);
}

int main() {
  int n, i, x;
  string com;

  scanf("%d", &n);

  for( i = 0; i < n; i++ ) {
    cin >> com;
    if ( com[0] == 'f' ) {
      scanf("%d", &x);
      Node *t = find(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com == "insert" ) {
      scanf("%d", &x);
      insert(x);
    } else if ( com == "print" ) {
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com == "delete" ) {
      scanf("%d", &x);
      treeDelete(find(root, x));
    }
  }
  
  return 0;
}



Measured memory_bytes: 21924
#include <iostream>
using namespace std;
int main()
{
  int n;
  int x,y,h,w;
  int a = 0;
 
  while(true){

       cin >> n;
	   if(n==0)
		   break;

	   int sum = 0;

       for(int i=0 ;i<n ;i++){
            cin >> x >> y >> h >> w;

             a = x + y + h ;

			 if(a<=60 && w<=2)
				 sum += 600;
			 else if(a<=80 && w<=5)
				 sum += 800;
			 else if(a<=100 && w<=10)
				 sum += 1000;
             else if(a<=120 && w<=15)
				 sum +=1200;
			 else if(a<=140 && w<=20)
				 sum += 1400;
             else if(a<=160 && w<=25)
				 sum += 1600;


	   }

	   cout << sum << endl;

 }
 return 0;
}

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


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


int main(){
	int a, d, n;
	while(cin >> a >> d >> n, a || d || n){
		vector<int> prime;
		for(int i = 0;(int)prime.size() < n;i++){
			int t = a + d*i;
			if(isPrime(t)) prime.push_back(t);
		}
		cout << prime.back() << endl;
	}

	return 0;
}

Measured memory_bytes: 3052
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
using namespace std;

typedef long long ll;

#define INF 10e10
#define rep(i,n) for(int i=0; i<n; i++)
#define rep_r(i,n,m) for(int i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back

const int limit = 100010;

typedef struct edge {
  int to;
  ll cost;
} edge;

vector<edge> tree[limit];
ll depth[limit];

void dfs (int v, int p, ll d) {
  depth[v] = d;
  for (auto &e : tree[v]) {
    if (e.to == p) continue;
    dfs(e.to, v, d + e.cost);
  }
}

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

  for (int i = 0; i < n - 1; ++i) {
    int a, b, c;
    cin >> a >> b >> c;
    a--, b--;
    tree[a].pb({b,c});
    tree[b].pb({a,c});
  }

  int q,k;
  cin >> q >> k;
  k--;

  dfs(k, -1, 0);
  for (int i = 0; i < q; ++i) {
    int x, y;
    cin >> x >> y;
    x--, y--;
    cout << depth[x] + depth[y] << endl;
  }
}


Measured memory_bytes: 14336
import java.io.*;
import java.util.*;
public class Main {
	public static class FS {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens()) {
				try { st = new StringTokenizer(br.readLine()); }
				catch (Exception e) {}
			} return st.nextToken();
		}
		int nextInt() { return Integer.parseInt(next()); }
		long nextLong() { return Long.parseLong(next()); }
	}

	public static long gcd(long a, long b) { return b == 0 ? a : gcd(b, a % b); }
	public static long lcm(long a, long b) { return a * b / gcd(a, b); }
	public static int abs(int x) { if (x < 0) return -x; return x; }

	public static void main(String[] args) {
		FS in = new FS();

		HashMap<Integer, TreeSet<Integer>> map;
		map = new HashMap<>();

		int n = in.nextInt();
		for (int i = 0; i < n; i++) {
			int a = in.nextInt();
			map.putIfAbsent(a, new TreeSet<>());
			map.get(a).add(i);
			map.get(a).add(n + 1);
		}

		int k = 0, l = -1;
		while (true) {
			if (!map.containsKey(k + 1))
				break;
			if (map.get(k + 1).higher(l) != (n + 1)) {
				l = map.get(k + 1).higher(l);
				k++;
			}
			else
				break;
		}
	
		int ans = n - k;
		if (l == -1)
			ans = l;

		System.out.println(ans);
	}
}


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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  string s;
  cin >> s;
  s[k - 1] -= 'A' - 'a';
  cout << s << '\n';
  return 0;
}

Measured memory_bytes: 256