akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++) 
#define fs first
#define sc second

// 1次元vectorの出力
template <class S>
void print(vector<S> &v) {
  for (ll i = 0; i < (ll)v.size(); i++) {
    cerr << v[i] << ' ';
  }
  cerr << endl;
}

// 2次元vectorの出力
template <class S>
void print(vector<vector<S>> &v) {
  for (ll i = 0; i < (ll)v.size(); i++) {
    for (ll j = 0; j < (ll)v[i].size(); j++) {
      cerr << v[i][j] << ' ';
    }
    cerr << endl;
  }
}

int main(void) {
	ll n;
	string s;
	cin >> n >> s;
	ll r=0; ll g=0; ll b=0;
    vector<ll> rp, bp, gp;
	vector<bool> rv(n,false);
	vector<bool> gv(n,false);
	vector<bool> bv(n,false);
    rep(j, n){
		char i = s[j];
		if (i == 'R'){r++; rp.push_back(j); rv[j]=true;}
		else if (i == 'G'){g++; gp.push_back(j); gv[j]=true;}
		else{b++; bp.push_back(j); bv[j]=true;}
	}
	if(r==0 || b==0 || g==0){
		cout << 0 << endl;
		return 0;
	}
	ll ans  = r*g*b;
	for(ll mid: rp){
		if(mid>0 && mid<n-1){
			for(ll left: gp){
				if(left >= mid) break;
				ll right = mid + mid - left;
				if(right < n){
				if(bv[right]){
					ans--;
				}}
			}
			for(ll left: bp){
				if(left >= mid) break;
				ll right = mid + mid - left;
				if(right < n){
				if(gv[right]){
					ans--;
				}}
			}
		}
	}
	for(ll mid: gp){
		if(mid>0 && mid<n-1){
			for(ll left: rp){
				if(left >= mid) break;
				ll right = mid + mid - left;
				if(right < n){
				if(bv[right]){
					ans--;
				}}
			}
			for(ll left: bp){
				if(left >= mid) break;
				ll right = mid + mid - left;
				if(right < n){
					if(rv[right]){
						ans--;
					}
				}
			}
		}
	}
	for(ll mid: bp){
		if(mid>0 && mid<n-1){
			for(ll left: gp){
				if(left >= mid) break;
				ll right = mid + mid - left;
				if(right < n){
				if(rv[right]){
					ans--;
				}}
			}
			for(ll left: rp){
				if(left >= mid) break;
				ll right = mid + mid - left;
				if(right < n){
				if(gv[right]){
					ans--;
				}}
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 3676
n = int(input())
h = list(map(int, input().split()))
dp = [10000] * n
dp[0] = 0
dp[1] = abs(h[1] -h[0])
if n > 2:
    for i in range(2,n):
        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]))
print(dp[n-1])

Measured memory_bytes: 13976
#define NDEBUG
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
const lint MOD = 998244353;
lint memo[301010];
int emod(lint x, lint p = MOD) {
  return (x % p + p) % p;
}
lint extgcd(lint a, lint b, lint& x, lint& y) {
  lint d = a;
  if (b != 0) {
    d = extgcd(b, a % b, y, x);
    y -= (a / b) * x;
  } else {
    x = 1; y = 0;
  }
  return d;
}
lint power(lint x, lint n, lint mod = numeric_limits<lint>::max()) {
  assert(n >= 0);
  if (n == 0) return 1;
  return power(x * x % mod, n / 2, mod) * (n % 2 ? x : 1) % mod;
}
lint inv(lint x, lint p = MOD) {
  assert((x %= p) != 0);
  return power(x, p - 2, p);
}
lint comb(lint n, lint r, lint mod = 0) {
  assert(n >= 0 and r >= 0);
  if (memo[r]) return memo[r];
  if (r > n) return 0;
  r = min(r, n - r);
  lint res = 1;
  if (mod) for (lint i = 0; i < r; i++) res = res * (n - i) % mod * inv(i + 1) % mod;
  else for (lint i = 0; i < r; i++) res = res * (n - i) / (i + 1);
  return memo[r] = memo[n - r] = res;
}
int main() {
  cin.tie(0); ios::sync_with_stdio(false);
  lint n, a, b, k; cin >> n >> a >> b >> k;
  lint x, y;
  lint d = extgcd(a, b, x, y);
  if (k % d) {
    cout << 0 << '\n';
    return 0;
  }
  k /= d; a /= d; b /= d;
  d = extgcd(a, b, x, y);
  x *= k; y *= k;
  lint res = 0;
  memo[0] = memo[n] = 1;
  for (lint i = 0; i < n; i++) {
    memo[i + 1] = (n - i) * memo[i] % MOD * inv(i + 1) % MOD;
  }
  if (x <= 0) {
    y -= a * (abs(x) / b - 10);
    x += b * (abs(x) / b - 10);
    while (x < 0) {
      x += b; y -= a;
    }
    while (x <= n) {
      if (0 <= y and y <= n) res = (res + memo[x] * memo[y] % MOD) % MOD;
      x += b; y -= a;
    }
  } else {
    x -= b * (abs(y) / a - 10);
    y += a * (abs(y) / a - 10);
    while (y < 0) {
      y += a; x -= b;
    }
    while (y <= n) {
      if (0 <= x and x <= n) res = (res + memo[x] * memo[y] % MOD) % MOD;
      y += a; x -= b;
    }
  }
  cout << res << '\n';
  return 0;
}

Measured memory_bytes: 2560
import java.util.*;
import java.lang.*;
public class Main{
  public static void main(String args[]){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    int m=sc.nextInt();
    int a[]=new int[100];
    a[0]=0;
    a[1]=0;
    a[2]=3;
   
    int l=3;
    for(int i=3;i<100;i++){
      a[i]=a[i-1]+l;
      l=l+1;
    }
    if(n==1&&m==1){
      System.out.println("0");
    }
    else if(n==2&&m==1||n==1&&m==2){
      System.out.println("1");
    }
    else{
      int p=0,q=0;
      if(n>2){
        p=a[n-1];
    }
      if(m>2){
        q=a[m-1];
      }
      int k=0;
      k=p+q;
      System.out.println(k);
  }
    
}}


Measured memory_bytes: 23636
n, k = map(int,input().split())

nums = [0]*(10**5+1)

for i in range(n):
    a, b = map(int,input().split())
    nums[a] += b
    
now = 0
for i,n in enumerate(nums):
    now += n
    if now >= k:
        print(i)
        break

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

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

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

	if (s[2] == s[3] && s[4] == s[5]) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	cin.get();
    cin.get();
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<bits/stdc++.h>
#define ll long long int
#define hell 1000000007LL
using namespace std;
ll power(ll x, ll y){ 
    if(y==0)
     return 1;
    else
    {
        ll p=power(x,y/2);
        if(y%2==0)
         return (p*p)%hell;
        else
        return (x*((p*p)%hell))%hell;
    }}
ll gcd(ll x,ll y)
{
    if(y==0)
     return x;
    else
    return gcd(y,x%y);
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(20);
   ll n,s=0;
   cin>>n;
   ll a[n];
   map<ll,ll>mp;
   for(int i=0;i<n;i++)
   {
       cin>>a[i];
       s=s+a[i];
       mp[a[i]]++;
   }
   ll q;
   cin>>q;
   while(q--)
   {
       ll b,c;
       cin>>b>>c;
       if(mp[b]>0)
       {
           ll x=(c-b)*mp[b];
           mp[c]=mp[c]+mp[b];
           mp[b]=0;
           s=s+x;
       }
       cout<<s<<"\n";
   }}
   

Measured memory_bytes: 10124
#include <stdio.h>
#define MAX 100

int BubbleSort(int A[],int N){

  int flag =1;
  int i;
  int cnt=0;
  
  while(flag){
    flag =0;
    for(i=N-1; i>0; i--){
      if(A[i] < A[i-1]){
        int tmp;
        tmp = A[i];
        A[i] = A[i-1];
        A[i-1] = tmp;
        cnt++;
        flag=1;
      }
    }
  }
  return cnt;
}


int main(){
  int N;
  int A[MAX];
  int ans,i;

  scanf("%d",&N);
  for(i=0; i<N; i++) scanf("%d",&A[i]);

  ans = BubbleSort(A,N);
  for(i=0; i<N; i++){
    if(i !=0) printf(" ");
    printf("%d",A[i]);
  }
  printf("\n");
  printf("%d\n",ans);

  return 0;
}



Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;
#define int long long   // <-----!!!!!!!!!!!!!!!!!!!

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(a)-1;i>=b;i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define printV(_v) for(auto _x:_v){cout<<_x<<" ";}cout<<endl
#define printVS(vs) for(auto x : vs){cout << x << endl;}
#define printVV(_vv) for(auto _v:_vv){for(auto _x:_v){cout<<_x<<" ";}cout<<endl;}
#define printP(p) cout << p.first << " " << p.second << endl
#define printVP(vp) for(auto p : vp) printP(p);
#define readV(_v) rep(j, _v.size()) cin >> _v[j];
#define readVV(_vv) rep(i, _vv.size()) readV(_vv[i]);
#define output(_x) cout << _x << endl;

typedef long long ll;
typedef pair<int, int> Pii;
typedef tuple<int, int, int> TUPLE;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<Pii> vp;
const int inf = 1e9;
const int mod = 1e9 + 7;

typedef complex<double> P;
typedef vector<P> G;
#define here(g, i) g[i]
#define next(g, i) g[(i + 1) % g.size()]
#define prev(g, i) g[(i - 1 + g.size()) % g.size()]
const double EPS = 1e-10;
const double INF = 1e12;
const double PI = acos(-1);

struct L {
    P a, b, v;
    L(){}
    L(P _a, P _b) : a(_a), b(_b), v(b - a) {}
    L(double _ax, double _ay, double _bx, double _by) : L(P(_ax, _ay), P(_bx, _by)) {}
};


double cross(P a, P b) {
    return imag(conj(a) * b);
}

double dot(P a, P b) {
    return real(conj(a) * b);
}

int ccw(P p0, P p1, P p2) {
    if (cross(p1 - p0, p2 - p0) > 0) return +1; // counter-clockwise
    if (cross(p1 - p0, p2 - p0) < 0) return -1; // clockwise
    if (dot(p1 - p0, p2 - p0) < 0) return +2;   // online_back
    if (dot(p0 - p1, p2 - p1) < 0) return -2;   // online_front
    return 0;                                   // on_segment
}

bool intersectSS(L l1, L l2) {
    return (ccw(l1.a, l1.b, l2.a) * ccw(l1.a, l1.b, l2.b) < 0 &&
            ccw(l2.a, l2.b, l1.a) * ccw(l2.a, l2.b, l1.b) < 0);
}

P crosspointSS(L l1, L l2) {
    double d1 = abs(cross(l2.v, l1.a - l2.a)); // l1.a - l2.b???
    double d2 = abs(cross(l2.v, l1.b - l2.a));
    double t = d1 / (d1 + d2);
    return l1.a + t * l1.v;
}

L readL() {
    double xa, ya, xb, yb;
    cin >> xa >> ya >> xb >> yb;
    return L(xa, ya, xb, yb);
}

int Count(vector<P> p) {
    int n = p.size();
    int ret = 0;
    rep(i, n) {
        bool flag = true;
        rep(j, i) {
            if (p[i] == p[j]) {
                flag = false;
                break;
            }
        }
        ret += flag;
    }
    return ret;
}

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

    int n;
    while (cin >> n, n) {
        int ans = 1;
        vector<L> l(n);
        rep(i, n) {
            l[i] = readL();
            vector<P> p;
            rep(j, i) {
                if (intersectSS(l[i], l[j])) {
                    p.emplace_back(crosspointSS(l[i], l[j]));
                }
            }
            ans += Count(p) + 1;
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 3272
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <numeric>

// 1 2 3 4
// 3 4 5 6 7 
// 4 - 11
// 

using namespace std;

using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)

const ll mod = 1000000007;

using namespace std;



int main() {
	int n, k;
	cin >> n >> k;
	ll low = 0;
	ll high = n;
	ll ans = 0;
	
	for (int i = 0; i <= n; i++) {
		//cout << "i:" << i;
		//cout << " low:" << low;
		//cout << " high:" << high;


		 
		if (i >= k - 1) {	
			ans = (ans + (high - low + 1 + mod) % mod) % mod;
			//cout << " ans:" << ans; 
		}
		//cout << endl;

		low = (low + (i + 1)) % mod;
		high = (high + n - i - 1 + mod) % mod;
	} 
	cout << ans << endl;

 	return 0;
}


Measured memory_bytes: 3196
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, a, a_sum = 0, b_sum = 0;

  cin >> N;
  vector<int> card(N);

  for (int i = 0; i < N; i++) {
    cin >> a;
    card.at(i) = a;
  }
  
  sort(card.begin(), card.end(), greater<int>());

  for (int i = 0; i < N; i++) {
    if (i == 0 || i % 2 == 0) {
      a_sum += card.at(i);
    }
    else {
      b_sum += card.at(i);
    }
    
  }
    cout <<  a_sum - b_sum << endl;
}


Measured memory_bytes: 3636
N = int(input())
A = [int(input()) for _ in range(N)]
i = 0
done = {a - 1: False for a in A}
num = 0
while True:
    i = A[i] - 1
    num += 1
    if i == 1:
        print(num)
        exit()
    if done[i]:
        print(-1)
        exit()
    done[i] = True

Measured memory_bytes: 19104
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPR(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, m, n) for(int i=m; i<n; i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(x) ll(x.size()) 
using P = pair<int, int>;
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 INF = 2e9;
const ll LINF = (1LL<<60);

template <typename T> inline
map<T, int> prime_factor(T n) {
  map<T, int> ret;
  for(T i = 2; i * i <= n; i++) {
    while(n % i == 0) {
      ret[i]++;
      n /= i;
    }
  }
  if(n != 1) ret[n] = 1;
  return ret;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n; cin >> n;
  vector<int> a(n);
  vector<map<int, int>> fac(n);
  REP(i,n){ 
    cin >> a[i];
    fac[i] = prime_factor(a[i]);
  }

  map<int, int> lc;
  map<int, int> tm;
  REP(i,n){
    for(auto [num, cnt]: fac[i]){
      chmax(lc[num], cnt);
      tm[num] += cnt;
    }
  }
  bool pw = true;
  for(auto [num, cnt]: tm){
    if(lc[num]!=cnt) pw = false;
  }
  if(pw){
    cout << "pairwise coprime\n";
    return 0;
  }

  int g = a[0];
  FOR(i,1,n) g = gcd(g, a[i]);
  if(g==1) cout << "setwise coprime\n";
  else cout << "not coprime\n";

  return 0;
}


Measured memory_bytes: 290468
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<map>
using namespace std;
char str[20][20];
map<vector<int>,int> dp[12][12];
int tb[20];
inline vector<int>conv(vector<int>a){
	vector<int>ret(a.size());
	for(int i=0;i<20;i++)tb[i]=-1;
	int ind=0;
	for(int i=0;i<a.size();i++){
		if(a[i]>=0){
			if(!~tb[a[i]]){
				tb[a[i]]=ind++;
			}
		}
	}
	for(int i=0;i<a.size();i++){
		if(a[i]<0)ret[i]=a[i];
		else ret[i]=tb[a[i]];
	}
	return ret;
}
char tmp[14][14];
int main(){
	int a,b;
	scanf("%d%d",&a,&b);
	for(int i=0;i<a;i++)scanf("%s",str[i]);
	if(b==1){
		for(int i=0;i<a;i++)for(int j=0;j<b;j++)tmp[j][i]=str[i][j];
		for(int i=0;i<b;i++)for(int j=0;j<a;j++)str[i][j]=tmp[i][j];
		swap(a,b);
	}
	vector<int>st;
	for(int i=0;i<b;i++){st.push_back(-2);}
	dp[0][0][st]=0;
	for(int i=0;i<a;i++){
		for(int j=0;j<b;j++){
			for(map<vector<int>,int>::iterator it=dp[i][j].begin();it!=dp[i][j].end();it++){
				vector<int>at=(*it).first;
				int cost=(*it).second;
			//	if(j==0){
		//		printf("(%d %d) ",i,j);
	//			for(int k=0;k<b;k++)printf("%d ",at[k]);
//				printf(": %d\n",cost);}
				// put #
				if(str[i][j]!='.'&&!(j&&at[0]>=0&&at[b-1]>=0&&at[0]==at[b-1])){
					vector<int>to=at;
					int val=to[b-1];
					int L=to[0];
					if(val<0||j==0)val=12;
					for(int k=0;k<to.size();k++){
						if(to[k]>=0&&to[k]==L)to[k]=val;
					}
					to.erase(to.begin());
					to.push_back(val);
					to=conv(to);
					if(dp[i][j+1].count(to))dp[i][j+1][to]=max(dp[i][j+1][to],cost+1);
					else dp[i][j+1][to]=cost+1;
				}
				// put .
				if(str[i][j]!='#'&&at[0]!=-1&&(j==0||at[b-1]!=-1)){
					vector<int>to=at;
					bool dame=true;
					if(to[0]<0)dame=false;
					for(int k=1;k<b;k++){
						if(to[k]==to[0])dame=false;
					}
					if(!dame){
						to.erase(to.begin());
						to.push_back(-1);
						to=conv(to);
						if(dp[i][j+1].count(to))dp[i][j+1][to]=max(dp[i][j+1][to],cost);
						else dp[i][j+1][to]=cost;
					}
				}
			}
		}
		dp[i+1][0]=dp[i][b];
	}
	int ret=-999999999;
	for(map<vector<int>,int>::iterator it=dp[a][0].begin();it!=dp[a][0].end();it++){
		vector<int>at=(*it).first;
		int cost=(*it).second;
	//	for(int i=0;i<b;i++)printf("%d ",at[i]);printf(": %d\n",cost);
		bool ok=true;
		for(int i=0;i<b;i++)if(at[i]>=1)ok=false;
		if(ok)ret=max(ret,cost);
	}
	if(ret<-999999)printf("-1\n");
	else printf("%d\n",ret);
}

Measured memory_bytes: 44492
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
	int a, b;
	cin >> a>> b;
	cout<< (a + b) % 24 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
int a,b,c,d;
cin>>a>>b>>c>>d;
if(abs(a-c)<=d)cout<<"Yes";
else if(abs(a-b)<=d&&abs(b-c)<=d)cout<<"Yes";
else cout<<"No";
return 0;
}

Measured memory_bytes: 256
// https://www.acmicpc.net/blog/view/22
// sort stl 사용방법 및 class operator 재정의 방법
// strlen

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>

using namespace std;

int strlen(char* ch) {
	int cnt = 0;
	while (*ch != 0) { ch++, cnt++; }
	return cnt;
}

class string {
public:
	char str[11] = { 0, };
	int len;
	string() {}
	string(char input[]) {
		len = strlen(input);
		for (int i = 0; i < len; i++)
			str[i] = input[i];
	}
	bool operator<(string b) {
		for (int i = 0; i < 11; i++) {
			if (str[i] < b.str[i]) return 1;
			else if (str[i] > b.str[i]) return 0;
		}

		return 0;
	}
	bool operator==(string b) {
		if (strlen(b.str) != len) return 0;
		for (int i = 0; i < len; i++) {
			if (str[i] != b.str[i]) return 0;
		}

		return 1;
	}

};

int n;
string dat[200001];


int main(void) {
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		char ch[11];
		scanf("%s", &ch);
		dat[i] = string(ch);
	}
//	sort(dat, dat + n, cmp);
	sort(dat, dat + n);
	printf("\n");
	int cnt[200001] = { 0, }, max = 0;
	for (int i = 0; i < n-1; i++) {
		if (dat[i] == dat[i + 1]) {
			cnt[i+1] = cnt[i]+1;
			if (max < cnt[i+1]) max = cnt[i+1];
		}
		else cnt[i+1] = 0;
	}

	for (int i = 0; i < n; i++) {
		if (cnt[i] == max) {
			printf("%s\n", dat[i].str);
		}
	}

	

	return 0;
}

Measured memory_bytes: 5760
#include<bits/stdc++.h> 
typedef long long ll;
using namespace std;
const ll mod =998244353; 
inline ll read(){
	ll x=0,f=1;char ch=getchar();
	while(ch>'9'||ch<'0'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
	return x*f;
}
ll n,k,x;
int main(){
	int i,j;
    //freopen("a.in","r",stdin);
    n=read(),k=read();
    x=n/k;
    printf("%lld",min(min(abs(n-x*k),abs(n-x*k+k)),abs(n-x*k-k)));
}

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

int sum(int num)
{
	return (num*(num+1))/2;
}

int main() {
    //code
    int n,l;
  	cin >> n >> l;
  	if(l>=0)
    {
      	cout << sum(n+l-1)-sum(l) << endl;
    }
  else
  {
    	if(n+l>=1)
          cout << sum(n+l-1)-sum(-l) << endl;
    	else
          cout << -(sum(-l)-sum(-l-n+1)) << endl;
  }
    return 0;
}

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

constexpr int inf = 1e9;

int main() {
    vector<int> a(5);
    for(int i = 0; i < 5; ++i) cin >> a[i];
    sort(begin(a), end(a));
    int ans = inf;
    do {
        int cur = 0;
        for(int i = 0; i < 5; ++i) {
            cur = (cur + 9) / 10 * 10;
            cur += a[i];
        }
        ans = min(ans, cur);
    } while(next_permutation(begin(a), end(a)));
    cout << ans << endl;
}

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

#import numpy as np
#import math, string, itertools, fractions, heapq, collections, re, array, bisect, copy, functools, random
from collections import deque, defaultdict, Counter
#from heapq import heappush, heappop
#from itertools import permutations, combinations, product, accumulate, groupby
#from bisect import bisect_left, bisect_right, insort_left, insort_right
#from operator import itemgetter as ig

sys.setrecursionlimit(10 ** 7)
#nf = 10 ** 20
#INF = float("INF")
#mod = 10 ** 9 + 7

'''
dd = [(-1, 0), (0, 1), (1, 0), (0, -1)]
ddn = dd + [(-1, 1), (1, 1), (1, -1), (-1, -1)]
ddn9 = ddn + [(0, 0)]
for dx, dy in dd:
        nx = j + dx; ny = i + dy
            if 0 <= nx < w and 0 <= ny < h:


def wi(): return list(map(int, sys.stdin.readline().split()))
def wip(): return [int(x) - 1 for x in sys.stdin.readline().split()]  # WideIntPoint
def ws(): return sys.stdin.readline().split()
def si(): return int(sys.stdin.readline())  # SingleInt
def ss(): return input()
def hi(n): return [si() for _ in range(n)]
def hs(n): return [ss() for _ in range(n)]  # HeightString
def s_list(): return list(input())
def mi(n): return [wi() for _ in range(n)]  # MatrixInt
def mip(n): return [wip() for _ in range(n)]
def ms(n): return [ws() for _ in range(n)]
def num_grid(n): return [[int(i) for i in sys.stdin.readline().split()[0]] for _ in range(n)]  # NumberGrid
def grid(n): return [s_list() for _ in range(n)]
 深さ優先探索
def dfs(G, v):
    global time, first_order,seen,last_order
    time += 1
    first_order[v-1] = time   #　行きがけ

    seen[v-1] = True # v を訪問済みにする
    # v から行ける各頂点 next_v について
    for next_v in G[v]:
        if seen[next_v-1]:
            continue
        dfs(G, next_v)

    time += 1
    last_order[v - 1] = time  # 帰りがけ
'''

N, Q = map(int,input().split())
G = defaultdict(list)
for i in range(1, N):
    a, b = map(int,input().split())
    G[a].append(b)
    G[b].append(a)

P = [0] * N
for i in range(Q):
    a, b = map(int,input().split())
    P[a-1] += b


def dfs(v,p=-1):

    # v からいける各頂点 next_v について
    for next_v in G[v]:
        if next_v == p:
            continue
        P[next_v-1] += P[v-1]
        dfs(next_v, v)

dfs(1)
print(*P)

'''
if __name__ == '__main__':
    main()
'''

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

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VD = vector<double>;
using VVD = vector<VD>;
using VS = vector<string>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VL = vector<long long>;
using VVL = vector<VL>;

#define sz(var) (int)var.size()
#define REP(var, start, end) for(int var = start; var < (int)end; ++var)
#define CLEAR(var, with) memset(var, with, sizeof(var))
#define ALL(x) x.begin(), x.end()
#define LL long long
#define ULL unsigned long long

int n, a[101];
int getcolour(int rating)
{
	return rating / 400;
}
void minmax()
{
	VB used(8, false);

	int grandmaster = 0;
	for(int i = 0; i < n; ++i)
	{
		if(a[i] >= 3200) {
			++grandmaster;
			continue;
		}
		int col = getcolour(a[i]);
		used[col] = true;
	}

	int mincolor = count(ALL(used), true);
	cout << max(1, mincolor) << " ";

	int available = 0;
	for(int i = 0; i < n; ++i)
		if(!used[i]) ++available;

	cout << mincolor + min(grandmaster, available) << endl;
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	//freopen("tmp.in", "r", stdin);
//	freopen("tmp.out", "w", stderr);
#endif
	cin >> n;

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

	minmax();

	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iomanip>
#include <list>
#include <vector>
#include <iostream>
#include <fstream>
#include <sstream>
#include <map>
#include <set>
#include <deque>

using namespace std;

namespace SP1 {
	bool ab(int a, int b) {
		return (a + b == 15) || (a*b == 15);
	}
}

namespace SP2 {
}

namespace SP3 {
}

namespace SP4 {
}

namespace SP5 {
}

int main()
{
	ifstream ifp("c:\\temp\\small-practice.in");
	ofstream ofp("c:\\temp\\res.out");
	istream & input = cin;
	ostream & output = cout;


	// p1
	if ( false)
	{
		int a, b;
		input >> a;
		input >> b;
		if (a + b == 15)
			output << "+";
		else if (a * b == 15)
			output << "*";
		else
			output << "x";
	}

	// p2
	if(false)
	{
		string s;
		int w;
		input >> s;
		input >> w;

		stringstream ss;
		ss << s[0];
		for (int i = 1; i < s.length(); i++) {
			if ((i % w) == 0)
				ss << s[i];
		}

		output << ss.str();
	}

	// p3
	{
		int m, d;
		float n;
		input >> n;
		input >> m;
		input >> d;

		float chanceOf2 = (n - (2 * d)) / n;
		if (d == 0)
			chanceOf2 = 0;
		float p = 1 / n * (1 - chanceOf2) + 1 / (n / 2) * chanceOf2;
		float res = p * (m - 1);
		output << fixed << showpoint << std::setprecision(20) << res;
	}

    return 0;
}



Measured memory_bytes: 256
#include <vector>
#include <map>
#include <set>
#include <cmath>
#include <iostream>
#include <algorithm>

typedef char                SINT8;
typedef unsigned char       UINT8;
typedef short               SINT16;
typedef unsigned short      UINT16;
typedef int                 SINT32;
typedef unsigned int        UINT32;
typedef long long           SINT64;
typedef unsigned long long  UINT64;
typedef double              DOUBLE;

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)>(0)?(a):-(a))
#define rep(i,a,b) for(int (i)=int(a);(i)<int(b);(i)++)

#define INF 1e9;
#define MOD 1e9+7;
#define INF64 1e18;


using namespace std;

int main() {

	SINT32 A,B,K;
	cin >> A>>B>>K;
	set<SINT32> DATA;
	
	rep(i,A,MIN(B+1,A+K)) {
		DATA.insert(i);		
	}
	

	rep(i,MAX(A,B-K+1),B+1) {
		DATA.insert(i);	
	}

	set<SINT32>::iterator it; //  イテレータを用意
	it = DATA.begin();
	rep (i,0,DATA.size()) {
		cout << *it << endl;
		it++;
	}

	return 0;
}

//	sort(DATA.begin(),DATA.end());
//	sort(DATA.begin(),DATA.end(),std::greater<SINT32>());
//	__gcd(ANS,DATA[i]);

//	// DATA.emplace_back(BUF);	//後ろに追加

//  DATA.erase(std::unique(DATA.begin(), DATA.end()), DATA.end());	//ソート後に使用

//	DATA.insert(DATA.begin() + X, 0);	//X番目の要素に0を挿入


//	vector<vector<SINT32>> DP(N,vector<SINT32>(3));　//2次元配列

/*
	SINT32 M = 3;
	vector<pair<SINT32,SINT32>> DATA2(M);
	for (SINT32 i = 0; i < M; i++) {
		cin >> DATA2[i].first;
		cin >> DATA2[i].second;
	}
	sort(DATA2.begin(),DATA2.end());
	cout << DATA2[0].first << endl;
	cout << DATA2[0].second << endl;
*/

// 	vector<pair<int,pair<int,int>>> DATA(M);
//	cin >> DATA[i].first;
//	cin >> DATA[i].second.first;
//	cin >> DATA[i].second.second;


//		APOSI = lower_bound(ADATA.begin(),ADATA.end(),QDATA[i]) - ADATA.begin();
//		BPOSI = lower_bound(BDATA.begin(),BDATA.end(),QDATA[i]) - BDATA.begin();


/* 文字列回転
	string N;
	cin >> N;
	N = N[N.length()-1] + N.substr(0,N.length()-1);
*/

/* SET コンテナ
	set<SINT32> DATA;
	for (SINT32 i = 0; i < N; i++) {
		SINT32 buf;
		cin >> buf;
		DATA.insert(buf);
	}

	//全表示
    set<string>::iterator it; //  イテレータを用意
    for(it = DATA.begin(); it != DATA.end(); it++) {
        cout << *it << endl;
    }

	//N番目を一部表示
	set<string>::iterator it; //  イテレータを用意
	it = DATA.begin();
	rep (i,0,N) {
		it++;
	}
	cout << *it << endl;
*/

/* map
	map<string,SINT32> mp;
	SINT32 N = 0;
	SINT32 mx = 0;

	cin >> N;
	for (SINT32 i = 0; i < N; i++) {
		string s;
		cin >> s;
		mp[s]++;
	}
	for(auto it=mp.begin();it!=mp.end();it++) {
		mx=max(mx,it->second);
	}

*/

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define eps 1e-9
using namespace std;

int main(int argc, char *argv[]){
  double d, a = 0;
  cin >> d;
  int y = d;
  double r = sqrt(2)*d;
  std::cout << setprecision(12) << max(r, y + max(1.0, sqrt(d*d - y*y))) << std::endl;
  return 0;
}

Measured memory_bytes: 1280
#include<cstdio>
int main(){
	char s[100]={};
	scanf("%s",s);
	int x;
	for(int i=0;i<100;i++){
		if(s[i]==0){
			x=i;
			break;
		}
	}
	for(int i=0;i<=x-9;i++){
		printf("%c",s[i]);
	}
	printf("\n");
	return 0;
} 

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

static const int MAX = 100000;
int A[MAX+1];
int main(){
  int N;
  cin >> N;

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

  sort(A,A+N);

  int count = 1,number = A[0],ret = 0;
  for(int i=1;i<N;i++){
    if(number != A[i]){
      if(count%2 == 1) ret++;
      count = 1;
      number = A[i];
    }else{
      count++;
    }
  }
  if(count%2 == 1)ret++;
  cout << ret << endl;
}

Measured memory_bytes: 640
n,t=map(int,input().split())
a=list(map(int,input().split()))
a.append(10**10)
cnt=0
for i in range(n):
  fir=a[i]
  if a[i]+t>a[i+1]:
    las=a[i+1]
  else:
    las=a[i]+t
  cnt+=las-fir
print(cnt)

Measured memory_bytes: 26708
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <stack>

using namespace std;

bool passed[100000];

char kind;

string dfs(string str){
	if(str=="")
		return str;
	stack<int> s;
	for(int i = 0; i < str.size(); i++){
		if(str[i]=='('){
			s.push(1);
		}
		else if(str[i]==')'){
			s.pop();
		}
		else if(str[i]==','){
			if(s.size()==1){
				return '(' + dfs(str.substr(1,i-1)) + ',' + dfs(str.substr(i+1,str.size()-i-2)) + ')';
			}
		}
	}
}
string dfsi(string str,string str2){
	if(str==""||str2=="")
		return "";
	stack<int> s;

	int idx1=-1;
	int idx2=-1;
	for(int i = 0; i < str.size(); i++){
		if(str[i]=='('){
			s.push(1);
		}
		else if(str[i]==')'){
			s.pop();
		}
		else if(str[i]==','){
			if(s.size()==1){
				idx1=i;
				break;
			}
		}
	}
	s=stack<int>();
	for(int i = 0; i < str2.size(); i++){
		if(str2[i]=='('){
			s.push(1);
		}
		else if(str2[i]==')'){
			s.pop();
		}
		else if(str2[i]==','){
			if(s.size()==1){
				idx2=i;
				break;
			}
		}
	}
	return '(' + dfsi(str.substr(1,idx1-1),str2.substr(1,idx2-1)) + ',' 
		+ dfsi(str.substr(idx1+1,str.size()-idx1-2),str2.substr(idx2+1,str2.size()-idx2-2)) + ')';
}

string dfsu(string str,string str2){
	if(str==""&&str2=="")
		return "";
	stack<int> s;

	int idx1=-1;
	int idx2=-1;
	if(str!=""){
		for(int i = 0; i < str.size(); i++){
			if(str[i]=='('){
				s.push(1);
			}
			else if(str[i]==')'){
				s.pop();
			}
			else if(str[i]==','){
				if(s.size()==1){
					idx1=i;
					break;
				}
			}
		}
	}
	if(str2!=""){
		s=stack<int>();
		for(int i = 0; i < str2.size(); i++){
			if(str2[i]=='('){
				s.push(1);
			}
			else if(str2[i]==')'){
				s.pop();
			}
			else if(str2[i]==','){
				if(s.size()==1){
					idx2=i;
					break;
				}
			}
		}
	}
	if(idx1==-1&&idx2!=-1){
		return '(' + dfs(str2.substr(1,idx2-1)) + ',' 
		+ dfs((str2.substr(idx2+1,str2.size()-idx2-2))) + ')';
	}
	else if(idx1!=-1&&idx2==-1){
		return '(' + dfs(str.substr(1,idx1-1)) + ','
		+ dfs((str.substr(idx1+1,str.size()-idx1-2))) + ')';
	}
	return '(' + dfsu(str.substr(1,idx1-1),str2.substr(1,idx2-1)) + ',' 
		+ dfsu(str.substr(idx1+1,str.size()-idx1-2),str2.substr(idx2+1,str2.size()-idx2-2)) + ')';
}



int main(){

	string str1,str2;
	while(cin>>kind>>str1>>str2){
		//string st=dfs(str1);
		//dfs(str2);
		string st;
		if(kind=='i')
			st=dfsi(str1,str2);
		else{
			st=dfsu(str1,str2);
		}
		cout<<st<<endl;
	}

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <vector>

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

int main()
{
  int L, R, d;
  cin >> L >> R >> d;

  cout << R / d - ((L - 1) / d) << endl;

  return 0;
}


Measured memory_bytes: 3616
import java.util.Scanner;

public class Main 
{
	public static void main(String[] args)
	{
		Scanner scanner = new Scanner(System.in);
		
		int n = scanner.nextInt();
		int[] x = new int[n];
		int[] y = new int[n];
		
		for(int i=0; i<n; i++)
		{
			x[i] = scanner.nextInt();
		}
		for(int i=0; i<n; i++)
		{
			y[i] = scanner.nextInt();
		}
		
		double d1 = 0;
		for(int i=0; i<n; i++)
		{
			d1 += Math.abs(x[i] - y[i]);
		}
		System.out.printf("%1$.6f\n", d1);
		
		double d2 = 0;
		for(int i=0; i<n; i++)
		{
			d2 += (x[i] - y[i]) * (x[i] - y[i]);
		}
		System.out.printf("%1$.6f\n", Math.sqrt(d2));
		
		double d3 = 0;
		for(int i=0; i<n; i++)
		{
			d3 += Math.abs((x[i] - y[i]) * (x[i] - y[i]) * (x[i] - y[i]));
		}
		System.out.printf("%1$.6f\n", Math.cbrt(d3));
		
		double dp = 0;
		for(int i=0; i<n; i++)
		{
			double d = Math.abs(x[i] - y[i]);
			if(dp < d )
			{
				dp = d;
			}
		}
		System.out.printf("%1$.6f\n", dp);
	}
}

Measured memory_bytes: 26516
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <stdbool.h>
typedef long long ll;
#define rep(i,n) for(ll i=0; i<(ll)(n); i++)
#define max(l,r) ((l)>(r)?l:r)
#define min(l,r) ((l)<(r)?l:r)
#define swap(l,r) {ll tp=l;l=r;r=tp;}
const ll MOD = 1000000007;

int main(){
    char s[5];
    scanf("%s", &s);

    int tmp = 0, ans = 0;
    if(s[0] == 'R') {
        if(s[1] == 'R'){
            if(s[2] == 'R'){
                ans = 3;
            }else {
                ans = 2;
            }
        }else{
            ans = 1;
        }
    }else{
        if(s[1] == 'R'){
            if(s[2] == 'R'){
                ans = 2;
            }else {
                ans = 1;
            }
        }else{
            if(s[2] == 'R'){
                ans = 1;
            }else {
                ans = 0;
            }
        }
    }
    printf("%d", ans);
}

Measured memory_bytes: 1736
package main

import "fmt"

func main() {
	var (
		s string
		t string
	)

	fmt.Scan(&s, &t)

	count := 0
	for i := 0; i < len(s); i++ {
		if s[i:i+1] == t[i:i+1] {
			count++

		}
	}
	fmt.Println(count)
}


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

int main(){
    int ans[100];
    queue<int> row;
    int t = 0, cur = -1;
    vector<int> in(17, -1);
    while(cur != 99){
        // new customer
        if(t%5 == 0 && t < 500) row.push(t/5);

        // customer leaves
        for(int i = 0; i < 17; i++) if(t >= in[i]) in[i] = -1;

        // customer comes in
        while(!row.empty()){
            int next = row.front();
            int num = next%5==1 ? 5 : 2;
            int i;
            for(i = 0; i <= 17-num; i++){
                int vacant = 0;
                for(int j = 0; j < num; j++){
                    vacant += (in[i+j]==-1);
                }
                if(vacant == num){
                    break;
                }
            }
            if(i > 17-num)  break;
            // decide the position i
            row.pop();
            int tot = t + 17*(next%2)+3*(next%3)+19;
            for(int j = 0; j < num; j++){
                in[i+j] = tot;
            }
            ans[next] = t-next*5;
            cur = next;
        }

        // time passes
        t++;
    }

    int n;
    while(cin >> n)  cout << ans[n] << endl;
    return 0;
}


Measured memory_bytes: 3108
import sys
n = int(input())
txy = []
for i in range(n):
  txy.append(list(map(int, input().split())))
pt = 0
py = 0
px = 0
for t, x, y in txy:
  dt = t - pt
  dx = x - px
  dy = y - py
  ax = abs(dx) % 2
  ay = abs(dy) % 2
  a = (ax + ay) % 2
  if abs(dx) + abs(dy) > dt or a != dt % 2:
    print("No")
    sys.exit()
print("Yes")


Measured memory_bytes: 27324
#define REP(i, n) for(int i = 0; i < (int)(n); i++)

#include "bits/stdc++.h"
using namespace std;

int main() {
	
	int coin[] = {1, 6, 36, 216, 1296, 7776, 46656, 9, 81, 729, 6561, 59049};
	int N;
	cin >> N;
	vector<int> d(N + 1, 100000);

	for (int c : coin) {
		if (c <= N) {
			d[c] = 1;
		}
	}

	REP(i, N + 1) {
		for (int c : coin) {
			if (c <= i) {
				d[i] = min(d[i], 1 + d[i - c]);
			}
		}
		//cout << i << "," << d[i] << endl;
	}

	cout << d[N] << endl;

	return 0;

}


Measured memory_bytes: 640
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<sstream>
#include<stack>
#include<string>
#include<unordered_set>
#include<vector>

#define ll long long
#define P pair<int,int>
#define FOR(i,N) for(int i=0;i<(int)N;i++)
#define FORIN(i,a,b) for(int i=a;i<(int)b;i++)
#define ALL(x) (x).begin(),(x).end()
#define LAST(x) (x)[(x).size()-1]
#define GI(name) int (name);scanf("%d",&(name))
#define GI2(name1,name2) int (name1),(name2);scanf("%d %d",&(name1),&(name2))
#define GI3(name1,name2,name3) int (name1),(name2),(name3);scanf("%d %d %d",&(name1),&(name2),&(name3))
#define GVI(name,size) vector<int> (name)(size);FOR(i,(size)scanf("%d",&(name)[i])

using namespace std;

string to_hex(int x){
    stringstream ss;
    ss<<hex<<x;
    return ss.str();
}

inline int get_int(){
    int ret;
    scanf("%d",&ret);
    return ret;
}

inline vector<int> get_ints(int n){
    vector<int> ret(n);
    FOR(i,n){
        scanf("%d",&ret[i]);
    }
    return ret;
}

inline string get_str(){
    string ret;
    cin>>ret;
    return ret;
}

bool is_prime(int n){
    int s=sqrt(n)+1;
    for(int i=2;i<=s;++i){
        if(n%i==0){
            return 0;
        }
    }
    return 1;
}

vector<P> prime_division(int n){
    vector<P> ret;
    int s=sqrt(n)+1;
    int c=0;
    for(int i=2;i<=s;++i){
        if(n%i==0){
            c=0;
            do{
                ++c;
                n/=i;
            }while(n%i==0);
            ret.push_back(P(i,c));
        }
    }
    return ret;
}

string to_string(string s){
    return s;
}

template<class T>
string to_string(vector<T> v){
    string ret="{";
    FOR(i,v.size()-1){
        ret+=to_string(v[i])+",";
    }
    if(v.size()>0){
        ret+=to_string(LAST(v));
    }
    ret+="}";
    return ret;
}

void debug_print(){
    cerr<<endl;
}

template<class Head,class... Tail>
void debug_print(Head head,Tail... tail){
    cerr<<to_string(head)<<" ";
    debug_print(tail...);
}

template<class... T>
void debug(T... args){
    cerr<<"["<<__LINE__<<"]: ";
    debug_print(args...);
}

void print(){
    cout<<endl;
}

template<class Head,class... Tail>
void print(Head head,Tail... tail){
    cout<<to_string(head);
    print(tail...);
}

int main(){
    GI2(a,b);
    print((a*b)%2==1?"Odd":"Even");
    return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	n := nextInt()
	k := nextInt()

	total := 0
	for i := 0; i < n; i++ {
		h := nextInt()
		if h >= k {
			total ++
		}
	}

	fmt.Printf("%d", total)
}


Measured memory_bytes: 896
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));
        }

        public void Solve(ConsoleInput cin)
        {
            int a = cin.ReadInt;
            int b = cin.ReadInt;
            bool f = false;
            for (int i = 1; i <= 3; i++)
            {
                if ((a * b * i) % 2 != 0) f = true;
            }
            string ans;
            if (f)
            {
                ans = "Yes";
            }
            else ans = "No";
            Console.WriteLine(ans);


            }
    }
 

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}



Measured memory_bytes: 11220
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {

        Scanner sc = new Scanner(System.in);
        
        int N = sc.nextInt();
        int M = sc.nextInt();
        int[] a = new int[M];
        int[] b = new int[M];
        int[] ans = new int[N];
        
        for(int i = 0; i < M; i++){
            a[i] = sc.nextInt();
            b[i] = sc.nextInt();
        }
        
        for(int i = 1; i <= N; i++){
            for(int j = 0; j < M;  j++){
                if(i == a[j]) ans[i - 1]++; 
                if(i == b[j]) ans[i - 1]++;
            }
        }
        for(int i = 0; i < N; i++) System.out.println(ans[i]);
    }
}

Measured memory_bytes: 22996
import java.util.*;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt(),b = sc.nextInt(),c = 0;
        List<Integer> list = new ArrayList<>();
        for (int i = 0; i < a; i++)list.add(sc.nextInt());
        list = list.stream().sorted(Comparator.comparing(Integer::intValue)).collect(Collectors.toList());
        for (int i = 0; i < b; i++) c += list.get(i);
        System.out.println(c);
    }
}


Measured memory_bytes: 39476
#include<bits/stdc++.h>
using namespace std;
typedef  long long ll;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}

template<class T> ll llpow(T x,T n){ll ans=1;if(x==0)ans=0;while(n){if(n&1)ans*=x;x*=x;n>>=1;}return ans;}
template<class T> inline T gcd(T x,T y){if(y==0)return x; else {return gcd(y,x%y);}}
template<class T> inline T lcm(T x,T y){return x/gcd(x,y)*y;}

#define rep(i,n) for(ll i=0;i<(ll)n;i++)
#define rep2(i, begin_i, end_i) for (ll i = (ll)begin_i; i < (ll)end_i; i++)

long long INF = 1LL<<60;
int main(){
    int n;
    cin>>n;
    vector<int> a(n);
   rep(i,n)cin>>a[i];
   bool wh=true;
   rep(i,n){
       if(!(a[i]%2)){
           if((a[i]%3)&&(a[i]%5)){
               wh=false;
           }
       }
   }
   if(wh)
               cout<<"APPROVED"<<endl;
               else
               cout<<"DENIED"<<endl;
    return 0;
}




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

for i in range(n-k+1):
    xl = x[i]
    xr = x[i+k-1]
    if i==0:
        MIN = abs(xl-xr) + abs(xl)

    MIN = min(MIN, abs(xl-xr) + abs(xl))
    MIN = min(MIN, abs(xl-xr) + abs(xr))

print(MIN)

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

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

    int n, m;
    pair<int, int> clue[5];
    int range[] = {0, 10, 100, 1000};
    cin >> n >> m;
    for(int i=0;i<m;++i){
        int s, c;
        cin >> s >> c;
        clue[i] = {s, c};
    }
    for(int x=range[n-1];x<range[n];++x){
        int d[4], xx = x;
        for(int i=n;i>0;--i){
            d[i] = xx % 10;
            xx /= 10;
        }
        for(int i=0;i<m;++i){
            if(d[clue[i].first] != clue[i].second) goto l_ng;
        }
        cout << x << endl;
        return 0;
        l_ng:;
    }
    cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3
from itertools import product, permutations, combinations
from bisect import bisect_right,bisect_left
N=int(input())
A=sorted(list(map(int, input().split())))
B=sorted(list(map(int, input().split())))
C=sorted(list(map(int, input().split())))


ret = 0
for i in range(N):
    # 中段を決めた時、その値より小さくなる上段を探す
    new_A = bisect_left(A, B[i])
    # 中段を決めた時、その値より大きくなる下段を探す
    new_C = bisect_right(C, B[i])
    # 組み合わせ
    ret += new_A * (N - new_C)

print(ret)

Measured memory_bytes: 23456
#include<bits/stdc++.h>
using namespace std;
#define tezi ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL)
typedef long long ll;

int main(){
    tezi;
    ll pro = 1, n, flag = 0, big = 1e18;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; ++i){
        cin >> a[i];
    }
    sort(a.begin(), a.end());
    for(int i = 0; i < n; ++i){
        ll num = pro * a[i];
        if(num > big || num < pro){
            flag = 1;
            break;
        }
        pro = num;
    }
    if(a[0] == 0) pro = 0, flag = 0;
    if(flag == 0) cout << pro << "\n";
    else cout << "-1\n";
    return 0;
}


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

typedef long long i64;
const int MAXN = 1e5 + 10;

i64 answer;
int N, tmp;
int A[MAXN], B[MAXN];

multiset<int> a, b;

namespace disjointSet_map
{
	map<int, int> fa;

	void clear()
	{
		fa.clear();
	}

	void setCircle(int x)
	{
		fa[x] = x;
	}

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

	void merge(int x, int y)
	{
		fa[find(x)] = find(y);
	}
}

int main()
{
	cin >> N;

	for (int i = 1; i <= N; i++)
		cin >> A[i], A[0] ^= A[i];
	for (int i = 0; i <= N; i++)
		a.insert(A[i]);

	for (int i = 1; i <= N; i++)
		cin >> B[i], B[0] ^= B[i];
	for (int i = 0; i <= N; i++)
		b.insert(B[i]);

	if (a != b)
		return cout << "-1" << endl, 0;

	disjointSet_map::setCircle(A[0]);
	for (int i = 1; i <= N; i++)
		if (A[i] != B[i])
			disjointSet_map::setCircle(A[i]);

	for (int i = 1; i <= N; i++)
		if (A[i] != B[i])
			disjointSet_map::merge(A[i], B[i]), answer++;

	for_each(disjointSet_map::fa.begin(), disjointSet_map::fa.end(),
			[] (pair<int, int> x )
			{	answer += (x.first == x.second);});

	cout << answer - 1 << endl;

	return 0;
}


Measured memory_bytes: 24448
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define all(v) v.begin(), v.end()

const ll mod=1000000007;

ll countBits(ll in){
  int res=0;
  for(;in>0;in>>=1){
    if((in&0x01)!=0){
      res++;
    }
  }
  return res;
}

template<typename T>
void show2dVector(vector<vector<T>>& v){
  for(int i=0;i<v.size();i++){
    int m=v[i].size();
    cout<<i<<" : ";
    for(int j=0;i<m;i++){
      cout<<v[i][j]<<" ";
    }
    cout<<endl;
  }
}

void bfs(const vector<vector<int>>&g, int v, vector<bool>& seen){
  seen[v]=true;
  cout<<v<<" ";
  for(auto next: g[v]){
    if(seen[next]){
      continue;
    }
    bfs(g,next,seen);
  }
}

bool dfs(vector<vector<int>> &g,int start,int goal,vector<bool>&seen){
  bool res=false;
  seen[start]=true;
  if(start==goal){
    return true;
  }
  for(auto next: g[start]){
    if(seen[next]){
      continue;
    }
    res=dfs(g,next,goal,seen);
    if(res){
      break;
    }
  }
  return res;
}

ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}

ll powm(ll a,ll n, ll m){
  ll ret=1;
  while(n>0){
    if(n%2==1){
      ret=(ret*a)%m;
    }
    n>>=1;
    a=(a*a)%m;
  }
  return ret;
}

const string yesno(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  ll n,y;cin>>n>>y;
  ll ans[3]={-1,-1,-1};
  for(int a=0;a<=2000;a++){
    for(int b=0;b<=2000;b++){
      int c=n-a-b;
      if(c<0){
        continue;
      }
      int val=a*1000+b*5000+c*10000;
      if(val==y){
        ans[0]=a;
        ans[1]=b;
        ans[2]=c;
        cout<<ans[2]<<" "<<ans[1]<<" "<<ans[0]<<endl;
        return 0;
      }
    }
  }
  cout<<ans[2]<<" "<<ans[1]<<" "<<ans[0]<<endl;
  return 0;
}


Measured memory_bytes: 256