akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
 
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
//setfill -   cout << setfill ('x') << setw (5); cout << 77 << endl; prints xxx77
//setprecision - cout << setprecision (14) << f << endl; Prints x.xxxx
//cout.precision(x)  cout<<fixed<<val;  // prints x digits after decimal in val


#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define repa(i,arr,n) for(int i=arr;i<=n;i++)
#define repd(i,arr,n) for(int i=arr;i>=n;i--)
#define trav(arr,x) for(auto& arr:x)
#define all(c) c.begin(), c.end()
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define sz(arr) arr.size()
#define pi 3.14159265358979323846
#define MAX (1000*1000*1000+7)
#define inf (1000*1000*1000+9)
#define vi vector<int>
#define pii pair<int,int>
#define pqueue priority_queue<int>
#define pdqueue priority_queue<int,vi,greater<int> >

int mat1[1005][1005],mat2[1005][1005];
int32_t main()
{
  fast;
  int n,x,val,sum=0,cnt=0;
  cin>>n>>x;
  vi v;
  rep(i,n)
  {
    cin>>val;
    v.pb(val);
  }

  sort(all(v));
  rep(i,n)
  {
    sum+=v[i];
    cnt++;
    if(sum>=x)
      break;
  }

  if(sum==x)
    cout<<cnt;
  else if(sum<x)
    cout<<cnt-1;
  else
    cout<<cnt-1;

  return 0;
  
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(int argc, const char * argv[]) {
    
    int N;
    cin>>N;
    
    int *a;
    a = (int*)malloc(sizeof(int)*N);
    for(int i=0;i<N;i++){
        cin>>a[i];
    }
    int ans=0;

    
    for(int i=0;i<N;i++){
        ans+=a[i]-1;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <iterator>
#include <cmath>
#include <set>
#include <deque> 
#include <string>


using namespace std;

int n;
int a[1000010];

int dCount[1000010];

bool pairWisePrime;
bool setWisePrime;

int getPCount(int pNum) {
	int count = 0;
	for (int i = 0 ; i < n ; i++) {
//		if (a[i] == 1) {
//			count++;
//			continue;
//		}
			
		if (a[i] % pNum == 0) {
			count++;
			while (a[i] % pNum == 0) {
				a[i] = a[i] / pNum;
			}
			continue;
		}
	}
	
	return count;
}

std::vector<int> primes;

void init() {
	bool isPrime[1010];	
	for (int i = 2 ; i <= 1010 ; i++) {
		isPrime[i] = true;
	}
	
	int p = 2;
	while (p <= 1010) {
		if (isPrime[p] == true) {
			primes.push_back(p);
			long long curNum = p;
			
			int j = 2;
			while (true) {
				curNum = p * j;
				if (curNum > 1010)
					break;
				isPrime[curNum] = false;
				j++;
			}
			
		}
		p++;
	}
	
}

int main()
{
	init();
	
	for (int i = 0 ; i < 1000010 ; i++)
		dCount[i] = 0;
	scanf("%d", &n);
	
	pairWisePrime = true;
	setWisePrime = true;
	
	for (int i = 0 ; i < n ; i++) {
		scanf("%d", &(a[i]));
		if (a[i] == 1)
			continue;
		
		dCount[a[i]]++;
		if (dCount[a[i]] >= 2) {
			pairWisePrime = false;

		}
		
		if (dCount[a[i]] >= n) {		
			setWisePrime = false;
		}
	}
	
	if (setWisePrime == true) {
		for (int p = 0 ; p < primes.size() ; p++) {
			int pNum = primes[p];
			int pCount = getPCount(pNum);
			if (pCount >= 2) {
				pairWisePrime = false;
			}
			if (pCount >= n) {
				setWisePrime = false;
				break;
			}
		}
	}
	
	for (int i = 0 ; i < 1000010 ; i++)
		dCount[i] = 0;
	for (int i = 0 ; i < n ; i++) {
		if (a[i] == 1)
			continue;
		
		dCount[a[i]]++;
		if (dCount[a[i]] >= 2) {
			pairWisePrime = false;

		}
		
		if (dCount[a[i]] >= n) {		
			setWisePrime = false;
		}
	}
	
	if (pairWisePrime) {
		printf("pairwise coprime\n");
		return 0;
	}
	
	if (setWisePrime) {
		printf("setwise coprime\n");
		return 0;
	}
	
	printf("not coprime\n");
	
	return 0;
}




Measured memory_bytes: 10932
N = gets.chomp.to_i
# xl = []
ll = []

ans = []

h = Hash.new(0)

N.times do |i|
  x, l = gets.chomp.split.map(&:to_i)
  h[x-l+1] = +1
  h[x+l] = -1
  ll << [x-l,x+l]
end

ll.sort_by!{|x| x[1] }

ans << ll[0]

N.times do |i|
  next if i == 0
  if ll[i][0] >= ans.last[1]
    ans << ll[i]
  end
end

print(ans.length)


Measured memory_bytes: 25592
n,k = map(int,input().split())
from math import factorial
for i in range(1,k+1):
    if n-k < i-1:
        print(0) 
    else:
        a = factorial(k-1) // factorial(i-1) // factorial(k-i)
        b = factorial(n-k+1) // factorial(i) // factorial(n-k-i+1)
        #print(a)
        #print(b)
        print(a*b % (10**9+7))

Measured memory_bytes: 3316
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>
#include <cassert>
#include <functional>
#include <set>
#include <deque>
#include <list>
using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
#define LNF __LONG_LONG_MAX__
const ll MOD = 1000000007;
const int MAX = 200000;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
// 法mでのaの逆元を計算
long long modinv(long long a, long long m) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
//最大公約数
long long gcd(long long x, long long y){
    if(y==0) return x;
    else return gcd(y,x%y);
}
//最小公倍数
long long lcm(long long x, long long y){
    return x / gcd(x, y) * y;
}
// nが大きく,kが10^7程度の時の二項係数
long long com[200005];
void combination(long long n,long long k){
    com[0] = 1;
    for(int i=1;i<=k;i++){
        com[i] = (com[i-1]*(n-i+1)%MOD)*modinv(i,MOD)%MOD;
    }
}

int main(){
    int M; cin >> M;
    cout << 24+24-M << endl;
    return 0;
}


Measured memory_bytes: 3680
#include<cstdio>
#include<iostream>
using namespace std;
typedef long long ll;
ll n;
ll ans=0;
void bfs(ll zhi,ll r,bool a,bool b,bool c){
	if(zhi>n)
	return;
	if(a&b&c)
	ans++;
	bfs(zhi+3*r,10*r,true,b,c);
	bfs(zhi+5*r,10*r,a,true,c);
	bfs(zhi+7*r,10*r,a,b,true);
}
int main(){
	cin>>n;
	bfs(0,1,false,false,false);
	printf("%d",ans);
}

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

int main(){
  int x1, x2, x3, x4, x5;
  cin >> x1 >> x2 >> x3 >> x4 >> x5;
  if(x1 == 0){
    cout << 1 << endl;
  }
  else if(x2 == 0){
    cout << 2 << endl;
  }
  else if(x3 == 0){
    cout << 3 << endl;
  }
  else if(x4 == 0){
    cout << 4 << endl;
  }
  else if(x5 == 0){
    cout << 5 << endl;
  }
}

Measured memory_bytes: 3136
# include <bits/stdc++.h>
using namespace std;
# define ll long long
const int N = 2e5 + 10, mod = 1e9 + 7, INF = 1e9 + 100;
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
    int x, y;
    cin >> x >> y;
    for(int i = 0; i < y; i++){
        int a;
        cin >> a;
        x -= a;
    }
    cout << (x <= 0 ? "Yes" : "No") << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second
 
const int mx=200010;
const ll mod=1e9+7;

vector<ll> inv,fact,invfact;

//snuke
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }
 
  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};
 


void mod_build(int n=101010){  
  fact.resize(n+1);
  inv.resize(n+1);
  invfact.resize(n+1);
  fact[0]=inv[0]=invfact[0]=1;
  inv[1]=1;
  rep(i,n){
    fact[i+1]=fact[i]*(i+1)%mod;
    if(i>0)inv[i+1]=mod-inv[mod%(i+1)]*(mod/(i+1))%mod;
    invfact[i+1]=invfact[i]*inv[i+1]%mod;
  }
}
ll perm(int n,int k){
  if(n<0||k<0||k>n)return 0;
  return fact[n]*invfact[n-k]%mod;
}
ll comb(int n,int k){
  if(n<0||k<0||k>n)return 0;
  return (fact[n]*invfact[n-k]%mod)*invfact[k]%mod;
}
ll powmod(ll n,ll k){
  k%=mod-1;
  if(k<0)k+=mod-1;
  ll ret=1;
  while(k){
    if(k&1)ret=ret*n%mod;
    n=n*n%mod;
    k>>=1;
  }
  return ret;
}

int main(){  
  mod_build();
  int n;
  cin >> n;
  string s[2];
  cin >> s[0] >> s[1];
  
  int cnt=0;
  mint ans=1;
  bool f=true;
  rep(i,n){
    if(s[0][i]==s[1][i]){
      if(f==true){
        f=false;
        if(cnt==0){
          ans *= 3;
        } else {      
          ans *= 2;
          ans *= powmod(3,cnt);
          cnt=0;        
        }
      } else {
        ans *= 2;
        ans *= powmod(3,max(cnt-1,0));
        cnt=0;
      }
    } else {
      cnt++;
      i++;
    }
  }
  if(cnt!=0&&!f){
    ans *= 2;
    ans *= powmod(3,cnt-1);
  }
  if(cnt!=0&&f){
    ans *= 2;
    ans *= powmod(3,cnt);
  }
  cout << ans.x << endl;
  return 0;
}

Measured memory_bytes: 2560
// #include<bits/stdc++.h>
// using namespace std;
// #define int long long
// #define pii pair<int,int>
// const int mod=1e9+7;
 
// int dx[]={-1, 0, 1, 0};
// int dy[]={0, -1, 0, 1};

// int mn;
// void call(int d,int x,vector<int>&v)
// {
//     int in=-1;
//     for(int i=0;i<5;i++)
//     {
      
//       if(v[i]==0)continue;
      
//       else if(v[i]<x)
//       {
//         int p=v[i];
//         v[i]=0; 
//         call(d+1,p*2,v);
//         v[i]=p; in=i;
//       }
//       else{
//         int p=v[i];
//         v[i]-=x;
//         v[i]=min((p-x)*2,p);
//         call(d+1,x*2,v);
//         v[i]=p; in=i;
//       }

//     }
//     if(in==-1)
//     {
//       mn=min(mn,d);
//     }
    
// }


// void solve(vector<int>&v,int x)
// {
//   int n=5;
//   int z=x;
//   int ans=0;
//   multiset<int>ms;
//   for(int i=0;i<n;i++)
//   {
    
//     ms.insert(v[i]);
//   }
  
//   sort(v.begin(),v.end());
//   int i=n-1;
//   while(i>=1)
//   {
//     if(v[i-1]*2>=v[i])
//     {
//       i--;
//     }
//     else break;
//   }

//   int p=v[i];
//   int cnt=0;
 
//   while(x<p)
//   {
//     auto z=ms.lower_bound(x);
//     if(*z==x)
//     {
//       ms.erase(z); x=x*2; cnt++; continue;
//     }
//     if(z==ms.begin())
//     {
//       x=2*x; cnt++; continue;
//     }
//     z--;
//     int a,b;
    
//     a=ceil(log2((1.0*p)/x));
//     b=ceil(log2((1.0*p)/(*z)));
    
//     if(a==b-1)
//     {
//       x=2*(*z); cnt++; ms.erase(z);
//     }
//     else{
//       x=x*2; cnt++;
//     }
    
     
//   }
//   ans=cnt+ms.size();
 


//  mn=1e18;
//  call(0,z,v);
//  if(ans==mn)return;
//  else{
  
//   cout<<ans<<" "<<mn<<"\n";
//    for(auto i : v)cout<<i<<" ";
//    cout<<"\n"<<p<<"\n"; exit(0);
//  }

// }

// int32_t main()
// {

// ios::sync_with_stdio(false);
// cin.tie(0);
// cout.tie(0);

// #ifndef ONLINE_JUDGE
// freopen("input.txt","rt",stdin);
// freopen("output.txt","wt",stdout);
// #endif 

// srand(time(0));
// int cnt=0;
// while(1)
// {
  

//   vector<int>v(5);

//   for(int i=0;i<5;i++)
//   {
//     v[i]=rand()%100 +1;
//   }
//   int x=rand()%100 +1;
//   cnt++;
//   solve(v,x);
//   cnt++;
//   if(cnt==100)break;
  
// }




// }




#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pii pair<int,int>
const int mod=1e9+7;
 
int dx[]={-1, 0, 1, 0};
int dy[]={0, -1, 0, 1};



int32_t main()
{

ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);

#ifndef ONLINE_JUDGE
freopen("input.txt","rt",stdin);
freopen("output.txt","wt",stdout);
#endif 


int n;
cin>>n;
int val=n/1000 + (n%1000!=0);

cout<<(val*1000)-n<<"\n";


}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,m,ans=100000000000000;
int main(){
    cin>>n>>m;
    vector<ll> h(n);
    for(ll i=0;i<n;i++) cin>>h.at(i);
    sort(h.begin(),h.end());
    for(ll i=0;i+m-1<n;i++){
        ans=min(ans,h.at(i+m-1)-h.at(i));
    }
    cout<<ans<<endl;
}


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

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

constexpr int INF = 1e9;
constexpr ll INFLL = 1e18;

constexpr int M = 1e9 + 7;

int main() {
    int n; cin >> n;
    vector<int> t(n + 1), y(n + 1), x(n + 1);
    for(int i = 1; i <= n; ++i) {
        cin >> t[i] >> x[i] >> y[i];
    }
    for(int i = 0; i < n; ++i) {
        int dis = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
        int dt = t[i + 1] - t[i];
        if(dt < dis || dt % 2 != dis % 2) {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
}


Measured memory_bytes: 1408
<?php
fscanf(STDIN, "%d%d%d%d", $a, $b, $c, $d);

printf("%d", countN(1) - countN($c) - countN($d) + countN(lcm($c,$d)));

function countN($div){
  global $a, $b;
  return intdiv($b, $div) - intdiv($a-1, $div);
}

function gcd($m, $n){
    if(!$n)return abs($m);
    return gcd($n, $m % $n);
}
function lcm($a, $b) {
    return $a / gcd($a, $b) * $b;
}

Measured memory_bytes: 4728
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
#include <iomanip>
// #include <regex> //正規表現
using namespace std;
#define rep(i,a,b) for(int i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define RANGE(a,b,c) (a).begin()+b,(a).begin()+c // コンテナ a の 要素 b から c へのイテレータ
#define MOD 1000000007ll
#define INF 1000000000
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;
// グリッドグラフの移動ベクトル
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

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

string s, t; cin >> s >> t;
const int ss = s.size(), ts = t.size();

// dp[i][j] = s の i 文字目まで， t の j 文字目まででのLCSの長さ
VVI dp(ss + 1, VI(ts + 1, 0));

rep(i, 1, ss + 1){
    rep(j, 1, ts + 1){
        if (s[i - 1] == t[j - 1]) dp[i][j] = max({dp[i][j], dp[i - 1][j], dp[i][j - 1], dp[i - 1][j - 1] + 1});
        else dp[i][j] = max({dp[i][j], dp[i - 1][j], dp[i][j - 1]});
    }
}

if (dp[ss][ts] == 0) {
    cout << " \n";
    return 0;
}

// cout << '#' << 0 << t << "\n";
// cout << 0;
// rep(i, 0, ts  + 1) cout << dp[0][i];
// cout << "\n";
// rep(i, 1, ss + 1) {
//     cout << s[i - 1];
//     rep(j, 0, ts + 1) cout << dp[i][j];
//     cout << "\n";
// }

// 復元
string ans = "";
int i = ss, j = ts;
while (i > 0 && j > 0) {
    if (dp[i][j] == dp[i - 1][j]) --i;
    else if (dp[i][j] == dp[i][j - 1]) --j;
    else {
        ans = s[i - 1] + ans;
        --i; --j;
    }
}


cout << ans <<  "\n";

}

// 境界，出力文字列 チェック



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

int main(){
  int A, B, C;
  cin>> A>> B>> C;
  int one =A-B;
  if(C-one<0){
    cout<< 0<< endl;
  }
  else{
    cout<< C-one<< endl;
  }
}

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


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

    int ans = 1;
    while(n >= 2*ans){
        ans = ans<<1;
    }
    cout << ans << endl;
}



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

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>
#include<iomanip>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<int, double> pid;
typedef pair<double, int> pdi;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

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

	int A, B, X;
	cin >> A >> B>>X;

	if (A<=X&&X <= A + B)
	{
		cout << "YES" << endl;
	}
	else
	{
		cout << "NO" << endl;
	}

	return 0;
}

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

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

Measured memory_bytes: 4864
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdbool.h>
#include <math.h>

int main()
{
    int h, w;
    scanf("%d%d", &h, &w);
    char a[100][101];
    int x[100] = {};
    int y[100] = {};
    int i, j;

    for (i=0; i<h; i++)
    {
        scanf("%s", a[i]);
    }

    for (i=0; i<h; i++)
    {
        for (j=0; j<w; j++)
        {
            if (a[i][j] == '#') y[i] = 1;
        }
    }

    for (i=0; i<w; i++)
    {
        for (j=0; j<h; j++)
        {
            if (a[j][i] == '#') x[i] = 1;
        }
    }

    for (i=0; i<h; i++)
    {
        for (j=0; j<w; j++)
        {
            if (x[j] && y[i])
            printf("%c", a[i][j]);
        }
        if (y[i]) printf("\n");
    }

    return 0;
}


Measured memory_bytes: 128
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back

using namespace std;
const long long MOD = (long long)1e9 + 7;

int n, d, x[20][20], ans;
bool ck[20000];

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> n >> d;
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < d; j++) {
			cin >> x[i][j];
		}
	}
	for (int i = 1; i*i < 20000; i++) {
		ck[i*i] = true;
	}
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			int tmp = 0;
			for (int k = 0; k < d; k++) {
				tmp += (x[i][k] - x[j][k])*(x[i][k] - x[j][k]);
			}
			if (ck[tmp]) ans++;
		}
	}
	cout << ans << "\n";
	//system("pause");
	return 0;
}

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

int main(){
    int n;
    cin >> n;
    int a[n];
    int dummy[n];
    rep(i,n){
        cin >> a[i];
        dummy[i] = a[i];
    }

    sort(dummy, dummy+n, greater<int>());
    int max_val = dummy[0];
    int second_max_val = dummy[1];
    int count=0;    
    rep(i,n){
        if(a[i] == max_val)
            count++;
    }

    rep(i,n){
        if(count>1){
            cout << max_val << endl;
        }
        else{
            if(a[i]==max_val){
                cout << second_max_val << endl;
            }
            else{
                cout << max_val << endl;
            }
        }
    }


    return 0;
}

Measured memory_bytes: 3200
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pi = pair<int, int>;
int n,m;
pi a[101][101];
int vis[102];
vector<int> v[101];
int pre[101];
int dfs(int x)
{
    if(vis[x]) return false;
    vis[x] = true;
    for(int y : v[x])
    {
        if(pre[y] == -1 || dfs(pre[y]))
        {
            pre[y] = x;
            return true;
        }
    }
    return false;
}
int conv(pi p)
{
    return p.first*m + p.second + 1;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n >> m;
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            int x;
            cin >> x;
            x--;
            a[i][j] = {x/m, x%m};
        }
    }
    for(int j=0;j<m;j++)
    {
        fill(pre, pre+n, -1);
        for(int i=0;i<n;i++)
            v[i].clear();
        for(int i=0;i<n;i++)
        {
            int num_cnt[101] = {};
            for(int k=j;k<m;k++)
            {
                num_cnt[a[i][k].first]++;
                if(num_cnt[a[i][k].first] == 1)
                {
                    v[i].push_back(a[i][k].first);
                }
            }
        }
        for(int i=0;i<n;i++)
        {
            fill(vis, vis+n, 0);
            dfs(i);
            ///cout << "dfs " << dfs(i) << '\n';
        }
        for(int i=0;i<n;i++)
        {
            //cout << "pre " << i << ' ' << pre[i] << '\n';
            for(int k=j;k<m;k++)
            {
                if(a[pre[i]][k].first == i)
                {
                    //cout << j << ' ' << k << '\n';
                    swap(a[pre[i]][k], a[pre[i]][j]);
                    break;
                }
            }
        }
        /*
        cout << '\n';
        for(int i=0;i<n;i++)
        {
            for(int j=0;j<m;j++)
            {
                cout << a[i][j].first << ' ';
            }
            cout << '\n';
        }*/
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            cout << conv(a[i][j]) << ' ';
        }
        cout << '\n';
    }
    for(int j=0;j<m;j++)
    {
        vector<pi> pv;
        for(int i=0;i<n;i++)
            pv.push_back(a[i][j]);
        sort(pv.begin(), pv.end());
        for(int i=0;i<n;i++)
            a[i][j] = pv[i];
    }
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<m;j++)
        {
            cout << conv(a[i][j]) << ' ';
        }
        cout << '\n';
    }
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using namespace std;
using ll=long long;

const ll inf =1LL << 62;
const ll mod=1000000007LL;
const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

int n,d;
string x;

int dp[1010][1010];

int main(void){
	cin >> n >> x >> d;
	reverse(_all(x));
	clr(dp,-1);
	dp[0][0]=0LL;

	rep(i,n)rep(j,d+1){
		if(dp[i][j]==-1) continue;
		int cur=x[i]-'0';
		rep(k,2){
			int ni=i+1,nj=j+(cur!=k);
			chmax(dp[ni][nj],k);	
		}
	}

	int ci=n,cj=d;
	while(ci!=0){
		int digit=dp[ci][cj];
		cout << dp[ci][cj];	
		ci--;
		int cur=x[ci]-'0';
		if(cur!=digit) cj--;
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 7180
#include <stdio.h>

int main()
{
        double w;
        while(~scanf("%lf",&w))
                printf("%s\n",w>91?"heavy":w>81?"light heavy":w>75?"middle":w>69?"light middle":w>64?"welter":w>60?"light welter":w>57?"light":w>54?"feather":w>51?"bantam":w>48?"fly":"light fly");
        return 0;
}

Measured memory_bytes: 608
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <string>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <tuple>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cassert>
#include <cstdint>
#include <cctype>
#include <numeric>
#include <bitset>
#include <functional>

using namespace std;

using ll =  long long;
using Pll = pair<ll, ll>;
using Pii = pair<int, int>;

constexpr int INF = 1 << 30;
constexpr ll LINF = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr long double EPS = 1e-10;
constexpr int dyx[4][2] = {
    { 0, 1}, {-1, 0}, {0,-1}, {1, 0}
};

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int n;
    cin >> n;
    string s;
    cin >> s;

    ll ans = 0LL;
    {
        ll r = 0, g = 0, b = 0;
        for(int i=0;i<n;++i) {
            if(s[i] == 'R') ++r;
            else if(s[i] == 'G') ++g;
            else ++b;
        }
        ans = r * g * b;
    }

    for(int i=0;i<n-2;++i) {
        for(int j=1;i+j*2<n;++j) {
            if(s[i] != s[i+j] and s[i+j] != s[i+j*2] and s[i] != s[i+j*2]) {
                --ans;
            }
        }
    }

    cout << ans << endl;
}


Measured memory_bytes: 3660
//Never stop chasing!-MdSourav.
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>

#define YES            cout<<"YES"<<endl;
#define NO             cout<<"NO"<<endl;
#define sz(x)          x.size()
#define ll             long long int
#define ls             long int
#define start          ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define test           int t;cin>>t;while(t--)
#define f(i, a, n)     for(int i=a; i<n;i++)
#define gcd(a,b)       __gcd(a,b)
#define lcd(a,b)       (a*b)/gcd(a,b)
#define pb             push_back
#define mp(x,y)        make_pair(x,y)
#define rsrt(v)        sort(v.begin(),v.end(),greater<int>());
#define srt(v)         sort(v.begin(),v.end())
#define basrt(a,n)     sort(a,a+n,greater<int>());
#define asrt(a,n)      sort(a,a+n)
#define fact(n)        ll x=1;for(ll i=1;i<=n;i++){x=(x*i);}
#define F              first
#define S              second
#define enter(v,n)     for(ll i=0;i<n;i++){ll x;cin>>x;v.pb(x);}
#define INF 	       1000000007
#define unique(v)      v.erase(unique(v.begin(),v.end()),v.end())
using namespace std;

double pi=3.14159265358979323846;

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);cout.tie(0);
    ll a,b,c;
    cin >> a >> b >> c;
     int x=a-b;
     int x2=c-x;
     if(x2<=0)
     {
         cout << "0" << endl;
     }
     else
     cout << x2 << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(long long i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

int main(){
  int a,b;
  cin >> a >> b;
  if (a % 3 == 0 || b % 3 == 0 || (a+b) % 3 == 0){
    cout << "Possible";
  } else {
    cout << "Impossible";
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define RI(X) scanf("%d", &(X))
#define RII(X, Y) scanf("%d%d", &(X), &(Y))
#define RIII(X, Y, Z) scanf("%d%d%d", &(X), &(Y), &(Z))
#define DRI(X) int (X); scanf("%d", &X)
#define DRII(X, Y) int X, Y; scanf("%d%d", &X, &Y)
#define DRIII(X, Y, Z) int X, Y, Z; scanf("%d%d%d", &X, &Y, &Z)
#define RS(X) scanf("%s", (X))
#define CASET int ___T, case_n = 1; scanf("%d ", &___T); while (___T-- > 0)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define PII pair<int,int>
#define VI vector<int>
#define VPII vector<pair<int,int> >
#define PLL pair<long long,long long>
#define VPLL vector<pair<long long,long long> >
#define F first
#define S second
typedef long long LL;
using namespace std;
const int MOD = 1e9+7;
const int SIZE = 401;
LL p[SIZE][SIZE],sum_p[SIZE][SIZE];
LL dp[SIZE][SIZE];
int A[SIZE],B[SIZE];
void ADD(LL& x,LL v){
    x=(x+v)%MOD;
    if(x<0)x+=MOD;
}
int main(){
    REPP(i,1,SIZE){
        p[i][0]=1;
        sum_p[i][0]=sum_p[i-1][0]+1;
        REPP(j,1,SIZE){
            p[i][j]=p[i][j-1]*i%MOD;
            sum_p[i][j]=(sum_p[i-1][j]+p[i][j])%MOD;
        }
    }
    DRII(N,C);
    REP(i,N)RI(A[i]);
    REP(i,N)RI(B[i]);
    dp[0][0]=1;
    REP(i,N){
        REP(j,C+1){
            if(!dp[i][j])continue;
            for(int k=0;j+k<=C;k++){
                ADD(dp[i+1][j+k],dp[i][j]*(sum_p[B[i]][k]-sum_p[A[i]-1][k]));
            }
        }
    }
    cout<<dp[N][C]<<endl;
    return 0;
}


Measured memory_bytes: 3968
n = int(input())
a = list(map(int,input().split()))
'''
おぐに聞く
a_list = []
'''
a_count = 0
count = 0
#print(a)
for i in range(n):
    if a[i]%2==0:
        a_count+=1
        #print(a[i])
        if a[i]%3==0 or a[i]%5==0:
            count+=1

if a_count==count:
    print("APPROVED")
else:
    print("DENIED")

Measured memory_bytes: 3064
import sys

import queue

class Dinic:
    def __init__(self, v, inf=sys.maxsize):
        self.V = v
        self.inf = inf
        self.G = [[] for _ in range(v)]
        self.level = [0 for _ in range(v)]
        self.iter = [0 for _ in range(v)]

    def add_edge(self, from_, to, cap):
        # to: 行き先, cap: 容量, rev: 反対側の辺
        self.G[from_].append({'to': to, 'cap': cap, 'rev': len(self.G[to])})
        self.G[to].append({'to': from_, 'cap': 0, 'rev': len(self.G[from_]) - 1})

    # sからの最短距離をbfsで計算
    def bfs(self, s):
        self.level = [-1 for _ in range(self.V)]
        self.level[s] = 0
        que = queue.Queue()
        que.put(s)
        while not que.empty():
            v = que.get()
            for i in range(len(self.G[v])):
                e = self.G[v][i]
                if e['cap'] > 0 and self.level[e['to']] < 0:
                    self.level[e['to']] = self.level[v] + 1
                    que.put(e['to'])

    # 増加バスをdfsで探す
    def dfs(self, v, t, f):
        if v == t:
            return f
        for i in range(self.iter[v], len(self.G[v])):
            self.iter[v] = i
            e = self.G[v][i]
            if e['cap'] > 0 and self.level[v] < self.level[e['to']]:
                d = self.dfs(e['to'], t, min(f, e['cap']))
                if d > 0:
                    e['cap'] -= d
                    self.G[e['to']][e['rev']]['cap'] += d
                    return d

        return 0

    def max_flow(self, s, t):
        flow = 0
        while True:
            self.bfs(s)
            # bfsで到達不可
            if self.level[t] < 0:
                return flow
            self.iter = [0 for _ in range(self.V)]
            f = self.dfs(s, t, self.inf)
            while f > 0:
                flow += f
                f = self.dfs(s, t, self.inf)

n = int(input())
data1 = [list(map(int,input().split())) for _ in range(n)]
data2 = [list(map(int,input().split())) for _ in range(n)]
v = 2*n + 2

D = Dinic(v)
for i in range(n):
    D.add_edge(2*n,i,1)
    D.add_edge(n+i,2*n+1,1)

for i,ab in enumerate(data1):
    for j,cd in enumerate(data2):
        if ab[0]<cd[0] and ab[1]<cd[1]:
            D.add_edge(i,n+j,1)

ans = D.max_flow(2*n,2*n+1)
print(ans)

Measured memory_bytes: 50264
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a

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

A.sort()

ans = max(A)
for i in range(N-1):
    ans = min(ans, gcd(A[i], A[i+1]))

print(ans)


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

using namespace std;

int main(){
    int N;
    int d[100];
    cin >> N;

    for(int i = 0; i < N; ++i) cin >> d[i];

    int bucket[100] = {0};
    for(int i = 0; i < N; ++i){
        bucket[d[i]]++;
    }
    int res = 0;

    for(int i = 1; i <= 100; ++i){

        if(bucket[i] > 0) res++;
    }

    cout << res << endl;
}

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

int main(){
  int a,b,c,d,e;
  cin >> a;
  b = a / 1000;
  c = (a % 1000) / 100;
  d = (a % 100) / 10;
  e = (a % 10);
  if(b == c && c == d){
    cout << "Yes" << endl;
  }else if(c == d && d == e){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  
}

Measured memory_bytes: 256
var m,n,i,j,tx,ty:longint;
    flagg,ans:boolean;
	c1,c2:array[0..57,0..57] of char;
begin
  readln(n,m);
  for i:=1 to n do
  begin
    for j:=1 to n do
		read(c1[i,j]);
	readln;
  end;
  for i:=1 to m do
  begin
    for j:=1 to m do
		read(c2[i,j]);
	readln;
  end;
  ans:=false;
  for tx:=0 to n-m do
	for ty:=0 to n-m do
	begin
	  flagg:=true;
	  for i:=1 to m do
		for j:=1 to m do
		  if (c2[i,j]<>c1[i+tx,j+ty]) then flagg:=false;
	  if flagg then ans:=true;
	end;
  if ans then writeln('Yes') else writeln('No');
end.
  

Measured memory_bytes: 128
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Logic();
        
    }

    /**ロジック */
    public static void Logic(){

        // 標準入力
        Scanner sc = new Scanner(System.in);
        Double D = sc.nextDouble();
        Double T = sc.nextDouble();
        Double S = sc.nextDouble();
        
        // 処理
        // 出力
        if (D/S <= T){
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }

}

Measured memory_bytes: 37312
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var firstLine = Console.ReadLine().Split(' ').Select(value => int.Parse(value)).ToList();
			var sx = firstLine[0];
			var sy = firstLine[1];
			var tx = firstLine[2];
			var ty = firstLine[3];

			var route = new StringBuilder();

			var diffx = tx - sx;
			var diffy = ty - sy;

			AddRouteHorizontalChar(route, diffx);
			AddRouteVerticalChar(route, diffy);
			AddRouteHorizontalChar(route, -diffx);
			AddRouteVerticalChar(route, -diffy);

			AddRouteHorizontalChar(route, -1);
			AddRouteVerticalChar(route, diffy + 1);
			AddRouteHorizontalChar(route, diffx + 1);
			AddRouteVerticalChar(route, -1);

			AddRouteHorizontalChar(route, 1);
			AddRouteVerticalChar(route, -diffy - 1);
			AddRouteHorizontalChar(route, -diffx - 1);
			AddRouteVerticalChar(route, 1);


			Console.WriteLine(route.ToString());
		}

		private static void AddRouteVerticalChar(StringBuilder route, int diff)
		{
			if(diff > 0)
			{
				for(int i = 0; i < diff; i++)
				{
					route.Append("U");
				}
			}
			else
			{
				diff *= -1;
				for(int i = 0; i < diff; i++)
				{
					route.Append("D");
				}
			}
		}

		private static void AddRouteHorizontalChar(StringBuilder route, int diff)
		{
			if (diff > 0)
			{
				for (int i = 0; i < diff; i++)
				{
					route.Append("R");
				}
			}
			else
			{
				diff *= -1;
				for (int i = 0; i < diff; i++)
				{
					route.Append("L");
				}
			}
		}
	}
}


Measured memory_bytes: 11248
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define mem(x,v) memset(x,v,sizeof(x))
#define Rep(i,a,b) for(register int i=(a);i<=int(b);++i)
#define rep(i,a,b) for(register int i=(a);i<int(b);++i)
#define Dep(i,a,b) for(register int i=(a);i>=int(b);--i)
#define gc getchar
#define pc putchar
#define fi first
#define se second
inline ll read(){
    ll x=0;int f=1;char c=gc();
    for(;!isdigit(c);c=gc())if(c=='-')f=-1;
    for(;isdigit(c);c=gc())x=(x<<1)+(x<<3)+(c^48);
    return x*f;
}
inline void write(ll x){if(x<0)x=-x,pc('-');if(x>=10)write(x/10);putchar(x%10+'0');}
inline void writeln(ll x){write(x);pc('\n');}
inline void wri(ll x){write(x);pc(' ');}
const int maxn = 255;
const int mod = 1e9+7;
int n,m;
char s[maxn];
int ans,fac[maxn],ifac[maxn];
inline int qpow(int a,int b){
	int ans=1;
	for(;b;b>>=1,a=1ll*a*a%mod)
		if(b&1) ans=1ll*ans*a%mod;
	return ans;
}
void init(){
	n = read(),m = read();
	scanf("%s",s+1);
	fac[0] = 1;rep(i,1,maxn) fac[i] = 1ll * fac[i-1] * i % mod;
	ifac[maxn-1] = qpow(fac[maxn-1],mod-2);
	Dep(i,maxn-2,0) ifac[i] = 1ll * ifac[i+1] * (i+1) % mod;
	assert(ifac[0]==1);
}
inline int C(int n,int m){
	return 1ll * fac[n] * ifac[m] % mod * ifac[n-m] % mod;
}
#define cal(x,y) C((x)+(y)-1,(y)-1)
int g[maxn],a[maxn];
void calc(int w,int tot){
	Rep(i,1,tot) a[i] = g[tot-i+1];a[tot+1]=0;
	int lim=0;while(lim<tot && a[lim+1]>1) ++lim;
	int i,j,k,l,t;
	for(i=1,k=1,l=1,t=0;i<=m;++i){
		if(s[i]=='r' && k<=tot) 
		k++; else
		if(s[i]=='b' && l<k && l<=lim) t+=a[l]-2,l++; else
		if(t) t--; 
	}
	if(k<=tot || l<=lim || t) return ;
	int pos=tot+1,res=fac[tot];
	for(i=1;i<=tot;i=j+1){
		for(j=i;a[j+1]==a[i];++j);
		res=1ll*res*ifac[j-i+1]%mod;
		pos+=(j-i+1)*(2*a[i]-1);
	}
	ans=(ans+1ll*res*cal(w,pos))%mod;
}
void dfs(int w,int z,int last){
	calc(w,z-1);
	if(last==1&&w-1>=0) g[z]=1,dfs(w-1-(z>1),z+1,1); 
	for(int i=max(2,last);w-(i-1)-(i-2)>=0;++i){
		g[z] = i,dfs(w-(i-1)-(i-2)-(z>1),z+1,i);
	}
	g[z] = 0;
}
int main(){
	ans=0;
	init(); 
	dfs(n,1,1);
	writeln(ans);
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(){

    int n,pot=10;
    int sum=0;
    int aux;

    cin>>n;
    aux=n;
    while(n!=0){
        sum+=(n%pot)/(pot/10);
        n/=10;
    }

    if(aux%sum==0)cout << "Yes"<<endl;
    else cout<<"No"<<endl;

    return 0;
}

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

using namespace std;

//typedef pair<int, int> P;
#define int long long
#define ll long long
#define mod 1000000007
#define INF (1LL<<60)

int N, M;
bool p[123456];
int n[123456];

signed main(){

	cin >> N >> M;
	p[1] = true;
	for(int i = 1; i <= N; i++){
		n[i] = 1;
	}
	for (int i = 0; i < M; i++){
		int x, y;
		cin >> x >> y;
		p[y] |= p[x];
		n[x]--;
		n[y]++;
		if (n[x] == 0) p[x] = false;
	}
	int ans = 0;
	for (int i = 1; i <= N; i++){
		if(p[i]) ans++;
	}
	cout << ans << endl;


	return 0;
}


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

int main(){
   unsigned long long int a, b, tmp, m=0, s=0, ai, bi;
   while(cin >> a >> b){
      ai=a; bi=b;
      while(1){
         if(a<b){
            tmp=a;
            a=b;
            b=tmp;
         }
         if(a%b==0){
            m=b;
            break;
         }else a=a%b;
      }
      s=ai*bi/m;
      cout<< m << " " << s << endl;
   }
   return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>  // clang-format off
using Int = long long;
#define REP_(i, a_, b_, a, b, ...) for (Int i = (a), lim##i = (b); i < lim##i; i++)
#define REP(i, ...) REP_(i, __VA_ARGS__, __VA_ARGS__, 0, __VA_ARGS__)
struct SetupIO { SetupIO() { std::cin.tie(nullptr), std::ios::sync_with_stdio(false), std::cout << std::fixed << std::setprecision(13); } } setup_io;
#ifndef dump
#define dump(...)
#endif  // clang-format on

/**
 *    author:  knshnb
 *    created: Sat May  2 21:57:02 JST 2020
 **/

/// @docs src/DataStructure/SegmentTree.md
template <class T, class F> struct SegmentTree {
    const F op;
    const T e;
    SegmentTree(F op_, T e_) : op(op_), e(e_) {}
    int n;
    std::vector<T> t;
    void set_by_identity(int n_) {
        n = n_;
        t.clear(), t.resize(2 * n, e);
    }
    void set_by_vector(const std::vector<T>& a) {
        n = a.size();
        t.clear(), t.resize(2 * n, e);
        for (int i = 0; i < n; i++) t[i + n] = a[i];
        build();
    }
    void build() {
        for (int i = n - 1; i; --i) t[i] = op(t[2 * i], t[2 * i + 1]);
    }
    T& operator[](int i) { return t[i + n]; }
    // [l, r)
    T query(int l, int r) const {
        assert(0 <= l && l <= r && r <= n);
        T resl = e, resr = e;
        for (l += n, r += n; l < r; l >>= 1, r >>= 1) {
            if (l & 1) resl = op(resl, t[l++]);
            if (r & 1) resr = op(t[--r], resr);
        }
        return op(resl, resr);
    }
    // i番目をxに変更
    void update(int i, const T& x) {
        assert(0 <= i && i < n);
        t[i += n] = x;
        while (i >>= 1) t[i] = op(t[2 * i], t[2 * i + 1]);
    }
    // i番目にxを作用 (a[i] = op(a[i], x))
    void operate(int i, const T& x) {
        assert(0 <= i && i < n);
        i += n;
        t[i] = op(t[i], x);
        while (i >>= 1) t[i] = op(t[2 * i], t[2 * i + 1]);
    }
    friend std::string to_string(const SegmentTree<T, F>& seg) {
        return to_string(std::vector<T>(seg.t.begin() + seg.n, seg.t.end()));
    }
};
template <class T, class F> auto make_segment_tree(F op, T e) { return SegmentTree<T, F>(op, e); }

signed main() {
    int n;
    std::cin >> n;
    std::vector<Int> a(n);
    REP(i, n) std::cin >> a[i];
    {
        auto b = a;
        std::sort(b.begin(), b.end());
        b.erase(std::unique(b.begin(), b.end()), b.end());
        REP(i, n) a[i] = std::lower_bound(b.begin(), b.end(), a[i]) - b.begin();
    }
    std::vector<std::vector<int>> g(n);
    for (int i = 0; i < n - 1; i++) {
        int u, v;
        std::cin >> u >> v;
        u--, v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }

    auto seg = make_segment_tree<Int>([&](Int x, Int y) { return std::max(x, y); }, 0);
    seg.set_by_identity(n);
    std::vector<Int> ans(n);
    auto dfs = [&](auto f, int v, int prv) -> void {
        Int bef = seg[a[v]];
        seg.update(a[v], seg.query(0, a[v]) + 1);
        ans[v] = seg.query(0, n);
        for (int s : g[v]) {
            if (s == prv) continue;
            f(f, s, v);
        }
        seg.update(a[v], bef);
    };
    dfs(dfs, 0, -1);
    for (Int x : ans) {
        std::cout << x << "\n";
    }
}


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

int main()
{
  int b, r, g, c, s, t;
  while( cin >> b >> r >> g >> c >> s >> t, b+r+g+c+s+t ) {
    int ans = 100;
    ans -= t * 3;
    ans += b * (15 * 6 + 5);
    ans += r * (15 * 4 + 3);
    ans += g * 7;
    ans += c * 2;
    ans += s * 3;
    cout << ans << endl;
  }
}

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

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define loop(i,a,b) for(ll i=a;i<b;i++)
#define loope(i,a,b) for(ll i=a;i<=b;i++)
#define test() ll t;cin>>t;while(t--)
#define f first
#define s second
#define pb push_back
#define mkp make_pair
#define ins insert
#define nl cout<<endl
#define P 1000000007
#define MOD(x) ((x%P)+P)%P



int main() 
{ 


      int n,k;
      cin>>n>>k;
      char a[n];

      loop(i,0,n)
      {
            cin>>a[i];
            if(i == k-1)
            {
                  a[i]=char(a[i]+32);
            }

            cout<<a[i];
      }




}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    long long i,N,Y,M,D,ty,ny,sum,pass;
    cin >> N;
    while(N--){
        sum=0;
        pass=0;
        cin >> Y >> M >> D;
        ty = 333 - (Y/3);
        ny = 999 - ty-Y;
        sum = ny*195+ty*200;
        if(Y%3==0){
            sum+=200;
            for(i=1;i<M;i++){
                pass+=20;
            }
        }
        else{
                for(i=1;i<M;i++){
                    if(i%2==0)  pass+=19;
                    else    pass+=20;
                }
                sum+=195;
        }
        pass+=D;
        //cout << ty << "   " << ny << endl;
        cout << sum-pass+1 << endl;
    }
    return 0;
}


Measured memory_bytes: 3100
#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;
    bool okflag = false;

    for(int i = 0; i < s.size(); i++) {
        int cnt = 0;
        for (int j = 0; j < s.size(); j++) {
            if (j + i >= s.size()) {
                if (s[j+i-s.size()] != t[j]) break;
            } else {
                if (s[j+i] != t[j]) break;
            }
            cnt++;
            if (cnt == s.size()) okflag = true;
        }
        if (okflag) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 3628
x, n = [int(i) for i in input().split()]

if n > 0:
    p = [int(i) for i in input().split()]
    ps = set(p)
    ans = 0

    c = 0

    
    while(True):
        if (x - c) not in ps:
            ans = x-c
            break
        elif (x + c) not in ps:
            ans = x+c
            break
        else:
            c += 1

    print(ans)
















else:
    print(x)

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

vector<int> v;

int P,Q,R;
int main (){
    cin >> P >> Q >> R;

    v.push_back(P+Q);
    v.push_back(R+Q);
    v.push_back(P+R);
    sort(v.begin(),v.end());
    cout << v[0] << endl;
    return 0;
}


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

void swap(int *x, int *y){
	int z = *x;
	*x = *y;
	*y = z;
}

int selectionSort(int *A, int n){
	int count = 0;
	for(int i=0;i<n;i++){
		int minj = i;
		for(int j = i;j<n;j++)
			if(A[j] < A[minj])
				minj = j;
		if(i != minj){
			swap(A[i], A[minj]);
			count++;
		}
	}
	return count;
}

int main(){
	int n, A[N], change;

	cin>>n;
	for(int i=0;i<n;i++){
		cin>>A[i];
	}
	
	change = selectionSort(A, n);
	
	for(int i=0;i<n;i++){
		if(i!=0) cout<<" ";
		cout<<A[i];
	}
	cout<<endl<<change<<endl;

	return 0;
}

Measured memory_bytes: 1164
import java.util.*;

class Main {

	private static final int M = 1_000_000_007;

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] s = sc.next().toCharArray();

		long[][] dp = new long[s.length + 1][4];
		dp[0][0] = 1;
		for (int i = 1; i <= s.length; i++) {
			for (int j = 0; j < 4; j++) {
				dp[i][j] = dp[i - 1][j];
				dp[i][j] %= M;
				if (s[i - 1] == '?') {
					dp[i][j] *= 3;
				}
			}
			if (s[i - 1] == '?') {
				for (int j = 1; j < 4; j++) {
					dp[i][j] += dp[i - 1][j - 1];
				}
			} else {
				dp[i][(s[i - 1] - 'A') + 1] += dp[i - 1][(s[i - 1] - 'A')];
			}
		}
		System.out.println(dp[s.length][3] % M);
	}
}


Measured memory_bytes: 31732
program test02
 integer H, N
 integer,allocatable :: A(:)
 integer :: kougekisum=0
 integer i

 read *, H, N
 allocate(A(N))

 read *,A

 do i=1,N
  kougekisum=kougekisum+A(i)
 end do

 if ( H <= kougekisum ) then
  print *, 'Yes'
 else
  print *, 'No'
 end if
 
endprogram test02


Measured memory_bytes: 1152
N, Q = map(int, input().split())

l = [[] for i in range(N)]

for i in range(N-1):
  a, b = map(int, input().split())
  l[a-1].append(b-1)
  l[b-1].append(a-1)

used = [False] * N
r = [0] * N

for i in range(Q):
  p, x = map(int, input().split())
  r[p-1] += x

stack = [0]
while stack:
  i = stack.pop()
  used[i] = True
  for to in l[i]:
    if not used[to]:
      stack.append(to)
      r[to] += r[i]

print(*r)

Measured memory_bytes: 55856
h,w,k = map(int, input().split())
item = [[0 for _ in range(w)] for _ in range(h)]
for i in range(k):
    y,x,v = list(map(int,input().split()))
    item[y-1][x-1]=v

dp = [[[0 for _ in range(w+1)] for _ in range(h+1)] for _ in range(4)]

for y in range(h):
    for x in range(w):
        for i in range(4):
            dp[0][y+1][x]=max(dp[0][y+1][x],dp[i][y][x])
            dp[i][y][x+1]=max(dp[i][y][x+1],dp[i][y][x])
        if item[y][x]>0:
            for i in range(3):
                dp[0][y+1][x]  =max(dp[0][y+1][x],  dp[i][y][x]+item[y][x])
                dp[i+1][y][x+1]=max(dp[i+1][y][x+1],dp[i][y][x]+item[y][x])
ans=dp[0][-1][-2]
print(ans)

Measured memory_bytes: 468692