akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <iomanip>
using namespace std;
 
int main () {
	double a,b,c,d;
	cin >> a >> b >> c >> d;
	cout << setprecision(20) <<sqrt((a-c)*(a-c)+(b-d)*(b-d));
	return 0;
}

Measured memory_bytes: 1280
#include<iostream>
using namespace std;
int main(){
  int n;
  cin>>n;
  string s;
  cin>>s;
  if(n%2==0){
    string a=s.substr(0,n/2);
    string b=s.substr(n/2,n/2);
    if(a==b)
      cout<<"Yes\n";
    else
      cout<<"No\n";
  }
  else
    cout<<"No\n";
  
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	int N, M;
	cin >> N;
	vector<int> Q(N);
	for (int i = 0; i < N; i++) {
		cin >> Q[i];
	}
	cin >> M;
	vector<vector<int>> drink(M, vector<int>(2));
	for (int i = 0; i < M; i++) {
		for (int j = 0; j < 2; j++) {
			cin >> drink.at(i).at(j);
		}
	}
	for (int i = 0; i < M; i++) {
		int total = 0;
		for (int j = 0; j < N; j++){
			if(j == drink.at(i).at(0) - 1){
				total += drink.at(i).at(1);
			} else {
				total += Q[j];
			}
		}
		cout << total << endl;
	}
}

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

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

  if(A >= 13){
    cout << B << endl;
    return 0;
  }
  else if(A >= 6 && A <= 12){
    cout << (B/2) << endl;
    return 0;
  }
  else{
    cout << 0 << endl;
    return 0;
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <stack>
#include <algorithm>
#include <cstdio>
#include <sstream>
#include <string>
#include <vector>
#include <cmath>

#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(int x=from;x<to;x++)

using namespace std;

int getLargestSquare(int size, vector<string>G){
vector<vector<int> > W(size,vector<int>(size));
char BLOCK = '*';
	
	rep(i,size) {
		W[0][i] = (G[0][i] == BLOCK) ? 0 : 1;
		W[i][0] = (G[i][0] == BLOCK) ? 0 : 1;
	}
	
	int maxWidth = 0;
	rep2(i,1,size){
		rep2(j,1, size){
			if ( G[i][j] == BLOCK ){
				W[i][j] = 0;
			}else{
				W[i][j] = min(W[i-1][j-1], min(W[i-1][j], W[i][j-1])) + 1;
				maxWidth = max( maxWidth, W[i][j] );
			}
		}
	}
	
	return maxWidth;
}



int main(void){

int n;
string ws;
	
	while(cin >> n){
		if(n==0 || cin.eof()) break;
		vector<string> g(n);
		rep(i,n) cin >> g[i];
		cout << getLargestSquare(n,g) << endl; 
	}
	return 0;
	
}

Measured memory_bytes: 7152
#include <iostream>
#include <cstdio>
#include <queue>
using namespace std;
typedef long long ll;

ll n, k;
queue<ll> qu;
int main() {
	cin >> n;
	for(ll i=1; i<=9; i++) qu.push(i);
	while(n--) {
		k = qu.front(); qu.pop();
		if(k % 10 > 0) qu.push(k*10 + k%10-1);
		qu.push(k*10 + k%10);
		if(k % 10 < 9) qu.push(k*10 + k%10+1);
	}
	cout << k;
	return 0;
}

Measured memory_bytes: 1792
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"

using namespace std;

typedef long int li;
typedef long double ld;
typedef long long ll;
typedef pair<ll, ll> pt;

#define fi first
#define se second
#define lson (p<<1)+1
#define rson (p<<1)+2
#define dump(x) cout << #x << " = " << x << endl
#define fastIO ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);

ll n, a[200007], k, p, sum;
ll mx;
double z, z1;

int main () {
    fastIO;
    cin >> n >> k;
    for(li i = 0; i < n; i ++) cin >> a[i];

    p = k;
    for(li i = 0; i < k; i ++) sum += a[i];
    mx = sum;

    while(p < n) {
        sum += a[p];
        sum -= a[p - k];
        mx = max(mx, sum);
        p ++;
    }

    z = mx, z1 = k;
    cout << fixed << setprecision(9) << (z + k) / 2.0;
}


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

int main() {
    int n;
    cin >> n;
    int a[10][10];
    memset(a, 0, sizeof(a));

    for (int i = 1; i <= n; ++i) {
        a[to_string(i)[0] - '0'][i % 10]++;
    }

    int ans = 0;
    for (int i = 0; i < 10; ++i) {
        for (int j = 0; j < 10; ++j) {
            ans += a[i][j] * a[j][i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
def nCr(n, r, mod):
    x, y = 1, 1
    for r_ in range(1, r+1):
        x = x*(n+1-r_)%mod
        y = y*r_%mod
    return x*pow(y, mod-2, mod)%mod
 
x, y = map(int, input().split())
mod = 10**9+7
if (x+y)%3 or 2*x<y or 2*y<x:
    print(0)
else:
    print(nCr((x+y)//3,(2*x-y)//3, mod))

Measured memory_bytes: 9068
import sys
input = sys.stdin.readline

n, k = [int(x) for x in input().split()]
a = [int(x) for x in input().split()]

s = sum(a[:k])
t = 0
for i in range(k, n):
    if a[i] > 0:
        t += a[i]
ans = max(t, s + t)
# print(s, t)
for i in range(n - k):
    s -= a[i]
    s += a[k + i]
    if a[k + i] > 0:
        t -= a[k + i]
    if a[i] > 0:
        t += a[i]
    ans = max(ans, s + t, t)
    # print(s, t)
print(ans)
    
    



Measured memory_bytes: 14508
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <algorithm>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
typedef long long ll;

int solve(int a, int b) {
  for(int x = 0; x <= 10000; ++x) {
    int ax = floor(x * 0.08);
    int bx = floor(x * 0.10);
    if(a == ax && b == bx) {
      return x;
    }
  }
  return -1;
}

int main(void) {
  int a, b;
  cin >> a >> b;
  int res = solve(a, b);
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 3212
#include<cstdio>
#include<algorithm>
using namespace std;
const int Maxn=100;
int N,A[Maxn+5];
int ans=1e9;
int main() {
	#ifdef LOACL
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	int a=1e9,b=-1e9;
	scanf("%d",&N);
	for(int i=1;i<=N;i++) {
		scanf("%d",&A[i]);
		a=min(a,A[i]);
		b=max(b,A[i]);
	}
	for(int t=a;t<=b;t++) {
		int tmp=0;
		for(int i=1;i<=N;i++)
			tmp+=(A[i]-t)*(A[i]-t);
		ans=min(ans,tmp);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main(void){
    int N=0;
    int W[101]={0};
    int answer=10000;
    int sa=0;
    int temp=0;
    int temp2=0;
    scanf("%d",&N);
    for(int i=0;i<N;i++){
        scanf("%d",&W[i]);
    }
    for(int i=0;i<N-1;i++){
        temp=0;
        temp2=0;
        for(int j=0;j<=i;j++){
            temp+=W[j];
        }
        for(int j=i+1;j<N;j++){
            temp2+=W[j];
        }
        sa=temp-temp2;
        if(sa<0) sa*=-1;
        if(answer>sa) answer=sa;
    }
    printf("%d\n",answer);
    return 0;
}

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

std::string compress(std::string const & name) {
  std::string const vowels("aiueo");
  std::string val;
  val.push_back(name[0]);
  for (int i = 1, len = name.length(); i < len; ++i) {
    if (vowels.find(name[i-1]) != std::string::npos) {
      val.push_back(name[i]);
    }
  }
  return val;
}

struct Impossible {};

int mindiff(std::string const & x, std::string const & y) {
  int const limit = std::min(x.length(), y.length());
  for (int i = 0; i < limit; ++i) {
    if (x[i] != y[i]) {
      return i + 1;
    }
  }
  return (x.length() == y.length() ? (throw Impossible()) : limit + 1);
}

int main() {
  int N;
  while (std::cin >> N && N) {
    std::vector<std::string> airports;
    for (int i = 0; i < N; ++i) {
      std::string S;
      std::cin >> S;
      airports.push_back(compress(S));
    }
    std::sort(airports.begin(), airports.end());
    try {
      std::vector<int> diffs;
      for (int i = 1; i < N; ++i) {
        diffs.push_back(mindiff(airports[i - 1], airports[i]));
      }
      std::cout << std::accumulate(
          diffs.begin(),
          diffs.end(),
          1,
          [](int x, int y) {
            return std::max(x, y);
          })
        << std::endl;
    } catch (Impossible const & e) {
      std::cout << "-1" << std::endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3308
#include <bits/stdc++.h>
using namespace std;
#define int long long int
mt19937 rng(chrono::duration_cast<chrono::nanoseconds>(chrono::high_resolution_clock::now().time_since_epoch()).count());
#define mp make_pair
#define pb push_back
#define F first
#define S second
const int N = 1000005;
#define M 1000000007
#define double long double
#define BINF 10000000000001
#define MAXN 500005
#define init(arr,val) memset(arr,val,sizeof(arr))
#define deb(x) cout << #x << " " << x << "\n";
const int LG = 22;

string s, r;
int n, m, dp[3001][3001], dp1[3305][3005], mark[3005], final[3005], cur;

int foo1(int i, int j){
    if(i == n or j == m)
        return 0;
    if(dp1[i][j] != -1)
        return dp1[i][j];
    int res = 0;
    if(s[i] == r[j])
        res = max(res, 1 + foo1(i + 1, j + 1));
    res = max(res, max(foo1(i + 1, j), foo1(i, j + 1)));
    return dp1[i][j] = res;
}

int foo(int i, int j){

    if(i == n or j == m){
        int c = 0;
        for(int l = 0; l < n; l++){
            if(mark[l]) c++;
        }
        if(c > cur){
            cur = c;
            for(int l = 0; l < n; l++)
                final[l] = mark[l];
        }
        return 0;
    }

    if(dp[i][j] != -1)
        return dp[i][j];

    int res = 0;

    if(s[i] == r[j]){
        mark[i] = 1;
        res = max(res, 1 + foo(i + 1, j + 1));
        mark[i] = 0;
    }
    int l = 0, r = 0;
    l = foo1(i, j + 1);
    r = foo1(i + 1, j);
    if(l >= r)
        res = max(res, foo(i, j + 1));
    else res = max(res, foo(i + 1, j));
    
    return dp[i][j] = res;
}


#undef int 
int main() {
#define int long long int
ios_base::sync_with_stdio(false); 
cin.tie(0); 
cout.tie(0);


    init(dp, -1);
    init(dp1, -1);
    cin >> s >> r;
    n = s.length(), m = r.length();

    int len = foo(0, 0);
    string ans;
    for(int i = 0; i < n; i++)
        if(final[i]) ans += s[i];

    cout << ans << endl;


return 0;
}



Measured memory_bytes: 148608
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <iomanip>
#include <stack>
#include <queue>
#include <numeric>
#include <map>
#include <unordered_map>
#include <set>
#include <fstream>
#include <chrono>
#include <random>
#include <bitset>
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) ((int)(x).size())
#define pb push_back
using ll = long long;
using namespace std;
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 (b<a) { a=b; return 1; } return 0; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}

int N,M;

vector<int> par, rnk;
void init(int N){ rep(i,N) {par[i] = i; rnk[i] = 0;} }
int root(int x) { return par[x] == x? x : par[x] = root(par[x]); }
bool same(int x, int y) { return root(x) == root(y); }
void unite(int x, int y){
  x = root(x); y = root(y);
  if(x==y) return;
  if(rnk[x] < rnk[y]) par[x] = y;
  else{
    par[y] = x;
    if(rnk[x] == rnk[y]) rnk[x]++;
  }
}

int main(){
  cin >> N >> M;
  par.resize(N);
  rnk.resize(N);
  init(N);
  rep(i,M){
    int a, b; cin >> a >> b;
    a--;b--;
    if(!same(a,b)) unite(a,b);
  }
  vector<int> A(N,0);
  int ans = 0;
  rep(i,N){

    A[root(i)]++;
  }
  rep(i,N){
    chmax(ans,A[i]);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 5580
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
ll MOD1=134832894;
ll MOD2=183489237;
ll x1=52452452;
ll x2=34567343;
vector<ll>hash1,hash2,X1,X2;
int n;
set<pair<ll,ll> >se;
int f(int i){
	se.clear();
	rep(j,n-i){
		ll a1=(hash1[i+j+1]-hash1[j]+MOD1)%MOD1*X1[n-(i+j+1)]%MOD1;
		ll a2=(hash2[i+j+1]-hash2[j]+MOD2)%MOD2*X2[n-(i+j+1)]%MOD2;
		se.insert(pair<ll,ll>(a1,a2));
	}
	return se.size();
}
int main(){
	string s;
	cin>>s;
	n=s.size();
	X1=X2=vector<ll>(n+1);
	X1[0]=X2[0]=1;
	rep(i,n){
		X1[i+1]=(X1[i]*x1)%MOD1;
		X2[i+1]=(X2[i]*x2)%MOD2;
	}
	hash1=hash2=vector<ll>(n+1);
	rep(i,n){
		hash1[i+1]=(s[i]-'a')*X1[i+1];
		hash2[i+1]=(s[i]-'a')*X2[i+1];
	}
	rep(i,n){
		hash1[i+1]=(hash1[i+1]+hash1[i])%MOD1;
		hash2[i+1]=(hash2[i+1]+hash2[i])%MOD2;
	}
//	rep(i,n){
	int l=0,r=n;
	while(r-l>4){
		int h1=l+(r-l)/3,h2=l+(r-l)/3*2;
//		cout<<l<<" "<<h1<<" "<<h2<<" "<<r<<endl;
		int H1=f(h1),H2=f(h2);
//		cout<<H1<<" "<<H2<<endl;
		if(H1>H2)r=h2;
		else l=h1;
	}
	int out=0;
	loop(i,l,r)out=max(out,f(i));
	cout<<out<<endl;
}






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

if a.count(1) == 0:
    print(-1)
else:
    ans = 0
    check = 1
    for i in range(n):
        if a[i] == check:
            check += 1
        else:
            ans += 1
    print(ans)

Measured memory_bytes: 77516
#include<iostream>

using namespace std;

int n,l[1000],r[1000],co;

int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>l[i]>>r[i];
		co+=r[i]-l[i]+1;
	}
	
	cout<<co<<endl;
	return 0;
}

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

int main(){
    int n;
    vector<int> array;

    cin >> n;
    for(int i=0; i<n; i++){
        int a;
        cin >> a;
        array.push_back(a);
    }

    for(int i=array.size()-1; i>=1; i--){
        cout << array[i] << " ";
    }cout << array[0] << endl;

    return 0;
}
    

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

int main(){
  int A,B,C;
  cin >> A >> B >> C;
  
  if ( A < B )
    swap(A,B);
  if ( B < C )
    swap(B,C);
  if ( A < B )
    swap(A,B);
    
  cout << A*10 + B + C << endl;
}  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A, B;
  int t = 0;
  cin >> A >> B;
  string s, sr;
  for (int i = A; i <= B; i++) {
    s = to_string(i);
    sr = s;
    reverse(sr.begin(), sr.end());
    if (s == sr){
      t++;
    }
  }
  cout << t << endl;
}

Measured memory_bytes: 3688
#include <cstdio>
#include <cstring>
using namespace std;

int dp[50][3001];
int main(){
	int n, m, s;
	while(scanf("%d %d %d", &n, &m, &s), n){
		memset(dp, 0, sizeof(dp));
		dp[0][0] = 1;
		for(int i=1; i<=m; ++i){
			for(int j=n*n; j>0; --j){
				for(int l=i; l<=s; ++l){
					dp[j][l] = (dp[j][l] + dp[j-1][l-i]) % 100000;
				}
			}
		}
		printf("%d\n", dp[n*n][s]);
/*		for(int i=0; i<n*n; i++){
			for(int j=0; j<s; j++){
				printf("%d\t", dp[i+1][j+1]);
			}
			printf("\n");
		}
*/	}
}

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

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

    vector<vector<bool>> dp(7, vector<bool>(100505));
    dp[0][0] = true;
    for (int i = 0; i < 6; i++) {
        int c = 100 + i;
        for (int j = 0; j <= X; j++) {
            dp[i + 1][j] = dp[i + 1][j] || dp[i][j];
            if (dp[i + 1][j]) {
                dp[i + 1][j + c] = dp[i + 1][j];
            }
        }
    }

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

Measured memory_bytes: 384
#include <stdio.h>
int main (void){
  int N,M;
  scanf("%d%d",&N,&M);
  int ansn=0;
  for(int i=0;i<N;i++){
    ansn+=i;
  }
  int ansm=0;
  for(int j=0;j<M;j++){
    ansm+=j;
  }
  printf("%d\n",ansn+ansm);
  
  return 0;
}

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

sum = a+b

if n < a+b:

    if n < a :
        print(n)
    else:
        print(a)

else: 
    if n%sum > a: 
        print (((n // sum)*a) + a)

    else:
        res = ((n // sum)*a) + (n % sum)
        print(res)


Measured memory_bytes: 3060
#include <iostream>

using namespace std;

int main(void)
{
    char S;
    cin >> S;

    switch (S)
    {
        case 'S':
            cout << "Cloudy" << endl;
            break;
        case 'C':
            cout << "Rainy" << endl;
            break;
        case 'R':
            cout << "Sunny" << endl;
            break;
    }
    return 0;
}

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


int main(){
  ll N;
  cin >> N;
  vector<ll> vec;
  REP(i, N) {
    ll a;
    cin >> a;
    vec.push_back(a);
  }
  ll cnt = 0;

  for (ll i=0; i<60; i++){
    ll idsum = 0;
    ll zc = 0, oc = 0;
    for (ll j=0;j<N;j++){
      if (vec[j]%2 == 0) zc++;
      else oc++;
      vec[j] = vec[j]>>1;
    }
    idsum = ((oc*zc%MOD)*((1LL<<i)%MOD))%MOD;
    cnt = (cnt+idsum)%MOD;
  }
  cout << cnt <<endl;
  return 0;
}


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

#define lol long long
#define gcd(x,y) __gcd(x,y)
#define mt make_tuple
#define mp make_pair
#define fi first
#define se second
#define fixed fixed<<setprecision(14)
using namespace std;
using pii=pair<int,int>;
template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }
template <class A> inline lol abs(A &a) { return (a < 0 ? -a : a); }
const lol inf=(1LL<<60);
const lol MOD=(1e9)+7;
const lol mod=998244353;
const int dx[]={1,0,-1,0,1,1,-1,-1};
const int dy[]={0,1,0,-1,1,-1,1,-1};
lol n,m,k,r;
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cin >>n;
  vector<long double> a(n);
  for(int i=0;i<n;i++) cin >>a[i];
  long double p=1e18;
  sort(a.begin(),a.end());
  long double sum=1;
  for(int i=0;i<n;i++){
    sum*=a[i];
    if(sum>p){
      cout <<"-1\n";
      return 0;
    }
  }
  cout<<(long long)sum<<'\n';
  return (0);
}

Measured memory_bytes: 4784
package main

import (
	"bufio"
	"fmt"
	"os"
	"unicode"
)

func main() {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanLines)
	sc.Scan()
	s := []rune(sc.Text())
	for _, r := range s {
		if unicode.IsUpper(r) {
			fmt.Print(string(unicode.ToLower(r)))
		} else if unicode.IsLower(r) {
			fmt.Print(string(unicode.ToUpper(r)))
		} else {
			fmt.Print(string(r))
		}
	}
  fmt.Println("")
}



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

#define fast_io ios_base::sync_with_stdio(0); cin.tie(NULL);
#define all(a) (a).begin(),(a).end()
#define rep(i, x, y) for(decltype(y) i = (x) - ((x) > (y)); i != (y) - ((x) > (y)); i += 1 - 2 * ((x) > (y)))


//time__("program time")

int main(){

	fast_io;
	//solve();

	int n;
	cin >> n;

	vector<int>a(n,0),b(n,0);

	rep(i,0,n){
		cin >> a[i];
		b[i] = a[i]-i-1;
	}
	sort(all(b));

	function <uint64_t(int c)>sadness = [&](int c)->uint64_t{
		uint64_t sum = 0;
		rep(i,0,n){
			sum += abs(a[i]-(c+i+1));
		}

		return sum;
	};

	uint64_t ans = 0;
	if(n%2 != 0){
		ans = sadness(b[n/2]);
	}else{
		ans = sadness((b[n/2-1]+b[n/2])/2);
	}
	cout << ans << "\n";

return 0;
}


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

using ll = long long;
using vi = vector<ll>;
using vvi = vector<vi>;
#define rep(i, s, n) for(int i = (int)(s); i < (int)(n); i++)

ll INF = 1ll << 60;

void chmin(ll &a, ll b){
  if(a > b)
    a = b;
}
void chmax(ll &a, ll b){
  if(a < b)
    a = b;
}

int main(){
  int x, y;
  cin >> x >> y;
  bool check = false;
  rep(a, 0, 101){
    rep(b, 0, 101){
      if(a+b == x && a*2+b*4 == y)
        check = true;
    }
  }
  
  if(check)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
  
  return 0;
  
}

Measured memory_bytes: 3636
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
struct node{
	struct node *prev;
	struct node *next;
	int key;
};
int n;
struct node *nil; //先頭

void insert(key);
void deletekey(key);
void deleteLast();
void deleteFirst();
struct node* listSearch(int);
void printList();
int main(void)
{
	int key;
	int i;
	char com[20];
	scanf("%d",&n);
	nil =(struct node *)malloc(sizeof(struct node));
	nil->next = nil;
	nil->prev = nil;
	for(i=0;i<n;i++){
		scanf("%s",com);

		if(com[0] == 'i'){
			scanf("%d",&key);
			insert(key);
		}
		if(com[0] == 'd'){
			if(com[6]=='F'){
				deleteFirst();
			}
			else if(com[6]=='L'){
				deleteLast();
			}
			else{
				scanf("%d",&key);
				deletekey(key);
			}
		}
		
	}
	printList();
	return 0;
}

void insert(int key){
	struct node *x;
	x = (struct node *)malloc(sizeof(struct node));
	x->key = key;
	x->next = nil->next;
	nil->next->prev = x;
	nil->next = x;
	x->prev = nil;
}

void printList(){
	int a=0;
	struct node *here;
	here = nil->next;
	while(1){
		if(here==nil) break;
		if(a++>0){
			printf(" ");
		}
		printf("%d",here->key);
		here = here->next;
	}
	printf("\n");
}

void deletekey(int key){
	struct node *bye;
	if(key == -1){
		bye = nil->next;
	}
	else if(key == -2){
		bye = nil->prev;
	}
	else{
		bye = listSearch(key);
	}
	if(bye == nil) return;
	bye->prev->next = bye->next;
	bye->next->prev = bye->prev;
	free(bye);
}

struct node* listSearch(int key){
	struct node *here;
	here = nil->next;
	while(key!=here->key && here!=nil){
		here = here->next;
	}
	return here;
}

void deleteFirst(){
	deletekey(-1);
}
void deleteLast(){
	deletekey(-2);
}


Measured memory_bytes: 33116
#include <stdio.h>
#include <string.h>

int map[12][6];
char input_map[12][8];

int group_num;
int group[12*6][2];

void tansaku(int x,int y,char color) {
	if(x<0 || x>=6 || y<0 || y>=12)return;
	if(map[y][x]!=0 || input_map[y][x]!=color)return;
	group[group_num][0]=y;
	group[group_num][1]=x;
	group_num++;
	map[y][x]=1;
	tansaku(x-1,y,color);
	tansaku(x+1,y,color);
	tansaku(x,y-1,color);
	tansaku(x,y+1,color);
}

int main(void) {
	int data_num,cur_data;
	int i,j,k;
	int rensa,deleted;
	scanf("%d",&data_num);
	for(cur_data=0;cur_data<data_num;cur_data++) {
		for(i=0;i<12;i++)scanf("%s",input_map[i]);
		for(rensa=0;;rensa++) {
			memset(map,0,sizeof(map));
			for(i=0;i<12;i++) {
				for(j=0;j<6;j++) {
					if(input_map[i][j]=='.' || input_map[i][j]=='O') {
						map[i][j]=1;
					} else {
						group_num=0;
						tansaku(j,i,input_map[i][j]);
						for(k=0;k<group_num;k++) {
							map[group[k][0]][group[k][1]]=group_num;
						}
					}
				}
			}
			deleted=0;
			for(i=0;i<12;i++) {
				for(j=0;j<6;j++) {
					if(map[i][j]>=4) {
						input_map[i][j]='.';
						if(i>0 && input_map[i-1][j]=='O')input_map[i-1][j]='.';
						if(i<11 && input_map[i+1][j]=='O')input_map[i+1][j]='.';
						if(j>0 && input_map[i][j-1]=='O')input_map[i][j-1]='.';
						if(j<5 && input_map[i][j+1]=='O')input_map[i][j+1]='.';
						deleted=1;
					}
				}
			}
			if(!deleted)break;
			for(i=11;i>0;i--) {
				for(j=0;j<6;j++) {
					if(input_map[i][j]=='.') {
						for(k=i;k>=0;k--) {
							if(input_map[k][j]!='.') {
								input_map[i][j]=input_map[k][j];
								input_map[k][j]='.';
								break;
							}
						}
					}
				}
			}
		}
		printf("%d\n",rensa);
	}
	return 0;
}

Measured memory_bytes: 0
n,m,q,r=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
a=max(x)+1
b=min(y)
if a>b:
    print("War")
    exit()
for i in range(a,b+1):
    if q<i<r:
        print("No War")
        exit()
print("War")

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

/* typedef */
/* long系 */
typedef long long ll;   // long long
typedef long double ld; // long double
/* vector系 */
typedef vector<int> vi;                    // intのvector
typedef vector<double> vd;                 // doubleのvector
typedef vector<ll> vll;                    // llのvector
typedef vector<ld> vld;                    // ldのvector
typedef vector<vector<int>> vvi;           // intの2次元vector
typedef vector<vector<double>> vvd;        // doubleの2次元vector
typedef vector<vector<ll>> vvll;           // llの2次元vector
typedef vector<vector<ld>> vvld;           // ldの2次元vector
typedef vector<pair<int, int>> vi_i;       // i_iのvector
typedef vector<pair<double, double>> vd_d; // d_dのvector
typedef vector<pair<ll, ll>> vl_l;         // l_lのvector
typedef vector<pair<ld, ld>> vld_ld;       // ld_ldのvector
typedef vector<string> vs;                 // stringのvector
/* pair系 */
typedef pair<int, int> i_i;       // int同士のpair
typedef pair<double, double> d_d; // double同士のpair
typedef pair<ll, ll> l_l;         // ll同士のpair
typedef pair<ld, ld> ld_ld;       // ld同士のpair

/* define */
#define all(v) v.begin(), v.end() // コンテナ全体
#define PI (acos(-1))             // 円周率pi

/* stringstream */
stringstream ss;
stringstream init_ss; // save default formatting

/* upper, lower */
struct ToUpper
{
    char operator()(char c)
    {
        return toupper(c);
    }
};
struct ToLower
{
    char operator()(char c)
    {
        return tolower(c);
    }
};

/* main */
void Main(void)
{
    ll n;
    cin >> n;
    vll a;
    a.resize(n);
    for (ll rv = 0; rv < n; rv++)
    {
        cin >> a[rv];
    }
    for (ll i = 0; i < n; i++)
    {
        if (a[i] == 0)
        {
            cout << 0 << endl;
            return;
        }
    }
    ll mul = 1;
    for (ll i = 0; i < n; i++)
    {
        if (mul * a[i] != (ll)pow(10.0, 18.0) && (ll)(log10((ld)mul) + log10((ld)a[i])) >= 18)
        {
            cout << -1 << endl;
            return;
        }
        else
            mul *= a[i];
    }
    cout << mul << endl;
}

int main(void)
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();

    return 0;
}


Measured memory_bytes: 3968
using System;

class Program {
  static void Main(string[] args) {
    char c;
    string str = "";

    while((c = Convert.ToChar(Console.Read())) != '\n') {
      if(c == 'B'){
        if(str.Length != 0){
          str = str.Remove(str.Length - 1);
        }
      }
      else {
        str += Convert.ToString(c);
      }
    }

    Console.WriteLine(str);
  }
}


Measured memory_bytes: 11092
import sys
import math
from collections import defaultdict
from bisect import bisect_left, bisect_right

sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

mod = 10**9 + 7

def I(): return int(input())
def LI(): return list(map(int, input().split()))
def LIR(row,col):
    if row <= 0:
        return [[] for _ in range(col)]
    elif col == 1:
        return [I() for _ in range(row)]
    else:
        read_all = [LI() for _ in range(row)]
        return map(list, zip(*read_all))

#################

N,D = LI()
X,Y = LIR(N,2)

ans = 0
for i in range(N):
    if X[i]**2 + Y[i]**2 <= D**2:
        ans += 1

print(ans)

Measured memory_bytes: 119076
n, k = map(int, input().split())
hs = list(map(int, input().split()))
 
dp = [0]*n
 
for i in range(1, n):
  first = max(0, i-k)
  dp[i] = min([d + abs(hs[i]-h) for d, h in zip(dp[first:i], hs[first:i])])
print(dp[-1])

Measured memory_bytes: 13980
#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() {
  string s,t;
  cin >> s>>t;
  for(int i=s.size();i>=0;i--){
    bool left=true;
    rep(j,t.size()){
      if(s[i+j]!=t[j]&&s[i+j] !='?'){
        left=false;
      }
    }
    if(left){
      string ans="";
      int count=0;
      for(int j=i;j<t.size()+i;j++){
        s[j]=t[count];
        count++;
      }
      rep(j,s.size()){
        if(s[j]=='?'){
          ans+='a';
        }else{
          ans+=s[j];
        }
      }
      cout << ans <<endl;
      return 0;
    }
  }
  cout << "UNRESTORABLE"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;

#define pll pair<ll,ll>
#define ff first
#define snd second
#define pb push_back
#define vll vector<ll>
#define vpll vector<pll>
#define endl "\n"
#define MOD 1000000007
using namespace std;

ll const N = 1e5+1;
map<ll,ll>m;

void prime(ll n)
{
        while(n>1 && n%2==0)
        {
                n/=2;
                m[2]++;
        }
        
        for(ll i=3;i*i<=n;i+=2)
        {
                while(n%i==0)
                {
                        n/=i;
                        m[i]++;
                }
        }
        
        if(n>2)
        m[n]++;
}

void solve()
{
   ll n;
   cin>>n;
   if(n==1)
   {
      cout<<0;
      return;
   }
   prime(n);
   ll ans = 0;
   for(auto itr = m.begin();itr!=m.end();itr++)
   {
        ll k = (*itr).ff;
        ll c_val = 1;
        while(m[k]>0)
        {
                if(m[k]-c_val<c_val+1)
                {
                     ans++;
                     break;
                }
                else
                {
                    ans++;
                }
                m[k] -= c_val;
                c_val++;
        }
   }
   cout<<ans;
}
 
int main() {
            ios_base::sync_with_stdio(false);
            cin.tie(NULL);
	    int t=1;
	    //cin>>t;
	    while(t--)
	    {
	            solve();
	    }
	    return 0;
}

Measured memory_bytes: 3656
<?php
$a = trim(fgets(STDIN));
$input = explode(' ', trim(fgets(STDIN)));
$i = 0;

sort($input);


$k_list =$input[($a / 2) - 1];
$k_list2 = $input[$a / 2];

//echo $k_list;
//echo $k_list2;


$i = $k_list2 - $k_list;


echo $i;
?>

Measured memory_bytes: 12792
#include <bits/stdc++.h>
using namespace std;
 
typedef pair<int,int> pii;
typedef long long ll;

void fastStream(){cin.tie(0);std::ios_base::sync_with_stdio(0);}

/*
  各スライムの移動距離の期待値を求めれば良い？
  あるスライムが移動する時、移動先が残っている確率を求めたい
  

 */

// O(logn)で繰り返し二乗法によりnum^p%modを計算
ll mod_pow(ll num,ll p,ll mod){
  ll mul=num;
  ll res=1;
  while(p){
    if(p%2)res=(res*mul)%mod;
    p/=2;
    mul=(mul*mul)%mod;
  }
  return res;
}
// fermerの小定理を用いてmodの割算を計算
ll div_mod(ll num,ll mod){
  return mod_pow(num,mod-2,mod);
}


const int mod = 1000000000 + 7;
int N;
ll X[100010];

int main(){

    cin >> N;
    for(int i = 0; i < N; i++) cin >> X[i];
    ll tmp = 0;
    ll sum = 0;

    for(int i = 0; i < N - 1; i++){
        ll d = (X[i + 1] - X[i]) % mod;
        (tmp += div_mod((i + 1), mod)) %= mod;
        (sum += d * tmp) %= mod;
    }
    for(ll i = 0; i < N - 1; i++){
        (sum *= (i + 1)) %= mod;
    }

    cout << sum << endl;


    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
typedef tuple<ll,ll,ll> Tu;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int n;
ll a[200100];
ll sum1=0,sum2=0,sum3=0,sum4=0;
ll t,s;
ll r_sum=0,l_sum=0;
ll sum=0;
int main(){
	cin>>n;
	REP(i,n){
		cin>>a[i];
		sum+=a[i];
	}
	t=1,s=3;
	sum1=a[0];
	r_sum=a[0];
	l_sum=sum-r_sum;
	sum3=a[1]+a[2];
	sum4=l_sum-sum3;
	ll ans=INFl;
	for(int i=2;i<=n-2;i++){
		r_sum+=a[i-1];
		l_sum-=a[i-1];
		sum2+=a[i-1];
		sum3-=a[i-1];
		while(t<i){
			if(abs(sum1-sum2)>=abs((sum1+a[t])-(sum2-a[t]))){	
				sum1+=a[t];
				sum2-=a[t];
				t++;
			}else{
				break;
			}
		}
		while(s<n){
			if(abs(sum3-sum4)>=abs((sum3+a[s])-(sum4-a[s]))){
				sum3+=a[s];
				sum4-=a[s];
				s++;
			}else{
				break;
			}
		}
		ll tmax=max(max(sum1,sum2),max(sum3,sum4));
		ll tmin=min(min(sum1,sum2),min(sum3,sum4));
		ans=min(ans,tmax-tmin);
		/*if(i==4){
			cout<<t<<" "<<s<<endl;
			cout<<sum1<<" "<<sum2<<" "<<sum3<<" "<<sum4<<endl;
		}*/
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
 
using namespace std;
 
 
#define mod(cans) cans%10**9+7
#define debug(x) cout << "Debug" << x << "\n"
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define cin_pl(n,x) rep(i,n){cin>>x[i];}
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define prians(Answer) cout<<Answer<<"\n"
#define TF(X) X==1?cout<<"Yes\n":cout<<"No\n"
#define elcon else{continue;}
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<vector<int>> matrix;
typedef pair<int,int> pii;
typedef vector<pii> vpi;
typedef greater<int> gi;
typedef vector<unsigned> vu;


ll gcd(ll x, ll y) { return (y == 0) ? x : gcd(y, x % y); }
bool is_prime(const unsigned n){
    switch(n){
        case 0:
        case 1: return false;
        case 2: return true;
    }
 
 
    for(unsigned i=2;i<n;++i){
        if(n%i == 0) return false;
    }
 
    return true;
}

int main()
{
   int x,ans=2;
   cin>>x;
   while(x>=0&&ans!=1)
   {
       
    switch (x%100)
    {
    case 0:ans=1;break;
    case 1:x-=101;break;
    case 2:x-=102;break;
    case 3:x-=103;break;
    case 4:x-=104;break;
    default:x-=105; break;
        
    }
       
   }   
   if(ans!=1)
   ans=0;
   prians(ans); 
}

Measured memory_bytes: 256
#include <stdio.h>

typedef struct List {
	struct List *next;
	int v;
} list;

int main()
{
	int i, N, K, a[100001];
	scanf("%d %d", &N, &K);
	for (i = 1; i <= N; i++) scanf("%d", &(a[i]));
	
	int ans = 0;
	if (a[1] != 1) {
		a[1] = 1;
		ans++;
	}
	
	list *adj[100001], e[100001];
	for (i = 2; i <= N; i++) {
		e[i].v = i;
		e[i].next = adj[a[i]];
		adj[a[i]] = &(e[i]);
	}
	
	int height[100001] = {}, q[100001], head, tail;
	list *p;
	q[0] = 1;
	for (head = 0, tail = 1; head < tail; head++) {
		for (p = adj[q[head]]; p != NULL; p = p->next) q[tail++] = p->v;
	}
	for (head--; head > 0; head--) {
		i = q[head];
		if (height[i] == K - 1 && a[i] != 1) {
			height[i] = -1;
			a[i] = 1;
			ans++;
		}
		if (height[a[i]] < height[i] + 1) height[a[i]] = height[i] + 1;
	}	
	printf("%d\n", ans);
	fflush(stdout);
	return 0;
}

Measured memory_bytes: 5228
use std::cmp;
use std::cmp::max;
use std::collections::BinaryHeap;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());
    let n: usize = sc.read();
    let m: usize = sc.read();
    let q: usize = sc.read();

    let mut points = vec![vec![vec![0; m + 1]; n]; n];
    for _ in 0..q {
        let a = sc.read::<usize>() - 1;
        let b = sc.read::<usize>() - 1;
        let c = sc.read::<usize>();
        let d: u64 = sc.read();
        points[a][b][c] = d;
    }

    let mut heap = BinaryHeap::new();
    heap.push((0, Vec::new()));
    let mut max = 0;
    while let Some((score, a)) = heap.pop() {
        if a.len() == n {
            max = cmp::max(max, score);
            continue;
        }
        let last = a.last().cloned().unwrap_or(1);
        for next in last..=m {
            let mut a = a.clone();
            a.push(next);
            let to = a.len() - 1;
            let mut score = score;
            for from in 0..a.len() {
                score += points[from][to][a[to] - a[from]];
            }
            heap.push((score, a));
        }
    }

    println!("{}", max);
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        Self(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

using namespace std;
#define DBG(x)                         \
    (void)(cout << "L" << __LINE__     \
                << ": " << #x << " = " \
                << (x) << '\n')

typedef long long ll;
using pii = pair<int, int>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const int INF = 0x3f3f3f3f;
const int maxn = 1100000;
int main()
{
    //检查有没有特判0,有没有越界限.
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setiosflags(ios::fixed) << setprecision(12);
    int n, m;
    cin >> n >> m;
    vector<int> vis(n + 1);
    vector<int> v(n + 1);
    int ac = 0, pen = 0;
    for (int i = 1; i <= m; i++)
    {
        int x;
        cin >> x;
        string s;
        cin >> s;
        if (!vis[x] && s == "AC")
        {
            ac++;
            vis[x] = 1;
            pen += v[x];
        }
        if (!vis[x] && s == "WA")
        {
            v[x]++;
        }
    }
    cout << ac << " " << pen << "\n";
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#define fore(i,x,y) for(long long i=x;i<y;i++)
typedef long long ll;
using namespace std;
int main()
{
	string s,ans="Yes";
	vector<int>vec(30,0);
	cin>>s;
	fore(i,0,s.size()){
		if(s[i]=='a')vec[0]++;
		if(s[i]=='b')vec[1]++;
		if(s[i]=='c')vec[2]++;
		if(s[i]=='d')vec[3]++;
		if(s[i]=='e')vec[4]++;
		if(s[i]=='f')vec[5]++;
		if(s[i]=='g')vec[6]++;
		if(s[i]=='h')vec[7]++;
		if(s[i]=='i')vec[8]++;
		if(s[i]=='j')vec[9]++;
		if(s[i]=='k')vec[10]++;
		if(s[i]=='l')vec[11]++;
		if(s[i]=='m')vec[12]++;
		if(s[i]=='n')vec[13]++;
		if(s[i]=='o')vec[14]++;
		if(s[i]=='p')vec[15]++;
		if(s[i]=='q')vec[16]++;
		if(s[i]=='r')vec[17]++;
		if(s[i]=='s')vec[18]++;
		if(s[i]=='t')vec[19]++;
		if(s[i]=='u')vec[20]++;
		if(s[i]=='v')vec[21]++;
		if(s[i]=='w')vec[22]++;
		if(s[i]=='x')vec[23]++;
		if(s[i]=='y')vec[24]++;
		if(s[i]=='z')vec[25]++;
	}
	fore(i,0,vec.size()){
		if(vec[i]%2==1)ans="No";
	}
	cout << ans << endl;
}

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

typedef long long ll;
const int INF = 1e9;
const ll LINF = 1e18;
const int mod = 1e9+7;

#define pi pair<int,int>
#define pl pair<lld,lld>

#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define SANKOU(n,a,b) cout << ((n) ? (#a) : (#b) ) << endl

#define mem0(x) memset(x,0,sizeof(x))
#define fillnum(x,n) fill(begin(x),end(x),n)
#define asort(x) sort(x.begin(),x.end())
#define dsort(x,t) sort(x.begin(),x.end(),greater<t>())
#define vuniq(x) x.erase(unique(x.begin(), x.end()), x.end())

#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)

int main() {
    string S;
    cin >> S;
    if(S == "Sunny"){
        cout << "Cloudy" << endl;
    } else if(S == "Cloudy"){
        cout << "Rainy" << endl;
    } else {
        cout << "Sunny" << endl;
    }
}

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

using namespace std;

int main(){
    cin.sync_with_stdio(0);
    cin.tie(0);
    string s;
    cin >> s;
    int ream = 0;
    for(char c: s){
        ream = (ream + (c - '0')) % 9; 
    }
    cout << (ream == 0?"Yes" : "No") << endl;
}

Measured memory_bytes: 3792
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); i++)
#define repd(i,a,b) for (double i = (a); i < (b); i++)
typedef long long ll;

int main (void)
{
    boost::multiprecision::cpp_int a, b, ans;
    cin >> a >> b;
    ans = a - b;
    cout << ans << endl;
}


Measured memory_bytes: 3448
import bisect

N = int(input())
a = [int(i) for i in input().split()]

a.sort()
pullout = 0
#print(a)

for i in list(set(a)):
    numi = bisect.bisect_right(a,i) - bisect.bisect_left(a,i)
    #print(i,numi)
    if numi == 0 or numi == i:
        continue
    elif numi > i:
        pullout += numi - i
    elif numi < i:
        pullout += numi

print(pullout)

Measured memory_bytes: 14396
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	int n, m; cin >> n >> m;
	int l = 0, r = INF;
	for( int i = 0; i < m; ++i ){
		int x, y; cin >> x >> y;
		l = max(l, x);
		r = min(r, y);
	}
	cout << max(0, r-l+1) << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n; cin >> n;

  vector<vector<int> > graph(n);
  vector<pair<int,int> > pair_vec;
  for(int i = 1; i < n; i++){
    int a, b; cin >> a >> b;
    a--; b--;
    
    graph[a].push_back(b);
    graph[b].push_back(a);
    pair_vec.push_back(make_pair(a, b));
  }
 
  int k = 0;
  map<pair<int, int>, int> mp;
  vector<int> cs(n, 0);
  vector<int> used(n, 0);
  queue<int> que;
  used[0] = 1;
  que.push(0);
  while(!que.empty()) {
    int v = que.front(); que.pop();
    if(k < (int)graph[v].size()) k = graph[v].size();
    int cur = 1;
    for(int u : graph[v]) {
      if(used[u]) continue;
      if(cur == cs[v]) cur++;
      cs[u] = mp[make_pair(u, v)] = mp[make_pair(v, u)] = cur++;
      used[u] = 1;
      que.push(u);
    }
  }
 
  cout << k << endl;
  for(auto p : pair_vec) cout << mp[p] << endl;
  return 0;
}

Measured memory_bytes: 20084
//package AtCoder.C114;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
    static InputStream inputStream = System.in;
    static OutputStream outputStream = System.out;
    static InputReader in = new InputReader(inputStream);
    static PrintWriter out = new PrintWriter(outputStream);

    public static void main(String[] args) {
        int n = in.NI();
        String q = in.next();
        StringBuilder ans = new StringBuilder();
        for (int i=0;i<q.length();i++) {
            char ch = q.charAt(i);
            for (int j=0;j<n;j++) {
                if (ch == 'Z'){
                    ch= 'A';
                } else {
                    ch++;
                }
            }
            ans.append(ch);
        }
        out.println(ans.toString());
        out.close();
    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int NI() {
            return Integer.parseInt(next());
        }

        public long NL() {
            return Long.parseLong(next());
        }

    }


}


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


def solve(num_str: str):
    N = len(num_str) - 1

    for bit in range(2 ** N):
        ans = num_str[0]
        for i in range(N):
            if bit & 1 << i:
                ans += "+"
            else:
                ans += "-"
            ans += num_str[i + 1]

        if eval(ans) == 7:
            print(ans + "=7")
            return

    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    ABCD = next(tokens)
    solve(ABCD)

if __name__ == '__main__':
    main()


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

using namespace std;


int main()
{
    int n, tmp, d;
    cin >> n;
    d = n;
    n--;
    int t[n+1] = {};
    while(n--){
        cin >> tmp;
        t[tmp-1]++;
    }
    for(int i = 0; i <d; i++){
        cout<<t[i]<<"\n";
    }
}


Measured memory_bytes: 4404
#include <iostream>

using namespace std;

int K[30];
int A[30][30];

int main()
{
	int N, M;
	int count = 0;
	int subcount = 0;

	cin >> N >> M;
	for (int i = 0; i < N; i++) {
		cin >> K[i];
		for (int j = 0; j < K[i]; j++) cin >> A[i][j];
	}

	for (int i = 1; i <= M; i++) {
		subcount = 0;
		for (int j = 0; j < N; j++) {
			for (int k = 0; k < K[j]; k++) {
				if (A[j][k] == i) subcount++;
			}
		}
		if (subcount == N) count++;

	}

	cout << count << endl;

	return 0;
}

Measured memory_bytes: 256
N, X = map(int, input().split())
xlist = sorted(list(map(int, input().split()))+ [X])

import fractions
from functools import reduce


def gcd(*numbers):
    return reduce(fractions.gcd, numbers)


def gcd_list(numbers):
    return reduce(fractions.gcd, numbers)
sbn = [xlist[i+1] - xlist[i] for i in range(N)]
print(gcd_list(sbn))


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n, k;
  cin >> n >> k;
  
  int ans = 0;
  while(n > 0){
    n /= k;
    ans++;
  }
  
  cout << ans << '\n';
}

Measured memory_bytes: 256
dataW = [] 
dataK = []

for i in range (10):
    a = int(input())
    dataW.append(a)
dataW.sort()
pointW = dataW[9]+dataW[8]+dataW[7]
    
for i in range(10):
    a = int(input())
    dataK.append(a)
dataK.sort()
pointK = dataK[9]+dataK[8]+dataK[7]

print(pointW, pointK)


Measured memory_bytes: 5600
#include <iostream>
using namespace std;
long long gcd(long long x, long long y){
    if(x%y==0) return y;
    else return gcd(y,x%y);
}
int main(void){
    long long n,i,a[100000];
    cin >> n;
    for(i=0;i<n;i++) cin >> a[i];
    long long ans = a[0];
    for(i=1;i<n;i++){
        ans = min(ans,gcd(ans,a[i]));
    }
    cout << ans;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define Tp template<typename Ty>
#define Ts template<typename Ty,typename... Ar>
#define Reg register
#define RI Reg int
#define Con const
#define CI Con int&
#define I inline
#define W while
#define N 2000
#define add(x,y) (e[++ee].nxt=lnk[x],e[lnk[x]=ee].to=y)
using namespace std;
int n,m,ans,ee,lnk[N+5],p[N+5][N+5],w[N+5][N+5];struct edge {int to,nxt;}e[N<<1];
class Tree
{
	private:
		int f[N+5];
	public:
		I int operator [] (CI x) Con {return f[x];}
		I void dfs(CI x)
		{
			for(RI i=lnk[x];i;i=e[i].nxt) e[i].to^f[x]&&(f[e[i].to]=x,dfs(e[i].to),0);
		}
		I void Calc(CI x,RI s)
		{
			p[s][x]==x&&(s=x,++ans);for(RI i=lnk[x];i;i=e[i].nxt) e[i].to^f[x]&&(Calc(e[i].to,s),0);
		}
}F[N+5];
int c;vector<pair<int,int> > V[N+5];
int q[N+5];I void BFS(CI id,CI x,CI y)
{
	RI i,k,t,H=1,T=0;q[++T]=y,p[x][y]=y,w[x][y]=1;
	W(H<=T) for(i=lnk[k=q[H++]];i;i=e[i].nxt) (t=e[i].to)^F[x][k]&&
		(!p[x][t]?(p[x][q[++T]=t]=y):w[x][t]&&(V[id].push_back(make_pair(y,t)),w[x][t]=w[t][x]=0));
}
I void Link(CI x,CI y)
{
	if(p[x][y]==y||p[y][x]==x) return;if(p[x][y]) return Link(p[x][y],y);if(p[y][x]) return Link(p[y][x],x);
	RI id=++c;V[id].clear(),BFS(id,x,y),BFS(id,y,x);
	for(RI i=0,s=V[id].size();i^s;++i) Link(V[id][i].first,V[id][i].second);--c;
}
int main()
{
	RI i,x,y;for(scanf("%d%d",&n,&m),i=1;i^n;++i) scanf("%d%d",&x,&y),add(x,y),add(y,x);
	for(i=1;i<=n;++i) F[i].dfs(i);for(i=1;i<=m;++i) scanf("%d%d",&x,&y),Link(x,y);
	for(i=1;i<=n;++i) F[i].Calc(i,i);return printf("%d\n",ans>>1),0;
}

Measured memory_bytes: 48388