akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define ALL(c) (c).begin(), (c).end()
#define pb push_back
#define eb emplace_back
const long long INF = 1LL<<60; // 仮想的な無限大の値;
using namespace std;
using ll = long long;
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; }

int main()
{
    int a;
    cin >> a;
    cout << a + a*a + a*a*a << endl;
    return 0;
}

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

#undef int
int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
#define int long long int
	ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
	int t = 1;
	//cin >> t;
	while (t--) {
		char c;
		cin >> c;
		if ((int)c >= 65 && (int)c <= 90)
			cout << "A" << endl;
		else
			cout << "a" << endl;

	}
	return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <algorithm>
#include <list>
#include <iomanip>
#include <string>
#include <cctype>
#include <cstdio>
#include <cmath>

using namespace std;

int main() {
  int N,M,kikan=0;
  cin>>N>>M;
  for(int i=0;i<M;i++){
    int a;
    cin>>a;
    kikan+=a;
  }
  if(N<kikan)
    cout<<-1<<endl;
  else
    cout<<N-kikan<<endl;
}

Measured memory_bytes: 3592
import sys
from itertools import permutations

from scipy.sparse.csgraph import floyd_warshall

input = sys.stdin.readline

N, M, R = map(int, input().split())
r = [int(x) - 1 for x in input().split()]

g = [[float('inf')] * N for _ in range(N)]
for i in range(M):
    A, B, C = map(int, input().split())
    g[A - 1][B - 1] = C
    g[B - 1][A - 1] = C

dist = floyd_warshall(g, directed=False)
ans = float('inf')
for route in permutations(r):
    res = 0
    for i in range(R - 1):
        res += dist[route[i]][route[i + 1]]
    ans = min(ans, int(res))
print(ans)


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



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector< vector<ll> > vvint;
typedef pair<ll, ll> pint;


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



void print(const vint& v)
{
  for(int i=0; i+1<v.size(); ++i){
    std::cout << v[i] << " ";
  }
  cout<<v.back()<<endl;
}

ll selectionSort(vint &a){
  ll n = a.size();
  ll cnt = 0;

  rep(i, n){
    ll minj = i;
    for(ll j=i; j<n; ++j){
      if(a[j] < a[minj]){
        minj = j;
      }
    }
    swap(a[i], a[minj]);
    cnt += i!=minj;
  }

  return cnt;
}

int main() {


  cout<<fixed<<setprecision(10);

  ll n; cin>>n;
  vint a(n); rep(i,n) cin>>a[i];

  ll cnt = selectionSort(a);
  print(a);
  cout<<cnt<<endl;


}





//




Measured memory_bytes: 3108
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<string.h>
#include<stdbool.h>
typedef long long ll;
typedef long double ld;
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
#define repp(i,l,r,k)for(ll i=(l);i<(r);i+=(k))
#define rrep(i,l,r)for(ll i=(l);i>=(r);i--)
#define INF (1LL<<60)
#define MOD1 1000000007
#define MAX_N (1 << 17)
#define YES printf("Yes\n")
#define NO printf("No\n")
#define PN printf("\n")



void swap(ll *a, ll *b){ll c;c=*b;*b=*a;*a=c;}
ll max2(ll a,ll b){return a>=b?a:b;}
ll min2(ll a,ll b){return a>=b?b:a;}
ll min3(ll a, ll b, ll c){return (a<=b && a<=c) ? a : b<=c ? b : c;}
ll max3(ll a, ll b, ll c){return (a>=b && a>=c) ? a : b>=c ? b : c;}
ll minn(ll n, ll a[n]){ll b=INF;rep(i,0,n) b=min2(b,a[i]);return b;}
ll maxn(ll n, ll a[n]){ll b=-INF;rep(i,0,n) b=max2(b,a[i]);return b;}
ll ABS(ll a){return a>=0?a:(-a);}
ll POW(ll a, ll b){ll c=1;rep(i,0,b) c*=a;return c;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
ll mod(ll n){return n%=MOD1;}
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
int downll(const void*a, const void*b){return*(ll*)a<*(ll*)b?1:*(ll*)a>*(ll*)b?-1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
void sortdown(ll*a,int n){qsort(a,n,sizeof(ll),downll);}

typedef struct{
    ll aa;
    ll bb;
}frequent;

int main(void){
    char s[30005];
    ll n,ans=0;
    scanf("%lld%s",&n,s);
    ll a[100]={},b[10]={},c[10]={};
    rep(i,0,n){
        b[(ll)s[i]-48]++;
    }
    // rep(i,0,10) printf("%lld ",b[i]);
    // PN;
    rep(i,0,10) c[i]=b[i];
    rep(i,0,n-2){
        c[((ll)s[i]-48)]--;
        rep(j,i+1,n-1){
            c[((ll)s[j]-48)]--;
            if( a[ ((ll)s[i]-48)*10+((ll)s[j]-48) ] == 0){
                a[ ((ll)s[i]-48)*10+((ll)s[j]-48) ] = 1;
                // rep(k,0,10) printf("%lld ",c[k]);
                // PN;
                rep(k,0,10){
                    ans+= c[k]>0 ? 1 : 0;
                }
                // printf("%lld ",ans);
            }
        }
        // PN;
        b[((ll)s[i]-48)]--;
        rep(j,0,10) c[j]=b[j];
    }
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int n,x;
	cin>>n>>x;
	int l[n+1],d[n];
	d[0]=0;
	int c=0;
	for(int i=0;i<n;i++){
		cin>>l[i];
		d[i+1]=d[i]+l[i];
		if(d[i+1]<=x)
			c++;
	}
	cout<<c+1;
	return 0;
}

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

using namespace std;

int main()
{
	int a, b, k;
	cin >> a >> b >> k;
	int z = __gcd(a, b);
	int count = 0;
	for(int i=z;i>=1;i--)
	{
		if(z%i == 0)
		{
			count++;
		}
		if(count == k)
		{
			cout << i << "\n";
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n); for(int i = 0;i < (int)(n);i++)
#define all(x) (x).begin(),(x).end()
typedef long long ll;
int main(){
    int n;
    cin >> n;
    vector<int>a(n);
    rep(i,n)cin >> a[i];
    int b = 0;
    rep(i,n)b = b^a[i];
    rep(i,n){
        int ans = b^a[i];
        cout << ans << endl;
    }
    return 0;
}

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

int main()
{

    double x1,y1,x2,y2;
    cin>>x1>>y1>>x2>>y2;

    cout << fixed << setprecision(15) << sqrt(pow(x2-x1,2)+pow(y2-y1,2)) << endl;

    return 0;
}  


Measured memory_bytes: 3296
#include <bits/stdc++.h>
using namespace std;
int main () {
  int N, M;
  cin >> N >> M;
  if(N == 1 && M == 1) cout << 1 << endl;
  else if(N == 1 && M != 1) cout << M - 2 << endl;
  else if(N != 1 && M == 1) cout << N - 2 << endl;
  else cout <<(long) (N - 2) * (M - 2)  << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void)
{
	int K, A, B;
	
	cin >> K;
	cin >> A >> B;
	
	for(int i=A;i <= B;i++)
	{
		if(i%K==0)
		{
			cout << "OK" << endl;
			return 0;
		}
	}
	cout << "NG" << endl;
			return 0;
}

Measured memory_bytes: 3632
#include <stdio.h>

int main()
{
  int a, b, c, d, x;

  scanf("%d %d %d %d", &a, &b, &c, &d);

  if (a < b) {
    x = a;
  } else {
    x = b;
  }

  if (c < d) {
    x += c;
  } else {
    x += d;
  }

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

  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
ll MOD=1000000007;
int inf=1000001000;
ll INF=100000000000000000;

int main() {
    int n;
    cin >> n;
    vector<ll> p(n);
    rep(i,n) cin >> p.at(i);
    vector<pair<ll,int>> a(n);
    rep(i,n){
        a.at(i).first=p.at(i);
        a.at(i).second=i+1;
    }
    sort(all(a));
    reverse(all(a));
    set<ll> s,t;
    s.insert(0);
    s.insert(0);
    t.insert(n+1);
    t.insert(n+1);
    ll ans=0;
    rep(i,n){
        ll f=a.at(i).first;
        int g=a.at(i).second;
        auto e=s.lower_bound(g);
        e--;
        ll x=*e;
        e--;
        ll y=*e;
        if (x==0) y=0;
        auto o=t.lower_bound(g);
        ll z=*o;
        ++o;
        ll w=*o;
        if (z==n+1) w=n+1;
        ans+=((x-y)*(z-g)+(g-(x))*(w-(z)))*f;
        s.insert(g);
        t.insert(g);
    }
    cout << ans << endl;
}


Measured memory_bytes: 11904
# cook your dish here

x,k,d=map(int,input().split())
x=abs(x)
f = x//d;

ans = 0

if(k<=f):
    ans = abs(x) - abs(k*d)
    
else:
    e =  (k - f)%2
    if(e==0):
        ans = x - f*d;
    else:
        ans = x - (f+1)*d;
            
    
print(abs(ans))  

Measured memory_bytes: 9044
#include <stdio.h>
int main()
{
  int a,b,c,d;
  scanf("%d%d%d",&a,&b,&c);
  if(a>b){d=a;a=b;b=d;}
  if(b>c){d=b;b=c;c=d;}
  if(a>b){d=a;a=b;b=d;}
  printf("%d %d %d\n",a,b,c);
  return 0;
}

Measured memory_bytes: 596
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
struct sp{
	char s[11];
	int index;
	int p;
};

int compare_p(const void *a, const void *b){
	struct sp *A = (struct sp *)a;
	struct sp *B = (struct sp *)b;
	return B->p - A->p;
}

int compare_s(const void *a, const void *b){
	struct sp *A = (struct sp *)a;
	struct sp *B = (struct sp *)b;
	char *a_s = (char *)A->s;
	char *b_s = (char *)B->s;
	int x = (a_s==b_s) ? 1 : strcmp(a_s, b_s);
	return strcmp(a_s, b_s);
}

int main(void){
	int n;
	scanf("%d", &n);
	struct sp sps[n];
	for(int i=0; i<n; i++){
		scanf("%s", sps[i].s);
		scanf("%d", &sps[i].p);
		sps[i].index = i+1;
	}
	qsort(sps, n, sizeof(struct sp), compare_p);
	qsort(sps, n, sizeof(struct sp), compare_s);
	for(int j=0; j<n; j++){
		printf("%d\n", sps[j].index);
	}
	return 0;
}


Measured memory_bytes: 128
#include <cstdio>
#include <iostream>
#include <set>
using namespace std;
int main()
{
  int n;
  scanf("%d",&n);
  if (n % 3)
  {
      printf("%d\n",n / 3);
  }else 
  {
      printf("%d\n", n / 3 );
  }
}

Measured memory_bytes: 256
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 k = sc.nextInt();
        boolean ans = false;
        int count = 0;
        
        for (int i = 1; i <= n; i += 2) {
            count++;
        }
        if (count >= k) {
            ans = true;
        }
        
        System.out.println(ans?"YES":"NO");
    }

}


Measured memory_bytes: 21716
#define _USE_MATH_DEFINES
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<ll, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<ll, ll> ll_ll;
typedef pair<double, double> d_d;
struct edge { int u, v; ll w; };

#define rep(i, N) for (int i = 0; i < N; i++)
#define pb push_back

ll MOD = 1000000007;
ll _MOD = 1000000009;
double EPS = 1e-10;

int f(int N, int x) {
	if (x) return (N + 1) / 2 * 2 - 1;
	else return N / 2 * 2;
}

int main() {
	int T; cin >> T;
	while (T--) {
		int N, x; cin >> N >> x;
		ll ans = 0;
		for (int z = 1; z < 128; z *= 2)
			ans += (ll)z * f(N, x & z);
		cout << ans << endl;
	}
}


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


int main()
{
    ll n,b, mx=0, cnt=0;
    string s;
    cin>>s;
    for(int i=0; i<s.size(); i++)
    {
        if(s[i]=='R')
            cnt++;
        else
            cnt=0;
        mx=max(mx, cnt);
    }
    cout<<mx<<endl;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pi 3.141592653589793238
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define MOD 1000000007
int main()
{
	fast;
	ll arr[5],k;
	for(int i=0;i<5;i++)
		cin>>arr[i];
	cin>>k;
	if(arr[4]-arr[0]>k)
	{
		cout<<":(";
		return 0;
	}
	else
	{
		for(int i=0;i<5;i++)
			for(int j=i+1;j<5;j++)
				if(arr[j]-arr[i]>k)
				{
					cout<<":(";
					return 0;
				}
	}
	cout<<"Yay!";
	return 0;
}


Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define int long long

using namespace std;
const int kMod = 1e9 + 7;

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

    vector<tuple<int, int, int, int>> elems;
    for (int i = 0; i < n; ++i) {
        int w, s, v; cin >> w >> s >> v;
        elems.emplace_back(s + w, s, w, v);
    }

    sort(elems.rbegin(), elems.rend());

    vector<long long> dp(30000, 0), ndp(dp);

    for (int i = 0; i < n; ++i) {
        ndp = dp;
        int s, w, v; tie(ignore, s, w, v) = elems[i];
        for (int j = 0; j <= s; ++j) {
            ndp[j] = max(ndp[j], dp[j + w] + v);
        }
        swap(dp, ndp);
    }

    long long ans = 0;
    for (auto& x : dp) {
        ans = max(ans, x);    
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 768
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <bitset>
#include <iomanip>
#include <climits>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound

ll modpow(ll a,ll n,ll mod){
  ll res=1;
  while(n){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a,ll mod){
  return modpow(a,mod-2,mod);
}

const int MAX=510000;
const int mod=1000000007;
ll fac[MAX],finv[MAX],inv[MAX];

void init(){
  fac[0]=fac[1]=1;
  finv[0]=finv[1]=1;
  inv[1]=1;
  rep(i,MAX){
    if(i>1){
      fac[i]=fac[i-1]*i%mod;
      inv[i]=mod-inv[mod%i]*(mod/i)%mod;
      finv[i]=finv[i-1]*inv[i]%mod;
    }
  }
}

ll com(int n,int k){
  if(n<k) return 0;
  if(n<0||k<0) return 0;
  return fac[n]*(finv[k]*finv[n-k]%mod)%mod;
}

int main(){
  int N;
  cin>>N;
  VI A(N+1);
  rep(i,N+1) cin>>A[i];
  init();
  VI B(N+1);
  int F;
  rep(i,N+1){
    B[A[i]]++;
    if(B[A[i]]==2) F=A[i];
  }
  int X=0;
  rep(i,N+1){
    if(A[i]!=F) X++;
    else break;
  }
  rep(i,N+1){
    if(A[N-i]!=F) X++;
    else break;
  }
  rep(i,N+1) cout<<(com(N+1,i+1)+mod-com(X,i))%mod<<endl;
}

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



int main() 
{
  ll N; cin>>N;
  vector<ll> A(N);
  vector<ll> B(N);
  rep(i,N)
  {
    cin>>A.at(i)>>B.at(i);
  }
  sort(A.begin(),A.end());
  sort(B.begin(),B.end());
  if(N%2==1)
  {
    ll a=A.at((N-1)/2);
    ll b=B.at((N-1)/2);
    cout<<b-a+1<<endl;
    return 0;
  }
  ll a=A.at(N/2-1)+A.at(N/2);
  ll b=B.at(N/2-1)+B.at(N/2);
  cout<<b-a+1<<endl;
  return 0;
}


Measured memory_bytes: 6472
#include<iostream>
#include<cmath>
#include<vector>
#include<map>
#include<queue>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rep1(i, n) for (int i = 1; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
const int INF = 1001001001;

using route = pair<P, int>;

int main() {
  int H, W;
  cin >> H >> W;
  char S[H][W];
  rep(i,H)rep(j,W) cin >> S[i][j];

  int ans = 0;
  rep(i,H)rep(j,W) {
    if (S[i][j] == '#') continue;
    P sp = P(i,j);
    queue<route> q;
    q.push(route(sp, 0));
    map<P, bool> visited;
    int steps = 0;
    while (!q.empty()) {
      route r = q.front();
      q.pop();
      P p = r.first;
      if (p.first < 0 || p.first >= H || p.second < 0 || p.second >= W) continue;
      if (S[p.first][p.second] == '#' || visited[p] == true) continue;
      visited[p] = true;
      steps = max(steps, r.second);
      q.push(route(P(p.first+1, p.second), r.second+1));
      q.push(route(P(p.first-1, p.second), r.second+1));
      q.push(route(P(p.first, p.second+1), r.second+1));
      q.push(route(P(p.first, p.second-1), r.second+1));
    }
    ans = max(ans, steps);
  }

  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
#include <queue>
#include <set>
#include <tuple>
using namespace std;

#define FOR(i,init,a) for(int i=init; i<a; i++)
#define rep(i,a) FOR(i,0,a)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define rep1(i,a) for(int i=1; i<=a; i++)
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define mem(a,n) memset( a, n, sizeof(a))
#define all(a) a.begin(),a.end()

typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef vector<int> V;
typedef vector<V> VV;
typedef vector<VV> VVV;
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LLINF = 1e18;
static const double pi = 3.141592653589793;

int n,k;
ll nums[100009];

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    cin>>n>>k;
    rep(i,n) cin>>nums[i];
    
    ll total=0;
    rep(i,n) if(nums[i]>0) total+=nums[i];
    
    if(total==0){
        cout1(0);
        return 0;
    }
    
    ll pl=0, mi=0, mx=0;
    rep(i,n){
        int num=nums[i];
        if(num>0) pl+=num;
        else mi+=num;
        if(i>=k-1){
            ll res=max(total+mi,total-pl);
            mx=max(mx,res);
            num=nums[i-(k-1)];
            if(num>0) pl-=num;
            else mi-=num;
        }
    }
    cout1(mx);
}

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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;

#if !ONLINE_JUDGE
#define debug
#endif

using namespace std;
 
/*******  All Required define Pre-Processors and typedef Constants *******/
#define mem(a, b) memset(a, (b), sizeof(a))
#define repd(i,k) for(int i=k;i>=0;i--)
#define rep(i,k) for(int i=0;i<k;i++)
#define repn(i,k1,k2) for(ll i=k1;i<k2;i++)
#define sz(x) (ll)(x).size()
#define ff first
#define ss second

#define all(cont) cont.begin(), cont.end()
#define rall(cont) cont.end(), cont.begin()
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define MOD 1000000007
#define ee6 (ll)1000001
#define ee5 (ll)100001

#define trav(a, v) for(auto& a : v)

#define tt ll t;cin>>t; while(t--)
typedef long long int ll;
 
typedef pair<ll, ll> pr;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef vector<pr> vpr;
typedef vector<vpr>vvpr;
typedef vector<vi> vvi;

//*X.find_by_order(2) element at index=2
//X.order_of_key(1) how many elements strictly less than 1

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag,
    tree_order_statistics_node_update>;

#ifdef debug
#define dbg(...) { cerr<<"[ "; dump(#__VA_ARGS__, __VA_ARGS__);}
#undef endl
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const pair<Arg1,Arg2> &x) {
    return out<<"("<<x.ff<<","<<x.ss<<")";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const vector<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1>
ostream& operator << (ostream& out, const set<Arg1> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
}
 
template <typename Arg1,typename Arg2>
ostream& operator << (ostream& out, const unordered_map<Arg1,Arg2> &a) {
    out<<"[";for(const auto &x:a)out<<x<<",";return out<<"]";
} 
 
template <typename Arg1>
void dump(const string name, Arg1&& arg1){
    cerr << name << " : " << arg1 << " ] " << endl;
}
 
template <typename Arg1, typename... Args>
void dump(const string names, Arg1&& arg1, Args&&... args){
    const string name = names.substr(0,names.find(','));
    cerr<<name<<" : "<<arg1<<" | ";
    dump(names.substr(1+(int)name.size()), args...);
}
#else
    #define dbg(args...)
#endif
 
ll powmod(ll x, ll y) 
{ 
    ll res = 1;  
    x = x % MOD;
    while (y > 0) 
    { 
        if (y & 1) 
          res = (res*x) % MOD; 
        y = y>>1; // y = y/2 
        x = (x*x) % MOD;   
    } 
    return res; 
} 

int main()
{
  #if !ONLINE_JUDGE
  //freopen("in.txt","r",stdin);
  #endif
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  
  ll n,a,b;
  cin>>n>>a>>b;
  if(a>b)cout<<"0";
  else if(a!=b and n==1)cout<<"0";
  else cout<<(b-a)*(n-2)+1;   
}

Measured memory_bytes: 256
# include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
typedef long long ll;
int n,a,b;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>n>>a>>b;
    if((b-a)%2==0){
        cout<<"Alice"<<endl;
    }
    else cout<<"Borys"<<endl;
}

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

template <typename Arg1>
void pn(Arg1&& arg1)
{ cout<<arg1<<"\n";}
template <typename Arg1, typename... Args>
void pn(Arg1&& arg1, Args&&... args)
{ cout<<arg1<<"\n"; pn(args...); }

template <typename Arg1>
void ps(Arg1&& arg1)
{ cout<<arg1<<" ";}
template <typename Arg1, typename... Args>
void ps(Arg1&& arg1, Args&&... args)
{ cout<<arg1<<" "; ps(args...); }

template <typename Arg1>
void pvs(Arg1&& arg1, ll n)
{ for(ll i=0;i<n;i++)ps(arg1[i]); }
template <typename Arg1>
void pvn(Arg1&& arg1, ll n)
{ for(ll i=0;i<n;i++)pn(arg1[i]); }

ll lcm(ll a,ll b) 
{ return (a*b)/__gcd(a,b); }

ll mulmod(ll a,ll b,ll mod) 
{ ll res=0; a=a%mod; 
    while(b>0)
    { if(b%2==1) res=(res+a)%mod; 
      a=(a*2)%mod; b/=2; }
    return res % mod; } 

ll mulpow(ll x,ll y,ll p) 
{ ll res=1; x=x%p;
    while(y>0) 
    { if (y&1) res=(res*x)%p; 
      y=y>>1; x=(x*x)%p; } 
    return res; } 

ll modInverse(ll n, ll p) 
{ return mulpow(n, p-2, p); } 

ll log(ll n, ll b)
{ ll c=0;
	while(n>(b-1))
	{ c++; n/=b; } return c; }

ll fib(ll n) 
{ double phi=(1+sqrt(5))/2; 
  return round(pow(phi,n)/sqrt(5)); } 

vector<bool> prime;
void sieve(int n)
{ prime.resize(n,true);
	for(int p=2;p*p<=n;p++)
		if(prime[p])
			for(int i=p*p;i<=n;i+=p)
				prime[i]=false; }

#define MOD 1000000007 //10^9+7
#define pi 3.14159265358979323846
#define f0(i,n) for(i=0;i<n;i++)
#define f1(i,n) for(i=1;i<=n;i++)
#define fd(i,n) for(i=n-1;i>=0;i--)
#define fn(i,s,d) for(i=s;i<d;i++)
#define pb push_back
#define mp make_pair
#define all(a) a.begin(),a.end()
#define sz(a) a.size()
#define vl vector<ll>
#define vb vector<bool>
#define vd vector<double>
#define vvl vector<vl>
#define vs vector<string>
#define vvs vector<vs>
#define pl pair<ll,ll>
#define pd pair<double,double>
#define vpl vector<pl>
#define vpd vector<pd>
#define vvpl vector<vpl>
#define ff first
#define ss second
#define um unordered_map
#define dsort(v) sort(v); reverse(v);


void solve()
{
	ll i,j;
	ll n;
	cin>>n;
	unordered_map<string,ll>u;
	while(n--)
	{
		string s;
		cin>>s;
		u[s]++;
	}
	ps("AC x",u["AC"]);
	pn("");
	ps("WA x",u["WA"]);
	pn("");
	ps("TLE x",u["TLE"]);
	pn("");
	ps("RE x",u["RE"]);
	pn("");
}

int main()
{
	#ifdef Deeksha
		freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
    #endif
	std::ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	solve();/* 
	ll t;
	cin>>t;
	for(ll tt=1;tt<=t;tt++)
	{
		//cout<<"Case #"<<tt<<": ";
		solve();
	}
	//*/
}



Measured memory_bytes: 3648
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <cmath>
#include <vector>
#define rep(i, n) for(int i = 0; i < n; i++)
using namespace std;
typedef long long ll;

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

    if(N == 1) {
        cout << "Hello World";
    }
    else {
        int A, B;
        cin >> A >> B;
        cout << A + B;
    }
    
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define pll pair<ll,ll>
#define fr first
#define se second
#define ull unsigned long long
#define getbit(x,i) (x>>i)&1

void solve(){
    ll n;cin>>n;
    ll ans=0;
    for(ll i=1;i<=n;i++){
        ll t=(n/i);
        ans+=(t*(i+t*i))/2;
    }
    cout<<ans<<endl;
}

int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    ll qu=1;
    // cin>>qu;
    for(ll cas=1;cas<=qu;cas++){
        // cout<<"Case #"<<cas<<": ";
        solve();
    }
}

Measured memory_bytes: 3648
#include <iostream>
void compareNum(int w, int h, int x, int y, int r);
using namespace std;
int main(int argc, const char * argv[]) {
    int w,h,x,y,r;
    cin >> w >> h >> x >> y >> r;
    compareNum(w, h, x, y, r);
    return 0;
}
void compareNum(int w, int h, int x, int y, int r){
    if (y <= h-r && x <= w-r&& x>=r && y>=r) {
        cout << "Yes" <<endl;
    }else{
        cout << "No" <<endl;
    }
}


Measured memory_bytes: 3116
#include <iostream>
#include<vector>
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define drep(i,n) for(int i = (n)-1; i >= 0; i--)
#define srep(i,s,t) for (int i = s; i < t; i++)
#define rng(a) a.begin(),a.end()
using ll = long long;

using namespace std;



int main() {
    int n;
    cin>>n;
    vector<int>a(n+1);
    rep(i,n) cin>>a[i+1];
    vector<int> b(n+1);
    for(int i = n; i > 0; i--){
        int sum = 0;
        for(int j = i+i; j <= n; j += i){
            sum ^=b[j];
        }
        b[i] = sum^a[i];
    }
    vector<int> ans;
    for (int i = 1; i <= n; i++) {
        if (b[i]) ans.push_back(i);
    }
    cout << ans.size() << endl;
    rep(i,ans.size()) {
        printf("%d%c", ans[i], i+1==ans.size()?'\n':' ');
    }
    

    return 0;
}


Measured memory_bytes: 5464
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define sz(x) (int)((x).size())
#define debug(x) cout << #x << ":" << x << ' ';
#define debugg(x) cout << #x << ":" << x << ' ' << "\n";
#define endl "\n"
#define L(X) ((X)<<1)
#define R(X) (((X)<<1)|1)
#define M(X,Y) (((X)+(Y))>>1)

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

const int MAXN = 1e5 + 5;
const int MOD = 1e9 + 7;
const int INF = 0x3f3f3f3f;
const long long int LLINF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-9;
const double PI = acos(-1);

template<typename T>   T max_self(T& a, T b) { if (a < b) a = b; return a; }
template<typename T>   T min_self(T& a, T b) { if (a > b) a = b; return a; }
template<typename T>   T add(T x, T y) { return ((x % MOD)  + (y % MOD)) % MOD;}
template<typename T>   T mul(T x, T y) { return ((x % MOD) * (long long)(y % MOD)) % MOD;}
template<typename T>   T sub(T x, T y) { return add(x, -y + MOD);}
template<typename T>   T gcd(T a, T b) { return b ? gcd(b, a % b) : a;}
template<typename T>   T lcm(T a, T b) { return a / gcd(a, b) * b;}
template<typename T>   vector<T> read(vector<T>& v, int n) {v.resize(n); for (auto &x : v)cin >> x;}
template<typename T>   void trav(vector<T> &v) {for (int i = 0 ; i < (int)v.size() ; ++i) {cout << v[i]; if (i != (int)v.size() - 1) cout << ' ';}}
int lg2(long long x)   {   return 64 - __builtin_clzll(x) - 1;	}
int lg2(int x)   {   return 32 - __builtin_clz(x) - 1;	}

//Variables Declaration

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

	int n ;
	cin >> n ;
	vector<pair<int, int>> tab;
	for (int i = 1 ; i <= n ; ++i) {
		int x ; cin >> x ;
		tab.push_back({x, i});

	}
	sort(all(tab));
	for (auto x : tab) {
		cout << x.second << " " ;
	}






	return 0;
}


Measured memory_bytes: 1780
#include "bits/stdc++.h"
#define MOD 1000000007
using namespace std;
long long f[1002][1002]={0};
char str[1002],a[1002][1002];
int main()
{
	int n,m;
	int i,j;
	scanf("%d %d",&n,&m);
	for(i=1;i<=n;i++)
	{
		getchar();
		for(j=1;j<=m;j++)
		{
			a[i][j]=getchar();
		}
	}
	for(i=1;i<=n;i++)
	{
		for(j=1;j<=m;j++)
		{
			if(a[i][j]=='#')
			{
				continue;
			}
			if(i==1&&j==1)
			{
				f[i][j]=1;
				continue;
			}
			f[i][j]=f[i][j-1]+f[i-1][j];
			f[i][j]%=MOD;
		}
	}
	printf("%lld\n",f[n][m]);
	return 0;
}

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

int main(){
  
  long long N;
  cin >> N;
  long long dup = N;
  
  long long sum = 0;
  while(N != 0){
    sum += N % 10;
    N /= 10;
  }
  if(dup % sum == 0)cout << "Yes";
  else cout << "No";
}
  
  
     

Measured memory_bytes: 3576
#include<stdio.h>
#include<string.h>
#define LEN 1000005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail, n;

void enqueue(P x){
  tail++;
  n++;
  Q[tail]=x;
}

P dequeue(){
  n--;
  if(Q[head].t>0) enqueue(Q[head]);
  head++;

  return Q[head-1];
}


int main(){
  int elaps = 0;
  int i, q;
  scanf("%d %d", &n, &q);
  
  head =1;
  tail = n;
  
  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }

  for(i=1;n>0;i++){
    
    if((Q[i].t-q)>0) {
      elaps=elaps+q;
      Q[i].t=Q[i].t-q;
      Q[i]=dequeue();
    }
    else if((Q[i].t-q)<=0){
      elaps=elaps+(q-(q-Q[i].t));
      Q[i].t=Q[i].t-q;
      printf("%s %d\n",Q[i].name,elaps);
      Q[i]=dequeue();
    }
  }  
  return 0;
}

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


void solve(long long N, long long M, std::vector<long long> H, std::vector<long long> A, std::vector<long long> B){
    int lose[N] = {};
    int ans = N;
    for (auto i = 0; i < M; i++) {
        auto a = A[i] - 1;
        auto b = B[i] - 1;
        if (H[a] >= H[b]) {
            if (!lose[b]) {
                lose[b] = 1;
                ans--;
            }
        }
        if (H[a] <= H[b]) {
            if (!lose[a]) {
                lose[a] = 1;
                ans--;
            }
        }
    }
    cout << ans << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> H(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&H[i]);
    }
    std::vector<long long> A(M);
    std::vector<long long> B(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
    }
    solve(N, M, std::move(H), std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 5916
from collections import defaultdict
N, K = list(map(int, input().split()))
R, S, P = list(map(int, input().split()))
T = list(input())

tmap = {
    'r': 0,
    's': 1,
    'p': 2
    }

score = {
    'r': R,
    's': S,
    'p': P,
}

# 勝つ手
pair = {
    'r': 'p',
    's': 'r',
    'p': 's',
}

# i % K != j % k ならばじゃんけんの手は独立に決定できる
# なので、じゃんけんの回数 % Kでグループ分けする
# 同一グループ内では、連続して同じ手は出せない。貪欲にやる

group = defaultdict(list)
for i in range(N):
    t = T[i]
    g = i % K
    group[g].append(t)

total = 0
for k in range(K):
    ls = group[k]
    tmp = ''

    s = 0
    for i in range(len(ls)):
        t = ls[i]

        win = pair[t]        
        draw = t
        lose = pair[win]

        # 勝ちの手が出せるならそうする
        if tmp != win:
            s += score[win]
            tmp = win
            continue           
        
        # 勝ちの手が出せないなら、次で勝てるように手を出す
        if tmp == win:
            if i < len(ls)-1:
                next_win = pair[ls[i + 1]]
                if draw == next_win:                
                    tmp = lose
                else:
                    tmp = draw
            else:
                pass
    total += s

print(total)

Measured memory_bytes: 63496
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(ll x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
template<class T>bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

vvll mp(200001, vll());

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n, k;
    cin >> n >> k;
    vll a(n);
    rep(i, n){
        cin >> a[i];
        mp[a[i]].emplace_back(i);
    }
    /*
    rep(i, 200001){
        if(SZ(mp[i]) > 1){
            ll x = mp[i][SZ(mp[i])-1];
            repr(j, 1, SZ(mp[i])){
                mp[i][j] = mp[i][j-1];
            }
            mp[i][0] = x;
        }
    }
    */
    vll b(n);
    vll cnt(200001, 0);
    rep(i, n){
        cnt[a[i]]++;
        if(cnt[a[i]] >= SZ(mp[a[i]])) cnt[a[i]] = 0;
        b[i] = mp[a[i]][cnt[a[i]]];
    }
    {
        ll T = 1;
        ll p = 0;
        while(1){
            if(p >= b[p]) T++;
            if(b[p] == n-1) break;
            p = (b[p]+1)%n;
        }
        dump(T);
        k %= T;
    }
    {
        ll p = 0;
        while(k){
            if(p >= b[p]) k--;
            if(!k) break;
            p = (b[p]+1)%n;
        }
        vll ans;
        repr(i, p, n){
            if(i < b[i]){
                i = b[i];
            }else{
                ans.emplace_back(a[i]);
            }
        }
        rep(i, SZ(ans)){
            cout << ans[i];
            cout << (i < SZ(ans)-1 ? " " : "\n");
        }
    }
    return 0;
}

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

using namespace std;

int main()
{
    int N , K , Mini = 0;
    cin >> N >> K;
    int F[N] ;
    for(int i =0 ; i < N ; ++i )
    {
        cin >> F[i] ;
    }
    sort( F , F + N ) ;
    for(int i = 0 ; i < K ; ++i)
    {
        Mini += F[i] ;

    }

    cout << Mini ;
    return 0;
}


Measured memory_bytes: 3488
//g++  7.4.0

#include <iostream>
#include<vector>

using namespace std;

int main()
{
    int n;
    cin>>n;
    
    vector <long >arr(n+1,0);
    for(int i=1;i<=n;i++)
    {
        for(int j=i;j<=n;j+=i)
            arr[j]+=1;            
    }
    long long ans=0;
    for(int i=1;i<=n;i++)
    {
        //cout<<i<<" "<<arr[i]<<endl;
        ans+=arr[i]*i;
    }
    cout<<ans;
    
}

Measured memory_bytes: 81396
#include<stdio.h>

int main(void) {
	int h, m, s;
	scanf("%d", &s);

	h = s / 3600;
	m = (s - (h * 3600)) / 60;
	s = s - (h * 3600 + m * 60);

	printf("%d:%d:%d\n", h, m, s);

	return 0;
}

Measured memory_bytes: 592
#include <stdio.h>
#include <stdlib.h>

int main(void){
	int n;
	long k;
	int *a;
	long set = 0, count = 0;
	long sum = 0;
	scanf("%d %ld", &n, &k);
	a = malloc(sizeof(int));
	for(int i = 0; i < n; i++){
		scanf("%d", a + i);
		for(int j = 0; j < i; j++){
			if(a[j] > a[i]){
				//printf("%d:%d\n", a[j], a[i]);
				count++;
			}
		}
	}
	for(int i = 0; i < n; i++){
		for(int j = 0; j < n; j++){
			if(a[i] > a[j])set++;
		}
	}
	set %= 1000000007;
	count %= 1000000007;
	sum = (set * (k * (k - 1) / 2 % 1000000007)) % 1000000007 + count * k % 1000000007;
	//printf("count: %d, set: %d\n", count, set);
	printf("%ld\n", sum % 1000000007);
	return 0;
}


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

#define all(a) (a).begin(), (a).end()
#define sz(a) (int)(a).size()
#define pb push_back
#define mp make_pair

using namespace std;

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

int main()
{

    //ifstream cin("input.txt");
    //freopen("input.txt", "r", stdin);

    //ios_base::sync_with_stdio(false);
    //cin.tie(0);

    int n, l;
    scanf("%d%d", &n, &l);

    vector<int> a(n);
    for (int i = 0; i < n; ++i) {
        scanf("%d", &a[i]);
    }

    int pos = -1;
    for (int i = 0; i < n - 1; ++i) {
        if (a[i] + a[i + 1] >= l) {
            pos = i;
            break;
        }
    }

    if (pos == -1) {
        printf("Impossible\n");
        return 0;
    }

    printf("Possible\n");

    for (int i = 0; i < pos; ++i) {
        printf("%d\n", i + 1);
    }
    for (int i = n - 2; i >= pos + 1; --i) {
        printf("%d\n", i + 1);
    }
    printf("%d\n", pos + 1);

}


Measured memory_bytes: 1152
<?php
class main {
    var $arr = array();
    var $img1 = array();
    var $img2 = array();
    function run() {
        $line = trim(fgets(STDIN));
        $this->arr = explode(" ", $line);

        for ($i = 0;$i < $this->arr[0]; $i++) {
            fscanf(STDIN, "%s", $s);
            $this->img1[$i] = str_split($s);
        }

        for ($j = 0;$j < $this->arr[1]; $j++) {
            fscanf(STDIN, "%s", $s);
            $this->img2[$j] = str_split($s);
        }

        for ($h = 0;$h <= ($this->arr[0] - $this->arr[1]); $h++ ) {
            for ($w = 0;$w <= ($this->arr[0] - $this->arr[1]); $w++ ) {
                if ($this->img1[$h][$w] == $this->img2[0][0]) {
                    $this->check($h, $w);
                }
            }
        }
        
        echo "No";
        
    }
    function check ($h, $w) {
        for ($n = 0; $n < $this->arr[1]; $n++) {
            for ($m = 0; $m < $this->arr[1]; $m++) {
                if ($this->img1[$h+$n][$w+$m] != $this->img2[$n][$m]) {
                    return false;
                }
            }
        }
        echo "Yes";
        exit;
    } 
}

$object = new main();
$object->run();

Measured memory_bytes: 4468
#include <iostream>
#include <fstream>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <string>
#include <cstdio>
#include <stack>

using namespace std;

int main()
{
	string s;
	cin >> s;
	int ans = 0;
	for (int i = 0; i<s.length(); i++)
	{
		if (s[i] == '+') ans++;
		else ans--;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{ 
    int a, b, c;
    int count = 0;

    do {
        cin >> a >> b >> c;
    } while ((a < 1 && a > 10000) || (b < 1 && b > 10000) || (c < 1 && c > 10000) ||
	     (a > b));

    for (int i = a; i <= b; i++) {       
         if (c % i == 0) {
	     count++;
         }
    }
     
    cout << count << endl;

    return (0);
}   

Measured memory_bytes: 1164
#include <iostream>

using namespace std;

unsigned long long int gcd(unsigned long long int a, unsigned long long int b)
{
	if(a % b == 0)
	{
		return(b);
	}
	else
	{
		return(gcd(b, a % b));
	}
}

unsigned long long int lcm(unsigned long long int a, unsigned long long int b)
{
	return(a * b / gcd(a, b));
}

void solve()
{
	unsigned long long int a, b;
	while(cin >> a >> b)
	{
		if(a < b)
		{
			unsigned long long int temp = a;
			a = b;
			b = temp;
		}
		cout << gcd(a, b) << " " << lcm(a, b) << endl;
	}
}

int main()
{
	solve();
	return(0);
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii  pair<int,int>
#define vpii vector<pii>
#define vll  vector<ll>
#define vi  vector<int>
#define pb push_back
#define f  first
#define s  second

int main() {

   int a,b;
   cin>>a>>b;
   
   if(a%b!=0)
      cout<<"1";
      else
        cout<<"0";
   
	return 0;
}

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

import math

N=int(input())

sosu = []
sosu.append(2)
for i in range(3,N+1):
    Flag = True
    for j in range(len(sosu)):
        if i%sosu[j]==0:
            Flag=False
            break
    if Flag:
        sosu.append(i)

def f(x,k):
    r=0
    while True:
        if x%k==0:
            x//=k
            r+=1
        else:
            break
    return r

yakusu = [1]*len(sosu)
for i in range(1,N+1):
    for j in range(len(sosu)):
        yakusu[j]+=f(i,sosu[j])

count75=0
count25=0
count15=0
count5=0
count3=0
for i in yakusu:
    if i >= 75:
        count75+=1
    if i >= 25:
        count25+=1
    if i >= 15:
        count15+=1
    if i >= 5:
        count5+=1
    if i >= 3:
        count3+=1
ans=0

ans+= count5*(count5-1)//2*(count5-2)
ans+= count5*(count5-1)//2*(count3-count5)
ans+=count15*(count15-1)+count15*(count5-count15)
ans+=count25*(count25-1)+count25*(count3-count25)
ans+=count75
print(ans)


Measured memory_bytes: 3064
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class Main{

  public static void main(String[] args) {
    new Main().run();
  }

  public void run() {
    
    try(BufferedReader in = new BufferedReader(new InputStreamReader(System.in))) {

      int n = Integer.parseInt(in.readLine());
      String line = in.readLine();
      int nHalf = n >> 1;

      int[] seqA = new int[nHalf];
      int[] seqB = new int[nHalf];
      int[][] seq = {seqA, seqB};

      Integer num;
      Map<Integer,Integer> mapA = new HashMap<>();
      Map<Integer,Integer> mapB = new HashMap<>();
      // Map<Integer,Integer>[] map ={mapA,mapB};
      List<Map<Integer,Integer>> aMap = new ArrayList<>();
      aMap.add(mapA);
      aMap.add(mapB);
      // map[0] = mapA;
      // map[1] = mapB;
      int offset=0,next=0;
      char regx = ' ';

      for(int i=0; i<n; i++) {
        if((next = line.indexOf(regx,offset)) == -1)
          next = line.length();
        num = new Integer(line.substring(offset, next));
        offset = ++next;

        seq[(i&1)][i>>1] = num;
        aMap.get(i&1).merge(num, 1, Integer::sum);
      }

      int[] vm = {0,0};
      int[] x =  {0,0};

      for (int i=0; i<aMap.size(); i++) {
        final int j = i;
        aMap.get(j).forEach((key,val) -> {
          if(vm[j] < val) {
            vm[j] = val;
            x[j]  = key;
          }
        });
      }

      int cca = nHalf - vm[0];
      int ccb = nHalf - vm[1];

      int[] vm2 = {0,0};
      final int fxa = x[0];
      final int fxb = x[1];
      int ans = 0;
  
      if(fxa == fxb) {
        for(int i=0; i<aMap.size(); i++) {
          final int j = i;
          aMap.get(j).forEach((key,val) -> {
            if(vm2[j] < val && key != x[j])
              vm2[j] = val;
          });
        }
      
        int cca2 = nHalf -vm2[0];
        int ccb2 = nHalf -vm2[1];

        ans = cca2 > ccb2 ? cca + ccb2 : cca2 + ccb;
      }
      else {
        ans = cca + ccb;
      }

      System.out.println(ans);
    }
    catch(IOException e) {
      System.err.println(e);
    }
  }
}

Measured memory_bytes: 46936
#include<bits/stdc++.h>
using namespace std;
int n,k,s;
int now=1e9;
int main()
{
    scanf("%d%d%d",&n,&k,&s);
    for(int i=1;i<=k;i++)printf("%d ",s);
    if(s==now)now=1;
    for(int i=k+1;i<=n;i++)printf("%d ",now);
    printf("\n");
    //system("pause");
}

Measured memory_bytes: 1280
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i=a; i<n; i++)
#define RREP(i, a, n) for(ll i=n-1; i>=a; i--)
typedef long long ll;
const ll mod =1e9+7;
const ll inf =1e18;
using namespace std;

int main() {
    ll n;
    cin>>n;
    cout<<n*n*n<<endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
int n, m;
bool used[100010];
int d[100010];
const int INF=1e9;
vector<P> g[100010];
int a[200020], b[200020];
int c[200020];
string s;
P p[100010];
int main()
{
	cin>>n>>m;
	for(int i=0; i<n; i++) cin>>d[i];
	for(int i=0; i<m; i++){
		cin>>a[i]>>b[i];
		a[i]--; b[i]--;
		g[a[i]].push_back({b[i], i});
		g[b[i]].push_back({a[i], i});
	}
	for(int i=0; i<n; i++) s+='B';
	for(int i=0; i<n; i++){
		p[i]=P(d[i], i);
	}
	sort(p, p+n);
	bool myon[100010]={};
	for(int i=0; i<n; i++){
		int x=p[i].second;
		int cnt=0, cnt1=0;
		for(auto q:g[x]){
			int y=q.first, k=q.second;
			if(d[y]>d[x]) continue;
			cnt1++;
		}
		if(cnt1==0){
			cout<<-1<<endl;
			return 0;
		}
		for(auto q:g[x]){
			int y=q.first, k=q.second;
			if(d[y]==d[x] && used[y] && myon[y]){
				c[k]=d[x];
				if(s[y]=='B') s[x]='W';
				else s[x]='B';
				cnt++;
			}
		}
		for(auto q:g[x]){
			int y=q.first, k=q.second;
			if(!used[y]) continue;
			if(cnt && !(d[y]==d[x] && myon[y])){
				c[k]=INF;
				continue;
			}
			if(d[y]<d[x]){
				c[k]=d[x]-d[y];
				s[x]=s[y];
				cnt++;
			}else{
				c[k]=d[x];
				if(s[y]=='B') s[x]='W';
				else s[x]='B';
				cnt++;
			}
		}
		used[x]=1;
		if(cnt==0) myon[x]=1;
	}
	cout<<s<<endl;
	for(int i=0; i<m; i++){
		cout<<c[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 14208
/*
これを入れて実行
g++ code.cpp
./a.out
*/

#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>

using namespace std;
typedef long long ll;
typedef long double ld;

int dy4[4] = { -1, 0, +1, 0 };
int dx4[4] = { 0, +1, 0, -1 };
int dy8[8] = { -1, -1, 0, 1, 1, 1, 0, -1 };
int dx8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };

const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;

bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
	return f.second > s.second;
}

ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}

ll lcm(ll a, ll b){
	return a / gcd(a, b) * b;
}

ll nCr(ll n, ll r){
	if (r == 0 || r == n){
		return 1;
	}
	else if (r == 1){
		return n;
	}
	return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}

ll nPr(ll n, ll r){
	r = n - r;
	ll ret = 1;
	for (ll i = n; i >= r + 1; i--) ret *= i;
	return ret;
}

//-----------------------ここから-----------

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

	map<char, int> mp;

	for (int i = 0; i < s.size(); i++){
		mp[s[i]]++;
	}

	
	for (char i = 'a'; i <= 'z'; i++){
		if (mp[i] == 0){
			cout << s + i << endl;
			return 0;
		}
	}

	string check = s;

	sort(check.begin(), check.end());
	reverse(check.begin(), check.end());

	if (check == s){
		cout << -1 << endl;
		return 0;
	}

	check = s;

	map<char, int> mp2;

	string ans = "";
	bool fin = false;

	next_permutation(s.begin(), s.end());
	for (int i = 0; i < s.size(); i++){
		ans += s[i];
		if (s[i] > check[i]){
			break;
		}
	}

	cout << ans << endl;

	

}


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

a.sort()

if a[0] >= 3200:
    print(1, n)
    exit()

ans = [0] * 9
for i in a:
    if i >= 3200:
        ans[8] += 1
    else:
        ans[i//400] = 1

print(sum(ans) - ans[-1], sum(ans))

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

int main() {
  int n; cin >> n; vector<int> a(n);
  rep(i,n)cin >> a[i];
  int ans=0;
  rep1(i,n){
    if(a[i]<a[i-1])ans+=a[i-1]-a[i];
  }
  ans+=a[n-1];
  cout << ans << endl;
}


Measured memory_bytes: 256
/************************************
/ AUTHOR : YATHARTH GOSWAMI         /  
/ ALIAS : hacker_yg                 /
/ INSTITUTE : IIT Kanpur            /
************************************/
//          TEMPLATE                //

#include <bits/stdc++.h>

#define ll long long
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define F first
#define S second

using namespace std;

int main(){
    int N;
    cin >> N;
    for (int i = 0; i < 3; i++){
        int d = N%10;
        N /= 10;
        if (d == 7){
            puts ("Yes");
            return 0;
        }
    }
    puts ("No");
    return 0;
}



Measured memory_bytes: 3624