akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define ull unsigned long long int
#define ll long long
#define int long long
#define ld long double
#define endl '\n'
const int mod= 1e9+7;
#define F first
#define S second
//#define x first
//#define y second
#define pb push_back
#define mp make_pair
#define trace(x) cerr << #x << " is " << x << endl;
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<"\n";
#define all(x) x.begin(),x.end()
#define reset(x,val) memset(x,val,sizeof(x))
#define flush fflush(stdout)
#define sz(a) a.size()
#define pii pair<int,int>
void fail(){std::cout<<"NO\n";exit(0);}
using namespace std;
int n,k;
const int N=405;
int cache[N][N],a[N],pre[N];
int dp(int i,int j)
{
 if(i==j)
 {
  return 0;
 }
 int &ans=cache[i][j];
 if(ans!=-1)return ans;
 ans=1e16;
 for(int k=i;k<j;k++)
 {
  int cost=dp(i,k)+dp(k+1,j)+pre[k]-pre[i-1]+pre[j]-pre[k];
  ans=min(ans,cost);
 }
 return ans;
}
int32_t main() {
    ios_base::sync_with_stdio(false);cin.tie(NULL); 
    for(int i=0;i<N;i++)
    for(int j=0;j<N;j++)
    cache[i][j]=-1;
    
    cin>>n;
    for(int i=1;i<=n;i++)
    {
     cin>>a[i];
     pre[i]=pre[i-1]+a[i];
    }
    cout<<dp(1,n)<<endl;
    return 0; 
}


Measured memory_bytes: 1536
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 1000000007; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;


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

  int w;
  cin >> w;

  int N = s.size();
  REP(i, N){
    if(i%w == 0) cout << s[i];
  }
  cout << endl;

  return 0;
}

Measured memory_bytes: 256
// 2010/12/22 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int n;
		cin >> n;
		if(n==0)
			break;

		for(int i=0; i<n; i++){
			int pm, pe, pj;
			cin >> pm >> pe >> pj;
			if(pm==100||pe==100||pj==100)
				cout << 'A' << endl;
			else if((pm+pe)/2>=90)
				cout << 'A' << endl;
			else if((pm+pe+pj)/3>=80)
				cout << 'A' << endl;
			else if((pm+pe+pj)/3>=70)
				cout << 'B' << endl;
			else if(((pm+pe+pj)/3>=50)&&(pm>=80||pe>=80))
				cout << 'B' << endl;
			else
				cout << 'C' << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;


int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i += 2)
        cout << s[i];
}


Measured memory_bytes: 592
#include <bits/stdc++.h>
 
typedef long long ll;
using namespace std;
int v[10001], w[10001];
ll cache[101][100001];

ll calc(int W, int n) {
	if(W < 0) {
		return INT_MIN;
	}
	
	if(n==0 || W==0) {
		return 0;
	}
	
	if(cache[n][W]!=-1) {
		return cache[n][W];
	}
	
	cache[n][W] = max(calc(W-w[n], n-1) + v[n], calc(W, n-1));
	return cache[n][W];
}
int main() {
	int n,W;
	cin>>n>>W;   
	for (int i=1; i<=n; i++) {
		cin>>w[i]>>v[i];
	}
	
	for (int i=0; i<=n; i++) {
		for (int j=0; j<=W;j++) {
			cache[i][j] = -1;
		}
	}
	
	cout << calc(W,n);
	return 0;
}

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

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

    vector<int> d(n+1, 0);
    for(int i=0; i<m; i++)
    {
        int x, y; cin >> x >> y;
        d[x]++;
        d[y]++;
    }

    int res = 1;
    for(int i=1; i<=n; i++) res &= (d[i]%2==0);

    if(res) cout << "YES\n";
    else cout << "NO\n";

    return 0;
}


Measured memory_bytes: 640
#include <cstdio>
#include <algorithm>
using namespace std;

bool a[700][700],dp[701][701];
int n,m,clr[700],nitem,item0[700],item1[700];

bool dfs(int u){
    if(clr[u]==1)item1[nitem]++;
    else item0[nitem]++;
    for(int v=0;v<n;v++){
        if(!a[u][v])continue;
        if(clr[v]!=0){
            if(clr[v]==clr[u])return false;
            else continue;
        }
        clr[v]=-clr[u];
        if(!dfs(v))return false;
    }
    return true;
}

int main(){
    scanf("%d%d",&n,&m);
    for(int i=0;i<n;i++){
        fill_n(a[i],n,true);
        a[i][i]=false;
    }
    for(int i=0;i<m;i++){
        int u,v;
        scanf("%d%d",&u,&v);
        u--;
        v--;
        a[u][v]=false;
        a[v][u]=false;
    }
    for(int i=0;i<n;i++){
        if(clr[i]==0){
            clr[i]=1;
            if(!dfs(i)){
                printf("-1\n");
                return 0;
            }
            nitem++;
        }
    }
    dp[0][0]=true;
    for(int i=1;i<=nitem;i++)
        for(int j=0;j<=n;j++){
            dp[i][j]=false;
            if(j>=item0[i-1])dp[i][j]=dp[i][j]||dp[i-1][j-item0[i-1]];
            if(j>=item1[i-1])dp[i][j]=dp[i][j]||dp[i-1][j-item1[i-1]];
        }
    int ans=n*n;
    for(int i=0;i<=n;i++)
        if(dp[nitem][i])
            ans=min(ans,(i*(i-1)+(n-i)*(n-i-1))/2);
    printf("%d\n",ans);
}

Measured memory_bytes: 1152
import sys
sys.setrecursionlimit(100000)
input = sys.stdin.readline
n,m=map(int,input().split())
z=n*(n-1)//2
l=[-1]*n
a=[1]*n
b=[input().split() for _ in range(m)]
c=[0]*m+[z]
d=[i for i in range(n)]
def r(s):
  t=l[s]
  if t<0:
    return s
  else:
    l[s]=r(t)
    return l[s]
def f(s):
  return r(int(s)-1)
for i in range(m-1,-1,-1):
  x,y=map(f,b[i])
  if x!=y:
    l[x]=d[y]
    d[y]=d[x]
    z-=a[x]*a[y]
    a[y]+=a[x]
  c[i]=z
for x in c[1:]:
  print(x)

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

string devine[4]={"AC","WA","TLE","RE"};

int main(){
  int n;
  cin >>n;
  int num[4]={0};
  for(int i=0;i<n;i++){
    string s;
    cin >>s ;
    if(s==devine[0]) num[0]++;
    if(s==devine[1]) num[1]++;
    if(s==devine[2]) num[2]++;
    if(s==devine[3]) num[3]++;
  }
  cout <<"AC x "<<num[0]<<endl;
  cout <<"WA x "<<num[1] <<endl;
  cout <<"TLE x "<<num[2] <<endl;
  cout <<"RE x " <<num[3] <<endl;
}

Measured memory_bytes: 3612
function Main(input) {
	input = input.split('\n');
	var N = parseInt(input[0], 10);
	var a = input[1].split(' ');

	var results = [];
	for (var i = 0; i < N; i++) {
		results[parseInt(a[i], 10) - 1] = i + 1;
	}
	console.log(results.join(' '));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 43080
import fractions

n,x=map(int,input().split())
l=list(map(int,input().split()))

l.append(x)
sl=sorted(l)

lis=[sl[i+1]-sl[i] for i in range(n)]

ans=0
for i in range(0, n):
    ans = fractions.gcd(ans, lis[i])
    
print(ans)



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

int main(){
    int n,m;
    cin >> n >> m;
    vector<P> r;
    rep(i,m){
        int p;string s;
        cin >> p >> s;
        p--;
        r.emplace_back(p,s);
    }
    vector<bool> ac(n,false);
    vector<int> wa(n,0);
    for(auto x : r){
        int p = x.first;
        string s = x.second;
        if(ac.at(p)) continue;
        else if(s == "AC") ac.at(p) = true;
        else wa.at(p)++;
    }
    int ans_ac = 0;
    int ans_wa = 0;
    for(auto x : ac) if(x) ans_ac++;
    for(int i = 0;i < n;++i) if(ac.at(i)) ans_wa +=wa.at(i);
    cout << ans_ac << " " << ans_wa << endl;
}

Measured memory_bytes: 8480
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>



#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i=int(a);i<int(b);i++)
#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n,k;cin>>n>>k;
  double res=0;
  repi(i,1,n+1)
  {
    int ti=i;
    int cnt=0;
    if(ti==0)continue;
    while(ti<k)
    {
      ti*=2;
      cnt++;
    }
    //cout<<i<<" "<<cnt<<endl;
    res+=pow(0.5,cnt)*1.0/n;
  }
  cout<<setprecision(14)<<res<<endl;
  return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll MOD = 1000000007;
const long long INF = 1LL << 60;

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()
{   
    int n,m; cin >> n >> m;
    cout << (n==m?"Yes":"No") << endl;
}
    

Measured memory_bytes: 256
n,k=map(int, input().split())
exp=list(map(lambda x:(int(x)+1)/2,input().split())) # 入力と同時に期待値計算

l=[0]*n
sum1=0
for i in range(n):# 累積和の計算
    sum1+=exp[i]
    l[i]=sum1 

ans=l[k-1]
for i in range(n-k):
    ans=max(ans,l[i+k]-l[i])
    
print(ans)

Measured memory_bytes: 23588
#include <bits/stdc++.h>
using namespace std;
 
#define MD 1000000007
typedef long long int ll;

int main(){
    ll x;
    cin>>x;
    ll sum=0,cnt=1;
    while(sum<x){
        sum+=cnt;
        cnt++;
    }
    cout<<cnt-1<<endl;

    return 0;
}

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

using namespace std;

int main()
{
    int x,y,a,b,c;
    cin>>x>>y>>a>>b>>c;

    vector<long long> a1(a);
    vector<long long> b1(b);
    vector<long long> c1(c);
    vector<long long> v(x+y+c);

    for(int i=0; i<a; i++)
        cin>>a1[i];
    sort(a1.begin(),a1.end(),greater<long long>());

    for(int i=0; i<b; i++)
        cin>>b1[i];
    sort(b1.begin(),b1.end(),greater<long long>());

    for(int i=0; i<c; i++)
        cin>>c1[i];
    sort(c1.begin(),c1.end(),greater<long long>());

    for(int i=0; i<x; i++)
        v.push_back(a1[i]);
    for(int i=0; i<y; i++)
        v.push_back(b1[i]);
    for(int i=0; i<c; i++)
        v.push_back(c1[i]);
    sort(v.begin(),v.end(),greater<long long>());

    long long ans=0;
    for(int i=0; i<x+y; i++)
        ans+=v[i];

    cout<<ans<<endl;

    return 0;
}


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

#define MAX_N 21

const int mod = 1e9+7;
int GM(int num){
    return (num >= mod ? num-mod : num);
}

int n;
bool a[MAX_N][MAX_N];
int dp[MAX_N][1<<MAX_N];

int solve(int i ,int b){
    if(i == n)
        return 1;
    int&ret = dp[i][b];
    if(~ret)
        return ret;

    ret = 0;
    for(int j=0; j<n; j++)
        if(a[i][j] && !(b&(1<<j)))
            ret = GM(ret+solve(i+1 ,b|(1<<j)));

    return ret;
}

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

    memset(dp ,-1 ,sizeof dp);
    printf("%d\n",solve(0 ,0));
}


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

int main(void)
{
	int n;
	while (cin >> n, n){
		int sum = 0, tmp;
		for (int i = 0; i < (n / 4); i++){
			cin >> tmp;
			sum += tmp;
		}
		cout << sum << endl;
	}
	 
	return 0;
}

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


int main(){
	string s,t;
	cin >>s>>t;
	int sum=0;
	for(int i=0;i<s.length();i++){
		if(s[i]!=t[i]) sum++;
	}
	cout <<sum<<endl;
	return 0;
}

Measured memory_bytes: 3912
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;

vector<P> G[1001][1001];
int dp[1001][1001];

vector<P> tp;

int dfs(int x,int y,int px=1000,int py=1000)
{
	if(dp[x][y]!=0)return dp[x][y];
	if(G[x][y].empty())return dp[x][y] = 1;
	for(auto i:G[x][y])
	{
		dp[x][y] = max(dp[x][y],dfs(i.first,i.second,x,y)+1);
	}
	return dp[x][y];
}


int main()
{
	int n;
	cin >> n;
	vector<vector<P>> input(n);
	map<P,int> h;//入次数
	for(int i = 0;i<n;i++)
	{
		for(int j = 0;j<n-1;j++)
		{
			int x=i;
			int y;
			cin >> y;
			y--;
			if(x>y)swap(x,y);
			input[i].emplace_back(x,y);

		}
	}
	for(int i = 0;i<n;i++)
	{
		for(int j =0;j<n-2;j++)
		{
			h[input[i][j+1]]++;
			G[input[i][j].first][input[i][j].second].emplace_back(input[i][j+1]);
		}
	}
	stack<P> S; //入次数がゼロの頂点
	for(int i = 0;i<n;i++)
	{
		for(int j = i+1;j<n;j++)
		{
			if(h[P(i,j)]==0)
			{
				S.emplace(i,j);
			}
		}
	}
	while(S.size())
	{
		auto now = S.top();S.pop();
		tp.push_back(now);
		for(auto i:G[now.first][now.second])
		{
			h[i]--;
			if(h[i]==0)S.emplace(i);
		}
	}
	if(tp.size()!=n*(n-1)/2)
	{
		cout << -1 << endl;
		return 0;
	}



	int ans = 0;
	for(int i = 0;i<n;i++)
	{
		for(int j = i+1;j<n;j++)
		{
			ans = max(ans,dfs(i,j));
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 89584
#include<iostream>
#include<string>
#include<vector>
#include<numeric>
#include<math.h>
#include<algorithm>
#include<iomanip>
#include<list>
#include<bitset>
using namespace std;

int count(int a) {
	int ans = 0;
	while (a % 2 == 0) {
		ans += 1;
		a /= 2;
	}
	return ans;
}

int main() {

	int N;
	cin >> N;

	int a;
	int ans = 0;
	for (int i = 0; i < N; i++) {
		cin >> a;
		ans += count(a);
	}

	cout << ans << endl;

	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>

void graph(int n){ 
	int i;
	if (n != 0){
		for (i = 0; i < n; i++){
			printf("*");
		}
	}
}

int main(void)
{
	int n;
	int i;
	float height;
	int kaikyuu[6] = {0};
	float kaikyuuti[6];
	int flag;
	
	kaikyuuti[0] = 165.0;
	
	for (i = 1; i < 6; i++){
		kaikyuuti[i] = kaikyuuti[i - 1] + 5;
	}
	
	scanf("%d", &n);
	
	while (n-- > 0){
		scanf("%f", &height);
		
		flag = 0;
		for (i = 0; i < 6; i++){
			if (height < kaikyuuti[i]){
				kaikyuu[i]++;
				flag = 1;
			}
			
			if (flag == 1){
				break;
			}
		}
	}
	
	for (i = 0; i < 6; i++){
		printf("%d:", i + 1);
		graph(kaikyuu[i]);
		printf("\n");
	}
	
	return (0);
}

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

using namespace std;

typedef short sho;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;
typedef string str; 
 
typedef pair<int,int> pii;
typedef pair<ll,ll> pll; 
typedef pair<ld,ld> pld;
 
typedef vector<int> vi; 
typedef vector<ll> vl; 
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<pii> vpi;
typedef vector<pll> vpl;
typedef vector<pld> vpd;

#define LOCAL
#define MP make_pair 
#define FF first
#define SS second
#define sz(x) (int)x.size()
#define begin(x) (x).begin() 
#define end(x) (x).end()
#define rbegin(x) (x).rbegin()
#define rend(x) (x).rend()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define rsz resize
#define ins insert
#define ft front()
#define bk back()
#define PF push_front 
#define PB push_back
#define PP push
#define lb lower_bound 
#define ub upper_bound
#define lowbit(x) x&(-x)
#define testbit(x,i) x&(1<<i)

inline void checkmin(int &x,int y){x=min(x,y);}
inline void checkmax(int &x,int y){x=max(x,y);}

const int maxn = 2e5 + 10;
int n, a[maxn];
map<int,long long> cnt;

int main() 
{
	#ifndef LOCAL
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif
	ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    /* start code */
    cin>>n;
    for(int i = 1; i <= n; i++) {
    	cin>>a[i];
    	cnt[a[i] + i]++;
	}
	long long ans=0;
	for(int i = 1; i <= n; i++) {
		int num = i - a[i];
		if(num < 1) {
			continue;
		}
		ans+=cnt[num];
	}
	cout<<ans<<endl;
    /* end code */
	return 0;
}

Measured memory_bytes: 18200
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair< ll, ll > Pi;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define rep3(i,i0,n) for(int i=i0;i<(n);i++)
#define pb push_back
#define mod 1000000007
const ll INF = 1LL << 60;
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; }
ll gcd(ll a, ll b) {return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) {return a/gcd(a,b)*b;}
#define all(x) x.begin(), x.end()
#define mp make_pair
bool compare(Pi a, Pi b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}


bool In_map(ll y,ll x,ll h,ll w){
    if(y<0 || x<0 || y>=h || x>=w){
        return 0;
    }else{
        return 1;
    }
}
const vector<ll> dx{1,0,-1,0};
const vector<ll> dy{0,1,0,-1};

int main() {
    ll H,W;
    cin >> H>>W;
    vector<vector<ll>> dp(10,vector<ll>(10,INF));
    vector<vector<ll>> A(H,vector<ll>(W));


    rep(i,10){
        rep(j,10){
            cin >>dp[i][j];
        }
    }

    rep(i,H){
        rep(j,W){
            cin >> A[i][j];
        }
    }

    rep(k,10){
        rep(i,10){
            rep(j,10){
                chmin(dp[i][j], dp[i][k] + dp[k][j]);
            }
        }
    }
    
    ll ans = 0;
    rep(i,H){
        rep(j,W){
            if(A[i][j] != -1){
                ans+=dp[A[i][j]][1];
            }
        }
    }
    
    
    cout << ans <<endl;
    
    return 0;
    

}


Measured memory_bytes: 3960
#include <iostream>
#include <vector>
 
using namespace std;
 
 
int main(void){
    vector<int> vec(9, 0);
    int N, tmp;
    cin >> N;
    for(int i = 0; i< N; i++)
    {
        cin >> tmp;
        if( tmp <= 399)
        {
            vec[0] = 1;
        }
        else if(tmp <= 799)
        {
            vec[1] = 1;
        }
        else if(tmp <= 1199)
        {
            vec[2] = 1;
        }
        else if(tmp <= 1599)
        {
            vec[3] = 1;
        }
        else if(tmp <= 1999)
        {
            vec[4] = 1;
        }
        else if(tmp <= 2399)
        {
            vec[5] = 1;
        }
        else if(tmp <= 2799)
        {
            vec[6] = 1;
        }
        else if(tmp <= 3199)
        {
            vec[7] = 1;
        }
        else if(tmp > 3199)
        {
            vec[8] += 1;
        }   
    }
    int count = 0;
    for(int i = 0; i < 8; i++)
    {
        count += vec[i];
    }
    int min, max;
    if(count > 0)
    {
        min = count;
    }else{
        min = 1;
    }
    
   max = vec[8] + count;
    
    cout << min << " " << max << 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;
using P = pair<int, int>;

int main(){
  ll x;
  cin>>x;
  ll a=100,ans=0;
  while(x>a){
    a=a+a/100;
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <chrono>
#include <random>
#include <cassert>

std::mt19937 rng((int) std::chrono::steady_clock::now().time_since_epoch().count());

int main() {
	std::ios_base::sync_with_stdio(false); std::cin.tie(NULL);
	int n, m, k;
	std::cin >> n >> m >> k;
	std::vector<std::vector<int>> mat(n, std::vector<int>(m));
	int id = 0;
	for(int c = 1; c <= k; c++) {
		int size;
		std::cin >> size;
		while(size--) {
			int x = id / m;
			int y = x % 2 == 1 ? m - id % m - 1 : id % m;
			mat[x][y] = c;
			id++;
		}
	}
	for(int i = 0; i < n; i++) {
		for(int j = 0; j < m; j++) {
			std::cout << mat[i][j] << (j + 1 == m ? '\n' : ' ');
		}
	}
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define elif else if
#define ffast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);

int main()
{
    ffast;


    int t;
    cin>>t;
    bool possible = false;
    while(t!=0)
    {
        int x = t%10;
        t = t/10;
        if(x==7)
            {
                possible = true;
                break;
            }
    }
    if(possible)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}






Measured memory_bytes: 3652
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        int n = sc.nextInt();
        StringBuilder sb = new StringBuilder();
        sb.append(s.substring(0,1));
        for(int i = 1;i<s.length();i++){
            if(i % n == 0){
                sb.append(s.substring(i,i+1));
            }
        }
        s = sb.toString();
        System.out.println(s);
    }
}

Measured memory_bytes: 23252
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<ll,ll>;
const int inf=1e9+7;
const ll INF=9e18;
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;}
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;}
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };
vector<vll> table;
vector<vll> sum;

int main(){cout<<fixed<<setprecision(20);
           //二次元imos
           int n,k;
           cin>>n>>k;
           int e=1e5;
           table.resize(e+1,vll(k+1));
           sum.resize(e+1,vll(k+1));
           rep(i,0,e+1){
            rep(j,0,k+1){
              table[i][j]=0;
            }
           }
           rep(i,0,n){
             int s,t,c;
             cin>>s>>t>>c;
             table[s][c]++;
             table[t][c]--;
           }
           
           rep(i,0,e+1){
            rep(j,0,k+1){
              sum[i][j]=0;
            }
           }
           rep(i,1,e+1){
            rep(j,1,k+1){
              if(sum[i-1][j]==0&&table[i][j]==1) {
                sum[i-1][j]++;              
                sum[i][j]--;
              }
              sum[i][j]+=sum[i-1][j]+table[i][j];
            /*  if(sum[i][j]==0&&table[i][j]==-1){
                sum[i][j]++;
                sum[i+1][j]--;
              }*/
            //cout<<table[i][j]<<" ";
            }
             //cout<<endl;
           }
           rep(i,1,e+1){
             rep(j,1,k+1){
              sum[i][j]+=sum[i][j-1];
             }
           }
           ll ans=0;
           rep(i,0,e+1){
            chmax(ans,sum[i][k]); 
             //cout<<ans<<" ";
           }
           cout<<ans<<endl;
          }

Measured memory_bytes: 57920
#include<bits/stdc++.h>
typedef long long ll;

using namespace std;

int keta(int n){
  int res = 0, tmp = n;
  while(tmp > 0){
    tmp /= 10;
    res++;
  }
  return res;
}

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int N; cin >> N;
  int ans = 0;
  for(int i = 1;i <= N;++i){
     if(keta(i) % 2 == 1) ans++; 
  }
  cout << ans;

  return 0;
}

Measured memory_bytes: 384
XABstr = input().split()
XAB = []
for n in XABstr:
    XAB.append(int(n))
dif = XAB[2]-XAB[1]
if dif <= 0:
    print('delicious')
elif dif > 0:
    if dif <= XAB[0]:
        print('safe')
    elif dif > XAB[0]:
        print('dangerous')

Measured memory_bytes: 3060
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
/*answer*/
    int n, m;
    int[] b;
    int[][] a;
    int i, j;
    int[] c;

    n = sc.nextInt();
    m = sc.nextInt();
    b = new int[m];
    a = new int[n][m];
    c = new int[n];

    for(i = 0;i < n;i++){
      for(j = 0;j < m;j++){
        a[i][j] = sc.nextInt();
      }
    }
    for(i = 0;i < m;i++){
      b[i] = sc.nextInt();
    }

    for(i = 0;i < n;i++){
      for(j = 0;j < m;j++){
        c[i] += a[i][j] * b[j];
      }
    }

    for(i = 0;i < n;i++){
      System.out.println(c[i]);
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 31792
#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 PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
const long long MOD = 1000000007;

char S[40][40];
ll H, W;
ll dist[40][40];

void bfs(ll si, ll sj){
    REP(i, H) REP(j, W) dist[i][j] = INT64_MAX / 2;
    queue<pll> que;
    que.push(pll(si * W + sj, 0));
    ll ret = 0;
    while(!que.empty()){
        ll i = que.front().first / W;
        ll j = que.front().first % W;
        ll d = que.front().second;
        que.pop();
        if(S[i][j] == '#') continue;
        if(dist[i][j] <= d) continue;
        dist[i][j] = d;
        if(i > 0) que.push(pll((i - 1) * W + j, d + 1));
        if(i < H - 1) que.push(pll((i + 1) * W + j, d + 1));
        if(j > 0) que.push(pll(i * W + j - 1, d + 1));
        if(j < W - 1) que.push(pll(i * W + j + 1, d + 1));
    }
}

signed main(){
    cin >> H >> W;
    string str;
    REP(i, H){
        cin >> str;
        REP(j, W){
            S[i][j] = str[j];
        }
    }
    ll ans = 0;
    REP(i, H){
        REP(j, W){
            if(S[i][j] == '#') continue;
            bfs(i, j);
            ll m = 0;
            REP(k, H){
                REP(l, W){
                    if(S[k][l] == '#') continue;
                    m = max(m, dist[k][l]);
                }
            }
            ans = max(ans, m);
        }
    }
    PRINT(ans);
}

Measured memory_bytes: 3636
from collections import defaultdict as dd
from collections import deque
import bisect
import heapq

def ri():
    return int(input())

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


def solve():
    n, k = rl()
    snacks = set()
    for i in range(k):
        d = ri()
        for s in rl():
            snacks.add(s)
    print (n - len(snacks))






mode = 's'

if mode == 'T':
    t = ri()
    for i in range(t):
        solve()
else:
    solve()


Measured memory_bytes: 70352
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
#define PI 3.14159265359
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))

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

  int a[3];

  rep(i, 3) {
    if (n[i] == '1')
      a[i] = 9;
    else
      a[i] = 1;

    cout << a[i];
  }

  return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
set<char>r;
string h;
cin>>h;
for(int i=0;i<h.size();i++){
           r.insert(h[i]);
}
if(r.size()==3){
           cout<<"Yes";
}
else{
           cout<<"No";
}
 
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cmath>
#include <map>
#include <numeric>
#include <iomanip>
#include <sstream>
using namespace std;

vector<string> split(const string& s, char delim) {
	vector<string> elems;
	stringstream ss(s);
	string item;
	while (getline(ss, item, delim)) {
		if (!item.empty()) {
			elems.push_back(item);
		}
	}
	return elems;
}

int main() {

	int n;
	cin >> n;
	n = n % 1000 == 0 ? 0 : 1000 - n % 1000;

	cout << n << endl;

	return 0;
};

Measured memory_bytes: 3632
#include<iostream>
#include<math.h>
#include<climits>
#include<stdio.h>
#include<string.h>
using namespace std;

int helper(int arr[][3],int n,int i,int state,int dp[][3])
{
  if(i==n)
  return 0;
  if(dp[i][state]!=-1)
  return dp[i][state];

  int MAX=INT_MIN;
  for(int j=0;j<3;j++)
  {
    if(j!=state)
    {
      MAX=max(MAX,helper(arr,n,i+1,j,dp));
    }
  }

  return dp[i][state]=arr[i][state]+MAX;

}
 
int main()
{
   int m,n;
   cin>>n;
   int arr[n][3];
   for(int i=0;i<n;i++)
   {
     for(int j=0;j<3;j++)
     cin>>arr[i][j];
   }
   int dp[n][3];
   memset(dp,-1,sizeof(dp));
    cout<<max(helper(arr,n,0,0,dp),max(helper(arr,n,0,1,dp),helper(arr,n,0,2,dp)));



    return 0;
}

Measured memory_bytes: 15308
x =int(input())
total =0
count =0
for i in range(x):
    if 500*i ==x:
        count =i*1000
        break
    elif 500*i > x:
        total =abs(500*(i-1) -x)
        count =(i-1) *1000
        # print(count)
        break
if total ==0:
    print(count)
else:
    for i in range(x):
        if 5*i ==total:
            print("aa")
            count +=i*5
        elif 5*i >total:
            count +=(i-1)*5
            # print(count)
            # total =abs(5*(i-1) -total)
            break
    print(count)

Measured memory_bytes: 3064
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */
struct edge {
  int to;
  int cost;
};

const int MAX_N = 100000;
int N;
vector<edge> table[MAX_N];

int colors[MAX_N];

void dfs(int node, int par, int score) {
  if (score % 2 == 0) colors[node] = 1;
  else colors[node] = 0;

  for (auto next : table[node]) {
    if (next.to == par) continue;
    dfs(next.to, node, score + next.cost);
  }
}

signed main() {
  cin >> N;
  fill(colors, colors + N, -1);
  for (int i = 0; i < N - 1; i++) {
    int s, t, c;
    cin >> s >> t >> c;
    s--; t--;
    c = c % 2;
    table[s].push_back({t, c});
    table[t].push_back({s, c});
  }

  dfs(0, -1, 0);

  for (int i = 0; i < N; i++) {
    cout << colors[i] << endl;
  }
}

Measured memory_bytes: 10240
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF 1001001001
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
using namespace std;

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

    ll a,b,c,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str;
    n=5;
    //vector<vector<ll>> v(tate,vector<ll> (yoko));
    vector<ll> v(n);
    rep(i,n)   cin >> v[i];
    rep(i,n){
        if(v[i]==0) cout<<i+1<<endl;
    }
    return 0;
}


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

void solve(long long N, long long M, std::vector<long long> A, std::vector<long long> B, std::vector<long long> C){
    priority_queue<pair<int, int>> q;
    for(int i = 0; i < N; ++i) q.push(make_pair(A[i], 1));
    for(int i = 0; i < M; ++i) q.push(make_pair(C[i], B[i]));
    ll ans = 0;
    for(int i = 0; i < N; ++i){
        auto p = q.top();
        q.pop();
        ans += p.first;
        if(p.second > 1){
            p.second --;
            q.push(p);
        }
    }
    cout << ans << endl;
    return ;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    std::vector<long long> A(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
    }
    std::vector<long long> B(M);
    std::vector<long long> C(M);
    for(int i = 0 ; i < M ; i++){
        scanf("%lld",&B[i]);
        scanf("%lld",&C[i]);
    }
    solve(N, M, std::move(A), std::move(B), std::move(C));
    return 0;
}


Measured memory_bytes: 4852
#include <stdio.h>
#include<stdlib.h>
#include<string.h>
struct Node {
        int key;
      struct   Node *prev, *next;
};
struct Node *nil;
void printList(){
  struct Node *cur = nil->next;
  int isf =0;
  while(1){
    if(cur==nil){
      break;
    }
    if(isf++>0){
      printf(" ");
    }
    printf("%d",cur->key);
    cur=cur->next;
  }
  printf("\n");
}
void init(){
        nil=(struct Node *)malloc(sizeof(struct Node));
        nil->next=nil;
        nil->prev=nil;
}
void insert(int key){
        struct Node *x=(struct Node *)malloc(sizeof(struct Node));
        x->key=key;
        x->next=nil->next;
        nil->next->prev=x;
        nil->next=x;
        x->prev=nil;
}
struct Node* listsearch(int key){
        struct Node *cur=nil->next;
        while(cur!=nil&&cur->key !=key) {
                cur=cur->next;
        }
        return cur;
}
void deleteNode(struct Node *t){
        if(t==nil) {
                return;
        }
        t->prev->next=t->next;
        t->next->prev=t->prev;
        free(t);

}
void deleteFirst(){
        deleteNode(nil->next);
}
void deleteLast(){
        deleteNode(nil->prev);
}
void deletekey(int key){
        deleteNode(listsearch(key));
}
int main(){
        int key,n,i;
        int size=0;
        char com[20];
        int np=0,nd=0;
        scanf("%d",&n);
        init();
        for(i=0; i<n; i++) {
                scanf("%s%d",com,&key);
                if(com[0]=='i') {
                        insert( key);
                        np++;
                        size++;
                }
                else if(com[0]=='d') {
                        if(strlen(com)>6) {
                                if(com[6]=='F') {
                                        deleteFirst();
                                }
                                else if(com[6]=='L') {
                                        deleteLast();
                                }

                        }

                        else{
                                deletekey(key);
                                nd;
                        }
                        size--;

                }
        }
        printList();
        return 0;
}



Measured memory_bytes: 33940
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

ll dx[9] = {-1, 1, 0, 0, -1, -1, 1, 1, 0};
ll dy[9] = {0, 0, -1, 1, -1, 1, -1, 1, 0};

/* Macros reg. ends here */

const ll INF = 1LL << 50;

ll cnt(ll x, ll y) {
  ll th = x * y;
  if (x == 1) return 0;

  ll up = x - 1;

  auto chk = [&](ll t) {
    if (t == 0) return true;

    auto g = [&](ll ii) { return (y + ii) * (t - ii + 1); };

    ll gt = g(t), gtm1 = g(t - 1);
    if (gtm1 < gt) return (gt < th);

    ll lc = 1, rc = t;
    while (lc < rc) {
      ll m0 = (lc + rc) / 2;
      ll m1 = m0 + 1;
      if (g(m0) < g(m1)) {
        lc = m1;
      } else {
        rc = m0;
      }
    }

    return (g(lc) < th);
  };

  if (chk(up)) return up;

  ll l = 0, r = up;
  while (l + 1 < r) {
    ll m = (l + r) / 2;
    if (chk(m)) {
      l = m;
    } else {
      r = m;
    }
  }

  return l;
}

int main() {
  // ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cout << fixed << setprecision(15);

  ll n;
  cin >> n;
  rep(i, n) {
    ll a, b;
    cin >> a >> b;
    ll ans = 0;
    ans += cnt(a, b);
    ans += cnt(b, a);
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 3624
def main():
    N = int(input())
    W_before = input()
    W_list = set()
    W_list.add(W_before)
    for i in range(N-1):
        W_after = input()
        if W_before[-1] != W_after[0]:
            print('No')
            return
        if W_after in W_list:
            print('No')
            return
        W_list.add(W_after)
        W_before = W_after
    print('Yes')

if __name__ == "__main__":
    main()


Measured memory_bytes: 9016
import java.util.*;

public class Main {

	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		int a = Integer.parseInt(sc.next());
		
		int b = 1000 - (a % 1000);
		
		if(b==1000)
		{
			System.out.println(0);
		}
		else
		{
			System.out.println(b);
		}
	}
}

Measured memory_bytes: 35756
#include <iostream>
#include <iomanip>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>
#include <numeric>
#include <set>

using namespace std;
struct aaa{aaa(){cin.tie(nullptr); ios::sync_with_stdio(false); cout<<fixed<<setprecision(20);};}aaa;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v){o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
#define debug(v) {cerr<<"\033[1;36m[debug]\033[m "<<#v<<" : "<<v<<endl;}

using int64 = long long;

void solve1(int64, int64, int64);

const int MOD = 1000000007;
struct mint {
    int64 x;
    mint(const int64 x1=0) { x = x1%MOD; };

    mint& operator++(int n) { x+=1; return *this; };
    mint& operator--(int n) { x-=1; return *this; };
    mint& operator=(int64 n) { x=n%MOD; return *this; };
    mint& operator--() {x-=1; return *this; };
    mint& operator+=(const mint a) { if ( (x+=a.x) >= MOD) x-=MOD; return *this; }
    mint& operator-=(const mint a) { if ( (x+= MOD-a.x) >= MOD) x-= MOD; return *this; }
    mint& operator*=(const mint a) { (x*=a.x) %= MOD; return *this; }
    mint& operator/=(const mint a) { return (*this) *= a.inv();}
    mint operator+(const mint a) const { mint res(*this); return res+=a; }
    mint operator-(const mint a) const { mint res(*this); return res-=a; }
    mint operator*(const mint a) const { mint res(*this); return res*=a; }
    mint operator/(const mint a) const { mint res(*this); return res/=a; }
    mint inv() const { return pow(MOD-2);}
    friend ostream& operator<<(ostream &os, const mint a) noexcept { return os << a.x; }
    constexpr bool operator == (const mint& r) const noexcept { return this->x == r.x; }
    constexpr bool operator != (const mint& r) const noexcept { return this->x != r.x; }
    mint pow(long long t) const {
        if (!t) return mint(1);
        mint a = pow(t>>1);
        a*=a;
        if(t&1) a*= *this;
        return a;
    }
};

mint nCr(int64 n, int64 r) {
    if (n < r) return 0;
    mint x = 1;
    mint y = 1;
    for (int i=1; i<=r; i++) {
        x *= (n - i + 1);
        y *= i;
    }
    return x / y;
}


const int N = 1000000;
int main() {
    int64 n,a,b;
    cin >> n >> a >> b;

    mint ans = mint(2).pow(n) - 1;
    ans -= nCr(n,a);
    ans -= nCr(n,b);
    debug(ans);


    cout << ans << endl;
}

Measured memory_bytes: 256
from collections import defaultdict
n, k = map(int, input().split())
a = list(map(int, input().split()))

a_cs = [0] * (n + 1)
for i in range(n):
    a_cs[i + 1] = a_cs[i] + a[i]

ans = 0
d = defaultdict(int)
for j in range(n + 1):
    if j - k >= 0:
        d[(a_cs[j - k] - (j - k)) % k] -= 1

    # print(j, d, d[(a_cs[j] - j) % k])
    ans += d[(a_cs[j] - j) % k]

    d[(a_cs[j] - j) % k] += 1

print(ans)


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

// #undef DEBUG  // Uncomment this line to forcefully disable debug print.
#if DEBUG
template <typename T>
void debug(T value) {
  std::cerr << value;
}
template <typename T, typename... Ts>
void debug(T value, Ts... args) {
  std::cerr << value << ", ";
  debug(args...);
}
#define dbg(...)                              \
  do {                                        \
    cerr << #__VA_ARGS__ << ": ";             \
    debug(__VA_ARGS__);                       \
    cerr << " (L" << __LINE__ << ")" << endl; \
  } while (0)
#else
#define dbg(...)
#endif

void read_from_cin() {}
template <typename T, typename... Ts>
void read_from_cin(T& value, Ts&... args) {
  std::cin >> value;
  read_from_cin(args...);
}
#define in(type, ...) \
  type __VA_ARGS__;   \
  read_from_cin(__VA_ARGS__);

template <typename T>
void write_to_cout(const T& value) {
  std::cout << value << std::endl;
}
template <typename T, typename... Ts>
void write_to_cout(const T& value, const Ts&... args) {
  std::cout << value << ' ';
  write_to_cout(args...);
}
#define out(...) write_to_cout(__VA_ARGS__);

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

using ll = long long;

using namespace std;

int main() {
  in(int, n);
  vector<int> a(n);
  rep(i, n) cin >> a[i];
  ll ans = 0;
  rep(i, n) ans += a[i] - 1;
  out(ans);
}


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

int main(){
  int A,B,K;
  cin >> A >> B >> K;
  for(int i=A; i<=min(A+K-1,B); i++){
    cout << i << endl;
  }for(int i=max(B-K+1,A+K); i<=B; i++){
    cout << i << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int q, mas[10][10];
int draw[][5][5] = {
  /*Small*/
  {{ 0, 0, 1, 0, 0},
   { 0, 1, 1, 1, 0},
   { 0, 0, 1, 0, 0}},
  //*midium*/
  {{ 0, 0, 1, 1, 1},
   { 0, 0, 1, 1, 1},
   { 0, 0, 1, 1, 1}},
  /*large*/
  {{ 0, 0, 1, 0, 0},
   { 0, 1, 1, 1, 0},
   { 1, 1, 1, 1, 1},
   { 0, 1, 1, 1, 0},
   { 0, 0, 1, 0, 0}},
};
 
bool check( int y, int x, int w){
  for(int i = 0 ; i < 5 ; i++ ){
    for(int j = 0 ; j < 5 ; j++ ){
      if(mas[y + i][x + j - 2] - draw[w][i][j] < 0) return false;
    }
  }
  return true;
}
 
void paint( int y, int x, int w){
  for(int i = 0 ; i < 5 ; i++ ){
    for(int j = 0 ; j < 5 ; j++ ){
      mas[y + i][x + j - 2] -= draw[w][i][j];
    }
  }
}
 
void repaint( int y, int x, int w){
  for(int i = 0 ; i < 5 ; i++ ){
    for(int j = 0 ; j < 5 ; j++ ){
      mas[y + i][x + j - 2] += draw[w][i][j];
    }
  }
}
 
bool rec( int y, int x, int n){
  if( n < 0 ) return false;
  if( y == 10 ) return n == 0;
  if( mas[y][x] == 0 ) return rec( y + (x == 9), (x + 1) % 10, n);
  for(int i = 0 ; i < 3 ; i++ ){
    if(!check( y, x, i)) continue;
    paint( y, x, i);
    if(rec( y, x, n - 1)){
      cout << x + (i == 1) << " " << y + 1 + (i == 2) << " " << i + 1 << endl;
      return true;
    }
    repaint( y, x, i);
  }
  return false;
}
 
int main(){
  cin >> q;
  for(int i = 0 ; i < 10 ; i++ ){
    for(int j = 0 ; j < 10 ; j++ ){
      cin >> mas[i][j];
    }
  }
  rec( 0, 0, q);
 }

Measured memory_bytes: 3084
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#define Cin(T, x) T x; cin >> x
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cout(x) cout << (x) << "\n"
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) sxs[i+1] = sxs[i] + xs[i]
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) find(Range(c), x) != c.end()
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Vec2(T, vs, n, m) vector<vector<T>> vs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)

using namespace std;
using ll = long long;

int main(void){
    Cin(int, n);
    Cin(int, x);
    Cins(int, n, m);
    Sort(m);
    Cout(n + (x - Sum(m)) / m[0]);
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP0(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REP1(i,n) for(int i=1, i##_len=(n); i<=i##_len; ++i)
#define RREP0(i,n) for(int i=n-1; i>=0; --i)
#define RREP1(i,n) for(int i=n; i>=1; --i)
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define FILL(c, v) fill((c).begin(),(c).end(), v)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define CLR(a) memset((a), 0 ,sizeof(a))

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

typedef long long LL;

const int INTINF = 2147483647;
const LL LLINF = 9223372036854775807;
int gcd(int a,int b){return b?gcd(b,a%b):a;}


void solve() {
  int N, M; cin >> N >> M;
  LL ans = 0;
  vector<pair<int, int>> AB; AB.reserve(N);
  int A, B; 
  REP0(i, N) { 
      cin >> A >> B;
      AB.push_back(make_pair(A, B));
  }
  SORT(AB);
  priority_queue<int> Q;

  int ptr = 0;
  REP1(dayLeft, M) {
       while (ptr < SZ(AB)) {
          if (AB[ptr].first > dayLeft) break;
          Q.push(AB[ptr].second);
          ptr++;
      }
      if (Q.empty()) continue;
      ans += Q.top();
      Q.pop();
  }
  cout << ans << endl;
}

int main(int argc, char const *argv[])
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  std::cout<<std::fixed<<std::setprecision(10);
  solve();
  return 0;
}

Measured memory_bytes: 1660
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  vector<int> p(n);
  for(int i=0;i<n;i++) cin >> p[i];
  int cnt = 0;
  for(int i=1;i<n-1;i++){
    if(p[i-1] < p[i] && p[i] < p[i+1]) cnt++;
    if(p[i-1] > p[i] && p[i] > p[i+1]) cnt++;
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip	;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
vi dp,visit;
vvi tG;
void dfs(int a){
	if(visit[a])return;
	if(tG[a].size()==0){
		dp[a]=true;
		return;
	}
	visit[a]=true;
	rep(i,tG[a].size())dfs(tG[a][i]);
	return;
}
int main(){
	int n;
	while(cin>>n,n){
		vector<vector<string> >in(n);
		rep(i,n){
			string s;
			cin>>s;
			string t="";
			rep(j,s.size()){
				if(!isalpha(s[j])){
					in[i].pb(t);
					j++;
					t="";
				}
				t+=s[j];
			}
		}
		vvi G(n);
		map<string,int>m;
		int co=1;
		rep(i,n)rep(j,in[i].size()){
			if(m[in[i][j]]){
				G[i].pb(m[in[i][j]]);
			}else{
				G[i].pb(co);
				m[in[i][j]]=co;
				co++;
			}
		}
		tG=vvi(co);
		rep(i,n){
			rep(j,G[i].size()-1)tG[G[i][0]].pb(G[i][j+1]);
		}
		dp=vi(co);
		visit=vi(co);
		dfs(1);
		int out=0;
		rep(i,co)if(dp[i])out++;
		cout<<out<<endl;
//		cout<<dfs(1)<<endl;
		
	}
}

Measured memory_bytes: 1380