akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

#define rep(i,a) for(int i = 0;i < (a); i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)
#define repd(i,a,b) for(int i = (a); i >= (b); i--)
#define repit(i,a) for(__typeof((a).begin()) i = (a).begin(); i != (a).end(); i++)
#define all(u) (u).begin(),(u).end()
#define rall(u) (u).rbegin(),(u).rend()
#define UNIQUE(u) (u).erase(unique(all(u)),(u).end())
#define pb push_back
#define mp make_pair
#define INF 1e9
#define EPS 1e-9
#define PI acos(-1.0)

using namespace std;

typedef long long ll;
typedef vector<int> vi;

const int mod = 100000007;
const int N = 200000;

ll dp[N] = {1, 1}, dp1[N] = {1, 1};

void gen()
{
    repi(i,2,N) {
        dp[i] = dp[i - 1] * 2;
        if (i > 5)
            dp[i] -= dp[i - 6];
        dp[i] = (dp[i] % mod + mod) % mod;

        dp1[i] = dp1[i - 1] * 2;
        if (i > 3)
            dp1[i] -= dp1[i - 4];
        dp1[i] = (dp1[i] % mod + mod) % mod;
    }

    repi(i,6,N)
        dp[i] = (dp[i] + dp[i - 5]) % mod;
    repi(i,4,N)
        dp1[i] = (dp1[i] + dp1[i - 3]) % mod;
}

char line[N];

#define dump(x) cerr<<#x<<" = "<<(x)<<endl;

int solve()
{
    int len = strlen(line);
    line[--len] = '\0';

    ll ans = 1;
    for (int i = 0; i < len; ) {
        int next_i = i;
        while (next_i < len && line[next_i] == line[i])
            ++next_i;

        if (line[i] == '8' || line[i] == '0')
            ans = ans * dp1[next_i - i] % mod;
        else
            ans = ans * dp[next_i - i] % mod;
        i = next_i;
    }
    return (int) ans;
}

int main()
{
    gen();

    while (fgets(line, N, stdin), line[0] != '#')
        printf("%d\n", solve());

    return 0;
}

Measured memory_bytes: 4332
#include <algorithm>
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
#include <sstream>
#include <vector>
#include <stack>
#include <set>
#include <map>
#include <cmath>
#include <queue>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
using namespace std;
typedef long long int ll;



int main()
{
	ll X;
	cin>>X;
	ll ans1,ans2;
	for(ll a = 0; a <= 1000; a++){
		for(ll b = -1000; b <= 1000; b++){
			if( pow((double)a,5) - pow((double)b,5) == X){
				ans1 = a;
				ans2 = b;
				break;
			}
		}
	}
	cout<<ans1<<" "<<ans2<<endl;
	return 0;
}



Measured memory_bytes: 4116
#include <bits/stdc++.h>
using namespace std;
#define int long long
// #define endl '\n'

vector<int> zf(string s) {
    int n = (int)s.size();
    vector<int> z(n);
    int l = 0, r = 0;
    z[0] = 0;
    for (int i = 1; i < n; i++) {
        if (i <= r)
            z[i] = min(r - i + 1, z[i - l]);
        while (i + z[i] < n && s[i+z[i]] == s[z[i]]) z[i]++;
        if (i + z[i] - 1 > r) {
            l = i; r = i + z[i] - 1;
        }
    }
    return z;
}

vector<int> pf(string s) {
    int n = (int)s.size();
    vector<int> p(n);
    p[0] = 0;
    for (int i = 1; i < n; i++) {
        p[i] = p[i - 1];
        while (p[i] && s[p[i]] != s[i]) {
            p[i] = p[p[i] - 1];
        }
        if (s[p[i]] == s[i]) p[i]++;
    }
    return p;
}

int gcd(int a, int b) {
    if (b == 0) return a; return gcd(b, a % b);
}

pair<int, int> gcdex(int a, int b) {
    if (b == 0) {
        return make_pair(1, 0);
    }
    pair<int, int> v = gcdex(b, a % b);
    return make_pair(v.second, v.first - v.second * (a / b));
}

int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n; cin >> n;
    n *= 2;
    int ans = n - 1;
    for (int d = 2; d <= n / d; d++) {
        if (n % d == 0) {
            int nn = d, mm = n / d;
            if (gcd(nn, mm) == 1) {
                pair<int, int> a = gcdex(nn, mm);
                if (a.first < 0) {
                    ans = min(ans, mm * a.second - 1);
                }
                else {
                    ans = min(ans, nn * a.first - 1);
                }
            }
        }
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3660
#include <stdio.h>


// キューの構造体
typedef struct {
    char name[11];
    int time;
} Queue;


int main()
{
    //入力
    int n, q;
    scanf("%d%d", &n, &q);

    int size = 2 * n; //キューのサイズ
    Queue Queue[size];
    int pre = 0, rear = 0, cnt = 0; //pre:enqueue, rear:inqueue, cnt:経過時間
    for( rear = 0; rear < n; ++rear )
        scanf("%s %d", Queue[rear].name, &Queue[rear].time);


    //処理と出力
    while( pre != rear ){
        if( Queue[pre].time <= q ){ // if( Queue[pre].time == q ){ inqueueしない }
            cnt += Queue[pre].time;
            printf("%s %d\n", Queue[pre].name, cnt);
        } else {
            cnt += q;
            Queue[pre].time -= q;
            Queue[rear] = Queue[pre]; //inqueue
            rear = (rear + 1) % size; //次のinqueue先
        }

        //次のdequeue先
        pre = (pre + 1) % size;
    }


    return 0;
}

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

#ifdef LOCAL
#include "contest.h"
#else
#define error(args...) 
#endif

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
inline bool valid(int x, int w) { return 0 <= x && x < w; }

void iostream_init() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.setf(ios::fixed);
    cout.precision(12);
}
//}}}

int main(){
    iostream_init();
    const int MAX_N = 100001;
    int N;
    cin >> N;

    LL a[MAX_N];
    LL b[MAX_N];
    REP(i, N) cin >> a[i] >> b[i];

    LL sum = 0;
    LL ans = 0;
    for(int i = N-1; i >= 0; i--) {
        a[i] += sum;
        a[i] %= b[i];
        LL diff = 0;
        if(a[i] != 0) {
            diff = b[i] - a[i];
        } 
        ans += diff;
        sum += diff;
    }

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



Measured memory_bytes: 1920
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, l, r,sum = 0;
  cin >> N;
  for(int i = 0; i < N; i++){
    cin >> l >> r;
    sum += r - l + 1;
  }
  cout << sum << endl;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <stdio.h>
#include <vector>
#include <algorithm> // sort
#include <map>
using namespace std;

int main(){
    int a[3][3][2];
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            cin>>a[i][j][0];
            a[i][j][1]=0;
        }
    }
    int b;
    for(int k=0;k<10;k++){
        cin>>b;
        for(int i=0;i<3;i++){
             for(int j=0;j<3;j++){
                 if(b==a[i][j][0]){
                     a[i][j][1]=1;
                }
            }
        }
    }
    int c1=1;
    int c2=1;
    for(int i=0;i<3;i++){
        for(int j=0;j<3;j++){
            c1*=a[i][j][1];
            c2*=a[j][i][1];
        }
        if(c1+c2>0){
            cout<<"Yes"<<endl;
            return 0;
        }
        c1=1;
        c2=1;
    }
    if(a[0][0][1]*a[1][1][1]*a[2][2][1]+a[0][2][1]*a[1][1][1]*a[2][0][1]>0){
        cout<<"Yes"<<endl;
        return 0;
    }
    cout<<"No"<<endl;
}

Measured memory_bytes: 256
h, n = map(int, input().split())
li = list(map(int, input().split()))
li.sort(reverse=True)
ans = 'No'
for i in li:
  if n <= 0:
    break
  h = h - i
  n -= 1
if h <= 0:
  ans = 'Yes'
  
print(ans)

Measured memory_bytes: 52420
{-# LANGUAGE ScopedTypeVariables #-}
{-# LANGUAGE BangPatterns #-}

import Control.Applicative
import Control.Monad
import Control.Arrow
import Data.List
import Data.Maybe
import Data.Char
import qualified Data.ByteString.Char8 as B
import Text.Printf

readInt = ( readLn :: IO Int )
readInts = map ( read :: String -> Int ) . words <$> getLine

getList = map ( fst . fromJust . B.readInt ) . B.words <$> B.getLine

which a b f = if f then a else b
mp [ a, b ] = ( a, b )

main = do
	[ n, a, b ] <- readInts
	print $ sum $ filter ( inRange a b . digitSum ) $ [ 1 .. n ]

inRange a b k = a <= k && k <= b

digitSum = sum . map digitToInt . show


Measured memory_bytes: 1020
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>

using namespace std;

int main(void)
{
	string s;
	cin >> s;

	int k;
	cin >> k;

	int size = s.size();

	vector<string> list;

	for (int i = 0; i < size; i++)
	{
		string ss = { s[i] };
		list.push_back(ss);
		for (int j = i + 1; (j < i + k && j < size); j++)
		{
			ss += s[j];
			list.push_back(ss);
		}
	}

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

	string befor = list[0];
	for (int i = 1, j=1; i < k;j++)
	{
		if (befor != list[j])
		{
			i++;
			befor = list[j];
		}
	}

	cout << befor << endl;

	return 0;
}

Measured memory_bytes: 1660
import java.util.*;
public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String line = sc.nextLine();
        String[] linesp = line.split(" ");
        int n = Integer.parseInt(linesp[0]);
        int m = Integer.parseInt(linesp[1]);
        int l = Integer.parseInt(linesp[2]);
        long[][] A = new long[n][m];
        long[][] B = new long[m][l];
        long[][] C = new long[n][l];
        for(int i = 0; i < n; i++) {
            String line1 = sc.nextLine();
            String[] line1sp = line1.split(" ");
            for(int j = 0; j < m; j++) {
                A[i][j] = Integer.parseInt(line1sp[j]);
            }
        }
        
        for(int i = 0; i < m; i++) {
            String line2 = sc.nextLine();
            String[] line2sp = line2.split(" ");
            for(int j = 0; j < l; j++) {
                B[i][j] = Integer.parseInt(line2sp[j]);
            }
        }
        
        for(int i = 0; i < n; i++) {
            for(int j = 0; j < l; j++) {
                long sum = 0;
                for(int k = 0; k < m; k++) {
                    sum += A[i][k] * B[k][j];
                }
                C[i][j] = sum;
            }
        }
        
        for(int i = 0; i < n; i++) {
            for(int j = 0; j < l; j++) {
                System.out.print(C[i][j]);
                if(j != l - 1) {
                    System.out.print(" ");
                }
            }
            System.out.println("");
        }
  }
 }


Measured memory_bytes: 40580
#include<bits/stdc++.h>
// #include <ext/pb_ds/assoc_container.hpp>
// #include <ext/pb_ds/tree_policy.hpp>
 
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
#pragma GCC optimize("-ffloat-store")
 
#define int  long long
#define rep(i,begin,end) for(__typeof(end)i=(begin)-((begin)>(end));i!=(end)-((begin)>(end));i+=1-2*((begin)>(end)))
#define F first
#define S second
#define sz(x) ((int)x.size())
#define pb push_back
#define pf push_front
#define eb emplace_back
#define all(v) (v).begin(), (v).end()
#define mod 1000000007
#define what_is(x) cerr << #x << " is " << x <<"\n";
#define sortA(v) sort(v.begin(), v.end())
#define sortD(v) sort(v.rbegin(), v.rend())
#define PI 3.14159265358979323846
#define vout(a) for(auto x:a) cout<<x<<" ";
#define INF 10000000000000000 //1e16
 
// #define ordered_set tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
 
 
// using namespace __gnu_pbds;
using namespace std;
 
using ll  = long long;
using vi  = vector<int>;
using pii = pair<int,int>;
using vii = vector<pii>;
using mi  = multiset<int>;
using mii = multiset<pii>;
 
int lcm(int a,int b) {return (a*(b/__gcd(a,b)));}



void solve()
{
    int n,m,t,i,k,r,l,u,v,w,j,s,sum=0,flag=0,count=0;
    string S,T,U; 
    // int a,b,x,y,z,c;
    cin>>m>>n;
    while(n--) cin>>t,sum+=t;
    if(sum>=m)
    {
        cout<<"Yes";
        return;
    }
    cout<<"No";
}

 

signed main()
{
    #ifndef ONLINE_JUDGE 
       freopen("input.txt","r",stdin);
       freopen("output.txt","w",stdout);
    #endif
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--)
    {
        solve();
        if(t)cout<<"\n";
    }
    return 0;
}

Measured memory_bytes: 3640
#include<iostream>
#include<algorithm>
using namespace std;
int a;
int main(){
	while(cin>>a){
		int sum=0;
		for(int i=0;i<10;i++){
			for(int j=0;j<10;j++){
				for(int k=0;k<10;k++){
					for(int l=0;l<10;l++){
						if(i+j+k+l==a){
							sum++;
						}
					}
				}
			}
		}
		cout<<sum<<endl;
	}
	return 0;
}							


Measured memory_bytes: 3080
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main{

	public static void main(String[] args) throws IOException {
		// TODO Auto-generated method stub
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String line;
		while ((line = br.readLine()) != null) {
			int n = Integer.parseInt(line);
			System.out.println(f(n));
		}
	}
	
	public static int f(int n) {
		int ret = 0;
		
		for (int i = 0; i < 10; i++) {
			for (int j = 0; j < 10; j++) {
				for (int k = 0; k < 10; k++) {
					for (int l = 0; l < 10; l++) {
						if (i + j + k + l == n) ret++;
					}
				}
			}
		}
		
		return ret;
	}

}

Measured memory_bytes: 24828
def main():
    a, b, c, d, e, f = map(int, input().split())
    max_weight = f // 100
    best_water = a
    best_suger = 0
    best_density = 0
    is_ideal = False
    for water in range(a, max_weight + 1):
        max_a = water // a
        max_b = water // b
        is_exist = False

        for add_a in range(max_a):
            water_a = (add_a + 1) * a
            is_exist = water_a + (water - water_a) // b * b == water
            if is_exist:
                break

        if not is_exist:
            for add_b in range(max_b):
                water_b = (add_b + 1) * b
                is_exist = water_b + (water - water_b) // a * a == water
                if is_exist:
                    break

        if is_exist:
            max_suger = e * water
            remaining = min(f - water * 100, max_suger)
            max_c = remaining // c
            max_d = remaining // d

            for add_c in range(max_c):
                sugar_c = (add_c + 1) * c
                sugar = sugar_c + (remaining - sugar_c) // d * d
                density = sugar / (water + sugar)
                if density > best_density:
                    best_density = density
                    best_water = water
                    best_suger = sugar
                    is_ideal = sugar == max_suger
                    if is_ideal:
                        break

            if not is_ideal:
                for add_d in range(max_d):
                    sugar_d = (add_d + 1) * d
                    sugar = sugar_d + (remaining - sugar_d) // c * c
                    density = sugar / (water + sugar)
                    if density > best_density:
                        best_density = density
                        best_water = water
                        best_suger = sugar
                        is_ideal = sugar == max_suger
                        if is_ideal:
                            break
            if is_ideal:
                break

    print(f'{best_water * 100 + best_suger} {best_suger}')


if __name__ == '__main__':
    main()


Measured memory_bytes: 62268
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
void solve(){
    ll n,q;
    string s;
    cin>>n>>s>>q;
    vector<set<ll>> v(26);
    for(ll i=0;i<n;i++)
    v[ll(s[i]-'a')].insert(i);
    for(ll qc=0;qc<q;qc++){
        ll op;
        cin>>op;
        if(op==1){
            ll i;
            char c;
            cin>>i>>c;
            i--;
            v[ll(s[i]-'a')].erase(i);
            v[ll(c-'a')].insert(i);
            s[i]=c;
        }
        else{
            ll l,r,res=0;
            cin>>l>>r;
            l--;
            r--;
            for(ll i=0;i<26;i++)
            if(!v[i].empty()){
                auto it=v[i].lower_bound(l);
                if(it==v[i].end())
                continue;
                ll j=(*it);
                it=v[i].upper_bound(r);
                if(it==v[i].begin())
                continue;
                --it;
                if(j<=(*it))
                res++;
            }
            cout<<res<<endl;
        }
    }
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll t=1;
    for(ll qc=0;qc<t;qc++)
    solve();
}


Measured memory_bytes: 26268
#include<map>
#include<set>
#include<queue>
#include<cmath>
#include<cstdio>
#include<vector>
#include<string>
#include<cstring>
#include<iostream>
#include<algorithm>
#define lc (x<<1)
#define rc (x<<1|1)
#define gc getchar()//(p1==p2&&(p2=(p1=buf)+fread(buf,1,size,stdin),p1==p2)?EOF:*p1++)
#define mk make_pair
#define pi pair<int,int>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int N=1e6+10,size=1<<20;

//char buf[size],*p1=buf,*p2=buf;
template<class o> void qr(o &x) {
	char c=gc; x=0; int f=1;
	while(!isdigit(c)){if(c=='-')f=-1; c=gc;}
	while(isdigit(c)) x=x*10+c-'0',c=gc;
	x*=f;
}
template<class o> void qw(o x) {
	if(x/10) qw(x/10);
	putchar(x%10+'0');
}
template<class o> void pr1(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); putchar(' ');
}
template<class o> void pr2(o x) {
	if(x<0)x=-x,putchar('-');
	qw(x); puts("");
}

int n,ls,rs,flag;
char s[N];
vector<int> v[N];

int pos[N<<2],p,delta;

void upd(int &x,int y) {//y更新x的值 
	if(y==N-1) return ;
	if(x==N-1) x=y;
	else if(v[x].back()==0||-x+v[x].back()<-y+v[y].back()) x=y;
}

void bt(int x,int l,int r) {
	if(l==r) {
		if(v[l].size()) pos[x]=l;
		else pos[x]=N-1;
		return ;
	}
	int mid=(l+r)>>1;
	bt(lc,l,mid);
	bt(rc,mid+1,r);
	upd(pos[x]=pos[lc],pos[rc]);
}

void find(int x,int l,int r,int L,int R) {
	if(L<=l&&r<=R) {upd(p,pos[x]); return ;}
	int mid=(l+r)>>1;
	if(L<=mid) find(lc,l,mid,L,R);
	if(mid< R) find(rc,mid+1,r,L,R);
}

void del(int x,int l,int r) {
	if(l==r) {
		v[l].pop_back();
		if(v[l].size()) pos[x]=l;
		else pos[x]=N-1;
		return ;
	}
	int mid=(l+r)>>1;
	if(p<=mid) del(lc,l,mid);
	else del(rc,mid+1,r);
	upd(pos[x]=pos[lc],pos[rc]);
}

int main() {
	qr(n); 
	for(int i=1,l,r;i<=n;i++) {
		scanf("%s",s+1);l=r=0;
		for(int j=1;s[j];j++) 
			if(s[j]==')') {
				if(r) r--;
				else l++;
			}
			else r++;
		v[l].push_back(r);
		ls+=l; rs+=r;
		flag|=!l;
		flag|=(!r)*2;
	}
	if((ls^rs)||(flag^3)) puts("No"),exit(0);
	for(int i=0;i<=ls;i++) sort(v[i].begin(),v[i].end());
	bt(1,0,ls);
	for(int i=1,t=0;i<=n;i++) {
		p=N-1;
		find(1,0,ls,0,t);
		if(p==N-1) puts("No"),exit(0);
		t+=-p+v[p].back(); del(1,0,ls);
	}
	puts("Yes");
	return 0;
}
/*
4
((
)
())
(())

*/

Measured memory_bytes: 34416
#include <bits/stdc++.h>
using namespace std;
void dfs(vector<int> adj[],bool vis[],int src,int dp[])
{
    vis[src]=true;
    for(auto x:adj[src])
    {
        if(!vis[x])
        {
            dfs(adj,vis,x,dp);
        }
        dp[src]=max(dp[src],1+dp[x]);
    }
}
int main()
{
    int v,e;
    cin>>v>>e;
    vector<int>adj[v+1];
    int i,j,k;
    int dp[v+1];
    memset(dp,0,sizeof(dp));
    for(i=0;i<e;i++)
    {
        int x,y;
        cin>>x>>y;
        adj[x].push_back(y);
    }
    bool vis[v+1];
    memset(vis,false,sizeof(vis));
    for(i=1;i<=v;i++)
    {
        if(!vis[i])
        dfs(adj,vis,i,dp);
    }
    int ans=0;
    for(i=1;i<=v;i++)
    ans=max(ans,dp[i]);
    cout<<ans<<endl;
}

Measured memory_bytes: 12984
if __name__ == '__main__':
    while True:
        key_in = input()
        #data = key_in.split(' ')
        data = [int(x) for x in key_in.split(' ')]
        data.sort()

        if data[0] == 0 and data[1] == 0:
            break
        else:
            print('{0} {1}'.format(data[0], data[1]))

Measured memory_bytes: 7556
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int main() {
    int h, w;
    cin >> h >> w;
    vector<string> grid(h);
    for (int i = 0; i < h; ++i) {
        cin >> grid[i];
    }
    vector<string> temp;
    for (int i = 0; i < h; ++i) {
        bool flag = true;
        for (int j = 0; j < grid[i].size(); ++j) {
            if(grid[i][j] == '#')
            {
                flag = false;
            }
        }
        if(!flag)
        {
            temp.push_back(grid[i]);
        }
    }
    vector<string> temp2(temp.size(), "");
    for (int i = 0; i < w; ++i) {
        bool flag = true;
        for (int j = 0; j < temp.size(); ++j) {
            if(temp[j][i] == '#')
            {
                flag = false;
            }
        }
        if(!flag)
        {
            for (int j = 0; j < temp.size(); ++j) {
                temp2[j].push_back(temp[j][i]);
            }
        }
    }
    for (int i = 0; i < temp2.size(); ++i) {
        cout << temp2[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <iomanip>
#include <string>
#include <stack>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <iterator>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <regex>
#include <time.h>
#include <complex>
using namespace std;
using pii  = pair<int,int>;
using ll=long long;
using ld=long double;
#define pb push_back
#define mp make_pair
#define sc second
#define fr first
#define stpr setprecision
#define cYES cout<<"YES"<<endl
#define cNO cout<<"NO"<<endl
#define cYes cout<<"Yes"<<endl
#define cNo cout<<"No"<<endl
#define rep(i,n) for(ll i=0;i<(n);++i)
#define Rep(i,a,b) for(ll i=(a);i<(b);++i)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rRep(i,a,b) for(int i=a;i>=b;i--)
#define crep(i) for(char i='a';i<='z';++i)
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define ALL(x) (x).begin(),(x).end()
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl;
#define endl '\n'
int ctoi(const char c){
  if('0' <= c && c <= '9') return (c-'0');
  return -1;
}
ll gcd(ll a,ll b){return (b == 0 ? a : gcd(b, a%b));}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
constexpr ll MOD=1000000007;
constexpr ll INF=1000000011;
constexpr ll MOD2=998244353;
constexpr ll LINF = 1001002003004005006ll;
constexpr ld EPS=10e-8;
template <class T, class U> inline bool chmax(T& lhs, const U& rhs) { if (lhs < rhs) { lhs = rhs; return 1; } return 0; }
template <class T, class U> inline bool chmin(T& lhs, const U& rhs) { if (lhs > rhs) { lhs = rhs; return 1; } return 0; }
template<typename T> istream& operator>>(istream& is,vector<T>& v){for(auto&& x:v)is >> x;return is;}
template<typename T,typename U> istream& operator>>(istream& is, pair<T,U>& p){ is >> p.first; is >> p.second; return is;}
template<typename T,typename U> ostream& operator>>(ostream& os, const pair<T,U>& p){ os << p.first << ' ' << p.second; return os;}
template<class T> ostream& operator<<(ostream& os, vector<T>& v){
  for(auto i=begin(v); i != end(v); ++i){
    if(i !=begin(v)) os << ' ';
    os << *i;
  }
  return os;
}

ll A,B,C,D,E,F,G,H,K,L,M,N,P,Q,R,W,X,Y,Z;
string S,T;
vector<ll> V(100007);

int main(){
  cin >> N ;
  M=INF;
  rep(i,N){
    cin >> A;
    if(A<=M){
      C++;
    }
    M=min(A,M);
  }
  cout << C << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll, ll> P;
using VP = vector<P>;
using VVP = vector<VP>;
using VI = vector<ll>;
using VVI = vector<VI>;
using VVVI = vector<VVI>;
const int inf = 1e9 + 7;
const ll INF = 1LL << 61;
const ll mod = 1e9 + 7;

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

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

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int i, j;
    VI v(101010, 0);
    int n;
    cin >> n;
    ll sum = 0;
    for (i = 0; i < n; i++) {
        ll a;
        cin >> a;
        sum += a;
        v[a]++;
    }
    int q;
    cin >> q;
    while (q--) {
        int b, c;
        cin >> b >> c;
        sum += (c - b) * v[b];
        v[c] += v[b];
        v[b] = 0;
        cout << sum << endl;
    }
}

Measured memory_bytes: 3912
import java.util.Scanner;

//Lunch
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		System.out.println((Math.min(sc.nextInt(), Math.min(sc.nextInt(), sc.nextInt())))+Math.min(sc.nextInt(), sc.nextInt())-50);
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000
#include <cstdio>
#include <cstring>
#include <iostream>

using namespace std ;

typedef long long LL ;

const int N = 500010 ;

int n ;
LL f[N][4] ;


LL qr(){
    LL r = 0, f = 1 ;
    char c = getchar() ;
    while (!isdigit(c)){
        if (c == '-') f = -f ;
        c = getchar() ;
    }
    while (isdigit(c)){
        r = r * 10 + c - 48 ;
        c = getchar() ;
    }
    return r * f ;
}
int main(){
    cin >> n ; LL x ;
    f[0][1] = f[0][2] = -(1ll << 52) ;
    for (int i = 1 ; i <= n ; ++ i){
        x = qr() ;
        f[i][0] = x ;
        f[i][2] = x ;
        f[i][1] = -x ;
        f[i][2] += f[i - 1][2] ;
        f[i][1] += max(f[i - 1][1], f[i - 1][2]) ;
        f[i][0] += max(f[i - 1][0], max(f[i - 1][1], f[i - 1][2])) ;
        if (x < 0){
            f[i][2] = max(f[i][2], f[i][1]) ;
            f[i][1] = max(f[i][1], f[i][0]) ;
        }
    }
    cout << max(f[n][1], max(f[n][0], f[n][2])) << endl  ;
    return 0 ;
}



Measured memory_bytes: 4352
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];
    ll res = 0;
    rep(i, N) {
        res += A[i] / 2;
        if(A[i] % 2 == 1 && i != N - 1) {
            if(A[i + 1] != 0)
                A[i + 1]++;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1024
N, K = map(int, input().split())
A = list(map(int, input().split()))

ans1 = 0
ans2 = 0
for i in range(N):
    for j in range(i+1, N):
        if A[i] < A[j]:
            ans2 += 1
        elif A[i] > A[j]:
            ans1 += 1

ans = ans1*(K*(K+1))//2 + ans2 * (K*(K-1))//2
ans = ans % (10**9+7)

print(ans)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define debug(x) cerr<<#x<<": "<<x<<endl;
#define MOD 1000000007ULL;
#define rep(i,n) for(int i=0;i<n;i++)


int main() {
	ll x,y,z;
  	cin>>x>>y>>z;
  	
  
  	cout<<z<<" "<<x<<" "<<y<<endl;
}

Measured memory_bytes: 3552
#include<stdio.h>
int main(){
	int t='a'-'A';
	char s[201];
	fgets(s,201,stdin);
	for(int i=0;s[i]!='\0';i++)if(s[i] >= 97 && s[i] <=122)s[i]-=t;
	printf("%s",s);
return 0;
	}


Measured memory_bytes: 2548
#include<queue>
#include<cstdio>
#include<cstring>
#include<algorithm>
#define maxn 100005
#define LL long long
using namespace std;
LL ans;
int n,m;
priority_queue<int> hep;
inline int read(){
	int ret=0,f=1;char ch=getchar();
	while (ch<'0'||ch>'9'){if (ch=='-') f=-1;ch=getchar();}
	while (ch>='0'&&ch<='9') ret=ret*10+ch-'0',ch=getchar();
	return ret*f;
}
int main(){
	n=read();m=read();
	for (int i=1;i<=n;i++) hep.push(read());
	while (m--){
		int x=hep.top();hep.pop();
		hep.push(x/2);
	}
	while (n--) ans+=hep.top(),hep.pop();
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 892
import java.util.*;
import java.io.*;

public class Main {
    public static void main(String[] args){
        FastScanner fs = new FastScanner();
        PrintWriter pw = new PrintWriter(System.out);

        int a = fs.nextInt();
        int b = fs.nextInt();
        int k = fs.nextInt();
        int l = Math.min(a, b);
        int kk = 0;
        while(true){
            if(a % l == 0 && b % l == 0){
                kk++;
            }
            if(kk >= k){
                break;
            }
            l--;
        }
        pw.println(l);
        pw.flush();
    }

    static int gcd(int a, int b) {
        return b > 0 ? gcd(b, a % b) : a;
    }

    public static class FastScanner {
        BufferedReader br;
        StringTokenizer st;

        public FastScanner(Reader in) {
            br = new BufferedReader(in);
        }

        public FastScanner() {
            this(new InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String readNextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 20948
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  int A;
  int B;
  int C;
  cin >> N;

  A=N % 10;
  B=((N-A)/10)%10;
  C=(N-N%100)/100;
  
  if(A!=7&&B!=7&&C!=7){
    cout << "No" << endl;
  }else{
    cout << "Yes" << endl;
  }
}

Measured memory_bytes: 3620
import sys
from collections import Counter

n = int(input())
v_list = list(map(int, input().split()))
c_list = list(map(int, input().split()))
t_list = []
ans = 0

for i in range(n):
    t_list.append(v_list[i] - c_list[i])

for i in t_list:
    if i < 0:
        continue
    ans += i

print(ans)


Measured memory_bytes: 3444
n = int(input())
a = list(map(int, input().split()))
a.sort()

P = a[n-1]/2
S = 0
T = 0

for i in range(n):
    if a[i] > P:
        S = a[i-1]
        T = a[i]
        break


if abs(S-P) <= abs(T-P):
    print(a[n-1],S)
else:
    print(a[n-1],T)

Measured memory_bytes: 14428
def main():
    n = int(input())
    d_list = []
    for i in range(n):
        d_list.append(int(input()))

    d_dict = dict()
    for di in d_list:
        d_dict[str(di)] = 1


    print(len(d_dict))

if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
def root(x):
    if(group[x] == x):
        return(x)
    else:
        group[x] = root(group[x])
        return(group[x])


def unite(x, y):
    x = root(x)
    y = root(y)
    if(x == y):
        return

    if(rank[x] < rank[y]):
        group[x] = y
    else:
        group[y] = x
        if(rank[x] == rank[y]):
            rank[x] += 1


def same(x, y):
    return(root(x) == root(y))


N, M = map(int, input().split())
N_list = list(map(int, input().split()))
for i in range(N):
    N_list[i] -= 1

group = [i for i in range(N)]
rank = [0 for i in range(N)]

for i in range(M):
    x, y = map(int, input().split())
    x -= 1
    y -= 1
    unite(x, y)


ans = 0
for i in range(N):
    if(same(i, N_list[i]) is True):
        ans += 1
print(ans)

Measured memory_bytes: 14008
from collections import deque
N,u,v = map(int,input().split())
G = {i:[] for i in range(1,N+1)}
for _ in range(N-1):
    a,b = map(int,input().split())
    G[a].append(b)
    G[b].append(a)
distT = [0 for _ in range(N+1)]
heap = deque([(u,0)])
distT[u] = 0
hist = [0 for _ in range(N+1)]
hist[u] = 1
while heap:
    x,d = heap.popleft()
    for y in G[x]:
        if hist[y]==0:
            distT[y] = d+1
            heap.append((y,d+1))
            hist[y]=1
heap = deque([(v,0)])
distA = [0 for _ in range(N+1)]
heap = deque([(v,0)])
distA[v] = 0
hist = [0 for _ in range(N+1)]
hist[v] = 1
while heap:
    x,d = heap.popleft()
    for y in G[x]:
        if hist[y]==0:
            distA[y]=d+1
            heap.append((y,d+1))
            hist[y] = 1
cmax = 0
for i in range(1,N+1):
    if distT[i]<=distA[i] and distA[i]>cmax:
        cmax = distA[i]
print(cmax-1)

Measured memory_bytes: 103724
#include <stdio.h>

int main(){
 int S, h, m, s;
 scanf("%d\n", &S);
 h = S / 3600;
 m = S % 3600 / 60;
 s = S % 60;
 printf("%d:%d:%d\n", h, m, s);
 return 0;

}

Measured memory_bytes: 596
#include<stdio.h>
int main(void)
{
	int c,c1,c5,c10,c50,c100,c500;
	scanf("%d %d %d %d %d %d",&c1,&c5,&c10,&c50,&c100,&c500);
	c1*=1;
	c5*=5;
	c10*=10;
	c50*=50;
	c100*=100;
	c500*=500;
	c=c1+c5+c10+c50+c100+c500;
	if(c>=1000){
		printf("1\n");
	}
	else{
		printf("0\n");
	}
	return 0;
}

Measured memory_bytes: 1012
//organize and stay in moment - Abhinav IIIT-A
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define f(i,x,n) for(int i=x;i<n;++i)
#define ar array
#define MAXN (int)2e5+5
#define pb push_back
int mod= 998244353;
int arr[MAXN];
int as;
void input(){
  cin>>as;
  f(i,0,as) cin>>arr[i];
}
void q1(){
  string s; cin>>s;
  int a=0,b=0;
  f(i,0,3)
  s[i]=='A'  ? ++a : ++b;
  if(a&&b)
    cout<<"Yes";
  else cout<<"No";
}
void q2(){
  int n,a,b;
  cin>>n>>a>>b;
  int t=a+b;
  int q=n/t;
  int ans=q*a;
  int r=n%t;
  ans+=min(r,a);
  cout<<ans;
}
void q3(){
  int a,b; cin>>a>>b;
  for(int i=1;i<=100000;++i){
    int x=i*8; x/=100;
    int y=i*10; y/=100;
    if(x==a && y==b){
      cout<<i;
      return ;
    }
  }
  cout<<-1;
}
void q4(){
  string s; cin>>s;
  deque<int> q;
  f(i,0,s.size())
  q.push_back(s[i]);
  int Q; cin>>Q;
  int curr=0;
  while(Q--){
    int t;
    cin>>t;
    if(t==1){
      curr=1-curr;
    }else{
      // 0 0 begin
      //0 1 end
      //1 0 end
      //1 1 begin
      int f;char c; cin>>f>>c;
      if((f+curr)%2==0)
        q.push_front(c);
      else q.push_back(c);
    }
  }
  string ret="";
  while(!q.empty()){
    ret+=q.front();
    q.pop_front();
  }
  if(curr)
     reverse(ret.begin(),ret.end());
   cout<<ret;
   return ;
}
void q5(){
  int n,p; cin>>n>>p;
  string s; cin>>s;
  int ans=0;
  if(p==2){
    f(i,0,n)
    if((s[i]-'0')%2==0)
      ans+=i+1;
  }else if(p==5){
    f(i,0,n)
    if((s[i]-'0')%5==0)
      ans+=i+1;
  }else {
    int tt=1;
    int curr=0;
     map<int,int> mp;
     mp[0]++;
     for(int i=n-1;i>=0;--i){
        curr+=(s[i]-'0')*tt;
        tt*=10;
        tt%=p; curr%=p;
        ans+=mp[curr];
        ++mp[curr];
     }
  }
  cout<<ans;
}
int mod2=998244353;
void solve(){
 
}
int32_t main()
{
  int t; t=1; //cin>>t;
  while(t--) q1();
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <cmath>
#include <sstream>
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define FORD(i, a, b) for(int i = (a); i > (b); i--)
#define pb(a) push_back(a)
#define mp(a,b) make_pair(a,b)
typedef long long int ll;
using namespace std;
ll mod1=1000000007;
ll mod2=67280421310721;
ll mod3=998244353;
ll INF=1e18;
ll po(ll a,ll b)
{
	ll res=1;
	while(b)
	{
		if(b%2==1)
		{
			res*=a;
			res%=mod3;
		}
		a*=a;
		a%=mod3;
		b>>=1;
	}
	return res;
}
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int test=1;
//	cin>>test;
	while(test--)
	{
		int n;
		string s;
		cin>>n>>s;
		ll r=0,g=0,b=0;
		ll c=0;
		FOR(i,0,n)
		{
			if(s[i]=='R')
			r++;
			else if(s[i]=='G')
			g++;
			else
			b++;
			FOR(j,i+1,n)
			{
				if((2*j-i)<n)
				{
					if(s[i]!=s[j] && s[j]!=s[2*j-i] && s[i]!=s[2*j-i])
					c++;
				}
			}
		}
		cout<<r*g*b-c;
	}
	return 0;
}

Measured memory_bytes: 3660
#include <bits/stdc++.h>
#define rep(i,n)    for(long long i = 0; i < (n) ; ++i)
#define orep(i,n)   for(long long i = 1; i <= (n); ++i)   // one rep
#define drep(i,n)   for(long long i = (n)-1; i >= 0; --i) // down rep
#define srep(i,s,t) for(long long i = (s); i < (t); ++i)  // set rep
#define rng(x)  (x).begin(),(x).end()

  // range
#define rrng(a) (a).rbegin(),(a).rend() // reverse range
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define ru(x,y) (((x)+(y)-1)/(y)) // round up
#define fi first
#define se second
#define eb emplace_back
#define fcout cout << fixed << setprecision(15)


using namespace std;
using ll  = long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vvi = vector<vi>;
using vp  = vector<P>;
using vl  = vector<ll>;

template<typename T> void Yes(T flag) {
  cout << (flag ? "Yes" : "No") << endl;
}

template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}

template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}

template<typename T> void pv2(vector<vector<T>> vec) {
  for(auto& v : vec) pv(v);
}

int main() {
  int n;cin>>n;
  int zorome=0;
  rep(i,n) {
    int a,b;
    cin >> a >> b;
    if(a==b) zorome++;
    else zorome=0;
    if(zorome==3) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;

  return 0;
}



Measured memory_bytes: 3608
#include <stdio.h>
 
int main() {
  int H , W,i,j;
 
  while(1){
    scanf("%d %d",&H,&W);
    if(H == 0 && W == 0) {
      break;
    }
    for(j=1; j<=H; j++) {
      for(i=1; i<=W; i++) {
    printf("#");
      }
      printf("\n");
    }
    printf("\n");
  }
  return 0;
 
}



Measured memory_bytes: 2144
#include <bits/stdc++.h>
using namespace std;
using ll = long long int;
#define INF 10000000
#define rep(i,a,b) for(ll (i)=a;(i)<(ll)(b);(i)++)
using ipair = pair<int,int>;
using itpl = tuple<int,int>;


int main(){
    ll N,K;
    cin >> N >> K;
    vector<ll>A(N,0);
    rep(i,0,N) cin >> A[i];
    transform(A.begin(),A.end(),A.begin(),[](ll i){return i-1;});
    vector<ll> check(N,INF);
    check[0] = 0;
    ll now = 0,loop,pre,startIdx;

    while(1){
        if(check[A[now]]!=INF){
            loop = check[now]-check[A[now]]+1;
            pre = check[A[now]];
            startIdx = A[now];
            break;
        }
        //cout << now << " " << A[now] << endl;
        check[A[now]] = check[now]+1;
        now = A[now];
        if(check[now]==K){cout << now+1 <<endl; return 0;} 
    }
    //cout << loop << " " << pre << " " << startIdx << endl;
    ll res = (K-pre)%loop;
    ll ans = startIdx;
    while(1){
        if(res==0)break;
        ans = A[ans];
        res--;
    }
    cout << ans+1 << endl;

}

Measured memory_bytes: 6384
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            long n = long.Parse(Console.ReadLine());
            long[] pArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();
            long cnt = 0;
            for(int j = 0; j < n-2; j++)
            {
                if (pArray[j + 1] != Math.Min(pArray[j], Math.Min(pArray[j + 1], pArray[j + 2])) 
                    && pArray[j + 1] != Math.Max(pArray[j], Math.Max(pArray[j + 1], pArray[j + 2])))
                {
                    cnt++;
                }
            }
            Console.WriteLine(cnt);
        }
    }
}
// 文字列の入力
//string s = Console.ReadLine();

// 整数の入力
//long n = long.Parse(Console.ReadLine());

// 文字列配列の入力
//string[] inputStrArray = Console.ReadLine().Split(' ');

// 整数配列の入力
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();


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

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

  int s[m],c[m];

  rep(i,m) cin >> s[i] >> c[i];

  rep(i,m){
      if(c[i]==0){
          
          if(n!=1 && s[i]==1){
              
              cout << -1 << endl;
              return 0;
          }
          
      }

      
  }

  for(int i=0;i<m-1;i++){
      for(int j=i+1;j<m;j++){
          if(s[i]==s[j]){
              if(c[i]!=c[j]){
                  cout << -1 << endl;
                  return 0;
              }
          }
      }
  }


int ans[n];

rep(i,n) ans[i]=0;

rep(i,m){
   
    ans[s[i]-1] = c[i];

}

if(ans[0] == 0 && n!=1){
    cout << 1;
    for(int i=1;i<n;i++){
        cout << ans[i];
        
    }
    return 0;
}
    rep(i,n) cout << ans[i] ;
    
    



}

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

using namespace std;

const int oo = 1e9;

string s;
int res=oo;

int main() {
   // freopen("in.txt","r",stdin);
    ios_base::sync_with_stdio(0); cin.tie(0);
    cin>>s;
    string ns;
    for (int i=0;i<s.length();i++) {
        char ch = s[i];
        ns = s;
        //cout<<ch<<endl;
        for (int it=0;;it++) {
            //cout<<ns<<endl;
            if (ns.length()==0) break;
            if (ns.length()!=0) {
                bool ok = true;
                //cout<<(ok|(ns[1]==ch))<<endl;
                for (int j=0;j<ns.length();j++) ok &= (ns[j]==ch);
                if (ok) {
                    res = min(res,it);
                    break;
                }
            }
            string tmp="";
            for (int i=0;i<ns.length()-1;i++)
                if (ns[i]==ch || ns[i+1]==ch) tmp+=ch;
                else tmp+=ns[i];
            ns = tmp;
        }
    }
    cout<<res<<endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <math.h>
#include <string>
#include <string.h>
#include <stack>
#include <queue>
#include <vector>
#include <utility>
#include <set>
#include <map>
#include <stdlib.h>
#include <iomanip>

using namespace std;

#define ll long long
#define vi vector<int>
#define FOR(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define pb push_back
#define pi 3.14159265359


ll gcd(ll a, ll b)
{
	ll c;
	while (a != 0) {
		c = a; a = b % a;  b = c;
	}
	return b;
}

int main() {
	ll A, B, K;
	cin >> A >> B >> K;
	FOR(i,A, A + K) {
		if (i > B)break;
		cout << i << endl;
	}
	FOR(j,B-K+1, B+1) {
		if (j > A + K - 1) {
			cout << j << endl;
		}
	}
	cin >> A;

	return 0;


}

Measured memory_bytes: 256
#63c
N = int(input())

s_10_list = [0]
s_not_10_list = [0]

for i in range(N):
    s = int(input())
    if s%10 != 0:
        s_not_10_list.append(s)
    else:
        s_10_list.append(s)
        
s_not_10_list.sort(reverse=True)

#全組み合わせは2**100で地球爆発
#貪欲法的にやってみる。

ans = sum(s_10_list) + sum(s_not_10_list)

if ans%10 != 0:
    print(ans)
else:
    if len(s_not_10_list) != 1:
        ans -= s_not_10_list.pop(-2) #末尾は0なので、-2とする。
        print(ans)
    else:
        print(0)

Measured memory_bytes: 3064
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <queue>
#include <algorithm>
#include <utility>
#include <cmath>
#include <map>
#include <set>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;

#define INF_LL (ll)1e18
#define INF (int)1e9
#define REP(i, n) for(int i = 0;i < (n);i++)
#define FOR(i, a, b) for(int i = (a);i < (b);i++)
#define all(x) x.begin(),x.end()
using ll = long long;
using PII = pair<int, int>;

const double eps = 1e-10;

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

const ll mod = 1e9+7;

int main(void){
	ll N;
	ll dp[70][3] = {};
	cin >> N;
	ll a = 0;
	while(((ll)1 << a) <= N)
		a++;
	dp[0][0] = 1;
	FOR(i, 1, a+1){
		if((N >> (a-i)) & 1){
			dp[i][0] = dp[i-1][0];
			dp[i][1] = dp[i-1][0]+dp[i-1][1];
			dp[i][2] = dp[i-1][1]*2+dp[i-1][2]*3;
		}else{
			dp[i][0] = dp[i-1][0]+dp[i-1][1];
			dp[i][1] = dp[i-1][1];
			dp[i][2] = dp[i-1][2]*3+dp[i-1][1];
		}
		REP(j, 3){
			dp[i][j] = dp[i][j]%mod;
		}
	}
	cout << (dp[a][0]+dp[a][1]+dp[a][2])%mod << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
using namespace std;
static const double EPS = 1e-5;
typedef long long ll;
#define FOR(i,n) for(i=0;i<n;i++)
#define rep(i,n) for(int i=0;i<n;i++)

int main(){
	int n;
	for(;cin>>n;){
		int r=0;
		rep(a,10)rep(b,10)rep(c,10)rep(d,10)
			if(a+b+c+d==n)r++;
		cout<<r<<endl;
	}
	return 0;
}

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

using namespace std;

#define PB push_back
#define f first
#define s second

typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;

const int MOD = 1000000007;
const int INF = 1000000007;
const int MAXN = (int)3e5+1;

void setIO(string name)
{
	freopen((name+".in").c_str(),"r",stdin);
	freopen((name+".out").c_str(),"w",stdout);
}

int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    //setIO("");
    int x;
    cin >> x;
    cout << 1000*(x/500) + 5*((x%500)/5);

    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <functional>
#include <numeric>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <utility>
#include <sstream>
#include <complex>

using namespace std;

#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define REP(i,N) for(long long i=0;i<(N);i++)
#define ALL(s) (s).begin(),(s).end()
#define fi first
#define se second

#define PI acos(-1.0)
#define INF 1000000007
#define EPS 1e-10

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<double, double> PD;
typedef pair<string, ll> PS;
typedef vector<ll> V;

int a, b;

int gcd(int a, int b){
	if (b == 0)return a;

	return gcd(b, a%b);
}

int main(){
	while (cin >> a >> b){
		cout << gcd(a, b) << endl;
	}
}

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

void vprint(vector<ll> A){
    ll L = A.size();
    FOR(i, 0, L){
        if(i) cout << ' ';
        cout << A[i];
    }
    cout << endl;
}

ll sum = 0;
ll N;

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

    // input
    cin >> N;

    vector<ll> A(N);
    FOR(i, 0, N){
        cin >> A.at(i);
    }

    for(ll a : A){
        sum += a;
    }
    
    vector<ll> B(N);
    B[0] = 0;
    FOR(i, 1, N){
        B[i] = A[i-1] - B[i-1];
    }
    
    ll b_sum = 0;
    for(ll b : B){
        b_sum += b;
    }

    B[0] = sum/2 - b_sum;
    FOR(i, 1, N){
        B[i] = A[i-1] - B[i-1];
    }

    FOR(i, 0, N){
        if(i) cout << ' ';
        cout << 2*B[i];
    }
    cout << endl;

    
    return 0;
}

Measured memory_bytes: 2944