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

#define ll long long int
#define ld long double
#define u128 __int128 
#define ff first
#define ss second
#define pb push_back
#define PI 3.141592653589793

#define MOD 1000000007
#define N 10100
#define M 1000010

int main() 
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(10);

	int n;
	cin >> n;
	int a[n];
	ll sum = 0;
	for (int i = 0; i < n; ++i)
	{
		cin >> a[i];
		sum += a[i];
	}

	int f = 1;
	for (int i = 0; i < n; ++i)
	{
		if(2 * a[i] >= sum)
		{
			f = 0;
		}
	}
	if(f)
		cout << "Yes\n";
	else
		cout << "No\n";
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int a[105];
int main(){
	int n,m,sum=0;
	cin>>n>>m;
	for(int i=0;i<n;i++) cin>>a[i],sum+=a[i];
	sort(a,a+n);
	int s=0;
	for(int i=n-1;i>=0;i--){
		if((long long)a[i]*4*m>=sum) s++;
	}
	cout<<(s>=m?"Yes":"No");
	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() {
  int a;
  cin >> a;
  
  cout << a + a * a + a * a * a << endl;
  
  return 0;
}


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

int main(){
    int N;
    int a[110000];
    cin >> N;
    for(int i = 0; i < N; i++) cin >> a[i];

    int numOdd = 0;
    for(int i = 0; i < N; i++){
        if(a[i] % 2 == 1) numOdd++;
    }
    if(numOdd % 2 == 0) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 640
N = int(input())
A = list(map(int, input().split()))
A1 = [0] * (10 ** 5 + 10)
A2 = [0] * (10 ** 5 + 10)

for n, a in enumerate(A):
    if n % 2 == 0:
        A1[a] += 1
    else:
        A2[a] += 1

c1 = max(A1)
c2 = max(A2)

s1 = A1.index(c1)
s2 = A2.index(c2)

if s1 != s2:
    print(N - c1 - c2)
else:
    A1.sort()
    A2.sort()
    print(N - max(A1[-1] + A2[-2], A1[-2] + A2[-1]))

Measured memory_bytes: 14268
import sys
input=sys.stdin.readline
n,k=map(int,input().split())
a=[int(input()) for i in range(n)]
a.sort()
res=float("INF")
for i in range(0,n-k+1):
    b=a[i+k-1]-a[i]
    if res>b:
        res=b
print(res)

Measured memory_bytes: 7492
#include <stdio.h>

int rst[32],s;

void solve(int rem,int left){
  int i;

  if(rem==0){
    for(i=0;i<s;i++){
      if(i!=0) printf(" ");
      printf("%d",rst[i]);
    }
    printf("\n");
  }
  for(i=rem;i>0;i--){
    if(i<=left){
      rst[s++] = i;
      solve(rem-i,i);
      s--;
    }
  }
}

int main(void){
  int n;

  while(1){
    scanf("%d",&n);
    if(!n) break;
    s = 0;
    solve(n,n);
  }

  return 0;
}

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

int main(){
    string s;
    int a[3];
    int b=0;
    for (int i=0;i<3;i++){
        a[i] = 0;
    }
    int ans=0;
    cin >> s; 
    for(int i=0;i<3;i++){
        if(s[i]=='R'){
            a[b]++;
        }else{
            b++;
        }
        
    }
    ans = max(a[0],max(a[1],a[2]));
    cout << ans;
}

Measured memory_bytes: 3584
#include<stdio.h>
#include<stdlib.h>
int R=1,C=1,HB[2000010]={0};
int N[2000010]={2100000000};
void H(int a){
  int i=C++;
  for(N[R]=a;a>N[HB[i/2]];i/=2)HB[i]=HB[i/2];
  HB[i]=R++;
}
int h(){
  int rt=HB[1],nt=1,i=0,k=HB[--C];
  while(nt-i){
    HB[i=nt]=k;
    if(i*2  <C&&N[  k  ]<N[HB[i*2  ]])HB[i]=HB[nt=i*2  ];
    if(i*2+1<C&&N[HB[nt]]<N[HB[i*2+1]])HB[i]=HB[nt=i*2+1];
  }
  return rt;
}
void prih(){
  int i,j=0;
  for(i=0;i<C;i++){
    if(i==1<<j){
      printf("\n");
      j++;
    }
    printf("%d ",N[HB[i]]);
  }
  printf("\n");
}
int main(){
  int a;
  char s[1000];
  while(scanf("%s",s),s[2]-'d'){
    if(s[0]=='i'){
      scanf("%d",&a);
      H(a);
    }
    else printf("%d\n",N[h()]);
  }    
  return 0;
}



Measured memory_bytes: 11536
/**********

                              Online C++ Compiler.
               Code, Compile, Run and Debug C++ program online.
Write your code in this editor and press "Run" button to compile and execute it.

*********/

#include <bits/stdc++.h>
#define ll long long 
using namespace std;

long long gcd(long long a,long long b){
    return b?gcd(b,a%b):a;
}

long long primechk[10000];

void preprocess(long long N){
    long long i,j;
    for(i=2;i<=N;i++){
        primechk[i]=1;
    }
    for(i=2;i<=N;i++){
        if(primechk[i]==1){
            for(j=2;i*j<=N;j++){primechk[i*j]=0;}
        }
    }
}

long long Binexpo(long long a,long long b){
    if(b==0)
        return 1;
    long long res=Binexpo(a,b/2);
    if(b%2){return res*res*a;}
    else{return res*res;}
}
long long Pwr(long long a,long long b,long long m){
    a%=m;
    long long res=1;
    while(b>0){
        if(b%2){res=res*a%m;}
        a=a*a%m;
        b>>=1;
    }
    return res;
}
int main()
{   long long a,b,c,d,e,f,g,h,i,j,k,x,y,z,sum,cnt=0,n;
    cin>>n;
    long long arr[n];
    for(i=0;i<n;i++){arr[i]=0;}
    if(n%2){
        for(i=0;i<n;i++){cin>>x;arr[x]++;}
        for(i=1;i<=n/2;i++){if(arr[2*i]==2){cnt++;}else{cnt*=0;break;}}
        if(arr[0]==1){cnt++;}else{cnt*=0;}
        if(cnt!=0){cout<<Pwr(2,n/2,1000000007);}else{cout<<0;}
    }
    else{
       for(i=0;i<n;i++){cin>>x;arr[x]++;}
        for(i=0;i<n/2;i++){if(arr[2*i+1]==2){cnt++;}else{cnt*=0;break;}}
        if(arr[0]!=0){cnt*=0;}
        if(cnt!=0){cout<<Pwr(2,n/2,1000000007);}else{cout<<0;}
    }

    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstdio>
#include <map>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,b) FOR(i,0,b)
#define PB push_back
#define MP make_pair
int main(){
  int num[11];
  int c1,c2,c3;
  while(cin>>c1>>c2>>c3){
    for(int i=0;i<=10;i++)num[i]=1;
    num[c1]=num[c2]=num[c3]=0;
    int cnt=0;
    if(20-c1-c2>10){
      cout<<"YES"<<endl;
      continue;
    }
    for(int i=(20-c1-c2);i>=1;i--){
      if(num[i]==1)cnt++;
    }
    if(100*cnt/7>=50)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
  }
}

Measured memory_bytes: 1152
//
//  main.cpp
//  test
//
//  Created by waccho on 2019/10/28.
//  Copyright © 2019 waccho. All rights reserved.
//

#include <bits/stdc++.h>
using namespace std;

#define int long long

signed main() {
    int N, M;
    cin >> N >> M;
    vector<pair<int,int>> A(N);
    for(int i=0; i<N; i++) cin >> A[i].first >> A[i].second;
    
    sort(A.begin(), A.end());
    
    priority_queue<int> pq;

    int ans = 0;
    int n=0;
    for(int day=1; day<=M; day++){
        while(n<N && A[n].first<=day){pq.push(A[n].second); n++;}
        if(pq.size()==0) continue;
        ans += pq.top();
        pq.pop();
    }
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 2936
import bisect,collections,copy,heapq,itertools,math,string
import sys
def S(): return sys.stdin.readline().rstrip()
def M(): return map(int,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))
def LS(): return list(sys.stdin.readline().rstrip().split())
N = I()
l = LI()
x = 0
for i in range(1, N+1):
    if i != l[i-1]:
        x += 1
if x > 2:
    print('NO')
else:
    print('YES')

Measured memory_bytes: 74684
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i,m,n) for(int i=(int)(m); i>=(int)(n); i--)
#define rrep(i,n) RREP(i,n-1,0)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
const ld eps = 1e-10;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n; cin >> n;
  vector<ll> C(n);
  map<int, vector<int>> mp;
  rep(i, n) {
    cin >> C[i];
    mp[C[i]].push_back(i);
  }
  vector<vector<ll>> dp(n+1, vector<ll>(2));
  dp[0][0] = 1;
  rep(i, n) {
    (dp[i+1][0] += dp[i][0] + dp[i][1]) %= mod;
    auto itr = lower_bound(all(mp[C[i]]), i+1);
    if(itr != mp[C[i]].end()) {
      if(*itr > i+1) (dp[*itr+1][1] += dp[i+1][0] + dp[i+1][1]) %= mod;
    }
  }
  cout << (dp[n][0]+dp[n][1])%mod << "\n";
  return 0;
}


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

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	int a,b; cin>>a>>b;
	if (a+b>=10) cout<<"error\n";
	else cout<<a+b;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring> //文字列を扱うためのライブラリ cstring を使えるようにする
using namespace std;

int main() {

string Mojiretsu; //文字列を読み込む。テキストp171のstringの機能を活用しています。
//用意した配列変数に、標準入力から文字列を代入する。空白スペースを含む1行の所得はgetlineが便利
getline(cin,Mojiretsu);       

    // 0文字目から最後の文字まで、iに代入していく。
    for(int i=0; i<=Mojiretsu.size() ; i=i+1  ){    //stringの機能で文字列の長さを所得する。
        
        if( isupper(Mojiretsu[i]) == 0 ) {          // i文字目の文字が
            Mojiretsu[i] = toupper(Mojiretsu[i]) ;  //小文字であれば、大文字に変換する。
            }else{  
            Mojiretsu[i] = tolower(Mojiretsu[i]) ;} //そうでなければ、小文字に変換する。
    }

cout << Mojiretsu << endl ;
return 0;
}


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

int n,a,b,k,t[101];

int main(){
  cin >> n;
  cin >> a >> b;
  cin >> k;
  for(int i=0;i<n;i++) cin >> t[i];
  sort(t,t+n,greater<int>() );
  int ans = 0;
  for(int i=0;i<=n;i++){
    int sum = k;
    for(int j=0;j<i;j++){
      sum += t[j];
    }
    int cal = a+i*b;
    ans = max(ans,sum/cal);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> void cmax(T& a, U b) { if (a<b) a = b; }
template<class T, class U> void cmin(T& a, U b) { if (a>b) a = b; }

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

  int n;
  cin >> n;
  vector<tuple<string, int, int>> l(n);
  rep(i, n) {
    cin >> get<0>(l[i]) >> get<1>(l[i]);
    get<1>(l[i]) = 10000 - get<1>(l[i]);
    get<2>(l[i]) = i+1;
  }
  sort(all(l));
  rep(i, n) {
//    cerr << get<0>(l[i]) << " " << get<1>(l[i]) << endl;
    cout <<  get<2>(l[i])<< endl;
  }
}


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

int main()
{
  int N;
  cin >> N;
  string w;
  // unordered_map<string,int> mp;
  map<string,int> mp;
  rep(i,N) {
    cin >> w;
    sort(w.begin(),w.end());
    mp[w]++;
  }
  ll ans=0;
  // for(auto p : mp){
  for(pair<string,int> p:mp){
    ll count = p.second;
    ans += count * (count-1) / 2;
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (1E9+7)
#define PI 3.1415926535897932384

std::ostream &operator<<(std::ostream &out, const vector<int> &tgt)
{
	string s;
	for (int i = 0; i<tgt.size(); i++) {
		s += (to_string(tgt[i]) + ((i != tgt.size() - 1) ? " " : ""));
	}
	out << s;
	return out;
}

int main() {
	string s;
	int ans = 0;
	cin >> s;
	for(auto c : s) {
		if (c == '1')ans++;
	}
	cout << ans << endl;

}


Measured memory_bytes: 256
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#include<bits/stdc++.h>  
#define endl "\n"
using namespace std;
	typedef long long ll;
	const int maxn=3050;
	const int inf=0x3f3f3f3f;
	string s1,s2,ans;
	int dp[maxn][maxn];
	ll n,m;
	int main(){
		IOS
		cin>>s1>>s2;
		int p1,p2;
		int len1=s1.size(),len2=s2.size();
		
		for(int i=0;i<len1;i++)
			for(int j=0;j<len2;j++){
				if(s1[i]==s2[j])
					dp[i+1][j+1]=dp[i][j]+1;
				else
					dp[i+1][j+1]=max(dp[i+1][j],dp[i][j+1]);
			}
			
		int i=len1-1,j=len2-1;
		while(i!=-1&&j!=-1){
			if(s1[i]==s2[j]){
				ans+=s1[i];
				i--;
				j--;
			}
			else if(dp[i+1][j]>dp[i][j+1]){
				j--;
			}
			else
				i--;
		}
		reverse(ans.begin(),ans.end());
		cout<<ans<<endl;
	}

Measured memory_bytes: 39416
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;


public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        String[] num = str.split(" ");
        int suu = Integer.parseInt(num[0]);
        int suu2 = Integer.parseInt(num[1]);
        List<String> mozi = new ArrayList<>();
        for(int i=0;i<suu;i++){
            mozi.add(sc.next());
        }
        Collections.sort(mozi);
       mozi.forEach(System.out::print);
    }

    
} 


Measured memory_bytes: 28500
#include<bits/stdc++.h>
#define N 100005
#define M 200005
#define pb push_back
using namespace std;
int i,j,k,l,s,n,m,last[N],to[M],Next[M],q[N],fa[N],si[N],ans,tot,x,y,dis[N],a[N];
vector<int>GT;
inline void add(int x,int y) {
	Next[++tot]=last[x]; last[x]=tot; to[tot]=y;
}
inline void build() {
	int l=0,r=1; q[1]=1,dis[1]=1;
	while (l<r) {
		int k=q[++l];
		for (int i=last[k];i;i=Next[i]) if (fa[k]!=to[i]) fa[q[++r]=to[i]]=k,dis[to[i]]=dis[k]+1;
	}
}
inline bool work(int x,int y,int z) {
	int L=0,R=GT.size()-1;
	if (L==x) L++;
	if (R==x) R--;
	while (L<=R) {	
		if (GT[L]+GT[R]-2*y+1>z) return false;
		L++,R--;
		if (L==x) L++;
		if (R==x) R--;
	}
	return true;
}
inline int Find(int x,int y) {
	int L=0,R=GT.size()-1,s=GT.size();
	while (L<=R) {
		int mid=(L+R)>>1;
		if (work(mid,x,y)) s=mid,R=mid-1;
		else L=mid+1;
	}
	return s;
}
inline bool check(int x) {
	for (int i=n;i;i--) {
		GT.clear();
		for (int j=last[q[i]];j;j=Next[j]) {
			if (to[j]==fa[q[i]]) continue;
			GT.pb(a[to[j]]);
		}
		sort(GT.begin(),GT.end());
		if (!GT.size()) {
			a[q[i]]=dis[q[i]];
			continue;
		}
 		if (GT.size()&1) {
			if (GT.size()==1) {
				a[q[i]]=GT[0];
				continue;
			}
			int gt=Find(dis[q[i]],x);
			if (gt>=GT.size()) return false;
			a[q[i]]=GT[gt];
		}
		else if (i!=1) {
			GT.pb(dis[q[i]]);
			sort(GT.begin(),GT.end());
			int gt=Find(dis[q[i]],x);
			if (gt>=GT.size()) return false;
			a[q[i]]=GT[gt];
		}
		else {
			for (int j=0;j<GT.size()/2;j++) if (GT[j]+GT[GT.size()-j-1]-1>x) return false;
			return true;
		}
	}
	if (a[1]>x) return false;
	return true;
}
int main() {
	scanf("%d",&n);
	for (i=1;i<n;i++) scanf("%d%d",&x,&y),add(x,y),add(y,x);
	build();
	for (i=n;i;i--) {
		if (!si[q[i]]) si[q[i]]++;
		ans+=si[q[i]]>>1;
		si[fa[q[i]]]++;
	}
	ans+=si[1]&1;
	printf("%d ",ans);
	int l=0,r=n;
	ans=0;
	while (l<=r) {
		int mid=(l+r)>>1;
		if (check(mid)) r=mid-1,ans=mid;
		else l=mid+1;
	}
	printf("%d\n",ans-1);
} 

Measured memory_bytes: 4732
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define endl '\n'
#define ll long long int
#define vec vector
#define forn(a) for(ll a=0; a<n; a++)
#define all(x) x.begin(), x.end()
#define deb(x) cerr<<#x<<" = "<<x<<endl

using namespace std;

int main() {
    IOS;

    int n; cin>>n;
    vec<int> v(n);
    forn(i) cin>>v[i], v[i]--;

    int fuera_de_lugar = 0;
    forn(i){
        if(i!=v[i]) fuera_de_lugar++;
    }

    if(fuera_de_lugar==2 || fuera_de_lugar==0) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
	int n;
	cin >> n;
	
	int total=0;
	for(int i=0; i<n; i++){
		int l,r;
		cin >> l >> r;
		total += r-l+1;
	}
	
	cout << total << endl;
	return 0;
}

Measured memory_bytes: 256
def solve():
    n, m = map(int, input().split())
    py = list(list(map(int, input().split())) for _ in range(m))
    py_with_key = sorted([(idx, pyi) for idx, pyi in enumerate(py)], key=lambda x: x[1])
    pref_no = 1
    cnt = 0
    ids = []
    for idx, p_y in py_with_key:
        if pref_no == p_y[0]:
            cnt += 1
        else:
            pref_no = p_y[0]
            cnt = 1
        city_id = '{0:06d}{1:06d}'.format(p_y[0], cnt)
        ids.append((idx, city_id))
    return "\n".join([x[1] for x in sorted(ids, key=lambda x: x[0])])


if __name__ == "__main__":
    print(solve())


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

int main(void) {
	int N, M;
	scanf("%d %d", &N, &M);
	int ans[50] = {0};
	for (int i = 0; i < M; i++) {
		int a, b;
		scanf("%d %d", &a, &b);
		ans[a - 1]++;
		ans[b - 1]++;
	}
	for (int i = 0; i < N; i++) {
		printf("%d\n", ans[i]);
	}
	return 0;
}


Measured memory_bytes: 3800
#include <bits/stdc++.h>
using namespace std;
#define __ <<" "<<
#define ___ <<" "
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {
    IoSetup() {
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout <<fixed<<setprecision(12);
        cerr <<fixed<<setprecision(12);
    }
}IoSetup;

typedef long long ll;
typedef pair < int , int >  pii;
static constexpr const signed int INF = 0x3f3f3f3f;
static constexpr const signed long long LINF = 0x3f3f3f3f3f3f3f3fLL;
static constexpr const signed int SMOD = 1000000007;
static constexpr const signed int NMOD = 998244353;
static constexpr const signed int dx[]={1,0,-1,0,1,1,-1,-1};
static constexpr const signed int dy[]={0,-1,0,1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a=max(a,b))==b;}
template<class T>bool chmin(T &a, const T &b){return(a=min(a,b))==b;}
inline int qp(int a,ll b,int mo){int ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}

string s,t;
int n;


signed main() {

    cin >> n;
    cin >> s >> t;

    for(int i = 0; i < n; i++) {
        cout << s[i] << t[i];
    }


  
    return 0;
}



Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <map>
#include <cstdlib>
#include <algorithm>
#include <string> 
 
using namespace std;
 
int main(){
    string s, inter, s2;
    int q, a, b;
    cin >> s >> q;
    for (int i = 0; i < q; i++){
        cin >> inter >> a >> b;
        if (inter == "replace"){
            cin >> s2;
            s = s.substr(0, a) + s2 + s.substr(b + 1, s.size() - b - 1);
        }
        else if (inter == "print") cout << s.substr(a, b - a + 1) << endl;
        else  reverse(s.begin() + a, s.begin() + b + 1);
    }
}

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

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

    int max = 0;
    for(int i=0; i<n; i++) {
        if(max<a[i]) max=a[i];
    }

    const int maxlen = h+max+1;
    int *dp = (int*)malloc(sizeof(int)*maxlen);
    for(int i=0; i<n; i++) dp[i]=0;

    for(int i=0; i<n; i++) {
        if(dp[a[i]]==0 || dp[a[i]]>b[i]) {
            dp[a[i]] = b[i];
        }
        for(int j=1; j<maxlen; j++) {
            if(dp[j]!=0) {
                if(j+a[i]<maxlen && (dp[j+a[i]]==0 || dp[j]+b[i]<dp[j+a[i]])) {
                    dp[j+a[i]] = dp[j]+b[i];
                } 
            }
        }
    }

    // for(int i=0; i<maxlen; i++) {
    //     cout<<dp[i]<<' ';
    // }
    // cout<<endl;

    int ans = 0;
    for(int i=h; i<maxlen; i++) {
        if(ans==0 || (ans>dp[i] && dp[i]!=0)) ans=dp[i];
    }

    cout<<ans<<endl;

    free(dp);
 
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lp(i, x, n) for (int i = x; i < (int)n; ++i)
#define all(v) (v).begin(), (v).end()
#define sz(v) (int)(v).size()
#define ll long long
#define N 123451
int n;

int main(){
        scanf("%d", &n);
        printf("%d", n * (n + 1) / 2);
        return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<numeric>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl;

using namespace std;

struct cake {
	int w, d, area, turn;
	cake(int w_, int d_, int turn_)
		: w(w_), d(d_), area(w_*d_), turn(turn_) {}
	bool operator<(const cake &c) const {
		if(turn != c.turn) { return turn < c.turn; }
		return area < c.area;
	}
};

vector<cake> cakes;

int main() {
	int n, w, d;
	while(cin >> n >> w >> d, w) {
		int turn=0;
		cakes.clear();
		cakes.push_back(cake(w, d, turn));
		int p, s;
		rep(i, n) {
			++turn;
			cin >> p >> s; p--;
			cake piece = cakes[p];
			cakes.erase(cakes.begin() + p);
			
			int k=1, diff=s;
			for(; diff > 0; ++k) {
				diff -= (k % 2) ? piece.w : piece.d;
			}
			
			diff *= -1;
			if(k % 2) { //縦分割
				int d1 = piece.d - diff;
				int d2 = diff;
				cakes.push_back(cake(piece.w, d1, turn));	
				cakes.push_back(cake(piece.w, d2, turn));	
			} 
			else { //横分割
				int w1 = piece.w - diff;
				int w2 = diff;
				cakes.push_back(cake(w1, piece.d, turn));	
				cakes.push_back(cake(w2, piece.d, turn));	
			}

			sort(ALL(cakes));
		}

		vector<int> result;
		rep(i, cakes.size()) result.push_back(cakes[i].area);

		sort(ALL(result));
		rep(i, result.size()) {
			if(i != 0) cout << " ";
			cout << result[i];
		}
		cout << endl;
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
static const ll INF = 1023456789;

#define REP(i,n)	for(int i=0;i<n;++i)
#define REPR(i,n)	for(int i=n-1;i>=0;--i)
#define FOR(i,s,n)	for(int i=s;i<n;++i)
#define FORR(i,s,n)	for(int i=n-1;i>=s;--i)
#define ALL(c)		(c).begin(),(c).end()
#define CLEAR(v)	memset(v,0,sizeof(v))
#define MP(a,b)		make_pair((a),(b))
#define ABS(a)		((a)>0?(a):-(a))
#define F			first
#define S			second

int main(int argc, char **argv) {
	ll d, n;
	cin >> d >> n;
	cout << (n == 100 ? 101 : n);
	REP(i, d) cout << "00";
	cout << endl;
	return 0;
}


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

int main(void) {
    long a,v,b,w,t;
    cin >> a >> v >> b >> w >> t;
    if ( a < b) {
        if ( (a+v*t) >= (b+w*t) ){
            cout << "YES";
        }else{
            cout << "NO";
        }
    }else {
        if ( (a-v*t) <= (b-w*t) ){
            cout << "YES";
        }else{
            cout << "NO";
        }
    }
    
}

Measured memory_bytes: 3640
/*
  Compete against Yourself.
  Author - Aryan Choudhary (@aryanc403)
*/

#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define fo(i,n)   for(i=0;i<(n);++i)
#define repA(i,j,n)   for(i=(j);i<=(n);++i)
#define repD(i,j,n)   for(i=(j);i>=(n);--i)
#define all(x) begin(x), end(x)
#define sz(x) ((lli)(x).size())
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define endl "\n"

typedef long long int lli;
typedef long double mytype;
typedef pair<lli,lli> ii;
typedef vector<ii> vii;
typedef vector<lli> vi;


const auto start_time = std::chrono::high_resolution_clock::now();
void aryanc403()
{
#ifdef ARYANC403
auto end_time = std::chrono::high_resolution_clock::now();
std::chrono::duration<double> diff = end_time-start_time;
    cerr<<"Time Taken : "<<diff.count()<<"\n";
#endif
}

#ifdef ARYANC403
#include "/home/aryan/codes/PastCodes/header.h"
#else
    #define dbg(args...)
#endif

const lli INF = 0xFFFFFFFFFFFFFFFL;

lli seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline lli rnd(lli l=0,lli r=INF)
{return uniform_int_distribution<lli>(l,r)(rng);}

class CMP
{public:
bool operator()(ii a , ii b) //For min priority_queue .
{    return ! ( a.X < b.X || ( a.X==b.X && a.Y <= b.Y ));   }};

void add( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt==m.end())         m.insert({x,cnt});
    else                    jt->Y+=cnt;
}

void del( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt->Y<=cnt)            m.erase(jt);
    else                      jt->Y-=cnt;
}

bool cmp(const ii &a,const ii &b)
{
    return a.X<b.X||(a.X==b.X&&a.Y<b.Y);
}

const lli mod = 1000000007L;
// const lli maxN = 1000000007L;

lli po(lli a,lli n)
{
    lli ans=1;
    while(n)
    {
        if(n&1)
            ans=(ans*a)%mod;
        a=(a*a)%mod;
        n/=2;
    }
    return ans;
}

    lli T,n,i,j,k,in,cnt,l,r,u,v,x,y;
    lli m;
    string s;
    vi a;
    //priority_queue < ii , vector < ii > , CMP > pq;// min priority_queue .

int main(void) {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    // freopen("txt.in", "r", stdin);
    // freopen("txt.out", "w", stdout);
// cout<<std::fixed<<std::setprecision(35);
// cin>>T;while(T--)
{

    cin>>n>>k;
    swap(k,n);
    a.resize(n+1);
    lli ans=0;
    repD(i,n,1)
    {
        lli &cnt=a[i];
        cnt=po(n/i,k);
        for(lli j=2*i;j<=n;j+=i)
            cnt-=a[j];
        cnt%=mod;
        ans+=i*cnt%mod;
    }

    ans%=mod;
    ans+=mod;
    ans%=mod;
    
    cout<<ans<<endl;
}   aryanc403();
    return 0;
}


Measured memory_bytes: 4040
N,M=map(int,input().split())
A=[input() for _ in range(N)]
B=[input() for _ in range(M)]
ans="No"
for i in range(N-M+1):
  for j in range(N-M+1):
    if [a[j:j+M] for a in A[i:i+M]]==B:    
      ans="Yes"
print(ans)

Measured memory_bytes: 3060
import sys
ans = 1
N = int(input())
A = list(map(int, input().split()))  
if A.count(0):
    print(0)
else:
    for _ in range(N):    
        ans *= A[_]
        if ans > pow(10,18):
            print(-1)
            sys.exit()
    print(ans)




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

using namespace std;

typedef long long ll;

int W;
int H;
ll P[100005];
ll Q[100005];


int main(int argc, char* argv[]) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    cin >> W >> H;

    for (int i = 0; i < W; ++i) {
        cin >> P[i];
    }
    for (int i = 0; i < H; ++i) {
        cin >> Q[i];
    }

    ll ans = 0;

    for (int i = 0; i < W; ++i) {
        ans += P[i];
    }
    for (int i = 0; i < H; ++i) {
        ans += Q[i];
    }

    //for (int j = 0; j < W; ++j) {
    //    for (int i = 0; i < H; ++i) {
    //        ans += min(P[j], Q[i]);
    //    }
    //}

    sort(P, P + W);
    sort(Q, Q + H);

    //for (int i = 0; i < W; ++i) {
    //    cout << P[i] << " ";
    //}
    //cout << endl;

    //for (int i = 0; i < H; ++i) {
    //    cout << Q[i] << " ";
    //}
    //cout << endl;

    int i = 0;
    int j = 0;

    while (j < W && i < H) {
        //cout << "i: " << i << ", j: " << j << endl;

        if (P[j] < Q[i]) {
            ans += P[j] * (H - i);
            j++;
        } else {
            ans += Q[i] * (W - j);
            i++;
        }
    }

    cout << ans << endl;
    

    return 0;
}



Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    long a,n;
    cin>>n;
    map<int,int> m;
    for(int i=1;i<=n;i++){
        cin>>a;
        m.insert(pair<int,int>(a,i));
    }
      map<int,int>::iterator itr; 
    
    for (itr =m.begin(); itr != m.end(); ++itr)
        cout <<  itr->second<<" "; 
              
    return 0;
}
     
   




Measured memory_bytes: 8288
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <iomanip>
#include <string>
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
using namespace std;

int main(void){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n, k;
  cin >> n >> k;
  vector<int> fruit(n);
  for(int i=0; i<n; i++){
    cin >> fruit[i];
  }
  sort(fruit.begin(), fruit.end());
  int ans=0;
  for(int i=0; i<k; i++){
    ans += fruit[i];
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    ll n,i,j,k,l,a,b,c,d,x;
    string s;
    cin>>s;
    cin>>k;
    i=0;
    while(i<(k-1) &&s[i]=='1')
    {
        i++;
    }
    cout<<s[i]<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, s, n) for(int i = s; i < (int)n; i++)
#define per(i, n) for(int i = n; i >= 0; i--)
#define ROF(i, s, n) for(int i = s; i >= (int)n; i--)
#define FORIT(i, A) for (auto i : A)
#define PRINT(x) cout << (x) << "\n"
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define MP make_pair
#define EACH(i, n) for (__typeof((n).begin()) i = (n).begin(); i != (n).end(); ++i)
#define SZ(a) int((a).size())
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define CLR(a) memset((a), 0 ,sizeof(a))
#define NCLR(a) memset((a), -1 ,sizeof(a))
#define dump(x) cout << #x << " = " << (x) << "\n";
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << "\n";
#define sq(n) (n) * (n)
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef priority_queue<int> maxpq;
typedef priority_queue< int, vector<int>, greater<int> > minpq;
static const double EPS = 1e-10;
static const double PI = acos( -1.0 );
static const int mod = 1000000007;
static const int INF = 1 << 25;
static const LL LL_INF = 1152921504606846976;
static const int dx[] = { -1, 0, 1, 0, 1, -1, 1, -1 };
static const int dy[] = { 0, -1, 0, 1, 1, 1, -1, -1 };

static const int r[ 8 ] = { 0, 0, 0, 0, 255, 255, 255, 255 }, g[ 8 ] = { 0, 0, 255, 255, 0, 0, 255, 255 }, b[ 8 ] = { 0, 255, 0, 255, 0, 255, 0, 255 };
char s;
int input_r, input_g, input_b;
int now_a;
string ans;
string a[ 8 ] = { "black", "blue", "lime", "aqua", "red", "fuchsia", "yellow", "white" };

int main() {
	while ( ~scanf( "%1s", &s ) && s != '0' ) {
		scanf( "%2x%2x%2x", &input_r, &input_g, &input_b );
		now_a = INF;
		for ( int i = 0; i < 8; i++ ) {
			if ( now_a > sq( r[ i ] - input_r ) + sq( g[ i ] - input_g ) + sq( b[ i ] - input_b ) ) {
				now_a = sq( r[ i ] - input_r ) + sq( g[ i ] - input_g ) + sq( b[ i ] - input_b );
				ans = a[ i ];
			}
		}
		printf( "%s\n", ans.c_str() );
	}
	return 0;
}

Measured memory_bytes: 1200
use std::io::prelude::*;

fn input<T>() -> T
where
    T: std::str::FromStr,
{
    let stdin = std::io::stdin();
    let token: String = stdin
        .lock()
        .bytes()
        .map(|c| c.unwrap() as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().unwrap()
}

fn main() {
    let a: i64 = input();
    let b: i64 = input();
    let c: i64 = input();

    let max = std::cmp::max(std::cmp::max(a, b), c);
    let mut d = max - a + max - b + max - c;
    if d % 2 == 1 {
        d += 3;
    }
    println!("{}", d / 2);
}


Measured memory_bytes: 4352
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1<<30;
#define vec2(a,y,x) vector<vector<int>> a(y,vector<int>(x,0))
#define vec1(a,n) vector<int> a(n);rep(i,n)cin>>a[i]
using P=pair<int,int>;
vector<int> dx={0,1,-1,0};
vector<int> dy={1,0,0,-1};

int main(){
  ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int n;
  cin>>n;
  vec1(v,n);
  vec1(c,n);
  int cnt=0;
  rep(i,n) if(v[i]>c[i]) cnt +=v[i]-c[i];
  cout<<cnt<<'\n';
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES // for C++  
#include <cmath> 
void call(int n);
using namespace std;
int main(){
	int n;
	int apa[12][10];
	for(int l=0;l<12;l++){
		for(int r=0;r<10;r++){
			apa[l][r]=0;
		}
	}
	cin>>n;
	
	for(int i=0;i<n;i++){
		int t,k,b,h;
		
		cin>>t>>k>>b>>h;
		if(t==1){
				 apa[k-1][b-1]+=h;
		}else if(t==2){
			apa[k+2][b-1]+=h;
		}else if(t==3){
			apa[k+5][b-1]+=h;
				}else if(t==4){
							   apa[k+8][b-1]+=h;
														  }
	}
	for(int l=0;l<12;l++){
		
		for(int r=0;r<10;r++){
			cout<<' '<<apa[l][r];
		}
		cout<<endl;
		
	if((l+1)%3==0 &&l!=11){
		for(int s=0;s<20;s++){
			cout<<'#';
		}
		cout<<endl;
	}}
}


Measured memory_bytes: 3112
/*GRATITUDE*/
//Arise Awake and Stop Not Till the Goal is reached. You are the greatest of all. Hare Krishna
//Break through all barriers..
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
#define ff              first
#define ss              second
#define uint            unsigned long long
#define int             long long
#define double           long double
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define endl            "\n"
#define all(x)             x.begin(), x.end()
#define all_r(x)           x.rbegin(), x.rend()
#define sortall(x)         sort(all(x))
#define sortall_r(x)       sort(all_r(x))  
#define tr(it, a)          for(auto it = a.begin(); it != a.end(); it++)
#define PI                 acos(-1)
#define w(t)              int t; cin>>t; while(t--)
#define for_f(a,b,c)      for(int i=a;i<=b;i=i+c)
#define for_r(a,b,c)      for(int i=a;i>=b;i=i-c) 
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
#define trace1(x) cout << '>' << #x << ':' << (x) << "\n"
#define trace2(x,y) cout<< '>' << #x << ':' << (x) << " | " << #y << ':' << (y) << "\n"
#define trace3(a,b,c) cout<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define trace4(a,b,c,d) cout<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"
void ash_god()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
#ifndef ONLINE_JUDGE
    freopen("i.txt", "r", stdin);
    freopen("o.txt", "w", stdout);
#endif
}
/*************************************************************************************************/
//Write your functions here..............................



/***************************************************************************************************/

void solve() {
/*Write your code here*/
  
int k; cin>>k;
string s; cin>>s;
if(s.length()<=k) cout<<s;
else {
for_f(0,k-1,1) cout<<s[i];
 cout<<"...";
}

}   
int32_t main()
{
ash_god();
bool tc=0;
if(tc)  {
    w(t) solve();
}
else solve();

return 0;
} 



Measured memory_bytes: 3608
#include <iostream>
using namespace std;
typedef long long  ll;

#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

int main()
{
	ll x; cin >> x;
	ll a = x / 11;
	ll b = x % 11;

	a *= 2;
	if (b == 0) {
		cout << a << endl;
	}
	else if (b <= 6) {
		cout << a + 1 << endl;
	}
	else if (b == 7) {
		cout << a + 2 << endl;
	}
	else if (b >= 8 && b < 11) {
		cout << a + 2 << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int x[99][2],y[99][20],n,a,b,c,d,e,f,g,h,p;
int main() {
	while(true) {
		memset(x,0,sizeof(x));
		memset(y,0,sizeof(y));
		cin>>n>>a>>b>>c;
		if(n==0){
			break;
		}
		for(int i=0;i<c;i++){
			cin>>d>>e>>f>>g;
			if(g!=0){
				y[e][f]+=20;
			}
			else{
				x[e][1]+=d+y[e][f];
				x[e][0]++;
			}
		}
		p=0;
		for(int i=b;i>=0;i--){
			for(int j=0;j<=99999;j++){
				h=0;
				for(int k=a;k>0;k--){
					if(x[k][0]==i&&x[k][1]==j){
						if(h>=1){
							cout<<'=';
						}
						else if(p>=1){
							cout<<',';
						}
						cout<<k;
						p++;
						h++;
					}
				}
			}
		}
		cout<<endl;
	}
}

Measured memory_bytes: 1168
H, W = map(int, input().split())
grid = []
flag = 1
for h in range(H):
  S = input()
  tmp = []
  for s in S:
    tmp.append(s)
  grid.append(tmp)

for h in range(H):
  for w in range(W):
    mark = grid[h][w]
    if mark == ".": continue

    if h-1 >= 0:
      up = grid[h-1][w]
    else: up = "."

    if h+1 <= H-1:
      down = grid[h+1][w]
    else: down = "."

    if w-1 >= 0:
      left = grid[h][w-1]
    else: left = "."
    
    if w+1 <= W-1:
      right = grid[h][w+1]
    else: right = "."

    if (up != "#") & (down != "#") & (right != "#") & (left != "#"): 
      flag = 0
      break

if flag == 1: print("Yes")
else:print("No")

    



Measured memory_bytes: 3064
N, K = map(int,input().split())
H = list(map(int,input().split()))
s = {}
for j in range(K):
  A, B = map(int,input().split())
  if H[A-1] < H[B-1]:
    s[A] = False
    if B in s.keys() and not s[B]:
      continue
    s[B] = True
  elif H[A-1] == H[B-1]:
    s[A] = False
    s[B] = False
  else:
    s[B] = False
    if A in s.keys() and not s[A]:
      continue
    s[A] = True
    
cnt = 0
for i in range(N):
  if not i+1 in s.keys():
    cnt+=1
    continue
  
  if s[i+1]:
    cnt+=1
print(cnt)

Measured memory_bytes: 20020
N = int(input())
x = []
for i in range(N):
  x.append(input().split())
ans = 0
for j in range(N):
  if x[j][1] == "JPY":
    ans = ans + int(x[j][0])
  else:
    ans = ans + float(x[j][0])*380000
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn=(2e5)+10;
int n;
ll a[maxn],ans;
int main() {
	//freopen("1.txt","r",stdin);
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%lld",&a[i]);
	for (int i=1;i<=n;i++)
		if (a[i]!=a[i-1]+1) ans+=a[i];
		else ans++;
	if (a[1]!=0) ans=-1;
	for (int i=1;i<n;i++)
		if (a[i+1]-a[i]>1) ans=-1;
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int lld;

const lld mod = 1e9+7;
const lld INF = 1e9;
const lld MAXN = 1e5;


int main()
{
	lld n,a[MAXN] = {0};

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

	lld cntp = 0;
	lld sum = 0;
	for(int i = 0; i < n; i++)  //最初がplus
	{
		sum += a[i];
		if (sum <= 0 && i % 2 == 0)   //和を1に持ってく
		{
			lld x = 1 - sum;
			sum += x;
			cntp += x;
		}
		if (sum >= 0 && i % 2 != 0)   //和を−1に持ってく
		{
			lld x = sum + 1;
			sum -= x;
			cntp += x;
		}
	}

	//cout << "p= " << cntp << endl;

	lld cntm = 0;
	sum = 0;
	for(int i = 0; i < n; i++)  //最初がminus
	{
		sum += a[i];
		if (sum >= 0 && i % 2 == 0)   //和を-1に持ってく
		{
			lld x = 1 + sum;
			sum -= x;
			cntm += x;
		}
		if (sum <= 0 && i % 2 != 0)   //和を1に持ってく
		{
			lld x = 1 - sum;
			sum += x;
			cntm += x;
		}
	}

	//cout << "m = " << cntm << endl;

	cout << min(cntp,cntm) << endl;


	return 0;
}

Measured memory_bytes: 1152
#include <stdio.h>

int main(){
    int n, d, x, a[100];
    int i, j, cnt=0;

    scanf("%d %d %d", &n, &d, &x);

    for(i=0; i<n; i++)
        scanf("%d", &a[i]);
    
    for(i=0; i<n; i++){
        j=0;
        while(j*a[i]+1 <= d){
            cnt++;
            j++;
        }
    }

    printf("%d\n", x+cnt);

    return 0;
}

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

int main() {
  int N,M; cin >> N >> M;
  vector<int> a(M); for (int i =0; i<M; i++) cin >> a.at(i);
  vector<long> f(N+1);
  vector<bool> check(N+1,false);
  for (int i =0; i<M; i++) {
    check.at(a.at(i)) =true;
  } 
  f.at(0) = 1;
  if (check.at(1)) {
    f.at(1) = 0;
  } else {
    f.at(1) = 1;
  }
  if (N >= 2 && check.at(2)) f.at(2) = 0;
  for (int i =2; i<=N; i++) {
    if (N >= 2 && check.at(i) == true) continue;
    f.at(i) = f.at(i-1) + f.at(i-2);
    f.at(i) %= 1000000007;
  }
  cout << f.at(N) % 1000000007 << endl;
}

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



int p(int n){//i1回分の各桁の和の計算はこの関数内で行ってしまえということ
  int sum=0;
  while(n>0){
  sum+=n%10;
    n/=10;
  }
  return sum;
}

int main(){
    int N,A,B;
    int souwa=0;
    int sum=0;
    cin >> N >> A >> B;
    for(int i=1;i<=N;i++){
         sum=p(i);
        if(sum>=A&&sum<=B) souwa+=i;
    }
    cout << souwa << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define int long long
using namespace std;
using P=pair<int,int>;
using Graph=vector<vector<int>>;
using ll=long long;


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);
}
bool root(string s){
    int n=s.length();
    if(n==2){
        if(s[0]==s[1]){
            return true;
        }
        else return false;
    }
    if(n==3){
        if(s[0]==s[2]){
            return true;
        }
        else return false;
    }
 
    return false;
}
 
 
//深さ優先
vector<int> seen;
vector<ll> h;
 
//普通の深さ優先探索seenを返す感じ
void dfs(const Graph &G,int v){

    seen[v] = 0; //v探索済み
 
    P good=make_pair(v,h[v]);
    for(auto next_v :G[v]){
        if(seen[next_v]!=-1) continue;//もう探索していた
        if(h[next_v]>good.second){
            good=make_pair(next_v,h[next_v]);
        }
        dfs(G,next_v);
    }
 
    if(!(h[v]==good.second && v==good.first)){
        seen[good.first]=1;
    }
}


int n;

void dfs(string s, char mx){
    if(s.length()==n){
        cout<<s<<endl;
    }else{
        for(char c='a';c<=mx;c++){
            dfs(s+c,((c==mx) ? (char)(mx+1) : mx));
        }
    }
}

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

    int C[n];
    vector<vector<int>> A(n,vector<int>(m,0));

    for(int i=0;i<n;i++){
        cin>>C[i];
        for(int j=0;j<m;j++){
            cin>>A[i][j];
        }
    }

    int ans=10e10 + 1;

    for(int tmp=0;tmp<(1<<n);tmp++){
        bitset<12> choi(tmp);
        vector<int> sc(m,0);
        int sum=0;

        for(int k=0;k<n;k++){
            if(choi.test(k)){
                sum+=C[k];
                for(int j=0;j<m;j++){
                    sc[j]+=A[k][j];
                }
            }
        }

        bool able=true;
        for(int i=0;i<m;i++){
            if(sc[i]<x) able=false;
        }

        if(able){
            ans=min(ans,sum);
        }
    }

    if(ans == 10e10 +1){
        cout<<-1<<endl;
        return 0;
    }
    cout<<ans<<endl;

}  

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

inline int D(){
    int t ;
    scanf( "%d" , &t ) ;
    return t ;
}
inline ll LLD(){
    ll t ;
    scanf( "%lld" , &t ) ;
    return t ;
}
//const int INF = 0x3f3f3f3f;
//const int mod=1e9+7;
//const double pi=3.14159265359;
//###################################################################

int main(){
    string s;
    cin>>s;
    int mx=0;
    int cnt=0;
    for(int i=0;i<3;i++){
        if(s[i]=='R') {
            cnt++;
            mx=max(mx,cnt);
        }
        else cnt=0;
    }
    cout<<mx;

}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll ;
long long gcd(long long aaa,long long bbb) {
    if(bbb==0) {
        return aaa;
    }
    return gcd(bbb,aaa%bbb);
}
int main (){ 
    
    int A,B;
    cin >> A >> B;
    cout << (A - 1) * (B - 1) << endl;
    
    return 0;
}


Measured memory_bytes: 256
import java.io._
import java.util.StringTokenizer
import scala.util.control.Breaks.{breakable,break}
import scala.collection.mutable.{Map, Stack, Queue, PriorityQueue, Set}
import scala.util.Random
import java.util.Date

object Main extends App {
  val startTime = new Date().getTime // to milli seconds

  val in = new InputReader(System.in)
  val pw = new PrintWriter(System.out)

  val D = in.next().toInt
  val c = new Array[Long](26+1)
  val s = Array.ofDim[Long](D+1, 26+1)

  for (i <- 1 to 26) {
    c(i) = in.next().toInt
  }
  for (d <- 1 to D) {
    for (i <- 1 to 26) {
      s(d)(i) = in.next().toInt
    }
  }


  /** functions **/
  def calcScore(t: Array[Int]): Long = {
    val last = new Array[Int](26+1)
    var res = 0L

    for (d <- 1 to D) {
      val ty = t(d)

      res += s(d)(ty)
      last(ty) = d

      for (i <- 1 to 26) {
        res -= c(i) * (d - last(i))
      }
    }

    res
  }


  /** solve **/
  val t = new Array[Int](D+1)
  for (d <- 1 to D) {
    t(d) = (d % 26 + 1)
  }

  val endTime = 1200
  var nowScore = calcScore(t)
  while ((new Date().getTime - startTime) < endTime) {
    for (_ <- 1 to 1000) {
      val d = Random.nextInt(D) + 1
      val ty = Random.nextInt(26) + 1

      val tmp = t(d)
      t(d) = ty
      val score = calcScore(t)
      if (score > nowScore) {
        nowScore = score
      }
      else {
        t(d) = tmp
      }
    }
  }


  for (d <- 1 to D) {
    pw.println(t(d))
  }
  pw.flush()
}

object Sub {
  def print2DimArray[A](mat: Array[Array[A]]): Unit = {
    mat.foreach(lin => println(lin.toList))
  }
}

class InputReader(stream: InputStream) {
  private[this] val reader = new BufferedReader(new InputStreamReader(stream))
  private[this] var tokenizer: StringTokenizer = new StringTokenizer(reader.readLine())
  def next(): String = {
    while (!tokenizer.hasMoreTokens()) {
      tokenizer = new StringTokenizer(reader.readLine())
    }
    tokenizer.nextToken()
  }
}


Measured memory_bytes: 57544
a, b, c = [int(x) for x in input().split()]
d = [int(x) for x in input().split()]
e = [[int(x) for x in input().split()] for i in range(a)]
r = 0
for i in range(a):
    t =  sum([x * d[idx] for idx, x in enumerate(e[i])])
    if t+c > 0:
        r += 1
print(r)

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

typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
#define mp make_pair
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define MOD 1000000007

int main(){
  int n;
  cin >> n;
  int d = n / 2 * 2;
  vector<pii> edges;
  for(int i = 1; i <= n; i++){
    for(int j = i+1; j <= n; j++){
      if(i+j == d+1){
        continue;
      }
      edges.emplace_back(i,j);
    }
  }
  int m = (int) edges.size();
  cout << m << endl;
  for(auto &p : edges){
    cout << p.first <<" " <<p.second <<endl;
  }
  return 0;
}


Measured memory_bytes: 384