akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define f(i,x,n) for(ll i=x;i<n;i++)
#define fl(i,x,n) for(ll i=n;i>=x;i--)
#define print(x) cout<<x<<endl
#define vec vector<ll>
#define pai pair<ll, ll>
#define itr(it) :: iterator it
#define MAX (ll)1e16
#define MIN (ll)-1e16
using namespace std;
       ///////////   ///     ///   ///      ///   ////////////  ///      ///
       ///           ///     ///   ///      ///   ///      ///  ///      ///
       ///           ///     ///   ///      ///   ///      ///  ///      ///
       ///////////   ///////////   ///      ///   ////////////  ////////////
               ///   ///     ///   ///      ///   ///      ///  ///      ///
               ///   ///     ///   ///      ///   ///      ///  ///      ///
       ///////////   ///     ///   ////////////   ////////////  ///      ///
ll minn( ll a , ll b)
{
    if(a>b)
        return b;
    return a;
}
ll maxx( ll a , ll b)
{
    if(a>b)
        return a;
    return b;
}
ll gcdd(ll a, ll b)
{
    if(b==0)
        return a;
    else
        return gcdd(b,a%b);
}
signed main()
{
    string s;
    cin>>s;
    f(i,0,3)
    {
        if(s[i]=='1')
            s[i]='9';
        else if(s[i]=='9')
            s[i]='1';
    }
    cout<<s<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int lli;
void printGrid(vector < vector <lli> > v){
    for(int i =0;i<v.size();i++){
        for(int j = 0 ;j <v[i].size();j++){
            cout << v[i][j] << " ";
        }
        cout << endl;
    }
}
int main(){
    lli n;
    cin >> n;
    vector <lli> v(n);
    for(int i =0;i<n;i++)cin >> v[i];
    vector < vector <lli> > cost(n,vector <lli>(n));
    for(int i =0;i<n;i++){
        cost[i][i] = v[i];
        lli temp = v[i];
        for(int j = i+1;j<n;j++){
            temp+=v[j];
            cost[i][j] = temp;
        }
    }
    vector < vector <lli> > dp(n,vector <lli>(n));
    for(int l = 2;l<=n;l++){
        for(int start = 0;start + l-1<n;start++ ){
            lli end = start+l-1;
            dp[start][end] = LONG_LONG_MAX;
            for(lli k = start;k<end;k++){
                dp[start][end] = min(dp[start][end],cost[start][k] + cost[k+1][end] + dp[start][k] + dp[k+1][end]);
            }
        }
    }
    //printGrid(cost);
    //printGrid(dp);
    cout << dp[0][n-1]<<endl;
}

Measured memory_bytes: 2816
#include <cstdio>
#include <cmath>
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

#ifdef _debug
#define dmp(x) cerr << #x << ": " << x << "\n"
#else
#define dmp(x) ((void)0)
#endif

const int mod = 1000000007, inf = 1111111111; 
using namespace std;
typedef long long lint;

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	string s;
	cin >> s;

	auto sgn = [](bool x) { return x ? 1 : -1; };
	auto sgnchar = [](bool x) { return x ? '+' : '-'; };

	for (int bit = 0b0; bit < (1 << 3); bit++) {
		int tmp = s[0] - '0';
		for (int i = 0; i < 3; i++) {
			tmp += sgn((1 << i) & bit) * (s[i + 1] - '0');
		}
		if (tmp == 7) {
		
			cout << s[0];
			for (int i = 0; i < 3; i++) {
				cout << sgnchar((1 << i) & bit);
				cout << s[i + 1];
			}
			cout << "=7\n";
			break;
		}
	}

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX 10000
#define NIL -1

typedef struct{
  int p;
  int l;
  int r;
}Node;

Node T[MAX];
int n;

void preParse(int u){
  if(u == NIL) return;

  printf(" %d", u);
  preParse(T[u].l);
  preParse(T[u].r);
}

void inParse(int u){
  if(u == NIL) return;
  inParse(T[u].l);
  printf(" %d", u);
  inParse(T[u].r);
}

void postParse(int u){
  if(u == NIL) return;
  postParse(T[u].l);
  postParse(T[u].r);
  printf(" %d", u);
}

int main(){
  int i, v, l, r, root;

  scanf("%d", &n);
  for(i=0; i<n; i++){
    T[i].p = NIL;
  }

  for(i=0; i<n; i++){
    scanf("%d%d%d", &v, &l, &r);
    T[v].l = l;
    T[v].r = r;
    if(l != NIL) T[l].p = v;
    if(r != NIL) T[r].p = v;
  }

  for(i=0; i<n; i++){
    if(T[i].p == NIL) root = i;
  }

 printf("Preorder\n");
  preParse(root);
  printf("\n");
  printf("Inorder\n");
  inParse(root);
  printf("\n");
  printf("Postorder\n");
  postParse(root);
  printf("\n");

  return 0;
}

Measured memory_bytes: 620
#include <cstdio>
#include <cstring>
#include <cmath>
#include <iostream>
#include <algorithm>

using namespace std;

const int maxn = 610;
int n,D1,D2,flag[maxn][maxn],cnt;

void solve(int x)
{
    int res = 0;
    while (x % 4 == 0)
    {
        x /= 4;
        res++;
    }
    if (x % 2 == 1)
    {
        for (int i = 1; i <= n; i++)
            for (int j = 1; j <= n; j++)
                if ((((i - 1) >> res) + ((j - 1) >> res)) % 2 == 1)
                    flag[i][j] = 1;
    }
    if (x % 4 == 2)
    {
        for (int i = 1; i <= n; i++)
            for (int j = 1; j <= n; j++)
                if (((i - 1) >> res) % 2 == 1)
                    flag[i][j] = 1;
    }
}

int main()
{
    scanf("%d%d%d",&n,&D1,&D2);
    n *= 2;
    solve(D1);
    /*
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= n; j++)
            cout << flag[i][j] << " ";
        cout << endl;
    }
    cout << endl;
    */
    solve(D2);
    /*
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= n; j++)
            cout << flag[i][j] << " ";
        cout << endl;
    }
    cout << endl;
    */
    for (int i = 1; i <= n; i++)
    {
        if (cnt == (n / 2) * (n / 2))
            break;
        for (int j = 1; j <= n; j++)
        {
            if (cnt == (n / 2) * (n / 2))
                break;
            if (!flag[i][j])
            {
                printf("%d %d\n",i - 1,j - 1);
                cnt++;
            }
        }
    }

    return 0;
}


Measured memory_bytes: 2304
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Vaibhav Pulastya
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        ABeginner solver = new ABeginner();
        solver.solve(1, in, out);
        out.close();
    }

    static class ABeginner {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int r = in.nextInt();
            if (n >= 10) {
                out.println(r);
            } else {
                out.println(r + 100 * (10 - n));
            }
        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new InputMismatchException();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new InputMismatchException();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            int res = 0;
            do {
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            } while (!isSpaceChar(c));
            return res * sgn;
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}



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

int main()
{
    int n,f=0;
    cin>>n;
    if((n%10)==7)
        f=1;
    n=n/10;
    if((n%10)==7)
        f=1;
    n=n/10;
    if((n%10)==7)
        f=1;
    if(f==1)
        cout<<"Yes"<<endl;
    else
        cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 3640
#include <stdio.h>
long a,b,r,x;
int main(void){
    for(;~scanf("%ld%ld",&a,&b);){
        a<b?a^=b^=a^=b:0;
        x=a*b;
        for(r=a%b;r!=0;r=a%b){
            a=b;
            b=r;
        }
        printf("%ld %ld\n",b,x/b);
    }
    
}

Measured memory_bytes: 1728
#include <algorithm>
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <cstdio>
#define N 600011
#define INF 0x7f7f7f7f
#define int long long
using namespace std;
struct point{
	int x,y;
	bool operator<(const point &other)const{
		return y<other.y;
	}
}a[N];
struct node{
	int l,r,maxx,ad;
}tree[N*4];
struct apple{
	int no,data,l;
}Stack[2][N],temp;
int top[2],xmax,ymax,n,ans;
void push_up(int now){
	tree[now].maxx=max(tree[now*2].maxx,tree[now*2+1].maxx);
}
void push_down(int now){
	if(tree[now].ad){
		tree[now*2].ad+=tree[now].ad;
		tree[now*2+1].ad+=tree[now].ad;
		tree[now*2].maxx+=tree[now].ad;
		tree[now*2+1].maxx+=tree[now].ad;
		tree[now].ad=0;
	}
}
void build(int l,int r,int now){
	tree[now].l=l;
	tree[now].r=r;
	if(l==r){
		tree[now].maxx=xmax-a[l].y;
		return;
	}
	int mid=(l+r)/2;
	build(l,mid,now*2);
	build(mid+1,r,now*2+1);
	push_up(now);
}
void add(int l,int r,int x,int now){
	if(l<=tree[now].l && tree[now].r<=r){
		tree[now].ad+=x;
		tree[now].maxx+=x;
		return;
	}
	push_down(now);
	int mid=(tree[now].l+tree[now].r)/2;
	if(l<=mid) add(l,r,x,now*2);
	if(r>mid) add(l,r,x,now*2+1);
	push_up(now);
}
int query(int l,int r,int now){
	if(l<=tree[now].l && tree[now].r<=r){
		return tree[now].maxx;
	}
	push_down(now);
	int mid=(tree[now].l+tree[now].r)/2,ret=-INF;
	if(l<=mid) ret=max(ret,query(l,r,now*2));
	if(r>mid) ret=max(ret,query(l,r,now*2+1));
	return ret;
}
void solve(){
	memset(tree,0,sizeof(tree));
	memset(Stack,0,sizeof(Stack));
	memset(top,0,sizeof(top));
	sort(a+1,a+n+1);
	a[n+1].y=ymax;
//	for(int i=1;i<=n;i++){
//		ans=max(ans,xmax+a[i+1].y-a[i].y);
//	}
	build(0,n,1);
	int mid=xmax/2,x;
	temp.no=0,temp.l=100,temp.data=0;Stack[0][++top[0]]=temp;
	temp.no=0,temp.l=100,temp.data=xmax;Stack[1][++top[1]]=temp;
//	a[n+1].x=0,a[n+1].y=ymax;
//	a[n+2].x=xmax,a[n+2].y=ymax;
//ans=0;
	for(int i=1;i<=n;i++){
		ans=max(ans,a[i].y+query(0,i-1,1));
		temp.no=i;
		temp.data=a[i].x;
		int fin=i;
		if(a[i].x<=mid){
			temp.l=Stack[0][top[0]].no;
			add(Stack[0][top[0]].no,i-1,-a[i].x,1);
			while(top[0] && Stack[0][top[0]].data<a[i].x){
				x=Stack[0][top[0]].no;
				add(Stack[0][top[0]].l,x-1,Stack[0][top[0]].data-a[i].x,1);
//				fin=Stack[0][top[0]].l;
				temp.l=min(temp.l,Stack[0][top[0]].l);
				top[0]--;
			}
			Stack[0][++top[0]]=temp;
		}
		else{
			temp.l=Stack[1][top[1]].no;
			add(Stack[1][top[1]].no,i-1,a[i].x-xmax,1);
			while(top[1] && Stack[1][top[1]].data>a[i].x){
				x=Stack[1][top[1]].no;
				add(Stack[1][top[1]].l,x-1,a[i].x-Stack[1][top[1]].data,1);
//				fin=Stack[1][top[1]].l;
				temp.l=min(temp.l,Stack[1][top[1]].l);
				top[1]--;
			}
			Stack[1][++top[1]]=temp;
		}
	}
	ans=max(ans,xmax+ymax-a[n].y);
	ans=max(ans,ymax+query(0,n,1));
}
signed main(){
	scanf("%lld%lld%lld",&xmax,&ymax,&n);
	for(int i=1;i<=n;i++) scanf("%lld%lld",&a[i].x,&a[i].y);
	solve();
	for(int i=1;i<=n;i++) swap(a[i].x,a[i].y);
	swap(xmax,ymax);
	solve();
	printf("%lld",ans*2);
	return 0;
}

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

int main(){
  int N, K, fruit;
  cin >> N >> K;
  
  vector<int> fruits;
  for (int i = 0; i < N; i++){
  cin >> fruit;
  fruits.push_back(fruit);
  }
  
  sort(fruits.begin(), fruits.end());
  
  int cost = 0;
  for (int i = 0; i < K; i++) cost += fruits[i];
  
  cout << cost;
  
  return 0;
  
}

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

#define REP(i, start, count) for(int i=(start); i<(int)(count); ++i)
#define rep(i, count) REP(i, 0, count)
#define ALLOF(c) (c).begin(), (c).end()

using ll = long long;
using ull = unsigned long long;
using veci = vector<int>;
using vecll = vector<ll>;
using vecull = vector<ull>;

int main(void) {
    int X, N;
    cin >> X >> N;
    veci p(N);
    rep(i, N) {
        cin >> p[i];
    }

    // plus
    int upper = X;
    while (true) {

        bool contain = false;
        rep(i, N) {
            if (upper == p[i]){
                contain = true;
                break;
            }
        }
        if (contain) {
            upper++;
        }
        else {
            break;
        }
    }

    // minus
    int downer = X;
    while (true)
    {

        bool contain = false;
        rep(i, N)
        {
            if (downer == p[i])
            {
                contain = true;
                break;
            }
        }
        if (contain)
        {
            downer--;
        }
        else
        {
            break;
        }
    }
    int ans = downer;
    if (abs(upper - X) < abs(downer - X)) {
        ans = upper;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3632
h,w,k = map(int,input().split())
s = [list(input()) for i in range(h)]
ans = 0
for i in range(2**h-1):
    for j in range(2**w-1):
        cnt = 0
        for x in range(h):
            for y in range(w):
                if (i>>x)&1==0 and (j>>y)&1==0 and s[x][y]=='#':
                    cnt+=1
        if cnt==k:
            ans+=1
print(ans)

Measured memory_bytes: 9152
#include<iostream>

using namespace std;

int x, y, s;

int extax(int p_a, int x){
	//?¨?????????????????±???????
	int res = 0;
	int tmp;
	do{
		tmp = (++res)*(100+x)/100;
		if(tmp > p_a) return 0;
	}while(tmp!=p_a);

	return res;
}

int intax(int p_b, int y){
	//?¨????????????????
	return p_b*(100+y)/100;
}

int main(){
	while(cin >> x >> y >> s,s){
		int a, b;
		int maxn = 0;
		for(int i=1;i<=s/2+1;i++){
			a = intax(i,x);
			b = s - a;
			if(a * b <= 0) continue;
			int sum_b = a + b;
			int sum_a = intax(i,y) + intax(extax(b,x),y);
			if(sum_a > maxn){
				//cout << a << " " << b << " " << sum_a << " " << sum_b << endl;
				maxn = sum_a;
			}
		}
		cout << maxn << endl;
	}
				
	return 0;
}

Measured memory_bytes: 3072
//#pragma GCC optimize "trapv"
#include<bits/stdc++.h>
#define  all(v)            v.begin(), v.end()
#define  sz(x)             (long long)x.size()
#define  debug(x)          cout << #x << ':' << x << endl;
#define  rep(i,n)          for(int i = 0; i <  n ; i++)
#define  reps(i,n)         for(int i = 1; i <= n ; i++)
#define  make_unique(v)    sort(all(v));v.erase(unique(all(v)), v.end());
#define  REMOVE(v,a)       v.erase(remove(v.begin(),v.end(), a), v.end());
#define  pb                push_back
#define  mp                make_pair
#define  endl              '\n'
#define  fi                first
#define  se                second
#define  ajs(a)            (a<0)?(-1*a):a

using namespace std;
typedef long long          ll;
typedef vector<long long>  vll;
typedef pair<ll,ll>        pll;
typedef vector<int>        vi;
const ll MOD = 1e9+7;
const int dx4[4] = {0, 1, 0, -1};
const int dy4[4] = {-1, 0, 1, 0};
const int dx8[8] = { -1, -1, -1, 0, 1, 1, 1, 0};
const int dy8[8] = { -1, 0, 1, 1, 1, 0, -1, -1};
bool cmp(int X, int Y) {return X > Y;}


ll gcd(ll a, ll b) {return !b ? a : gcd(b, a % b);}
ll lcm(ll a, ll b) {return (a / gcd(a, b)) * b;}
ll modpow(ll a, ll b, ll m=MOD){a %= m; ll res = 1; while (b) {if (b & 1)res = (res * a) % m; a = (a * a) % m; b >>= 1;} return res;}
ll bpow(ll a, ll b){if(b<0){return 0;}ll res = 1; while (b) {if (b & 1)res = res * a; a = a * a; b >>= 1;} return res;}
ll modinv(ll a, ll m = MOD) {return modpow(a, m - 2, m);}


const int N = 1e6 + 5;
vi adj[N];
ll vis[102][102];



int main(){ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll n,x,t;cin>>n>>x>>t;
ll ans = (n+x-1)/x;
ans*=t;
cout<<ans;
	
}





	
	




		



Measured memory_bytes: 27096
#include<bits/stdc++.h>
#define mod 1000000007
#define int long long int
#define phi 1.6180339
#define rep(i,n) for(auto i=0;i<(n);i++)
#define endl "\n"
#define For(i,a,b) for(auto i=(a);i<(b);i++)
#define op1 cin.tie(NULL)
#define op2 cout.tie(NULL)
#define op3 std::ios_base::sync_with_stdio(false)
#define MAXX 1000001
using namespace std;
vector<int> arr(MAXX);
void trozen()
{
    int n;
    string s;
    cin>>n>>s;
    string temp="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    for(int i=0;i<s.length();i++)
    {
        int index;
        for(int k=0;k<26;k++)
            if(temp[k]==s[i])
            {
                index=k;
                break;
            }
        s[i]=temp[(index+n)%26];
    }
    cout<<s<<endl;
}
int32_t main()
{
    op1;op2;op3;
    /*#ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif*/
    trozen();
    return 0;
}


Measured memory_bytes: 10980
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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



int main(){
    ll n,m;
    cin >> n >> m;

    vector<ll> p(m);
    vector<string> S(m);
    REP(i,m){
        cin >> p[i] >> S[i];
    }

    vector<ll> correct(n,0);
    vector<ll> penalty(n,0);
    
    REP(i,m){
        if(S[i] == "WA" & correct[p[i]-1] == 0){
            penalty[p[i]-1] += 1; 
        }
        else if(S[i] == "AC"){
            correct[p[i]-1] = 1;
        }
    }
    REP(i,m){
        penalty[p[i]-1] = correct[p[i]-1]* penalty[p[i]-1];
    }
    cout << accumulate(correct.begin(),correct.end(),0LL) << ' ' << accumulate(penalty.begin(),penalty.end(),0LL) << endl;
    /*
    REP(i,n){
        cout << correct[i];
    }
    cout << endl;
    REP(i,n){
        cout << penalty[i];
    }
    cout << endl;
*/
}

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

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define SIZE(x) ((int)(x).size())
#define MIN(c) (*min_element(ALL(c))) 
#define MAX(c) (*max_element(ALL(c)))
#define ACC(c) (accumulate(ALL(c), 0))
#define SLL(x, n) ((x) << (n))
#define SRL(x, n) ((x) >> (n))
#define MIN2(a, b) ((a) < (b)) ? (a) : (b)
#define MAX2(a, b) ((a) > (b)) ? (a) : (b)
#define MP(a, b) (make_pair((a), (b)))
#define ENDL "\n"
#define PRINT(x) cout << (x) << ENDL

using namespace std;
using ll = long long;
using pint = pair<int, int>;

inline int in(int& a) {return scanf("%d", &a);}
inline void out(int n) {printf("%d\n", n);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};


int N, M;
int k[10], s[10][10], p[10];

bool isValid(int state){
    bool ok[10];
    REP(i, M){
        ok[i] = (p[i] == 0);
    }
    REP(i, M){
        REP(j, k[i]){
            if(state & SLL(1, s[i][j])) ok[i] = !ok[i];
        }
    }
    REP(i, M){
        if(!ok[i]) return false;
    }
    return true;
}

signed main(){
    cin >> N >> M;
    REP(i, M){
        cin >> k[i];
        REP(j, k[i]){
            cin >> s[i][j];
            s[i][j]--;
        }
    }
    REP(i, M) cin >> p[i];
    int cnt = 0;
    FOR(i, 0, SLL(1, N)){
        if(isValid(i)) cnt++;
    }
    PRINT(cnt);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC return 0;
using namespace std;
const int N(2e5 + 5);
int n, freq[N], a[N];
long long res, curr;
int main() {
    DAU
    cin >> n;
    for (int i = 1; i <= n; ++i)
        cin >> a[i], ++freq[a[i]];
    for (int i = 1; i <= n; ++i)
        res += (1LL * freq[i] * (freq[i] - 1)) / 2;
    for (int i = 1; i <= n; ++i) {
        curr = res - (1LL * freq[a[i]] * (freq[a[i]] - 1)) / 2;
        --freq[a[i]];
        curr += (1LL * freq[a[i]] * (freq[a[i]] - 1)) / 2;
        ++freq[a[i]];
        cout << curr << '\n';
    }
    PLEC
}


Measured memory_bytes: 3712
import itertools

N, A, B, C = map(int, input().split())
l = [0 for _ in range(N)]
for i in range(N):
    l[i] = int(input())


ans = 10 ** 8
for t in list(itertools.product((0, 1, 2, 3), repeat=len(l))):
    a = [i for i, j in zip(l, t) if j == 0]
    b = [i for i, j in zip(l, t) if j == 1]
    c = [i for i, j in zip(l, t) if j == 2]
    if len(a) * len(b) * len(c) == 0:
        continue
    tmp1 = abs(sum(a) - A) + max(0, len(a) - 1) * 10
    tmp2 = abs(sum(b) - B) + max(0, len(b) - 1) * 10
    tmp3 = abs(sum(c) - C) + max(0, len(c) - 1) * 10
    ans = min(ans, tmp1 + tmp2 + tmp3)


print(ans)

Measured memory_bytes: 10996
#include <bits/stdc++.h>
using namespace std;
#define PI 3.14159265358979323
#define ll long long int
#define vi vector <int>
#define vl vector <ll>
#define all(v) (v).begin(),(v).end()
#define pb push_back
#define MOD 1000000007
ll power(ll a, ll b) { //a^b
	ll res = 1;
	a = a % MOD;
	while (b > 0) {
		if (b & 1) {res = (res * a) % MOD; b--;}
		a = (a * a) % MOD;
		b >>= 1;
	}
	return res;
}

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

int main() {
#ifndef ONLINE_JUDGE
	// for getting input from input.txt
	freopen("input.txt", "r", stdin);
	// for writing output to output.txt
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	ll x, k, d;
	cin >> x >> k >> d;
	ll ans;
	if (x >= 0) {
		ll times = x / d;
		if (times >= k)
			ans = x - d * k;
		else {
			x = x - times * d;
			k = k - times;
			if (k % 2)
				ans = abs(x - d);
			else
				ans = x;
		}
	}
	else {
		x = x * -1;
		ll times = x / d;
		if (times >= k)
			ans = x - d * k;
		else {
			x = x - times * d;
			k = k - times;
			if (k % 2)
				ans = abs(x - d);
			else
				ans = x;
		}
	}
	cout << ans << "\n";
}


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

int main() {
	int p = 0, o = 3;
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	if (a == b) o--;
	if (b == c) o--;
	if (a == c) o--;
	if (o == 0) o++;
	printf("%d\n", o);
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;


public class Main {
//	final static int MOD = 1000000007;

	public static long ans = 0;

	public static void main(String[] args) {

//		int ans = 0;
		Scanner sc = new Scanner(System.in);
		boolean f = false;

//		long a = sc.nextLong();

		long a = sc.nextInt();
		long b = sc.nextInt();
		long c = sc.nextInt();
		long k = sc.nextInt();


		//-------------------------------------------------------------------------------------

		for(int i = 0; i <= k; i++) {
			for(int j = 0; j <= k; j++) {
				for(int l = 0; l <= k; l++) {
					if(i + j + l <= k)
						f = name(i, j, l, a, b, c);
					if(f) break;
				}
				if(f) break;
			}
			if(f) break;
		}

		//-------------------------------------------------------------------------------------

		if(f) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}

//		System.out.println(ans);

		sc.close();
	}

	public static boolean name(int i, int j, int l, long a, long b, long c) {
		long tmpa = a;
		long tmpb = b;
		long tmpc = c;
		for(int t = 0; t <= i; t++) {
			tmpa *= 2;
		}
		for(int t = 0; t <= j; t++) {
			tmpb *= 2;
		}
		for(int t = 0; t <= l; t++) {
			tmpc *= 2;
		}

		if(tmpc > tmpb && tmpb > tmpa) {
			return true;
		} else {
			return false;
		}
	}



}

Measured memory_bytes: 35600
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))

n = int(input())
p = LI()
cnt = 0

for i in range(1,n-1):
    if p[i-1] < p[i] < p[i+1] or p[i-1] > p[i] > p[i+1]:
        cnt += 1

print(cnt)


Measured memory_bytes: 6860
# -*- coding: utf-8 -*-
import math

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

chk_0 = 0
for i in range(N):
  if ( A[i]==0 ):
    chk_0 = 1

if ( chk_0 == 1 ):
  print(0)
else:
  log10_A = 0
  for i in range(N):
    log10_A += math.log10(A[i])
  #print(log10_A)
  
  if ( log10_A > 18 ):
    print(-1)
  else:
    ans = 1
    for i in range(N):
      ans = ans*A[i]
    if ( ans > 10**18 ):
      print(-1)
    else:
      print(ans)

Measured memory_bytes: 22268
#include <iostream>
#include <vector>
#include <stdio.h>
using namespace std;
int main() {
  int N,g_size,k_size;
  cin >> N;
  vector<int> guusuu;
  vector<int> kisuu;
  for (int i=1;i<=N;i++){
    if (i%2==0){
	    guusuu.push_back(1);
    }else {
	    kisuu.push_back(1);
    }
    g_size = guusuu.size();
    k_size = kisuu.size();
  }
  cout << g_size*k_size <<"\n";
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,a,b) for(int i=(a);i<(b);i++)
#define pb push_back
#define eb emplace_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second

using vint=vector<int>;
using pint=pair<int,int>;
using vpint=vector<pint>;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

template<class A,class B>
ostream& operator<<(ostream& ost,const pair<A,B>&p){
	ost<<"{"<<p.first<<","<<p.second<<"}";
	return ost;
}

template<class T>
ostream& operator<<(ostream& ost,const vector<T>&v){
	ost<<"{";
	for(int i=0;i<v.size();i++){
		if(i)ost<<",";
		ost<<v[i];
	}
	ost<<"}";
	return ost;
}

template<uint32_t mod>
struct ModInt{
	uint32_t a;
	ModInt& s(uint32_t vv){
		a=vv<mod?vv:vv-mod;
		return *this;
	}

	ModInt(int64_t x=0){s(x%mod+mod);}

	ModInt& operator+=(const ModInt &x){return s(a+x.a);}
	ModInt& operator-=(const ModInt &x){return s(a+mod-x.a);}
	ModInt& operator*=(const ModInt &x){
		a=uint64_t(a)*x.a%mod;
		return *this;
	}
	ModInt& operator/=(const ModInt &x){
		*this*=x.inv();
		return *this;
	}

	ModInt operator+(const ModInt &x)const{return ModInt(*this)+=x;}
	ModInt operator-(const ModInt &x)const{return ModInt(*this)-=x;}
	ModInt operator*(const ModInt &x)const{return ModInt(*this)*=x;}
	ModInt operator/(const ModInt &x)const{return ModInt(*this)/=x;}
	bool operator==(const ModInt &x)const{return a==x.a;}
	bool operator!=(const ModInt &x)const{return a!=x.a;}
	bool operator<(const ModInt &x)const{return a<x.a;}

	ModInt operator-()const{return ModInt()-*this;}
	ModInt pow(int64_t n)const{
		ModInt res(1),x(*this);
		while(n){
			if(n&1)res*=x;
			x*=x;
			n>>=1;
		}
		return res;
	}

	ModInt inv()const{return pow(mod-2);}
};

template<uint32_t mod>
istream& operator>>(istream& in,ModInt<mod>& a){
	return (in>>a.a);
}
template<uint32_t mod>
ostream& operator<<(ostream& out,const ModInt<mod>& a){
	return (out<<a.a);
}
using mint=ModInt<998244353>;

const int L=1000000;

int N;
int A[222222];

mint sum[L+1];
mint sq[L+1];
mint f[L+1];
signed main(){
	scanf("%lld",&N);
	rep(i,N)scanf("%lld",&A[i]);

	rep(i,N){
		sum[A[i]]+=A[i];
		sq[A[i]]+=A[i]*A[i];
	}

	for(int i=1;i<=L;i++){
		for(int j=i+i;j<=L;j+=i){
			sum[i]+=sum[j];
			sq[i]+=sq[j];
		}
	}

	for(int i=1;i<=L;i++){
		f[i]=sum[i]*sum[i]-sq[i];
	}
	mint ans;
	for(int i=L;i>0;i--){
		for(int j=i+i;j<=L;j+=i)f[i]-=f[j];
		ans+=f[i]/i;
	}

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

Measured memory_bytes: 13568
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <cstring>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <unordered_set>
#include <unordered_map>
#include <array>
#include <cassert>
#include <bitset>
using namespace std;
using LL = long long;

string S;
LL N;

LL digitsum(LL n) {
	LL res = 0;
	while (n > 0) {
		res += n % 10;
		n /= 10;
	}
	return res;
}

int main(void)
{
	cin >> S;
	int len = S.size();
	N = atoll(S.c_str());
	LL ten = 1;
	LL ans = digitsum(N);
	for (int i = 1; i < len; ++i) {
		ten *= 10;
		LL nine = ten - 1;
		LL dif = (N - nine);
		dif /= ten;
		LL num = dif * ten + nine;
		assert(num >= 0);
		if (num > N) {
			continue;
		}
		ans = max(ans, digitsum(num));
	}
	cout << ans << endl;
	return 0;
}


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

string s;
string t;
int a,b;
string u;

int main(){
  cin >> s >> t;
  cin >> a >> b;
  cin >> u;
  if(s==u){
    cout << a - 1 << ' ' << b << endl;
  }
  else{
    cout << a << ' ' << b-1 << endl;
  }
}

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

using namespace std;
typedef long long ll;
const int N = 5e5 + 10;
char s[N];
char str[N];

void solved()
{
    cin >> str;
    int q,cases;
    cin >> q;
    int l = 2e5,r = l - 1;
    int n = strlen(str);
    for(int i = 0;i < n;i++)
    {
        s[++r] = str[i];
    }
    while(q--)
    {
        cin >> cases;

        if(cases == 1)swap(l,r);
        else 
        {
            int f;
            string str;
            cin >> f >> str;
            if(f == 1)
            {
                if(l <= r)s[--l] = str[0];
                else s[++l] = str[0];
            }
            else 
                if(l <= r)s[++r] = str[0];
                else s[--r] = str[0];
        }
    }
    if(l > r)
    for(int i = l;i >= r;i--)cout << s[i];
    else 
    for(int i = l;i <= r;i++)cout << s[i];

}


int main()
{
#ifdef ONLINE_JUDGE
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#endif 
    int t = 1;
    //cin >> t;
    while(t--)
    {
        solved();
    }

#ifdef LOCAL
    system("pause");
#endif 
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  vector<int> A;
  long sum=0;
  for(int i=0; i<N; i++)
{
    int a; cin >> a;
    sum+=a;
    A.push_back(a);
  }
  long min = INT_MAX;
  long sum2 =0;
  for(int i=0; i<N-1; i++){
    sum2+=A[i];
    sum-=A[i];
    if(abs(sum2-sum)<min)
{
      min=abs(sum2-sum);
    }
  }
  cout << min << endl;
  return 0;
}


Measured memory_bytes: 1400
def smaller(x, y):
	if x < y:
		return x
	return y

N, K = map(int, input().split())
H = []
for i in range(0, N):
	H.append(int(input()))
H.sort()
ans = 5000000000000000
for i in range(0, N-K+1):
	ans = smaller(ans, H[i+K-1]-H[i])
print(ans)

Measured memory_bytes: 50520
#include<iostream>
#include<sstream>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<complex>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cassert>

#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define mp make_pair
#define pb push_back
#define each(i,c) for(__typeof((c).begin()) i=(c).begin();i!=(c).end();i++)
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = "<<(x)<<endl
#define F first
#define S second
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;
const int inf = (int)1e9;
const double INF = 1e12, EPS = 1e-9;

int n, c[50], t[50];
bool cmp(const pi &a, const pi &b){
	return t[a.F] < t[b.F];
}
int main(){
	while(cin >> n, n){
		rep(i, n) cin >> t[i] >> c[i];
		vector<pi> vv;
		rep(i, n) vv.pb(mp(t[i], i));
		sort(all(vv));
		queue<pair<int, pi> > q[2];
		rep(i, n) q[0].push(mp(vv[i].S, mp(vv[i].F, 0)));
		
		int cur = 0, next = 1, ans = 0;
		while(q[0].size() || q[1].size()){
			
			if(q[cur].empty()) swap(cur, next);
			else if(q[next].size() && q[cur].front().S.F > q[next].front().S.F) swap(cur, next);
			
			vector<pi> v;
			int nxt = q[cur].front().S.F;
			while(q[cur].size() && q[cur].front().S.F <= nxt){
				v.pb(mp(q[cur].front().F, q[cur].front().S.S));
				q[cur].pop();
			}
			sort(all(v), cmp);
			rep(i, v.size()){
				if(cur == 1) v[i].S++;
				if(v[i].S == c[v[i].F]) assert(ans <= nxt), ans = nxt;
				else q[next].push(mp(v[i].F, mp(nxt + t[v[i].F], v[i].S)));
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 1224
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    string a,b,c;
    cin>>a>>b>>c;
    if(a[a.size()-1]==b[0]&&b[b.size()-1]==c[0]){
    cout<<"YES"<<endl;
    }else{
      cout<<"NO"<<endl;
    }
}


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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  S[3] = '8';
  cout << S << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
const double PI = acos(-1);
const double EPS = 1e-15;
long long INF=(long long)1E17;
#define i_7 (long long)(1E9+7)
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
using namespace std;
bool prime(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}

long long gcd(long long a, long long b){
  if(a<b){
    swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd(b,a%b);
  }
}
 
long long lcm(long long x, long long y){
  return (x/gcd(x,y))*y;
}
 
class UnionFind {
    public:
    //各頂点の親の番号を格納する。その頂点自身が親だった場合は-(その集合のサイズ)を入れる。
    vector<int> Parent;
    
    //クラスを作るときは、Parentの値を全て-1にする。
    //以下のようにすると全てバラバラの頂点として解釈できる。
    UnionFind(int N) {
        Parent = vector<int>(N, -1);
    }
    
    //Aがどのグループに属しているか調べる
    int root(int A) {
        if (Parent[A] < 0) return A;
        return Parent[A] = root(Parent[A]);
    }
    
    //自分のいるグループの頂点数を調べる
    int size(int A) {
        return -Parent[root(A)];//先祖をrootで取っておきたい。
    }
    
    //AとBをくっ付ける
    bool connect(int A, int B) {
        //AとBを直接つなぐのではなく、root(A)にroot(B)をくっつける
        A = root(A);
        B = root(B);
        if (A == B) {
            //すでにくっついてるからくっ付けない
            return false;
        }
        
        //大きい方(A)に小さいほう(B)をくっ付けたい
        //大小が逆だったらAとBをひっくり返す。
        if (size(A) < size(B)) swap(A, B);
        
        //Aのサイズを更新する
        Parent[A] += Parent[B];
        //Bの親をAに変更する
        Parent[B] = A;
        
        return true;
    }
};

int main(){
  int x,y;
  cin>>x>>y;
  if(x>=0 && y>=0){
    if(x<y){
      cout<<y-x<<endl;
    }else{
      cout<<min(x+y+1,x-y+2)<<endl;
    }
  }else if(x>=0 && y<0){
    if(x<abs(y)){
      cout<<abs(y)-x+1<<endl;
    }else{
      cout<<x-abs(y)+1<<endl;
    }
  }else if(x<0 && y>=0){
    if(abs(x)<y){
      cout<<min(y-x,y-abs(x)+1)<<endl;
    }else{
      cout<<min(y-x,abs(x)-y+1)<<endl;
    }
  }else{
    if(abs(x)<abs(y)){
      cout<<abs(y)-abs(x)+2<<endl;
    }else{
      cout<<abs(x)-abs(y)<<endl;
    }
  }
  return 0;
}


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

int main(){
  int n, x, num;
  int ans = 0;
  cin >> n >> x;
  vector<int> L(n + 1);
  L[0] = 0;
  for (int i = 1; i < n + 1; i++){
    cin >> num;
    L[i] = L[i - 1] + num;
  }
  rep(i, n + 1){
    if(L[i] > x){
      break;
    }else {
      ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
        static void Main(string[] args)
        {
            try
            {
                SetOut(sw);
                Solve.Answer();
                Out.Flush();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var nk = IO.RSInt;
            var h = new int[nk[0]];
            for (int i = 0; i < nk[0]; i++)
            {
                h[i] = IO.RInt;
            }
            Array.Sort(h);
            var sub = new int[nk[0] - nk[1] + 1];
            for (int i = 0; i < nk[0] - nk[1] + 1; i++)
            {
                sub[i] = h[i + nk[1] - 1] - h[i];
            }
            WriteLine(sub.Min());
        }
    }

    public class IO
    {
        #region Input
        public static int RInt => int.Parse(ReadLine());
        public static long RLong => long.Parse(ReadLine());
        public static double RDouble => double.Parse(ReadLine());

        public static string[] RSString => ReadLine().Split();
        public static int[] RSInt => ReadLine().Split().Select(s => int.Parse(s)).ToArray();
        public static long[] RSLong => ReadLine().Split().Select(s => long.Parse(s)).ToArray();
        public static double[] RSDouble => ReadLine().Split().Select(s => double.Parse(s)).ToArray();
        #endregion

        #region Output
        public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
        public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");
        public static void WriteLineYES_or_NO(bool flag) => WriteLine(flag ? "YES" : "NO");
        #endregion
    }

    public class Mod
    {
        #region
        private readonly static long M = 1000000007;

        public static long Add(long a, long b) => (a * b) % M;
        public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
        public static long Multi(long a, long b) => (a * b) % M;
        #endregion
    }
}

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

int main() {
    int R, G, B, N; cin >> R >> G >> B >> N;
    int n_r = N / R, n_g = N / G;
    int b, r_b, count = 0;
    for (int r = 0; r <= n_r; r++) {
        for (int g = 0; g <= n_g; g++) {
            b = (N - R * r - G * g) / B;
            r_b = (N - R * r - G * g) % B;
            if (b >= 0 && r_b == 0) count++;
        }
    }
    cout << count << endl;
    return 0;
}


Measured memory_bytes: 256
<?php
$word = strtolower(trim(fgets(STDIN)));
$c = 0;
while(true){
  $in = trim(fgets(STDIN));
  if($in === "END_OF_TEXT") break;

  $array = explode(" ", $in);
  foreach($array as $a){
    if(strtolower($a) === $word) ++$c;
  }
}
print($c . "\n");



Measured memory_bytes: 9232
n = int(input())
l = 0
r = float("INF")
w = 0
LR = sorted([list(map(int,input().split())) for i in range(n)])
rm = [float("INF")]*(n+1)
for i in range(n):
    rm[-2-i] = min(rm[-1-i],LR[-1-i][1])
for i in range(n):
    x,y = LR[-1-i]
    l = max(l,x)
    r = min(r,y)
    w = max(w,y-x+1)
    rm[-2-i] = min(rm[-1-i],y)
ans = max(r-l+1,0)+w
for k in range(n-1):
    i,j = LR[k]
    a = max(r-i+1,0)
    b = max(rm[k+1]+1-l,0)
    ans = max(ans,a+b)
print(ans)

Measured memory_bytes: 28372
module.exports=function(t){var e={};function r(n){if(e[n])return e[n].exports;var i=e[n]={i:n,l:!1,exports:{}};return t[n].call(i.exports,i,i.exports,r),i.l=!0,i.exports}return r.m=t,r.c=e,r.d=function(t,e,n){r.o(t,e)||Object.defineProperty(t,e,{enumerable:!0,get:n})},r.r=function(t){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(t,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(t,"__esModule",{value:!0})},r.t=function(t,e){if(1&e&&(t=r(t)),8&e)return t;if(4&e&&"object"==typeof t&&t&&t.__esModule)return t;var n=Object.create(null);if(r.r(n),Object.defineProperty(n,"default",{enumerable:!0,value:t}),2&e&&"string"!=typeof t)for(var i in t)r.d(n,i,function(e){return t[e]}.bind(null,i));return n},r.n=function(t){var e=t&&t.__esModule?function(){return t.default}:function(){return t};return r.d(e,"a",e),e},r.o=function(t,e){return Object.prototype.hasOwnProperty.call(t,e)},r.p="",r(r.s=0)}([function(t,e,r){"use strict";var n=r(1);r(2)(n.readFileSync("/dev/stdin","utf8"))},function(t,e){t.exports=require("fs")},function(t,e,r){"use strict";var n=r(3),i=r(5);t.exports=function(t){var e=new n(t);i(e)}},function(t,e,r){"use strict";var n=r(4);t.exports=class{constructor(t){var e=t.trim().split(/\s+/g);this.inp=new n(e)}inr(){return this.inp.deq()}in(){return parseInt(this.inp.deq(),10)}fin(){this.inp.clear()}}},function(t,e,r){"use strict";t.exports=class{constructor(){var t=arguments.length>0&&void 0!==arguments[0]?arguments[0]:[];this.size=t.length,this.items=t,this.ind=0}enq(t){this.size+=1,this.items.push(t)}deq(){var t=this.items[this.ind];return this.size-=1,this.ind+=1,t}clear(){this.items=[],this.size=0,this.ind=0}}},function(t,e,r){"use strict";t.exports=function(t){var e=t.inr();console.log(e.replace(/,/g," "))}}]);

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

using namespace std;
typedef long long ll;

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

    vector<int> vec(n);
    
    ll sum = 0;
    int h;
    for (int i = 0; i < n; i++) {
        cin >> h;
        vec.at(i) = h;
        sum += h;
    }

    sort(vec.begin(), vec.end());

    for (int i = 0; i < k; i++) {
        if (vec.empty()) {
            break;
        }
        sum -= vec.at(n - 1 - i);
        vec.pop_back();
    }

    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#define SENTINEL 1000000001
typedef struct
{
  char c;
  int x;
} card;
void quickSort(card*,int,int);
int partition(card*,int,int);
void swap(card*,int,int);
void merge(card*,int,int,int);//almost same function compared to 5B
void mergeSort(card*,int,int);//almost same function compared to 5B
int arrayCompare(card*,card*,int);
void printArray(card*,int);
int main(void)
{
  int i;//counter
  int n;//length of array
  int par;//partition number
  card *arr;
  card *stableArr;
  scanf("%d",&n);
  arr=(card*)malloc(sizeof(card)*n);
  stableArr=(card*)malloc(sizeof(card)*n);
  for(i=0;i<n;i++)
    {
      scanf(" %c %d",&arr[i].c,&arr[i].x);
      stableArr[i]=arr[i];
    }
  quickSort(arr,0,n-1);
  mergeSort(stableArr,0,n);
  if(arrayCompare(arr,stableArr,n)==1) printf("Stable\n");
  else printf("Not stable\n");
  printArray(arr,n);
  return 0;
}
void quickSort(card *arr,int p,int r)
{
  int q;
  if(p<r)
    {
      q=partition(arr,p,r);
      quickSort(arr,p,q-1);
      quickSort(arr,q+1,r);
    }
}
int partition(card *arr,int p,int r)
{
  int i;//counter
  int parlast;//last index of first half part
  int sep=arr[r].x;//separate number
  parlast=p-1;
  for(i=p;i<r;i++)
    {
      if(arr[i].x<=sep)
	{
	  parlast++;
	  swap(arr,parlast,i);
	}
    }
  swap(arr,parlast+1,r);
  return parlast+1;
}
void swap(card *arr,int x,int y)
{
  card temp;
  temp=arr[x];
  arr[x]=arr[y];
  arr[y]=temp;
}
void merge(card *arr,int left,int mid,int right)
{
  int i,j,k;//counter
  int n1=mid-left;//the number of elements in array l
  int n2=right-mid;//the number of elements in array r
  card *l=(card*)malloc(sizeof(card)*(n1+1));
  card *r=(card*)malloc(sizeof(card)*(n2+1));
  for(i=0;i<n1;i++) l[i]=arr[left+i];
  for(i=0;i<n2;i++) r[i]=arr[mid+i];
  l[n1].x=SENTINEL;
  r[n2].x=SENTINEL;
  i=0;
  j=0;
  for(k=left;k<right;k++)
    {
      if(l[i].x<=r[j].x)
	{
	  arr[k]=l[i];
	  i++;
	}
      else
	{
	  arr[k]=r[j];
	  j++;
	}
    }
  free(l);
  free(r);
}
void mergeSort(card *arr,int left,int right)
{
  int mid;//separate point of array
  if(left+1<right)
    {
      mid=(left+right)/2;
      mergeSort(arr,left,mid);
      mergeSort(arr,mid,right);
      merge(arr,left,mid,right);
    }
}
int arrayCompare(card *arr1,card *arr2,int n)
{
  int i;
  for(i=0;i<n;i++)
    {
      if(arr1[i].c!=arr2[i].c||arr1[i].x!=arr2[i].x) return 0;
    }
  return 1;
}
void printArray(card *arr,int n)
{
  int i;//counter
  for(i=0;i<n;i++) printf("%c %d\n",arr[i].c,arr[i].x);
}



Measured memory_bytes: 3736
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i,n) for (int i = 0; i < (n); ++i)
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; }
const ll INF=1LL<<60;
const int inf=(1<<30)-1;
const int mod=1e9+7;
int dx[8]={1,0,-1,0,-1,-1,1,1};
int dy[8]={0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    double a,b,h,m;cin >> a >> b >> h >> m;
    double x=h*30.0+m/2.0,y=m*6;
    double t=min(abs(x-y),360-abs(x-y));
    cout << fixed << setprecision(15) << sqrt(a*a+b*b-2*a*b*cos(t/180.0*M_PI)) << endl;
}

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

def lcm(a, b):
    return a // gcd (a, b) * b

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

n, m = map(int, input().split())
g = gcd(n,m)
if g == 1:
    print(1)
else:
    print(len(factorization(g))+1)


Measured memory_bytes: 3188
#include <stdio.h>

int main(){
  int stats[5], sum = 0, ave, i;
  for(i = 0; i < 5; i++){
    scanf("%d", &stats[i]);
    if(stats[i] < 40) stats[i] = 40;
    sum = sum + stats[i];
  }
  ave = sum / 5;
  printf("%d\n", ave);
  return 0;
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
#define F first
#define S second
#define T second.first
#define C second.second
#define FIO ios_base::sync_with_stdio(0);cin.tie(0);
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int,pair<int,int>> piii;

const int N= 1e2+5, L = 14, OO = 0x3f3f3f3f;
const int M= 1e9+7;
const double ESP = 1e-8;

char A[1005][1005];
int mem[1005][1005];
int n, m;
int solve(int idx1, int idx2){
    if(idx1 == n || idx2 == m || A[idx1][idx2] == '#')
        return 0;
    if(idx1 == n-1 && idx2 == m-1)
        return 1;

    int& ret = mem[idx1][idx2];
    if(~ret)
        return ret;

    return ret = (solve(idx1+1, idx2) + solve(idx1, idx2+1))%M;
}


int main(){
    FIO
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
    cin>>n>>m;
    memset(mem, -1, sizeof mem);
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++)
            cin>>A[i][j];
    }
    cout<<solve(0,0);
}


Measured memory_bytes: 5248
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repk(i, k, n) for (int i = k; i < n; i++)
#define MOD 1000000007
#define INF 1e9
#define PIE 3.14159265358979323

template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T>
T GCD(T a, T b) {
    if (b == 0)
        return a;
    else
        return GCD(b, a % b);
}
template <class T>
inline T LCM(T a, T b) {
    return (a * b) / GCD(a, b);
}

using namespace std;
//#inculude <bits/stdc++.h>
#define int long long

signed main() {
    int n;
    string s;
    cin >> n >> s;
    map<char, int> m;
    rep(i, n) m[s[i]]++;
    int ans = 1;
    for (auto it = m.begin(); it != m.end(); it++) {
        ans *= it->second + 1;
        ans %= MOD;
    }
    cout << ans - 1 << endl;
}


Measured memory_bytes: 512