akhauriyash/Code-Regression huggingface dataset:
//==========================================================================
    #define mod 1e9+7
    #include<decimal/decimal>
    #include <iostream>           //  CCCCC RRRRR  EEEEE  AAA   TTTTT EEEEE DDDD
    #include<algorithm>           //  C     R  R   E     A   A    T   E     D  D
    #include<bits/stdc++.h>       //  C     RRRR   EEEE  AAAAA    T   EEEE  D  D
    #include<cstring>             //  C     R  R   E     A   A    T   E     D  D
    #include<vector>              //  CCCCC R   R  EEEEE A   A    T   EEEEE DDDD
    //==========================================================================
    #include<stack>               //  BBBB   Y   Y
    #include<queue>               //  B   B   Y Y
    #include<deque>               //  BBBB     Y
    #include<cmath>               //  B   B    Y
    #include<numeric>             //  BBBB     Y
    //==========================================================================
    #include<utility>             //   AAA  M   M M   M IIIII TTTTT
    #include<unordered_map>       //  A   A MMMMM MMMMM   I     T
    #include<unordered_set>       //  AAAAA M M M M M M   I     T
    #include<set>                 //  A   A M   M M   M   I     T
    #include<map>                 //  A   A M   M M   M IIIII   T
    #include<list>
    #include<set>
    #include<string>
    //==========================================================================
    //==========================================================================
     
using namespace std;

int main() 
 {
      ios_base::sync_with_stdio(false); 
      cin.tie(NULL); 
      long long int a,b,c,ans1,ans12,zr=0;
      cin>>a>>b>>c;
      if(c>=a)
      {
           c=c-a;
      a=0;
      
      if(c>=b)
      {
           //cout<<"DF\n";
           b=0;
      }
      else
      b=b-c;
      cout<<a<<" "<<b;
      }
      else
      {
           a=a-c;
           cout<<a<<" "<<b;
      }
      
      
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
	
	//準備部分
	int r,c,h,i,data[101][101]={};
	
	//入力部分
	scanf("%d %d",&r,&c);
	for(h=0;h<r;h++){
		for(i=0;i<c;i++){
			scanf("%d",&data[h][i]);
		}
	}
	
	//計算部分
	for(h=0;h<r;h++){
		for(i=0;i<c;i++){
			data[h][c]+=data[h][i];
			data[r][i]+=data[h][i];
			data[r][c]+=data[h][i];
		}
	}
	
	//出力部分
	for(h=0;h<r+1;h++){
		for(i=0;i<c+1;i++){
			if(i>0)printf(" ");
			printf("%d",data[h][i]);
		}
		printf("\n");
	}
	
	return 0;
}



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

int main() {
	int n;
	cin>>n;
	int v[n][2];
	for(int i=0;i<n;i++)
	{
		cin>>v[i][0];
		cin>>v[i][1];
	}
	for(int i=0;i<=n-3;i++)
	{
		if(v[i][0]==v[i][1]&&v[i+1][0]==v[i+1][1]&&v[i+2][0]==v[i+2][1])
		{
			cout<<"Yes";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 3628
x,y=map(int,input().split())
if x>0 and y>0:
    if x<=y:
        print(y-x)
    else:
        print(x-y+2)
elif x<0 and y<0:
    if x<=y:
        print(y-x)
    else:
        print(x-y+2)
else:
    if y==0 or x==0:
        if y<0 or x>0:
            print(abs(y)+abs(x)+1)
        else:
            print(abs(y)+abs(x))
    else:
        print(abs(abs(x)-abs(y))+1)


Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <iomanip>
#include <stack>
#include <array>
#include <deque>
#include <forward_list>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#include <iterator>
#include <string>
#include <cstring>
//#include <fstream>
#include <complex>
#define _USE_MATH_DEFINES
#include <cmath>
#include <math.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=n;i>0;i--)
#define arep(a,i,n) for(int i=(a);i<(n);i++)
#define SORT(v) sort((v).begin(),(v).end())
const ll INF = (1LL << 50);
typedef pair<int, int> P;

int main() {

	int a, b;
	cin >> a >> b;

	if (a == 1 && b == 2) cout << 3;
	if (a == 2 && b == 3) cout << 1;
	if (a == 3 && b == 2)cout << 1;
	if (a == 1 && b == 3)cout << 2;
	if (a == 2 && b == 1)cout << 3;
	if (a == 3 && b == 1)cout << 2;

	return 0;

}

Measured memory_bytes: 256
X = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(X[int(input()) - 1])

Measured memory_bytes: 3060
# import bisect
# from collections import Counter, defaultdict, deque
# import copy
# from heapq import heappush, heappop, heapify
# from fractions import gcd
# import itertools
# from operator import attrgetter, itemgetter
# import math

import sys

# import numpy as np

ipti = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)

def main():
    n = int(input())
    if n % 2 == 0:
        print(n//2 - 1)
    else:
        print(n//2)

if __name__ == '__main__':
    main()

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

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int64_t A, B;
  cin >> A >> B;

  auto f = [](int64_t n) {
    vector<int64_t> res;
    for (int64_t i = 1; i * i < n + 1; i++) {
      if (n % i == 0) {
        res.emplace_back(i);
        res.emplace_back(n / i);
      }
    }
    sort(res.begin(), res.end());
    res.erase(unique(res.begin(), res.end()), res.end());
    return res;
  };

  vector<int64_t> C = f(A), D = f(B), E;
  for (auto c : C) {
    for (auto d : D) {
      if (c == d) E.emplace_back(c);
    }
  }

  sort(E.begin(), E.end());
  int cnt = 0;
  for (int i = 0; i < (int)E.size(); i++) {
    if (E[i] == -1) continue;
    cnt++;
    if (i == 0) continue;
    for (int j = i + 1; j < (int)E.size(); j++) {
      if (E[j] % E[i] == 0) E[j] = -1;
    }
  }
  cout << cnt << '\n';
  return 0;
}


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

typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<P,ll> PLL;
typedef pair<P,P> PP;
typedef vector<ll> VECLL;
typedef vector<P> VECP;
typedef priority_queue<P,VECP,greater<P> > PQP;
typedef priority_queue<ll, VECLL, greater<ll> > PQll;

#define rep(i,a,n) for(ll i = a;i < n;i++)   
#define rrep(i,a,n) for(ll i = n; i >= a;i--)
#define index_check(i,n) if(i > n-1 || i < 0) continue; 
#define LINF (ll)1e18
#define INF (int)1e9
#define fs first
#define sc second

#include <bits/stdc++.h>
#define rep(i,a,n) for(ll i = a;i < n;i++)
typedef long long ll;
using namespace std;

#define SEG_LEN (1 << 18)

ll seg[SEG_LEN*2];

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


void set_num(ll ind, ll v){
    ind += SEG_LEN;
    seg[ind] += v;
    while(1){
        ind /= 2;
        if(ind == 0) break;

        seg[ind] = gcd(seg[ind*2], seg[ind*2+1]);
    }
}

ll get_gcd(ll l, ll r){
    l += SEG_LEN;
    r += SEG_LEN;
    ll res = 0;
    while(l < r){
        if(l % 2 == 1){
            res = gcd(res,seg[l]);
            l++;
        }
        l /= 2;

        if(r % 2 == 1){
            res = gcd(res,seg[r-1]);
            r--;
        }
        r /= 2;
    }

    return res;
}


int main(){ 
    
    ll n;
    cin >> n;
    
    rep(i,0,n){
        ll a;
        cin >> a;
        set_num(i+1,a);
    }

    ll ans = 1;
    rep(i,0,n){
        if(i == 0) ans = max(ans,get_gcd(i+2,n+1));
        else if(i == n-1) ans =  max(ans, get_gcd(1,i+1) );
        else ans = max(ans,gcd(get_gcd(1,i+1),get_gcd(i+2,n+1)) );

    }

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


Measured memory_bytes: 5220
#include <iostream>
#include <fstream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <limits>
#include <queue>
#include <iomanip>
#include <set>

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

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

using namespace std;
using ll = long long int;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vvll> vvvll;
const int MOD=1000000007;
//const int MOD=998244353;
const int INTMAX=1001001000;
const ll LLMAX=1010010010010010000;

bool comp(vll a,vll b){
    return a[0]>b[0];
}


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll N;
    cin>>N;
    vll A(N);
    for(ll i=0;i<N;i++){
        cin>>A[i];
    }
    
    vector<vector<bool>> B(N,vector<bool>(20,0));
    
    for(ll i=0;i<N;i++){
        for(ll j=0;j<20;j++){
            if(A[i]==0)break;
            if(A[i]%2==1)B[i][j]=1;
            else B[i][j]=0;
            A[i]/=2;
        }
    }
    
    /*for(ll i=0;i<N;i++){
        printf("%lld:",i+1);
        for(ll j=0;j<20;j++){
            printf("%d",B[i][19-j]==1);
        }
        printf("\n");
    }*/
    
    ll a=0,b=0;//b<a
    vector<bool> P=B[0];
    ll ans=1;
    while(true){
        ll a_pre=a;
        while(true){
            if(a==N-1) break;
            a++;
            bool ok=true;
            vector<bool> Q=P;
            for(ll i=0;i<20;i++){
                if(Q[i]==1 && B[a][i]==1){
                    ok=false;
                    break;
                }else if(B[a][i]==1){
                    Q[i]=1;
                }
            }
            
            if(ok){
                ans+=a-b+1;
                //printf("%d\n",a-b+1);
                P=Q;
            }else{
                a--;
                break;
            }
        }
        
        if(a==N-1) break;
        
        for(ll i=0;i<20;i++){
            if(B[b][i]==1){
                P[i]=0;
            }
        }
        b++;
    }
    
    cout<<ans<<endl;
    
    
    return 0;
}


Measured memory_bytes: 15872
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<math.h>
#include<stack>

using namespace std;

int main(){
  int n;
  int a[10][3][4];
  int i,j,k;
  int b,f,r,v;

  for(i=0;i<10;i++){
    for(j=0;j<3;j++){
      for(k=0;k<4;k++){
        a[i][j][k]=0;
      }
    }
  }

  cin>>n;

  for(i=0;i<n;i++){
    cin>>b>>f>>r>>v;
    a[r-1][f-1][b-1]+=v;
  }

  for(i=0;i<4;i++){
    for(j=0;j<3;j++){
      for(k=0;k<10;k++){
        cout<<" "<<a[k][j][i];
      }
      cout<<endl;
    }
    if(i<3){
      cout<<"####################"<<endl;
    }
  }

  return 0;
}

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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

ll calc(ll x) {
    if(x % 2) {
        return 3 * x + 1;
    } else {
        return x / 2;
    }
}

int main(void) {
    ll s;
    ll i = 0;
    map<ll, ll> m;
    cin >> s;
    while(true) {
        i++;
        m[s]++;
        if(m[s] > 1) {
            cout << i << endl;
            return 0;
        }
        s = calc(s);
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
  int X;
  cin >> X;
  int num[1001] = {};
  num[1]++;
  for (int a = 2; a * a <= 1000; a++)
  {
    long val = a;
    for (int b = 2; b <= 9; b++)
    {
      val *= a;
      if (val <= X)
        num[val]++;
    }
  }
  for (int i = 1000; 0 < i; i--)
  {
    if (0 < num[i])
    {
      cout << i << endl;
      break;
    }
  }
  return 0;
}

Measured memory_bytes: 256
n,m,X,Y = map(int, input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
#print(X<Y)
#print(min(y)-max(x)>0)
#print((Y>max(x) or X<min(y)))
if X<Y and (min(y)-max(x)>0) and (Y>max(x) and X<min(y)):
    print("No War")
else:
    print("War")


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define maxn 5010
#define maxm 200010
#define p 1000000007
#define v 2400
using namespace std;
typedef long long ll;
template<typename T> inline void read(T &x)
{
    x=0;char c=getchar();bool flag=false;
    while(!isdigit(c)){if(c=='-')flag=true;c=getchar();}
    while(isdigit(c)){x=(x<<1)+(x<<3)+(c^48);c=getchar();}
    if(flag)x=-x;
}
int n;
ll ans;
int a[maxm],b[maxm];
ll f[maxn][maxn],fac[maxm],ifac[maxm];
ll inv(ll x)
{
    ll t=1,y=p-2;
    while(y)
    {
        if(y&1) t=t*x%p;
        x=x*x%p,y>>=1;
    }
    return t;
}
ll C(int n,int m)
{
    return fac[n]*ifac[m]%p*ifac[n-m]%p;
}
void init()
{
    fac[0]=ifac[0]=1;
    for(int i=1;i<=4*v;++i) fac[i]=fac[i-1]*i%p;
    ifac[4*v]=inv(fac[4*v]);
    for(int i=4*v-1;i;--i) ifac[i]=ifac[i+1]*(i+1)%p;
}
int main()
{
    init(),read(n);
    for(int i=1;i<=n;++i)
        read(a[i]),read(b[i]),f[-a[i]+v][-b[i]+v]++;
    for(int i=1;i<=2*v;++i)
        for(int j=1;j<=2*v;++j)
            f[i][j]=(f[i][j]+f[i-1][j]+f[i][j-1])%p;
    for(int i=1;i<=n;++i) ans=(ans+f[a[i]+v][b[i]+v]-C(2*(a[i]+b[i]),2*a[i])+p)%p;
    printf("%lld",ans*inv(2)%p);
    return 0;
}

Measured memory_bytes: 193304
#include <algorithm>
#include <bits/stdc++.h>
#include<iostream>
#include<string>
using namespace std;
#define rep(i, n) for (int i = 0; i <(int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define ll long long
int main() {
  ll N; cin>>N;
  vector<ll> A(N);
  for(int i=0; i<N; i++) cin>>A[i];
  ll count=0;
  bool zou=1;
  bool gen=1;
  for(int i=1; i<N; i++){
    if(A[i]-A[i-1]==0) continue;
    if(A[i]-A[i-1]>0 && zou==1) gen=0;
    if(A[i]-A[i-1]<0 && gen==1) zou=0;
    if(A[i]-A[i-1]>0 && gen==1){
      count++;
      zou=1;
      gen=1;
    }
    if(A[i]-A[i-1]<0 && zou==1){
      count++;
      zou=1;
      gen=1;
    }
  }
  cout<<count+1<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
	int a[3], b[2];
	cin >> a[0] >> a[1] >> a[2] >> b[0] >> b[1];
	sort(a, a+3);
	sort(b, b+2);
	cout << a[0] + b[0] - 50 << endl;
}

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

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pii;
typedef priority_queue< int, vector< int >, greater< int > >  minHeap;

#define ones(x) __builtin_popcount(x)
#define onesl(x) __builtin_popcountl(x)
#define onesll(x) __builtin_popcountll(x)

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define scn(n) scanf("%d",&n)
#define scnll(n) scanf("%lld",&n)
#define scn2(n,m) scanf("%d%d",&n,&m)
#define scn3(n,m,w) scanf("%d%d%d",&n,&m,&w)
#define scn2ll(n,m) scanf("%lld%lld",&n,&m)
#define atoz(v) v.begin(),v.end()
#define ratoz(v) v.rbegin(),v.rend()
#define Fill(a,v) memset(a,v,sizeof(a))
#define sz(v) v.size()
#define fi first
#define se second
#define inf 1e9
#define pi acos(-1.0)
#define sqr(x) x*x
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define ten(n) (int)1e##n
#define tenll(n) (lli)1e##n
#define mod 1000000007
#define FastIO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int Set(int N,int pos)
{
    return N=N | (1<<pos);
}
int reset(int N,int pos)
{
    return N = N & ~(1<<pos);
}
bool check(int N,int pos)
{
    return (bool)(N & (1<<pos));
}


inline int addmod(int x ,int y){return (x%mod + y%mod)%mod;}
inline int submod(int x ,int y){return (x%mod - y%mod + mod)%mod;}
inline int mulmod(int x ,int y){return (x%mod *1LL* y%mod)%mod;}
inline int nextSubMask(int i , int mask) {return (i-1)&mask;} /// returns next smallest submask

void we_r_done(){cout<<"NO"; exit(0);}

void debug(bool ok , string mssg)
{
    if(ok)return;
    cout<<mssg;
    exit(0);
}

int main()
{
    ///freopen("output.txt","w",stdout);
    ///freopen("input.txt","r",stdin);

    ///FastIO;

    string s;
    cin>>s;

    map<int,int>cnt;

    if(s[0] == '?'){
        for(int i=0; i<10; i++) cnt[i] = 1;
    }
    else{
        cnt[s[0]-'0'] = 1;
    }

    for(int i=1; i<s.size(); i++){

        map<int,int>temp;

        if(s[i] == '?'){
            for(auto it : cnt){
                for(int j=0; j<10; j++){
                    int now = (it.fi*10 + j)%13;
                    temp[ now ] = addmod(it.se,temp[now]);
                }
            }
        }
        else{
            for(auto it : cnt){
                int j = s[i]-'0';
                int now = (it.fi*10 + j)%13;
                temp[ now ] = addmod(it.se,temp[now]);

            }
        }
        cnt = temp;
    }

    cout<<cnt[5];

    return 0;

}

///sin and cos expect input in radians not degrees. so use , sin(degrees * pi / 180)
///using bs = bitset<MX>; // how many distinct number can be form?


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
#define de(x) cout << #x << "=" << x << endl;
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "-1" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------
bool ng;
ll ki,gu;
struct edge{ll to;};
struct graph{
    ll N;
    vector<vector<edge> > G;
    vector<ll> used;

    graph(ll n): N(n), G(N), used(N,0) {}

    void add_edge(ll s, ll t){
        G[s].emplace_back((edge){t});
        G[t].emplace_back((edge){s}); //無向ならON
    }

    void dfs(ll v=0, ll p=-1){
        if(p==-1) used[v]=1;
        for(auto E : G[v]){
            if(used[E.to]){
                if(used[v]+used[E.to]!=3) ng=true;
            }
            if(!used[E.to]){
                used[E.to]=(3-used[v]);
                dfs(E.to, v);
            }
        }
        if(used[v]==1) ++ki;
        else ++gu;
    }
};
//--MAIN-----------------------------------
void Main() {
    ll N,M; cin>>N>>M;
    bool GG[N][N]={};
    graph g(N);
    rep(i,M){
        ll a,b; cin>>a>>b; --a,--b;
        GG[a][b]=true;
        GG[b][a]=true;
    }
    rep(i,N){
        reps(j,i+1,N){
            if(GG[i][j]) continue;
            g.add_edge(i,j);
        }
    }
    vector<ll> kiki;
    vector<ll> gugu;
    rep(i,N){
        ki=gu=0;
        if(g.used[i]) continue;
        g.dfs(i);
        kiki.emplace_back(ki);
        gugu.emplace_back(gu);
    }
    if(ng) dame;
    bool dp[800][800]={};
    dp[0][0]=true;
    rep(i,kiki.size()){
        rep(j,N+1){
            if(!dp[i][j]) continue;
            dp[i+1][j+kiki[i]]=true;
            dp[i+1][j+gugu[i]]=true;
        }
    }
    ll ans=INF2;
    rep(i,N+1){
        if(dp[kiki.size()][i]) mini(ans,(i*(i-1)/2+(N-i)*(N-i-1)/2));
    }
    cout<< ans <<"\n";

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

Measured memory_bytes: 6528
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	jpy := 0
	btc := 0.0
	for i := 0; i < n; i++ {
		var x float64
		var u string
		fmt.Scan(&x)
		fmt.Scan(&u)
		if u == "JPY" {
			jpy += int(x)
		} else {
			btc += x * 380000.0
		}
	}
	fmt.Println(float64(jpy) + btc)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n); i++)
#define lower(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
using namespace std;
using ll = long long;
int INF = 1001001001;

int main() {
  string s, t;
  cin >> s >> t;
  int ans = INF;
  rep(i, s.size()-t.size()+1) {
    int cnt = 0;
    rep(j, t.size()) {
      if(s[i+j] == t[j]) continue;
      else cnt++;
    }
    ans = min(cnt, ans);
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3628
h,w= map(int,input().split())
a = [input() for _ in range(h)]
s = ''
for i in range(w+2):
    s+='#'
print(s)
for i in a:
    t = list(i)
    t.insert(0,'#')
    t.append('#')
    print(''.join(t))
print(s)

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

int main() {
  ll n; cin >> n;
  map<string, ll> mp;
  rep(i, n){
    string S;  cin >> S;
    sort(S.begin(),S.end());
    mp[S]++;
  }
  
  ll ans = 0;
  for(auto it = mp.begin(); it != mp.end(); it++){
    ll t = it -> second;
    ans += (t*(t-1)) / 2;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 11416
//SAIKH SERAJ FAHIM, CSE-19-HSTU, BANGLADESH.

#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    int n,i,ac=0,wa=0,tle=0,re=0;
    cin>>n;
    cin.ignore();
    for(i=1; i<=n; i++)
    {
        getline(cin,s);
        if(s=="AC")
            ac++;
        else if(s=="WA")
            wa++;
        else if(s=="TLE")
            tle++;
        else if(s=="RE")
            re++;
    }
    cout<<"AC "<<"x "<<ac<<endl;
    cout<<"WA "<<"x "<<wa<<endl;
    cout<<"TLE "<<"x "<<tle<<endl;
    cout<<"RE "<<"x "<<re<<endl;
    return 0;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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; }

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int n; cin>>n;
    vector<P> p(n);
    rep(i,n) {
        cin>>p[i].first;
        p[i].second = i;
    }
    sort(p.begin(), p.end(), greater<>());
    multiset<ll> st; 
    st.insert(-1); st.insert(-1); st.insert(n); st.insert(n);
    ll ans = 0;
    rep(i,n) {
        int idx = p[i].second; ll v = p[i].first;
        st.insert(idx);
        auto itr = st.lower_bound(idx);
        auto l2 = prev(itr);
        auto l1 = prev(l2);
        auto r1 = next(itr);
        auto r2 = next(r1);

        // cout << "itr - l2 = " << *itr-*l2 << ", r2 - r1 = " << *r2-*r1 << '\n';
        // cout << "l2 - l1 = " << *l2-*l1 << ", r1 - itr = " << *r1-*itr << '\n';
        ans += ((*itr-*l2)*(*r2-*r1)*v);
        ans += ((*l2-*l1)*(*r1-*itr)*v);
        // cout << "ans = " << ans << '\n';
    }

    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 6528
# coding: utf-8


def main():
    _ = int(input())
    A = list(map(int, input().split()))
    B = [0] * 9
    mn, mx = 0, 0

    for a in A:
        a //= 400
        if a > 7: a = 8
        B[a] += 1
    
    for i in range(8):
        if B[i] > 0: mn += 1
    
    mx = mn + B[8]
    if mn == 0: mn += 1

    print(mn, mx)

if __name__ == "__main__":
    main()


Measured memory_bytes: 9084
#include<iostream>
#include<cstdio>
using namespace std;
const int maxn = 110;
int H,W,count;
int dx[4]={0,-1,0,1};
int dy[4]={1,0,-1,0};
char maze[maxn][maxn];
bool visit[maxn][maxn];
void dfs(int m,int n){
	visit[m][n] = true;
	for(int i=0;i<4;i++){
		int nx = m + dx[i];
		int ny = n + dy[i];
		if(nx>=0&&nx<H&&ny>=0&&ny<W&&maze[nx][ny]==maze[m][n]&&!visit[nx][ny]){
			dfs(nx,ny);
			
		} 
	} 
}
int main(){
	while(1){
		scanf("%d%d",&H,&W);
		getchar();
		count = 0;
		if(H==0&&W==0) break;
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				scanf("%c",&maze[i][j]);
				visit[i][j]=false;
			}
			getchar();
		}
		for(int i=0;i<H;i++){
			for(int j=0;j<W;j++){
				if(visit[i][j]) continue;
				else{
					dfs(i,j);
					count++;
				}
			}
		}
		cout<<count<<endl;
	}
} 


Measured memory_bytes: 3620
a=[list(map(int,input().split())) for _ in range(3)]
n=int(input())
b={int(input()) for _ in range(n)}
FLAG=False
for i in range(3):
  if a[i][0] in b and a[i][1] in b and a[i][2] in b:
    FLAG=True
  if a[0][i] in b and a[1][i] in b and a[2][i] in b:
    FLAG=True
_FLAG=True
for i in range(2):
  if a[i][i] not in b:
    _FLAG=False
if _FLAG:
  FLAG=True
_FLAG=True
for i in range(2):
  if a[i][-1-i] not in b:
    _FLAG=False
if _FLAG:
  FLAG=True
if FLAG:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
from sys import stdin,stdout
def INPUT():return list(int(i) for i in stdin.readline().split())
import math
def inp():return stdin.readline()
def out(x):return stdout.write(x)
import math as M
MOD=10**9+7
import sys
#####################################
a,b=INPUT()
if a>=2*b:
    print(a-2*b)
else:
    print(0)


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

using namespace std;
#define ll long long
#define ld long double
#define PI 3.141592653L
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const ll INF = (ll)1e18;
const int N = 2e5 + 5;
const ll MOD = 1e9+7;

int parent[N];

int gcd(int a, int b) { 
    if (a == 0) 
        return b;  
    return gcd(b%a, a);  
} 
   
int lcm(int a, int b) {  
    return (a*b)/gcd(a,b);  
} 

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

int find(int x) {
    return x == parent[x] ? x : parent[x] = find(parent[x]);
}

void Union(int x, int y) {
    int xPar = find(x), yPar = find(y);
    if(xPar != yPar) parent[xPar] = yPar;
}

ll nCr(ll n, ll r) {
    ll res = 1;
    for(ll i=1;i<=r;i++) {
        res = res * (n - r + i) / i;
        // is different from
        // res *= (n -r + i) / i;
    }
    return res;
}

int n, m;
vector<int> adj[N];
vector<int> p(N), h(N), a(N), g(N);
bool ok = true;

// in an undirected graph, use dfs(child, parent)
void dfs(int v, int ancestor=-1) {
    a[v] = p[v];
    int sumG = 0;
    for(auto next : adj[v]) {
        if(next != ancestor) {
            // 从下到上 dfs
            dfs(next, v);
            sumG += g[next];
            a[v] += a[next];
        }
    }
    // 三个条件
    if(!((a[v] + h[v]) % 2 == 0)) ok = false;
    g[v] = (a[v] + h[v]) / 2;
    if(!(0 <= g[v] && g[v] <= a[v])) ok = false;
    if(!(sumG <= g[v])) ok = false;
}

void solve() {
    int x;
    cin >> x;
    cout << ((x >= 30) ? "Yes" : "No") << endl;
    return;
} 

int main()
{
    IOS
    //int t;
    //cin >> t;
    //while(t--) 
    solve();
    return 0; 
}


Measured memory_bytes: 10976
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
    ll i,j,k,a,b,c,n,t,m,p,q,d,e,f,l,nl,np,x,y,x1,y2,y1,x2;
    vector<ll > s;
    vector<ll > vv,ss,v;
    map<string,ll> ma,sa;
    string st,et,ft,pt,ct;
    deque<char> de;
    ios_base::sync_with_stdio(false);
    cin>>st;
    c = st.size()-1;
    if(st[c]=='2' || st[c]=='4'|| st[c]=='5' || st[c]=='7'|| st[c]=='9')cout<<"hon"<<endl;
   else if(st[c]=='0' || st[c]=='1' || st[c]=='6'  || st[c]=='8')cout<<"pon"<<endl;
    else if(st[c]=='3')cout<<"bon"<<endl;
}


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

int main() {
  string day="MON";
  cin >> day; 
  if(day=="MON"){
    cout << "6";
  }else if(day=="TUE"){
    cout << "5";
  }else if(day=="WED"){
    cout << "4";
  }else if(day=="THU"){
    cout << "3";
  }else if(day=="FRI"){
    cout << "2";
  }else if(day=="SAT"){
    cout << "1";
  }else if(day=="SUN"){
    cout << "7";
  }
	return 0;
}


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

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

  cin >> S;  
  
  string res = "Yes";
  
  if( N%2 != 0){
    res = "No";
  }
  
  for(int i = 0; i < N/2;i++){
   if(S.at(i) == S.at(i+N/2)){
     //OK
   }
   else{
    res = "No";
     break;
   }
      
      
  }
  
  cout << res << endl;

}





Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;
 
 
lint fac[MAX], finv[MAX], inv[MAX];
 
void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint i = 2; i < MAX; i++)
    {
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}
 
long long COM(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
 
lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;
 
    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }
 
    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
     lint gcd(lint a,lint b){
        return __gcd(a,b);
    }    

  int main(){
      lint n,m;
      cin >>n>>m; vector<lint> A(n);
      lint ans=0;
      rep(i,n)cin >> A[i];
      sort(all(A));
        lint left=-1;
        lint right=INF;
        while(right-left>1){
            lint mid= left +(right-left)/2;
            lint count=0;
            lint y;
            rep(i,n){
                auto x=lower_bound(all(A),mid-A[i]);
                y=A.end()-x;
                count+=y;
            }
            if(count>m)left=mid;
            else right=mid;
        }
       vector<lint> accum(n+1);
       accum[0]=0;
       rep(i,n){
           accum[i+1]=accum[i]+A[i];
       }
       rep(i,n){
            auto x=lower_bound(all(A),right-A[i]);
            lint num=A.end()-x;
            ans+=num*A[i]+accum[n]-accum[n-num];
            m-=num;
       }
       ans+=m*left;
       cout<<ans;

  }
  
  
     
  

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

int main() 
{ 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll a, b, c;
    cin >> a >> b >> c;
    cout << max((c - max(abs(a-b), 0LL)), 0LL) << "\n";
    return 0; 
}

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

using namespace std;

int main() {
	int n;
	vector<long long> a;
	cin >> n;
	long long A;
	
	for (int i = 0; i < n; i++) {
		cin >> A;
		a.push_back(A);
	}


	long long ans1 = 0;
	long long count = 0;
	
	for (int i = 0; i < n ; i++) {
		ans1 += a[i];
		if (i % 2 == 0) {
			if (ans1 >= 0) {
				
				count += ans1 + 1;
				ans1 = -1;
			}
		}
		else {
			if (ans1 <= 0) {
				count += 1 - ans1;
				ans1 = 1;
			}
		}
	}
	

	long long count2 = 0;
	ans1 = 0;
	for (int i = 0; i < n ; i++) {
		ans1 += a[i];
		if (i % 2 != 0) {
			if (ans1 >= 0) {

				count2 += ans1 + 1;
				ans1 = -1;
			}
		}
		else {
			if (ans1 <= 0) {
				count2 += 1 - ans1;
				ans1 = 1;
			}
		}
	}

	cout << min(count, count2) << endl;

	return 0;
}

Measured memory_bytes: 1400
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt(), m = in.nextInt();
        int[] cnt = new int[n];
        boolean[] red = new boolean[n];
        Arrays.fill(cnt, 1);
        red[0] = true;
        for (int i = 0; i < m; i++) {
            int x = in.nextInt() - 1, y = in.nextInt() - 1;
            if(red[x]) red[y] = true;
            cnt[x]--;
            cnt[y]++;
            if(cnt[x] == 0) red[x] = false;
        }
        int ans = 0;
        for(boolean flag: red) {
            ans += flag ? 1 : 0;
        }
        System.out.println(ans);
    }
}

Measured memory_bytes: 63708
import java.io.*;
import java.util.*;
public class Main {
 public static void main(String[] args)throws IOException{
  BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
  while(true){
   int f=0;
   String str4[]=new String[100];  
   str4=br.readLine().split(" ");
   String str1=str4[0];
   String str2=str4[1]; 
   String str3[]=new String[100];
   char ch=str2.charAt(0);
   int n=str1.indexOf("_");
   //原文の判定
   if(n>=0){
    str3=str1.split("_");
    f=2;
    }
   else if(Character.isUpperCase(str1.charAt(0)))f=1;
   String str="";
//規則の判定
  
   if(ch=='X')break;
   else if(ch=='U'){
   //変換
    if(f==0)str=str1.substring(0,1).toUpperCase()+str1.substring(1);
    else if(f==2){
     for(int i=0;i<str3.length;i++)
      str+=str3[i].substring(0,1).toUpperCase()+str3[i].substring(1);
    }
    else str=str1;
   }
   else if(ch=='L'){
   //変換
    if(f==0)str=str1;
    else if(f==1)str=str1.substring(0,1).toLowerCase()+str1.substring(1);
    else if(f==2){
     str+=str3[0];
     for(int i=1;i<str3.length;i++)
      str+=str3[i].substring(0,1).toUpperCase()+str3[i].substring(1);
    }
   }
   else if(ch=='D') {
   //変換
    str1=str1.substring(0,1).toLowerCase()+str1.substring(1);
    int idx=0;
    for(int i=0;i<str1.length();i++){
     if(Character.isUpperCase(str1.charAt(i))){
      str+=str1.substring(idx,i)+"_"+str1.substring(i,i+1).toLowerCase();
      idx=i+1;
     }
}
    str+=str1.substring(idx);
      }
  System.out.println(str);
  }
 }
}


Measured memory_bytes: 24208
#include<bits/stdc++.h>
#define For(i, a, b) for(register int i = a; i <= b; ++ i)

using namespace std;

const int maxn = 100 + 10;
int f[maxn];

int main() {
	int n;
	cin >> n;
	f[0] = 1;
	For(j, 4, n)
		f[j] |= f[j - 4];
	For(j, 7, n)
		f[j] |= f[j - 7];
	if(f[n])
		puts("Yes");
	else
		puts("No");
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
 
int descending_compare(const void *a, const void *b){
    return (int)(*(int*)b - *(int*)a);
}
 
int ascending_compare(const void *a, const void *b){
    return (int)*(int*)a - *(int*)b;
}
 
 
 
 
int main(void){
    int n;
    int *a;
    int cnt = 0;
    int answer = 0;
    int i;
 
    scanf("%d", &n);
 
    a = malloc(sizeof(int) * n+1);
 
    for (i = 0; i < n; i++){
        scanf("%d", &a[i]);
    }
 
    qsort(a, n, sizeof(int), ascending_compare);
 
    a[n] = 0;
 
 
    for (i = 0; i < n+1; i++){
        cnt++;
        if (a[i] != a[i-1] && i != 0){
            cnt--;
            if (cnt > a[i-1]){
                answer += (cnt - a[i-1]);
            }else if(cnt < a[i-1]){
                answer += cnt;
            }
            cnt = 1;
        }
    }
 
    printf("%d\n", answer);
 
 
 
 
 
 
 
    return 0;
}

Measured memory_bytes: 892
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <string>
#include <queue>
#include <numeric>
#include <ctype.h>
#include <limits>
#include <iomanip>

#define rep(i,n) for (int i = 0; i < n; i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

typedef long long ll;

int main() {
	/*vector<int>v(3);
	cin >> v[0] >> v[1] >> v[2];
	sort(all(v));
	cout << v[0] + v[1] << endl;*/

	int N;
	cin >> N;
	vector<int>w(N);
	int s1 = 0, s = 0;
	rep(i, N) {
		cin >> w[i];
		s += w[i];
	}
	int mi = 0, ma = 0;
	rep(i, N) {
		if (s1 + w[i] < s / 2) {
			s1 += w[i];
		}
		else {
			mi = min(s1, s - w[i] - s1) + w[i];
			ma = max(s1, s - w[i] - s1);
			break;
		}
	}
	cout << abs(mi - ma);


	/*int N, M;
	cin >> N >> M;
	vector<int>a(M);
	ll ans = 0;
	rep(i, M) {
		cin >> a[i];
	}

	rep(i, M) {
		if (i >= 1 && i < M) {
			if (a[i] == a[i - 1] + 1) {
				ans = 0;
				break;
			}
		}

		if (i == 0) {

		}
		else {
			if (i == M - 1) {

			}
		}

		}
	}
	cout << ans;*/

	return 0;
}

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

#define pb push_back
#define mp make_pair
#define inside sl<=l&&r<=sr
#define outside r<sl||sr<l
#define INF 1000000009
#define mod 1000000007
using namespace std;
typedef long long ll;
int n;
struct block{
	ll w, s, v;
};
block arr[1003];

int com(const block& a, const block& b){
	return a.w+a.s < b.w+b.s;
}

ll dp[1003][20004];

int main(){
	//freopen("stl.gir", "r", stdin);
	
	cin >> n;
	for (int i = 0; i < n; i++){
		cin >> arr[i].w >> arr[i].s >> arr[i].v;
	}
	
	sort(arr, arr+n, com);
	
	/*for (int i = 0; i < n; i++){
		cout << "(" << arr[i].w << ", " << arr[i].s << ", " << arr[i].v << ")\n";
	}*/
	
	// dp[i][j] = ilk i blok kullanılarak toplam ağırlığı j olan max value
	// dp[i][j] = max(dp[i-1][j], dp[i-1][j-w[i]]+v[i]);
	
	for (int i = 0; i < n; i++){
		for (int j = 0; j < 20004; j++){
			if (i == 0){
				if (j < arr[i].w) dp[i][j] = 0;
				else dp[i][j] = arr[i].v;
			} else if (j == 0){
				dp[i][j] = 0;
			} else {
				dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
				if (j-arr[i].w >= 0 && arr[i].s >= j-arr[i].w) dp[i][j] = max(dp[i][j], dp[i-1][j-arr[i].w]+arr[i].v);
			}
		}
	}
	
	//cout << dp[1][0] << endl;
	cout << dp[n-1][20003] << endl;
	
}

Measured memory_bytes: 156544
#include <bits/stdc++.h>
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
using namespace std;

int main()
{
    int intarr[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int K;
    cin >> K;
    cout << intarr[K-1];
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
long long dp[1010][1010];
int main() {
    int h, w; cin >> h >> w;
    dp[0][1] = 1;
    for (int i = 0; i < h; i++) {
        string s; cin >> s;
        for (int j = 0; j < w; j++) {
            if (s[j] == '.') {
                dp[i+1][j+1] = (dp[i][j+1] + dp[i+1][j]) % mod;
            }
        }
    }
    cout << dp[h][w] << endl;
    return 0;
}

Measured memory_bytes: 8192
while True:
    table = input().split()
    
    a = int(table[0])
    op = table[1]
    b = int(table[2])
    
    if op == '?':
        break
    
    if op == '+':
        print('%d'%(a+b))
    elif op == '-':
        print('%d'%(a-b))
    elif op == '*':
        print('%d'%(a*b))
    else:
        print('%d'%(a/b))


Measured memory_bytes: 5596
#include<stdio.h>
int main(void)
{
	int a,b,x,y,z,m;
	scanf("%d",&a);
	scanf("%d",&b);
	
	x=a*b;
	y=a*1;
	z=b*1;
	m=x-y-z+1;
	
	printf("%d\n",m);
	return 0;
}

Measured memory_bytes: 128
from collections import deque

S=deque(str((input())))
Q=int(input())
t=0
for _ in range(Q):
    T=list(map(str,input().split()))
    if T[0]=="1":
        t+=1
    else:
        if (T[1]=="1" and t%2 == 0) or (T[1]=="2" and t%2 != 0):
            S.appendleft(T[2])
        else:
            S.append(T[2])


if t%2 != 0:
    S.reverse()

print("".join(S))

Measured memory_bytes: 8692
N, M = map(int, input().split())
c = [0 for i in range(N+1)]
for x in range(M):
    L, R = map(int, input().split())
    c[L-1] += 1
    c[R] -= 1
r = 0
t = 0
for x in c[:-1]:
    t += x
    if t == M:
        r += 1
print(r)


Measured memory_bytes: 10512
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
int n,k,a[200];


int main(){
	
	cin>>n;
	for(int i=0;i<n;i++)
		cin>>a[i];
	int ans=10000000,index;
	for(int i=1;i<=100;i++){
		int sum=0;
		for(int j=0;j<n;j++){
			sum+=(a[j]-i)*(a[j]-i);
		}
		ans=min(ans,sum);
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

vector<int> diff(const vector<int>& a, const vector<int>& b)
{
    vector<int> res(10);
    for (int i = 1; i <= 9; i++) {
        res[i] = a[i] - b[i];
    }
    return res;
}

bool check_diff(const vector<int>& a, const vector<int>& b)
{
    for (int i = 1; i <= 9; i++) {
        if (a[i] < b[i]) return 0;
    }
    return 1;
}

map<vector<int>, int> mem;
vector<vector<int>> pat;

bool check(const vector<int>& p)
{
    int res = 0, cnt = 0;
    for (int i = 1; i <= 9; i++) {
        cnt += p[i];
        res += p[i] * i;
    }
    return (res == 10 && cnt > 2);
}

void make_pattern(int n, const vector<int>& p)
{
    if (n == 10) {
        if (check(p)) {
            pat.emplace_back(p);
        }
        return;
    }
    for (int i = 0; i <= 10 / n; i++) {
        vector<int> np = p;
        np[n] += i;
        make_pattern(n + 1, np);
    }
}

int solve(const vector<int>& m_cnt)
{
    int res = 0;
    if (mem.count(m_cnt) != 0) {
        return mem[m_cnt];
    }

    for (const auto& p : pat) {
        if (check_diff(m_cnt, p)) {
            res = max(res, solve(diff(m_cnt, p)) + 1);
        }
    }
    return mem[m_cnt] = res;
}

int main()
{
    int N;
    make_pattern(1, vector<int>(10));
    while (cin >> N, N > 0) {
        vector<int> m_cnt(10);
        for (int i = 0; i < N; i++) {
            int m;
            cin >> m;
            m_cnt[m]++;
        }

        int res = 0;
        for (int i = 1; i <= 5; i++) {
            int mini = min(m_cnt[i], m_cnt[10 - i]); 
            if (i == 5) mini /= 2;
            res += mini;
            m_cnt[i] -= mini;
            m_cnt[10 - i] -= mini;
        }
        mem.clear();
        res += solve(m_cnt);
        cout << res << endl;
    }        
    return 0;
}

Measured memory_bytes: 9648
while(True):
    a, op, b = input().split()
    a = int(a)
    b = int(b)

    if (op == "?"):
        break

    elif (op == "+"):
        ans = a+b

    elif (op == "-"):
        ans = a-b

    elif (op == "*"):
        ans = a*b

    elif (op == "/"):
        ans = a//b

    print(ans)






Measured memory_bytes: 5596
//includes
#include<iostream>
#include<vector>
#include<set>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<string>
#include<stack>
#include<map>
#include<queue>
#include<iomanip>
#include<numeric>
#include<assert.h>
#include<cstring>
#include<unordered_map>
#include<bitset>


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;
}

//macros and consts
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(a) (a).begin(),(a).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define FORE(i,a) for(auto &i : a)
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define accm accumulate
#define Fi first
#define Se second
#define INF 1e9
#define llINF (1LL<<60)
#define mINF -1e9
#define mllINF -(1LL<<60)
#define endl "\n"
#define CONT continue
#define BRK break
#define modulo(n, m) (((n)%(m)+(m))%m)

//shorter types
using namespace std;
using ll = long long;
using vi = std::vector<int>;
using vc = std::vector<char>;
using vll = std::vector<long long>;
using vs = std::vector<string>;
using Mi = map<int,int>;
using Mll = map<ll,ll>;
using UMi = unordered_map<int,int>;
using UMll = unordered_map<ll,ll>;
using Pi = pair<int,int>;
using Pll = pair<ll,ll>;
using vPi = vector<Pi>;
using vPll = vector<Pll>;
using vvi = vector<vector<int>>;
using vvll = vector<vector<ll>>;
using vvc = vector<vector<char>>;
using vvs = vector<vector<string>>;
using pqgi = priority_queue<int,vector<int>,greater<int>>;
using pqsi = priority_queue<int,vector<int>,less<int>>;
using pqgll = priority_queue<int,vector<int>,greater<int>>;
using pssll = priority_queue<int,vector<int>,less<int>>;
template<class T>
using vec = vector<T>;
#define int long long



int N,K;
 vector<int> A,F;
bool check(int val){
	int cost = 0;
	for(int i = 0; i < N; i++){
		if(A[i] * F[i] > val){
			cost += max(0LL,A[i] - (val / F[i]));
		}
	}
	return cost <= K;
}
//here begins your code
signed main(){
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);
  cin >> N >> K;


  A.resize(N);
  F.resize(N);
  REP(i,N){
  	cin >> A[i];
  }
  REP(i,N){
  	cin >> F[i];
  }
  sort(ALL(A));
  sort(F.rbegin(),F.rend());

  int ng = -1;
  int ok = llINF;
  while(abs(ok - ng) > 1){
  	int mid = (ok + ng)/2;
  	if(check(mid)){
  		ok = mid;
  	}
  	else{
  		ng = mid;
  	}
  }
  cout << ok << endl;
  //check types
  //do not eb if you resize
  //resize before you access by idx
  return 0;
} 

Measured memory_bytes: 3328
#include <iostream>
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <string>
#include <list>
#include <math.h>
using namespace std;
int main() {
	double x, c, d;
	long a=0,y;
	cin >> y >> x;
	for (int i = 0; i < y; i++) {
		cin >> c >> d;
		double tmp;
		c = pow(c, 2);
		d = pow(d, 2);
		tmp = sqrt(c + d);
		if (x >= tmp) {
			a++;
		}
		else {

		}
	}
	cout << a << endl;
}

Measured memory_bytes: 3832
#include <iostream>

using namespace std;

int main() {
	
	int t;

	while (cin >> t && t != 0) {

		int n;
		int total = 0;
		cin >> n;

		int s, f;

		for (int i = 0; i < n; i++) {
			cin >> s >> f;
			total += (f - s);
		}

		if (total - t >= 0)
			cout << "OK\n";

		else
			cout << t - total << "\n";

	}
	
	return 0;

}







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

string alph="abcdefghijklmnopqrstuvwxyz";
map<char, int> M;
int alphc[27][51];

int main(){
	int x=0;
	for(char c : alph){
		M[c]=x;
		x++;
	}
	int n;
	cin>>n;
	for(int i=0;i<n;i++){
		string s;
		cin>>s;
		for(char c : s){
			alphc[M[c]][i]++;
		}
	}
	
	for(int i=0;i<26;i++){
		alphc[i][50]=51;
		for(int j=0;j<n;j++){
			alphc[i][50]=min(alphc[i][50],alphc[i][j]);
		}
	}
	
	for(int i=0;i<26;i++){
		while(alphc[i][50]--){
			cout<<alph[i];
		}
	}
	cout<<endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define int ll
typedef pair<int,int> pii;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define all(a) (a).begin(),(a).end()
#define pb emplace_back

vector<string> split(string s,char ch){
    vector<string> ret;
    string tmp ="";
    rep(i,s.size()){
        if(s[i]==ch){
            ret.pb(tmp);
            tmp = "";
        }else tmp+=s[i];
    }
    if(tmp.size())ret.pb(tmp);
    return ret;
}

int solveL(string s){
    int res = s[0]-'0';
    for(int i=1;i<s.size();i+=2){
        if(s[i]=='+')res+=s[i+1]-'0';
        if(s[i]=='*')res*=s[i+1]-'0';
    }
    return res;
}

int solveM(string s){
    vector<string> res = split(s,'+');
    
    rep(i,res.size()){
        int r = solveL(res[i]);
        stringstream ss;
        ss<<r;
        res[i] = ss.str();
    }
    int sum = 0;
    rep(i,res.size()){
        sum+=stoi(res[i]);
    }
    return sum;
}

signed main(){
    string s;
    cin>>s;
    int ans;
    cin>>ans;
    
    int m = solveM(s);
    int l = solveL(s);
    
    if(m==ans&&l==ans)cout<<'U'<<endl;
    else if(m==ans)cout<<'M'<<endl;
    else if(l==ans)cout<<'L'<<endl;
    else cout<<'I'<<endl;
    
}

Measured memory_bytes: 3180
import sys
import re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
from queue import Queue


def input(): return sys.stdin.readline().strip()


def INT(): return int(input())


def MAP(): return map(int, input().split())


def LIST(): return list(map(int, input().split()))


sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7


def main():
    n = INT()
    a = LIST()

    ans = 0

    # if n == 1:
    #     print(1)
    #     exit()

    # if a[0] < a[1]:
    #     sign = 1
    # elif a[0] > a[1]:
    #     sign = -1
    # else:
    #     sign = 0

    sign = 0

    for i in range(n-1):
        if a[i] < a[i+1] and sign == -1:
            ans += 1
            sign = 0

        elif a[i] > a[i+1] and sign == 1:
            ans += 1
            sign = 0

        elif sign == 0:
            if a[i] < a[i+1]:
                sign = 1
            elif a[i] > a[i+1]:
                sign = -1

    print(ans + 1)


if __name__ == '__main__':
    main()


Measured memory_bytes: 16324