akhauriyash/Code-Regression huggingface dataset:
//我永远喜欢ysgh
#include<bits/stdc++.h>
#define For(i,x,y) for (register int i=(x);i<=(y);i++)
#define FOR(i,x,y) for (register int i=(x);i<(y);i++)
#define Dow(i,x,y) for (register int i=(x);i>=(y);i--)
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define siz(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
#define fil(a,b) memset((a),(b),sizeof(a))
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pa;
typedef vector<int> poly;
inline ll read(){
    ll x=0,f=1;char c=getchar();
    while ((c<'0'||c>'9')&&(c!='-')) c=getchar();
    if (c=='-') f=-1,c=getchar();
    while (c>='0'&&c<='9') x=x*10+c-'0',c=getchar();
    return x*f;
}

const int N = 110;
int n,k;
char s[N];

const int mod = 1e9+7;
int fac[N<<1],ifac[N<<1];
inline void init(){
	fac[0]=1;
	For(i,1,200) fac[i]=1ll*fac[i-1]*i%mod;
	auto power=[](int a,int b){
		int ret=1;
		for (;b;b>>=1,a=1ll*a*a%mod) if (b&1) ret=1ll*ret*a%mod;
		return ret;
	};
	ifac[200]=power(fac[200],mod-2);
	Dow(i,199,0) ifac[i]=1ll*ifac[i+1]*(i+1)%mod;
}

int ans,cnt,a[N],_cnt,_a[N],tot;
inline bool check(){
	if (!_cnt) return 0;
	cnt=_cnt;
	For(i,1,cnt) a[i]=_a[i];
	reverse(a+1,a+1+cnt);
	int lim=0;
	while (lim<cnt&&a[lim+1]>1) ++lim;
	int cnt_r=0,cnt_b=0,cnt_x=0;
	For(i,1,k) 
		if (s[i]=='r'&&cnt_r<cnt) ++cnt_r;
		else if (s[i]=='b'&&cnt_b<min(lim,cnt_r)) ++cnt_b,cnt_x+=a[cnt_b]-2;
		else if (cnt_x) --cnt_x;
	return !cnt_x&&cnt_b==lim&&cnt_r==cnt;
}
inline int calc(int sum){
	auto C=[=](int n,int m){
		return 1ll*fac[n]*ifac[m]%mod*ifac[n-m]%mod;
	};
	int ret=fac[cnt];
	for (int l=1,r=1;l<=cnt;l=++r){
		while (a[r+1]==a[l]&&r<cnt) ++r;
		ret=1ll*ret*ifac[r-l+1]%mod;
	}
	return 1ll*ret*C(n+tot-1,sum+tot-1)%mod;
}
inline void dfs(int sum,int last){
	if (check()){
		ans+=calc(sum-1);
		if (ans>=mod) ans-=mod;
	}
	if (last==1&&sum+1<=n) _a[++_cnt]=1,dfs(sum+2,1),--_cnt;
	for (int i=last;sum+i*2-3<=n;i++){
		if (i==1) continue;
		_a[++_cnt]=i,tot+=2;
		dfs(sum+i*2-2,i);
		--_cnt,tot-=2;
	}
}

int main(){
	n=read(),k=read(),scanf("%s",s+1);
	init(),tot=2,ans=1,dfs(0,1),printf("%d\n",ans);
}

Measured memory_bytes: 256
var
 n,x,i:longint;
 ans,now:int64;
 a:array[0..100001] of longint;
begin
 readln(n,x);
 for i:=1 to n do
  read(a[i]);
 for i:=1 to n do
  begin
   if now+a[i]<=x then now:=a[i]
    else 
     begin
      ans:=ans+now+a[i]-x;
      now:=a[i]-(now+a[i]-x);
     end;
  end;
 writeln(ans);
end.

Measured memory_bytes: 512
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <stack>
#include <cmath>
#include <list>
#include <iomanip>
#include <set>
#include <map>
#include <sstream>
#include <string.h>
#include <fstream>
#include <stdio.h>

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int, int> PII;
typedef vector<int> VI;

#define FOR(i,a,b) for(int (i)=(a);i<(b);++(i))
#define RFOR(i,a,b) for(int (i)=(a)-1;(i)>=(b);--(i))
#define MP make_pair
#define MOD 1000000007
#define INF 1000000001
#define PB push_back
#define eps 1e-5
#define X first
#define Y second

int n, a[100];
string s;

int main()
{
    cin >> n >> s;
    FOR (i,0,n) a[s[i]-'a']++;
    LL ans = 1;
    FOR (i,0,'z'-'a'+1) {
        ans = ans*(a[i]+1) % MOD;
    }
    
    cout << (ans+MOD-1)%MOD;
}

/*
 80000
 40694
 73594
 13614
 65544
 */


Measured memory_bytes: 512
N = int(input())
a = list(map(int,input().split()))
num = list(range(10**5+1))
val = [0]*(10**5+1)
dic = dict(zip(num,val))
for i in a:
    if i == 0:
        dic[i] += 1
        dic[i+1] += 1
    elif i == 10**5:
        dic[i-1] += 1
        dic[i] += 1
    else:
        dic[i-1] += 1
        dic[i] += 1
        dic[i+1] += 1
print(max(dic.values()))

Measured memory_bytes: 21620
#include <bits/stdc++.h>
const int INF=1e9,MOD=1e9+7;
const long long LINF=1e18;
using namespace std;
#define int long long
//template
//main
signed main(){
  int N;cin>>N;int n=N+N%2;
  std::vector<int> v(n,LINF);
  for(int i=0;i<N;i++)cin>>v[i];
  sort(v.begin(),v.end());
  if(v[N-1]<0&&N%2){
    int ans=0;
    for(int i=0;i<N-1;i++)ans+=v[i];
    ans*=-1;
    ans+=v[N-1];
    cout<<ans<<endl;
    return 0;
  }
  if(v[n-1]==LINF)v[n-1]=0;
  int ans=0;
  for(int i=0;i<N;i+=2)ans+=abs(v[i]+v[i+1]);
  cout<<ans<<endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(int i=0;i<(n);++i)
#define all(x) (x).begin(), (x).end()
#define PB(x) push_back(x)
#define MP(x,y) make_pair(x,y)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;

int a[12][12];
int r[12];


int main() {
    
    int n,m,x;
    cin >> n >> m >> x;
    vector<int> c(n);
    rep(i,n) {
        cin >> c[i];
        rep(j,m) {
            cin >> a[i][j];
        }
    }

    int ans = 100000000;
    //n個についてbit全探索
    //t[i]をtrue,falseで判断
    int sum=0;
    vector<int> t(n);
    for(int bit=0; bit <(1<<n); ++bit) {
        for(int i=0;i<n;i++) {
            if(bit & (1<<i))    t[i]=true;
            else    t[i]=false;
        }
        //ここから処理を書く
        rep(i,n) {
            if(t[i] == true) {
                sum+=c[i];
                rep(j,m) {
                    r[j]+=a[i][j];
                }
            }
        }
        rep(i,m) {
            if(r[i]<x) {
                break;
            }
            if(i == m-1) {
                ans = min(ans,sum);
            }
        }
        rep(i,m)    r[i] = 0;
        sum = 0;
    }


    if(ans == 100000000) cout<<-1<<endl;
    else    cout<< ans << endl;


 return 0;
}


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

int main(){
  int n;
  cin >> n;
  
  int sum = 0;
  int tmp = n;
  for(;;){
    sum += tmp%10;
    tmp /= 10;
    if(tmp==0) break;
  }
  
  if(n%sum==0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}

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

int main() {
  //N 団体数　
  int N;
  cin >> N ;
  int seki = 0;
     
// for 
    for (int i = 0 ; i < N ; i++) {
		int l,r;
      	cin >>l>>r;
      
      	for ( l ; l <= r  ; l++) {
          seki++;
//          cout << seki << l << endl;
        }
    }
      
// 出力
     cout << seki << endl;
     
    }
//　終了

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define rep(i,n) for(int i = 0; i < n; ++i)
#define rep1(i,n) for(int i = 1; i <= n; ++i)
using namespace std;
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(a > b){ a = b; return 1; } return 0; }
typedef long long ll;
using pl = pair<ll,ll>;
using pll = pair<pl,pl>;
int main()
{
  int t; cin >> t;
  vector<ll> ans;
  while(t-- > 0) {
    int n; cin >> n;
    vector<int> k(n),l(n),r(n);
    rep(i,n) cin >> k[i] >> l[i] >> r[i];
    vector<pll> a, b;
    ll res = 0;
    rep(i,n) {
      if(l[i] > r[i]) {
	a.push_back({{k[i] - 1, l[i]}, {r[i], l[i] - r[i]}});
      }
      else {
	b.push_back({{n - k[i] - 1, l[i]}, {r[i], r[i] - l[i]}});	
      }
    }
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    // for(auto val: a) cout << val.first.first << ":" << val.first.second << ":" << val.second.first << ":" << val.second.second << "\n";
    // for(auto val: b) cout << val.first.first << ":" << val.first.second << ":" << val.second.first << ":" << val.second.second << "\n";
    // cout << a.size() << ":" << b.size() << "\n";
    {
      int m = a.size();
      priority_queue<pair<ll,pl>> pq;
      int idx = m - 1;
      for (int i = m - 1; i >= 0; --i) {
	while(idx >= 0 && a[idx].first.first >= i) {
	  pq.push({a[idx].second.second, {a[idx].first.second, a[idx].second.first}});
	  idx--;
	}
	if( !pq.empty() ){
	  pair<ll,pl> p = pq.top(); pq.pop();
	  res += p.second.first;
	}
      }
      while(idx >= 0) {
	pq.push({a[idx].second.second, {a[idx].first.second, a[idx].second.first}});
	idx--;
      }      
      while( !pq.empty() ) {
	pair<ll,pl> p = pq.top(); pq.pop();
	res += p.second.second;
      }
    }
    {
      int m = b.size();
      priority_queue<pair<ll,pl>> pq;
      int idx = m - 1;
      for (int i = m - 1; i >= 0; --i) {
	while(idx >= 0 && b[idx].first.first >= i) {
	  pq.push({b[idx].second.second, {b[idx].first.second, b[idx].second.first}});
	  idx--;
	}
	if( !pq.empty() ){
	  pair<ll,pl> p = pq.top(); pq.pop();
	  res += p.second.second;
	}
      }
      while(idx >= 0) {
	pq.push({b[idx].second.second, {b[idx].first.second, b[idx].second.first}});
	idx--;
      }
      while( !pq.empty() ) {
	pair<ll,pl> p = pq.top(); pq.pop();
	res += p.second.first;
      }
    }    
    ans.push_back(res);
  }
  for(auto val: ans) cout << val << "\n";
  
  return 0;
}


Measured memory_bytes: 17240
#include<bits/stdc++.h>
#include<string.h>
 
typedef long long int ll;
 
using namespace std;
 
void SieveOfEratosthenes(int n,vector <int> &primes) 
{ 
    // Create a boolean array "prime[0..n]" and initialize 
    // all entries it as true. A value in prime[i] will 
    // finally be false if i is Not a prime, else true. 
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime)); 
  
    for (int p=2; p*p<=n; p++) 
    { 
        // If prime[p] is not changed, then it is a prime 
        if (prime[p] == true) 
        { 
            // Update all multiples of p greater than or  
            // equal to the square of it 
            // numbers which are multiple of p and are 
            // less than p^2 are already been marked.  
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
  
    // Print all prime numbers 
    for (int p=2; p<=n; p++) 
       if (prime[p]) 
          primes.push_back(p);
} 
 
ll max(ll a,ll b)
{
    if(a>b)
        return a;
    return b;
}
 
ll power(ll x, ll y,ll mod) 
{ 
    ll temp; 
    if( y == 0) 
        return 1; 
    temp = power(x, y/2,mod); 
    if (y%2 == 0) 
        return (temp*temp)%mod; 
    else
        return (((x*temp)%mod)*temp)%mod; 
} 
 
vector <set <int> > g;

 

int main()
{
    vector <vector <int> > v;
    vector <int> row(3);
    v.resize(3,row);
    for(int i=0;i<3;i++)
    {
        for(int j=0;j<3;j++)
            cin>>v[i][j];
    }
    int n;
    cin>>n;
    set <int> s;
    for(int i=0;i<n;i++)
    {
        int x;
        cin>>x;
        s.insert(x);
    }
    for(int i=0;i<3;i++)
        for(int j=0;j<3;j++)
            if(s.find(v[i][j])!=s.end())
                v[i][j]=0;
    bool test=0;
    for(int i=0;i<3;i++)
    {
        bool t=1;
        for(int j=0;j<3;j++)
            if(v[i][j]!=0)
            {
                t=0;
                break;
            }
        if(t)
        {
            test=1;
            break;
        }
    }
    if(test)
    {
        cout<<"Yes\n";
        return 0;
    }

    for(int i=0;i<3;i++)
    {
        bool t=1;
        for(int j=0;j<3;j++)
            if(v[j][i]!=0)
            {
                t=0;
                break;
            }
        if(t)
        {
            test=1;
            break;
        }
    }
    if(test)
    {
        cout<<"Yes\n";
        return 0;
    }

    if(v[0][0]==0&&v[1][1]==0&&v[2][2]==0)
    {
        cout<<"Yes\n";
        return 0;
    }

    if(v[0][2]==0&&v[1][1]==0&&v[2][0]==0)
    {
        cout<<"Yes\n";
        return 0;
    }

    cout<<"No\n";



    return 0;   
}
 
 


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

int32_t main() {
    string s, t;
    cin >> s >> t;

    int dp[t.length() + 1][s.length() + 1];

    for (int i = 0; i <= t.length(); ++i)
        for (int j = 0; j <= s.length(); ++j)
            dp[i][j] = 0;


    for (int i = 1; i <= t.length(); ++i) {
        for (int j = 1; j <= s.length(); ++j) {
            if (t[i - 1] == s[j - 1])   
                dp[i][j] = dp[i - 1][j - 1] + 1;
            else 
                dp[i][j] = max(dp[i][j - 1], dp[i - 1][j]);
        }
    }

    string ans = "";

    int i = t.length(), j = s.length();

    while (i > 0 and j > 0) {
        if (dp[i][j] == dp[i - 1][j]) {
            i--;
        }
        else if (dp[i][j] == dp[i][j - 1]) {
            j--;
        }
        else {
            i--;
            j--;
            ans += t[i];
        }
    }

    reverse(ans.begin(), ans.end());

    cout << ans << "\n";
} 

Measured memory_bytes: 70656
def main(A,N):
    A = [0] + A
    for a in range(N//2,0,-1):
        #print(inds[ind::ind+1])
        if sum(A[a::a]) %2== 0:
            A[a] = 0
        else:
            A[a] = 1
        
    res = [x for x in range(0,N+1) if A[x]]
    print(len(res))
    print(*res)

N = int(input())
A = [int(x) for x in input().split()]
    
main(A,N)


Measured memory_bytes: 14136
#include <iostream>
#include <string>
#include <sstream>
#include <utility>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <cmath>
#include <functional>
#include <chrono>
#include <cstring>
#include <bits/stdc++.h>

using namespace std;
typedef long long lint;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MM_PI		3.14159265358979323846

typedef vector<lint> vl;
typedef pair<lint,lint> pll;

#define mpr make_pair

lint gcd(lint a, lint b){

    if (a>b) swap(a, b);
    if (b%a == 0) return a;
    return gcd(b%a, a);
}
lint mod = 1e9+7;
lint pow(lint n){
    lint base = 2;
    lint cur = 1;
    while (n > 0){
        if (n%2) cur = cur*base%mod;
        n = n/2;
        base = base*base % mod;
    }
    return cur;
}

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

    lint n; cin>>n;
    vector<pll> sa(n);
    map<pll, lint> cnt;
    for (lint i =0; i<n; ++i){
        lint a, b;
        cin>>a>>b;
        if (a==0 && b==0){
            cnt[{0,0}]++;
        } else if (a!=0 && b!=0){
            if (a<0) {
                a=-a;
                b=-b;
            }
            lint g = gcd(abs(a), abs(b));
            cnt[{a/g, b/g}]++;
        } else {
            if (a==0) cnt[{0,1}]++;
            else cnt[{1,0}]++;
        }
    }


    lint ans00 = 1;
    if (cnt[{0,0}] == 0) ans00 = 0;
    else ans00 = cnt[{0,0}];

    cnt.erase({0,0});

    lint ans = 1;
    while(!cnt.empty()){
        pair<pll, lint> cur = *cnt.begin();
        cnt.erase(cnt.begin());
        pll curp = cur.first;
        pll rcurp = {curp.second, -curp.first};
        if (rcurp.first < 0) {
            rcurp = {-curp.second, curp.first};
        } else if (rcurp.first == 0) {
            rcurp = {0, 1};
        }

        if (cnt.find(rcurp) == cnt.end()) cnt[rcurp]=0;
        auto rcurit = cnt.find(rcurp);

        ans = ans * (pow(cur.second)-1 + pow(rcurit->second)-1 +1)%mod;

        cnt.erase(rcurit);

    }
    ans= (ans + mod -1)%mod;
    cout<<(ans + ans00)%mod;


}


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

typedef long long LL;

const int N=1000,M=30000,INF=(1<<30)-1;

int n,m,a[N+9],b[N+9];
int dp[M+9],ans;

int main(){
  scanf("%d%d",&m,&n);
  for (int i=1;i<=n;++i)
	scanf("%d%d",&a[i],&b[i]);
  for (int i=1;i<=M;++i) dp[i]=INF;
  for (int i=1;i<=n;++i)
	for (int j=a[i];j<=M;++j)
	  dp[j]=min(dp[j],dp[j-a[i]]+b[i]);
  ans=INF;
  for (int i=m;i<=M;++i) ans=min(ans,dp[i]);
  printf("%d\n",ans);
  return 0;
}

Measured memory_bytes: 384
import java.util.Scanner;
import java.util.LinkedList;

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

class IrohasObsession {
	
	int N;
	int K;
	int[] dislikeNums;
	
	IrohasObsession() {
		//input
		Scanner cin = new Scanner(System.in);
		this.N = cin.nextInt();
		this.K = cin.nextInt();
		this.dislikeNums = new int[K];
		for (int i = 0; i < K; i++) {
			dislikeNums[i] = cin.nextInt();
		}
	}
	
	void run() {
		int i = N;
		while (true) {
			if (!isContains(i)) {
				break;
			}
			i++;
		}
		System.out.println(i);
	}
	
	boolean isContains(int num) {
		char[] tmpNums = String.valueOf(num).toCharArray();
		LinkedList<Integer> list = new LinkedList<Integer>();
		for (int i = 0; i < tmpNums.length; i++) {
			list.add(Integer.valueOf(String.valueOf(tmpNums[i])));
		}
		for (int i = 0; i < K; i++) {
			if (list.contains(this.dislikeNums[i])) {
				return true;
			}
		}
		return false;
	}
	
}


Measured memory_bytes: 26300
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
const int INF{int(1e9)};

int main()
{
  int n;	cin >> n;
  int x = n%10;
  if (x== 0 || x==1 || x==6 || x==8)  cout << "pon" << endl;
  else if (x==3) cout << "bon" << endl;
  else cout << "hon" << endl;
}

Measured memory_bytes: 3624
#include <iostream>
#include <bitset>
#include <iomanip>
#include <string>
#include <vector>
#include <cmath>
#include <queue>
#include <algorithm>

using namespace std;

int main()
{
	long long h, w;
	long long ans;

	cin >> h >> w;

	double H = h, W = w;

	if (h == 1 || w == 1)
		ans = 1;
	else if (h % 2 == 1 && w % 2 == 1)
		ans = (long long)((H*W) / 2) + 1;
	else
		ans = (long long)((H*W) / 2);


	cout << ans << endl;
}

Measured memory_bytes: 256
from itertools import product

N = int(input())

cnt = 0
for i in range(3, len(str(N))+1):
  for p in product(["7", "5", "3"], repeat = i):
    if "7" in p and "5" in p and "3" in p:
      p = int("".join(p))
      if p <= N:
        cnt += 1
print(cnt)

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

int main(){
	int a=1,b=1,i,l;
	while((cin>>a>>b)&&(a!=0||b!=0)){
			for(i=1;i<=a;i++){
				if(i%2==1){
					if(b%2==0){
						for(l=1;l<=b/2;l++){
							cout<<"#.";
						}
						cout<<endl;
					}
					else{
						cout<<"#";
						for(l=1;l<=(b-1)/2;l++){
							cout<<".#";
						}
						cout<<endl;
					}
				}
				else{
					if(b%2==0){
						for(l=1;l<=b/2;l++){
							cout<<".#";
						}
						cout<<endl;
					}
					else{
						cout<<".";
						for(l=1;l<=(b-1)/2;l++){
							cout<<"#.";
						}
						cout<<endl;
					}
				}
			}
			cout<<endl;		
	}
}

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

int main()
{
    string s;
    cin >> s;
    int ans = 0, len = s.length();

    int s_stack = 0;
    for (int i = 0; i < len; ++i) {
        if (s[i] == 'S') {
            if (i + 1 < len && s[i + 1] == 'T') {
                ans++;
                i++;
            } else {
                s_stack++;
            }
        } else if (s_stack) {
            ans++;
            s_stack--;
        }
    }

    cout << len - 2 * ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include<cmath>
#include<cstdio>
#include<vector>
using namespace std;
struct node{
    int u, v, w;
    node(int _u, int _v, int _w):u(_u), v(_v), w(_w){}
};
vector<node>ans;
inline int lowbit(int x) {
    return x & -x;
}
int main() {
    int L;
    scanf("%d", &L);
    for(int i=19;i>1;i--) {
        ans.push_back(node(i, i+1, 0));
        ans.push_back(node(i, i+1, (1<<(20-i-1))));
    }
    while( L ) {
        int p = int(log2(lowbit(L)));
        if( p == 19 ) {
            ans.push_back(node(1, 2, 0));
            ans.push_back(node(1, 2, 1<<18));
        }
        else ans.push_back(node(1, 20-p, L^lowbit(L)));
        L ^= lowbit(L);
    }
    printf("%d %d\n", 20, ans.size());
    for(int i=0;i<ans.size();i++)
        printf("%d %d %d\n", ans[i].u, ans[i].v, ans[i].w);
} 


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
using namespace std;
int main(void){
  while(1){
    int w,c=1150;
    cin >> w;
    if(w == -1)break;
    w -= 10;
    c += max(0,min(w,10)) * 125;
    w -= 10;
    c += max(0,min(w,10)) * 140;
    w -= 10;
    c += max(0,w) * 160;
    cout << 4280 - c << endl;
  }
}

Measured memory_bytes: 1160
import           Debug.Trace

main :: IO ()
main = do
    [n, k] <- map read . words <$> getLine :: IO [Int]
    print $ solve n k

solve n k = foldr (\b acc -> acc + itr b) 0 bs - if k == 0 then n else 0
    where
      bs = [1..n]
      itr b = let (p, r) = n `divMod` b in
                  p * max 0 (b - k) + max 0 (r - k + 1)


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

int main() {
    int N,M; cin >> N >> M;
    vector<vector<int>> res(N,vector<int>(2,0));
    for(int i = 0; i < M; i++) {
        int p;
        string s;
        cin >> p >> s;
        if(s == "AC") 
            res.at(p-1).at(0) = 1;
        else if(res.at(p-1).at(0) != 1)
            res.at(p-1).at(1)++;
    }
    int ac = 0;
    int wa = 0;
    for(int i = 0; i < N; i++) {
        ac += res[i][0];
        if(res.at(i).at(0) == 1)
        wa += res[i][1];
    }
    cout << ac << " " << wa << endl;
}

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

using namespace std;

int main(){
    int n, res = 0;
    cin >> n;
    long long ar[n];
    for(int i = 0; i < n; i++){
        cin >> ar[i];
    }
    unordered_map<long long, int> mp;
    for(int i = 0; i < n; i++){
        mp[i - ar[i]]++;
    }
    long long sol = 0;
    for(int i = 0; i < n; i++){
        sol += mp[ar[i] + i];
    }
    cout << sol << '\n';
}


Measured memory_bytes: 20080
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<bool> vb;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define INT(str) stoi((str), 0)
#define INTB(str) stoi((str), 0, 2) // 2進数の文字列を int に
//cout << fixed << setprecision(15);

int main() {
  int a, b;
  cin >> a >> b;
  if (b < a) {
    int t = a;
    a = b;
    b = t;
  }
  cout << string(b, 48 + a) << endl;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define F first
#define S second

const int mx=200010;
const ll mod=1e9+7;

int main(){
  int n;
  string s;
  cin >> n >> s;
  int ans=0;
  rep(i,n-2){
    if(s.substr(i, 3)=="ABC"){ans++;}
  }

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


Measured memory_bytes: 256
import sys
from collections import deque

sys.setrecursionlimit(4100000)


def inputs(num_of_input):
    ins = [input() for i in range(num_of_input)]
    return ins


def solve(inputs):
    W = inputs
    appeared = set()
    prev = ''
    for w in W:
        if w in appeared:
            return "No"
        appeared.add(w)
        if not (prev == '' or w[0] == prev):
            return "No"
        prev = w[-1]
    return "Yes"


def string_to_int(string):
    return list(map(int, string.split()))


if __name__ == "__main__":
    N = int(input())
    ret = solve(inputs(N))
    print(ret)

Measured memory_bytes: 3316
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
ll n;
ll ans;
int main(void){
    cin>>n;
    n-=599;
    while(n>0){
        ans++;
        n-=200;
    }
    cout<<8-ans<<endl;
    
}


Measured memory_bytes: 3612
#!/usr/bin/perl
#= CPAN mocules =====================================================#
require 5.8.8;			# Perl 5.8.8以降
use strict;				# strictモード
use warnings;			# 警告有効
use utf8;				# UTF8モード ON

#= Global values ====================================================#
#= Local routines ===================================================#
sub main(){
	my $input = <>;
	chomp $input;

	my @in = split(/ /, $input);
	if ($in[0] eq "H"){
		print $in[1];
	}else{
		if ($in[1] eq "H"){
			print "D";
		}else{
			print "H";
		}
	}

	return 0;
}

#----- 実行 -----#
exit( main() );




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

#define rep(i,n) for(int i=0;i<(n);i++)
#define rep2(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define mod 1000000007
#define INF 2000000000
typedef long long ll;
bool compare(pair<int, int> a, pair<int, int> b) {
    if(a.first != b.first){
        return a.first < b.first;
        
    }else{
        return a.second < b.second;
    }
}



int main() {
    int ans = 0;
    string S,T;

    cin >> S >> T;
    rep(i,3){
        if(S[i] == T[i]){
            ans++;
        }
    }
    cout << ans << endl;
    
    
    return 0;
    

}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string.h>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<cmath>
#include<random>
#include<set>
#include<queue>

using namespace std;

long long dp[3][100100] = {};
const long long INF = 1LL << 60;
#define MOD 1000000007
#define Int int64_t
#define PI 3.14159265358979
#define dump(a) cout << a << endl; 

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

/**
* @fn
* 最大値を取ります.Vector<int>を渡すこと.
*/
long long int imax(vector<int> a) {
	int MAX = -10000000;
	for (int i = 0; i < a.size(); i++) {
		if (MAX < a.at(i)) MAX = a.at(i);
	}
	return MAX;
}

/**
* @fn
* 最小値を取ります.Vector<int>を渡すこと.
*/
long long int imin(vector<int> a) {
	int MIN = 1000000000;
	for (int i = 0; i < a.size(); i++) {
		if (MIN > a.at(i)) MIN = a.at(i);
	}
	return MIN;
}

/**
* @fn
* 自然数について、桁数を求める
*/
Int getDigit(Int num) {
	return (Int)(log10(num)) + 1;
}


int get2Digit(Int num) {
	int cnt = 0;
	while (num > 0) {
		if (num % 2 != 0) {
			return cnt;
		}
		cnt++;
		num /= 2;
	}
}

long long int absmin(vector<int> a, long long int b) {
	int mini = 100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (mini > abs(a.at(i) - b)) {
			mini = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}


long long int absmax(vector<int> a, long long int b) {
	int max = -100000000;
	int d = 0;
	for (int i = 0; i < a.size(); i++) {
		if (max < abs(a.at(i) - b)) {
			max = abs(a.at(i) - b);
			d = i;
		}
	}
	return d;
}

int gcd(int a, int b)
{
	if (a < b) swap(a, b);
	if (b < 1) return -1;
	if (a % b == 0) return b;
	return gcd(b, a % b);
}

void haerobatya(int start, int end, char level) {
	if (start > end) swap(start, end);
	for (int i = start; i <= end; i++) {
		if (i < 100) {
			cout << "https://atcoder.jp/contests/abc0" << i << "/tasks/abc0" << i << "_" << level << endl;
		}
		else {
			cout << "https://atcoder.jp/contests/abc" << i << "/tasks/abc" << i << "_" << level << endl;
		}
	}
}

long long int cntmod(long long int warareru, long long int mod) {
	long long int i = 0;
	for (i = 0; true; i++) {
		if (warareru % mod == 0 && warareru >= mod) {
			warareru /= mod;
		}
		else {
			return i;
		}
	}
}

void ansYes(bool a) {
	if (a == true) cout << "Yes" << endl;
	else cout << "No" << endl;
}

void ansYES(bool a) {
	if (a == true) cout << "YES" << endl;
	else cout << "NO" << endl;
}


Int euclidean_gcd(Int a, Int b) {
	while (true) {
		if (a < b) swap(a, b);
		if (!b) break;
		a %= b;
	}
	return a;
}

typedef pair<int, int> pai;


//ここまでライブラリ
//ここから本文

int main() {
	string a, b, c;
	cin >> a >> b >> c;
	cout << a.at(0) << b.at(1) << c.at(2) << endl;
}


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

typedef long long ll;

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

    int h,n;
    cin >> h >> n;
    vector<int> a(n);
    int sum = 0;
    for(int i=0;i<n;i++){
        cin >> a[i];
        sum += a[i];
    }
    if(sum>=h) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 640
#include<cstdio>
using namespace std;
inline int read()
{
	int X=0;
	char ch=getchar();
	while(ch<'0'||ch>'9')
		ch=getchar();
	while(ch>='0'&&ch<='9')
	{
		X=(X<<1)+(X<<3)+ch-'0';
		ch=getchar();
	}
	return X;
}
int main()
{
	int a,b;
	a=read();
	b=read();
	a%=500;
	if(b>=a)
		printf("Yes");
	else
		printf("No");
	return 0;
}

Measured memory_bytes: 128
//بِسْمِ ٱللَّٰهِ ٱلرَّحْمَٰنِ ٱلرَّحِيمِ
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef double db;

#define endl "\n"

const int MOD = 1000000007;


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

    string x;
	cin >> x;
    int a = x.length();
	
	

        cout << x[0] << a - 2<< x[a-1] << endl;
	
    return 0;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n)for(int i=0;i<(n);i++)
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
using ll = long long;
using P = pair<int, int>;
using Graph = vector<vector<int>>;

int main(){
    int h, w, d; cin >> h >> w >> d;
    vector<vector<int>> a(h, vector<int>(w));
    vector<P> place(h*w+1); 
    rep(i,h)rep(j,w) {
        cin >> a[i][j];
        place[a[i][j]] = P(i,j);
    } 
    vector<int> mp(h*w+1, 0);
    for(int i = 1; i <= h*w; i++){
        if(i <= d) mp[i] = 0;
        else {
            int x1 = place[i].first;
            int y1 = place[i].second;
            int x2 = place[i-d].first;
            int y2 = place[i-d].second;
            mp[i] = mp[i-d] + abs(x1 - x2) + abs(y1 - y2);
        }
    }
    int q; cin >> q;
    rep(i,q){
        int l, r; cin >> l >> r;
        cout << mp[r] - mp[l] << endl;
    }
    return 0;
}

Measured memory_bytes: 2560
#include<set>
#include <string>
#include <iostream>
#include <cstdlib>
#include <queue>
using namespace std;
typedef set<string> dictionary;
dictionary d;
queue<pair<string, string> > Q;
int n;
int main()
{
  cin >> n;
  for (int i = 0; i < n; i++) {
    string str, word;
    cin >> str >> word;
    Q.push(make_pair(str, word));
  }

  for (int i = 0; i < n; i++) {
    pair<string, string> p = Q.front();
    Q.pop();
    if (p.first == "insert"){
      d.insert(p.second);
    } else if (p.first == "find") {
      if (d.count(p.second) > 0) {
        cout << "yes" << endl;
      }else {
        cout << "no" << endl;
      }
    }
  }
}


Measured memory_bytes: 119340
#include <iostream>

using namespace std;

int main() {
	int a,b,i;
	int aa,bb;
	int time=0,sa;
	while(1){
		cin >> a;
		if(a==0) break;
		cin >> b;
		for(i=0;i<b;i++){
			cin >> aa >> bb;
			sa=bb-aa;
			time=time+sa;
		}
		if(time>=a){
			cout << "OK" << endl;
		}else if(time<a){
			cout << a-time << endl;
		} 
		
		time=0;
}
	return 0;
}

Measured memory_bytes: 3092
#pragma GCC optimize ("O3")
#pragma GCC target ("avx")
//#include<bits/stdc++.h>
#include<cstdio>
#include<algorithm>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

const int cm = 1 << 17;
char cn[cm], * ci = cn + cm, ct;
inline char getcha() {
	if (ci - cn == cm) { fread_unlocked(cn, 1, cm, stdin); ci = cn; }
	return *ci++;
}
inline int getint() {
	int A = 0;
	if (ci - cn + 16 > cm) while ((ct = getcha()) >= '0') A = A * 10 + ct - '0';
	else while ((ct = *ci++) >= '0') A = A * 10 + ct - '0';
	return A;
}

const int dm = 1 << 19;
char dn[dm], * di = dn;
inline void putint(int X) {
	int keta = 0;
	char C[4];
	while (X) {
		*(C + keta) = '0' + X % 10;
		X /= 10;
		keta++;
	}
	for (int i = keta - 1; i >= 0; i--)* di++ = (*(C + i));
	*di++ = '\n';
}

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


	int N = getint(), M = getint(), L = getint();
	int C[300][300];
	rep(j, N) rep(i, j) C[i][j] = 1e9 + 1;
	rep(i, M) {
		int a = getint(), b = getint(), c = getint();
		C[--a][--b] = c;
		C[b][a] = c;
	}

	rep(k, N) {
		auto Ck = C[k];
		rep(i, k) {
			auto Ci = C[i];
			auto Cik = Ci[k];
			for (int j = i + 1; j < k; j++) {
				chmin(Ci[j], Cik + C[j][k]);
			}
			for (int j = k + 1; j < N; j++) {
				chmin(Ci[j], Cik + Ck[j]);
			}
		}
		for (int i = k + 1; i < N; i++) {
			auto Ci = C[i];
			auto Cki = Ck[i];
			for (int j = i + 1; j < N; j++) {
				chmin(Ci[j], Cki + Ck[j]);
			}
		}
	}

	rep(j, N) rep(i, j) {
		C[i][j] = (C[i][j] <= L) ? 1 : 1e9;
	}

	rep(k, N) {
		auto Ck = C[k];
		rep(i, k) {
			auto Ci = C[i];
			auto Cik = Ci[k];
			for (int j = i + 1; j < k; j++) {
				chmin(Ci[j], Cik + C[j][k]);
			}
			for (int j = k + 1; j < N; j++) {
				chmin(Ci[j], Cik + Ck[j]);
			}
		}
		for (int i = k + 1; i < N; i++) {
			auto Ci = C[i];
			auto Cki = Ck[i];
			for (int j = i + 1; j < N; j++) {
				chmin(Ci[j], Cki + Ck[j]);
			}
		}
	}

	int Q = getint();
	rep(i, Q) {
		int s = getint(), t = getint();
		if (--s > --t) swap(s, t);
		if (C[s][t] == 1) {
			*di++ = '0';
			*di++ = '\n';
		}
		else if (C[s][t] < 1e9) putint(C[s][t] - 1);
		else {
			*di++ = '-';
			*di++ = '1';
			*di++ = '\n';
		}
	}

	fwrite(dn, 1, di - dn, stdout);

	Would you please return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
//const int N = 1000000;
const ll mod = 1000000007;
//using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int dh[8] = {0, 0, 1, 1, 1, -1, -1, -1};
const int dw[8] = {1, -1, 0, 1, -1, 0, 1, -1};
  
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * (B / gcd(A, B));
}
using Edge = pair<int,int>;
using Graph = vector<vector<Edge>>;
Graph G;
  
/*------------------------------------------------------------------*/

int main(){
    int n; cin >> n;
    string s; cin >> s;
    int l_count = 0, r_count = 0;
    rep(i, n){
        if(s[i] == '(') l_count++;
        else if(s[i] == ')'){
            if(l_count == 0) r_count++;
            else if(l_count > 0) l_count--;
        }
    }
    //cout << l_count << " " << r_count << endl;
    rep(i, l_count) s += ')';
    rep(i, r_count) s = '(' + s;
    cout << s << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using PII = pair<int, int>;
#define FI(i,a,b) for(int i=(a);i<=(b);++i)
#define FD(i,b,a) for(int i=(b);i>=(a);--i)
#define DEBUG(x) cerr << #x << ": " << (x) << endl;
constexpr int inv(LL x, int m) { return x > m ? inv(x % m, m) : x > 1 ? inv(m % x, m) * (m - m / x) % m : x; }
constexpr int mpow(LL a, LL k, int m) { int r(1); for (a %= m; k; k >>= 1, a = a * a % m) if (k & 1)r = r * a % m; return r; }

int main() {
    LL a, b, c;
    cin >> a >> b >> c;
    cout << b + min(a + b + 1, c) << endl;
}


Measured memory_bytes: 256
passengers, bus_size, time_lim = map(int, input().split())
pass_list = [int(input()) for passenger in range(passengers)]
pass_list.sort()
front = 0
now = 0
cnt = 0
ans = 0
for psngr_lst in pass_list:
    if cnt == 0:
        front = psngr_lst
        now = psngr_lst
        cnt += 1
    elif cnt == bus_size:
        front = psngr_lst
        now = psngr_lst
        cnt = 1
        ans += 1
    elif now - front <= time_lim:
        if psngr_lst - front <= time_lim:
            now = psngr_lst
            cnt += 1
        else:
            front = psngr_lst
            now = psngr_lst
            cnt = 1
            ans += 1
if cnt:
    ans += 1
print(ans)
        

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


#define li          long long int
#define rep(i,to)   for(li i=0;i<((li)(to));i++)
#define repp(i,start,to)    for(li i=(li)(start);i<((li)(to));i++)
#define pb          push_back
#define sz(v)       ((li)(v).size())
#define bgn(v)      ((v).begin())
#define eend(v)     ((v).end())
#define allof(v)    (v).begin(), (v).end()
#define dodp(v,n)       memset(v,(li)n,sizeof(v))
#define bit(n)      (1ll<<(li)(n))
#define mp(a,b)     make_pair(a,b)
#define rin rep(i,n)
#define EPS 1e-12
#define ETOL 1e-8
#define MOD 1000000007
typedef pair<li, li> PI;

#define INF bit(60)

#define DBGP 1


#define idp if(DBGP)
#define F first
#define S second
#define p2(a,b)     idp cout<<a<<"\t"<<b<<endl
#define p3(a,b,c)       idp cout<<a<<"\t"<<b<<"\t"<<c<<endl
#define p4(a,b,c,d)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<endl
#define p5(a,b,c,d,e)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<endl
#define p6(a,b,c,d,e,f)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<endl
#define p7(a,b,c,d,e,f,g)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<endl
#define p8(a,b,c,d,e,f,g,h)     idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<endl
#define p9(a,b,c,d,e,f,g,h,i)       idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<endl
#define p10(a,b,c,d,e,f,g,h,i,j)        idp cout<<a<<"\t"<<b<<"\t"<<c<<"\t"<<d<<"\t"<<e<<"\t"<<f<<"\t"<<g<<"\t"<<h<<"\t"<<i<<"\t"<<j<<endl
#define foreach(it,v)   for(__typeof((v).begin()) it=(v).begin(); it!=(v).end(); ++it)
#define p2p(x)      idp p2((x).F, (x).S)
#define dump(x,n)   idp{rep(i,n){cout<<x[i]<<" ";}puts("");}
#define dump2(x,n)  idp{rep(i,n){cout<<"["<<x[i].F<<" , "<<x[i].S<<"] ";}puts("");}
#define dumpi(x)    idp{foreach(it, x){cout<<(*it)<<" ";}puts("");}
#define dumpi2(x)   idp{foreach(it, x){cout<<"["<<(it)->F<<" , "<<(it)->S<<"] ";}puts("");}

#define read2d(a,w,h)   rep(i,h)rep(j,w)cin>>a[i][j]
#define dump2d(a,w,h)   rep(i,h){rep(j,w)cout<<a[i][j]<<" ";puts("");}

typedef pair<li, li> PI;



int main() {
    li a, v;
    li b, w;
    cin >> a >> v;
    cin >> b >> w;
    li t;
    cin >> t;

    li d = abs(a - b);
    if (v <= w) {
        puts("NO");
        return 0;
    }

    li dd = (v - w) * t;
    cout << (dd >= d ? "YES" : "NO") << endl;

    return 0;
}

Measured memory_bytes: 3604
#include<bits/stdc++.h>
#define ll long long int
#define M 1000000007
#define mod 998244353
#define mp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define pi pair<ll,ll>
using namespace std;
const ll N=100010;

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

    ll n,k;
    cin>>n>>k;
    ll ar[n];
    ll dp[n];
    for(ll i=0;i<n;++i){cin>>ar[i];dp[i]=INT_MAX;}
    dp[0]=0;
    for(ll i=0;i<n;++i)
    {
        for(ll j=1;j<=k;++j)
        {
            if(i+j<n)
            {
                dp[i+j]=min(dp[i+j],dp[i]+abs(ar[i]-ar[i+j]));
            }
        }
    }
    cout<<dp[n-1];

    return (0);
}


Measured memory_bytes: 1792
#include<stdio.h>
int main(void){
  int x=0,y=0,z=0,N,Y,total,i,j,k;
  scanf("%d %d",&N,&Y);

  for(i=0;i<=N;i++){
    for(j=0;j+i<=N;j++){
      k=N-i-j;
      total=10000*i+5000*j+1000*k;
      if(total==Y){
          x=i;
          y=j;
          z=k;
        }
    }
  }
  if(x+y+z==0) printf("-1 -1 -1\n");
  else printf("%d %d %d\n",x,y,z);
  return 0;
}


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

int main(){
    int N;
    cin >> N;
    int a[N];
    for(int i=0; i<N; i++){
        cin >> a[i];
    }
    
    int target = 1;
    for(int i=0; i<N; i++){
        if(target == a[i]){
            target += 1;
        }
    }

    int count = N - (target-1);
    if(target == 1){
        cout << -1 << endl;
    }else{
        cout << count << endl;
    }
    return 0;
    
}

Measured memory_bytes: 4400
#include <bits/stdc++.h>
#define int long long
const int INF = 1e18L + 5;
#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++)
using namespace std;

signed main(){

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

    string s, t;
    cin >> s >> t;
    int cnt = 0;
    rep(i,3) {
        if (s[i] == t[i]) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int K,N;
  cin>>K>>N;
  vector<int> A(N);
  for(int i=0;i<N;i++){
    cin>>A[i];
  }
  sort(A.begin(),A.end());
  int ma=0;
  for(int i=1;i<N;i++){
    int d=0;
    d=A[i]-A[i-1];
    if(d>ma){
      ma=d;
    }
  }
  if(A[0]+K-A[N-1]>ma){
    ma=A[0]+K-A[N-1];
  }
  cout<<K-ma<<endl;
}

Measured memory_bytes: 4036
using System;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;
using System.Collections.Generic;
using System.Diagnostics;
using System.Numerics;
using Enu = System.Linq.Enumerable;

public class Program
{
    public void Solve()
    {
        int A = Reader.Int(), B = Reader.Int();
        var gridA = Reader.StringArray(A);
        var gridB = Reader.StringArray(B);

        for (int sr = 0; sr + B <= A; sr++)
            for (int sc = 0; sc + B <= A; sc++)
            {
                bool ok = true;
                for (int dr = 0; dr < B; dr++)
                    for (int dc = 0; dc < B; dc++)
                        if (gridA[sr + dr][sc + dc] != gridB[dr][dc])
                        {
                            ok = false;
                            break;
                        }
                if (ok) { Console.WriteLine("Yes"); return; }
            }

        Console.WriteLine("No");
    }
}


class Entry { static void Main() { new Program().Solve(); } }
class Reader
{
    static TextReader reader = Console.In;
    static readonly char[] separator = { ' ' };
    static readonly StringSplitOptions op = StringSplitOptions.RemoveEmptyEntries;
    static string[] A = new string[0];
    static int i;
    static void Init() { A = new string[0]; }
    public static void Set(TextReader r) { reader = r; Init(); }
    public static void Set(string file) { reader = new StreamReader(file); Init(); }
    public static bool HasNext() { return CheckNext(); }
    public static string String() { return Next(); }
    public static int Int() { return int.Parse(Next()); }
    public static long Long() { return long.Parse(Next()); }
    public static double Double() { return double.Parse(Next()); }
    public static int[] IntLine() { return Array.ConvertAll(Split(Line()), int.Parse); }
    public static int[] IntArray(int N) { return Range(N, Int); }
    public static int[][] IntTable(int H) { return Range(H, IntLine); }
    public static string[] StringArray(int N) { return Range(N, Next); }
    public static string[][] StringTable(int N) { return Range(N, () => Split(Line())); }
    public static string Line() { return reader.ReadLine().Trim(); }
    public static T[] Range<T>(int N, Func<T> f) { var r = new T[N]; for (int i = 0; i < N; r[i++] = f()) ; return r; }
    static string[] Split(string s) { return s.Split(separator, op); }
    static string Next() { CheckNext(); return A[i++]; }
    static bool CheckNext()
    {
        if (i < A.Length) return true;
        string line = reader.ReadLine();
        if (line == null) return false;
        if (line == "") return CheckNext();
        A = Split(line);
        i = 0;
        return true;
    }
}

Measured memory_bytes: 13140
/**
 *    author:  otera    
**/
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

//#define int long long
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cerr << #x << " = " << (x) << 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 solve() {
	int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;
    int x = tx - sx, y = ty - sy;
    rep(i, x) {
        cout << 'R';
    }
    rep(i, y) {
        cout << 'U';
    }
    rep(i, x) {
        cout << 'L';
    }
    rep(i, y) {
        cout << 'D';
    }
    cout << 'D';
    rep(i, x + 1) {
        cout << 'R';
    }
    rep(i, y + 1) {
        cout << 'U';
    }
    cout << "LU";
    rep(i, x + 1) {
        cout << 'L';
    }
    rep(i, y + 1) {
        cout << 'D';
    }
    cout << 'R' << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//int t; cin >> t; rep(i, t)solve();
	solve();
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>


int main(){


	int n,a=0;

	scanf("%d",&n);

	a=n%10;

	if(a==2||a==4||a==5||a==7||a==9)

		printf("hon");

	if(a==0||a==1||a==6||a==8)
		printf("pon");

	if(a==3)
		printf("bon");

	return 0;
}


Measured memory_bytes: 1736
from sys import stdin
import sys
import math
from functools import reduce
import functools
import itertools
from collections import deque,Counter,defaultdict
from operator import mul
import copy
# ! /usr/bin/env python
# -*- coding: utf-8 -*-
import heapq
sys.setrecursionlimit(10**6)
# INF =  float("inf")
INF = 10**18
import bisect
import statistics
mod = 10**9+7
# mod = 998244353



N = int(input())

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

A = sorted(A, reverse=True)

ans = A[0]
for i in range(N-2):
    ans += A[i//2+1]

print(ans)














Measured memory_bytes: 110252
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
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;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
int main(){
    int n;cin >> n;
    vi a(n);
    rep(i,n) cin >> a[i];
    int pc=0,mc=0;
    deque<int> P,M;
    rep(i,n){
        if(a[i]>=0){
            pc++;
            P.push_back(a[i]);
        }
        else{
            mc++;
            M.push_back(a[i]);
        }
    }
    if(pc==n){
        sort(a.rbegin(),a.rend());
        int mn=a[n-1];
        int mn2=mn;
        int mx=a[0];
        int mx2=mx;
        for(int i=1;i<n-1;i++){
            mn2-=a[i];
        }
        mx2-=mn2;
        cout << mx2 << endl;
        for(int i=1;i<n-1;i++){
            cout << mn << " " << a[i] << endl;
            mn-=a[i];
        }
        cout << mx << " " << mn << endl;
    }
    else if(pc==0){
        sort(a.rbegin(),a.rend());
        int mx=a[0]-a[n-1];
        for(int i=1;i<n-1;i++) mx-=a[i];
        cout << mx << endl;
        cout << a[0] << " " << a[n-1] << endl;
        int mx2=a[0]-a[n-1];
        for(int i=1;i<n-1;i++){
            cout << mx2 << " " << a[i] << endl;
            mx2-=a[i];
        }
    }
    else{
        int ans=0;
        deque<int> cP=P;
        deque<int> cM=M;
        while(cP.size()){
            ans+=cP.front();
            cP.pop_front();
        }
        while(cM.size()){
            ans-=cM.front();
            cM.pop_front();
        }
        cout << ans << endl;
        int sum=M.front();
        M.pop_front();
        mc--;
        while(pc>0&&mc>=0){
            if(pc==1){
                cout << P.front() << " " << sum << endl;
                sum=P.front()-sum;
                P.pop_front();
                pc--;
                while(mc>0){
                    cout << sum << " " << M.front() << endl;
                    sum-=M.front();
                    M.pop_front();
                    mc--;
                }
            }
            else{
                cout << sum << " " << P.front() << endl;
                sum-=P.front();
                P.pop_front();
                pc--;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 3072