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

public class Main {

    public static void main(String[] args) { 

        Scanner sc = new Scanner(System.in);

        String[] abt = sc.nextLine().split(" ");
        int N = Integer.parseInt(abt[0]);
        int X = Integer.parseInt(abt[1]);

        String[] LN = sc.nextLine().split(" ");
        int length = 0;
        int bound = 1;
        for (String l : LN) {
            int li = Integer.parseInt(l);
            length += li;

            if (length <= X) {
                bound++;
            }
        }

        System.out.println(bound);
    }
}


Measured memory_bytes: 22996
#include<bits/stdc++.h>
using namespace std;
#define MOD 1000000007


int main() {
  
  long long N,Q,sum = 0;
  cin >> N;

  vector<int> num(1000100);
  for(int i = 0;i < N;i++) {
    int a;
    cin >> a;
    num.at(a)++;
    sum += a;
  }

  cin >> Q;

  for(int i = 0;i < Q;i++) {
    long long b,c;
    cin >> b >> c;
    int ch_num = num.at(b);
    num.at(b) -= ch_num;
    num.at(c) += ch_num;
    sum -= b*ch_num - c*ch_num;
    cout << sum << endl;
  }
  
  
}


Measured memory_bytes: 7188
#include <cstdio>
#include <cstring>
#include <algorithm>

using namespace std;

int A[555], B[555], C[555], t = 0;

void add(int a, int b, int c) {
    A[++t] = a;
    B[t] = b;
    C[t] = c;
}

int main() {
    int l;
    scanf("%d", &l);
    for(int i = 2; i < 20; i++) {
        add(i, i + 1, 1 << (19 - i));
        add(i, i + 1, 0);
    }
    for(int i = 0; i < 19; i++)
        if((l >> i) & 1) add(1, 20 - i, (l >> (i + 1)) << (i + 1));
    if((l >> 19) & 1) {
        add(1, 2, 262144);
        add(1, 2, 0);
    }
    printf("20 %d\n", t);
    for(int i = 1; i <= t; i++) printf("%d %d %d\n", A[i], B[i], C[i]);
    return 0;
}

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

using namespace std;
 
/// ----------------------------- (Debug) ------------------------------
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; }; sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0); sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i));}
sim, class b dor(pair < b, c > d) {ris << "(" << d.first << ", " << d.second << ")";}
sim dor(rge<c> d) {*this << "["; for (auto it = d.b; it != d.e; ++it) *this << ", " + 2 * (it == d.b) << *it; ris << "]";}
#else
sim dor(const c&) { ris; }
#endif
};
vector<char*> tokenizer(const char* args) {
  char *token = new char[111]; strcpy(token, args); token = strtok(token, ", ");
  vector<char*> v({token});
  while(token = strtok(NULL,", ")) v.push_back(token);
  return reverse(v.begin(), v.end()), v;
}
void debugg(vector<char*> args) { cerr << "\b\b "; }
template <typename Head, typename... Tail>
void debugg(vector<char*> args, Head H, Tail... T) {
  debug() << " [" << args.back() << ": " << H << "] ";
  args.pop_back(); debugg(args, T...);
}
#define harg(...) #__VA_ARGS__
#ifndef ONLINE_JUDGE
#define dbg(...) { debugg(tokenizer(harg(__VA_ARGS__, \b\t-->Line)), __VA_ARGS__, __LINE__); cerr << endl;}
#else
#define dbg(...) { }
#endif
/// -----------------------------------------------------------------------
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi; 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)    
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define print(x) cout << x << "\n";
#define REP(i,a,b) for(i=a;i<=b;i++)
#define RAP(i,a,b) for(i=a;i>=b;i--)
#define spa <<" "<<
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
ll mod=998244353;
const int MX=0x3f3f3f3f;

int main(){
    IOS;
    string s;
    cin>>s;
    cout<<s[0]<<s[1]<<s[2];
    return 0;   
}




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

using namespace std;


int main() {
    int k, res = 0;
    scanf("%d", &k);
    for (int a = 1; a <= k; a++)
        for (int b = 1; b <= k; b++)
            for (int c = 1; c <= k; c++)
                res += __gcd(a, __gcd(b, c));
    printf("%d\n", res);
    return 0;
}


Measured memory_bytes: 3784
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;
int diff=200000;
int parent[400005];
int ran[400005];

void init(int n)
{
  int i;
  rep(i,n){
    parent[i]=i;
    ran[i]=0;
  }
}

int find(int x)
{
  if(parent[x]==x)
    return x;
  else
    return parent[x]=find(parent[x]);
}

void unite(int x,int y)
{
  x=find(x);
  y=find(y);
  if(x==y)return;

  if(ran[x]<ran[y])
    parent[x]=y;
  else{
    parent[y]=x;
    if(ran[x]==ran[y])ran[x]++;
  }
}


int main(void) {
  int i,j;
  int n,k,l;
  cin>>n>>k>>l;
  int p,q,r,s;
  init(2*n);
  rep(i,k){
    cin>>p>>q;
    p--;q--;
    unite(p,q);
  }
  rep(i,l){
    cin>>r>>s;
    r--;s--;
    unite(n+r,n+s);
  }
  pii pp[200005];
  rep(i,n){
    pp[i].first=parent[find(i)];
    pp[i].second=parent[find(n+i)];
  }

  map<pii,int> mp;
  rep(i,n)
    mp[pp[i]]++;

  rep(i,n){
    if(i)cout<<" ";
    cout<<mp[pp[i]];
  }
  cout<<endl;
}


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

int main()
{
    int a,b,c =0;
    cin >> a >> b >> c;
    
    if(a == b){
        cout << c << endl;
    }
    else if (b == c){
        cout << a << endl;
    }
    else if ( c == a){
        cout << b << endl;
    }
    return 0;
}

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

#define MOD 1000000007

using namespace std;

long long int my_power(long long int base, long long int up)
{
  long long int num = 1;
  while (up > 0){
    if (up & 1)
      num = (num * base) % MOD;
    up >>= 1;
    base = (base * base) % MOD;
  }
  return num;
}

void calculate(int& N, int& K)
{
  long long int sum_of_gcd = 0; 
  vector<long long int> num_of_gcd(K + 1);
  for (int i = K; i >= 1; i--){
    num_of_gcd[i] = my_power(K / i, N);
    for (int j = i * 2; j <= K; j += i)
      num_of_gcd[i] = (num_of_gcd[i] - num_of_gcd[j] + MOD) % MOD;
  }
  for (int i = 1; i <= K; i++)
    sum_of_gcd = (sum_of_gcd + i * num_of_gcd[i]) % MOD;
  cout << sum_of_gcd << '\n';
}

int main(void)
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N, K;
  cin >> N >> K;
  calculate(N, K);
  return 0;
}


Measured memory_bytes: 3992
s=input()
alphabets=["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]
for i in range(len(alphabets)):
    if alphabets[i]==s:
        print(alphabets[i+1])

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
typedef long long ll;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define rrep(i,n,a) for(int i=n;i>=a;i--)
#define FOR(i,n) for(int i=0;i<n;i++)
#define all(s) s.begin(),s.end()
#define vi vector<int>
#define vvi vector<vector<int>>
#define pcnt(n) __builtin_popcount(n)
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const double PI = acos(-1);

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int a,b;
    string s;
    cin>>a>>b>>s;
    s[b-1] = (char)(s[b-1]+'a'-'A');
    cout<<s<<endl;
}

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

const long long INF = 1000000000;

typedef long long ll;

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

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




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

	int n; cin>>n;

	vector<int> a(n+1);
	vector<int> b(n);

	ll sum =0;
	for(int i=0; i<n+1; i++){
		cin>>a[i];
		sum +=a[i];
	}
	for(int i=0; i<n; i++){
			cin>>b[i];
	}

	for(int i=0; i<n; i++){
		int n = min(a[i],b[i]);
		a[i] -=n; b[i] -=n;

		n = min(a[i+1],b[i]);
		a[i+1] -= n;
	}
	ll d=0;
	for(auto e :a){
		d +=e;
	}

	writeln(sum-d);
}




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

using namespace std;
typedef long long ll;

int dfs(int lb, int rem, int num) {
  if (rem == 0) return 1;
  if (num <= 0) return 0;
  if (lb * lb > rem) return 0;
  int res = 0;
  for (int i = lb; i * i <= rem; i++) {
    res += dfs(i, rem - i * i, num - 1);
  }
  return res;
}

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  
  int n;
  while (cin >> n, n) {
    int ans = 0;
    for (int i = 1; i * i <= n; i++) {
      ans += dfs(i, n - i * i, 3);
    }
    cout << ans << endl;
  }

  return 0;
}


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

#define rep(i, n) for(int i=0; i < (int)n; i++)

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

void toS(int *d) {
  int dt[6];
  rep(i, 6) dt[i] = d[i];
  d[0] = dt[4];
  d[1] = dt[0];
  d[2] = dt[2];
  d[3] = dt[3];
  d[4] = dt[5];
  d[5] = dt[1];
}

void toN(int *d) {
  int dt[6];
  rep(i, 6) dt[i] = d[i];
  d[0] = dt[1];
  d[1] = dt[5];
  d[2] = dt[2];
  d[3] = dt[3];
  d[4] = dt[0];
  d[5] = dt[4];
}

void toW(int *d) {
  int dt[6];
  rep(i, 6) dt[i] = d[i];
  d[0] = dt[2];
  d[1] = dt[1];
  d[2] = dt[5];
  d[3] = dt[0];
  d[4] = dt[4];
  d[5] = dt[3];
}

void toE(int *d) {
  int dt[6];
  rep(i, 6) dt[i] = d[i];
  d[0] = dt[3];
  d[1] = dt[1];
  d[2] = dt[0];
  d[3] = dt[5];
  d[4] = dt[4];
  d[5] = dt[2];
}

int main(void) {
  int n[6]={0};
  rep(i, 6) cin >> n[i];

  string s;
  cin >> s;

  rep(i, s.length()) {
    switch (s[i])
    {
    case 'S':
      toS(n);
      break;

    case 'N':
      toN(n);
      break;

    case 'W':
      toW(n);
      break;

    case 'E':
      toE(n);
      break;
    }
  }

  cout << n[0] << endl;
  
}



Measured memory_bytes: 3204
#include<stdlib.h>
#include <string.h> 
#include <stdio.h>


int main(void){
	
	int *status;
	int *ans;
	int i=0;
	int j=0;
	int k=0;
	int rock=0;
	int num_p=0;
	int num_r=0;
	
	status=malloc(sizeof(int)*50);
	ans=malloc(sizeof(int)*100);
	while(1){
		
		for(i=0;i<50;i++){
			status[i]=0;
		}
		
		scanf("%d %d",&num_p,&num_r);
		
		if(num_p==0 && num_r==0){
			break;
		}
		
		j=0;
		rock=num_r;
		
		while(1){
			
			if(num_r!=0){
				status[j]++;
				num_r--;
				if(status[j]==rock){
					ans[k]=j;
					k++;
					break;
				}
				
			} else{
				num_r=status[j];
				status[j]=0;
			}
			
			j++;
			
			if(j==(num_p)){
				j=0;
			}
		}
		}
		
		ans[k]=-1;
			
		for(i=0;ans[i]!=-1;i++){
			printf("%d\n",ans[i]);
		}
	
	
		free(status);
		free(ans);

	return 0;
		
}

Measured memory_bytes: 600
#include <iostream>

using namespace std;

int main(){
  int N, A, B, min, max;
  cin >> N >> A >> B;
  if(A < B) max = A;
  else max = B;
  min = A+B-N;
  if(min < 0) min = 0;
  cout << max << " " << min << "\n";
  return 0;
}


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

using namespace std;

#define loop(i, init, val) for(i = init; i < val; i++)
#define srt(v) {sort(v.begin(), v.end());}

int main(){
	int i;
	int h,n;
	cin >> h >> n;

	vector<int> a(n);

	loop(i, 0, n)	cin >> a[i];

	int sum = 0;
	loop(i, 0, n) sum += a[i];

	if(sum >= h)	cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 640
// DP F

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
using namespace std;

typedef long long ll;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1e9;
const long long INFL = 1LL<<60;

void dump(const vector<pair<int, int>>& a)
{
  for (auto v : a) {
    cerr << v.first << " " << v.second << endl;
  }
}


int main()
{
  ll x, y;
  cin >> x >> y;

  ll ans = 0;

  for (ans = 0; x * ll(pow(2L, ans)) <= y; ans++) {
  }

  cout << ans << endl;

  return 0;
}


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

int main() {
  string ans;
  cin >> ans;
  if(ans == "a"){
  cout << "vowel"<< endl;
  }
  else if(ans == "e"){
  cout << "vowel"<< endl;
  }
  else if(ans == "i"){
  cout << "vowel"<< endl;
  }
  else if(ans == "o"){
  cout << "vowel"<< endl;
  }
  else if(ans == "u"){
  cout << "vowel"<< endl;
  }
  else{
  cout << "consonant"<< endl;
  }
  }

Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
int main()
{
    int n,count=1;
    scanf("%d", &n);
    char s[n+1];
    scanf("%s", s);
    s[n]='\0';
    for(int i=0; i<strlen(s)-1; i++)
    {
        if(s[i]!=s[i+1])
            count++;
    }
    printf("%d\n", count);
    return 0;
}


Measured memory_bytes: 1804
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

const int mod = 1000000007;
struct mint{
	ll x;
	mint(ll x = 0):x((x%mod+mod)%mod){}
	mint operator-() const{return mint(-x);}
	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;
	}
	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;
	}
	bool operator==(const mint a){
		return x == a.x;
	}
};

mint dp[1000005][2];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;
	cin >> s;
	int n = s.size();
	dp[0][0] = 1;
	rep(i,n){
		{// a+b = 0
			if(s[i] == '0'){
				dp[i+1][0] = dp[i][0];
				dp[i+1][1] = dp[i][1];
			}
			else{
				dp[i+1][1] = dp[i][0] + dp[i][1];
			}
		}
		{// a+b = 1
			if(s[i] == '0'){
				dp[i+1][1] += dp[i][1] * 2;
			}
			else{
				dp[i+1][0] += dp[i][0] * 2;
				dp[i+1][1] += dp[i][1] * 2;
			}
		}
	}
	mint ans = dp[n][0] + dp[n][1];
	cout << ans.x << endl;
	return 0;
}

Measured memory_bytes: 16128
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <map>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int N, M;
int A[100000];
int m_sum[100001];

int main() {
    cin >> N >> M;
    REP(i, N) cin >> A[i];
    REP(i, N) m_sum[i + 1] = (m_sum[i] + A[i]) % M;

    map<int, ll> m;
    REP(i, N + 1) m[m_sum[i]]++;
    ll ans = 0;
    for (auto p : m) {
        ans += p.second * (p.second - 1) / 2;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4992
k,x=map(int,input().split())

right= (1000000)*(-1)
left=1000000
al=[]
for i in range(x-(k-1),x+1):
  if i<right or left<i:
    continue
  for j in range(k):
    t=i+j
    if (i+j in al)!=True and (t<right)==False and (left <t)==False:
      al.append(i+j)
  

al.sort()
print(*al)





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

int main()
{
    int s;
    map<int, bool> mp;
    cin >> s;
    mp[s] = true;
    int ans = 1;
    do
    {
        if (s % 2 == 0)
            s /= 2;
        else
            s = 3 * s + 1;
        ans++;
        if (mp[s] == true)
            break;
        mp[s] = true;

    } while (true);
    cout << ans << endl;
    return 0;
}

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

ll fac[2000010],ifac[2000010];
int n,k;

inline int rd()
{
	int x=0;char ch=getchar();
	for (;ch<'0'||ch>'9';ch=getchar());
	for (;ch>='0'&&ch<='9';ch=getchar()) x=x*10+ch-'0';
	return x;
}

inline ll pls(const ll &x,const ll &y) { return (x+y<mod)?x+y:x+y-mod; }
inline ll mns(const ll &x,const ll &y) { return (x-y<0)?x-y+mod:x-y; }
inline ll ksm(ll x,ll y) { ll res=1;for (;y;y>>=1,x=x*x%mod) if (y&1) res=res*x%mod;return res; }
inline ll C(const int &x,const int &y) { return (x<0||y<0||x<y)?0:fac[x]*ifac[y]%mod*ifac[x-y]%mod; }

inline void pre_gao()
{
	fac[0]=1;
	for (int i=1;i<=2000000;i++) fac[i]=fac[i-1]*i%mod;
	ifac[2000000]=ksm(fac[2000000],mod-2);
	for (int i=1999999;~i;i--) ifac[i]=ifac[i+1]*(i+1)%mod;
}

int main()
{
	n=rd();k=rd();pre_gao();
	ll ans=0;
	for (int r=0;r<=k;r++)
	{
		int b=k-r;
		if (r<n||r<b) continue;
		if (r-b>=n) { ans=pls(ans,C(k,r));continue; }
		int hh=n-(r-b);
		if (r>b) ans=pls(ans,mns(C(k,r),C(k,hh-1)));
		else
		{
			if (n==1) ans=pls(ans,C(k-1,r));
			else ans=pls(ans,mns(C(k-1,r),C(k-1,hh-2)));
		}
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 31488
// AOJ 1250: Leaky Cryptography
// 2017.10.16 bal4u@uu

#include <stdio.h>

unsigned v[9];

int main()
{
	int n, i, j;
	unsigned sum, ans;

	scanf("%d", &n);
	while (n-- > 0) {
		for (i = 0; i < 9; i++) scanf("%x", v+i);

		ans = 0;
		for (i = 0; i < 32; i++) {
			for (sum = 0, j = 0; j < 8; j++) sum += v[j] ^ ans;
			if ((sum & (1<<(i+1)-1)) != ((v[8] ^ ans) & (1<<(i+1)-1)))
				ans |= (1 << i);
		}
		printf("%x\n",ans);
    }
	return 0;
}

Measured memory_bytes: 1692
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define erep(i, a, b) for (int i = a; i <= (int)(b); ++i)
#define per(i, a, b) for (int i = (b); i > (a); --i)
#define eper(i, a, b) for (int i = ((int)(a)); i >= b; --i)
#define pb push_back
#define mp make_pair
#define INF (1 << 28) - 1
#define MOD 1000000007
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
int dy[] = {0, 0, 1, -1};
int dx[] = {1, -1, 0, 0};
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

string s;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> s;
    int q;
    cin >> q;
    rep(i, 0, q)
    {
        string oder, str;
        int a, b;
        cin >> oder >> a >> b;

        if (oder == "print")
        {
            rep(j, a, b + 1) cout << s[j];
            cout << endl;
        }
        else if (oder == "reverse")
        {
            string sub = s.substr(a, b - a + 1);
            reverse(sub.begin(), sub.end());
            int k = 0;
            rep(j, a, b + 1)
                s[j] = sub[k++];
        }
        else
        {
            string target;
            cin >> target;
            int k = 0;
            rep(j, a, b + 1)
                s[j] = target[k++];
        }
    }
    return 0;
}


Measured memory_bytes: 3184
#include<bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define srep(i,n,m) for(int i=n;i<m;i++)
#define elif else if
#define INF 1000000007
using namespace std;
int gcd(int a,int b){
    if(b==0) return a;
    return gcd(b,a%b);
}
int m,n,aa[110000][10],k=0,cnt=0,a,b;
pair<int,int> p[220000];
string s,ss[220000],sf,se;
char c;
signed main(){
    cin>>s>>n;
    rep(i,n){
        cin>>m;
        if(m==1){
            k=(k+1)%2;
        }else{
            cin>>a>>c;
            if((a+k)%2==1){
                sf=c+sf;
            }else{
                se=se+c;
            }
        }
    }
    s=sf+s+se;
    if(k==0){
        cout<<s;
    }else{
        for(int i=s.size()-1;i>-1;i--){
            cout<<s[i];
        }
    }
}

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

int main(void) {
    long long int n, a, b;

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> a >> b;
    cout << n / (a + b) * a + min(n % (a + b), a) << "\n";
    return 0;
}

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

using namespace std;

map <int, int> mp;

int main() {
    //fstream cin("A.in");
    //ofstream cout("A.out");
    int n;
    ios::sync_with_stdio(false);
    cin >> n;
    int ans = 0;
    for(int i = 1; i <= n; i++) {
        int x;
        cin >> x;
        mp[x]++;
        if(mp[x] > 1 && mp[x] % 2 == 0)
            ans--;
        else
            ans++;
    }
    cout << ans;
    //cin.close();
    //cout.close();
    return 0;
}


Measured memory_bytes: 4992
#include<iostream>
#include<vector>
#include<queue>
using namespace std;
enum COLOR{WHITE, BLACK};

struct Edge{
    int w;
    int i;
    int j;
    Edge(int w_, int i_, int j_) : w(w_), i(i_), j(j_) {}
    bool operator< (const Edge& right) const{
        return w > right.w;
    }
};

int main(){
    int n;
    cin >> n;
    vector<vector<int> > G(n, vector<int>(n));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            cin >> G[i][j];
            if (G[i][j] == -1) G[i][j] = 1e8;
        }
    }
    vector<COLOR> state(n, WHITE);
    priority_queue<Edge> prim;
    state[0] = BLACK;
    int sum = 0;
    int idx_new_gray = 0;
    for (int i = 1; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (state[j] != WHITE) continue;
            prim.push(Edge(G[idx_new_gray][j], idx_new_gray, j));
        }
        while (state[prim.top().j] == BLACK) prim.pop();
        sum += G[prim.top().i][prim.top().j];
        state[prim.top().j] = BLACK;
        idx_new_gray = prim.top().j;
        prim.pop();
    }
    cout << sum << endl;
    return 0;
}



Measured memory_bytes: 3204
import numpy as np

n = int(input())

dp = [0]*(n+1)

b = 6
c = 9
for i in range(1, n+1):
  if i>=b*6: b*=6
  if i>=c*9: c*=9
  if i < 6:
    dp[i] = i
  elif i < 9:
    dp[i] = min(dp[i-1]+1, dp[i-b]+1)
  else:
    dp[i] = min(dp[i-1]+1, dp[i-b]+1, dp[i-c]+1)
print(dp[-1])

Measured memory_bytes: 27420
import sys
input=sys.stdin.readline
n,k=map(int,input().split())
dp=[[0]*k for i in range(k)]
for i in range(n):
    x,y,z=input().split()
    x,y=int(x),int(y)
    if (x//k)%2==(y//k)%2:
        if z=='W':
            x,y=x%k,y%k
            dp[0][0]+=1
            if y<k-1:
                dp[0][y+1]-=1
            if x<k-1:
                dp[x+1][0]-=1
            if x<k-1 and y<k-1:
                dp[x+1][y+1]+=2
        else:
            x,y=x%k,y%k
            if y<k-1:
                dp[0][y+1]+=1
            if x<k-1:
                dp[x+1][0]+=1
            if x<k-1 and y<k-1:
                dp[x+1][y+1]-=2
    else:
        if z=='W':
            x,y=x%k,y%k
            if y<k-1:
                dp[0][y+1]+=1
            if x<k-1:
                dp[x+1][0]+=1
            if x<k-1 and y<k-1:
                dp[x+1][y+1]-=2
        else:
            x,y=x%k,y%k
            dp[0][0]+=1
            if y<k-1:
                dp[0][y+1]-=1
            if x<k-1:
                dp[x+1][0]-=1
            if x<k-1 and y<k-1:
                dp[x+1][y+1]+=2
for i in range(k):
    for j in range(1,k):
        dp[i][j]+=dp[i][j-1]
Max=0
Min=n
for j in range(k):
    for i in range(k):
        if i==0:
            Max=max(Max,dp[i][j])
            Min=min(Min,dp[i][j])
        else:
            dp[i][j]+=dp[i-1][j]
            Max=max(Max,dp[i][j])
            Min=min(Min,dp[i][j])
ans=max(Max,n-Min)
print(ans)


Measured memory_bytes: 52188
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
#define all(v) v.begin(), v.end()
const int inf = 1000000000; //10^9
using ll = long long;
using P = pair<int, int>;
//加算代入演算子は+=！！！！！

int main()
{
    string s;
    cin >> s;
    ll sum = 0;
    int n = s.size();

    for (int bit = 0; bit < (1 << n - 1); bit++)
    { //2^n繰り返す
        ll temp = s[0] - '0';
        rep(i, n - 1)
        {
            if (bit & (1 << i))
            { //1が立っていればホニャララ
                sum += temp;
                temp = s[i + 1] - '0';
            }
            else {
                temp *= 10;
                temp += s[i + 1] - '0';
            }
        }
    sum += temp;
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
from collections import deque
n,q = map(int,input().split())
d = defaultdict(list)
dp = [0] * n
ep = [0] * n
for i in range(n-1):
    ta,tb = map(int,input().split())
    d[ta-1].append(tb-1)
    d[tb-1].append(ta-1)
for i in range(q):
    ta,tb = map(int,input().split())
    dp[ta-1] +=tb
ep[0]+=1
l = deque()
l.append(0)

while l:
    t = l.pop()
    ep[t] = 1
    for i in d[t]:
        if not ep[i]:
            dp[i] += dp[t]
            l.append(i)
print(*dp)


Measured memory_bytes: 122712
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#define debug(x)  cerr << #x << " = " << x << endl
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

const int maxN = 1e5 + 5;
const ll INF = 1e18;
const ll MOD = 1e9 + 7;

ll gcd(ll a, ll b) {return !b ? a : gcd(b, a % b);}
ll sq(ll x) {return (x * x) % MOD;}
ll modP(ll a, ll b) {return (!b ? 1 : (sq(modP(a, b / 2)) * (b % 2 ? a : 1)) % MOD);}

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	int a, b, h; cin >> a >> b >> h;
	cout << (a + b) * h / 2 << endl;
	return 0;
}



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

using int64 = long long;

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

    vector<int> a(N), prev(N);
    prev[0] = 0;

    int max_idx = -1;
    int64 sum = 0;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        sum += a[i];

        prev[i] = max_idx;
        if (max_idx < 0 or a[max_idx] < a[i]) {
            max_idx = i;
        }
    }

    priority_queue<int64> Q;
    int64 charge = 0;
    for (int i = N - 1; i >= max_idx; i--) {
        Q.push(a[i]);
        if (a[i] == a[max_idx]) charge++;
    }

    vector<int64> ans(N, 0);

    int64 op_sum = 0;
    while (max_idx != 0) {
        int prev_idx = prev[max_idx];
        /*
        cerr << "max_idx: " << max_idx << " prev_idx: " << prev_idx << endl;
        cerr << "charge: " << charge << endl;
        */

        int64 cnt = (a[max_idx] - a[prev_idx]) * charge;

        for (int i = prev_idx; i < max_idx; i++) Q.push(a[i]);

        while (!Q.empty() and Q.top() >= a[prev_idx]) {
            if (Q.top() != a[max_idx]) {
                cnt += Q.top() - a[prev_idx];
                charge++;
            }
            Q.pop();
        }

        ans[max_idx] = cnt;
        op_sum += cnt;
        max_idx = prev_idx;
    }

    ans[0] = sum - op_sum;

    for (int i = 0; i < N; i++) cout << ans[i] << endl;

    return 0;
}

Measured memory_bytes: 2936
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; ll W; cin >> N >> W;
  vector<ll> w(N, 0); vector<ll> v(N, 0);
  REP(i, N){
    cin >> w[i] >> v[i];
  }
  ll INF = 1e18;
  vector<vector<ll> > dp(N+1, vector<ll>(1e5+1, INF));
  dp[0][0] = 0;
  for(int i = 1; i <= N; i++){
    for(int j = 0; j <= 1e5; j++){
      if(j-v[i-1] >= 0){
        dp[i][j] = min(dp[i-1][j], dp[i-1][j-v[i-1]] + w[i-1]);
      }else{
        dp[i][j] = dp[i-1][j];
      }
    }
  }
  ll ans = 0;
  for(int j = 1e5; j > 0; j--){
    if(dp[N][j] <= W){
      ans = j;
      break;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 80256
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		List<Integer> sales = new ArrayList<>();
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext()) {
			int x = sc.nextInt();
			if (x == 0) {
				System.out.println(sales.get(sales.size()-1));
				sales.remove(sales.size() - 1);
			}else {
			sales.add(x);
			}
		}
	}
}



Measured memory_bytes: 26208
#include <iostream>
#include <vector>
#include <map>
#define repeat(i,n) for (int i = 0; (i) < (n); ++(i))
using namespace std;
int main() {
    // input
    int n, m; cin >> n >> m;
    map<int,int> xs;
    repeat (i,n) {
        int x; cin >> x;
        xs[x] += 1;
    }
    // compute
    vector<int> cnt(m), pr(m);
    for (auto it : xs) {
        int x, k; tie(x, k) = it;
        cnt[x % m] += k;
        pr [x % m] += k / 2 * 2;
    }
    int ans = 0;
    repeat (i,m) {
        int j = (m - i) % m;
        if (i == j) {
            ans += cnt[i] / 2;
        } else if (i < j) {
            int k = min(cnt[i], cnt[j]);
            ans += k;
            ans += min(cnt[i] - k, pr[i]) / 2;
            ans += min(cnt[j] - k, pr[j]) / 2;
        }
    }
    // output
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 5760
#include<stdio.h>

int main() {
	int k, a, b, f = 0, g=0, i;
	scanf("%d", &k);
	scanf("%d %d", &a, &b);
	i = a;
	while(f == 0) {
		if (i%k == 0) {
			g++;
			f++;
		}
		else {
			if (i == b) {
				f++;
			}
			else {
				i++;
			}
		}
	}
	if (g == 1) {
		printf("OK");
	}
	else {
		printf("NG");
	}
}

Measured memory_bytes: 2152
#include <bits/stdc++.h>
#define ll long long

using namespace std;

int main() {
  ll n, a, m = INT64_MAX;
  cin >> n;
  vector<ll> c(n);
  for(int i = 0; i < n; i++) {
    cin >> a;
    if(i)
      c[i] = c[i - 1] + a;
    else
      c[i] = a;
  }
  for(int i = 0; i < n - 1; i++)
    m = min(m, abs(c[n - 1] - c[i] * 2));
  cout << m << endl;
}

Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define ll long long 
#define pb push_back
#define mod 1000000007
#define all(v) v.begin(),v.end()
#define MP make_pair
#define F first
#define S second
#define inf 10000000000000
#define vll vector<ll>
using namespace std;
const int N=100005;
ll par[N];
ll root(ll x)
{
	return (par[x]==x)?x:(par[x]=root(par[x]));
}
void join(ll x,ll y)
{
	x=root(x);
	y=root(y);
	if(x!=y)
		par[x]=y;
}
void solve()
{
	ll i;
	ll n,m,u,v,w,ans=0;
	cin>>n>>m;
	for(i=1;i<=n;i++)
		par[i]=i;
	while(m--)
	{
		cin>>u>>v>>w;
		join(u,v);
	}
	for(i=1;i<=n;i++)
		if(par[i]==i)
			ans++;
	cout<<ans;
}
 
int main() {
    
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	
    ll t=1;
    //cin>>t;
    while(t--)
        solve();
 
    
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define pii pair<int,int>
#define pll pair<ll, ll>
#define pil pair<int,ll>
#define pli pair<ll,int>
#define ppi pair<pii,int>
#define pip pair<int,pii>
#define pdd pair<double, double>
#define f first
#define s second
#define MOD 1000000007
#define mkp make_pair
#define M_PI 3.14159265358979323846
#define FOR(i,l,r) for (int i=l;i<=r;i++)
#define LOR(i,l,r) for (ll i=l;i<=r;i++)
#define FORD(i,r,l) for (int i=r;i>=l;i--)
#define LORD(i,r,l) for (ll i=r;i>=l;i--)
#define INF 1000000000
#define CL(x) memset(x,0,sizeof(x))
#define DEB(x) cout << #x << " : " << x << '\n'
#define ALL(x) x.begin(), x.end()
#define SZ(x) x.size()
#define UI(x) (int)(x-'A')
#define LI(x) (int)(x-'a')
typedef long long ll;

#define MXQ 70005
#define MXK 105
ll N,K;
ll DP[MXK][MXQ];
vector<ll> V;
int To[MXQ];
int vs;
ll ans;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>N>>K;
    for(ll i = 1; i*i <= N; i++)
    {
        V.pb(i);
        if(N/i!=i)V.pb(N/i);
    }
    sort(ALL(V));
    vs=SZ(V);
    
    int pt = vs-1;
    To[0]=pt;
    FOR(i,1,vs-1)
    {
        while( V[i]*V[pt]>N )pt--;
        To[i]=pt;
        //cout<<i<<" to "<<pt<<'\n';
    }

    FOR(i,0,vs-1)DP[1][i]=V[i];
    
    ll d;
    FOR(i,2,K)
    {
        DP[i][0]=DP[i-1][vs-1];
        FOR(j,1,vs-1)
        {
            d = V[j]-V[j-1];
            DP[i][j] = (DP[i][j-1]+d*DP[i-1][ To[j] ])%MOD;
        }
        //cout<<DP[i][vs-1]<<'\n';
    }
    cout<<DP[K][vs-1]<<'\n';

    return 0;
}

Measured memory_bytes: 57592
import java.util.Scanner;
 
public class Main {
 
	static Scanner scanner;
 
	public static void main(String[] args) {
	    scanner = new Scanner(System.in);
 
	    int n=gi();
	    int r=gi();
	    //int c=gi();
 
	    //System.out.print(String.valueOf(c));
 
        if (n>=10) {
        	System.out.print(r);
        }else {
        	System.out.print(r+(100*(10-n)));
        }
 
 
	}
	// 文字列として入力を取得
	public static String gs() {
		return scanner.next();
	}
 
	// intとして入力を取得
	public static int gi() {
		return Integer.parseInt(scanner.next());
	}
 
	// longとして入力を取得
	public static long gl() {
		return Long.parseLong(scanner.next());
	}
 
	// doubleとして入力を取得
	public static double gd() {
		return Double.parseDouble(scanner.next());
	}
}

Measured memory_bytes: 35748
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
ll M=1e9+7;


#define MAXN 10000005
ll spf[MAXN]; 
ll hash1[MAXN] = { 0 }; 
void sieve() 
{ 
	spf[1] = 1; 
	for (ll i = 2; i < MAXN; i++) 
		spf[i] = i; 
	for (ll i = 4; i < MAXN; i += 2) 
		spf[i] = 2; 
	for (ll i = 3; i * i < MAXN; i++) { 
		if (spf[i] == i) { 
			for (ll j = i * i; j < MAXN; j += i) 
				if (spf[j] == j) 
					spf[j] = i; 
		} 
	}
} 

void getFactorization(ll x) 
{ 
	ll temp; 
	while (x != 1) { 
		temp = spf[x]; 
		
		if (x % temp == 0) {
			hash1[spf[x]]++; 
			
			x = x / spf[x];
		} 
		while (x % temp == 0) 
			x = x / temp; 
	} 
} 

bool check(ll x) 
{ 
	ll temp; 
	while (x != 1) { 
		temp = spf[x]; 
		if (x % temp == 0 && hash1[temp] > 1) 
			return false; 
		while (x % temp == 0) 
			x = x / temp; 
	} 
	return true; 
} 
 
int main()
{
	ll n;
	cin>>n;
	sieve();
	vector<ll> vec(n+1,0);
	bool bb=1;
	for(ll i=1;i<=n;i++){
		cin>>vec[i];
		getFactorization(vec[i]);
	}
	
	for(ll i=1;i<=n;i++){
		if(check(vec[i])==0){
			bb=0;break;
		}
	}
	
	if(bb==1){
		cout<<"pairwise coprime"<<endl;
	}
	else{
		ll g=vec[1];
		for(ll i=2;i<=n;i++){
			g=__gcd(g,vec[i]);
		}
		if(g==1){
			cout<<"setwise coprime"<<endl;
		}
		else{
			cout<<"not coprime"<<endl;
		}
	}
	
}

Measured memory_bytes: 96756
#include <algorithm>
#include <cstdio>
#include <cstring>

int n, k; 

int main() {
    scanf("%d%d", &n, &k); 

    long long tmp = n / k; 
    long long res = tmp * tmp * tmp;

    if ((k & 1) == 0) {
        tmp = n / k; 
        if (n % k >= k / 2) {
            tmp++; 
        }
        res += tmp * tmp * tmp; 
    }
    printf("%lld\n", res); 
    return 0; 
}

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

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

const int MAXN = 2e5;

int h, w, n, y, x;
char s[MAXN+10], t[MAXN+10];

int u, d, l, r;

int main()
{
    int i, j;
    scanf("%d%d%d%d%d", &h, &w, &n, &y, &x);
    scanf("%s%s", s+1, t+1);

    u=0; d=h+1; l=0; r=w+1;

    for(i=n; i>=1; i--)
    {
        char b=s[i], a=t[i];

        if(a=='U') d++, d=min(h+1, d);
        else if(a=='D') u--, u=max(0, u);
        else if(a=='L') r++, r=min(w+1, r);
        else if(a=='R') l--, l=max(0, l);
        //printf("%d %d %d %d\n", u, d, l, r);
        if(u+1>=d || l+1>=r) return !printf("NO");

        if(b=='U') u++, u=max(0, u);
        else if(b=='D') d--, d=min(h+1, d);
        else if(b=='L') l++, l=max(0, l);
        else if(b=='R') r--, r=min(w+1, r);
        //printf("%d %d %d %d\n", u, d, l, r);
        if(u+1>=d || l+1>=r) return !printf("NO");

    }
    if(u+1<=y && y<=d-1 && l+1<=x && x<=r-1) printf("YES");
    else printf("NO");
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define int  long long int
#define mod 1000000000000007
#define pb push_back
#define mp make_pair
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define gcd __gcd
#define fastio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define min3(a,b,c) min(a,min(b,c))
#define max3(a,b,c) max(a,max(b,c))
#define all(i) i.begin(),i.end()
#define rep(i,a,b) for(int i=a;i<b;i++)
#define set_bit __builtin_popcount //gives number of set_bits
#define ff first
#define ss second
#define cases(t) int t;cin>>t; rep(casn,1,t+1)
#define el cout<<"\n";
#define deci(n) int n; scanf("%lld",&n);
#define decs(n) string n; cin>>n;
#define sz(v) v.size()
#define repit(m) for(auto it=m.begin();it!=m.end();it++)
// #define find(m,i) (m.find(i)!=m.end())
// #define find(m,i) (m.find(i)==m.end())
#define cYES cout<<"YES\n";
#define cNO cout<<"NO\n";
#define ins insert
#define imax 1000000000000000000
#define imin -1000000000000000000
// #define NP 50000
//  cerr << "\nTime : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";
 
//  IIITA
//SUNEET KUMAR -->  ਸੁਨੀਤ
 
// scanning numbers extremely fast/////////
void fs(int &number)
{
    bool negative = false;
    register int c;
    number = 0;
    c = getchar();
    if (c=='-')
    {
        negative = true;
        c = getchar();
    }
    for (; (c>47 && c<58); c=getchar())
        number = number *10 + c - 48;
    if (negative)
        number *= -1;
}
// ========================================
int power(int a,int x)
{
        a%=mod;
    int res=1;
    while(x>0)
    {
        if(x&1)
        res=res*a%mod;
        a=a*a%mod;
        x>>=1;
    }
    return res;
}
int max(int a,int b)
{
    if(a>b)
    {
        return a;
    }
    else
    {
        return b;
    }
}
int min(int a,int b)
{
    if(a>b)
    {
        return b;
    }
    else
    {
        return a;
    }
}
int madd(int a,int b)
{
    int ans;
    ans=(a%mod+b%mod)%mod;
    return ans;
}
int mmult(int a,int b)
{
    int ans=1;
    ans=((a%mod)*(b%mod))%mod;
    return ans%mod;
}
int modinverse(int a)
{
    return power(a,mod-2);
}
 
void nhi_degi()
{
   int n,m;cin>>n>>m;
   vector<int>v[n+3];
   int h[n+4];
   for(int i=1;i<=n;i++)
   {
       cin>>h[i];
   }
    map<int,int>mx;
   while(m--)
   {
       int x,y;cin>>x>>y;
       if(h[x]>h[y])
       {
           mx[x]++;
       }
       else if(h[y]>h[x])
       {
           mx[y]++;
       }
       v[x].pb(y);
       v[y].pb(x);
   }
   int count=0;
   for(int i=1;i<=n;i++)
   {
        if(v[i].size()==0||(v[i].size()==mx[i]))
        {
            count++;
        }   
   }
   cout<<count;el
}
signed main()
{
    // cases(t)
    // {
        nhi_degi();
    // }
}

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

int main(){
    ll x;
    cin >> x;

    ll ans_a = 0;
    ll ans_b = 0;
    for(int i = -200; i <= 200; i++){
        ll k = pow(i, 5);
        k -= x;
        if(k < 0){
            k = 0 - k;
            ll z = pow(k, 1.0 / 5.0);
            if(pow(z, 5) == k){
                ans_a = i;
                ans_b = 0 - z;
                break;
            }
        }else{
            ll z = pow(k, 1.0 / 5.0);
            if(pow(z, 5) == k){
                ans_a = i;
                ans_b = 0 - z;
                break;
            }
        }
    }

    cout << ans_a << " " << ans_b << endl;
}

Measured memory_bytes: 4036
#include<bits/stdc++.h>
using namespace std;
int n,l[100010],r[100010],i,tmp;
long long ans;
int main(){
	scanf("%d",&n);
	for(i=0;i<n;++i)scanf("%d%d",l+i,r+i);
	sort(l,l+n+1);sort(r,r+n+1);
	for(i=0;i<n;++i){if((tmp=l[n-i]-r[i])<1)break;ans+=tmp;}
	return !printf("%lld\n",ans<<1);
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <cassert>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using ii = pair<int, int>;
using vvi = vector<vi>;
using vii = vector<ii>;
using gt = greater<int>;
using minq = priority_queue<int, vector<int>, gt>;
using P = pair<ll,ll>;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  int n; cin >> n;
  int ans = ceil((double)n/1000) * 1000 - n;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3644
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include <time.h>
typedef long long ll;
typedef long double ld;
#define INF (1LL<<60)
#define MOD1 1000000007
/*swap 交換*/
void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
/*2つのうち大きい数を返す*/
ll max2(ll a,ll b){return a>=b?a:b;}
/*2つのうち小さい数を返す*/
ll min2(ll a,ll b){return a>=b?b:a;}
/*絶対値*/
ll ABS(ll a){return a>=0?a:(-a);}
typedef struct{
    ll aa;
    ll bb;
}frequent;
// 小大
int compare(const void *a, const void *b){return *(ll *)a - *(ll *)b;}

int main(void){
    ll a,b,x;
    scanf("%lld%lld%lld",&a,&b,&x);
    if(b==0) printf("1\n");
    if(a==0 && b!=0) printf("%lld\n",b/x+1);
    if(a!=0) printf("%lld\n",b/x-(a-1)/x );
    return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <utility>

#define YNUM(X) ( X < 0 ? X + 3 : X )

typedef std::pair<int, int> WH;
typedef std::vector<WH> whvec;

int main(){
	int h, w;

	while( std::cin >> h >> w, w + h != 0 ){
		bool map[502][502];
		std::string in;
		std::vector<std::vector<whvec> > data(3, std::vector<whvec>(502));
		int data_max = 0;
		int height_sum[502][502], width_sum[502][502];
		WH wh;

		memset( map, 0, sizeof(map) );
		memset( height_sum, 0, sizeof(height_sum) );
		memset( width_sum, 0, sizeof(width_sum) );

		for( int i = 1; i <= h; ++i ){
			std::cin >> in;
			for( int l = 1; l <= w; ++l ){
				map[i][l] = ( in[l - 1] == '.' );
			}
		}

		for( int i = 1; i <= h; ++i ){
			for( int l = 1; l <= w; ++l ){
				if(map[i][l]){
					width_sum[i][l] = width_sum[i][l - 1] + 1;
					height_sum[i][l] = height_sum[i - 1][l] + 1;
				}
			}
		}

		for( int i = 1, n = 1; n <= h; n++, i = n % 3 ){
			data[i] = std::vector<whvec>(502);
			for( int l = 1; l <= w; l++ ){
				if( map[n][l] ){
					if( map[n - 1][l] && map[n][l - 1] ){
						int x_cnt = width_sum[n][l], y_cnt = height_sum[n][l];
						for( int m = 0; m < data[YNUM(i - 1)][l].size(); ++m ){
							wh = WH( std::min(data[YNUM(i - 1)][l][m].first, x_cnt), data[YNUM(i - 1)][l][m].second + 1 );
							if( std::find( data[i][l].begin(), data[i][l].end(), wh ) == data[i][l].end() ){
								data[i][l].push_back( wh );
								data_max = std::max( data_max, wh.first * wh.second );
							}
						}
						for( int m = 0; m < data[i][l - 1].size(); ++m ){
							wh = WH( data[i][l - 1][m].first + 1, std::min(data[i][l - 1][m].second, y_cnt) );
							if( std::find( data[i][l].begin(), data[i][l].end(), wh ) == data[i][l].end() ){
								data[i][l].push_back( wh );
								data_max = std::max( data_max, wh.first * wh.second );
							}
						}
						
					}else if( map[n - 1][l] ){
						for( int m = 0; m < data[YNUM(i - 1)][l].size(); ++m ){
							data[i][l].push_back( wh = WH( 1, data[YNUM(i - 1)][l][m].second + 1 ) );
							data_max = std::max( data_max, wh.first * wh.second );
						}

					}else if( map[n][l - 1] ){
						for( int m = 0; m < data[i][l - 1].size(); ++m ){
							data[i][l].push_back( wh = WH( data[i][l - 1][m].first + 1, 1 ) );
							data_max = std::max( data_max, wh.first * wh.second );
						}

					}else data[i][l].push_back( wh = WH( 1, 1 ) ), data_max = std::max( data_max, wh.first * wh.second );
				}	
			}
		}

		std::cout << data_max << std::endl;
 	}
	return 0;
}

Measured memory_bytes: 5880
A, B, C, D = map(int, input().split())
dp = [[0]*(D+1) for _ in range(C+1)]
dp[A][B] = 1
mod = 998244353
for y in range(A, C+1):
    for x in range(B, D+1):
        if y==A and x==B:
            continue
        dp[y][x] = (dp[y-1][x]*x + dp[y][x-1]*y - dp[y-1][x-1]*(y-1)%mod*(x-1)) % mod
#for d in dp:
#    print(d)
print(dp[C][D])


Measured memory_bytes: 133888
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  int N;
  cin>>N;
  lint A[N+1];
  REP(i,N)cin>>A[i];
  A[N]=0;
  lint m=1000;
  lint k=0;
  REP(i,N){
    if(A[i+1]>A[i]){
      k+=m/A[i];
      m-=A[i]*(m/A[i]);
    }else if(A[i+1]<A[i]){
      m+=A[i]*k;
      k=0;
    }
    cerr<<m<<" "<<k<<endl;
  }
  cout<<m<<endl;
  return 0;
}


Measured memory_bytes: 3644
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

ll K, N;
ll A[200000];

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> K >> N;
    for(int i = 0; i < N; i++) cin >> A[i];
    ll ans = 1e12;
    for(int i = 0; i < N; i++){
        int j = (i+1)%N;
        ll tmp = A[j]-A[i];
        if(tmp < 0) tmp += K;
        ans = min(ans, K-tmp);
    }
    cout << ans << endl;
}

Measured memory_bytes: 1792
#include<stdio.h>

int main (){
	int N,i;
	scanf("%d",&N);
	float A[N];
	float sum = 0,value=0;
	for (i=0;i<N;i++){
		scanf("%f",&A[i]);
	}
	for (i=0;i<N;i++){
		sum=sum+(1/A[i]);
	}
	value = 1/sum;
	printf("%f\n",value);
	return 0;
}


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

using namespace std;

void abc_170a();

void abc_171a();

void abc_172a();

void abc_173a();

int main()
{
  //abc_170a();
  //abc_171a();
  //abc_172a();
  abc_173a();

}

void abc_170a()
{
  vector<int> x(5);
  for (int i = 0; i < 5; ++i) cin >> x[i];

  for (int i = 0; i < 5; ++i)
  {
    if (x[i] == 0)
    {
      cout << i + 1 << "\n";
      return;
    }
  }
}


void abc_171a()
{
  char c;
  cin >> c;

  if (c == tolower(c)) cout << "a\n";
  else cout << "A\n";
}

void abc_172a()
{
  int a;
  cin >> a;

  cout << a + a * a + a * a * a << "\n";
}

void abc_173a()
{
  int N;
  cin >> N;

  if (N % 1000) cout << 1000 - N % 1000 << "\n";
  else cout << "0\n";
}


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

int main()
{
  int N;
  cin >> N;
  vector<int> X(N);
  for (auto & x : X)
    cin >> x;
  auto P = static_cast<int>(accumulate(X.begin(), X.end(), 0.)/N + .5);
  int p = 0;
  for (const auto & x : X)
    p += (x - P)*(x - P);
  cout << p;
  return 0;
}


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


int main()
{
    int n,c;
    cin >> n >> c;
    int a=0,b;
    for(int i=0;i<c;i++){
        cin >> b;
        a+=b;
    }
    cout << (a-1)/(n+1)+1 << endl;
    return 0;
}



Measured memory_bytes: 3100
#include <math.h>
#include <stdlib.h>
#include <string.h>
#include <algorithm>
#include <array>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

int main() {
    int N,L[11],m=0,l=0;
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>L[i];
        m=max(m,L[i]);
        l=l+L[i];
    }
    if(l>2*m)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

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

int calculation(int a, int b, int *c){
	int i,x;
	x=1;
	if(1<=a&&a<=100){ //??¶?´?
		for(i=0;i<b;i++){ //?????????????¨????
			x=x*a;
		}
		*c=x;
		if(c!=NULL){ //NULL?????????
			return 0;
		}
		else{
			return (-1);
		}
	}
	else
	{
		return (-1);
	}
}

int main(){
	int a,b,c,r;
	scanf("%d",&a); //??\???
	b=3;
	r=calculation(a,b,&c);
	if(r==0){
	printf("%d\n",c); //??????
	return 0;
	}
	else
	{
		printf("over\n"); //?????????
		return 1;
	}
}

Measured memory_bytes: 1768