akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
using namespace std;

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

	vector<char> alph = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };

	int c_num, c_befo, last;

	vector<int> num(26, 0);

	if (s == "zyxwvutsrqponmlkjihgfedcba") {
		cout << -1 << endl;
		return 0;
	}
	else {
		for (int j = 0; j < s.length(); j++) {
			c_num = (int)s[j] - 'a';
			num[c_num] += 1;
		}

		if (s.length() < 26) {
			for (int k = 0; k < 26; k++) {
				if (num[k] == 0) {
					s = s + alph[k];
					cout << s << endl;
					return 0;
				}
			}
		}
		else {
			c_befo = (int)s[s.length() - 1] - 'a';
			for (int l = 0; l < 26; l++) {
				c_num = (int)s[s.length() - 1] - 'a';
				if (c_num >= c_befo) {
					num[c_num] -= 1;
					s.pop_back();
					c_befo = c_num;
				}
				else {
					c_num = (int)s[s.length() - 1] - 'a';
					s.pop_back();
					for (int m = 0; m < 26; m++) {
						if (num[m] == 0 && m > c_num) {
							s = s + alph[m];
							cout << s << endl;
							return 0;
						}
					}
				}
			}
		}
	}
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
typedef int long long ll;
using namespace std;
int const INF = 1000000;
int n;
vector<int> v;
bool dp[101][10001];

int main(){
    cin>>n;
    rep(i,n){
        int x;cin>>x;
        v.push_back(x);
    }
    dp[0][0]=true;
    rep(i,n){
        
        for(int j=10001;j>=0;j--){
            dp[i+1][j]=dp[i][j];
            if((j-v[i])>=0&&dp[i][j-v[i]]==true){
                dp[i+1][j]=true;
            }
            
        }
    }
  //  rep(i,101){cout<<dp[n][i];}
    for(int i=10000;i>=0;i--){
        if(dp[n][i]==true){
            if(i%10!=0){
                cout<<i<<endl;return 0;
            }
        }
    }
    cout<<0<<endl;
    
    return 0;
}


Measured memory_bytes: 1280
ii = lambda : int(input())
mi = lambda : map(int,input().split())
li = lambda : list(map(int,input().split()))

n = ii()
alis = li()

for i in range(1,n):
    alis[i] -= i

from collections import defaultdict as dl
d1 = dl(int)
d2 = dl(int)
for i in range(n):
    d1[alis[i]] += 1

ans = 0
ima = 0
for i in range(n-1):
    d2[alis[i]] += 1
    tmp = -(ima + alis[i])
    ans += d1[tmp] - d2[tmp]
    ima += 2
print(ans)


Measured memory_bytes: 84372
while True:
    n, x = map(int, input().split())
    if n == x == 0:
        break
    result = 0
    for a in range(1, x // 3):
        for b in range(a + 1, x // 2):
            c = x - a - b
            if b < c <= n:
                result += 1
    print(result)

Measured memory_bytes: 7656
#include <iostream>
#include <string>
#include <vector>
#include<algorithm>
#include <stdio.h>
#include <bitset>
#include<math.h>
#include<list>
#include<map>
using namespace std;
typedef long long ll;
#define PI 3.14159265358979323846  



int main() {
	int n, ans;
	cin >> n;
	ans = pow(n, 2);
	cout << ans << endl;

}

Measured memory_bytes: 256
//abc063_b.cpp
//Tue Oct 30 22:02:57 2018

#include <iostream>
#include <string>
#include <queue>
#include <unordered_map>
#include <vector>
#include <algorithm>
#include <math.h>
#define INTINF 2147483647
#define LLINF 9223372036854775807
using namespace std;
using ll=long long;
typedef pair<int,int> P;

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

	unordered_map<char, int> mp;
	int flag = 0;
	for (int i=0;i<s.size();i++){
		auto itr = mp.find(s[i]);
		if (itr != mp.end()){
			flag = 1;
			break;
		}else {
			mp[s[i]] = 1;
		}
	}

	if (flag == 1){
		cout << "no" << endl;
	}else {
		cout << "yes" << endl;
	}

}

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

int main(){
  string s; cin >> s;
  bool ok = false;
  if(s[0] == s[1] && s[2] == s[3] && s[0] != s[2])  ok = true;
  else if(s[0] == s[2] && s[1] == s[3] && s[0] != s[1])  ok = true;
  else if(s[0] == s[3] && s[1] == s[2] && s[0] != s[2])  ok = true;
  ok ? puts("Yes") : puts("No");
  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#pragma region include
#include <iostream>
#include <iomanip>
#include <stdio.h>

#include <sstream>
#include <algorithm>
#include <iterator>
#include <cmath>
#include <complex>

#include <string>
#include <cstring>
#include <vector>
#include <bitset>

#include <queue>
#include <set>
#include <map>
#include <stack>
#include <list>

#include <ctime>
////
//#include <random>//
#pragma endregion //#include
/////////

#pragma region typedef
typedef long long LL;
typedef long double LD;
typedef unsigned long long ULL;
#pragma endregion //typedef
////定数
const int INF = (int)1e9;
const LL MOD = (LL)1e9+7;
const LL LINF = (LL)4e18+20;
const LD PI = acos(-1.0);
const double EPS = 1e-9;
/////////
using namespace::std;

void solve(){
	int H,W;
	cin>>H>>W;
	vector< vector<int> > fld(H,vector<int>(W,0));
	vector< vector<bool> > fld2(H,vector<bool>(W,false));
	for(int h=0;h<H;++h){
		string str;
		cin>> str;
		for(int w=0;w<W;++w){
			if( str[w] == '#' ){
				fld[h][w] = 1;
				fld2[h][w] = true;
			}
		}
	}
	for(int h=0;h<H;++h){
		for(int w=0;w<W;++w){
			if( fld[h][w] == 1 ){
				if( w+1 < W ){
					if( fld[h][w+1] == 1 ){
						fld2[h][w] = false;
						fld2[h][w+1] = false;
					}
				}
				if( h+1 < H ){
					if( fld[h+1][w] == 1 ){
						fld2[h][w] = false;
						fld2[h+1][w] = false;
					}
				}
			}
		}
	}
	for(int h=0;h<H;++h){
		for(int w=0;w<W;++w){
			if( fld2[h][w] ){
				cout << "No" << endl;
				return;
			}
		}
	}
	cout << "Yes" << endl;
}

#pragma region main
signed main(void){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	std::cout << std::fixed;//小数を10進数表示
	cout << setprecision(16);//小数点以下の桁数を指定//coutとcerrで別	

	solve();
}
#pragma endregion //main()


Measured memory_bytes: 256
import bisect
import sys
import math
from collections import deque
from heapq import heappush, heappop

def sRaw():
    return input().rstrip("\r")


def iRaw():
    return int(input())


def ssRaw():
    return input().split()


def isRaw():
    return list(map(int, ssRaw()))


INF = 1 << 29

#DIV = (10**9) + 7
DIV = 998244353

def mod_inv_prime(a, mod=DIV):
    return pow(a, mod-2, mod)


def mod_inv(a, b):
    r = a
    w = b
    u = 1
    v = 0
    while w != 0:
        t = r//w
        r -= t*w
        r, w = w, r
        u -= t*v
        u, v = v, u
    return (u % b+b) % b


def CONV_TBL(max, mod=DIV):
    fac, finv, inv = [0]*max, [0]*max, [0]*max
    fac[0] = fac[1] = 1
    finv[0] = finv[1] = 1
    inv[1] = 1
    for i in range(2, max):
        fac[i] = fac[i-1]*i % mod
        inv[i] = mod - inv[mod % i] * (mod//i) % mod
        finv[i] = finv[i-1]*inv[i] % mod

    class CONV:
        def __init__(self):
            self.fac = fac
            self.finv = finv
            pass

        def ncr(self, n, k):
            if(n < k):
                return 0
            if(n < 0 or k < 0):
                return 0
            return fac[n]*(finv[k]*finv[n-k] % DIV) % DIV

    return CONV()


def cumsum(As):
    s = 0
    for a in As:
        s += a
        yield s


sys.setrecursionlimit(200005)


def dijkstra(G,start=0):
    heap = []
    cost = [INF]*len(G)
    heappush(heap,(0,start))
    while len(heap)!=0:
        c,n = heappop(heap)
        if cost[n] !=INF:
            continue
        cost[n]=c
        for e in G[n]:
            ec,v = e
            if cost[v]!=INF:
                continue
            heappush(heap,(ec+c,v))
    return cost


def main():
    N = iRaw()
    As = isRaw()
    As.sort(reverse=True)
    ans = As[0]
    n=2
    idx=1
    while n<N:
        ans+=As[idx]
        n+=1
        if n>=N:
            break
        ans+=As[idx]
        n+=1
        idx+=1
        if n>=N:
            break
    print(ans)
    
main()


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

int main()
{
    int A, B;
    cin >> A >> B;
    if((A+B)%2 == 1)
    {
        cout << "IMPOSSIBLE" << endl;
    }
    else
    {
        cout << (A+B)/2 << endl;
    }
    return 0;
}

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

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define REP(i,n) FOR(i,0,n)
using ll = long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using mii = map<int, int>;
using msi = map<string, int>;
using pii = pair<int, int>;

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

    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;

    int score = 0;
    REP(i, n - 1) if(s[i] == s[i+1]) score++;
    int ans = min(score + k * 2, n - 1);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 512
import Control.Monad
import Control.Applicative
import Data.Char

main :: IO ()
main = do
  is <- words <$> getLine
  print $ solve is

solve :: [String] -> Int
solve inputs = go [] inputs
  where
    go [acc] [] = acc
    go (x:y) (c:cs)
      | c == "+" = go (x+head y:drop 1 y) cs
      | c == "-" = go (head y-x:drop 1 y) cs
      | c == "*" = go (x*head y:drop 1 y) cs
      | otherwise = go ([read c :: Int, x] ++ y) cs
    go ns (c:cs) = go (read c : ns) cs

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

int main()
{
string s;
cin>>s;
ll sum=0;
for(ll i=0;i<s.length();i++)
{
  sum+=(s[i]-'0');
}
if(sum%9==0)
cout<<"Yes"<<endl;
else
cout<<"No"<<endl;


}


Measured memory_bytes: 3756
#include <iostream>
#include <cstring>
using namespace std;
#define MOD 1000000007

long powMod(long x, long n, long mod){
	if (n == 0) return 1;
	else if (n == 1) return (x % mod);
	else if (n % 2 == 0){
		long t = powMod(x, n/2, mod);
		return (t*t) % mod;
	}
	else{
		return (x*powMod(x, n-1, mod)) % mod;
	}
}

long divMod(long a, long b, long mod){
	long t = powMod(b, mod-2, mod);
	return (a*t) % mod;
}

long r1, r2, c1, c2;
long sr1_c, sr2_c, ans;

int main(){
    cin >> r1 >> c1 >> r2 >> c2;
    sr1_c = r1;
    sr2_c = r2 + 1;
    ans = 0;
    for (int c = 0; c < c2; ++c){
        sr1_c = divMod((sr1_c*(r1 + c + 1)) % MOD, c + 2, MOD);
        sr2_c = divMod((sr2_c*(r2 + c + 2)) % MOD, c + 2, MOD);
        if (c >= c1 - 1){
            ans = (ans + sr2_c) % MOD;
            ans = (ans - sr1_c + MOD) % MOD;
        }
    }
    cout << ans;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);

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

	int ans = -1;

	for(int r=0; r<(1<<n); r++) {

		int rev = 0;//反面的數量
		vector<int> v(n);
		for(int i=0; i<n; i++) {
			if(r&(1<<i)) v[i] = a[i];
			else v[i] = b[i], rev++;
		}
		if(rev&1) continue;

		vector<int> sorted(v);
		sort(sorted.begin(), sorted.end());

		vector<int> p(n, -1);
		for(int i=0; i<n; i++) {
			for(int j=0; j<n; j++) {
				if((i-j+2*n)%2 == ((r&(1<<j))?1:0)) continue;
				if(p[j]==-1 && v[j]==sorted[i]) {
					p[j] = i;
					break;
				}
			}
		}

		bool success = true;
		for(int i=0; i<n; i++) {
			if(p[i]==-1) {
				success = false;
				break;
			}
		}
		if(!success) continue;

		int cnt = 0;
		for(int i=0; i<n; i++) {
			for(int j=i+1; j<n; j++) {
				if(p[j]<p[i]) cnt++;
			}
		}
		ans = (ans==-1) ? cnt : min(ans, cnt);
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 384
#include<cstdio>
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
	int a[3];
		int ope=0;
		for(int i=0;i<3;i++)
			cin>>a[i];
			sort(a,a+3);
			int xc;
		xc=a[1]-a[0];
		if(xc%2==0)
		{
			ope+=(xc/2);
				ope+=a[2]-a[1];
		}
		else
		{
			ope+=(xc/2)+1;
			if(a[1]%2&&a[0]%2)
			{
				ope+=a[2]-a[1];
			}
			else
				ope+=a[2]-a[1]+1;
		}
		printf("%d\n",ope);
	return 0;
}

Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int L = sc.nextInt();
        sc.close();

        int[] appleAziArray = IntStream.rangeClosed(L, L + N - 1).toArray();

        int taberuAppleNoZettaiAzi = Arrays.stream(appleAziArray)
                .map(i -> {
                    if (i > 0)
                        return i;
                    else
                        return -i;
                })
                .min().orElse(0);

        int motomeruAzi = Arrays.stream(appleAziArray)
                .filter(i -> i != taberuAppleNoZettaiAzi)
                .filter(i -> i != -taberuAppleNoZettaiAzi)
                .sum();

        System.out.println(motomeruAzi);

    }
}


Measured memory_bytes: 28368
import sys
import math
import itertools


# \n
def input():
    return sys.stdin.readline().rstrip()


def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n ** 0.5 // 1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
                arr.append(i)

    if temp != 1:
        arr.append(temp)

    if arr == []:
        arr.append(n)
    return arr


def main():
    N = int(input())

    P = [0] * (N + 1)

    for i in range(1, N + 1):
        arr = factorization(i)
        for s in arr:
            P[s] += 1

    ans = 0
    PN = []
    for j in P:
        if j != 0:
            PN.append(j)

    ans = 0
    count = 0
    # 75**
    for i in PN:
        if i >= 74:
            count += 1
    ans += count

    count = 0
    # 25*3
    sub1 = 0
    sub2 = 0
    for i in PN:

        if i >= 24:
            sub1 += 1
        if i >= 2:
            sub2 += 1
    ans += sub1 * (sub2 - 1)

    # 15*5
    sub1 = 0
    sub2 = 0
    for i in PN:

        if i >= 14:
            sub1 += 1
        if i >= 4:
            sub2 += 1
    ans += sub1 * (sub2 - 1)

    # 5*5*3
    sub1 = 0
    sub2 = 0
    for i in PN:

        if i >= 4:
            sub1 += 1
        if i >= 2:
            sub2 += 1
    ans += sub1 * (sub1 - 1)*(sub2-2)//2


    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 9444
import java.util.Arrays;
import java.util.Scanner;
import java.util.regex.Matcher;

public class Main {
    static Scanner sc = new Scanner(System.in);

    public static void main(String[] args) {
        int a = sc.nextInt();
        int b = sc.nextInt();
        int m = sc.nextInt();
        int[] priceA = new int[a];
        int[] priceB = new int[b];
        int[][] kupon = new int[m][3];
        for (int i = 0; i< a ; i++ ){
            priceA[i] = sc.nextInt();
        }
        for (int i = 0; i< b ; i++ ){
            priceB[i] = sc.nextInt();
        }
        for (int i = 0; i<m; i++){
            for (int j = 0; j<3; j++){
                kupon[i][j] = sc.nextInt();
            }
        }

        int minValue = Integer.MAX_VALUE;
        int tempValue = 0;
        //先计算kupon的最优价格
        for (int i = 0; i<m; i++){
            tempValue = priceA[kupon[i][0]-1] + priceB[kupon[i][1]-1]-kupon[i][2];
            minValue = Math.min(minValue, tempValue);
        }

        int aMin = Arrays.stream(priceA).min().getAsInt();
        int bMin = Arrays.stream(priceB).min().getAsInt();
        
        minValue = Math.min(minValue, aMin+bMin);
        
        System.out.println(minValue);

    }
}

Measured memory_bytes: 161604
#include <numeric>
#include <stack>
#include <queue>
#include <random>
#include <unordered_set>
#include <unordered_map>
#include <iostream>
#include <sstream>
#include <vector>
#include <cstdio>
#include <map>
#include <set>
#include <functional>
#include <queue>
#include <string>
#include <bitset>
#include <cassert>
#include <cmath>
#include <algorithm>
#include <tuple>
#include <sstream>

using namespace std;

#define forn(a, e) for (int a = 0; a < (int)(e); a++)
#define forr(a, s, e) for (int a = s; a < (int)(e); a++)
#define fore(e, a) for (auto& e : a)

#ifdef LOCAL
#define logv(a) {cerr << #a << " = "; fore(e, a) {cerr << e << " ";} cerr << "\n";}
#define logvp(a) {cerr << #a << " = "; fore(e, a) {cerr << "(" << e.first << ", " << e.second << ") ";} cerr << "\n";}
#define logvv(a) {cerr << #a << " = \n"; fore(r, a) { fore(e, r) {cerr << e << " ";} cerr << "\n";} }
#define logvf(a, field) {cerr << #a"."#field << " = \n"; fore(e, a) { cerr << e.field << " ";} cerr << "\n"; }
#define logs(a) cerr << #a << " = " << (a) << "\n";
#define logss(a, b) cerr << #a << " = " << (a) << ", " << #b << " = " << (b) << "\n";
#define logp(a) cerr << #a << " = " << "(" << a.first << ", " << a.second << ")" << "\n";
#define cond(pred, stmt) if (pred) { stmt }
#else
#define logv(a)
#define logvp(a)
#define logvv(a)
#define logvf(a, field)
#define logs(a)
#define logss(a, b)
#define logp(a)
#define cond(pred, stmt)
#endif

using i64 = long long;
using iip = pair<int, int>;
using ivec = vector<int>;
using llvec = vector<i64>;
using svec = vector<string>;

template<typename T, typename Dim>
auto make_vec(T value, Dim dim) { return vector<T>(dim, value); }
template<typename T, typename Dim1, typename... Dim>
auto make_vec(T value, Dim1 dim1, Dim... dims) { return make_vec(make_vec(value, dims...), dim1); }

template<typename T>
bool uax(T& v, const T& newv) { if (v < newv) { v = newv; return true; } else return false; }
template<typename T>
bool uin(T& v, const T& newv) { if (v > newv) { v = newv; return true; } else return false; }

template<typename T>
istream& operator>>(istream& is, vector<T>& c) { for (auto& e : c) is >> e; return is; }

// template<typename ...T>
// istream& read(T&... args) { return (cin >> ... >> args); }

static mt19937 rande(123123);
template<typename T>
T rand_int(T from, T to) { uniform_int_distribution<T> distr(from, to); return distr(rande); }

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

    int n, k;
    while (cin >> n >> k) {
        int ans = 0;
        forn(i, n) {
            int h;
            cin >> h;
            if (h >= k) {
                ans++;
            }
        }
        cout << ans << endl;
    }
}


Measured memory_bytes: 256
#include "stdio.h"
#include "stdlib.h"

int comp( const void *c1, const void *c2 );

int main(void) {
  int N;
  int A[101];
  int Alice=0;
  int Bob=0;
  int Acnt=0;
  int Bcnt=0;
  int i, j, num;
  
  if( scanf("%d", &N) == 1);
  
  for(i=0; i < N; i++)
  {
        if( scanf("%d", &A[i]) == 1);
      
  }
  
  qsort( A, i, sizeof(int), comp );
  
  for(j=0; j < i; j++)
  {
      if(Acnt == Bcnt)
      {
        Alice = Alice + A[j];
        Acnt++;
      }
      else
      {
        Bob= Bob + A[j];
        Bcnt++;
      }
  }
  
  num = Alice - Bob;
  
  printf("%d\n", num);
  
  return 0;
}

/* 比較関数 */
int comp( const void *c1, const void *c2 )
{
  int tmp1 = *(int *)c1;
  int tmp2 = *(int *)c2;

  if( tmp1 > tmp2 )  return -1;
  if( tmp1 == tmp2 ) return  0;
  if( tmp1 < tmp2 )  return  1;
}


Measured memory_bytes: 128
import sys

input = sys.stdin.readline


def main():
    N = int(input())
    P = [None] * N
    for i in range(N):
        P[i] = int(input())

    dp = [0] * (N + 1)
    for p in P:
        dp[p] = dp[p - 1] + 1
    
    ans = N - max(dp)
    print(ans)


if __name__ == "__main__":
    main()


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

int selectionSort(int A[], int N) {
        int i, j, t, sw = 0, mini;
        for(i = 0; i < N; i++) {
                mini = i;
                for(j = i; j < N; j++) {
                        if(A[j] < A[mini]) mini = j;
                }
                t = A[i]; A[i] = A[mini]; A[mini] = t;
                if(i != mini) sw++;
        }
        return sw;
}

int main() {
        int A[100], N, i, sw;
        cin >> N;
        for(i = 0; i < N; i++) cin >> A[i];
        sw = selectionSort(A, N);
        for(int j = 0; j < N; j++) {
                if(j > 0) cout << " ";
                cout << A[j];
        }
        cout << endl;
        cout << sw << endl;
        return 0;
}

Measured memory_bytes: 3108
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <climits>

using namespace std;

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

typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;

#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,n-1)

const double EPS = 1e-10;
const double PI = acos(-1.0);

int main() {
	int n;
	vi num(100002, 0);

	cin >> n;

	int a, b;

	REP(i, n) {
		cin >> a >> b;

		FOR(j, a-1, b-1) {
			num[j]++;
		}
	}

	int ans = 0;
	FOR(i, 1, n) {
		if(i <= num[i]) {
			ans = i;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1536
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <iterator>
#include <map>
#include <queue>
#define mp make_pair
#define pb push_back
#define p push
#define FOR(a,c) for(int a = 0;a<c;a++)
#define FORR(el,vecc) for(auto& el:vecc)
#define ll long long int
#define abs(x) (x<0 ? (-x) : x)
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d %d",&a,&b)
#define getIII(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a,b) scanf("%lld %lld",&a,&b)
#define getLLL(a,b,c) scanf("%lld%lld%lld",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define BEND2(c) (c).begin(),(c).end(),greater<int>()
#define fi first
#define se second
#define PI 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfi(a) printf("%d",a);
#define pfii(a,b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a,b) printf("%lld%lld",a,b);
#define pfd(a) printf("%.6lf\n",a);
#define SIZE

#define sag (sol|1)
#define sol (root<<1)
#define ort (bas+son)/2
#define N (int)(1e5+10)


using namespace std;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<ll>> vvl;
typedef vector<long long> vl;
typedef vector<pair<int,int>> vpi;
typedef vector<pair<long long,long long>> vpl;
typedef vector<vector<pair<long long,long long>>> vvpl;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef pair <ll,ll> pll;
const  double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MX = 200005;

int main() {
    ll n ,k ;
    cin >> n;
    vi vec(n+1);
     ll sum = 0;
    for (int i = 1; i <=n ; ++i) {
        cin >> vec[i];
        sum +=vec[i];
    }
    int c =0;
    if ( sum % n > n/2)c=1;
    sum/=n;
    sum+=c;
    ll res= 0 ;
    for (int j = 1 ; j <=n ; ++j) {
        res+= abs((sum - vec[j]) * (sum - vec[j]));
    }

    cout  <<res;
    return 0;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		//
		// 入力
		//
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		char[] cArray = sc.next().toCharArray();

		//
		// 処理
		// WRを無くす最短操作を求める
		// 左からWを見つける
		// 見つかったら右からRを見つける（場所はセーブしておくこと）
		// WとRをswap
		// 操作数 countをインクリメント
		//
		// テスト
		// 3
		// RRR
		// 3
		// WWW
		// 6
		// RRRWWW
		// 6
		// WWWRRR
		// 8
		// WRWWRWRR
		// 9
		// RWWRWRRWW
		//
		int count = 0;
		int j_save = N - 1;
		outside: for(int i = 0; i < j_save; i++) {
			// 左からWを探す
			if(cArray[i] == 'W') {
				for(int j = j_save; j >= i; j--) { // あえてj=iを実施
					// 右からRを探す
					if(cArray[j] == 'R') {
						swap(cArray, i, j);
						count++;
						j_save = j;
						break;
					}

					if(j==i) {
						// 多重ループ抜ける
						break outside;
					}
				}
			}
		}

		System.out.println(count);
	}

	public static void swap(char[] cArray, int i, int j) {
		char tmp = cArray[i];
		cArray[i] = cArray[j];
		cArray[j] = tmp;
	}

}


Measured memory_bytes: 31788
<?php
  
fscanf(STDIN, "%d", $n);
$h = trim(fgets(STDIN));
$hi = array_map('intval', explode(' ', $h));

$isMono = true;
for ($i = $n - 1; $i > 1; $i--) {
	$isMono = ($hi[$i] >= $hi[$i - 1]) ?: ($hi[$i] >= --$hi[$i - 1]);
	if (!$isMono) break;
}

echo $isMono ? 'Yes': 'No';


Measured memory_bytes: 36412
// ALDS 1_3_D: Areas on the Cross-Section Diagram

// input: \\///\_/\/\\\\/_/\\///__\\\_\\/_\/_/\

fn main() {
    let mut s1 :Vec<usize> = Vec::new();
    let mut s2 :Vec<(usize, usize)> = Vec::new();

    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();

    let mut sum = 0;

    for (i, c) in s.chars().enumerate() {
        match c {
            '\\' => {
                s1.push(i);
            },
            '/' => {
                if s1.len() > 0 {
                    let j = s1.pop().unwrap();
                    let mut a = i - j;
                    sum += a;
                    while s2.len() > 0 {
                        let pair = s2.pop().unwrap();
                        let first = pair.0;
                        let second = pair.1;
                        if first <= j  {
                            s2.push(pair);
                            break;
                        }
                        a += second;
                    }
                    s2.push((j, a));
                }
            },
            _ => {
                // Do nothing.
            }
        }
    }

    let mut ans: Vec<usize> = Vec::new();
    while s2.len() > 0 {
        let pair = s2.pop().unwrap();
        let second = pair.1;
        ans.push(second);
    }
    ans.reverse();

    println!("{}", sum);
    print!("{}", ans.len());
    for a in &ans {
        print!(" {}", a);
    }
    println!();
}


Measured memory_bytes: 5024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define F first
#define S second
#define pb push_back
#define eb emplace_back
#define PI 3.14159265359
#define sz(c) (int)c.size()
#define len(c) (int)c.length()
#define hcf(a, b) __gcd(a, b)
#define all(c) c.begin(), c.end()
#define vint vector<int>
#define vll vector<ll>
#define vpint vector<pair<int, int>>
#define vpll vector<pair<ll, ll>>
#define fr(it, a, b) \
    for (int it = (a); it < (b); it++)
#define tr(con, it) \
    for (auto it = con.begin(); it != con.end(); it++)
#define present(con, ele) (con.find(ele) != con.end())
#define cpresent(con, ele) (find(all(con), ele) != con.end())
#define maximum(a, b, c) (a > b ? (a > c ? a : c) : (b > c ? b : c))
#define minimum(a, b, c) (a < b ? (a < c ? a : c) : (b < c ? b : c))
typedef long long ll;
typedef long double lf;
typedef pair<int, int> pi;
typedef unsigned long long lu;
const ll mod = 1e9 + 7;
int32_t main()
{
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int u, ans;
    fr(i, 1, 6)
    {
        cin >> u;
        if (u == 0)
        {
            ans = i;
        }
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, start, n) for (int i = (int)(start); i < (int)(n); ++i)
int A, B, C, D;
void func()
{
    cin >> A >> B >> C >> D;
    int a, b;
    a = (A % D == 0) ? A / D : A / D + 1;
    b = (C % B == 0) ? C / B : C / B + 1;
    if (a >= b)
        cout << "Yes" << endl;
    else
    {
        cout << "No" << endl;
    }
}
int main()
{
    func();
}

Measured memory_bytes: 3572
n, m = map(int, input().split())
maiz=[[] for _ in range(n)]
for _ in range(m):
    a,b=map(int,input().split())
    a-=1;b-=1
    maiz[a].append(b)
    maiz[b].append(a)
    

#=== 幅優先探索　開始 ===#
queue = [0] # スタート地点をキューに入れる
ans=[0]*n
visited =[0]*n
visited[0] = 1  # 訪問したかどうかをメモする
while queue:
    x= queue.pop(0)
     # 訪問済みにする
    # 次に訪れる場所　左上右下
    for y in maiz[x]:
        if visited[y]==0 :
            visited[y] = 1
            # 進行可能でまだ訪問していなければキューに入れてかかった手数を記録する
            queue.append(y)
            ans[y]=x
if min(visited)==0:
    print("No")
    exit()
else:
    print("Yes")
for i in range(1,n):
    print(ans[i]+1)

Measured memory_bytes: 34548
import itertools
from collections import deque,defaultdict,Counter
from itertools import accumulate
import bisect
from heapq import heappop,heappush
from fractions import gcd
from copy import deepcopy
import math
import queue
#import numpy as np
#import sympy as syp(素因数分解とか)
Mod = 1000000007
import sys

sys.setrecursionlimit(100000) 
  
def sieve_of_eratosthenes(n):
    if not isinstance(n,int):
        raise TypeError("n is not int")
    if n<2:
        raise ValueError("n is not effective")
    prime = [1]*(n+1)
    for i in range(2,int(math.sqrt(n))+1):
        if prime[i] == 1:
            for j in range(2*i,n+1):
                if j%i == 0:
                    prime[j] = 0
    res = []
    for i in range(2,n+1):
        if prime[i] == 1:
            res.append(i)
    return res

def factorial(i):
    if i == 1:
        return 1
    else:
        return i*factorial(i-1)
 
class UnionFind:
    def __init__(self,n):
        self.parent = [i for i in range(n+1)]
        self.rank = [0 for i in range(n+1)]
    
    def findroot(self,x):
        if x == self.parent[x]:
            return x
        else:
            y = self.parent[x]
            y = self.findroot(self.parent[x])
            return y
    
    def union(self,x,y):
        px = self.findroot(x)
        py = self.findroot(y)
        if px < py:
            self.parent[py] = px
        else:
            self.parent[px] = py
 
    def same_group_or_no(self,x,y):
        return self.findroot(x) == self.findroot(y)




def main(): #startline-------------------------------------------- 
    a,b = map(int,input().split())
    print(a*b//gcd(a,b))



if __name__ == "__main__":
    main() #endline===============================================
    

Measured memory_bytes: 5172
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#include"debug_deque.hpp"
#define vector DebugDeque
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(prints) FUNC(printe) FUNC(printw) FUNC(printew) FUNC(printb) FUNC(printd) FUNC(printde);
#endif
template <class S, class T>
istream& operator >> (istream& in, pair<S, T>& p){ in >> p.first >> p.second; return in; }
template <class T>
istream& operator >> (istream& in, vector<T>& v){ for(auto& e : v){ in >> e; } return in; }
template <char d = ' ', class T>
ostream& operator << (ostream& out, vector<T>& v){ for(auto& e : v){ out << e << d; } return out; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    uint n; cin >> n;
    if(n == 3){
        cout << 2 << ' ' << 5 << ' ' << 63 << '\n';
        return 0;
    }
    vector<int> anss({2, 3, 4, 9});
    if(n == 4){
        cout << anss << '\n';
        return 0;
    }
    int next = 6;
    while(anss.size() < n){
        if(next % 6 == 0){
            if(next > 30000){ break; }
            anss.push_back(next);
            next += 2;
        }else{
            if(next > 30000){ break; }
            anss.push_back(next);
            next += 2;
            if(next > 30000){ break; }
            anss.push_back(next);
            next += 2;
        }
    }
    next = 15;
    while(anss.size() < n){
        anss.push_back(next);
        next += 6;
        if(next > 30000){ break; }
        anss.push_back(next);
        next += 6;
    }
    if(anss.size() > n){
        anss.erase(anss.begin() + 4);
    }
    sort(anss.begin(), anss.end());
    cout << anss << '\n';
    set<int> s(anss.begin(), anss.end());
    int acc = accumulate(anss.begin(), anss.end(), 0ll);
    prints(anss.size(), s.size(), acc, acc % 6);
    for(int i = 1; i <= 30000; i++){
        if((i %  2 == 0 || i % 3 == 0) && !s.count(i)){
            printd(i);
        }
    }
}


Measured memory_bytes: 1408
//_nebula_
#include<bits/stdc++.h>
using namespace std;
#define int long  long
#define double long double
int t;
const int M=1e9+7;
int factt(int n)
{
    int ans=1;
    for(int i=1;i<=n;i++)
    {
        ans*=i;
        ans=ans%M;
    }
    return ans;
}
int max(int a,int b,int c)
{
    return max(a,max(b,c));
}
int min(int a,int b,int c)
{
    return min(a,min(b,c));
}
int fspow(int x,int y)
{
    int ans;
    if(y==0) return 1;
    ans=fspow(x, y/2);
    if(y%2==0) return (ans*ans);
    return x*ans*ans;
}
int gcd(int x,int y)
{
    if(x<y) swap(x,y);
    if(y==0) return x;
    return gcd(x%y,y);
}
int p2(int x)
{
    int ans=0;
    while(x>=1)
    {
        ans++;
        x/=2;
    }
    return ans;
}
signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    t=1;
    // freopen("input.txt","r",stdin);
    //freopen("output.txt","w",stdout);
    //cin>>t;
    // int tmp=t;
    while(t--)
    {
      int n,x,T;
      cin>>n>>x>>T;
      cout<<((n+x-1)/x)*T<<"\n";

    }
}


Measured memory_bytes: 3632
using System;
using System.Collections.Generic;
using System.Linq;

namespace CSharpSample01
{
    
    class Program
    {

        static bool Is_Prime(int n)
        {
            bool is_prime = true;

            for(int i = 2; i <= Math.Sqrt(n); i++)
            {
                if(n % i == 0)
                {
                    is_prime = false;
                    break;
                }
            }

            return is_prime;
        }
        
        static void Main(string[] args)
        {            

            while (true)
            {
                string[] input = Console.ReadLine().Split(' ');
                int a = int.Parse(input[0]);
                int b = int.Parse(input[1]);
                int n = int.Parse(input[2]);

                if(a == 0 && b == 0 && n == 0)
                {
                    break;
                }

                int ans = 0;
                int cnt = 0;
                int i = 0;

                while (true)
                {
                    int k = a + i * b;

                    if (Is_Prime(k) && k != 1)
                    {
                        cnt++;
                    }

                    if(cnt == n && k != 1)
                    {
                        ans = k;
                        break;
                    }
                    i++;
                }
                
                Console.WriteLine(ans);
                
            }
            
        }
    }
}


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

typedef long long ll;
typedef pair<int,int> P;
int dx[] = {-1, 1, 0,  0};
int dy[] = { 0, 0, 1, -1};
 
int main(){
  int n;
  cin  >> n;
  bool IsPrime[55556];
  for(int i=0; i<=55555; i++){
    IsPrime[i] = true;
  }
  IsPrime[0] = false;
  IsPrime[1] = false;
  for(int i=2; i<=55555; i++){
    if(IsPrime[i]){
      for(int j=2; j*i<=55555; j++){
        IsPrime[i*j] = false;
      }
    }
  }
  int cnt = 0;
  vector<int> ans;
  for(int i=1; i<=5555; i++){
    if(IsPrime[10*i+1]){
      cnt++;
      ans.push_back(10*i+1);
      if(cnt==n) break;
    }
  }
  cout << ans[0];
  for(int i=1; i<n; i++){
    cout << " " << ans[i];
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(100000000)

def main():
    N,M = map(int,input().split())
    e = [[] for i in range(N)]
    t = 0
    a = []
    for i in range(M):
        r,l,d = map(int,input().split())
        e[r-1].append((l-1,d))
        e[l-1].append((r-1,-d))
        a.append(r-1)
        a.append(l-1)
        t = r-1

    col = [ float("inf") for i in range(N) ]
    def dfs(i,c):
        for node in e[i]:
            if col[node[0]] == float("inf"):
                col[node[0]] = c + node[1]
                dfs(node[0],c+node[1])
            elif col[node[0]] != c + node[1]:
                print("No")
                exit()


    dfs(t,0)
    a = list(set(a))
    for i in a:
        if col[i] == float("inf"):
            dfs(i,0)


    print("Yes")


if __name__ == '__main__':
    main()


Measured memory_bytes: 153232
X, N = list(map(int, input().split()))

if N == 0:
  print(X)
  exit()

P = list(map(int, input().split()))
up_min = 0
low_min = 0

arr = [0] * 102
for i in P:
  arr[i] = 1
lower = arr[:X]
lower.reverse()
upper = arr[X:]
for i, num in enumerate(lower):
  if num == 0:
    low_min = len(lower) - 1 - i
    break
for i, num in enumerate(upper):
  if num == 0:
    up_min = len(lower) + i
    break

if abs(up_min - X) >= abs(X - low_min):
  print(low_min)
else:
  print(up_min)


Measured memory_bytes: 8968
use std::collections::BTreeSet;
use std::io::prelude::*;
use std::io::stdin;
use std::str::FromStr;

fn main() {
    let n: u64 = read();
    let m: u64 = read();
    let mut start = BTreeSet::new();
    let mut end = BTreeSet::new();

    for _ in 0..m {
        let a: u64 = read();
        let b: u64 = read();
        if a == 1 {
            start.insert(b);
        } else if b == n {
            end.insert(a);
        }
    }
    println!(
        "{}",
        if start.is_disjoint(&end) {
            "IMPOSSIBLE"
        } else {
            "POSSIBLE"
        }
    );
}

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


Measured memory_bytes: 6396
def solve(N, K, Hs):
    Hs.sort(reverse=True)
    ans = 0
    for h in Hs:
        if K > 0:
            K -= 1
        else:
            ans += h
    print(ans)


if __name__ == '__main__':
    N, K = map(int, input().split())
    Hs = [int(i) for i in input().split()]
    solve(N, K, Hs)


Measured memory_bytes: 26360
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <functional>
#include <climits>
#include <cstring>
#include <cmath>
#include <numeric>
#include <iomanip>

using namespace std;

#define int long long

#define rep(i, n) for (int i=0;i<(int)n;++i)
#define rep1(i, n) for (int i=1;i<=(int)n;++i)
#define rrep(i, n) for (int i=(int)n-1;i>=0;--i)
#define rrep1(i, n) for (int i=n;i>=1;--i)
#define range(i, l, r) for (int i=l;i<(int)r;++i)
#define rrange(i, l, r) for (int i=(int)r-1;i>=(int)l;--i)
#define unless(a) if(!(a))
#define all(a) begin(a),end(a)
#define fst first
#define scd second
#define PB emplace_back
#define PPB pop_back

using ll=long long;
using vi=vector<int>;
using pii=pair<int, int>;
using ld=long double;

bool chmin(int&a,int b){return a>b?(a=b,true):false;}
bool chmax(int&a,int b){return a<b?(a=b,true):false;}
constexpr int TEN(int n){return n==0?1:10*TEN(n-1);}

const int mod = TEN(9)+7;

string convert(int a)
{
	string ret = "";

	while (a) {
		ret.push_back(a % 10);
		a /= 10;
	}

	reverse(all(ret));

	return ret;
}

int S(int a)
{
	int ret = 0;

	while (a) ret += a % 10, a /= 10;

	return ret;
}

double f(int a)
{
	return (double)a / S(a);
}

void output(int a)
{
	printf("%lld: S(%lld) = %lld, f(%lld) = %f\n", a, a, S(a), a, f(a));
}

signed main()
{
	int N, x; cin >> N >> x;
	vi a(N);
	rep(i,N) cin>>a[i];
	int ans = 0;
	ans += max(a[0] - x, 0ll);
	chmin(a[0], x);

	range(i, 1, N) {
		if (a[i] + a[i - 1] > x) {
			// 0 <= x - a[i - 1]
			ans += max(a[i] - (x - a[i - 1]), 0ll);
			chmin(a[i], x - a[i - 1]);
		}
	}

	cout << ans << endl;
}




Measured memory_bytes: 1024
using System;
using System.Linq;
using System.Collections.Generic;

namespace program
{
    class Program
    {
        static void Main()
        {
          int[] a = Input.ScanIntArray();
          Console.WriteLine(a[0]*a[1]/2);
        }
    }

    static class Input
    {
        static public int ScanInt() { return int.Parse(Console.ReadLine()); }
        static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
        static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
        static public long ScanLong() { return long.Parse(Console.ReadLine()); }
        static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
        static public int[] ScanIntArray() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); }
        static public uint[] ScanUintArray() { return Console.ReadLine().Split(' ').Select(x => uint.Parse(x)).ToArray(); }
        static public double[] ScanDoubleArray() { return Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToArray(); }
        static public long[] ScanLongArray() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); }
        static public ulong[] ScanUlongArray() { return Console.ReadLine().Split(' ').Select(x => ulong.Parse(x)).ToArray(); }

        static public string ScanStr() { return Console.ReadLine(); }
        static public string[] ScanStrArray() { return ScanStr().Split(' '); }
    }

    static class MyMath
    {
        public static int GCD(int a, int b)
        {
            Func<int, int, int> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static ulong GCD(ulong a, ulong b)
        {
            Func<ulong, ulong, ulong> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static int LCM(int a, int b)
        {
            return a * b / GCD(a, b);
        }
        public static ulong LCM(ulong a, ulong b)
        {
            return a * b / GCD(a, b);
        }
    }
}


Measured memory_bytes: 11348
#include <bits/stdc++.h>
using namespace std;
int n,m,L;
int x[30];
int main(){
    scanf("%d",&L);
    while(L){
        x[++n]=L%2;
        m+=x[n];
        L/=2;
    }
    reverse(x+1,x+n+1);
    m+=2*(n-1)-1;
    printf("%d %d\n",n,m);
    for(int i=1;i<n;i++)
    {
    	printf("%d %d %d\n",i,i+1,0);
    	printf("%d %d %d\n",i,i+1,1<<(n-i-1));
	}
    int val=(1<<(n-1));
    for(int i=2;i<=n;i++)
	{
        if (!x[i])continue;
        printf("%d %d %d\n",1,i,val);
        val+=(1<<(n-i));
    }
    return 0;
}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
	var n int
	fmt.Scan(&n)

	ans := 0
	for i := 1; i <= n; i++ {
		if i%3 == 0 || i%5 == 0 {
			continue
		}
		ans += i
	}
	fmt.Println(ans)
}


Measured memory_bytes: 1756
#[allow(unused_imports)]
use std::cmp;
use std::io::Write;

// Input macro from https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, [ $t:tt ]) => {{
    let len = read_value!($iter, usize);
    (0..len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  }};

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn main() {
  let out = std::io::stdout();
  let mut out = std::io::BufWriter::new(out.lock());
  macro_rules! puts {
    ($($format:tt)*) => (write!(out,$($format)*).unwrap());
  }
  input! {
    x: i32,
    y: i32,
    z: i32,
  }

  puts!("{} {} {}\n", z, x, y);
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int X = sc.nextInt();
        int[] L = new int[N+1];
        for(int i = 0; i < N; i++){
            L[i] = sc.nextInt();
        }

        int x = 0;
        int count = 0;
        while(x <= X && count <= N){
            x += L[count];
            count++;
        }

        System.out.println(count);
    }
}

Measured memory_bytes: 22100
// Always have fun - aNONYMOUS //

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

#define IOS ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define ll long long
#define mod 1e9+7
#define inf 1e18
#define pb push_back
#define mp make_pair
#define vll vector<ll>

int main(){
	IOS;
	ll t,n,i,j,k,ans;
	t=1;//cin >> t;
	while(t--){
		ans=0;
		string s,t;
		cin >> s >> t;
		n=s.length();
		for(i=0;i<n;i++){
			if(s[i]==t[i])
				continue;
			else
				ans++;
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 3832
#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;
typedef pair<P, char> PC;

int f[10000];
int n, m, d[10000];

int main(){
	while (cin >> n >> m&&n + m){
		fill(f, f + 10000, 0);
		fill(d, d + 10000, 0);
		int sum = 1;
		FOR(i, 1, n + 1)cin >> f[i];
		REP(i, m)cin >> d[i];
		REP(i, m){
			sum += d[i];
			if (sum >= n){
				cout << i + 1 << endl;
				break;
			}
			//cout << '!' << sum << endl;
			sum += f[sum];
			if (sum >= n){
				cout << i + 1 << endl;
				break;
			}
			//cout << '!' << sum << endl;
		}
	}
}

Measured memory_bytes: 1232
#include <cstdio>
#include <array>
#include <algorithm>

std::array<int, 200005> d;
std::array<long long, 200005> ds;

long long min_max_diff(int l, int m, int r, int n)
{
    long long p1 = ds[l];
    long long p2 = ds[m] - ds[l];
    long long p3 = ds[r] - ds[m];
    long long p4 = ds[n] - ds[r];
    long long min = std::min(p1, std::min(p2, std::min(p3, p4)));
    long long max = std::max(p1, std::max(p2, std::max(p3, p4)));
    // printf("p1 = %lld p2 = %lld p3 = %lld p4 = %lld\n", p1, p2, p3, p4);
    return max - min;
}

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

    int l = 1, r = 3;
    long long ans = 1LL << 60, crnt, next;
    for (int m = 2; m < n - 1; ++m)
    {
        while(std::abs((ds[m] - ds[l]) - (ds[l] - ds[0])) > std::abs((ds[m] - ds[l + 1]) - (ds[l + 1] - ds[0])) && l < m)
        {
            l += 1;
        }

        while(std::abs((ds[n] - ds[r]) - (ds[r] - ds[m])) > std::abs((ds[n] - ds[r + 1]) - (ds[r + 1] - ds[m])) && r < n)
        {
            r += 1;
        }
        ans = std::min(ans, min_max_diff(l, m, r, n));
        // printf("m = %d l = %d r = %d ans = %lld\n", m, l, r, ans);
    }
    printf("%lld\n", ans);

    return 0;
}


Measured memory_bytes: 2560