akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>

using namespace std;

int
main(void){
	int n; cin >> n;
	vector<pair<int, pair<int, int> > > vec(n);
	for(int i = 0; i < n; i++){
		cin >> vec[i].first >> vec[i].second.first >> vec[i].second.second;
	}
	int curx = 0, cury = 0, curt = 0;
	for(int i = 0; i < n; i++){
		int x = vec[i].second.first;
		int y = vec[i].second.second;
		int t = vec[i].first;
		if(abs(curx - x) + abs(cury - y) > (t - curt)){
			cout << "No";
			return 0;
		}
		else if(abs(curx - x) + abs(cury - y) == (t - curt)){
			continue;
		}
		else{
			if((abs(curx - x) + abs(cury - y))%2 == (t - curt)%2){
				continue;
			}
			else{
				cout << "No";
				return 0;
			}
		}
	}
	cout << "Yes";
}

Measured memory_bytes: 1408
#include<stdio.h>
#include<string.h>
#include<math.h>
int main(void)
{
	int a,s,d[300],f,g,h[3],i,j,k,x,flg;
	scanf("%d",&a);
	while(a!=0){
		k=0;
		f=1;
		for(i=1;i<=a*2;i++)	d[i]=2;
		for(i=0;i<a;i++){
			scanf("%d",&s);
			d[s]=1;
		}
		h[1]=a;
		h[2]=a;
		while(1){
			flg=1;
			for(i=1;i<=a*2;i++){
				if(d[i]==f&&k<i){
					flg=0;
					k=i;
					f=(f+1)%2;
					if(f==0)	f=2;
					d[i]=0;
					h[f]--;
					break;
				}
			}
			if(flg==1){
				k=0;
				f=(f+1)%2;
				if(f==0)	f=2;
			}
			if(h[1]==0)	break;
			if(h[2]==0)	break;
		}
		printf("%d\n%d\n",h[1],h[2]);
		scanf("%d",&a);
	}
	return 0;
}

Measured memory_bytes: 2612
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    scanf("%d",&n);
    vector<int>a(n);
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
    }
    int maxc=a[1]-a[0];
    int minc=a[0];
    for(int i=0;i<n-1;i++){
        if(a[i]<=minc){
            minc=a[i];
            for(int j=i+1;j<n;j++)
            {
                if(a[j]-minc>maxc)
                maxc=a[j]-minc;
            }
        }
    }
    cout<<maxc<<endl;
    return 0;
}



Measured memory_bytes: 3616
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define pi 3.14159265359
#define all(i) i.begin(),i.end()
using namespace std;
const long long INF=1e9+7;
const string alp="abcdefghijklmnopqrstuvwxyz"; //26
const string ALP="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
//const ll MOD=998244353LL;
//const ll MOD=1777777777LL;


int main() {
  ll N;
  cin>>N;
  ll ans=1000000000000;
  
  for(ll i=1;i*i<=N;i++){
    if(N%i==0){
      ll j=N/i;
      ans=min(ans,i+j-2);
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
vector<int> G[100001] ;
int dp[100001] ;
int dfs(int u)
{
    if( dp[u] != -1 ) return dp[u] ;
    int ans = 0 ;
    for(int i = 0 ; i < G[u].size() ; i++)
    {
        ans = max( ans , 1  + dfs( G[u][i] ) );
    }
    return dp[u] = ans ;
}

signed main()
{
  
    int n , m ;
    cin >> n >> m ;
    int x , y ;
    for(int i=0;i<m;i++)
    {
        cin >> x >> y ;
        G[x].push_back(y);
    }
    for(int i=0;i<=n;i++) dp[i] = -1 ;
    int ans = 0 ;
    for(int u = 1 ; u <= n ; u++)
        ans = max( ans , dfs(u) ) ;
    cout << ans << endl ;

    return 0;
}


Measured memory_bytes: 8192
#include <iostream>
#include <vector>
using namespace std;
vector<int> E[101];
bool visited[101];
int in[101];
int out[101];
int count=0;
int nv(int n)
{
	int i=1;
	for(i=1;i<=n;i++)
	{
		if ( visited[i]==false )
			return i;
	}
	if (i>n) return 0;
}

void bfs(int n)
{
	visited[n]=true;
	in[n]=++count;
	for(vector<int>::iterator it=E[n].begin();it!=E[n].end();++it)
	{
		int now=*it;
		if(visited[now]==false)
			bfs(now);
	}
	out[n]=++count;
}

int main()
{
	int n;
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		int e,n0;
		cin>>e>>n0;
		for(int j=0;j<n0;j++)
		{
			int t;
			cin>>t;
			E[e].push_back(t);
		}
		visited[i]=false;
		in[i]=out[i]=0;
	}

	int now=nv(n);
	while(now!=0)
	{
		bfs(now);
		now=nv(n);
	}


/*	for(int i=1;i<=n;i++)
	{
		for(vector<int>::iterator it=E[i].begin();it!=E[i].end();++it)
			cout<<*it<<" ";
		cout<<endl;
	}
*/
	for(int i=1;i<=n;i++)
		cout<<i<<" "<<in[i]<<" "<<out[i]<<endl;
	return 0;

	

}

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

int main() {
	int n, x, t;
	cin >> n >> x >> t;
	int ans = (n+x-1)/x * t;
	
	cout << ans << endl;
	return 0;
}

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

const ll infll=9223372036854775806;
const int inf=2147483646;

int main()
{
	//freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
	ios_base::sync_with_stdio(false); cin.tie(0);
	int n,k,i;
	string a;
	cin>>n>>k>>a;
	for (i=0;i<a.size();i++){
		if (i==k-1){
			cout<<(char)(((int)a[i])+32);
		}
		else {
			cout<<a[i];
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
long long f[500010][3],ans;
int n;
char s[500010];
main()
{
	scanf("%d",&n);
	scanf("%s",s+1);
	if (n<3)
	{
		puts("0");
		return 0;
	}
	s[0]='0',s[n+1]='0',s[n+2]='0';
	int pre=0,now=1;
	while (now<=n+2)
	{
		while(s[now]!='0')
			now++;
		if(now==pre+1)
		{
			ans+=max(f[pre][0],max(f[pre][1],f[pre][2]));
			pre=now;
			now++;
			continue;
		}
		f[now][0]=max(f[pre][0],max(f[pre][1],f[pre][2]));
		if(s[now+1]=='1')
			if(now==pre+2)
				f[now][1]=f[pre][0]+now-pre-1;
			else
				f[now][1]=max(f[pre][1]+now-pre-2,f[pre][0]+now-pre-1);
		if(s[now-1]=='1')
		{
			int pos=now;
			while(pos+1<=n&&s[pos+1]=='1')
				pos++;
			if(now==pre+2)
				f[now][2]=f[pre][0]+pos-now;
			else
				f[now][2]=max(max(f[pre][0],f[pre][1]),f[pre][2]-1)+pos-now;
		}
		pre=now;
		now++;
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 12416
import sys
N = int(input())
array = [ list(map(str,input().split())) for I in range(N) ]
# print(array)
for I in array:
    if not ( I[1] == 'JPY' and 1 <= int(I[0]) <= 10 ** 8 ) and \
    not ( I[1] == 'BTC' and 1/10 ** 8 <= float(I[0]) <= 100 ): sys.exit()

amount = 0
for I in array:
    if I[1] == 'JPY': amount += int(I[0])
    if I[1] == 'BTC': amount += float(I[0]) * 380000

print(amount)

Measured memory_bytes: 9204
#include <iostream>
#include <cstdio>
#include<cmath>
#include<algorithm>
using namespace std;

int main() {
   int n,m;
    scanf("%d %d",&n,&m);
    if(n>m) return 0*printf("0\n");
    int ans = 1;
    for(int i=1;i<=sqrt(m)+1;i++) {
        if(m%i==0) {
            if(n<=i) ans = max(ans,m/i);
            if(n<=m/i) ans = max(ans,i);
        }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 256
n,a,b,f[50001];main(){for(a=2;a<50001;a++)if(!f[a])for(b=a*2;b<50001;b+=a)f[b]=1;for(;scanf("%d",&n),n;printf("%d\n", b))for(b=0,a=2;a<=n/2;a++)f[a]+f[n-a]||b++;exit(0);}

Measured memory_bytes: 600
#include<iostream>
#include<string.h>
using namespace std;
long long n,k;
long long a[1000110],c[1000010],d[1000010];
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	cin>>n>>k;
		long long sum=0;
	sum=(k+1)*k/2;
	sum-=k;
	sum%=1000000007;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	memset(c,0,sizeof(c));
	memset(d,0,sizeof(d));
	for(int i=0;i<n;i++){
		for(int j=0;j<i;j++){
			if(a[i]>a[j]){
				c[i]++;
			}
		}
		for(int j=i+1;j<n;j++){
			if(a[i]>a[j]){
				d[i]++;
			}
		}
	}

	long long ans=0;
//	cout<<sum<<endl;
	for(int i=0;i<n;i++){
//		cout<<c[i]<<"   "<<d[i]<<endl;
		ans+=(c[i]*sum);
		ans%=1000000007;
		ans+=(d[i]*(sum+k));
		ans%=1000000007;
	}
	cout<<ans<<endl;
	return 0;
}

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

N,M = map(int,input().split())
S = [[]for i in range(N)]
for i in range(M):
    u,v = map(int,input().split())
    S[u-1].append(v-1)
St,T = map(int,input().split())

D = [[float('inf')]*3 for i in range(N)]
D[St-1][0] = 0
queue = [St-1]
i = 0
while queue != []:
    i += 1
    hoge = []
    for q in queue:
        for s in S[q]:
            if D[s][i%3] > i:
                D[s][i%3] = i
                if not s in hoge:
                    hoge.append(s)
    queue = hoge[:]
    if D[T-1][0] != float('inf'):
        break
if D[T-1][0] == float('inf'):
    print(-1)
else:
    print(D[T-1][0]//3)

Measured memory_bytes: 78128
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>

#define MOD 1e9+7;
#define INF 1e17+9;
#define PI acos(-1);

using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	int sum=0;
	for(int i=0;i<n;i++){
		cin >> a[i];
		sum+=a[i];
	}
	sort(a.begin(),a.end());
	if(sum%10!=0){
		cout << sum << endl;
		return 0;
	}else{
		for(int i=0;i<n;i++){
			int temp=sum-a[i];
			if(temp%10!=0){
				cout << temp << endl;
				return 0;
			}
		}
	}
	cout << "0" << endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>

struct DICE {
	int top;
	int north;
	int south;
	int east;
	int west;
	int bottom;
};

struct DICE dice;

void N() {
	int num[6];
	num[0] = dice.top; num[1] = dice.south; num[2] = dice.east;
	num[3] = dice.west; num[4] = dice.north; num[5] = dice.bottom;
	dice.top = num[1]; dice.south = num[5]; dice.east = num[2];
	dice.west = num[3]; dice.north = num[0]; dice.bottom = num[4];
}

void S() {
	int num[6];
	num[0] = dice.top; num[1] = dice.south; num[2] = dice.east;
	num[3] = dice.west; num[4] = dice.north; num[5] = dice.bottom;
	dice.top = num[4]; dice.south = num[0]; dice.east = num[2];
	dice.west = num[3]; dice.north = num[5]; dice.bottom = num[1];
}

void E() {
	int num[6];
	num[0] = dice.top; num[1] = dice.south; num[2] = dice.east;
	num[3] = dice.west; num[4] = dice.north; num[5] = dice.bottom;
	dice.top = num[3]; dice.south = num[1]; dice.east = num[0];
	dice.west = num[5]; dice.north = num[4]; dice.bottom = num[2];
}

void W() {
	int num[6];
	num[0] = dice.top; num[1] = dice.south; num[2] = dice.east;
	num[3] = dice.west; num[4] = dice.north; num[5] = dice.bottom;
	dice.top = num[2]; dice.south = num[1]; dice.east = num[5];
	dice.west = num[0]; dice.north = num[4]; dice.bottom = num[3];
}

int main() {
	int nums[6];
	char command[101];
	for (int i = 0; i < 6; i++) {
		scanf("%d", &nums[i]);
	}
	dice.top = nums[0]; dice.south = nums[1]; dice.east = nums[2];
	dice.west = nums[3]; dice.north = nums[4]; dice.bottom = nums[5];
	scanf("%s", command);
	for (int i = 0; command[i] != '\0'; i++) {
		if (command[i] == 'N') N();
		else if (command[i] == 'S') S();
		else if (command[i] == 'E') E();
		else if (command[i] == 'W') W();
	}

	printf("%d\n", dice.top);
	return 0;
}


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

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

Measured memory_bytes: 256
n,k=map(int,input().split())
r,s,p=map(int,input().split())
t=list(input())
ans=0
for i in range(len(t)):
    #print(t[i])
    if t[i]=="r":
        ans+=p
        if i+k<len(t):
            if t[i+k]=="r":
                t[i+k]=""
    if t[i]=="s":
        ans+=r
        if i+k<len(t):
            if t[i+k]=="s":
                t[i+k]=""
    if t[i]=="p":
        ans+=s
        if i+k<len(t):
            if t[i+k]=="p":
                t[i+k]=""
print(ans)


Measured memory_bytes: 4084
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
int N;
int main(){
	cin>>N;
	ll R=1;
	for(int i=1;i<N+1;i++){
		R=(R*i)%1000000007;
	}
	cout<<R<<endl;
	return 0;
}


Measured memory_bytes: 256
import sys
from functools import lru_cache, cmp_to_key
from heapq import merge, heapify, heappop, heappush
from math import *
# import math
from collections import defaultdict as dd, deque, Counter as C
from itertools import combinations as comb, permutations as perm
from bisect import bisect_left as bl, bisect_right as br, bisect
from time import perf_counter
from fractions import Fraction
# sys.setrecursionlimit(int(pow(10, 2)))
# sys.stdin = open("input.txt", "r")
# sys.stdout = open("output.txt", "w")
mod = int(pow(10, 9) + 7)
mod2 = 998244353
def data(): return sys.stdin.readline().strip()
def out(*var, end="\n"): sys.stdout.write(' '.join(map(str, var))+end)
def l(): return list(sp())
def sl(): return list(ssp())
def sp(): return map(int, data().split())
def ssp(): return map(str, data().split())
def l1d(n, val=0): return [val for i in range(n)]
def l2d(n, m, val=0): return [l1d(n, val) for j in range(m)]





# @lru_cache(None)


    


W,H,x,y=l()

if(x==W/2 and y==H/2):
    print(W*H/2,1)
else:
    print(W*H/2,0)



Measured memory_bytes: 5508
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <deque>
#include <stack>
#include <map>
const int MOD = 1e9+7;
#define PI 3.14159265359
typedef long long ll;
using namespace std;

int d, n;

bool is_ok(ll x){
	for (int i = 0; i < d; i++){
		if (x % 100 != 0) return false;
		x /= 100;
	}
	if (x % 100 == 0) return false;
	return true;
}

int main(){
	cin >> d >> n;
	int coun = 0;
	for (ll i = 1; ; i++){
		if (is_ok(i)){
			coun++;
		}
		if (coun == n){
			cout << i << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 3596
// #define DEBUG_IS_VALID 

#ifdef DEBUG_IS_VALID
#define DEB 1 
#define _LIBCPP_DEBUG 0
#else
#define DEB 0
#define NDEBUG
#endif

#include "bits/stdc++.h"

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = x; i >= n; i--)
#define rrep(i, n) RREP(i,n,0)
#define pb push_back
#pragma GCC optimize ("-O3")

using namespace std;

#define DUMPOUT cout
#define dump(...) if(DEB) DUMPOUT<<"  "<<#__VA_ARGS__<<" :["<<__LINE__<<":"<<__FUNCTION__<<"]"<<endl<<"    "; if(DEB) dump_func(__VA_ARGS__)
template<typename T1,typename T2>ostream& operator << (ostream& os, pair<T1,T2> p){cout << "(" << p.first << ", " << p.second << ")"; return os;}
template<typename T>ostream& operator << (ostream& os, vector<T>& vec) { os << "{"; for (int i = 0; i<vec.size(); i++) os << vec[i] << (i + 1 == vec.size() ? "" : ", "); os << "}"; return os; }
template<typename T>ostream& operator << (ostream& os, set<T>& st){cout << "{"; for(auto itr = st.begin(); itr != st.end(); itr++) cout << *itr << (next(itr)!=st.end() ? ", " : ""); cout << "}"; return os;}
template<typename T1,typename T2>ostream& operator << (ostream& os, map<T1,T2> mp){cout << "{"; for(auto itr = mp.begin(); itr != mp.end(); itr++) cout << "(" << (itr->first) << ", " << (itr->second) << ")" << (next(itr)!=mp.end() ? "," : ""); cout << "}"; return os; }

void dump_func(){DUMPOUT << endl;}
template <class Head, class... Tail>void dump_func(Head&& head, Tail&&... tail){ DUMPOUT << head; if (sizeof...(Tail) == 0) { DUMPOUT << " "; } else { DUMPOUT << ", "; } dump_func(std::move(tail)...);}
template<class T> inline bool chmax(T& a,T const& b){if(a>=b) return false; a=b; return true;}
template<class T> inline bool chmin(T& a,T const& b){if(a<=b) return false; a=b; return true;}
void _main();
int main(){ cin.tie(0); ios::sync_with_stdio(false); _main(); return 0;}

using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;

const int mod=1e9+7,INF=1<<29;
const double EPS=1e-5,PI=3.1415926535897932384626;
const ll lmod = 1e9+7,LINF=1LL<<59; 

void _main(){
  int H,W; cin >> H >> W ;
  vector<string> a(H);
  rep(i,H) cin >> a[i] ;
  vector<string> s1(a),s2(a);
  rep(i,H) s1[i][0] = s2[i][W-1] = '#';
  rep(i,H) REP(j,1,W-1){
    if(i%2) s2[i][j] = '#';
    else s1[i][j] = '#';
  }
  REP(i,1,H-1) REP(j,1,W-1){
    if(a[i][j]=='.') continue;
    if(i%2) s1[i][j] = '#';
    else s2[i][j] = '#';
  }
  rep(i,H) cout << s1[i] << endl;
  cout << "" << endl;
  rep(i,H) cout << s2[i] << endl;
}

Measured memory_bytes: 1536
# coding: utf-8
# Your code here!

card = input().split()
kaisu = int(input())

red  = int(card[0])
green  = int(card[1])
blue = int(card[2])

for num in range(1, kaisu + 1):
    
    if red >= green:
        green = green * 2
        
    elif green >= blue:
        blue = blue * 2
    
    else:
        blue = blue * 2
        
    # print(red,green,blue)
        

if red < green < blue:
    print("Yes")
    
else:
    print("No")

Measured memory_bytes: 9192
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
using dou =long double;
string Yes="Yes";
string YES="YES";
string NO="NO";
string No="No";
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define res resize
#define as assign
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
 
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 9223372036854775806ll;
const int mod = 1000000007ll;
const ll  MOD = 1000000007LL;
//-0.4620981203755741
int main(){
    string s;
    std::cin >> s;
    int qq;
    std::cin >> qq;
    int cnt=0;
    string s1,s2;
    rep(qqq,qq){
        int q;
        std::cin >> q;
        if(q==1){
            cnt++;
        }
        else{
            int f;
            char c;
            std::cin >> f>>c;
            
            if((cnt)%2==0){
                if(f==1)s1.pb(c);
                else s2.pb(c);
            }
            else{
                if(f==2)s1.pb(c);
                else s2.pb(c);
            }
        }
    }
    reverse(all(s1));
    s=s1+s+s2;
    if(cnt%2==1){
        reverse(all(s));
    }
    std::cout << s << std::endl;
}

Measured memory_bytes: 1348
// https://beta.atcoder.jp/contests/abc102/tasks/abc102_b

#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
	int N;
	cin >> N;

	vector<int> A(N);
	for(int i=0;i<A.size();i++){
		cin >> A[i];
	}
	sort(A.begin(), A.end());

	cout << A.back() - A.front() << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long int mod = 1000000007;
typedef long long int lli;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<lli> vlli;
typedef vector<bool> vb;
long long int max(long long int a,long long int b){
  if(a>b)
    return a;
  else
    return b;
}
long long int min(long long int a,long long int b){
  if(a<b)
    return a;
  else
    return b;
}
long long int binpow(long long a, long long b, long long m) {
  a %= m;
  long long res = 1;
  while (b > 0) {
    if (b & 1)
      res = res * a % m;
      a = a * a % m;
      b >>= 1;
    }
  return res;
}
long long binpow(long long a, long long b) {
    if (b == 0)
        return 1;
    long long res = binpow(a, b / 2);
    if (b % 2)
        return res * res * a;
    else
        return res * res;
}
 
//############################ENDOFTEMPLATE############################

void solve(){
  int n,m;
  cin>>n>>m;

  priority_queue<lli> pq;
  for(int i = 0;i<n;i++){
    lli a;
    cin>>a;
    pq.push(a);
  } 

  for(int i = 0;i<m;i++){
    lli val = pq.top();
    pq.pop();
    val = val/2;
    pq.push(val);
  }

  lli cost = 0;
  while(!pq.empty()){
    cost+=pq.top();
    pq.pop();
  }

  cout<<cost;

}
 
 
 
 
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  //freopen("moobuzz.in","r",stdin);
  //freopen("moobuzz.out","w",stdout);
  int t = 1;
  //cin>>t;
  while(t--){
    solve();
  }
}

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

int main(){
  int N;
  std::cin >> N;
  
  std::vector<int> ppl(N, 0);
  
  int num;
  while (std::cin >> num) ppl[num - 1]++;
  
  for (int i = 0; i < N; i++) std::cout << ppl[i] << std::endl;
  
  return 0;
}

Measured memory_bytes: 3672
using System;
using System.Collections.Generic;

namespace test
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            string[] line = Console.ReadLine().Split(' ');

            long A = long.Parse(line[0]);

            string[] line2 = line[1].Split('.');

            long B = long.Parse(line2[0]) * 100 + long.Parse(line2[1]);

            long ans = A * B / 100;

            Console.WriteLine(ans.ToString());


        }


    }
}


Measured memory_bytes: 27452
#include<cstdio>
#include<cstring>
const int N=1e5+50;
char s[N];
int len,x,y,ans;
int main(){
	scanf("%s",s);
	len=strlen(s);
	for(int i=0;i<len;i++){
		if(x==y){
			x++;
			if(s[i]=='p')ans--;
		}else{
			y++;
			if(s[i]=='g')ans++;
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
	int A, B;
	scanf("%d %d",&A,&B);

	if(A-B==0){
	printf("Draw\n");
	}else if(A==1 || B==1){
	if(A==1) printf("Alice\n");
	else printf("Bob\n");
	}else if(A<B)printf("Bob\n");
	else printf("Alice\n");
	return 0;
}


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

struct Node {
  int k;
  struct Node *r,*l,*p;
};
typedef struct Node* node;
node root;
node NIL;

void insert(int);
void inorder(node);
void preorder(node);

int main(){
  int n,i,x;
  char com[20];
  scanf("%d",&n);
  root = NIL;
  
  for(i=0;i<n;i++){
    scanf("%s",com);
    if(com[0]=='i'){
      scanf("%d",&x);
      insert(x);
    }
    else if(com[0]=='p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }
  }
  return 0;
}
void insert(int k){
  node y=NIL;//xの親
  node x=root;
  node z;
  
  z=(node)malloc(sizeof(struct Node));

  z->k = k;
  z->l = NIL;
  z->r = NIL;
 
  while(x != NIL){
   y=x;//親を設定
    if( z->k < x->k )
      x = x->l;//左の子へ
    else x = x->r;//右の子へ
  }
  z->p = y;
  
  if(y==NIL)
    root = z;
  else {
    if( z->k < y->k ){
      y->l = z;
    }
    else
      y->r = z;
  }
}
void inorder(node u){
  if(u==NIL)return;
  inorder(u->l);
  printf(" %d",u->k);
  inorder(u->r);
}
void preorder(node u){
  if(u==NIL)return;
  printf(" %d",u->k);
  preorder(u->l);
  preorder(u->r);
}



Measured memory_bytes: 26128
/**
 *      purpose : 
 *      author  : kyomukyomupurin
 *      created : 
**/

// input/output
#include <iostream>
#include <fstream>
#include <sstream>
// container class
#include <array>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
// math, algorithm
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
// etc
#include <bitset>
#include <cctype>
#include <cstring>
#include <chrono>
#include <iomanip>
#include <random>
#include <utility>
// using-directive
using namespace std;
// alias template
using int64 = int64_t;
using pii = pair<int, int>;
using pll = pair<int64_t, int64_t>;
// text macro replacement
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define print(x) cout << (x) << '\n'

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

  int S; cin >> S;
  int h = S / 3600;
  S %= 3600;
  int m = S / 60;
  S %= 60;
  int s = S;
  cout << h << ":" << m << ":" << s << '\n';

  return 0;
}


Measured memory_bytes: 3172
#define ENABLE_DEBUG 1
// Kana's kitchen {{{
#include<bits/stdc++.h>
#define ALL(v) std::begin(v),std::end(v)
#define LOOP(k) for(i64 ngtkana_is_a_genius=0; ngtkana_is_a_genius<(i64)k; ngtkana_is_a_genius++)

using i32 = std::int_least32_t;
using i64 = std::int_least64_t;
using u32 = std::uint_least32_t;
using u64 = std::uint_least64_t;
using usize = std::size_t;

template <class T, class U> using pair = std::pair<U, T>;
template <class T> using diag_pair = std::pair<T, T>;
template <class... Args> using tuple = std::tuple<Args...>;
template <class T> using vec = std::vector<T>;
template <class T> using numr = std::numeric_limits<T>;

#ifdef NGTKANA
#include<debug.hpp>
#else
#define DEBUG(...)(void)0
#endif
/*}}}*/

int main(){
    std::cin.tie(nullptr);
    std::ios::sync_with_stdio(false);
    std::cout << std::setprecision(15) << std::fixed;

    i64 inf = 1'000'000'000'000'000'001;

    usize n;
    std::cin >> n;
    i64 ans = 1;
    while (n--) {
        i64 x;
        std::cin >> x;
        ans = ans == 0 ? 0 : inf/ans < x ? inf : ans * x;
    }
    if (ans==inf) ans = -1;

    std::cout << ans << '\n';
}


Measured memory_bytes: 3672
# B Kleene_Inversion

n,k = map(int,input().split(" "))
a = list(map(int,input().split(" ")))
a_inv,b_inv = 0,0
mod = 10**9+7

for i in range(n):
    for j in range(n):
        if (a[i] > a[j]):
            if (i < j):
                a_inv += 1
            b_inv += 1
            

s_inv = a_inv*k+b_inv*(k*(k-1))//2

print(s_inv%mod)

Measured memory_bytes: 3188
//08-5 おせんべい
#include<iostream>
#include<fstream>
#include<stdio.h>
#include<math.h>
#include<time.h>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<set>
#include<stack>
#include<queue>
#include<cstdlib>
#include<algorithm>
#include<random>
#include<cassert>
using namespace std;
#include<boost/multiprecision/cpp_int.hpp>
namespace boost_multiprecision = boost::multiprecision;
#define LL long long
#define CINT boost_multiprecision::cpp_int
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483648
#define INT_MAX 2147483647
#define LL_MIN -9223372036854775808
#define LL_MAX 9223372036854775807
#define segment_size 65536
#define ROOP() while(true)

int R,C;
bool a[10000][10];
int sum[10];//ひっくり返さないといけないものの合計

int solve(int n){//n行目までのときの最大値 b:trueのときひっくり返す
    if(n+1 == R){
        int tmp1 = 0;
        int tmp2 = 0;
        for(int i=0; i<C; i++){
            int t = 0;
            for(int j=0; j<R; j++){
                if(a[i][j]) t++;
            }
            tmp1 += max(t,R-t);
            if(a[i][n]) t--;
            else t++;
            tmp2 += max(t,R-t);
        }
        return max(tmp1,tmp2);
    }
    else{
        int re = 0;
        //ひっくり返さない
        re = max(re,solve(n+1));
        //ひっくり返す
        for(int i=0; i<C; i++){
            a[i][n] = !a[i][n];
        }
        re = max(re,solve(n+1));
        return re;
    }
    

}

//なるべく多くfalseにしたい
int main(){
    ROOP(){
        cin >> R >> C;
        if(R==0 && C==0) break;

        for(int i=0; i<R; i++){
            for(int j=0; j<C; j++){
                int tmp;
                cin >> tmp;
                if(tmp == 1) a[j][i] = true;
                else a[j][i] = false;
                sum[i] += tmp;
            }
        }

        cout << solve(0) << endl;
    }
    return 0;
}


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

#define F first
#define S second
#define MP make_pair
#define pb push_back
#define all(a) a.begin(), a.end()
#define lcm(a, b) (a)/__gcd((a),(b))*(b)
#define endl '\n'

using namespace std;

typedef long long LL;
typedef pair<int, int> P;
typedef pair<LL, LL> LP;

static const int INF = INT_MAX;
static const LL LINF = LLONG_MAX;
static const int MIN = INT_MIN;
static const LL LMIN = LLONG_MIN;
static const int MOD = 1000000007;
static const int SIZE = 200005;

const int dx[] = {0, -1, 1, 0};
const int dy[] = {-1, 0, 0, 1};

vector<int> Div(int n) {
    vector<int> ret;
    for(int i = 1; i * i <= n; ++i) {
        if(n % i == 0) {
            ret.pb(i);

            if(i * i != n) ret.pb(n / i);
        }
    }
    sort(all(ret));
    return ret;
}

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

    int n, y;
    cin >> n >> y;
    for( int i = 0; i <= n; ++i ) {
        for( int j = 0; j <= n; ++j ) {
            if( i + j > n ) break;
            if( i * 1000 + j * 5000 + (n - i - j) * 10000 == y ) {
                cout << n - i - j << " " << j << " " << i << endl;
                return 0;

            }
        }
    }
    cout << "-1 -1 -1" << endl;
    return 0;
}



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

using namespace std;

int n;

int main(int argc, char const *argv[]) {
  scanf("%d\n", &n);
  /*
  char w[n][10];
  for (int i = 0; i < n; i++) {
    scanf("%s\n", w[i]);
  }
  */
  vector<string> w(n);
  for (int i = 0; i < n; i++) {
    getline(cin, w[i]);
  }
  for (int i = 0; i < n; i++) {
    if(i != 0){
      if(w[i-1][w[i-1].length()-1]!=w[i][0]){
        printf("No\n");
        return 0;
      }
      for (int j = 0; j < i; j++) {
        bool matching = true;
        if(w[i].length() != w[j].length()) continue;
        for (int l = 0; l < w[i].length(); l++) {
          if(w[j].length()-1 < l){
            matching = false;
            break;
          }
          if(w[j][l] != w[i][l]){
            matching = false;
            break;
          }
        }
        if(matching){
          printf("No\n");
          return 0;
        }
      }
    }
  }
  printf("Yes\n");

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
int main(){

int H_1, M_1, H_2, M_2, K;
cin >> H_1 >> M_1 >> H_2 >> M_2 >> K;

int hour, minute, time, ans;

hour = (H_2 - H_1) * 60;
minute = M_2 - M_1;

if(minute < 0){
     minute = minute + 60;
     hour = hour - 60;
}

time = hour + minute;

if(time - K <= 0){
     cout << 0 << endl;
}
else{
     cout << time - K << endl;
}

return 0;
}

Measured memory_bytes: 3624
#include <iostream>
using namespace std;
typedef unsigned long long u64;
typedef signed long long l64;

int main(void)
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  l64 x, y;
  cin >> x >> y;
  u64 cnt = 0;
  if ((abs(x)<abs(y) && x<0) || (abs(x)>abs(y) && x>0)) {
    cnt++;
    x *= -1;
  }
  cnt += abs(abs(x)-abs(y));
  if (x*y<0 || (x==0 && y<0)) cnt++;
  cout << cnt << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
#define ll long long int
 
#define REP(i, n) for(int i = 0; i < (n); i++)
#define SREP(i, s) for(int i = 0; i < (s.size()); i++)
#define SORT(v, n) sort(v, v+n);
#define GSORT(v, n) sort(v, v+n, greater<int>());
#define VSORT(v) sort(v.begin(),v.end());
#define VGSORT(v) sort(v.begin(),v.end(),greater<int>());
#define REV(a) reverse(begin(a),end(a));

int main(){
	ios::sync_with_stdio(false);cin.tie(0);
////////////////////////////////////////////	
	int n,a,b;
	cin >> n >> a >> b;
	if((a<=b&&a+n>=b)||(a>=b&&b+n>a)) cout << 0 << endl;
	else cout << -min(b-a+n,a-b+n) << endl;
//////////////////////////////////////////////
}


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

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

lli n, w;
std::vector<std::pair<lli, lli>> vec;
std::vector<std::vector<lli>> dp;


int main() {
    std::cin >> n >> w;
    vec.assign(n+1, {0, 0});
    for (lli i = 1; i <= n; i++) {
        std::cin >> vec[i].first >> vec[i].second;
    }
    dp.assign(n+1, std::vector<lli>(w+1, 0));
    
    for (lli i = 1; i <= n; i++) {
        for (lli p = 0; p <= w; p++) {
            if (p >= vec[i].first) {
                chmax(dp[i][p], dp[i-1][p-vec[i].first] + vec[i].second);
            }
            chmax(dp[i][p], dp[i-1][p]);
        }
    }
    std::cout << dp[n][w] << std::endl;
}



Measured memory_bytes: 80256
#include<iostream>
#include<cctype>
#include<cstdio>
using namespace std;
int main(){
    char ch;
    while(1){
        if(ch == '\n') break;
        scanf("%c",&ch);
        
        if(isalpha(ch)){
            if(islower(ch)) printf("%c",toupper(ch));
            else printf("%c",tolower(ch));
        }
        else printf("%c",ch);
    }
    return 0;
}


Measured memory_bytes: 3152
d, g = map(int, input().split())
pc = [list(map(int, input().split())) for i in range(d)]
ans = 10000
for i in range(2**d):
  score = 0
  b = 0
  cnt = 0
  for j in range(d):
    if ((i >> j) & 1):
      score += (j+1)*pc[j][0]*100 + pc[j][1]
      cnt += pc[j][0]
    else:
      b = j
  for k in range(pc[b][0]):
    if score >= g and cnt < ans:
      ans = cnt
    score += (b+1)*100
    cnt += 1
print(ans)

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

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t,a;
    string s;
    t = 1;
    while(t--) {
     a = 700;
     cin >> s;
     if(s[0] == 'o')
      a = a + 100;
     if(s[1] == 'o')
      a = a + 100;
     if(s[2] == 'o')
      a = a + 100;
     cout << a << endl;
    }
    return 0;
}


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

int main()
{
	int x,y,temp,step;
	cin>>x>>y;

	while(x!=0){
		if(x-y<0){
			temp=x;
			x=y;
			y=temp;
		}
		step=1;
		for(;;){
			x=x%y;
			temp=x;
			x=y;
			y=temp;
			if(y==0)break;
			step++;
		}
		cout<<x<<" "<<step<<"\n";
		cin>>x>>y;
	}
	return 0;
}

		

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

int main(){
    long long X,K,D;
    cin >> X >> K >> D;
    long long q = abs(X)/D;
    long long r = abs(X)%D;
    if (K < q){
        cout << abs(X) - D*K;
    } else{
        if ((K-q)%2==0) cout << r;
        else cout << D-r;
    }
}

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

int main(void) {
	int n; cin >> n;
	int a[n], i;
	for (i = 0; i < n; i++) {
		cin >> a[i];
	}

	sort(a, a + n);

	cout << a[n - 1] - a[0] << endl;

	return 0;
}



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

int main(){
    char h[4] = {'A','T','C','G'};
    string s;
    cin >> s;
    bool f = false;
    int ans = 0,c = 0;

    for(int i = 0; i < s.size(); ++i){
        if(s[i] == h[0] || s[i] == h[1] || s[i] == h[2] || s[i] == h[3]){
            f = true;
        }else{
            f = false;
        }

        if(f){
            c++;
        }else{
            if(ans < c)ans = c;

            c = 0;
        }
    }
    
    if(ans < c)ans = c;

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,n) for(int i=0; i<(n); i++)

using namespace std;

int main(){
	int N;
	int A[100005];
	cin >> N;
	rep(i,N) cin >> A[i];

	int odd = 0;
	rep(i,N) if(A[i] % 2) odd++;

	cout << (odd%2 ? "NO" : "YES") << endl;
}

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

int main() {
    ll x, k, d;
    cin >> x >> k >> d;
    x = abs(x);

    ll a = min(k, x / d);
    k -= a;
    x -= a * d;

    if (k % 2 == 0)
        cout << x << endl;
    else
        cout << d - x << endl;

    return 0;
}


Measured memory_bytes: 3560
import math, sys
from bisect import bisect_left, bisect_right
from collections import Counter, defaultdict, deque
from copy import deepcopy
from functools import lru_cache
from heapq import heapify, heappop, heappush
from itertools import accumulate, combinations, permutations
input = sys.stdin.readline
mod = 10**9 + 7
ns = lambda: input().strip()
ni = lambda: int(input().strip())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

def main():
    s = ns()
    k = ni()

    check = set()

    for left in range(0, len(s)):
        for right in range(left+1, left+k+1):
            check.add(s[left:right])
    
    print(sorted(list(check))[k-1])

if __name__ == '__main__':
    main()

Measured memory_bytes: 5192
#include <bits/stdc++.h>
using namespace std;
#define sync ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define rep(i,n) for(int i=0; i<int(n); ++i)
#define repp(i,a,n) for(int i=a; i<int(n); ++i)
#define sz(x) int((x).size())
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define mp make_pair

template<class T> std::ostream& operator<<(std::ostream& os, const std::vector<T> &input){for (auto const& i: input) {os << i << " ";}return os;}
template<class T> std::ostream& operator<<(std::ostream& os, const std::set<T> &input){for (auto const& i: input) {os << i << " ";}return os;}
template<class T> std::ostream& operator<<(std::ostream& os, const std::multiset<T> &input){for (auto const& i: input) {os << i << " ";}return os;}
template<class T, size_t n> std::ostream& operator<<(std::ostream& os, const std::array<T, n> &input){for (size_t i=0; i<n; ++i) {os << input[i] << " ";}return os;}
template<class T1, class T2> std::ostream& operator<<(std::ostream& os, const std::pair<T1,T2> &input){os << "(" << input.first << ", " << input.second << ')';return os;}
template<class T1, class T2> std::ostream& operator<<(std::ostream& os, const std::unordered_map<T1,T2> &input){for (auto const& i: input) {os << i << " ";}return os;}

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail> void debug_out(Head H, Tail... T) {cerr << " " << H;debug_out(T...);}
#ifdef LOCAL
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define dbg(...) 42
#endif

double startTime;
double getCurrentTime(){return ((double)clock() - startTime) / CLOCKS_PER_SEC;}

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef vector<int> vi;
typedef vector<pi> vp;
typedef vector<ll> vl;
typedef vector<vi> vvi;

// === temeplate ===

const int maxn = 50;

void solve(){
	int n,m,k; cin >> n >> m >> k;

	vi sumX(n,0), sumY(m,0);
	vvi Y(n, vi(0));
	rep(i,k){
		int x,y;cin >> x >> y; --x,--y;
		Y[x].pb(y);

		sumX[x] ++;
		sumY[y] ++;
	}

	int ans = 0;

	multiset<int> val; val.clear();

	rep(y,m) val.insert(sumY[y]);

	// dbg(val);

	rep(x,n){
		int sum = sumX[x];
		for(int y: Y[x]){
			val.erase(val.find(sumY[y]));
			sumY[y]--;
			val.insert(sumY[y]);
		}
		auto it = val.end();
		sum += *(--it);
		ans = max(ans, sum);
		for(int y: Y[x]){
			val.erase(val.find(sumY[y]));
			sumY[y]++;
			val.insert(sumY[y]);
		}
	}
	cout << ans << endl;
}

int main(){
    sync;
    int cas = 1;
    // cin >> cas;
    rep(ca, cas) solve();
    return 0;
}

Measured memory_bytes: 35932
#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<ll> a(n);
    rep(i,n) cin>>a[i];
    vector<ll> x(n),y(n);

    rep(i,n) {
        x[i] = a[i]+i+1;
        y[i] = i+1-a[i];
    }

    map<ll,ll> mp;
    ll ans = 0;
    rep(i,n) {
        ans += mp[y[i]];
        mp[x[i]]++;
    }

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

Measured memory_bytes: 30620
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
struct node {
	int l, r;
	bool operator < (const node &a) const {
		return r == a.r? l > a.l :r < a.r;
	}
}a[120000];
bool bkt[120000];
int main() {
	int n, m;
	cin >> n >> m;
	for(int i = 1; i <= m; i ++ ) {
		cin >> a[i].l >> a[i].r;
	}
	sort(a+1, a+m+1);
	int now = 0;
	int maxn = 0;
	for(int i = 1; i <= m; i ++ ) {
		if(maxn > a[i].l) continue;
		else maxn = a[i].r, now ++;
	}
	printf("%d\n", now);
}

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

int main() {
    int a, b;
    char op;
    cin >> a >> op >> b;
    if (op == '-') {
        cout << a - b << endl;
    }
    else if (op == '+') {
        cout << a + b << endl;
    }
    return 0;
}


Measured memory_bytes: 256
import heapq as hp
def o():return map(int,input().split())
n,m=o()
c=[[0] for i in range(m)]
for i in range(n):
  a,b=o()
  if a<=m:
    c[m-a]+=[-b]
d=[]
ans=0
for i in range(m-1,-1,-1):
  for j in c[i]:
    hp.heappush(d,j)
  ans-=hp.heappop(d)
print(ans)

Measured memory_bytes: 70176
#include <bits/stdc++.h>
using namespace std;
int num,res;

//ac是这些数字排列成的数字
//cnt表示已经有多少位置了

bool ok(long long n)
{
    int ret = 0;
    int cur;
    while(n)
    {
        cur = n%10;
        n /= 10;
        if(cur == 3) ret |= 1;
        else if(cur == 5) ret |= 2;
        else if(cur == 7) ret |= 4;
    }
    return ret == 7;
}

void dfs(long long ac)
{
    if(ac > num) return;
    else
    {
        if(ok(ac))
            ++res;
    }
    dfs(ac*10+3);
    dfs(ac*10+5);
    dfs(ac*10+7);
}

int main()
{
    scanf("%d",&num);
    res = 0;
    dfs(0);
    printf("%d\n",res);
    return 0;
}


Measured memory_bytes: 256
/*
for (int i = 0; i < N; ++i){}

// 各桁の和を計算する関数
int findSumOfDigits(int n) {
  int sum = 0;
  while (n > 0) { // n が 0 になるまで
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

sort(a, a + N, greater<int>());  // a[0:N] を大きい順にソート

int num[110] = {0};  // バケット
for (int i = 0; i < N; ++i) {
    num[d[i]]++;  // d[i] が 1 個増える
}

map<string, int> mp; // 連想配列 map<キー型, 値型> オブジェクト名
for (int i = 0; i < N; ++i) {
    auto itr = mp.find(s[i]);        // s[i] が設定されているか？
    if(itr != mp.end() ) {
         mp[s[i]] += 1;
    }
    else {
         mp[s[i]] += 1 ;
    }
}
stack<int> s;	//intをデータとするスタックを用意
s.push(1);		//{} -> {1}
printf("%d\n", s.top());	// 3
s.pop();

queue<int> que;	//intをデータとするキューを用意
que.push(1);		//{} -> {1}
printf("%d\n", que.front());	// 1
que.pop();
*/
#include <iostream>
#include <set>
#include <map>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <bitset>

using namespace std;

// #define for(i,a,b) for (int i=(a);i<(b);++i)
typedef long long ll;
typedef pair<int,int> point;
#define rep(i,n) for(i,0,n)

// int 
// // 各桁の和を計算する関数
// int findSumOfDigits(int n) {
//   int amari = 0;
//   int keta = 0;
//   while (n > 0) { // n が 0 になるまで
//     amari += n % 2;
//     if (keta%2==0)
//     n /= 10;
//   }
//   return sum;
// }
 
 

int main() {
	// 入力
	ll A, B;
	cin >> A >> B;
 
	// 解法
	if (A%2==1 && B%2==1) printf("Yes\n");
	else printf("No\n");
}
 


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

int main(){

    int N;
    cin >> N;
    vector<int> l(N), r(N);
    for(int i = 0; i < N; i++) cin >> l[i] >> r[i];

    int ans = 0;
    for(int i = 0; i < N; i++) ans += r[i] - l[i] + 1;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <assert.h>
#include <vector>
#include <unordered_map>
#include <queue>
#include <climits>
#include <cmath>
#include <algorithm>
using namespace std;

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

  int32_t N;
  cin >> N;
  int64_t cur = 1000;
  int64_t stock = 0;
  vector<int64_t> A(N);
  for (auto& a : A) {
    cin >> a;
  }

  for (int i = 0; i < N - 1; i++) {
    if (A[i] < A[i+1] && cur >= A[i]) {
      stock += (cur / A[i]);
      cur -= (cur / A[i]) * A[i];
    } else if (A[i] > A[i+1] && stock > 0) {
      cur += stock * A[i];
      stock = 0;
    }
  }
  cur += stock * A[N-1];
  cout << cur << endl;

  return 0;
}


Measured memory_bytes: 3660
#include <stdio.h>
int a[31];
int main(void){
	int i,temp;
	for(i=0;i<28;i++){
		scanf("%d",&temp);
		a[temp]=1;
	}
	for(i=1;i<31;i++){
		if(a[i]==0)
			printf("%d\n",i);
	}
	return 0;
}

Measured memory_bytes: 596
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>

using namespace std;
int main(void)
{

  int af, bf, count = 0;
  cin >> af >> bf;
  vector<int> vec(af);
  for (auto &a : vec)
  {
    cin >> a;
    if (bf <= a)
      count++;
  }

  cout << count << endl;
}


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


int main(){
    int a,b,ori,c,d;
    cin>>a>>b;
    ori=b*10;
    ori=ori-1000;
    rep(i,2000){
        c=(ori+i)*0.08;
        d=(ori+i)*0.1;
        if(c==a and d==b){
            cout<<ori+i<<endl;
            return 0;
        }
    }
    cout<<-1<<endl;
    return 0;
}

Measured memory_bytes: 256